aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2019-01-17 15:56:23 -0600
committerAlex Gaynor <alex.gaynor@gmail.com>2019-01-17 16:56:23 -0500
commita77994408da328e6b0fba331211be9ad2db5c5b6 (patch)
tree240940ee473a526d3438514799665dc4463dc0d8 /src
parent2b40f493bf6f9eb131b46d7ab582b89033bcda64 (diff)
downloadcryptography-a77994408da328e6b0fba331211be9ad2db5c5b6.tar.gz
cryptography-a77994408da328e6b0fba331211be9ad2db5c5b6.tar.bz2
cryptography-a77994408da328e6b0fba331211be9ad2db5c5b6.zip
support byteslike in ConcatKDF{HMAC,Hash}, Scrypt, and X963KDF (#4709)
* byteslike concatkdf * byteslike scrypt * byteslike x963kdf
Diffstat (limited to 'src')
-rw-r--r--src/cryptography/hazmat/backends/openssl/backend.py3
-rw-r--r--src/cryptography/hazmat/primitives/kdf/concatkdf.py2
-rw-r--r--src/cryptography/hazmat/primitives/kdf/scrypt.py2
-rw-r--r--src/cryptography/hazmat/primitives/kdf/x963kdf.py2
4 files changed, 5 insertions, 4 deletions
diff --git a/src/cryptography/hazmat/backends/openssl/backend.py b/src/cryptography/hazmat/backends/openssl/backend.py
index f74c955a..ab0daa28 100644
--- a/src/cryptography/hazmat/backends/openssl/backend.py
+++ b/src/cryptography/hazmat/backends/openssl/backend.py
@@ -2181,8 +2181,9 @@ class Backend(object):
def derive_scrypt(self, key_material, salt, length, n, r, p):
buf = self._ffi.new("unsigned char[]", length)
+ key_material_ptr = self._ffi.from_buffer(key_material)
res = self._lib.EVP_PBE_scrypt(
- key_material, len(key_material), salt, len(salt), n, r, p,
+ key_material_ptr, len(key_material), salt, len(salt), n, r, p,
scrypt._MEM_LIMIT, buf, length
)
if res != 1:
diff --git a/src/cryptography/hazmat/primitives/kdf/concatkdf.py b/src/cryptography/hazmat/primitives/kdf/concatkdf.py
index 89c3b282..65b25cdc 100644
--- a/src/cryptography/hazmat/primitives/kdf/concatkdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/concatkdf.py
@@ -32,7 +32,7 @@ def _common_args_checks(algorithm, length, otherinfo):
def _concatkdf_derive(key_material, length, auxfn, otherinfo):
- utils._check_bytes("key_material", key_material)
+ utils._check_byteslike("key_material", key_material)
output = [b""]
outlen = 0
counter = 1
diff --git a/src/cryptography/hazmat/primitives/kdf/scrypt.py b/src/cryptography/hazmat/primitives/kdf/scrypt.py
index 44e369fb..df9745e6 100644
--- a/src/cryptography/hazmat/primitives/kdf/scrypt.py
+++ b/src/cryptography/hazmat/primitives/kdf/scrypt.py
@@ -52,7 +52,7 @@ class Scrypt(object):
raise AlreadyFinalized("Scrypt instances can only be used once.")
self._used = True
- utils._check_bytes("key_material", key_material)
+ utils._check_byteslike("key_material", key_material)
return self._backend.derive_scrypt(
key_material, self._salt, self._length, self._n, self._r, self._p
)
diff --git a/src/cryptography/hazmat/primitives/kdf/x963kdf.py b/src/cryptography/hazmat/primitives/kdf/x963kdf.py
index a8c07751..fd9d125e 100644
--- a/src/cryptography/hazmat/primitives/kdf/x963kdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/x963kdf.py
@@ -46,7 +46,7 @@ class X963KDF(object):
if self._used:
raise AlreadyFinalized
self._used = True
- utils._check_bytes("key_material", key_material)
+ utils._check_byteslike("key_material", key_material)
output = [b""]
outlen = 0
counter = 1