From 4e189556edf225eb76a3e829ba2cf171e4f890a2 Mon Sep 17 00:00:00 2001 From: tamaki0575-cloud <265693791+tamaki0575-cloud@users.noreply.github.com> Date: Sun, 22 Nov 2026 03:32:38 +1100 Subject: [PATCH 1/2] gh-162219: Provide explicit SIMD defaults for HACL streaming HMAC --- Makefile.pre.in | 4 ++-- Modules/_hmac_hacl.c | 11 +++++++++++ PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 2 +- 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 Modules/_hmac_hacl.c diff --git a/Makefile.pre.in b/Makefile.pre.in index 650838d68286c73..06653e5e52ab452 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1581,8 +1581,8 @@ $(LIBHACL_BLAKE2_LIB_STATIC): $(LIBHACL_BLAKE2_OBJS) Modules/_hacl/Hacl_HMAC.o: $(srcdir)/Modules/_hacl/Hacl_HMAC.c $(LIBHACL_HMAC_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_HMAC.c -Modules/_hacl/Hacl_Streaming_HMAC.o: $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c $(LIBHACL_HMAC_HEADERS) - $(CC) -Wno-unused-variable -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c +Modules/_hacl/Hacl_Streaming_HMAC.o: $(srcdir)/Modules/_hmac_hacl.c $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c $(LIBHACL_HMAC_HEADERS) + $(CC) -Wno-unused-variable -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hmac_hacl.c $(LIBHACL_HMAC_LIB_STATIC): $(LIBHACL_HMAC_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_HMAC_OBJS) diff --git a/Modules/_hmac_hacl.c b/Modules/_hmac_hacl.c new file mode 100644 index 000000000000000..358844e63c2ce33 --- /dev/null +++ b/Modules/_hmac_hacl.c @@ -0,0 +1,11 @@ +/* Compile the HACL* streaming HMAC implementation with explicit SIMD defaults. */ +#include "_hacl/internal/Hacl_Streaming_HMAC.h" + +#ifndef HACL_CAN_COMPILE_VEC128 +# define HACL_CAN_COMPILE_VEC128 0 +#endif +#ifndef HACL_CAN_COMPILE_VEC256 +# define HACL_CAN_COMPILE_VEC256 0 +#endif + +#include "_hacl/Hacl_Streaming_HMAC.c" diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index d16aa7b4254b453..9498b856cb266a4 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -458,7 +458,7 @@ - + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index 99b2631b673a80d..c63ffcae647c118 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -1028,7 +1028,7 @@ Modules - + Modules From edd38b5f0ae5154c9b8662c627f44f1724ceab66 Mon Sep 17 00:00:00 2001 From: tamaki0575-cloud <265693791+tamaki0575-cloud@users.noreply.github.com> Date: Sun, 22 Nov 2026 20:26:38 +1100 Subject: [PATCH 2/2] gh-162219: Move the HMAC wrapper beside the HACL sources --- Makefile.pre.in | 4 ++-- Modules/_hacl/README.md | 1 + Modules/{ => _hacl}/_hmac_hacl.c | 4 ++-- PCbuild/pythoncore.vcxproj | 2 +- PCbuild/pythoncore.vcxproj.filters | 2 +- Tools/build/generate_sbom.py | 1 + 6 files changed, 8 insertions(+), 6 deletions(-) rename Modules/{ => _hacl}/_hmac_hacl.c (72%) diff --git a/Makefile.pre.in b/Makefile.pre.in index 06653e5e52ab452..5e5564107a93d94 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -1581,8 +1581,8 @@ $(LIBHACL_BLAKE2_LIB_STATIC): $(LIBHACL_BLAKE2_OBJS) Modules/_hacl/Hacl_HMAC.o: $(srcdir)/Modules/_hacl/Hacl_HMAC.c $(LIBHACL_HMAC_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_HMAC.c -Modules/_hacl/Hacl_Streaming_HMAC.o: $(srcdir)/Modules/_hmac_hacl.c $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c $(LIBHACL_HMAC_HEADERS) - $(CC) -Wno-unused-variable -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hmac_hacl.c +Modules/_hacl/Hacl_Streaming_HMAC.o: $(srcdir)/Modules/_hacl/_hmac_hacl.c $(srcdir)/Modules/_hacl/Hacl_Streaming_HMAC.c $(LIBHACL_HMAC_HEADERS) + $(CC) -Wno-unused-variable -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/_hmac_hacl.c $(LIBHACL_HMAC_LIB_STATIC): $(LIBHACL_HMAC_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_HMAC_OBJS) diff --git a/Modules/_hacl/README.md b/Modules/_hacl/README.md index 0d6454cdd6efb36..c3fce79494b2f37 100644 --- a/Modules/_hacl/README.md +++ b/Modules/_hacl/README.md @@ -19,6 +19,7 @@ changes needed, work with the upstream repository. ## Local files +* [_hmac_hacl.c](_hmac_hacl.c) * [python_hacl_namespaces.h](python_hacl_namespaces.h) * [README.md](README.md) * [refresh.sh](refresh.sh) diff --git a/Modules/_hmac_hacl.c b/Modules/_hacl/_hmac_hacl.c similarity index 72% rename from Modules/_hmac_hacl.c rename to Modules/_hacl/_hmac_hacl.c index 358844e63c2ce33..a4e800736aeb911 100644 --- a/Modules/_hmac_hacl.c +++ b/Modules/_hacl/_hmac_hacl.c @@ -1,5 +1,5 @@ /* Compile the HACL* streaming HMAC implementation with explicit SIMD defaults. */ -#include "_hacl/internal/Hacl_Streaming_HMAC.h" +#include "internal/Hacl_Streaming_HMAC.h" #ifndef HACL_CAN_COMPILE_VEC128 # define HACL_CAN_COMPILE_VEC128 0 @@ -8,4 +8,4 @@ # define HACL_CAN_COMPILE_VEC256 0 #endif -#include "_hacl/Hacl_Streaming_HMAC.c" +#include "Hacl_Streaming_HMAC.c" diff --git a/PCbuild/pythoncore.vcxproj b/PCbuild/pythoncore.vcxproj index 9498b856cb266a4..3dea47e239df28a 100644 --- a/PCbuild/pythoncore.vcxproj +++ b/PCbuild/pythoncore.vcxproj @@ -458,7 +458,7 @@ - + diff --git a/PCbuild/pythoncore.vcxproj.filters b/PCbuild/pythoncore.vcxproj.filters index c63ffcae647c118..842795ecb2f6a6c 100644 --- a/PCbuild/pythoncore.vcxproj.filters +++ b/PCbuild/pythoncore.vcxproj.filters @@ -1028,7 +1028,7 @@ Modules - + Modules diff --git a/Tools/build/generate_sbom.py b/Tools/build/generate_sbom.py index 6975d9687f815dc..051ec48e00a4e08 100644 --- a/Tools/build/generate_sbom.py +++ b/Tools/build/generate_sbom.py @@ -77,6 +77,7 @@ class PackageFiles(typing.NamedTuple): exclude=[ "Modules/_hacl/refresh.sh", "Modules/_hacl/README.md", + "Modules/_hacl/_hmac_hacl.c", "Modules/_hacl/python_hacl_namespace.h", ] ),