René's URL Explorer Experiment


Title: gh-99108: Import SHA2-224 and SHA2-256 from HACL* by msprotz · Pull Request #99109 · python/cpython · GitHub

Open Graph Title: gh-99108: Import SHA2-224 and SHA2-256 from HACL* by msprotz · Pull Request #99109 · python/cpython

X Title: gh-99108: Import SHA2-224 and SHA2-256 from HACL* by msprotz · Pull Request #99109 · python/cpython

Description: Issue #99108 is about replacing hashlib primitives (for the non-OpenSSL case) with verified implementations from HACL*. This is the first PR in the series, and focuses specifically on SHA2-256 and SHA2-224. This PR imports Hacl_Streaming_SHA2 into the Python tree. This is the HACL* implementation of SHA2, which combines a core implementation of SHA2 along with a layer of buffer management that allows updating the digest with any number of bytes. This supersedes the previous implementation in the tree. @franziskuskiefer was kind enough to benchmark the changes: in addition to being verified (thus providing significant safety and security improvements), this implementation also provides a sizeable performance boost! --------------------------------------------------------------- Benchmark Time CPU Iterations --------------------------------------------------------------- Sha2_256_Streaming 3163 ns 3160 ns 219353 // this PR LibTomCrypt_Sha2_256 5057 ns 5056 ns 136234 // library used by Python currently The changes in this PR are as follows: import the subset of HACL* that covers SHA2-256/224 into Modules/_hacl rewire sha256module.c to use the HACL* implementation To review the changes, one should focus on sha256module.c, and possibly Hacl_Streaming_SHA2.h which is the API entry point. The rest of the files are part of HACL* and are cherry-picked straight from the HACL* repository, so as to minimize the amount of hand-edits and facilitate future refreshes of the code, should HACL* land some performance improvements. The original code comes from https://github.com/project-everest/hacl-star/tree/master/dist/gcc-compatible. The various .h files in include/, krmllib/, etc. will be shared across (hopefully) future primitives imported from HACL*. I can trim those files to minimize the amount of includes, but then this will make refreshing the code in the future harder (since the trimming will have to be redone for each refresh). The code was originally authored by @karthikbhargavan and I; @polubelova and @R1kM provided a considerable amount of help over the past week, as we were overhauling our implementation to offer a significant performance boost (we want this first PR to be a good one!). Thanks to everyone involved in this team effort. There are a couple remarks left in the source code, but for now, I think it's better to open up a PR and start discussing. As promised, tagging @alex for this PR. Thanks so much! Issue: gh-99108

Open Graph Description: Issue #99108 is about replacing hashlib primitives (for the non-OpenSSL case) with verified implementations from HACL*. This is the first PR in the series, and focuses specifically on SHA2-256 and ...

X Description: Issue #99108 is about replacing hashlib primitives (for the non-OpenSSL case) with verified implementations from HACL*. This is the first PR in the series, and focuses specifically on SHA2-256 and ...

