diff options
-rw-r--r-- | cryptography/hazmat/backends/multibackend.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/cryptography/hazmat/backends/multibackend.py b/cryptography/hazmat/backends/multibackend.py index 035517ea..e560c7df 100644 --- a/cryptography/hazmat/backends/multibackend.py +++ b/cryptography/hazmat/backends/multibackend.py @@ -16,13 +16,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, HMACBackend + CipherBackend, HashBackend, HMACBackend, PBKDF2HMACBackend ) @utils.register_interface(CipherBackend) @utils.register_interface(HashBackend) @utils.register_interface(HMACBackend) +@utils.register_interface(PBKDF2HMACBackend) class PrioritizedMultiBackend(object): name = "multibackend" @@ -69,3 +70,17 @@ class PrioritizedMultiBackend(object): except UnsupportedAlgorithm: pass raise UnsupportedAlgorithm + + def pbkdf2_hmac_supported(self, algorithm): + return any(b.pbkdf2_hmac_supported(algorithm) for b in self._backends) + + def derive_pbkdf2_hmac(self, algorithm, length, salt, iterations, + key_material): + for b in self._backends: + try: + return b.derive_pbkdf2_hmac( + algorithm, length, salt, iterations, key_material + ) + except UnsupportedAlgorithm: + pass + raise UnsupportedAlgorithm |