From 020ae0fa11bd5e33863b3944ad14bb18ec748645 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Thu, 30 Jan 2014 11:38:43 -0800 Subject: Added PBKDF2HMAC support --- cryptography/hazmat/backends/multibackend.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 -- cgit v1.2.3