diff options
author | David Reid <dreid@dreid.org> | 2014-02-12 11:18:35 -0800 |
---|---|---|
committer | David Reid <dreid@dreid.org> | 2014-02-12 11:18:35 -0800 |
commit | ba657d3856554ba81fad4cf83acd723ab7f3bee9 (patch) | |
tree | e17fba2f9c6435e657dd95d48e5449e2b99e89ca /tests/hazmat/backends/test_multibackend.py | |
parent | d3a061a3d3b2b856cf7c839b19739e20235b4962 (diff) | |
parent | e7bdb1b3e76346d4e0aa7cbf2291e6f25e7b43b3 (diff) | |
download | cryptography-ba657d3856554ba81fad4cf83acd723ab7f3bee9.tar.gz cryptography-ba657d3856554ba81fad4cf83acd723ab7f3bee9.tar.bz2 cryptography-ba657d3856554ba81fad4cf83acd723ab7f3bee9.zip |
Merge pull request #600 from alex/multi-rsa
Added RSABackend to MultiBackend
Diffstat (limited to 'tests/hazmat/backends/test_multibackend.py')
-rw-r--r-- | tests/hazmat/backends/test_multibackend.py | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/tests/hazmat/backends/test_multibackend.py b/tests/hazmat/backends/test_multibackend.py index ca21c9fc..ce77ce2f 100644 --- a/tests/hazmat/backends/test_multibackend.py +++ b/tests/hazmat/backends/test_multibackend.py @@ -16,7 +16,7 @@ import pytest from cryptography import utils from cryptography.exceptions import UnsupportedAlgorithm from cryptography.hazmat.backends.interfaces import ( - CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend + CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend, RSABackend ) from cryptography.hazmat.backends.multibackend import MultiBackend from cryptography.hazmat.primitives import hashes, hmac @@ -67,7 +67,7 @@ class DummyHMACBackend(object): @utils.register_interface(PBKDF2HMACBackend) -class DummyPBKDF2HMAC(object): +class DummyPBKDF2HMACBackend(object): def __init__(self, supported_algorithms): self._algorithms = supported_algorithms @@ -80,6 +80,12 @@ class DummyPBKDF2HMAC(object): raise UnsupportedAlgorithm +@utils.register_interface(RSABackend) +class DummyRSABackend(object): + def generate_rsa_private_key(self, public_exponent, private_key): + pass + + class TestMultiBackend(object): def test_ciphers(self): backend = MultiBackend([ @@ -134,7 +140,7 @@ class TestMultiBackend(object): def test_pbkdf2(self): backend = MultiBackend([ - DummyPBKDF2HMAC([hashes.MD5]) + DummyPBKDF2HMACBackend([hashes.MD5]) ]) assert backend.pbkdf2_hmac_supported(hashes.MD5()) @@ -142,3 +148,16 @@ class TestMultiBackend(object): with pytest.raises(UnsupportedAlgorithm): backend.derive_pbkdf2_hmac(hashes.SHA1(), 10, b"", 10, b"") + + def test_rsa(self): + backend = MultiBackend([ + DummyRSABackend() + ]) + + backend.generate_rsa_private_key( + key_size=1024, public_exponent=65537 + ) + + backend = MultiBackend([]) + with pytest.raises(UnsupportedAlgorithm): + backend.generate_rsa_private_key(key_size=1024, public_exponent=3) |