aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_multibackend.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/hazmat/backends/test_multibackend.py')
-rw-r--r--tests/hazmat/backends/test_multibackend.py89
1 files changed, 89 insertions, 0 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index d8c09bd7..3fa364e2 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -98,6 +98,21 @@ class DummyRSABackend(object):
algorithm):
pass
+ def mgf1_hash_supported(self, algorithm):
+ pass
+
+ def rsa_padding_supported(self, padding):
+ pass
+
+ def generate_rsa_parameters_supported(self, public_exponent, key_size):
+ pass
+
+ def decrypt_rsa(self, private_key, ciphertext, padding):
+ pass
+
+ def encrypt_rsa(self, public_key, plaintext, padding):
+ pass
+
@utils.register_interface(DSABackend)
class DummyDSABackend(object):
@@ -107,6 +122,18 @@ class DummyDSABackend(object):
def generate_dsa_private_key(self, parameters):
pass
+ def create_dsa_signature_ctx(self, private_key, algorithm):
+ pass
+
+ def create_dsa_verification_ctx(self, public_key, signature, algorithm):
+ pass
+
+ def dsa_hash_supported(self, algorithm):
+ pass
+
+ def dsa_parameters_supported(self, p, q, g):
+ pass
+
@utils.register_interface(CMACBackend)
class DummyCMACBackend(object):
@@ -199,6 +226,16 @@ class TestMultiBackend(object):
backend.create_rsa_verification_ctx("public_key", "sig",
padding.PKCS1v15(), hashes.MD5())
+ backend.mgf1_hash_supported(hashes.MD5())
+
+ backend.rsa_padding_supported(padding.PKCS1v15())
+
+ backend.generate_rsa_parameters_supported(65537, 1024)
+
+ backend.encrypt_rsa("public_key", "encryptme", padding.PKCS1v15())
+
+ backend.decrypt_rsa("private_key", "encrypted", padding.PKCS1v15())
+
backend = MultiBackend([])
with raises_unsupported_algorithm(
_Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
@@ -217,6 +254,31 @@ class TestMultiBackend(object):
backend.create_rsa_verification_ctx(
"public_key", "sig", padding.PKCS1v15(), hashes.MD5())
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.mgf1_hash_supported(hashes.MD5())
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.rsa_padding_supported(padding.PKCS1v15())
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.generate_rsa_parameters_supported(65537, 1024)
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.encrypt_rsa("public_key", "encryptme", padding.PKCS1v15())
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.decrypt_rsa("private_key", "encrypted", padding.PKCS1v15())
+
def test_dsa(self):
backend = MultiBackend([
DummyDSABackend()
@@ -227,6 +289,11 @@ class TestMultiBackend(object):
parameters = object()
backend.generate_dsa_private_key(parameters)
+ backend.create_dsa_verification_ctx("public_key", "sig", hashes.SHA1())
+ backend.create_dsa_signature_ctx("private_key", hashes.SHA1())
+ backend.dsa_hash_supported(hashes.SHA1())
+ backend.dsa_parameters_supported(1, 2, 3)
+
backend = MultiBackend([])
with raises_unsupported_algorithm(
_Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
@@ -238,6 +305,28 @@ class TestMultiBackend(object):
):
backend.generate_dsa_private_key(parameters)
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.create_dsa_signature_ctx("private_key", hashes.SHA1())
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.create_dsa_verification_ctx(
+ "public_key", b"sig", hashes.SHA1()
+ )
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.dsa_hash_supported(hashes.SHA1())
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.dsa_parameters_supported('p', 'q', 'g')
+
def test_cmac(self):
backend = MultiBackend([
DummyCMACBackend([algorithms.AES])