From cc5d1bf129c7e1a41906101fd1cb142b74765303 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 7 Jul 2014 13:56:48 -0500 Subject: add PKCS8SerializationBackend support to MultiBackend --- tests/hazmat/backends/test_multibackend.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py index a68fe560..19795634 100644 --- a/tests/hazmat/backends/test_multibackend.py +++ b/tests/hazmat/backends/test_multibackend.py @@ -19,7 +19,7 @@ from cryptography.exceptions import ( ) from cryptography.hazmat.backends.interfaces import ( CMACBackend, CipherBackend, DSABackend, EllipticCurveBackend, HMACBackend, - HashBackend, PBKDF2HMACBackend, RSABackend + HashBackend, PBKDF2HMACBackend, PKCS8SerializationBackend, RSABackend ) from cryptography.hazmat.backends.multibackend import MultiBackend from cryptography.hazmat.primitives import cmac, hashes, hmac @@ -192,6 +192,12 @@ class DummyEllipticCurveBackend(object): raise UnsupportedAlgorithm(_Reasons.UNSUPPORTED_ELLIPTIC_CURVE) +@utils.register_interface(PKCS8SerializationBackend) +class DummyPKCS8SerializationBackend(object): + def load_pkcs8_pem_private_key(self, data, password): + pass + + class TestMultiBackend(object): def test_ciphers(self): backend = MultiBackend([ @@ -471,3 +477,12 @@ class TestMultiBackend(object): ec.SECT163K1() ) ) + + def test_pkcs8_serialization_backend(self): + backend = MultiBackend([DummyPKCS8SerializationBackend()]) + + backend.load_pkcs8_pem_private_key(b"keydata", None) + + backend = MultiBackend([]) + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_KEY_FORMAT): + backend.load_pkcs8_pem_private_key(b"keydata", None) -- cgit v1.2.3 From 965dbbe2301c667b51e310b503bd25cfa5a3bac3 Mon Sep 17 00:00:00 2001 From: Paul Kehrer Date: Mon, 7 Jul 2014 15:15:05 -0500 Subject: change some nomenclature --- tests/hazmat/backends/test_multibackend.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py index 19795634..3be8371f 100644 --- a/tests/hazmat/backends/test_multibackend.py +++ b/tests/hazmat/backends/test_multibackend.py @@ -484,5 +484,5 @@ class TestMultiBackend(object): backend.load_pkcs8_pem_private_key(b"keydata", None) backend = MultiBackend([]) - with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_KEY_FORMAT): + with raises_unsupported_algorithm(_Reasons.UNSUPPORTED_SERIALIZATION): backend.load_pkcs8_pem_private_key(b"keydata", None) -- cgit v1.2.3