diff options
| author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-28 08:50:37 -0800 |
|---|---|---|
| committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-01-28 08:50:37 -0800 |
| commit | 1f8cd620cfbb854b0dfcdbf89c140160a8caba13 (patch) | |
| tree | bc8df644f525bb5b5ed97e83324b1e3d4ad8a6f2 /cryptography | |
| parent | 59393dde1b47e235bc3803815909f944f54fa32f (diff) | |
| parent | 8454c5153537439b36b879e82ab3a3d8e7aa7909 (diff) | |
| download | cryptography-1f8cd620cfbb854b0dfcdbf89c140160a8caba13.tar.gz cryptography-1f8cd620cfbb854b0dfcdbf89c140160a8caba13.tar.bz2 cryptography-1f8cd620cfbb854b0dfcdbf89c140160a8caba13.zip | |
Merge pull request #513 from alex/kdf-interface
Begin designing the KDF interfaces. Fixes #511
Diffstat (limited to 'cryptography')
| -rw-r--r-- | cryptography/exceptions.py | 4 | ||||
| -rw-r--r-- | cryptography/hazmat/primitives/interfaces.py | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/cryptography/exceptions.py b/cryptography/exceptions.py index 2654b453..e2542a1f 100644 --- a/cryptography/exceptions.py +++ b/cryptography/exceptions.py @@ -38,3 +38,7 @@ class InvalidSignature(Exception): class InternalError(Exception): pass + + +class InvalidKey(Exception): + pass diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py index 293fcd78..1a27644f 100644 --- a/cryptography/hazmat/primitives/interfaces.py +++ b/cryptography/hazmat/primitives/interfaces.py @@ -257,3 +257,19 @@ class RSAPublicKey(six.with_metaclass(abc.ABCMeta)): """ The public exponent of the RSA key. Alias for public_exponent. """ + + +class KeyDerivationFunction(six.with_metaclass(abc.ABCMeta)): + @abc.abstractmethod + def derive(self, key_material): + """ + Deterministically generates and returns a new key based on the existing + key material. + """ + + @abc.abstractmethod + def verify(self, key_material, expected_key): + """ + Checks whether the key generated by the key material matches the + expected derived key. Raises an exception if they do not match. + """ |
