aboutsummaryrefslogtreecommitdiffstats
path: root/tests/hazmat/backends/test_multibackend.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-05 08:55:09 -0500
committerPaul Kehrer <paul.l.kehrer@gmail.com>2014-04-05 08:55:09 -0500
commit6abaf40a591bbae5e2eeebb8a29e6558aeae047c (patch)
tree5e2a7de8ca3c3f32da66773fcf24a45555e57cd7 /tests/hazmat/backends/test_multibackend.py
parent509343e400942e78f5c1d0d5f380002939b24266 (diff)
parent29474ac7dab3f5c8b664463ed28ec83b7b77250b (diff)
downloadcryptography-6abaf40a591bbae5e2eeebb8a29e6558aeae047c.tar.gz
cryptography-6abaf40a591bbae5e2eeebb8a29e6558aeae047c.tar.bz2
cryptography-6abaf40a591bbae5e2eeebb8a29e6558aeae047c.zip
Merge pull request #739 from skeuomorf/dsa-backend
DSA backend
Diffstat (limited to 'tests/hazmat/backends/test_multibackend.py')
-rw-r--r--tests/hazmat/backends/test_multibackend.py33
1 files changed, 32 insertions, 1 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py
index f0be72b2..f46009d4 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, DSABackend, HMACBackend, HashBackend, PBKDF2HMACBackend,
+ RSABackend
)
from cryptography.hazmat.backends.multibackend import MultiBackend
from cryptography.hazmat.primitives import hashes, hmac
@@ -98,6 +99,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 +203,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 = object()
+ 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)