Title: Handle error scenarios of HACL* functions · Issue #131316 · python/cpython · GitHub
Open Graph Title: Handle error scenarios of HACL* functions · Issue #131316 · python/cpython
X Title: Handle error scenarios of HACL* functions · Issue #131316 · python/cpython
Description: This is a follow-up on #130960 (comment): For all hash algorithms (NEW with this PR): malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) copy: may return NULL (out of memory) Full list from #130960 (comm...
Open Graph Description: This is a follow-up on #130960 (comment): For all hash algorithms (NEW with this PR): malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) copy: may return NULL (out...
X Description: This is a follow-up on #130960 (comment): For all hash algorithms (NEW with this PR): malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) copy: may return NULL (out...
Opengraph URL: https://github.com/python/cpython/issues/131316
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Handle error scenarios of HACL* functions","articleBody":"This is a follow-up on https://github.com/python/cpython/pull/130960#issuecomment-2726897435:\n\u003eFor all hash algorithms (NEW with this PR):\nmalloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory)\ncopy: may return NULL (out of memory)\n\nFull list from https://github.com/python/cpython/pull/130960#issuecomment-2715631704\n\u003e For Hacl_Streaming_HMAC:\n\u003e \n\u003e * malloc may return OutOfMemory, InvalidAlgorithm (e.g. requesting Blake2b_256 on an ARM machine), or Success\n\u003e * reset may return InvalidLength (if trying to reset the state with a key of different length, this is not supported), or Success\n\u003e * update: MaximumLengthExceeded or Success\n\u003e * digest: OutOfMemory or Success\n\u003e * copy: may return NULL (indicates out of memory)\n\u003e \n\u003e For all hash algorithms (_NEW with this PR_):\n\u003e \n\u003e * malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory)\n\u003e * copy: may return NULL (out of memory)\n\u003e \n\u003e For SHA3/Keccak only:\n\u003e \n\u003e * digest may return InvalidAlgorithm (if the algorithm is shake)\n\u003e * squeeze may return InvalidAlgorithm (if the algorithm is not shake)\n\u003e \n\u003e I think all of these can be handled as a followup, I just thought it would be good to have it in writing here so that you can decide which of these are worth checking for. The reason I brought up other hash algorithms is that, since you requested (or maybe @picnixz ?) proper out of memory handling in HACL*, we now may return NULL for other algorithms (like hash algorithms), meaning that this PR will introduce new possibly-NULL return values as a side-effect of updating the vendored copy of HACL*.\n\u003e \n\u003e For the record, Python ignores MaximumLengthExceeded on the basis that this cannot happen in practice.\n\n\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-131324\n* gh-135291\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/chris-eibl","@type":"Person","name":"chris-eibl"},"datePublished":"2025-03-16T07:03:54.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/131316/cpython/issues/131316"}
| 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:f2fcdb46-d64b-9783-65f0-1a0cef971229 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9274:31622E:C1F4F0:112E3C4:696A622C |
| html-safe-nonce | 016391ebbfcc97d4c2b4ca15a138da8c2e9ba5c08f04c3aded483f6c96c09911 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5Mjc0OjMxNjIyRTpDMUY0RjA6MTEyRTNDNDo2OTZBNjIyQyIsInZpc2l0b3JfaWQiOiI5Mzg3OTgzODU3MzQ1MDkxMDAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cdb77e5740f82e0ee87b94307c2a345aae242bb51e856aab995366aa7708e502 |
| hovercard-subject-tag | issue:2922827014 |
| 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/131316/issue_layout |
| twitter:image | https://opengraph.githubassets.com/a604e68dfd73f28783573b8d47361192e74554b58c04d21a73bf757a63d5edd7/python/cpython/issues/131316 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/a604e68dfd73f28783573b8d47361192e74554b58c04d21a73bf757a63d5edd7/python/cpython/issues/131316 |
| og:image:alt | This is a follow-up on #130960 (comment): For all hash algorithms (NEW with this PR): malloc, malloc_with_params_and_key, malloc_with_key: may return NULL (out of memory) copy: may return NULL (out... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | chris-eibl |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9b7735a184970dd9333b2cbe036c8f3c0a9108c64aaa93827c5a64fc70993392 |
| 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 | 87cbd411c2982752221b5751d583a515b23bf5fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width