summaryrefslogtreecommitdiff
path: root/tests/test_pem.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_pem.py')
-rw-r--r--tests/test_pem.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_pem.py b/tests/test_pem.py
index 61a66fc..3e03ab0 100644
--- a/tests/test_pem.py
+++ b/tests/test_pem.py
@@ -86,3 +86,17 @@ class TestByteOutput(unittest.TestCase):
key = rsa.key.PrivateKey.load_pkcs1(private_key_pem)
self.assertTrue(is_bytes(key.save_pkcs1(format='DER')))
self.assertTrue(is_bytes(key.save_pkcs1(format='PEM')))
+
+
+class TestByteInput(unittest.TestCase):
+ """Tests that PEM and DER can be loaded from bytes."""
+
+ def test_bytes_public(self):
+ key = rsa.key.PublicKey.load_pkcs1_openssl_pem(public_key_pem.encode('ascii'))
+ self.assertTrue(is_bytes(key.save_pkcs1(format='DER')))
+ self.assertTrue(is_bytes(key.save_pkcs1(format='PEM')))
+
+ def test_bytes_private(self):
+ key = rsa.key.PrivateKey.load_pkcs1(private_key_pem.encode('ascii'))
+ self.assertTrue(is_bytes(key.save_pkcs1(format='DER')))
+ self.assertTrue(is_bytes(key.save_pkcs1(format='PEM')))