diff options
author | michael-hart <michael.hart1994@gmail.com> | 2014-09-23 23:10:32 +0100 |
---|---|---|
committer | michael-hart <michael.hart1994@gmail.com> | 2014-09-25 22:37:08 +0100 |
commit | a3204baf9bcfd2288d049c4f27e75c535b4397ed (patch) | |
tree | edd261144a3b6950618d9d5156df33c61796f9f4 /tests | |
parent | d31446085ba34f5bacf2631c8adab1ab491bee2e (diff) | |
download | cryptography-a3204baf9bcfd2288d049c4f27e75c535b4397ed.tar.gz cryptography-a3204baf9bcfd2288d049c4f27e75c535b4397ed.tar.bz2 cryptography-a3204baf9bcfd2288d049c4f27e75c535b4397ed.zip |
Part 1 of rebase, with corrections for pep8
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/primitives/test_serialization.py | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py index d369e8f4..4bc7e811 100644 --- a/tests/hazmat/primitives/test_serialization.py +++ b/tests/hazmat/primitives/test_serialization.py @@ -24,6 +24,7 @@ from cryptography.hazmat.primitives import interfaces from cryptography.hazmat.primitives.asymmetric import ec from cryptography.hazmat.primitives.serialization import ( load_pem_pkcs8_private_key, load_pem_private_key, + load_pem_public_key, load_pem_traditional_openssl_private_key ) @@ -38,7 +39,7 @@ class TestPEMSerialization(object): def test_load_pem_rsa_private_key(self, backend): key = load_vectors_from_file( os.path.join( - "asymmetric", "Traditional_OpenSSL_Serialization", "key1.pem"), + "asymmetric", "PEM_Serialization", "rsa_private_key.pem"), lambda pemfile: load_pem_private_key( pemfile.read().encode(), b"123456", backend ) @@ -49,6 +50,17 @@ class TestPEMSerialization(object): if isinstance(key, interfaces.RSAPrivateKeyWithNumbers): _check_rsa_private_numbers(key.private_numbers()) + def test_load_dsa_private_key(self, backend): + key = load_vectors_from_file( + os.path.join( + "asymmetric", "PEM_Serialization", "dsa_private_key.pem"), + lambda pemfile: load_pem_private_key( + pemfile.read().encode(), b"123456", backend + ) + ) + assert key + assert isinstance(key, interfaces.DSAPrivateKey) + @pytest.mark.parametrize( ("key_file", "password"), [ @@ -70,6 +82,28 @@ class TestPEMSerialization(object): assert key assert isinstance(key, interfaces.EllipticCurvePrivateKey) + def test_load_pem_rsa_public_key(self, backend): + key = load_vectors_from_file( + os.path.join( + "asymmetric", "PEM_Serialization", "rsa_public_key.pem"), + lambda pemfile: load_pem_public_key( + pemfile.read().encode(), backend + ) + ) + assert key + assert isinstance(key, interfaces.RSAPublicKey) + + def test_load_pem_dsa_public_key(self, backend): + key = load_vectors_from_file( + os.path.join( + "asymmetric", "PEM_Serialization", "dsa_public_key.pem"), + lambda pemfile: load_pem_public_key( + pemfile.read().encode(), backend + ) + ) + assert key + assert isinstance(key, interfaces.DSAPublicKey) + @pytest.mark.traditional_openssl_serialization class TestTraditionalOpenSSLSerialization(object): |