From b924696b2e8731f39696584d12cceeb3aeb2d874 Mon Sep 17 00:00:00 2001 From: Alex Gaynor Date: Sat, 5 Nov 2016 22:08:21 -0400 Subject: Fixes #3211 -- fixed hkdf's output with short length (#3215) --- src/cryptography/hazmat/primitives/kdf/hkdf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/cryptography/hazmat/primitives/kdf/hkdf.py b/src/cryptography/hazmat/primitives/kdf/hkdf.py index f738bbdc..82ed9b1c 100644 --- a/src/cryptography/hazmat/primitives/kdf/hkdf.py +++ b/src/cryptography/hazmat/primitives/kdf/hkdf.py @@ -91,7 +91,7 @@ class HKDFExpand(object): output = [b""] counter = 1 - while (self._algorithm.digest_size // 8) * len(output) < self._length: + while self._algorithm.digest_size * (len(output) - 1) < self._length: h = hmac.HMAC(key_material, self._algorithm, backend=self._backend) h.update(output[-1]) h.update(self._info) -- cgit v1.2.3