aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/hazmat
diff options
context:
space:
mode:
Diffstat (limited to 'cryptography/hazmat')
-rw-r--r--cryptography/hazmat/primitives/asymmetric/rsa.py14
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