VYPR
High severity7.5NVD Advisory· Published Mar 27, 2017· Updated May 13, 2026

CVE-2016-9243

CVE-2016-9243

Description

HKDF in cryptography before 1.5.2 returns an empty byte-string if used with a length less than algorithm.digest_size.

Affected packages

Versions sourced from the GitHub Security Advisory.

PackageAffected versionsPatched versions
cryptographyPyPI
< 1.5.31.5.3

Patches

1
b924696b2e87

Fixes #3211 -- fixed hkdf's output with short length (#3215)

https://github.com/pyca/cryptographyAlex GaynorNov 6, 2016via ghsa
2 files changed · +12 1
  • src/cryptography/hazmat/primitives/kdf/hkdf.py+1 1 modified
    @@ -91,7 +91,7 @@ def _expand(self, key_material):
             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)
    
  • tests/hazmat/primitives/test_hkdf.py+11 0 modified
    @@ -142,6 +142,17 @@ def test_unicode_typeerror(self, backend):
     
                 hkdf.verify(b"foo", u"bar")
     
    +    def test_derive_short_output(self, backend):
    +        hkdf = HKDF(
    +            hashes.SHA256(),
    +            4,
    +            salt=None,
    +            info=None,
    +            backend=backend
    +        )
    +
    +        assert hkdf.derive(b"\x01" * 16) == b"gJ\xfb{"
    +
     
     @pytest.mark.requires_backend_interface(interface=HMACBackend)
     class TestHKDFExpand(object):
    

Vulnerability mechanics

Generated by null/stub on May 9, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.

References

19

News mentions

0

No linked articles in our index yet.