Skip to content

Commit

Permalink
empty EKU test vector
Browse files Browse the repository at this point in the history
Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw committed Aug 2, 2024
1 parent 3970d90 commit 2726ee7
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/development/test-vectors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,8 @@ Custom X.509 Vectors
algorithm parameters. This encoding is invalid, but was generated by Java 20.
* ``ekucrit-testuser-cert.pem`` - A leaf certificate containing a critical EKU.
This is an invalid certificate per CA/B 7.1.2.7.6.
* ``empty-eku.pem`` - A leaf certificate containing an empty EKU extension.
This is an invalid certifcate per :rfc:`5280` 4.2.1.12.

Custom X.509 Request Vectors
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down
10 changes: 10 additions & 0 deletions tests/x509/test_x509.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from cryptography.hazmat.primitives.asymmetric.utils import (
decode_dss_signature,
)
from cryptography.x509.extensions import ExtendedKeyUsage
from cryptography.x509.name import _ASN1Type
from cryptography.x509.oid import (
AuthorityInformationAccessOID,
Expand Down Expand Up @@ -5733,6 +5734,15 @@ def test_bad_time_in_validity(self, backend):
x509.load_pem_x509_certificate,
)

def test_invalid_empty_eku(self, backend):
cert = _load_cert(
os.path.join("x509", "custom", "empty-eku.pem"),
x509.load_pem_x509_certificate,
)

with pytest.raises(ValueError, match="InvalidSize"):
cert.extensions.get_extension_for_class(ExtendedKeyUsage)


class TestNameAttribute:
EXPECTED_TYPES: typing.ClassVar[
Expand Down
11 changes: 11 additions & 0 deletions vectors/cryptography_vectors/x509/custom/empty-eku.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----BEGIN CERTIFICATE-----
MIIBpjCCAUygAwIBAgIUXbgOb3WRImMh6PjbldAK3smepIkwCgYIKoZIzj0EAwIw
GjEYMBYGA1UEAwwPeDUwOS1saW1iby1yb290MCAXDTcwMDEwMTAwMDAwMVoYDzI5
NjkwNTAzMDAwMDAxWjAWMRQwEgYDVQQDDAtleGFtcGxlLmNvbTBZMBMGByqGSM49
AgEGCCqGSM49AwEHA0IABM3LPV6xuBpFrGXEPvnjF2VnXwhfqYbfIrWUSVQFf6Eb
TiPFZH96VPllxT176ftzTAHWMSG0oCdEduz2MFR0nqWjcjBwMB0GA1UdDgQWBBS+
VOamU8j9i+62OkrB1PsJXEHTpTAfBgNVHSMEGDAWgBTrOA5ME/MKp4PpBUmEBQ6U
vTpcWjALBgNVHQ8EBAMCB4AwCQYDVR0lBAIwADAWBgNVHREEDzANggtleGFtcGxl
LmNvbTAKBggqhkjOPQQDAgNIADBFAiEAq8/MoJb/PyG710O0o/dAXYvsCbQgNNvg
CAcF/8JQGxUCIEJgYI2pX8slVoRke9RDDMKzNQ49qkKOd++v2tTb+rbh
-----END CERTIFICATE-----

0 comments on commit 2726ee7

Please sign in to comment.