Merge pull request #531 from reaperhulk/pbkdf2-commoncrypto
PBKDF2HMAC (CommonCrypto)
diff --git a/cryptography/hazmat/backends/commoncrypto/backend.py b/cryptography/hazmat/backends/commoncrypto/backend.py
index 8792c8a..e5d4ee0 100644
--- a/cryptography/hazmat/backends/commoncrypto/backend.py
+++ b/cryptography/hazmat/backends/commoncrypto/backend.py
@@ -99,20 +99,10 @@
}
def hash_supported(self, algorithm):
- try:
- self._hash_mapping[algorithm.name]
- except KeyError:
- return False
- else:
- return True
+ return algorithm.name in self._hash_mapping
def hmac_supported(self, algorithm):
- try:
- self._supported_hmac_algorithms[algorithm.name]
- except KeyError:
- return False
- else:
- return True
+ return algorithm.name in self._supported_hmac_algorithms
def create_hash_ctx(self, algorithm):
return _HashContext(self, algorithm)
@@ -121,11 +111,7 @@
return _HMACContext(self, key, algorithm)
def cipher_supported(self, cipher, mode):
- try:
- self._cipher_registry[type(cipher), type(mode)]
- except KeyError:
- return False
- return True
+ return (type(cipher), type(mode)) in self._cipher_registry
def create_symmetric_encryption_ctx(self, cipher, mode):
if isinstance(mode, GCM):
diff --git a/docs/hazmat/primitives/key-derivation-functions.rst b/docs/hazmat/primitives/key-derivation-functions.rst
index 529f441..551dbd6 100644
--- a/docs/hazmat/primitives/key-derivation-functions.rst
+++ b/docs/hazmat/primitives/key-derivation-functions.rst
@@ -80,7 +80,7 @@
keys. See OWASP's `Password Storage Cheat Sheet`_ for more
detailed recommendations if you intend to use this for password storage.
:param backend: A
- :class:`~cryptography.hazmat.backends.interfaces.CipherBackend`
+ :class:`~cryptography.hazmat.backends.interfaces.PBKDF2HMACBackend`
provider.
.. method:: derive(key_material)