aboutsummaryrefslogtreecommitdiffstats
path: root/src/cryptography/hazmat/primitives/kdf/scrypt.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/scrypt.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/scrypt.py')
-rw-r--r--src/cryptography/hazmat/primitives/kdf/scrypt.py7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/cryptography/hazmat/primitives/kdf/scrypt.py b/src/cryptography/hazmat/primitives/kdf/scrypt.py
index 77dcf9ab..44e369fb 100644
--- a/src/cryptography/hazmat/primitives/kdf/scrypt.py
+++ b/src/cryptography/hazmat/primitives/kdf/scrypt.py
@@ -30,9 +30,7 @@ class Scrypt(object):
)
self._length = length
- if not isinstance(salt, bytes):
- raise TypeError("salt must be bytes.")
-
+ utils._check_bytes("salt", salt)
if n < 2 or (n & (n - 1)) != 0:
raise ValueError("n must be greater than 1 and be a power of 2.")
@@ -54,8 +52,7 @@ class Scrypt(object):
raise AlreadyFinalized("Scrypt 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_scrypt(
key_material, self._salt, self._length, self._n, self._r, self._p
)