aboutsummaryrefslogtreecommitdiffstats
path: root/cryptography
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2013-12-23 16:11:03 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2013-12-23 16:11:03 -0800
commit4dbed96fb73a4899a902d35086b893bfb96ebcca (patch)
treeb4e5596856f115b0325909a21194e76ce1f8c472 /cryptography
parentb8564e829306731f5133ac6bcbfc8e2f7e1a25f4 (diff)
parent4f776c495cfef4dd29023cb7bb035612d1e53916 (diff)
downloadcryptography-4dbed96fb73a4899a902d35086b893bfb96ebcca.tar.gz
cryptography-4dbed96fb73a4899a902d35086b893bfb96ebcca.tar.bz2
cryptography-4dbed96fb73a4899a902d35086b893bfb96ebcca.zip
Merge pull request #338 from reaperhulk/hmac-supported-check
Add hmac_supported method to backend
Diffstat (limited to 'cryptography')
-rw-r--r--cryptography/hazmat/backends/interfaces.py7
-rw-r--r--cryptography/hazmat/backends/openssl/backend.py3
2 files changed, 10 insertions, 0 deletions
diff --git a/cryptography/hazmat/backends/interfaces.py b/cryptography/hazmat/backends/interfaces.py
index 912476bb..9a570968 100644
--- a/cryptography/hazmat/backends/interfaces.py
+++ b/cryptography/hazmat/backends/interfaces.py
@@ -60,6 +60,13 @@ class HashBackend(six.with_metaclass(abc.ABCMeta)):
class HMACBackend(six.with_metaclass(abc.ABCMeta)):
@abc.abstractmethod
+ def hmac_supported(self, algorithm):
+ """
+ Return True if the hash algorithm is supported for HMAC by this
+ backend.
+ """
+
+ @abc.abstractmethod
def create_hmac_ctx(self, key, algorithm):
"""
Create a HashContext for calculating a message authentication code.
diff --git a/cryptography/hazmat/backends/openssl/backend.py b/cryptography/hazmat/backends/openssl/backend.py
index f11ddf22..7b67fb0b 100644
--- a/cryptography/hazmat/backends/openssl/backend.py
+++ b/cryptography/hazmat/backends/openssl/backend.py
@@ -184,6 +184,9 @@ class Backend(object):
digest = self.lib.EVP_get_digestbyname(algorithm.name.encode("ascii"))
return digest != self.ffi.NULL
+ def hmac_supported(self, algorithm):
+ return self.hash_supported(algorithm)
+
def create_hash_ctx(self, algorithm):
return _HashContext(self, algorithm)