python / python/cpython

`hmac.digest()` and `HMAC(...).digest()` disagree when blocksize is smaller than 16

Open
#155,428 0 comments 1 reaction 1 assignee View on GitHub

@picnixz is already working on this.

Since Aug 9, 2026.

stdlib type-bug
Dominant language
Python
Stars
77.2k
Forks
35.9k
PR merge metrics
PR metrics pending

Description

Bug report

Bug description:

hmac.digest() and HMAC(...).digest() return DIFFERENT MACs for any digest whose block_size is below 16, because hmac._compute_digest_fallback reads block_size raw while hmac.HMAC._init_old clamps it to 64.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs
  • gh-155429

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.