Opengraph URL: https://github.com/python/cpython/pull/99109

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/commits/:range(.:format)
route-controllerpull_requests
route-actioncommits
fetch-noncev2:9071a4ce-970c-f111-44b3-52d2465c0c95
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD116:2F27D5:3E88A0:5169BC:699536F2
html-safe-nonce9b4e2d2b2e8cb29f1cdd2a48a19bde5e9c8dc43e15f6342405e0b1a4ea39205d
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEMTE2OjJGMjdENTozRTg4QTA6NTE2OUJDOjY5OTUzNkYyIiwidmlzaXRvcl9pZCI6IjcwNzQ5NTM0MzYzNzUzNjUzNjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmacb676b1f605367047b0c2a3ebbed428c71afe4c767e160f65e79edfaa1e15d431
hovercard-subject-tagpull_request:1111359087
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/commits
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
twitter:imagehttps://avatars.githubusercontent.com/u/10673049?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/10673049?s=400&v=4
og:image:altIssue #99108 is about replacing hashlib primitives (for the non-OpenSSL case) with verified implementations from HACL*. This is the first PR in the series, and focuses specifically on SHA2-256 and ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4bd759bc5f83244e2a0de29b937365905c0fefd238b6f077c24a49830375b4df
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/python/cpython git https://github.com/python/cpython.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id81598961
octolytics-dimension-repository_nwopython/cpython
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id81598961
octolytics-dimension-repository_network_root_nwopython/cpython
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasecac7d4a5a6053f6655d0c3e8bfe5fd7a55c216fd
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F99109%2Fcommits%2F9ec37a69f7f805050d2353626bf05ea81add3794
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Fcpython%2Fpull%2F99109%2Fcommits%2F9ec37a69f7f805050d2353626bf05ea81add3794
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Fcommits&source=header-repo&source_repo=python%2Fcpython
Reloadhttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Reloadhttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Reloadhttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
python https://github.com/python
cpythonhttps://github.com/python/cpython
Please reload this pagehttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Notifications https://github.com/login?return_to=%2Fpython%2Fcpython
Fork 34.1k https://github.com/login?return_to=%2Fpython%2Fcpython
Star 71.5k https://github.com/login?return_to=%2Fpython%2Fcpython
Code https://github.com/python/cpython
Issues 5k+ https://github.com/python/cpython/issues
Pull requests 2.1k https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects 31 https://github.com/python/cpython/projects
Security 0 https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Code https://github.com/python/cpython
Issues https://github.com/python/cpython/issues
Pull requests https://github.com/python/cpython/pulls
Actions https://github.com/python/cpython/actions
Projects https://github.com/python/cpython/projects
Security https://github.com/python/cpython/security
Insights https://github.com/python/cpython/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fpython%2Fcpython%2Fissues%2Fnew%2Fchoose
gpsheadhttps://github.com/gpshead
python:mainhttps://github.com/python/cpython/tree/main
msprotz:sha2_haclhttps://github.com/msprotz/cpython/tree/sha2_hacl
Conversation 40 https://github.com/python/cpython/pull/99109
Commits 36 https://github.com/python/cpython/pull/99109/commits
Checks 0 https://github.com/python/cpython/pull/99109/checks
Files changed https://github.com/python/cpython/pull/99109/files
Please reload this pagehttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
gh-99108: Import SHA2-224 and SHA2-256 from HACL* https://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794#top
Show all changes 36 commits https://github.com/python/cpython/pull/99109/files
f941537 Replace SHA2 implementation with verified code from HACL* msprotz Nov 4, 2022 https://github.com/python/cpython/pull/99109/commits/f941537517177ebd342f1375eba70fc89beabb70
89712f6 Fixup some casts msprotz Nov 4, 2022 https://github.com/python/cpython/pull/99109/commits/89712f60e70bc28056f94cba62548b3013f591a8
21fddf1 And proper error handling for maximum hashing lengths exceeded msprotz Nov 4, 2022 https://github.com/python/cpython/pull/99109/commits/21fddf15a5e78a7a3f98cfe4f35ae37874702e63
6c5498e Remove extra file msprotz Nov 4, 2022 https://github.com/python/cpython/pull/99109/commits/6c5498eb892623df036b17fbaa77a352ba78dee4
77c682c See if using srcdir helps msprotz Nov 4, 2022 https://github.com/python/cpython/pull/99109/commits/77c682c633d6652683feee4fb3b3451184e3b58b
1586188 Delete 11 un-needed files msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/158618826c66d2c39f2ff08dabf9b4b8558a2504
621ef0d Wrong direction for error checking msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/621ef0dd112e61cbdc5c73a00c31f4b4128d51a6
81cac0f Remove another four files msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/81cac0f7f0cd178449f8fd065abfc97625e99d3b
5134c6a better code quality msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/5134c6ab723071a7b1fe28b07a0479856f2a000e
f212447 Fixup memory management mistake msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/f21244796b3f3d13078d2d1ca34ba346a7bf622a
6543fdd Fix Linux build msprotz Nov 7, 2022 https://github.com/python/cpython/pull/99109/commits/6543fdd1f153175a267e36168a3b686dd3b094e4
a52e9ce Address review comments from @tiran; regenerate configure msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/a52e9ce7c69660ed2aee47d9f7676f86b7a96792
de35332 Merge remote-tracking branch 'origin/sha2_hacl' into sha2_hacl msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/de353321143f704be724567caae244b664462128
7f997a9 Move Linux & BSD CFLAGS into configure msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/7f997a9aed641494db1789092bdf839d566c6118
ec36acb Add NEWS entry. msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/ec36acb46039e19de21db30ed2048a802b40f194
c5d5e67 SRCDIRS msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/c5d5e67b08d824ad54055359bef012862e244869
adc0b8b Properly regenerate configure msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/adc0b8b1fe50e9d1ad3064caba34b043949d8158
ca1e02e Fix paths in Windows build msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/ca1e02e16af8f1620c7d81e339a923c35780f014
47be718 Add include directory msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/47be718fe68c528b1b41c90a33a79b13492a0944
b508177 Fixup include paths msprotz Nov 8, 2022 https://github.com/python/cpython/pull/99109/commits/b5081778e8349b0f55831b65fc449fa2cb6ba1eb
e893889 Fix patchcheck msprotz Nov 9, 2022 https://github.com/python/cpython/pull/99109/commits/e893889a4cdd56f96b1e3eace555c7b1b57e0381
1c82dc2 Automate import of HACL* into the tree with a script msprotz Dec 20, 2022 https://github.com/python/cpython/pull/99109/commits/1c82dc2c19e8ed5284e9c194e71f60a50bee6c75
a632c84 Use newly-implemented copy operation msprotz Dec 20, 2022 https://github.com/python/cpython/pull/99109/commits/a632c84b6c09e87b51378821f171f1ddce8df6aa
60d87fe Merge remote-tracking branch 'upstream/main' into sha2_hacl msprotz Dec 20, 2022 https://github.com/python/cpython/pull/99109/commits/60d87fe7958faba95c0f7ac4c6585c6507b3fb22
f4b267e Add a suitable test for data > 4GB msprotz Dec 20, 2022 https://github.com/python/cpython/pull/99109/commits/f4b267ebe24d5b8c33001b11eaab68a8f10e575c
537831e Make more robust & follow shellcheck. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/537831e052b16849946d92376ee6f1344806df21
f33e2ef Update to the latest HACL* revision. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/f33e2efe612e6c575d8d93ac5d9346c8e2396237
ce292e7 Add a README to the _hacl directory. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/ce292e751b0b8df0de35437e7d4613b2d308d70f
aa24fd4 reword and ReSTify the news entry. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/aa24fd4332608f7c5f83e2c7bc8dd673e003ce1d
29fd3c9 Dynamically rename the Hacl_ C symbols. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/29fd3c94f4de81800314f3704def039e76bfe06f
0362c1a missing file add & readme update. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/0362c1a850cc3118e5bde394ad49f5d8238cbb90
0f33a6a _ gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/0f33a6aed87dc84731bcb86b9ec471e0531729f3
d7c1240 remove wrongly placed defines. gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/d7c12407dfc18796bb9632ab5c7175d9456c3ebb
9ec37a6 Merge branch 'main' into sha2_hacl gpshead Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
92033ad Stylistic fix in Modules/sha256module.c msprotz Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/92033ad520892d39664e92e9c7e2d43fa99658d4
c670530 Fix a warning on Windows builders msprotz Jan 31, 2023 https://github.com/python/cpython/pull/99109/commits/c6705301aa34287457dd4d1c4b7fc147c3d9912e
Clear filters https://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Please reload this pagehttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Please reload this pagehttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
Prev https://github.com/python/cpython/pull/99109/commits/d7c12407dfc18796bb9632ab5c7175d9456c3ebb
Next https://github.com/python/cpython/pull/99109/commits/92033ad520892d39664e92e9c7e2d43fa99658d4
Please reload this pagehttps://github.com/python/cpython/pull/99109/commits/9ec37a69f7f805050d2353626bf05ea81add3794
https://github.com/gpshead
gpsheadhttps://github.com/python/cpython/commits?author=gpshead
view the diff.https://github.com/python/cpython/commit/9ec37a69f7f805050d2353626bf05ea81add3794
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.