diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-18 14:57:27 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-02-18 14:57:27 -0800 |
| commit | f8cf48bb4a751451ebb7571e91e1eda3b7345e88 (patch) | |
| tree | 85137c3db5c7f895516d5d7d031c30f6c61cb5cd /cryptography | |
| parent | 788147d4e3f085362c7151e1b202aa4bb90fce69 (diff) | |
| parent | d883cd2f13187a4d1054c543872677b5ca4ffb2c (diff) | |
| download | cryptography-f8cf48bb4a751451ebb7571e91e1eda3b7345e88.tar.gz cryptography-f8cf48bb4a751451ebb7571e91e1eda3b7345e88.tar.bz2 cryptography-f8cf48bb4a751451ebb7571e91e1eda3b7345e88.zip | |
Merge pull request #634 from reaperhulk/rsa-signing-interfaces
RSA Sign/Verify Interfaces
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/hazmat/backends/interfaces.py | 15 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/interfaces.py | 37 |
2 files changed, 52 insertions, 0 deletions
diff --git a/cryptography/hazmat/backends/interfaces.py b/cryptography/hazmat/backends/interfaces.py index b867f26a..a543ba1f 100644 --- a/cryptography/hazmat/backends/interfaces.py +++ b/cryptography/hazmat/backends/interfaces.py @@ -90,3 +90,18 @@ class RSABackend(six.with_metaclass(abc.ABCMeta)): Generate an RSAPrivateKey instance with public_exponent and a modulus of key_size bits. """ + + @abc.abstractmethod + def create_rsa_signature_ctx(self, private_key, padding, algorithm): + """ + Returns an object conforming to the AsymmetricSignatureContext + interface. + """ + + @abc.abstractmethod + def create_rsa_verification_ctx(self, public_key, signature, padding, + algorithm): + """ + Returns an object conforming to the AsymmetricVerificationContext + interface. + """ diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py index 5ef469d0..11696160 100644 --- a/cryptography/hazmat/primitives/interfaces.py +++ b/cryptography/hazmat/primitives/interfaces.py @@ -287,6 +287,43 @@ class RSAPublicKey(six.with_metaclass(abc.ABCMeta)): """ +class AsymmetricSignatureContext(six.with_metaclass(abc.ABCMeta)): + @abc.abstractmethod + def update(self, data): + """ + Processes the provided bytes and returns nothing. + """ + + @abc.abstractmethod + def finalize(self): + """ + Returns the signature as bytes. + """ + + +class AsymmetricVerificationContext(six.with_metaclass(abc.ABCMeta)): + @abc.abstractmethod + def update(self, data): + """ + Processes the provided bytes and returns nothing. + """ + + @abc.abstractmethod + def verify(self): + """ + Raises an exception if the bytes provided to update do not match the + signature or the signature does not match the public key. + """ + + +class AsymmetricPadding(six.with_metaclass(abc.ABCMeta)): + @abc.abstractproperty + def name(self): + """ + A string naming this padding (e.g. "PSS", "PKCS1"). + """ + + class KeyDerivationFunction(six.with_metaclass(abc.ABCMeta)): @abc.abstractmethod def derive(self, key_material): |
