diff options
author | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-04-16 09:29:06 -0400 |
---|---|---|
committer | Paul Kehrer <paul.l.kehrer@gmail.com> | 2014-04-16 09:29:06 -0400 |
commit | 182825a138f0a565939c20fcf9d97f15945dbd30 (patch) | |
tree | d4105e3b7ea926ec9a31a4f7232b008a03dc6e6d /cryptography | |
parent | cd6183389098ecf498edc054fea4c9d4019e4981 (diff) | |
parent | 83cd3f894353c5f9e6393972319e7c20c0981a9c (diff) | |
download | cryptography-182825a138f0a565939c20fcf9d97f15945dbd30.tar.gz cryptography-182825a138f0a565939c20fcf9d97f15945dbd30.tar.bz2 cryptography-182825a138f0a565939c20fcf9d97f15945dbd30.zip |
Merge pull request #919 from Ayrx/cmac-interfaces
CMAC interfaces + documentation
Diffstat (limited to 'cryptography')
-rw-r--r-- | cryptography/hazmat/backends/interfaces.py | 15 | ||||
-rw-r--r-- | cryptography/hazmat/primitives/interfaces.py | 20 |
2 files changed, 35 insertions, 0 deletions
diff --git a/cryptography/hazmat/backends/interfaces.py b/cryptography/hazmat/backends/interfaces.py index e4c1df34..4137b534 100644 --- a/cryptography/hazmat/backends/interfaces.py +++ b/cryptography/hazmat/backends/interfaces.py @@ -142,3 +142,18 @@ class OpenSSLSerializationBackend(object): Load a private key from PEM encoded data, using password if the data is encrypted. """ + + +@six.add_metaclass(abc.ABCMeta) +class CMACBackend(object): + @abc.abstractmethod + def cmac_supported(self): + """ + Returns True if the backend supports CMAC + """ + + @abc.abstractmethod + def create_cmac_ctx(self, algorithm): + """ + Create a CMACContext for calculating a message authentication code. + """ diff --git a/cryptography/hazmat/primitives/interfaces.py b/cryptography/hazmat/primitives/interfaces.py index 4d92ef27..810a67a4 100644 --- a/cryptography/hazmat/primitives/interfaces.py +++ b/cryptography/hazmat/primitives/interfaces.py @@ -469,3 +469,23 @@ class KeyDerivationFunction(object): Checks whether the key generated by the key material matches the expected derived key. Raises an exception if they do not match. """ + + +@six.add_metaclass(abc.ABCMeta) +class CMACContext(object): + @abc.abstractmethod + def update(self, data): + """ + Processes the provided bytes. + """ + + def finalize(self): + """ + Returns the message authentication code as bytes. + """ + + @abc.abstractmethod + def copy(self): + """ + Return a CMACContext that is a copy of the current context. + """ |