diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-03-16 08:17:39 -0430 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-03-16 08:17:39 -0430 |
commit | e171c5fcf47263d4aee35c555844e4c4d7aec5f0 (patch) | |
tree | 10fd0e14053b0b467279dd40e6c722c647bed865 /cryptography | |
parent | 1e7ce06edb9179cf2afc66b031767d9246242fad (diff) | |
parent | 68855e0611e70486ef1ae93a0936babb3fc80704 (diff) | |
download | cryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.tar.gz cryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.tar.bz2 cryptography-e171c5fcf47263d4aee35c555844e4c4d7aec5f0.zip |
Merge pull request #807 from Ayrx/add-backend-check-to-rsa
Added backend check to rsa primitives
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/primitives/asymmetric/rsa.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/asymmetric/rsa.py b/cryptography/hazmat/primitives/asymmetric/rsa.py index dfb43340..cbef8e32 100644 --- a/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -16,6 +16,8 @@ from __future__ import absolute_import, division, print_function import six from cryptography import utils +from cryptography.exceptions import UnsupportedInterface +from cryptography.hazmat.backends.interfaces import RSABackend from cryptography.hazmat.primitives import interfaces @@ -41,6 +43,10 @@ class RSAPublicKey(object): self._modulus = modulus def verifier(self, signature, padding, algorithm, backend): + if not isinstance(backend, RSABackend): + raise UnsupportedInterface( + "Backend object does not implement RSABackend") + return backend.create_rsa_verification_ctx(self, signature, padding, algorithm) @@ -128,9 +134,17 @@ class RSAPrivateKey(object): @classmethod def generate(cls, public_exponent, key_size, backend): + if not isinstance(backend, RSABackend): + raise UnsupportedInterface( + "Backend object does not implement RSABackend") + return backend.generate_rsa_private_key(public_exponent, key_size) def signer(self, padding, algorithm, backend): + if not isinstance(backend, RSABackend): + raise UnsupportedInterface( + "Backend object does not implement RSABackend") + return backend.create_rsa_signature_ctx(self, padding, algorithm) @property |