aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/primitives/kdf/pbkdf2.py
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2018-12-02 19:20:33 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2018-12-02 06:20:33 -0500
commitafaa4c65b58e31f36a8162f88ad79829f68d0a86 (patch)
tree0660c30fe1382a2507c017b0df20c51544462258 /src/cryptography/hazmat/primitives/kdf/pbkdf2.py
parent3531439f8a09dd40102ac0e336cb962e86d8bf57 (diff)
downloadcryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.gz
cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.tar.bz2
cryptography-afaa4c65b58e31f36a8162f88ad79829f68d0a86.zip
centralize our bytes check (#4622)
this will make life a bit easier when we support bytearrays
Diffstat (limited to 'src/cryptography/hazmat/primitives/kdf/pbkdf2.py')
-rw-r--r--src/cryptography/hazmat/primitives/kdf/pbkdf2.py6
1 files changed, 2 insertions, 4 deletions
diff --git a/src/cryptography/hazmat/primitives/kdf/pbkdf2.py b/src/cryptography/hazmat/primitives/kdf/pbkdf2.py
index f8ce7a3b..fbe8964d 100644
--- a/src/cryptography/hazmat/primitives/kdf/pbkdf2.py
+++ b/src/cryptography/hazmat/primitives/kdf/pbkdf2.py
@@ -31,8 +31,7 @@ class PBKDF2HMAC(object):
self._used = False
self._algorithm = algorithm
self._length = length
- if not isinstance(salt, bytes):
- raise TypeError("salt must be bytes.")
+ utils._check_bytes("salt", salt)
self._salt = salt
self._iterations = iterations
self._backend = backend
@@ -42,8 +41,7 @@ class PBKDF2HMAC(object):
raise AlreadyFinalized("PBKDF2 instances can only be used once.")
self._used = True
- if not isinstance(key_material, bytes):
- raise TypeError("key_material must be bytes.")
+ utils._check_bytes("key_material", key_material)
return self._backend.derive_pbkdf2_hmac(
self._algorithm,
self._length,