From 16d3ae1b8e96b4c112c0f17911b5d14f0ed20385 Mon Sep 17 00:00:00 2001 From: Marko Kreen Date: Thu, 17 Oct 2019 04:07:56 +0300 Subject: UniversalString needs to be encoded as UCS-4 (#5000) --- tests/x509/test_x509.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/x509/test_x509.py b/tests/x509/test_x509.py index 07a6019b..fa3a41a7 100644 --- a/tests/x509/test_x509.py +++ b/tests/x509/test_x509.py @@ -4602,6 +4602,23 @@ class TestName(object): b"7000680079002e0069006f310d300b060355040a0c0450794341" ) + @pytest.mark.requires_backend_interface(interface=X509Backend) + def test_universalstring_bytes(self, backend): + # UniversalString is UCS-4 + name = x509.Name([ + x509.NameAttribute( + NameOID.COMMON_NAME, + u'cryptography.io', + _ASN1Type.UniversalString + ), + x509.NameAttribute(NameOID.ORGANIZATION_NAME, u'PyCA'), + ]) + assert name.public_bytes(backend) == binascii.unhexlify( + b"30563145304306035504031c3c00000063000000720000007900000070000000" + b"740000006f000000670000007200000061000000700000006800000079000000" + b"2e000000690000006f310d300b060355040a0c0450794341" + ) + @pytest.mark.supported( only_if=lambda backend: backend.ed25519_supported(), -- cgit v1.2.3