aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography/hazmat
diff options
context:
space:
mode:
Diffstat (limited to 'cryptography/hazmat')
-rw-r--r--cryptography/hazmat/backends/interfaces.py15
-rw-r--r--cryptography/hazmat/primitives/interfaces.py20
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.
+ """