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.py35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index f0be72b2..4ec8a110 100644
--- a/tests/hazmat/backends/test_multibackend.py
+++ b/tests/hazmat/backends/test_multibackend.py
@@ -18,7 +18,8 @@ from cryptography.exceptions import (
UnsupportedAlgorithm, _Reasons
)
from cryptography.hazmat.backends.interfaces import (
- CipherBackend, HMACBackend, HashBackend, PBKDF2HMACBackend, RSABackend
+ CipherBackend, HMACBackend, HashBackend, PBKDF2HMACBackend, RSABackend,
+ DSABackend
)
from cryptography.hazmat.backends.multibackend import MultiBackend
from cryptography.hazmat.primitives import hashes, hmac
@@ -27,6 +28,8 @@ from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
from ...utils import raises_unsupported_algorithm
+from pretend import stub
+
@utils.register_interface(CipherBackend)
class DummyCipherBackend(object):
@@ -98,6 +101,15 @@ class DummyRSABackend(object):
pass
+@utils.register_interface(DSABackend)
+class DummyDSABackend(object):
+ def generate_dsa_parameters(self, key_size):
+ pass
+
+ def generate_dsa_private_key(self, parameters):
+ pass
+
+
class TestMultiBackend(object):
def test_ciphers(self):
backend = MultiBackend([
@@ -193,3 +205,24 @@ class TestMultiBackend(object):
):
backend.create_rsa_verification_ctx(
"public_key", "sig", padding.PKCS1v15(), hashes.MD5())
+
+ def test_dsa(self):
+ backend = MultiBackend([
+ DummyDSABackend()
+ ])
+
+ backend.generate_dsa_parameters(key_size=1024)
+
+ parameters = stub()
+ backend.generate_dsa_private_key(parameters)
+
+ backend = MultiBackend([])
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.generate_dsa_parameters(key_size=1024)
+
+ with raises_unsupported_algorithm(
+ _Reasons.UNSUPPORTED_PUBLIC_KEY_ALGORITHM
+ ):
+ backend.generate_dsa_private_key(parameters)