diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-03-10 08:38:57 -0500 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2015-03-10 08:38:57 -0500 |
commit | 1955ebfb81ac498a86ccd50fd582ca8216a5fa56 (patch) | |
tree | 4ce1741c43f8f810ca55d64047aacc8104bc0fd1 /tests/hazmat/primitives/test_dsa.py | |
parent | d0109a59993ba568bb81a67a062dcfb460692447 (diff) | |
download | cryptography-1955ebfb81ac498a86ccd50fd582ca8216a5fa56.tar.gz cryptography-1955ebfb81ac498a86ccd50fd582ca8216a5fa56.tar.bz2 cryptography-1955ebfb81ac498a86ccd50fd582ca8216a5fa56.zip |
support DER serialization of public keys
Diffstat (limited to 'tests/hazmat/primitives/test_dsa.py')
-rw-r--r-- | tests/hazmat/primitives/test_dsa.py | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/hazmat/primitives/test_dsa.py b/tests/hazmat/primitives/test_dsa.py index 112818f4..d699b7c6 100644 --- a/tests/hazmat/primitives/test_dsa.py +++ b/tests/hazmat/primitives/test_dsa.py @@ -944,16 +944,33 @@ class TestDSASerialization(object): @pytest.mark.requires_backend_interface(interface=DSABackend) @pytest.mark.requires_backend_interface(interface=PEMSerializationBackend) class TestDSAPEMPublicKeySerialization(object): - def test_public_bytes_unencrypted_pem(self, backend): + @pytest.mark.parametrize( + ("key_path", "loader_func", "encoding"), + [ + ( + os.path.join("asymmetric", "PKCS8", "unenc-dsa-pkcs8.pub.pem"), + serialization.load_pem_public_key, + serialization.Encoding.PEM, + ), ( + os.path.join( + "asymmetric", + "DER_Serialization", + "unenc-dsa-pkcs8.pub.der" + ), + serialization.load_der_public_key, + serialization.Encoding.DER, + ) + ] + ) + def test_public_bytes_match(self, key_path, loader_func, encoding, + backend): key_bytes = load_vectors_from_file( - os.path.join("asymmetric", "PKCS8", "unenc-dsa-pkcs8.pub.pem"), - lambda pemfile: pemfile.read().encode() + key_path, lambda pemfile: pemfile.read(), mode="rb" ) - key = serialization.load_pem_public_key(key_bytes, backend) + key = loader_func(key_bytes, backend) _skip_if_no_serialization(key, backend) serialized = key.public_bytes( - serialization.Encoding.PEM, - serialization.PublicFormat.SubjectPublicKeyInfo, + encoding, serialization.PublicFormat.SubjectPublicKeyInfo, ) assert serialized == key_bytes |