mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
gh-99108: Replace SHA2-224 & 256 with verified code from HACL* (#99109)
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 Co-authored-by: Gregory P. Smith [Google LLC] <greg@krypto.org> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
914f8fd9f7
commit
1fcc0efdaa
18 changed files with 1779 additions and 350 deletions
3
configure
generated
vendored
3
configure
generated
vendored
|
@ -24426,6 +24426,7 @@ SRCDIRS="\
|
|||
Modules/_ctypes \
|
||||
Modules/_decimal \
|
||||
Modules/_decimal/libmpdec \
|
||||
Modules/_hacl \
|
||||
Modules/_io \
|
||||
Modules/_multiprocessing \
|
||||
Modules/_sha3 \
|
||||
|
@ -26966,7 +26967,7 @@ fi
|
|||
as_fn_append MODULE_BLOCK "MODULE__SHA256_STATE=$py_cv_module__sha256$as_nl"
|
||||
if test "x$py_cv_module__sha256" = xyes; then :
|
||||
|
||||
|
||||
as_fn_append MODULE_BLOCK "MODULE__SHA256_CFLAGS=-I\$(srcdir)/Modules/_hacl/include -I\$(srcdir)/Modules/_hacl/internal -D_BSD_SOURCE -D_DEFAULT_SOURCE$as_nl"
|
||||
|
||||
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue