diff options
Diffstat (limited to 'tests/hazmat')
-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()]) |