diff options
-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 |