diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2015-01-17 17:26:42 -0500 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2015-01-17 17:26:42 -0500 |
commit | 4f27959a58f7cc0a26a488fd2005fd9e69364092 (patch) | |
tree | ca8e765f88170b46f692a0c2f7514bbdd22b3d5f /tests | |
parent | 2dcdf87195b9bbe3be8abd5439ebc14a4e8bfe36 (diff) | |
parent | 170f1da651bcd97a05f3876953e04a6e7f44c06e (diff) | |
download | cryptography-4f27959a58f7cc0a26a488fd2005fd9e69364092.tar.gz cryptography-4f27959a58f7cc0a26a488fd2005fd9e69364092.tar.bz2 cryptography-4f27959a58f7cc0a26a488fd2005fd9e69364092.zip |
Merge pull request #1609 from reaperhulk/der-multibackend
DER multibackend
Diffstat (limited to 'tests')
-rw-r--r-- | tests/hazmat/backends/test_multibackend.py | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py index 43ecbf83..5a8891c4 100644 --- a/tests/hazmat/backends/test_multibackend.py +++ b/tests/hazmat/backends/test_multibackend.py @@ -9,9 +9,9 @@ from cryptography.exceptions import ( UnsupportedAlgorithm, _Reasons ) from cryptography.hazmat.backends.interfaces import ( - CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, - HashBackend, PBKDF2HMACBackend, PEMSerializationBackend, - RSABackend, X509Backend + CMACBackend, CipherBackend, DERSerializationBackend, DSABackend, + EllipticCurveBackend, HMACBackend, HashBackend, PBKDF2HMACBackend, + PEMSerializationBackend, RSABackend, X509Backend ) from cryptography.hazmat.backends.multibackend import MultiBackend from cryptography.hazmat.primitives import cmac, hashes, hmac @@ -180,6 +180,15 @@ class DummyPEMSerializationBackend(object): pass +@utils.register_interface(DERSerializationBackend) +class DummyDERSerializationBackend(object): + def load_der_private_key(self, data, password): + pass + + def load_der_public_key(self, data): + pass + + @utils.register_interface(X509Backend) class DummyX509Backend(object): def load_pem_x509_certificate(self, data): @@ -446,6 +455,18 @@ class TestMultiBackend(object): with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_SERIALIZATION): backend.load_pem_public_key(b"keydata") + def test_der_serialization_backend(self): + backend = MultiBackend([DummyDERSerializationBackend()]) + + backend.load_der_private_key(b"keydata", None) + backend.load_der_public_key(b"keydata") + + backend = MultiBackend([]) + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_SERIALIZATION): + backend.load_der_private_key(b"keydata", None) + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_SERIALIZATION): + backend.load_der_public_key(b"keydata") + def test_x509_backend(self): backend = MultiBackend([DummyX509Backend()]) |