aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cryptography/hazmat/primitives/interfaces.py12
-rw-r--r--docs/hazmat/primitives/interfaces.rst46
2 files changed, 58 insertions, 0 deletions
diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py
index e70338ba..4d92ef27 100644
--- a/cryptography/hazmat/primitives/interfaces.py
+++ b/cryptography/hazmat/primitives/interfaces.py
@@ -185,6 +185,12 @@ class HashContext(object):
@six.add_metaclass(abc.ABCMeta)
class RSAPrivateKey(object):
+ @abc.abstractmethod
+ def signer(self, padding, algorithm, backend):
+ """
+ Returns an AsymmetricSignatureContext used for signing data.
+ """
+
@abc.abstractproperty
def modulus(self):
"""
@@ -270,6 +276,12 @@ class RSAPrivateKey(object):
@six.add_metaclass(abc.ABCMeta)
class RSAPublicKey(object):
+ @abc.abstractmethod
+ def verifier(self, signature, padding, algorithm, backend):
+ """
+ Returns an AsymmetricVerificationContext used for verifying signatures.
+ """
+
@abc.abstractproperty
def modulus(self):
"""
diff --git a/docs/hazmat/primitives/interfaces.rst b/docs/hazmat/primitives/interfaces.rst
index cdb925ee..f4fb8ded 100644
--- a/docs/hazmat/primitives/interfaces.rst
+++ b/docs/hazmat/primitives/interfaces.rst
@@ -112,6 +112,27 @@ Asymmetric interfaces
An `RSA`_ private key.
+ .. method:: signer(padding, algorithm, backend)
+
+ .. versionadded:: 0.3
+
+ Sign data which can be verified later by others using the public key.
+
+ :param padding: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricPadding`
+ provider.
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.RSABackend`
+ provider.
+
+ :returns:
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricSignatureContext`
+
.. method:: public_key()
:return: :class:`~cryptography.hazmat.primitives.interfaces.RSAPublicKey`
@@ -200,6 +221,31 @@ Asymmetric interfaces
An `RSA`_ public key.
+ .. method:: verifier(signature, padding, algorithm, backend)
+
+ .. versionadded:: 0.3
+
+ Verify data was signed by the private key associated with this public
+ key.
+
+ :param bytes signature: The signature to verify.
+
+ :param padding: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricPadding`
+ provider.
+
+ :param algorithm: An instance of a
+ :class:`~cryptography.hazmat.primitives.interfaces.HashAlgorithm`
+ provider.
+
+ :param backend: A
+ :class:`~cryptography.hazmat.backends.interfaces.RSABackend`
+ provider.
+
+ :returns:
+ :class:`~cryptography.hazmat.primitives.interfaces.AsymmetricVerificationContext`
+
+
.. attribute:: modulus
:type: int