diff options
author | Mohammed Attia <skeuomorf@gmail.com> | 2014-04-02 03:46:57 +0200 |
---|---|---|
committer | Mohammed Attia <skeuomorf@gmail.com> | 2014-04-04 19:15:07 +0200 |
commit | 97c27c698dc5325aff3887cf13e0e58bcfd1acfe (patch) | |
tree | 3ec6458c309f6448f304726ef84355e9f41e216a /tests/hazmat/backends/test_multibackend.py | |
parent | 9ac7c1d9032816e161b64f8e283bffac99b85c2e (diff) | |
download | cryptography-97c27c698dc5325aff3887cf13e0e58bcfd1acfe.tar.gz cryptography-97c27c698dc5325aff3887cf13e0e58bcfd1acfe.tar.bz2 cryptography-97c27c698dc5325aff3887cf13e0e58bcfd1acfe.zip |
Add DSABackend
Diffstat (limited to 'tests/hazmat/backends/test_multibackend.py')
-rw-r--r-- | tests/hazmat/backends/test_multibackend.py | 35 |
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) |