diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-30 11:36:10 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-30 11:36:10 -0800 |
commit | 2d02857b4b1d6d8adbdd1fa1a753a2c464860bcf (patch) | |
tree | ea36b876ec571c4c020ecc673c6311a3f863e834 | |
parent | 2b8b415a0aadf6a1a1c78a7b474d8b1dbcbc544f (diff) | |
download | cryptography-2d02857b4b1d6d8adbdd1fa1a753a2c464860bcf.tar.gz cryptography-2d02857b4b1d6d8adbdd1fa1a753a2c464860bcf.tar.bz2 cryptography-2d02857b4b1d6d8adbdd1fa1a753a2c464860bcf.zip |
Added support for HMAC backend
-rw-r--r-- | cryptography/hazmat/backends/multibackend.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py index 210efbe8..035517ea 100644 --- a/cryptography/hazmat/backends/multibackend.py +++ b/cryptography/hazmat/backends/multibackend.py @@ -15,11 +15,14 @@ from __future__ import absolute_import, division, print_function from cryptography import utils from cryptography.exceptions import UnsupportedAlgorithm -from cryptography.hazmat.backends.interfaces import CipherBackend, HashBackend +from cryptography.hazmat.backends.interfaces import ( + CipherBackend, HashBackend, HMACBackend +) @utils.register_interface(CipherBackend) @utils.register_interface(HashBackend) +@utils.register_interface(HMACBackend) class PrioritizedMultiBackend(object): name = "multibackend" @@ -55,3 +58,14 @@ class PrioritizedMultiBackend(object): except UnsupportedAlgorithm: pass raise UnsupportedAlgorithm + + def hmac_supported(self, algorithm): + return any(b.hmac_supported(algorithm) for b in self._backends) + + def create_hmac_ctx(self, key, algorithm): + for b in self._backends: + try: + return b.create_hmac_ctx(key, algorithm) + except UnsupportedAlgorithm: + pass + raise UnsupportedAlgorithm |