aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Kehrer <paul.l.kehrer@gmail.com>2017-12-02 00:41:25 +0800
committerAlex Gaynor <alex.gaynor@gmail.com>2017-12-01 11:41:25 -0500
commit9fa6fb273559d29d471df80942ce066e6e40dfde (patch)
tree7108f14bfee1aebafdade8c8282b4f0cee32013d
parent4662d44fd3db5078a1882100653a3dbab3e3c7a1 (diff)
downloadcryptography-9fa6fb273559d29d471df80942ce066e6e40dfde.tar.gz
cryptography-9fa6fb273559d29d471df80942ce066e6e40dfde.tar.bz2
cryptography-9fa6fb273559d29d471df80942ce066e6e40dfde.zip
Pass the right length of null bytes when no salt is provided to HKDF (#4036)
This bug looks bad but ends up being benign because HMAC is specified to pad null bytes if a key is too short. So we passed too few bytes and then OpenSSL obligingly padded it out to the correct length. However, we should still do the right thing obviously.
-rw-r--r--src/cryptography/hazmat/primitives/kdf/hkdf.py2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cryptography/hazmat/primitives/kdf/hkdf.py b/src/cryptography/hazmat/primitives/kdf/hkdf.py
index 82ed9b1c..964ac2cc 100644
--- a/src/cryptography/hazmat/primitives/kdf/hkdf.py
+++ b/src/cryptography/hazmat/primitives/kdf/hkdf.py
@@ -30,7 +30,7 @@ class HKDF(object):
raise TypeError("salt must be bytes.")
if salt is None:
- salt = b"\x00" * (self._algorithm.digest_size // 8)
+ salt = b"\x00" * self._algorithm.digest_size
self._salt = salt