diff options
| author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-27 11:05:29 -0800 |
|---|---|---|
| committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-27 11:05:29 -0800 |
| commit | b2774f53bc5840ae7c414ee78bef654a2ae89f01 (patch) | |
| tree | 6fdba6fac20984321a0269d3edb165f076bfbf1f /cryptography | |
| parent | 6b4f32311e038a60ed496e2f44558b8803f9e033 (diff) | |
| download | cryptography-b2774f53bc5840ae7c414ee78bef654a2ae89f01.tar.gz cryptography-b2774f53bc5840ae7c414ee78bef654a2ae89f01.tar.bz2 cryptography-b2774f53bc5840ae7c414ee78bef654a2ae89f01.zip | |
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. + """ |
