Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-99108: Implement HACL* HMAC#130157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
picnixz merged 55 commits intopython:mainfrompicnixz:feat/hmac/hacl-99108
Apr 4, 2025
Merged

Conversation

picnixz
Copy link
Member

@picnixzpicnixz commentedFeb 15, 2025
edited
Loading

This supersedes#126359.

Ideally, I'd like this to be part of 3.14 but we only have two alpha releases until the first beta.

Note that the HACL* HMAC implementation doesnot support truncated SHA-2-512/224 (which is different from SHA-2/224) so we need to either ask HACL* to do it or document it in thehmac module documentation.

For reviews, I would strongly advise review commit by commit instead of the entire file. Each commit should compile separately (assuming preceeding ones are present, maybe except the first few commits are not compiling due to some configure/build I forgot to put it at that time, but otherwise the interface was written incrementally).

cc@msprotz@gpshead


📚 Documentation preview 📚:https://cpython-previews--130157.org.readthedocs.build/

@picnixzpicnixzforce-pushed thefeat/hmac/hacl-99108 branch 2 times, most recently from21fcd9a to583c1f4CompareFebruary 15, 2025 14:15
@picnixz
Copy link
MemberAuthor

@msprotz I'm not sure if it's an HACL issue or not, butLib_IntVector_Intrinsics_vec256 inlibintvector.h is conditionnally exposed, yet it's unconditionally used in_hacl/Hacl_Streaming_Types.h.

@msprotz
Copy link
Contributor

You are correct -- there is one additional step to do to handle this case. Note that HMAC is the first time we havea file that contains references to vec128/vec256yet may be compiled on a system that has no such types. (Previously, Blake2b_256 was only ever built if vec256 was known at build-time to exist, and likewise with Blake2s_128.)

One option is to conditional includes, but that leads to other difficulties, such as having to hide cases of the agile hmac state union behind #ifdef, and then propagating #ifdefs everywhere in this file. This is error-prone and a lot of maintenance.

The other option we've done is simply to#define Lib_IntVector_Intrinsics_vec256 void * in case the build determines that HACL_CAN_COMPILE_VEC256 is false (and likewise with vec128). This solves all of the problems above and avoids a complicated include dance.

What I don't understand / remember, though, is why this isn't done directly inside libintvector.h. (We currently do it in our mini-configure for CI purposes and emit those #ifdefs in config.h.)

I'd be curious to see if you could manually patch libintvector.h to define those types to void* (in the #else case of #ifdef HACL_CAN_COMPILE_VEC256, and likewise for VEC128) and then see if we get a good build? I would then be happy to upstream this fix. Thank you!

@picnixzpicnixzforce-pushed thefeat/hmac/hacl-99108 branch 2 times, most recently froma993e69 to8ce1524CompareMarch 12, 2025 12:04
@picnixz
Copy link
MemberAuthor

picnixz commentedMar 12, 2025
edited
Loading

I'll wait for#130960 to be merged so that I don't need to re-update the SBOMs etc.

@picnixzpicnixzforce-pushed thefeat/hmac/hacl-99108 branch 7 times, most recently from22e3003 to56b3c8fCompareMarch 16, 2025 10:41
@picnixzpicnixz mentioned this pull requestMar 16, 2025
@msprotz
Copy link
Contributor

Agreed that SIMD can be left for later -- this should be transparent from the point of view of the clients.

Copy link
Member

@chris-eiblchris-eibl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

LGTM. Thank you@picnixz!

picnixzand others added2 commitsMarch 29, 2025 17:18
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
@picnixzpicnixz requested a review fromhugovkMarch 30, 2025 08:29
@picnixzpicnixz added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 1, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commit258aa20 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F130157%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 1, 2025
@picnixzpicnixz added the 🔨 test-with-refleak-buildbotsTest PR w/ refleak buildbots; report in status section labelApr 1, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@picnixz for commit258aa20 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F130157%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-refleak-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-refleak-buildbotsTest PR w/ refleak buildbots; report in status section labelApr 1, 2025
@picnixz
Copy link
MemberAuthor

picnixz commentedApr 1, 2025
edited
Loading

I expect failures on some FIPS-only build bots but that's fine because the test suite is already failing on them. And some failures on other build bots as well (like aarch64 which is known to be flaky these past days). Once all build bots are fine, I'll merge it (but only on Friday, as I'm leaving in a few hours) [so please don't merge it since I want to write the commit message, TiA]

@picnixzpicnixz merged commit0a97427 intopython:mainApr 4, 2025
42 checks passed
@picnixzpicnixz deleted the feat/hmac/hacl-99108 branchApril 4, 2025 17:04
@picnixz
Copy link
MemberAuthor

Thank you all for the feedback, especially@msprotz for the upstream work! The next step is to enable the SIMD support.

chris-eibl reacted with rocket emoji

picnixz added a commit to picnixz/cpython that referenced this pull requestApr 5, 2025
A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMACis not available or disabled. For now, only named hash algorithms are recognized and SIMD support providedby HACL* for the BLAKE2 hash functions is not yet used.
seehwan pushed a commit to seehwan/cpython that referenced this pull requestApr 16, 2025
A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMACis not available or disabled. For now, only named hash algorithms are recognized and SIMD support providedby HACL* for the BLAKE2 hash functions is not yet used.
zanieb added a commit to astral-sh/python-build-standalone that referenced this pull requestMay 17, 2025
The big changes here are:- Switching to zlib-ng on Windows(python/cpython#131438)- Using hmac for hashing functions(python/cpython#130157)---------Co-authored-by: Geoffrey Thomas <geofft@ldpreload.com>
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gpsheadgpsheadgpshead approved these changes

@AA-TurnerAA-TurnerAA-Turner approved these changes

@chris-eiblchris-eiblchris-eibl approved these changes

@sethmlarsonsethmlarsonAwaiting requested review from sethmlarsonsethmlarson is a code owner

@tirantiranAwaiting requested review from tirantiran is a code owner

@ericsnowcurrentlyericsnowcurrentlyAwaiting requested review from ericsnowcurrentlyericsnowcurrently is a code owner

@erlend-aaslanderlend-aaslandAwaiting requested review from erlend-aaslanderlend-aasland is a code owner

@corona10corona10Awaiting requested review from corona10corona10 is a code owner

@hugovkhugovkAwaiting requested review from hugovk

Assignees

@picnixzpicnixz

Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

7 participants
@picnixz@msprotz@bedevere-bot@gpshead@hugovk@AA-Turner@chris-eibl

[8]ページ先頭

©2009-2025 Movatter.jp