Title: SystemError in OpenSSL's SHAKE when passing negative digest sizes · Issue #135759 · python/cpython · GitHub
Open Graph Title: SystemError in OpenSSL's SHAKE when passing negative digest sizes · Issue #135759 · python/cpython
X Title: SystemError in OpenSSL's SHAKE when passing negative digest sizes · Issue #135759 · python/cpython
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'...
Open Graph 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'').di...
X 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.s...
Opengraph URL: https://github.com/python/cpython/issues/135759
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"SystemError in OpenSSL's SHAKE when passing negative digest sizes","articleBody":"# Bug report\n\n### Bug description:\n\n```py\nimport _hashlib\n\n_hashlib.openssl_shake_128(b'').digest(-1) # SystemError\n_hashlib.openssl_shake_128(b'').hexdigest(-1) # MemoryError\n\nimport _sha3\n_sha3.shake_128(b'').digest(-1) # ValueError\n_sha3.shake_128(b'').hexdigest(-1) # ValueError\n```\n\nThe 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 https://github.com/python/cpython/pull/135744 for this issue at the same time.\n\nNow, 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 https://github.com/python/cpython/issues/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.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\n_No response_\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-135767\n\u003c!-- /gh-linked-prs -->\n\n> [!NOTE]\n> See https://github.com/python/cpython/issues/135759#issuecomment-2992097338 for the rationale of a non-backport.","author":{"url":"https://github.com/picnixz","@type":"Person","name":"picnixz"},"datePublished":"2025-06-20T14:12:33Z","url":"https://github.com/python/cpython/issues/135759"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:c5414318-67df-6b1a-be7f-5293185b581a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CC8E:21DFED:220495:2B52D3:6B01F403 |
| html-safe-nonce | 4dc6b4e395ca6974bb2990109ad3a472416c412474597f251bf9517a1f808760 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDQzhFOjIxREZFRDoyMjA0OTU6MkI1MkQzOjZCMDFGNDAzIiwidmlzaXRvcl9pZCI6IjIwOTU3MDEwMzI5OTM2ODI0MzUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 68594a6dd3fea8728cdcffc21f059a8b3b868ae4490fd50af7b3e6dd99054347 |
| hovercard-subject-tag | issue:3163483907 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/135759/issue_layout |
| twitter:image | https://opengraph.githubassets.com/0f8a65b14a8f11110d660db5c0793eeeb9af62e81a943d52fc09567bda4bb562/python/cpython/issues/135759 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/0f8a65b14a8f11110d660db5c0793eeeb9af62e81a943d52fc09567bda4bb562/python/cpython/issues/135759 |
| og:image:alt | 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'').di... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | picnixz |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width