aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/primitives/test_serialization.py
diff options
context:
space:
mode:
authormichael-hart <michael.hart1994@gmail.com>2014-09-26 00:32:25 +0100
committermichael-hart <michael.hart1994@gmail.com>2014-09-26 18:40:28 +0100
commit254811fd619188610298485a66885784944c1de8 (patch)
tree0e5cabb33f221649e12de0a39fed9f2385d156d2 /tests/hazmat/primitives/test_serialization.py
parent2ca899115b80dba47b65a8255bbbce1cce2ce238 (diff)
downloadcryptography-254811fd619188610298485a66885784944c1de8.tar.gz
cryptography-254811fd619188610298485a66885784944c1de8.tar.bz2
cryptography-254811fd619188610298485a66885784944c1de8.zip
Added all changes lost in merge reset
Diffstat (limited to 'tests/hazmat/primitives/test_serialization.py')
-rw-r--r--tests/hazmat/primitives/test_serialization.py37
1 files changed, 32 insertions, 5 deletions
diff --git a/tests/hazmat/primitives/test_serialization.py b/tests/hazmat/primitives/test_serialization.py
index 4bc7e811..2ee096be 100644
--- a/tests/hazmat/primitives/test_serialization.py
+++ b/tests/hazmat/primitives/test_serialization.py
@@ -82,21 +82,40 @@ class TestPEMSerialization(object):
assert key
assert isinstance(key, interfaces.EllipticCurvePrivateKey)
- def test_load_pem_rsa_public_key(self, backend):
- key = load_vectors_from_file(
+ @pytest.mark.parametrize(
+ ("key_file"),
+ [
+ os.path.join("asymmetric", "PKCS8", "unenc-rsa-pkcs8.pub.pem"),
os.path.join(
"asymmetric", "PEM_Serialization", "rsa_public_key.pem"),
+ ),
+ ]
+ )
+ def test_load_pem_rsa_public_key(self, key_file, backend):
+ key = load_vectors_from_file(
+ key_file,
lambda pemfile: load_pem_public_key(
pemfile.read().encode(), backend
)
)
assert key
assert isinstance(key, interfaces.RSAPublicKey)
+ if isinstance(key, interfaces.RSAPublicKeyWithNumbers):
+ numbers = key.public_numbers()
+ assert numbers.e == 65537
- def test_load_pem_dsa_public_key(self, backend):
+ @pytest.mark.parametrize(
+ ("key_file"),
+ [
+ os.path.join("asymmetric", "PKCS8", "unenc-dsa-pkcs8.pub.pem"),
+ os.path.join(
+ "asymmetric", "PEM_Serialization",
+ "dsa_public_key.pem"
+), ),
+ ]
+ def test_load_pem_dsa_public_key(self, keyfile, backend):
key = load_vectors_from_file(
- os.path.join(
- "asymmetric", "PEM_Serialization", "dsa_public_key.pem"),
+ keyfile,
lambda pemfile: load_pem_public_key(
pemfile.read().encode(), backend
)
@@ -104,6 +123,14 @@ class TestPEMSerialization(object):
assert key
assert isinstance(key, interfaces.DSAPublicKey)
+ def test_load_pem_ec_public_key(self, backend):
+ key = load_vectors_from_file(
+ os.path.join("asymmetric", "PEM_Serialization",
+ "ec_public_key.pem"),
+ lambda pemfile: load_pem_public_key(
+ pemfile.read().encode(), backend
+ )
+ )
@pytest.mark.traditional_openssl_serialization
class TestTraditionalOpenSSLSerialization(object):