FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

SystemError in OpenSSL's SHAKE when passing negative digest sizes · Issue #135759 · python/cpython · GitHub

Repository navigation

SystemError in OpenSSL's SHAKE when passing negative digest sizes #135759

Description

Bug report

Bug description:

import _hashlib

_hashlib.openssl_shake_128(b'').digest(-1)     # SystemError
_hashlib.openssl_shake_128(b'').hexdigest(-1)  # MemoryError

import _sha3
_sha3.shake_128(b'').digest(-1)                # ValueError
_sha3.shake_128(b'').hexdigest(-1)             # ValueError

The reason is that OpenSSL implementation accepts a ssize_t but HACL* accepts a uint32_t. I suggest raising a ValueError in OpenSSL's implementation as well. I'll rewrite #135744 for this issue at the same time.

Now, to prevent users passing incorrect data length, I also suggest to restrict has lengths to 2 ** 29 as it was done in HACL* and in #79103 but I'll do it in a follow-up. In the first time, let's only focus on raising a ValueError for all implementations on negative inputs.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Linked PRs

Note

See #135759 (comment) for the rationale of a non-backport.

Activity

  1. self-assigned this
    on Jun 20, 2025
  2. picnixz commented on Jun 20, 2025

    MemberAuthor

    I'm not going to backport this as this changes error messages and exception types. AFAIK, there is no crash, just weird exception types.

  3. added a commit that references this issue on Jun 21, 2025
  4. added a commit that references this issue on Jul 12, 2025
  5. added a commit that references this issue on Aug 4, 2025
  6. added a commit that references this issue on Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


    Back | FazBrowse Home | New Git URL