Skip to content

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

Closed

Description

@picnixz

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

Activity

  1. self-assigned this
    on Aug 9, 2026
  2. added
    type-bugAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directory
    on Aug 9, 2026
  3. added 3 commits that reference this issue on Oct 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

stdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions