Skip to content

Commit f3612c8

Browse files
authored
name constraint vector with invalid IPv4 netmask (pyca#6114)
1 parent 7a06e8a commit f3612c8

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

docs/development/test-vectors.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,10 @@ Custom X.509 Vectors
374374
* ``nc_invalid_ip_netmask.pem`` - An RSA 2048 bit self-signed certificate
375375
containing a name constraints extension with a permitted element that has an
376376
``IPv6`` IP and an invalid network mask.
377+
* ``nc_invalid_ip4_netmask.der`` - An RSA 2048 bit self-signed certificate
378+
containing a name constraints extension with a permitted element that has an
379+
``IPv4`` IP and an invalid network mask. The signature on this certificate
380+
is invalid.
377381
* ``nc_single_ip_netmask.pem`` - An RSA 2048 bit self-signed certificate
378382
containing a name constraints extension with a permitted element that has two
379383
IPs with ``/32`` and ``/128`` network masks.

tests/x509/test_x509_ext.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3580,7 +3580,7 @@ def test_ip_invalid_length(self, backend):
35803580
ExtensionOID.NAME_CONSTRAINTS
35813581
)
35823582

3583-
def test_invalid_netmask(self, backend):
3583+
def test_invalid_ipv6_netmask(self, backend):
35843584
cert = _load_cert(
35853585
os.path.join("x509", "custom", "nc_invalid_ip_netmask.pem"),
35863586
x509.load_pem_x509_certificate,
@@ -3591,6 +3591,17 @@ def test_invalid_netmask(self, backend):
35913591
ExtensionOID.NAME_CONSTRAINTS
35923592
)
35933593

3594+
def test_invalid_ipv4_netmask(self, backend):
3595+
cert = _load_cert(
3596+
os.path.join("x509", "custom", "nc_invalid_ip4_netmask.der"),
3597+
x509.load_der_x509_certificate,
3598+
backend,
3599+
)
3600+
with pytest.raises(ValueError):
3601+
cert.extensions.get_extension_for_oid(
3602+
ExtensionOID.NAME_CONSTRAINTS
3603+
)
3604+
35943605
def test_certbuilder(self, backend):
35953606
permitted = [
35963607
".example.org",
733 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)