[3.14] gh-136912: fix handling of `OverflowError` in `hmac.digest` (GH-136917) (#137116)
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 d658b9053beaacaae80e318f59a5ddd672aa757a)
B
Bénédikt Tran committed
8ad6eda4830f480380f84c2847acd7f550b2d1c2
Parent: c625839
Committed by GitHub <noreply@github.com>
on 10/8/2025, 10:09:45 AM