gh-136912: fix handling of `OverflowError` in `hmac.digest` (#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.
B
Bénédikt Tran committed
d658b9053beaacaae80e318f59a5ddd672aa757a
Parent: f7c380e
Committed by GitHub <noreply@github.com>
on 7/26/2025, 8:22:06 AM