aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Gaynor <alex.gaynor@gmail.com>2014-01-30 11:32:35 -0800
committerAlex Gaynor <alex.gaynor@gmail.com>2014-01-30 11:32:35 -0800
commit2b8b415a0aadf6a1a1c78a7b474d8b1dbcbc544f (patch)
treefd9dd7d369ae6885fe0919a4c20e1f4045c127fb
parentfcaf9761d1a2a570b2249c2ef3fff322dbb0b37b (diff)
downloadcryptography-2b8b415a0aadf6a1a1c78a7b474d8b1dbcbc544f.tar.gz
cryptography-2b8b415a0aadf6a1a1c78a7b474d8b1dbcbc544f.tar.bz2
cryptography-2b8b415a0aadf6a1a1c78a7b474d8b1dbcbc544f.zip
HashBackend is now supported by PrioritizedMultiBackend
-rw-r--r--cryptography/hazmat/backends/multibackend.py14
1 files changed, 13 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py
index 9b91ff45..210efbe8 100644
--- a/cryptography/hazmat/backends/multibackend.py
+++ b/cryptography/hazmat/backends/multibackend.py
@@ -15,10 +15,11 @@ from __future__ import absolute_import, division, print_function
from cryptography import utils
from cryptography.exceptions import UnsupportedAlgorithm
-from cryptography.hazmat.backends.interfaces import CipherBackend
+from cryptography.hazmat.backends.interfaces import CipherBackend, HashBackend
@utils.register_interface(CipherBackend)
+@utils.register_interface(HashBackend)
class PrioritizedMultiBackend(object):
name = "multibackend"
@@ -43,3 +44,14 @@ class PrioritizedMultiBackend(object):
except UnsupportedAlgorithm:
pass
raise UnsupportedAlgorithm
+
+ def hash_supported(self, algorithm):
+ return any(b.hash_supported(algorithm) for b in self._backends)
+
+ def create_hash_ctx(self, algorithm):
+ for b in self._backends:
+ try:
+ return b.create_hash_ctx(algorithm)
+ except UnsupportedAlgorithm:
+ pass
+ raise UnsupportedAlgorithm