diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cryptography/hazmat/backends/openssl/rsa.py | 11 | ||||
-rw-r--r-- | src/cryptography/hazmat/primitives/asymmetric/rsa.py | 12 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/rsa.py b/src/cryptography/hazmat/backends/openssl/rsa.py index fa23bf89..10c51fee 100644 --- a/src/cryptography/hazmat/backends/openssl/rsa.py +++ b/src/cryptography/hazmat/backends/openssl/rsa.py @@ -611,6 +611,12 @@ class _RSAPrivateKey(object): self._rsa_cdata ) + def sign(self, data, padding, algorithm): + signer = self.signer(padding, algorithm) + signer.update(data) + signature = signer.finalize() + return signature + @utils.register_interface(RSAPublicKeyWithSerialization) class _RSAPublicKey(object): @@ -661,3 +667,8 @@ class _RSAPublicKey(object): self._evp_pkey, self._rsa_cdata ) + + def verify(self, signature, data, padding, algorithm): + verifier = self.verifier(signature, padding, algorithm) + verifier.update(data) + verifier.verify() diff --git a/src/cryptography/hazmat/primitives/asymmetric/rsa.py b/src/cryptography/hazmat/primitives/asymmetric/rsa.py index 41b0089e..2cb89515 100644 --- a/src/cryptography/hazmat/primitives/asymmetric/rsa.py +++ b/src/cryptography/hazmat/primitives/asymmetric/rsa.py @@ -40,6 +40,12 @@ class RSAPrivateKey(object): The RSAPublicKey associated with this private key. """ + @abc.abstractmethod + def sign(self, data, padding, algorithm): + """ + Signs the data. + """ + @six.add_metaclass(abc.ABCMeta) class RSAPrivateKeyWithSerialization(RSAPrivateKey): @@ -88,6 +94,12 @@ class RSAPublicKey(object): Returns the key serialized as bytes. """ + @abc.abstractmethod + def verify(self, signature, data, padding, algorithm): + """ + Verifies the signature of the data. + """ + RSAPublicKeyWithSerialization = RSAPublicKey |