Skip to content

Conversation

@picnixz
Copy link
Member

@picnixz picnixz commented Jul 26, 2025

The OpenSSL and HACL* implementations of HMAC single-shot digest computation reject keys whose length exceeds INT_MAX and UINT32_MAX respectively. The OpenSSL implementation also rejects messages whose length exceed INT_MAX.

Using such keys in hmac.digest previously raised an OverflowError which was propagated to the caller. This commit mitigates this case by making hmac.digest fall back to HMAC's pure Python implementation which accepts arbitrary large keys or messages.

This change only affects the top-level entrypoint hmac.digest, leaving _hashopenssl.hmac_digest and _hmac.compute_digest untouched.

(cherry picked from commit d658b90)

…st` (pythonGH-136917)

The OpenSSL and HACL* implementations of HMAC single-shot
digest computation reject keys whose length exceeds `INT_MAX`
and `UINT32_MAX` respectively. The OpenSSL implementation
also rejects messages whose length exceed `INT_MAX`.

Using such keys in `hmac.digest` previously raised an `OverflowError`
which was propagated to the caller. This commit mitigates this case by
making `hmac.digest` fall back to HMAC's pure Python implementation
which accepts arbitrary large keys or messages.

This change only affects the top-level entrypoint `hmac.digest`, leaving
`_hashopenssl.hmac_digest` and `_hmac.compute_digest` untouched.
(cherry picked from commit d658b90)

Co-authored-by: Bénédikt Tran <[email protected]>
@gpshead gpshead self-assigned this Jul 27, 2025
@gpshead
Copy link
Member

gpshead commented Jul 27, 2025

waiting for 3.14.1

@vstinner
Copy link
Member

vstinner commented Oct 7, 2025

@picnixz: Is it still a draft? The 3.14 branch was reopened for 3.14.1 changes.

@picnixz picnixz marked this pull request as ready for review October 8, 2025 09:57
@picnixz picnixz merged commit 8ad6eda into python:3.14 Oct 8, 2025
52 checks passed
@picnixz picnixz deleted the backport-d658b90-3.14 branch October 8, 2025 10:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants