GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Clinic signatures of HACL* hash functions are inconsistent with OpenSSL implementation · Issue #134696 · python/cpython

Clinic signatures of HACL* hash functions are inconsistent with OpenSSL implementation #134696

New issue
Copy link
New issue
Copy link
Closed
Closed
Clinic signatures of HACL* hash functions are inconsistent with OpenSSL implementation#134696
Copy link
Assignees
picnixz
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@8R0WNI3
8R0WNI3
opened on May 26, 2025
Issue body actions

Bug description:

According to its docstring, the function hashlib.shake_128(...).hexdigest() should accept an argument length, either as positional or as keyword argument. However, since Python 3.14, the function only accepts positional arguments and fails with TypeError: shake_128.hexdigest() takes no keyword arguments otherwise.

I narrowed the root cause for this behaviour down to the following two commits (I'm not 100% sure though as I don't have any C-background):

  • 1f77739
  • 061e50f

Reproducer:

import hashlib
hashlib.shake_128(b'').hexdigest(1) # working
hashlib.shake_128(b'').hexdigest(length=1) # not working anymore, but was working before

For example, on Python Python 3.13.3 (main, Apr 8 2025, 13:54:08) [Clang 17.0.0 (clang-1700.0.13.3)] on my mac I can still use the keyword argument, but on alpine:edge Python 3.12.10 (main, May 21 2025, 16:23:36) [GCC 14.2.0] on linux it is expecting positional arguments only.

CPython versions tested on:

CPython main branch, 3.14, 3.13, 3.12

Operating systems tested on:

Linux, macOS

Linked PRs

  • gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures #134713
  • gh-134696: fix hashlib FIPS-only BLAKE-2 buildbot  #134968
  • [3.14] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) #134961
  • [3.13] gh-134696: align OpenSSL and HACL*-based hash functions constructors AC signatures (GH-134713) #134962

Activity

Next
  1. 8R0WNI3
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on May 26, 2025
  2. picnixz
    added
    extension-modulesC modules in the Modules dirC modules in the Modules dir
    topic-argument-clinic
    on May 26, 2025
  3. picnixz commented on May 26, 2025

    @picnixz
    picnixz
    on May 26, 2025
    Member
    More actions

    I cannot reproduce the issue. On Python 3.15, it works well and I don't think I change anything between 3.14 and 3.15 (namely I can use a keyword argument). If you cannot use a keyword argument on 3.12, then I think it's ok? I mean, the recent behavior is an extension of the old one.

  4. picnixz
    added
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    on May 26, 2025
  5. 8R0WNI3 commented on May 26, 2025

    @8R0WNI3
    8R0WNI3
    on May 26, 2025
    Author
    More actions

    On alpine:3 running Python 3.12.10 (main, May 21 2025, 20:03:03) [GCC 14.2.0], the keyword argument is allowed (this was the behaviour in the past and seems to be the case in 3.15 as well. However, on alpine:edge running Python 3.12.10 (main, May 21 2025, 16:23:36) [GCC 14.2.0], the keyword argument is not allowed anymore.

  6. picnixz commented on May 26, 2025

    @picnixz
    picnixz
    on May 26, 2025
    Member
    More actions

    3.12 is security-only so we won't fix this IMO (it's not a security issue). In your comment, you're linking 3.12.10 twice so I don't really understand which one is 3.12 or not (only the timestamps change and I don't know which correspond to what)

  7. encukou commented on May 26, 2025

    @encukou
    encukou
    on May 26, 2025
    Member
    More actions

    Could you share how you're installing dependencies & building CPython on alpine:edge?

  8. 8R0WNI3 commented on May 26, 2025

    @8R0WNI3
    8R0WNI3
    on May 26, 2025
    Author
    More actions

    Reproducer:

    > docker run -it alpine:edge
      > apk add python3
      > python3 -c "import hashlib; print(hashlib.shake_128(b'').hexdigest(length=1))"

    However, in the meantime I figured if I run apk upgrade libcrypto3, the keyword argument is accepted again, so this might be an issue between Python and openssl?

  9. picnixz commented on May 26, 2025

    @picnixz
    picnixz
    on May 26, 2025
    Member
    More actions

    I may have an idea. What's the output of type(hashlib.shak_128(b''). If OpenSSl is not installed, then we may have fell back on the HACL* implementation

  10. picnixz commented on May 26, 2025

    @picnixz
    picnixz
    on May 26, 2025
    Member
    More actions

    And indeed there is some issue here:

    Image

    This is in _sha3module. So the HACL* implementation doesn't allow for keyword arguments. Thanks for spotting this disparity.

    Reacted by Jonas Brand and Philipp Heil
  11. picnixz
    changed the title [-]`hashlib.shake_128().hexdigest()` no support for keyword arguments anymore[/-] [+]Signature for `shake_{128,256}.hexdigest()` is not inconsistent between OpenSSL and HACL* implementation[/+] on May 26, 2025
  12. picnixz
    added
    3.13only security fixesonly security fixes
    and removed
    pendingThe issue will be closed if no feedback is providedThe issue will be closed if no feedback is provided
    topic-argument-clinic
    on May 26, 2025
  13. 10 remaining items

  14. picnixz
    changed the title [-]Clinic signatures in `_sha3` and `_blake2` are inconsistent with OpenSSL implementation[/-] [+]Clinic signatures of HACL* hash functions are inconsistent with OpenSSL implementation[/+] on May 26, 2025
  15. picnixz
    added 9 commits that reference this issue on May 31, 2025

    gh-134696: align OpenSSL and HACL*-based hash functions constructors …

    c6e63d9

    [3.14] pythongh-134696: align OpenSSL and HACL*-based hash functions …

    8235738

    [3.13] pythongh-134696: align OpenSSL and HACL*-based hash functions …

    4ba757a

    gh-134696: fix `hashlib` tests for FIPS-only BLAKE-2 buildbot (#134968)

    379d0bc

    pythongh-134696: fix `hashlib` tests for FIPS-only BLAKE-2 buildbot (p…

    622dea0

    [3.14] pythongh-134696: align OpenSSL and HACL*-based hash functions …

    ab91460

    [3.13] pythongh-134696: align OpenSSL and HACL*-based hash functions …

    ad4c913

    [3.14] gh-134696: align OpenSSL and HACL*-based hash functions constr…

    777fd49

    [3.13] gh-134696: align OpenSSL and HACL*-based hash functions constr…

    2c325e2
  16. picnixz
    closed this as completedon Jun 2, 2025
  17. Pranjal095
    added 2 commits that reference this issue on Jul 12, 2025

    pythongh-134696: align OpenSSL and HACL*-based hash functions constru…

    cd0fc32

    pythongh-134696: fix `hashlib` tests for FIPS-only BLAKE-2 buildbot (p…

    bac898b
  18. taegyunkim
    added 2 commits that reference this issue on Aug 4, 2025

    pythongh-134696: align OpenSSL and HACL*-based hash functions constru…

    f7105df

    pythongh-134696: fix `hashlib` tests for FIPS-only BLAKE-2 buildbot (p…

    5e8fec9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @picnixz
    picnixz

Labels

3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixesextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.