]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-99108: Add HACL* Blake2 implementation to hashlib (GH-119316)
authorJonathan Protzenko <protz@microsoft.com>
Tue, 13 Aug 2024 21:42:19 +0000 (14:42 -0700)
committerGitHub <noreply@github.com>
Tue, 13 Aug 2024 21:42:19 +0000 (21:42 +0000)
commit325e9b8ef400b86fb077aa40d5cb8cec6e4df7bb
tree9c1677183d3a508207f05097e6751edce520d35e
parentee1b8ce26e700350e47a5f65201097121c41912e
gh-99108: Add HACL* Blake2 implementation to hashlib (GH-119316)

This replaces the existing hashlib Blake2 module with a single implementation that uses HACL\*'s Blake2b/Blake2s implementations. We added support for all the modes exposed by the Python API, including tree hashing, leaf nodes, and so on. We ported and merged all of these changes upstream in HACL\*, added test vectors based on Python's existing implementation, and exposed everything needed for hashlib.

This was joint work done with @R1kM.

See the PR for much discussion and benchmarking details.   TL;DR: On many systems, 8-50% faster (!) than `libb2`, on some systems it appeared 10-20% slower than `libb2`.
55 files changed:
Lib/test/test_hashlib.py
Makefile.pre.in
Misc/NEWS.d/next/Core and Builtins/2024-07-19-09-38-01.gh-issue-99108.qzM6gl.rst [new file with mode: 0644]
Misc/sbom.spdx.json
Modules/Setup.stdlib.in
Modules/_blake2/blake2b2s.py [deleted file]
Modules/_blake2/blake2b_impl.c [deleted file]
Modules/_blake2/blake2module.c [deleted file]
Modules/_blake2/blake2module.h [deleted file]
Modules/_blake2/blake2s_impl.c [deleted file]
Modules/_blake2/clinic/blake2s_impl.c.h [deleted file]
Modules/_blake2/impl/blake2-config.h [deleted file]
Modules/_blake2/impl/blake2-impl.h [deleted file]
Modules/_blake2/impl/blake2.h [deleted file]
Modules/_blake2/impl/blake2b-load-sse2.h [deleted file]
Modules/_blake2/impl/blake2b-load-sse41.h [deleted file]
Modules/_blake2/impl/blake2b-ref.c [deleted file]
Modules/_blake2/impl/blake2b-round.h [deleted file]
Modules/_blake2/impl/blake2b.c [deleted file]
Modules/_blake2/impl/blake2s-load-sse2.h [deleted file]
Modules/_blake2/impl/blake2s-load-sse41.h [deleted file]
Modules/_blake2/impl/blake2s-load-xop.h [deleted file]
Modules/_blake2/impl/blake2s-ref.c [deleted file]
Modules/_blake2/impl/blake2s-round.h [deleted file]
Modules/_blake2/impl/blake2s.c [deleted file]
Modules/_hacl/Hacl_Hash_Blake2b.c [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2b.h [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2b_Simd256.h [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2s.c [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2s.h [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2s_Simd128.c [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_Blake2s_Simd128.h [new file with mode: 0644]
Modules/_hacl/Hacl_Hash_SHA3.c
Modules/_hacl/Hacl_Hash_SHA3.h
Modules/_hacl/Lib_Memzero0.c [new file with mode: 0644]
Modules/_hacl/include/krml/internal/target.h
Modules/_hacl/internal/Hacl_Hash_Blake2b.h [new file with mode: 0644]
Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h [new file with mode: 0644]
Modules/_hacl/internal/Hacl_Hash_Blake2s.h [new file with mode: 0644]
Modules/_hacl/internal/Hacl_Hash_Blake2s_Simd128.h [new file with mode: 0644]
Modules/_hacl/internal/Hacl_Hash_SHA3.h
Modules/_hacl/internal/Hacl_Impl_Blake2_Constants.h [new file with mode: 0644]
Modules/_hacl/lib_memzero0.h [new file with mode: 0644]
Modules/_hacl/libintvector.h [new file with mode: 0644]
Modules/_hacl/python_hacl_namespaces.h
Modules/_hacl/refresh.sh
Modules/blake2module.c [new file with mode: 0644]
Modules/clinic/blake2module.c.h [moved from Modules/_blake2/clinic/blake2b_impl.c.h with 54% similarity]
PCbuild/pythoncore.vcxproj
Tools/build/generate_sbom.py
Tools/c-analyzer/cpython/_parser.py
configure
configure.ac
pyconfig.h.in