diff --git a/docs/x509/reference.rst b/docs/x509/reference.rst index 29c1502cc85d96985c8a51aca2a194cd596938c9_ZG9jcy94NTA5L3JlZmVyZW5jZS5yc3Q=..3eb646a602954ab5438d1ba6788bbf13b2e8ee6a_ZG9jcy94NTA5L3JlZmVyZW5jZS5yc3Q= 100644 --- a/docs/x509/reference.rst +++ b/docs/x509/reference.rst @@ -2874,6 +2874,12 @@ Corresponds to the dotted string ``"2.5.4.17"``. + .. attribute:: UNSTRUCTURED_NAME + + .. versionadded:: 3.0 + + Corresponds to the dotted string ``"1.2.840.113549.1.9.2"``. + .. class:: SignatureAlgorithmOID @@ -3235,6 +3241,10 @@ Corresponds to the dotted string ``"1.2.840.113549.1.9.7"``. + .. attribute:: UNSTRUCTURED_NAME + + Corresponds to the dotted string ``"1.2.840.113549.1.9.2"``. + Helper Functions ~~~~~~~~~~~~~~~~ .. currentmodule:: cryptography.x509 diff --git a/src/cryptography/x509/oid.py b/src/cryptography/x509/oid.py index 29c1502cc85d96985c8a51aca2a194cd596938c9_c3JjL2NyeXB0b2dyYXBoeS94NTA5L29pZC5weQ==..3eb646a602954ab5438d1ba6788bbf13b2e8ee6a_c3JjL2NyeXB0b2dyYXBoeS94NTA5L29pZC5weQ== 100644 --- a/src/cryptography/x509/oid.py +++ b/src/cryptography/x509/oid.py @@ -82,6 +82,7 @@ INN = ObjectIdentifier("1.2.643.3.131.1.1") OGRN = ObjectIdentifier("1.2.643.100.1") SNILS = ObjectIdentifier("1.2.643.100.3") + UNSTRUCTURED_NAME = ObjectIdentifier("1.2.840.113549.1.9.2") class SignatureAlgorithmOID(object): @@ -164,6 +165,7 @@ class AttributeOID(object): CHALLENGE_PASSWORD = ObjectIdentifier("1.2.840.113549.1.9.7") + UNSTRUCTURED_NAME = ObjectIdentifier("1.2.840.113549.1.9.2") _OID_NAMES = { @@ -196,6 +198,7 @@ NameOID.INN: "INN", NameOID.OGRN: "OGRN", NameOID.SNILS: "SNILS", + NameOID.UNSTRUCTURED_NAME: "unstructuredName", SignatureAlgorithmOID.RSA_WITH_MD5: "md5WithRSAEncryption", SignatureAlgorithmOID.RSA_WITH_SHA1: "sha1WithRSAEncryption", diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index 29c1502cc85d96985c8a51aca2a194cd596938c9_dGVzdHMveDUwOS90ZXN0X3g1MDkucHk=..3eb646a602954ab5438d1ba6788bbf13b2e8ee6a_dGVzdHMveDUwOS90ZXN0X3g1MDkucHk= 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -1232,7 +1232,7 @@ assert isinstance(extensions, x509.Extensions) assert list(extensions) == [] - def test_get_attribute_for_oid(self, backend): + def test_get_attribute_for_oid_challenge(self, backend): request = _load_cert( os.path.join( "x509", "requests", "challenge.pem" @@ -1242,6 +1242,19 @@ x509.oid.AttributeOID.CHALLENGE_PASSWORD ) == b"challenge me!" + def test_get_attribute_for_oid_multiple(self, backend): + request = _load_cert( + os.path.join( + "x509", "requests", "challenge-unstructured.pem" + ), x509.load_pem_x509_csr, backend + ) + assert request.get_attribute_for_oid( + x509.oid.AttributeOID.CHALLENGE_PASSWORD + ) == b"beauty" + assert request.get_attribute_for_oid( + x509.oid.AttributeOID.UNSTRUCTURED_NAME + ) == b"an unstructured field" + def test_invalid_attribute_for_oid(self, backend): """ This test deliberately triggers a ValueError because to parse