diff options
author | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-30 11:38:43 -0800 |
---|---|---|
committer | Alex Gaynor <alex.gaynor@gmail.com> | 2014-01-30 11:38:43 -0800 |
commit | 020ae0fa11bd5e33863b3944ad14bb18ec748645 (patch) | |
tree | 108bfc2e3b4ee4fc12efa099b272c69988868068 | |
parent | 2d02857b4b1d6d8adbdd1fa1a753a2c464860bcf (diff) | |
download | cryptography-020ae0fa11bd5e33863b3944ad14bb18ec748645.tar.gz cryptography-020ae0fa11bd5e33863b3944ad14bb18ec748645.tar.bz2 cryptography-020ae0fa11bd5e33863b3944ad14bb18ec748645.zip |
Added PBKDF2HMAC support
-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 |