diff options
author | Ayrx <terrycwk1994@gmail.com> | 2014-03-16 15:42:52 +0800 |
---|---|---|
committer | Ayrx <terrycwk1994@gmail.com> | 2014-03-16 15:42:52 +0800 |
commit | f886a82e34c902cde6bd4e05f3d8b84bfdc9945f (patch) | |
tree | 3a9c659941b9710c633d75879e3399ff9535868c /cryptography | |
parent | 3fb221f1fb02ffed7a558bd06ba41bb75c329fc5 (diff) | |
download | cryptography-f886a82e34c902cde6bd4e05f3d8b84bfdc9945f.tar.gz cryptography-f886a82e34c902cde6bd4e05f3d8b84bfdc9945f.tar.bz2 cryptography-f886a82e34c902cde6bd4e05f3d8b84bfdc9945f.zip |
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 |