https://github.com/python/cpython/commit/5f2ba152a0471f6f556ca2d9486e5ba486fcfbde commit: 5f2ba152a0471f6f556ca2d9486e5ba486fcfbde branch: main author: Bénédikt Tran <10796600+picn...@users.noreply.github.com> committer: gpshead <g...@krypto.org> date: 2025-04-20T17:40:17Z summary:
gh-131298: eliminate HACL* static libraries for cryptographic modules (GH-132438) * simplify HACL* build for MD5, SHA1, SHA2 and SHA3 modules * remove statically linked libraries for HACL* implementation * is it better now? * is it better now? * fixup * Present HACL* as a static or shared library. On WASI, extension modules based on HACL* require the HACL* library to be linked statically. On other platforms, it can be built dynamically. * amend whitespace * remove temporary .so file as it requires more symlinks * avoid smelly symbols * fixup checksums * regen sbom * fixup shell warnings and comments * it *should* work files: M Makefile.pre.in M Misc/sbom.spdx.json M Modules/Setup.stdlib.in M Modules/_hacl/lib_memzero0.h M Modules/_hacl/python_hacl_namespaces.h M Modules/_hacl/refresh.sh M Modules/makesetup M configure M configure.ac diff --git a/Makefile.pre.in b/Makefile.pre.in index e41a26e469dc22..886bd7ae1c504d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -227,17 +227,12 @@ ENSUREPIP= @ENSUREPIP@ # Internal static libraries LIBMPDEC_A= Modules/_decimal/libmpdec/libmpdec.a LIBEXPAT_A= Modules/expat/libexpat.a -LIBHACL_MD5_A= Modules/_hacl/libHacl_Hash_MD5.a -LIBHACL_SHA1_A= Modules/_hacl/libHacl_Hash_SHA1.a -LIBHACL_SHA2_A= Modules/_hacl/libHacl_Hash_SHA2.a -LIBHACL_SHA3_A= Modules/_hacl/libHacl_Hash_SHA3.a -LIBHACL_BLAKE2_A= Modules/_hacl/libHacl_Hash_Blake2.a -LIBHACL_HMAC_A= Modules/_hacl/libHacl_HMAC.a + +# HACL* build configuration LIBHACL_CFLAGS=@LIBHACL_CFLAGS@ -LIBHACL_SIMD128_FLAGS=@LIBHACL_SIMD128_FLAGS@ -LIBHACL_SIMD256_FLAGS=@LIBHACL_SIMD256_FLAGS@ -LIBHACL_SIMD128_OBJS=@LIBHACL_SIMD128_OBJS@ -LIBHACL_SIMD256_OBJS=@LIBHACL_SIMD256_OBJS@ +LIBHACL_LDFLAGS=@LIBHACL_LDFLAGS@ +LIBHACL_BLAKE2_SIMD128_CFLAGS=@LIBHACL_SIMD128_FLAGS@ -DHACL_CAN_COMPILE_VEC128 +LIBHACL_BLAKE2_SIMD256_CFLAGS=@LIBHACL_SIMD256_FLAGS@ -DHACL_CAN_COMPILE_VEC256 # Module state, compiler flags and linker flags # Empty CFLAGS and LDFLAGS are omitted. @@ -660,25 +655,40 @@ LIBEXPAT_HEADERS= \ ########################################################################## # hashlib's HACL* library +# +# On WASI, static build is required. +# On other platforms, a shared library is used. LIBHACL_MD5_OBJS= \ Modules/_hacl/Hacl_Hash_MD5.o +LIBHACL_MD5_LIB_STATIC=Modules/_hacl/libHacl_Hash_MD5.a +LIBHACL_MD5_LIB_SHARED=$(LIBHACL_MD5_OBJS) LIBHACL_SHA1_OBJS= \ Modules/_hacl/Hacl_Hash_SHA1.o +LIBHACL_SHA1_LIB_STATIC=Modules/_hacl/libHacl_Hash_SHA1.a +LIBHACL_SHA1_LIB_SHARED=$(LIBHACL_SHA1_OBJS) LIBHACL_SHA2_OBJS= \ Modules/_hacl/Hacl_Hash_SHA2.o +LIBHACL_SHA2_LIB_STATIC=Modules/_hacl/libHacl_Hash_SHA2.a +LIBHACL_SHA2_LIB_SHARED=$(LIBHACL_SHA2_OBJS) LIBHACL_SHA3_OBJS= \ Modules/_hacl/Hacl_Hash_SHA3.o +LIBHACL_SHA3_LIB_STATIC=Modules/_hacl/libHacl_Hash_SHA3.a +LIBHACL_SHA3_LIB_SHARED=$(LIBHACL_SHA3_OBJS) +LIBHACL_BLAKE2_SIMD128_OBJS=@LIBHACL_BLAKE2_SIMD128_OBJS@ +LIBHACL_BLAKE2_SIMD256_OBJS=@LIBHACL_BLAKE2_SIMD256_OBJS@ LIBHACL_BLAKE2_OBJS= \ Modules/_hacl/Hacl_Hash_Blake2s.o \ Modules/_hacl/Hacl_Hash_Blake2b.o \ Modules/_hacl/Lib_Memzero0.o \ - $(LIBHACL_SIMD128_OBJS) \ - $(LIBHACL_SIMD256_OBJS) + $(LIBHACL_BLAKE2_SIMD128_OBJS) \ + $(LIBHACL_BLAKE2_SIMD256_OBJS) +LIBHACL_BLAKE2_LIB_STATIC=Modules/_hacl/libHacl_Hash_BLAKE2.a +LIBHACL_BLAKE2_LIB_SHARED=$(LIBHACL_BLAKE2_OBJS) LIBHACL_HMAC_OBJS= \ Modules/_hacl/Hacl_HMAC.o \ @@ -688,6 +698,8 @@ LIBHACL_HMAC_OBJS= \ $(LIBHACL_SHA2_OBJS) \ $(LIBHACL_SHA3_OBJS) \ $(LIBHACL_BLAKE2_OBJS) +LIBHACL_HMAC_LIB_STATIC=Modules/_hacl/libHacl_HMAC.a +LIBHACL_HMAC_LIB_SHARED=$(LIBHACL_HMAC_OBJS) LIBHACL_HEADERS= \ Modules/_hacl/include/krml/FStar_UInt128_Verified.h \ @@ -732,7 +744,6 @@ LIBHACL_BLAKE2_HEADERS= \ Modules/_hacl/internal/Hacl_Impl_Blake2_Constants.h \ Modules/_hacl/internal/Hacl_Hash_Blake2s_Simd128.h \ Modules/_hacl/internal/Hacl_Hash_Blake2b_Simd256.h \ - Modules/_hacl/internal/Hacl_Streaming_Types.h \ $(LIBHACL_HEADERS) LIBHACL_HMAC_HEADERS= \ @@ -1461,74 +1472,72 @@ $(LIBEXPAT_A): $(LIBEXPAT_OBJS) $(AR) $(ARFLAGS) $@ $(LIBEXPAT_OBJS) ########################################################################## -# Build HACL* static libraries for hashlib and HACL* HMAC. +# HACL* library build +# +# The HACL* modules are dynamically compiled and linked with the +# corresponding CPython built-in modules on demand, depending on +# whether the module is built or not. # -# The contents of libHacl_Blake2.a vary depending on whether we -# have the ability to compile vectorized versions +# In particular, the HACL* objects are also dependencies of the +# corresponding C extension modules but makesetup must NOT create +# a rule for them. +# +# For WASI, static linking is needed and HACL* is statically linked instead. + +Modules/_hacl/Lib_Memzero0.o: $(srcdir)/Modules/_hacl/Lib_Memzero0.c $(LIBHACL_HEADERS) + $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Lib_Memzero0.c Modules/_hacl/Hacl_Hash_MD5.o: $(srcdir)/Modules/_hacl/Hacl_Hash_MD5.c $(LIBHACL_MD5_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_MD5.c - -$(LIBHACL_MD5_A): $(LIBHACL_MD5_OBJS) +$(LIBHACL_MD5_LIB_STATIC): $(LIBHACL_MD5_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_MD5_OBJS) Modules/_hacl/Hacl_Hash_SHA1.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA1.c $(LIBHACL_SHA1_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA1.c - -$(LIBHACL_SHA1_A): $(LIBHACL_SHA1_OBJS) +$(LIBHACL_SHA1_LIB_STATIC): $(LIBHACL_SHA1_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_SHA1_OBJS) Modules/_hacl/Hacl_Hash_SHA2.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c $(LIBHACL_SHA2_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA2.c - -$(LIBHACL_SHA2_A): $(LIBHACL_SHA2_OBJS) +$(LIBHACL_SHA2_LIB_STATIC): $(LIBHACL_SHA2_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_SHA2_OBJS) Modules/_hacl/Hacl_Hash_SHA3.o: $(srcdir)/Modules/_hacl/Hacl_Hash_SHA3.c $(LIBHACL_SHA3_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_SHA3.c - -$(LIBHACL_SHA3_A): $(LIBHACL_SHA3_OBJS) +$(LIBHACL_SHA3_LIB_STATIC): $(LIBHACL_SHA3_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_SHA3_OBJS) Modules/_hacl/Hacl_Hash_Blake2s.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s.c $(LIBHACL_BLAKE2_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s.c - Modules/_hacl/Hacl_Hash_Blake2b.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b.c $(LIBHACL_BLAKE2_HEADERS) $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b.c - Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128.c $(LIBHACL_BLAKE2_HEADERS) - $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_SIMD128_FLAGS) -DHACL_CAN_COMPILE_VEC128 -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128.c - + $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_BLAKE2_SIMD128_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128.c Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.c $(LIBHACL_BLAKE2_HEADERS) - $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_SIMD128_FLAGS) -DHACL_CAN_COMPILE_VEC128 -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.c - + $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_BLAKE2_SIMD128_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.c Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c $(LIBHACL_BLAKE2_HEADERS) - $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_SIMD256_FLAGS) -DHACL_CAN_COMPILE_VEC256 -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c - + $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_BLAKE2_SIMD256_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256.c Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o: $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.c $(LIBHACL_BLAKE2_HEADERS) - $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_SIMD256_FLAGS) -DHACL_CAN_COMPILE_VEC256 -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.c - -Modules/_hacl/Lib_Memzero0.o: $(srcdir)/Modules/_hacl/Lib_Memzero0.c $(LIBHACL_BLAKE2_HEADERS) - $(CC) -c $(LIBHACL_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Lib_Memzero0.c - -$(LIBHACL_BLAKE2_A): $(LIBHACL_BLAKE2_OBJS) + $(CC) -c $(LIBHACL_CFLAGS) $(LIBHACL_BLAKE2_SIMD256_CFLAGS) -o $@ $(srcdir)/Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.c +$(LIBHACL_BLAKE2_LIB_STATIC): $(LIBHACL_BLAKE2_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_BLAKE2_OBJS) +# Other HACL* cryptographic primitives + 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 - -$(LIBHACL_HMAC_A): $(LIBHACL_HMAC_OBJS) +$(LIBHACL_HMAC_LIB_STATIC): $(LIBHACL_HMAC_OBJS) -rm -f $@ $(AR) $(ARFLAGS) $@ $(LIBHACL_HMAC_OBJS) +########################################################################## # create relative links from build/lib.platform/egg.so to Modules/egg.so # pybuilddir.txt is created too late. We cannot use it in Makefile # targets. ln --relative is not portable. @@ -3302,12 +3311,21 @@ MODULE__DECIMAL_DEPS=$(srcdir)/Modules/_decimal/docstrings.h @LIBMPDEC_INTERNAL@ MODULE__ELEMENTTREE_DEPS=$(srcdir)/Modules/pyexpat.c @LIBEXPAT_INTERNAL@ MODULE__HASHLIB_DEPS=$(srcdir)/Modules/hashlib.h MODULE__IO_DEPS=$(srcdir)/Modules/_io/_iomodule.h -MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_A) -MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_A) -MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_A) -MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_A) -MODULE__BLAKE2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_A) -MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_A) + +# HACL*-based cryptographic primitives +MODULE__MD5_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_MD5_HEADERS) $(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__MD5_LDEPS=$(LIBHACL_MD5_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA1_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA1_HEADERS) $(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA1_LDEPS=$(LIBHACL_SHA1_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA2_HEADERS) $(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA2_LDEPS=$(LIBHACL_SHA2_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA3_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_SHA3_HEADERS) $(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__SHA3_LDEPS=$(LIBHACL_SHA3_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__BLAKE2_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_BLAKE2_HEADERS) $(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__BLAKE2_LDEPS=$(LIBHACL_BLAKE2_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__HMAC_DEPS=$(srcdir)/Modules/hashlib.h $(LIBHACL_HMAC_HEADERS) $(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@) +MODULE__HMAC_LDEPS=$(LIBHACL_HMAC_LIB_@LIBHACL_LDEPS_LIBTYPE@) + MODULE__SOCKET_DEPS=$(srcdir)/Modules/socketmodule.h $(srcdir)/Modules/addrinfo.h $(srcdir)/Modules/getaddrinfo.c $(srcdir)/Modules/getnameinfo.c MODULE__SSL_DEPS=$(srcdir)/Modules/_ssl.h $(srcdir)/Modules/_ssl/cert.c $(srcdir)/Modules/_ssl/debughelpers.c $(srcdir)/Modules/_ssl/misc.c $(srcdir)/Modules/_ssl_data_111.h $(srcdir)/Modules/_ssl_data_300.h $(srcdir)/Modules/socketmodule.h MODULE__TESTCAPI_DEPS=$(srcdir)/Modules/_testcapi/parts.h $(srcdir)/Modules/_testcapi/util.h diff --git a/Misc/sbom.spdx.json b/Misc/sbom.spdx.json index cafda98ba2d59e..5da77f158cbf38 100644 --- a/Misc/sbom.spdx.json +++ b/Misc/sbom.spdx.json @@ -888,11 +888,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "3d65f95f6f4bbfe980a89b82c55d02d7694a5a79" + "checksumValue": "66108dcbb7fc9e8aa7adcc440fede22c62164d92" }, { "algorithm": "SHA256", - "checksumValue": "0f8d744620cf5f6b8450da187484b418d24dec7d8cf72b757b7080e84cb3ae5e" + "checksumValue": "284079d2af21a570c58c82e54536b8b9bae0f0a321f229b242c92dc350d10bdf" } ], "fileName": "Modules/_hacl/lib_memzero0.h" @@ -930,11 +930,11 @@ "checksums": [ { "algorithm": "SHA1", - "checksumValue": "dbed915328619b1159012649a427c6928033dd90" + "checksumValue": "4a0bdb9496d49bbfa3ad50bb7854d8f099e84891" }, { "algorithm": "SHA256", - "checksumValue": "0297ea0a5d1117e001d5dbb90f99d47ee9e0f9d3dd45da02ba5dc477e551cb5a" + "checksumValue": "b1a45149239ee7af7de769a3e9339950d47c199bb9eaa10edce8a00fde603b12" } ], "fileName": "Modules/_hacl/python_hacl_namespaces.h" diff --git a/Modules/Setup.stdlib.in b/Modules/Setup.stdlib.in index bd1e6c9a961877..0774e7ddab844c 100644 --- a/Modules/Setup.stdlib.in +++ b/Modules/Setup.stdlib.in @@ -16,6 +16,9 @@ # generated by PY_STDLIB_MOD macro. # * All source files automatically depend on $(PYTHON_HEADERS) and # $(MODULE_{NAME}_DEPS). +# * ${NAME}$(EXT_SUFFIX) rules automatically depend on $(MODULE_{NAME}_LDEPS), +# thus $(MODULE_{NAME}_LDEPS) must only contain Makefile rule names. To pass +# specific values to the linker, use $(MODULE_{NAME}_LDFLAGS) instead. # # See Modules/Setup and Modules/makesetup # @@ -76,13 +79,23 @@ # needs -lreadline or -ledit, sometimes termcap, termlib, or tinfo @MODULE_READLINE_TRUE@readline readline.c -# hashing builtins, can be disabled with --without-builtin-hashlib-hashes -@MODULE__MD5_TRUE@_md5 md5module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_MD5.a -D_BSD_SOURCE -D_DEFAULT_SOURCE -@MODULE__SHA1_TRUE@_sha1 sha1module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_SHA1.a -D_BSD_SOURCE -D_DEFAULT_SOURCE -@MODULE__SHA2_TRUE@_sha2 sha2module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_SHA2.a -D_BSD_SOURCE -D_DEFAULT_SOURCE -@MODULE__SHA3_TRUE@_sha3 sha3module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_SHA3.a -D_BSD_SOURCE -D_DEFAULT_SOURCE -@MODULE__BLAKE2_TRUE@_blake2 blake2module.c -I$(srcdir)/Modules/_hacl/include Modules/_hacl/libHacl_Hash_Blake2.a -D_BSD_SOURCE -D_DEFAULT_SOURCE - +############################################################################ +# HACL*-based Cryptographic Primitives +# +# Since the compilation of the built-in cryptographic modules depends +# on whether we are building on WASI or not, rules will be explicitly +# written. In the future, it should be preferrable to be able to setup +# the relevant bits here instead of in Makefile.pre.in or configure.ac. + +# Hash functions can be disabled with --without-builtin-hashlib-hashes. +@MODULE__MD5_TRUE@_md5 md5module.c +@MODULE__SHA1_TRUE@_sha1 sha1module.c +@MODULE__SHA2_TRUE@_sha2 sha2module.c +@MODULE__SHA3_TRUE@_sha3 sha3module.c +@MODULE__BLAKE2_TRUE@_blake2 blake2module.c + +# Since HMAC is always supported, the HACL* implementation modules must +# be built unconditionally. @MODULE__HMAC_TRUE@_hmac hmacmodule.c ############################################################################ diff --git a/Modules/_hacl/lib_memzero0.h b/Modules/_hacl/lib_memzero0.h index fea3e41c907f44..2043834b9bbe08 100644 --- a/Modules/_hacl/lib_memzero0.h +++ b/Modules/_hacl/lib_memzero0.h @@ -1,4 +1,5 @@ #include <inttypes.h> +#include "python_hacl_namespaces.h" void Lib_Memzero0_memzero0(void *dst, uint64_t len); diff --git a/Modules/_hacl/python_hacl_namespaces.h b/Modules/_hacl/python_hacl_namespaces.h index e234a123e1606d..1c2f7fea5c837a 100644 --- a/Modules/_hacl/python_hacl_namespaces.h +++ b/Modules/_hacl/python_hacl_namespaces.h @@ -6,234 +6,251 @@ * conflicts with builds linking or dynamically loading other code potentially * using HACL* libraries. * - * Something like this to generate new entries for the list: nm *.o | grep Hacl | cut -c 20- | sort | uniq | grep -v python_hashlib | egrep ^_ | gsed 's/_\(.*\)/#define \1 python_hashlib_\1/' + * Something like this to generate new entries for the list: + * + * nm *.o | grep Hacl | cut -c 20- | sort | uniq | grep -v _Py_LibHacl_ | egrep ^_ | sed 's/_\(.*\)/#define \1 _Py_LibHacl_\1/g' */ -#define Hacl_Hash_SHA2_state_sha2_224_s python_hashlib_Hacl_Hash_SHA2_state_sha2_224_s -#define Hacl_Hash_SHA2_state_sha2_224 python_hashlib_Hacl_Hash_SHA2_state_sha2_224 -#define Hacl_Hash_SHA2_state_sha2_256 python_hashlib_Hacl_Hash_SHA2_state_sha2_256 -#define Hacl_Hash_SHA2_state_sha2_384_s python_hashlib_Hacl_Hash_SHA2_state_sha2_384_s -#define Hacl_Hash_SHA2_state_sha2_384 python_hashlib_Hacl_Hash_SHA2_state_sha2_384 -#define Hacl_Hash_SHA2_state_sha2_512 python_hashlib_Hacl_Hash_SHA2_state_sha2_512 -#define Hacl_Hash_SHA2_malloc_256 python_hashlib_Hacl_Hash_SHA2_malloc_256 -#define Hacl_Hash_SHA2_malloc_224 python_hashlib_Hacl_Hash_SHA2_malloc_224 -#define Hacl_Hash_SHA2_malloc_512 python_hashlib_Hacl_Hash_SHA2_malloc_512 -#define Hacl_Hash_SHA2_malloc_384 python_hashlib_Hacl_Hash_SHA2_malloc_384 -#define Hacl_Hash_SHA2_copy_256 python_hashlib_Hacl_Hash_SHA2_copy_256 -#define Hacl_Hash_SHA2_copy_224 python_hashlib_Hacl_Hash_SHA2_copy_224 -#define Hacl_Hash_SHA2_copy_512 python_hashlib_Hacl_Hash_SHA2_copy_512 -#define Hacl_Hash_SHA2_copy_384 python_hashlib_Hacl_Hash_SHA2_copy_384 -#define Hacl_Hash_SHA2_init_256 python_hashlib_Hacl_Hash_SHA2_init_256 -#define Hacl_Hash_SHA2_init_224 python_hashlib_Hacl_Hash_SHA2_init_224 -#define Hacl_Hash_SHA2_init_512 python_hashlib_Hacl_Hash_SHA2_init_512 -#define Hacl_Hash_SHA2_init_384 python_hashlib_Hacl_Hash_SHA2_init_384 -#define Hacl_SHA2_Scalar32_sha512_init python_hashlib_Hacl_SHA2_Scalar32_sha512_init -#define Hacl_Hash_SHA2_update_256 python_hashlib_Hacl_Hash_SHA2_update_256 -#define Hacl_Hash_SHA2_update_224 python_hashlib_Hacl_Hash_SHA2_update_224 -#define Hacl_Hash_SHA2_update_512 python_hashlib_Hacl_Hash_SHA2_update_512 -#define Hacl_Hash_SHA2_update_384 python_hashlib_Hacl_Hash_SHA2_update_384 -#define Hacl_Hash_SHA2_digest_256 python_hashlib_Hacl_Hash_SHA2_digest_256 -#define Hacl_Hash_SHA2_digest_224 python_hashlib_Hacl_Hash_SHA2_digest_224 -#define Hacl_Hash_SHA2_digest_512 python_hashlib_Hacl_Hash_SHA2_digest_512 -#define Hacl_Hash_SHA2_digest_384 python_hashlib_Hacl_Hash_SHA2_digest_384 -#define Hacl_Hash_SHA2_free_256 python_hashlib_Hacl_Hash_SHA2_free_256 -#define Hacl_Hash_SHA2_free_224 python_hashlib_Hacl_Hash_SHA2_free_224 -#define Hacl_Hash_SHA2_free_512 python_hashlib_Hacl_Hash_SHA2_free_512 -#define Hacl_Hash_SHA2_free_384 python_hashlib_Hacl_Hash_SHA2_free_384 -#define Hacl_Hash_SHA2_sha256 python_hashlib_Hacl_Hash_SHA2_sha256 -#define Hacl_Hash_SHA2_sha224 python_hashlib_Hacl_Hash_SHA2_sha224 -#define Hacl_Hash_SHA2_sha512 python_hashlib_Hacl_Hash_SHA2_sha512 -#define Hacl_Hash_SHA2_sha384 python_hashlib_Hacl_Hash_SHA2_sha384 +#define Lib_Memzero0_memzero0 _Py_LibHacl_Lib_Memzero0_memzero0 + +#define Hacl_Hash_SHA2_state_sha2_224_s _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_224_s +#define Hacl_Hash_SHA2_state_sha2_224 _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_224 +#define Hacl_Hash_SHA2_state_sha2_256 _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_256 +#define Hacl_Hash_SHA2_state_sha2_384_s _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_384_s +#define Hacl_Hash_SHA2_state_sha2_384 _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_384 +#define Hacl_Hash_SHA2_state_sha2_512 _Py_LibHacl_Hacl_Hash_SHA2_state_sha2_512 +#define Hacl_Hash_SHA2_malloc_256 _Py_LibHacl_Hacl_Hash_SHA2_malloc_256 +#define Hacl_Hash_SHA2_malloc_224 _Py_LibHacl_Hacl_Hash_SHA2_malloc_224 +#define Hacl_Hash_SHA2_malloc_512 _Py_LibHacl_Hacl_Hash_SHA2_malloc_512 +#define Hacl_Hash_SHA2_malloc_384 _Py_LibHacl_Hacl_Hash_SHA2_malloc_384 +#define Hacl_Hash_SHA2_copy_256 _Py_LibHacl_Hacl_Hash_SHA2_copy_256 +#define Hacl_Hash_SHA2_copy_224 _Py_LibHacl_Hacl_Hash_SHA2_copy_224 +#define Hacl_Hash_SHA2_copy_512 _Py_LibHacl_Hacl_Hash_SHA2_copy_512 +#define Hacl_Hash_SHA2_copy_384 _Py_LibHacl_Hacl_Hash_SHA2_copy_384 +#define Hacl_Hash_SHA2_init_256 _Py_LibHacl_Hacl_Hash_SHA2_init_256 +#define Hacl_Hash_SHA2_init_224 _Py_LibHacl_Hacl_Hash_SHA2_init_224 +#define Hacl_Hash_SHA2_init_512 _Py_LibHacl_Hacl_Hash_SHA2_init_512 +#define Hacl_Hash_SHA2_init_384 _Py_LibHacl_Hacl_Hash_SHA2_init_384 +#define Hacl_SHA2_Scalar32_sha512_init _Py_LibHacl_Hacl_SHA2_Scalar32_sha512_init +#define Hacl_Hash_SHA2_update_256 _Py_LibHacl_Hacl_Hash_SHA2_update_256 +#define Hacl_Hash_SHA2_update_224 _Py_LibHacl_Hacl_Hash_SHA2_update_224 +#define Hacl_Hash_SHA2_update_512 _Py_LibHacl_Hacl_Hash_SHA2_update_512 +#define Hacl_Hash_SHA2_update_384 _Py_LibHacl_Hacl_Hash_SHA2_update_384 +#define Hacl_Hash_SHA2_digest_256 _Py_LibHacl_Hacl_Hash_SHA2_digest_256 +#define Hacl_Hash_SHA2_digest_224 _Py_LibHacl_Hacl_Hash_SHA2_digest_224 +#define Hacl_Hash_SHA2_digest_512 _Py_LibHacl_Hacl_Hash_SHA2_digest_512 +#define Hacl_Hash_SHA2_digest_384 _Py_LibHacl_Hacl_Hash_SHA2_digest_384 +#define Hacl_Hash_SHA2_free_256 _Py_LibHacl_Hacl_Hash_SHA2_free_256 +#define Hacl_Hash_SHA2_free_224 _Py_LibHacl_Hacl_Hash_SHA2_free_224 +#define Hacl_Hash_SHA2_free_512 _Py_LibHacl_Hacl_Hash_SHA2_free_512 +#define Hacl_Hash_SHA2_free_384 _Py_LibHacl_Hacl_Hash_SHA2_free_384 +#define Hacl_Hash_SHA2_sha256 _Py_LibHacl_Hacl_Hash_SHA2_sha256 +#define Hacl_Hash_SHA2_sha224 _Py_LibHacl_Hacl_Hash_SHA2_sha224 +#define Hacl_Hash_SHA2_sha512 _Py_LibHacl_Hacl_Hash_SHA2_sha512 +#define Hacl_Hash_SHA2_sha384 _Py_LibHacl_Hacl_Hash_SHA2_sha384 -#define Hacl_Hash_MD5_malloc python_hashlib_Hacl_Hash_MD5_malloc -#define Hacl_Hash_MD5_init python_hashlib_Hacl_Hash_MD5_init -#define Hacl_Hash_MD5_update python_hashlib_Hacl_Hash_MD5_update -#define Hacl_Hash_MD5_digest python_hashlib_Hacl_Hash_MD5_digest -#define Hacl_Hash_MD5_free python_hashlib_Hacl_Hash_MD5_free -#define Hacl_Hash_MD5_copy python_hashlib_Hacl_Hash_MD5_copy -#define Hacl_Hash_MD5_hash python_hashlib_Hacl_Hash_MD5_hash +#define Hacl_Hash_MD5_malloc _Py_LibHacl_Hacl_Hash_MD5_malloc +#define Hacl_Hash_MD5_init _Py_LibHacl_Hacl_Hash_MD5_init +#define Hacl_Hash_MD5_update _Py_LibHacl_Hacl_Hash_MD5_update +#define Hacl_Hash_MD5_digest _Py_LibHacl_Hacl_Hash_MD5_digest +#define Hacl_Hash_MD5_free _Py_LibHacl_Hacl_Hash_MD5_free +#define Hacl_Hash_MD5_copy _Py_LibHacl_Hacl_Hash_MD5_copy +#define Hacl_Hash_MD5_hash _Py_LibHacl_Hacl_Hash_MD5_hash -#define Hacl_Hash_SHA1_malloc python_hashlib_Hacl_Hash_SHA1_malloc -#define Hacl_Hash_SHA1_init python_hashlib_Hacl_Hash_SHA1_init -#define Hacl_Hash_SHA1_update python_hashlib_Hacl_Hash_SHA1_update -#define Hacl_Hash_SHA1_digest python_hashlib_Hacl_Hash_SHA1_digest -#define Hacl_Hash_SHA1_free python_hashlib_Hacl_Hash_SHA1_free -#define Hacl_Hash_SHA1_copy python_hashlib_Hacl_Hash_SHA1_copy -#define Hacl_Hash_SHA1_hash python_hashlib_Hacl_Hash_SHA1_hash +#define Hacl_Hash_SHA1_malloc _Py_LibHacl_Hacl_Hash_SHA1_malloc +#define Hacl_Hash_SHA1_init _Py_LibHacl_Hacl_Hash_SHA1_init +#define Hacl_Hash_SHA1_update _Py_LibHacl_Hacl_Hash_SHA1_update +#define Hacl_Hash_SHA1_digest _Py_LibHacl_Hacl_Hash_SHA1_digest +#define Hacl_Hash_SHA1_free _Py_LibHacl_Hacl_Hash_SHA1_free +#define Hacl_Hash_SHA1_copy _Py_LibHacl_Hacl_Hash_SHA1_copy +#define Hacl_Hash_SHA1_hash _Py_LibHacl_Hacl_Hash_SHA1_hash -#define Hacl_Hash_SHA3_update_last_sha3 python_hashlib_Hacl_Hash_SHA3_update_last_sha3 -#define Hacl_Hash_SHA3_update_multi_sha3 python_hashlib_Hacl_Hash_SHA3_update_multi_sha3 -#define Hacl_Impl_SHA3_absorb_inner python_hashlib_Hacl_Impl_SHA3_absorb_inner -#define Hacl_Impl_SHA3_keccak python_hashlib_Hacl_Impl_SHA3_keccak -#define Hacl_Impl_SHA3_loadState python_hashlib_Hacl_Impl_SHA3_loadState -#define Hacl_Impl_SHA3_squeeze python_hashlib_Hacl_Impl_SHA3_squeeze -#define Hacl_Impl_SHA3_state_permute python_hashlib_Hacl_Impl_SHA3_state_permute -#define Hacl_SHA3_sha3_224 python_hashlib_Hacl_SHA3_sha3_224 -#define Hacl_SHA3_sha3_256 python_hashlib_Hacl_SHA3_sha3_256 -#define Hacl_SHA3_sha3_384 python_hashlib_Hacl_SHA3_sha3_384 -#define Hacl_SHA3_sha3_512 python_hashlib_Hacl_SHA3_sha3_512 -#define Hacl_SHA3_shake128_hacl python_hashlib_Hacl_SHA3_shake128_hacl -#define Hacl_SHA3_shake256_hacl python_hashlib_Hacl_SHA3_shake256_hacl -#define Hacl_Hash_SHA3_block_len python_hashlib_Hacl_Hash_SHA3_block_len -#define Hacl_Hash_SHA3_copy python_hashlib_Hacl_Hash_SHA3_copy -#define Hacl_Hash_SHA3_digest python_hashlib_Hacl_Hash_SHA3_digest -#define Hacl_Hash_SHA3_free python_hashlib_Hacl_Hash_SHA3_free -#define Hacl_Hash_SHA3_get_alg python_hashlib_Hacl_Hash_SHA3_get_alg -#define Hacl_Hash_SHA3_hash_len python_hashlib_Hacl_Hash_SHA3_hash_len -#define Hacl_Hash_SHA3_is_shake python_hashlib_Hacl_Hash_SHA3_is_shake -#define Hacl_Hash_SHA3_malloc python_hashlib_Hacl_Hash_SHA3_malloc -#define Hacl_Hash_SHA3_reset python_hashlib_Hacl_Hash_SHA3_reset -#define Hacl_Hash_SHA3_update python_hashlib_Hacl_Hash_SHA3_update -#define Hacl_Hash_SHA3_squeeze python_hashlib_Hacl_Hash_SHA3_squeeze +#define Hacl_Hash_SHA3_update_last_sha3 _Py_LibHacl_Hacl_Hash_SHA3_update_last_sha3 +#define Hacl_Hash_SHA3_update_multi_sha3 _Py_LibHacl_Hacl_Hash_SHA3_update_multi_sha3 +#define Hacl_Impl_SHA3_absorb_inner _Py_LibHacl_Hacl_Impl_SHA3_absorb_inner +#define Hacl_Impl_SHA3_keccak _Py_LibHacl_Hacl_Impl_SHA3_keccak +#define Hacl_Impl_SHA3_loadState _Py_LibHacl_Hacl_Impl_SHA3_loadState +#define Hacl_Impl_SHA3_squeeze _Py_LibHacl_Hacl_Impl_SHA3_squeeze +#define Hacl_Impl_SHA3_state_permute _Py_LibHacl_Hacl_Impl_SHA3_state_permute +#define Hacl_SHA3_sha3_224 _Py_LibHacl_Hacl_SHA3_sha3_224 +#define Hacl_SHA3_sha3_256 _Py_LibHacl_Hacl_SHA3_sha3_256 +#define Hacl_SHA3_sha3_384 _Py_LibHacl_Hacl_SHA3_sha3_384 +#define Hacl_SHA3_sha3_512 _Py_LibHacl_Hacl_SHA3_sha3_512 +#define Hacl_SHA3_shake128_hacl _Py_LibHacl_Hacl_SHA3_shake128_hacl +#define Hacl_SHA3_shake256_hacl _Py_LibHacl_Hacl_SHA3_shake256_hacl +#define Hacl_Hash_SHA3_block_len _Py_LibHacl_Hacl_Hash_SHA3_block_len +#define Hacl_Hash_SHA3_copy _Py_LibHacl_Hacl_Hash_SHA3_copy +#define Hacl_Hash_SHA3_digest _Py_LibHacl_Hacl_Hash_SHA3_digest +#define Hacl_Hash_SHA3_free _Py_LibHacl_Hacl_Hash_SHA3_free +#define Hacl_Hash_SHA3_get_alg _Py_LibHacl_Hacl_Hash_SHA3_get_alg +#define Hacl_Hash_SHA3_hash_len _Py_LibHacl_Hacl_Hash_SHA3_hash_len +#define Hacl_Hash_SHA3_is_shake _Py_LibHacl_Hacl_Hash_SHA3_is_shake +#define Hacl_Hash_SHA3_init_ _Py_LibHacl_Hacl_Hash_SHA3_init_ +#define Hacl_Hash_SHA3_malloc _Py_LibHacl_Hacl_Hash_SHA3_malloc +#define Hacl_Hash_SHA3_reset _Py_LibHacl_Hacl_Hash_SHA3_reset +#define Hacl_Hash_SHA3_update _Py_LibHacl_Hacl_Hash_SHA3_update +#define Hacl_Hash_SHA3_squeeze _Py_LibHacl_Hacl_Hash_SHA3_squeeze -#define Hacl_Hash_Blake2b_Simd256_copy python_hashlib_Hacl_Hash_Blake2b_Simd256_copy -#define Hacl_Hash_Blake2b_Simd256_digest python_hashlib_Hacl_Hash_Blake2b_Simd256_digest -#define Hacl_Hash_Blake2b_Simd256_finish python_hashlib_Hacl_Hash_Blake2b_Simd256_finish -#define Hacl_Hash_Blake2b_Simd256_free python_hashlib_Hacl_Hash_Blake2b_Simd256_free -#define Hacl_Hash_Blake2b_Simd256_hash_with_key python_hashlib_Hacl_Hash_Blake2b_Simd256_hash_with_key -#define Hacl_Hash_Blake2b_Simd256_hash_with_key_and_params python_hashlib_Hacl_Hash_Blake2b_Simd256_hash_with_key_and_params -#define Hacl_Hash_Blake2b_Simd256_info python_hashlib_Hacl_Hash_Blake2b_Simd256_info -#define Hacl_Hash_Blake2b_Simd256_init python_hashlib_Hacl_Hash_Blake2b_Simd256_init -#define Hacl_Hash_Blake2b_Simd256_load_state256b_from_state32 python_hashlib_Hacl_Hash_Blake2b_Simd256_load_state256b_from_state32 -#define Hacl_Hash_Blake2b_Simd256_malloc python_hashlib_Hacl_Hash_Blake2b_Simd256_malloc -#define Hacl_Hash_Blake2b_Simd256_malloc_with_key python_hashlib_Hacl_Hash_Blake2b_Simd256_malloc_with_key -#define Hacl_Hash_Blake2b_Simd256_malloc_with_key0 python_hashlib_Hacl_Hash_Blake2b_Simd256_malloc_with_key0 -#define Hacl_Hash_Blake2b_Simd256_malloc_with_params_and_key python_hashlib_Hacl_Hash_Blake2b_Simd256_malloc_with_params_and_key -#define Hacl_Hash_Blake2b_Simd256_reset python_hashlib_Hacl_Hash_Blake2b_Simd256_reset -#define Hacl_Hash_Blake2b_Simd256_reset_with_key python_hashlib_Hacl_Hash_Blake2b_Simd256_reset_with_key -#define Hacl_Hash_Blake2b_Simd256_reset_with_key_and_params python_hashlib_Hacl_Hash_Blake2b_Simd256_reset_with_key_and_params -#define Hacl_Hash_Blake2b_Simd256_store_state256b_to_state32 python_hashlib_Hacl_Hash_Blake2b_Simd256_store_state256b_to_state32 -#define Hacl_Hash_Blake2b_Simd256_update python_hashlib_Hacl_Hash_Blake2b_Simd256_update -#define Hacl_Hash_Blake2b_Simd256_update_last python_hashlib_Hacl_Hash_Blake2b_Simd256_update_last -#define Hacl_Hash_Blake2b_Simd256_update_multi python_hashlib_Hacl_Hash_Blake2b_Simd256_update_multi -#define Hacl_Hash_Blake2b_copy python_hashlib_Hacl_Hash_Blake2b_copy -#define Hacl_Hash_Blake2b_digest python_hashlib_Hacl_Hash_Blake2b_digest -#define Hacl_Hash_Blake2b_finish python_hashlib_Hacl_Hash_Blake2b_finish -#define Hacl_Hash_Blake2b_free python_hashlib_Hacl_Hash_Blake2b_free -#define Hacl_Hash_Blake2b_hash_with_key python_hashlib_Hacl_Hash_Blake2b_hash_with_key -#define Hacl_Hash_Blake2b_hash_with_key_and_params python_hashlib_Hacl_Hash_Blake2b_hash_with_key_and_params -#define Hacl_Hash_Blake2b_info python_hashlib_Hacl_Hash_Blake2b_info -#define Hacl_Hash_Blake2b_init python_hashlib_Hacl_Hash_Blake2b_init -#define Hacl_Hash_Blake2b_malloc python_hashlib_Hacl_Hash_Blake2b_malloc -#define Hacl_Hash_Blake2b_malloc_with_key python_hashlib_Hacl_Hash_Blake2b_malloc_with_key -#define Hacl_Hash_Blake2b_malloc_with_params_and_key python_hashlib_Hacl_Hash_Blake2b_malloc_with_params_and_key -#define Hacl_Hash_Blake2b_reset python_hashlib_Hacl_Hash_Blake2b_reset -#define Hacl_Hash_Blake2b_reset_with_key python_hashlib_Hacl_Hash_Blake2b_reset_with_key -#define Hacl_Hash_Blake2b_reset_with_key_and_params python_hashlib_Hacl_Hash_Blake2b_reset_with_key_and_params -#define Hacl_Hash_Blake2b_update python_hashlib_Hacl_Hash_Blake2b_update -#define Hacl_Hash_Blake2b_update_last python_hashlib_Hacl_Hash_Blake2b_update_last -#define Hacl_Hash_Blake2b_update_multi python_hashlib_Hacl_Hash_Blake2b_update_multi -#define Hacl_Hash_Blake2s_Simd128_copy python_hashlib_Hacl_Hash_Blake2s_Simd128_copy -#define Hacl_Hash_Blake2s_Simd128_digest python_hashlib_Hacl_Hash_Blake2s_Simd128_digest -#define Hacl_Hash_Blake2s_Simd128_finish python_hashlib_Hacl_Hash_Blake2s_Simd128_finish -#define Hacl_Hash_Blake2s_Simd128_free python_hashlib_Hacl_Hash_Blake2s_Simd128_free -#define Hacl_Hash_Blake2s_Simd128_hash_with_key python_hashlib_Hacl_Hash_Blake2s_Simd128_hash_with_key -#define Hacl_Hash_Blake2s_Simd128_hash_with_key_and_params python_hashlib_Hacl_Hash_Blake2s_Simd128_hash_with_key_and_params -#define Hacl_Hash_Blake2s_Simd128_info python_hashlib_Hacl_Hash_Blake2s_Simd128_info -#define Hacl_Hash_Blake2s_Simd128_init python_hashlib_Hacl_Hash_Blake2s_Simd128_init -#define Hacl_Hash_Blake2s_Simd128_load_state128s_from_state32 python_hashlib_Hacl_Hash_Blake2s_Simd128_load_state128s_from_state32 -#define Hacl_Hash_Blake2s_Simd128_malloc python_hashlib_Hacl_Hash_Blake2s_Simd128_malloc -#define Hacl_Hash_Blake2s_Simd128_malloc_with_key python_hashlib_Hacl_Hash_Blake2s_Simd128_malloc_with_key -#define Hacl_Hash_Blake2s_Simd128_malloc_with_key0 python_hashlib_Hacl_Hash_Blake2s_Simd128_malloc_with_key0 -#define Hacl_Hash_Blake2s_Simd128_malloc_with_params_and_key python_hashlib_Hacl_Hash_Blake2s_Simd128_malloc_with_params_and_key -#define Hacl_Hash_Blake2s_Simd128_reset python_hashlib_Hacl_Hash_Blake2s_Simd128_reset -#define Hacl_Hash_Blake2s_Simd128_reset_with_key python_hashlib_Hacl_Hash_Blake2s_Simd128_reset_with_key -#define Hacl_Hash_Blake2s_Simd128_reset_with_key_and_params python_hashlib_Hacl_Hash_Blake2s_Simd128_reset_with_key_and_params -#define Hacl_Hash_Blake2s_Simd128_store_state128s_to_state32 python_hashlib_Hacl_Hash_Blake2s_Simd128_store_state128s_to_state32 -#define Hacl_Hash_Blake2s_Simd128_update python_hashlib_Hacl_Hash_Blake2s_Simd128_update -#define Hacl_Hash_Blake2s_Simd128_update_last python_hashlib_Hacl_Hash_Blake2s_Simd128_update_last -#define Hacl_Hash_Blake2s_Simd128_update_multi python_hashlib_Hacl_Hash_Blake2s_Simd128_update_multi -#define Hacl_Hash_Blake2s_copy python_hashlib_Hacl_Hash_Blake2s_copy -#define Hacl_Hash_Blake2s_digest python_hashlib_Hacl_Hash_Blake2s_digest -#define Hacl_Hash_Blake2s_finish python_hashlib_Hacl_Hash_Blake2s_finish -#define Hacl_Hash_Blake2s_free python_hashlib_Hacl_Hash_Blake2s_free -#define Hacl_Hash_Blake2s_hash_with_key python_hashlib_Hacl_Hash_Blake2s_hash_with_key -#define Hacl_Hash_Blake2s_hash_with_key_and_params python_hashlib_Hacl_Hash_Blake2s_hash_with_key_and_params -#define Hacl_Hash_Blake2s_info python_hashlib_Hacl_Hash_Blake2s_info -#define Hacl_Hash_Blake2s_init python_hashlib_Hacl_Hash_Blake2s_init -#define Hacl_Hash_Blake2s_malloc python_hashlib_Hacl_Hash_Blake2s_malloc -#define Hacl_Hash_Blake2s_malloc_with_key python_hashlib_Hacl_Hash_Blake2s_malloc_with_key -#define Hacl_Hash_Blake2s_malloc_with_params_and_key python_hashlib_Hacl_Hash_Blake2s_malloc_with_params_and_key -#define Hacl_Hash_Blake2s_reset python_hashlib_Hacl_Hash_Blake2s_reset -#define Hacl_Hash_Blake2s_reset_with_key python_hashlib_Hacl_Hash_Blake2s_reset_with_key -#define Hacl_Hash_Blake2s_reset_with_key_and_params python_hashlib_Hacl_Hash_Blake2s_reset_with_key_and_params -#define Hacl_Hash_Blake2s_update python_hashlib_Hacl_Hash_Blake2s_update -#define Hacl_Hash_Blake2s_update_last python_hashlib_Hacl_Hash_Blake2s_update_last -#define Hacl_Hash_Blake2s_update_multi python_hashlib_Hacl_Hash_Blake2s_update_multi -#define Hacl_Hash_MD5_finish python_hashlib_Hacl_Hash_MD5_finish -#define Hacl_Hash_MD5_hash_oneshot python_hashlib_Hacl_Hash_MD5_hash_oneshot -#define Hacl_Hash_MD5_reset python_hashlib_Hacl_Hash_MD5_reset -#define Hacl_Hash_MD5_update_last python_hashlib_Hacl_Hash_MD5_update_last -#define Hacl_Hash_MD5_update_multi python_hashlib_Hacl_Hash_MD5_update_multi -#define Hacl_Hash_SHA1_finish python_hashlib_Hacl_Hash_SHA1_finish -#define Hacl_Hash_SHA1_hash_oneshot python_hashlib_Hacl_Hash_SHA1_hash_oneshot -#define Hacl_Hash_SHA1_reset python_hashlib_Hacl_Hash_SHA1_reset -#define Hacl_Hash_SHA1_update_last python_hashlib_Hacl_Hash_SHA1_update_last -#define Hacl_Hash_SHA1_update_multi python_hashlib_Hacl_Hash_SHA1_update_multi -#define Hacl_Hash_SHA2_hash_224 python_hashlib_Hacl_Hash_SHA2_hash_224 -#define Hacl_Hash_SHA2_hash_256 python_hashlib_Hacl_Hash_SHA2_hash_256 -#define Hacl_Hash_SHA2_hash_384 python_hashlib_Hacl_Hash_SHA2_hash_384 -#define Hacl_Hash_SHA2_hash_512 python_hashlib_Hacl_Hash_SHA2_hash_512 -#define Hacl_Hash_SHA2_reset_224 python_hashlib_Hacl_Hash_SHA2_reset_224 -#define Hacl_Hash_SHA2_reset_256 python_hashlib_Hacl_Hash_SHA2_reset_256 -#define Hacl_Hash_SHA2_reset_384 python_hashlib_Hacl_Hash_SHA2_reset_384 -#define Hacl_Hash_SHA2_reset_512 python_hashlib_Hacl_Hash_SHA2_reset_512 -#define Hacl_Hash_SHA2_sha224_finish python_hashlib_Hacl_Hash_SHA2_sha224_finish -#define Hacl_Hash_SHA2_sha224_init python_hashlib_Hacl_Hash_SHA2_sha224_init -#define Hacl_Hash_SHA2_sha224_update_last python_hashlib_Hacl_Hash_SHA2_sha224_update_last -#define Hacl_Hash_SHA2_sha256_finish python_hashlib_Hacl_Hash_SHA2_sha256_finish -#define Hacl_Hash_SHA2_sha256_init python_hashlib_Hacl_Hash_SHA2_sha256_init -#define Hacl_Hash_SHA2_sha256_update_last python_hashlib_Hacl_Hash_SHA2_sha256_update_last -#define Hacl_Hash_SHA2_sha256_update_nblocks python_hashlib_Hacl_Hash_SHA2_sha256_update_nblocks -#define Hacl_Hash_SHA2_sha384_finish python_hashlib_Hacl_Hash_SHA2_sha384_finish -#define Hacl_Hash_SHA2_sha384_init python_hashlib_Hacl_Hash_SHA2_sha384_init -#define Hacl_Hash_SHA2_sha384_update_last python_hashlib_Hacl_Hash_SHA2_sha384_update_last -#define Hacl_Hash_SHA2_sha384_update_nblocks python_hashlib_Hacl_Hash_SHA2_sha384_update_nblocks -#define Hacl_Hash_SHA2_sha512_finish python_hashlib_Hacl_Hash_SHA2_sha512_finish -#define Hacl_Hash_SHA2_sha512_init python_hashlib_Hacl_Hash_SHA2_sha512_init -#define Hacl_Hash_SHA2_sha512_update_last python_hashlib_Hacl_Hash_SHA2_sha512_update_last -#define Hacl_Hash_SHA2_sha512_update_nblocks python_hashlib_Hacl_Hash_SHA2_sha512_update_nblocks -#define Hacl_Hash_SHA3_absorb_inner_32 python_hashlib_Hacl_Hash_SHA3_absorb_inner_32 -#define Hacl_Hash_SHA3_keccak_piln python_hashlib_Hacl_Hash_SHA3_keccak_piln -#define Hacl_Hash_SHA3_keccak_rndc python_hashlib_Hacl_Hash_SHA3_keccak_rndc -#define Hacl_Hash_SHA3_keccak_rotc python_hashlib_Hacl_Hash_SHA3_keccak_rotc -#define Hacl_Hash_SHA3_sha3_224 python_hashlib_Hacl_Hash_SHA3_sha3_224 -#define Hacl_Hash_SHA3_sha3_256 python_hashlib_Hacl_Hash_SHA3_sha3_256 -#define Hacl_Hash_SHA3_sha3_384 python_hashlib_Hacl_Hash_SHA3_sha3_384 -#define Hacl_Hash_SHA3_sha3_512 python_hashlib_Hacl_Hash_SHA3_sha3_512 -#define Hacl_Hash_SHA3_shake128 python_hashlib_Hacl_Hash_SHA3_shake128 -#define Hacl_Hash_SHA3_shake128_absorb_final python_hashlib_Hacl_Hash_SHA3_shake128_absorb_final -#define Hacl_Hash_SHA3_shake128_absorb_nblocks python_hashlib_Hacl_Hash_SHA3_shake128_absorb_nblocks -#define Hacl_Hash_SHA3_shake128_squeeze_nblocks python_hashlib_Hacl_Hash_SHA3_shake128_squeeze_nblocks -#define Hacl_Hash_SHA3_shake256 python_hashlib_Hacl_Hash_SHA3_shake256 -#define Hacl_Hash_SHA3_state_free python_hashlib_Hacl_Hash_SHA3_state_free -#define Hacl_Hash_SHA3_state_malloc python_hashlib_Hacl_Hash_SHA3_state_malloc +#define Hacl_Hash_Blake2b_Simd256_copy _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_copy +#define Hacl_Hash_Blake2b_Simd256_copy_internal_state _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_copy_internal_state +#define Hacl_Hash_Blake2b_Simd256_digest _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_digest +#define Hacl_Hash_Blake2b_Simd256_finish _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_finish +#define Hacl_Hash_Blake2b_Simd256_free _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_free +#define Hacl_Hash_Blake2b_Simd256_hash_with_key _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_hash_with_key +#define Hacl_Hash_Blake2b_Simd256_hash_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_hash_with_key_and_params +#define Hacl_Hash_Blake2b_Simd256_info _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_info +#define Hacl_Hash_Blake2b_Simd256_init _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_init +#define Hacl_Hash_Blake2b_Simd256_load_state256b_from_state32 _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_load_state256b_from_state32 +#define Hacl_Hash_Blake2b_Simd256_malloc _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_malloc +#define Hacl_Hash_Blake2b_Simd256_malloc_internal_state_with_key _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_malloc_internal_state_with_key +#define Hacl_Hash_Blake2b_Simd256_malloc_with_key _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_malloc_with_key +#define Hacl_Hash_Blake2b_Simd256_malloc_with_key0 _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_malloc_with_key0 +#define Hacl_Hash_Blake2b_Simd256_malloc_with_params_and_key _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_malloc_with_params_and_key +#define Hacl_Hash_Blake2b_Simd256_reset _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_reset +#define Hacl_Hash_Blake2b_Simd256_reset_with_key _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_reset_with_key +#define Hacl_Hash_Blake2b_Simd256_reset_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_reset_with_key_and_params +#define Hacl_Hash_Blake2b_Simd256_store_state256b_to_state32 _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_store_state256b_to_state32 +#define Hacl_Hash_Blake2b_Simd256_update _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_update +#define Hacl_Hash_Blake2b_Simd256_update_last _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_update_last +#define Hacl_Hash_Blake2b_Simd256_update_last_no_inline _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_update_last_no_inline +#define Hacl_Hash_Blake2b_Simd256_update_multi _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_update_multi +#define Hacl_Hash_Blake2b_Simd256_update_multi_no_inline _Py_LibHacl_Hacl_Hash_Blake2b_Simd256_update_multi_no_inline +#define Hacl_Hash_Blake2b_copy _Py_LibHacl_Hacl_Hash_Blake2b_copy +#define Hacl_Hash_Blake2b_digest _Py_LibHacl_Hacl_Hash_Blake2b_digest +#define Hacl_Hash_Blake2b_finish _Py_LibHacl_Hacl_Hash_Blake2b_finish +#define Hacl_Hash_Blake2b_free _Py_LibHacl_Hacl_Hash_Blake2b_free +#define Hacl_Hash_Blake2b_hash_with_key _Py_LibHacl_Hacl_Hash_Blake2b_hash_with_key +#define Hacl_Hash_Blake2b_hash_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2b_hash_with_key_and_params +#define Hacl_Hash_Blake2b_info _Py_LibHacl_Hacl_Hash_Blake2b_info +#define Hacl_Hash_Blake2b_init _Py_LibHacl_Hacl_Hash_Blake2b_init +#define Hacl_Hash_Blake2b_malloc _Py_LibHacl_Hacl_Hash_Blake2b_malloc +#define Hacl_Hash_Blake2b_malloc_with_key _Py_LibHacl_Hacl_Hash_Blake2b_malloc_with_key +#define Hacl_Hash_Blake2b_malloc_with_params_and_key _Py_LibHacl_Hacl_Hash_Blake2b_malloc_with_params_and_key +#define Hacl_Hash_Blake2b_reset _Py_LibHacl_Hacl_Hash_Blake2b_reset +#define Hacl_Hash_Blake2b_reset_with_key _Py_LibHacl_Hacl_Hash_Blake2b_reset_with_key +#define Hacl_Hash_Blake2b_reset_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2b_reset_with_key_and_params +#define Hacl_Hash_Blake2b_update _Py_LibHacl_Hacl_Hash_Blake2b_update +#define Hacl_Hash_Blake2b_update_last _Py_LibHacl_Hacl_Hash_Blake2b_update_last +#define Hacl_Hash_Blake2b_update_multi _Py_LibHacl_Hacl_Hash_Blake2b_update_multi +#define Hacl_Hash_Blake2s_Simd128_copy _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_copy +#define Hacl_Hash_Blake2s_Simd128_copy_internal_state _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_copy_internal_state +#define Hacl_Hash_Blake2s_Simd128_digest _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_digest +#define Hacl_Hash_Blake2s_Simd128_finish _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_finish +#define Hacl_Hash_Blake2s_Simd128_free _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_free +#define Hacl_Hash_Blake2s_Simd128_hash_with_key _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_hash_with_key +#define Hacl_Hash_Blake2s_Simd128_hash_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_hash_with_key_and_params +#define Hacl_Hash_Blake2s_Simd128_info _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_info +#define Hacl_Hash_Blake2s_Simd128_init _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_init +#define Hacl_Hash_Blake2s_Simd128_load_state128s_from_state32 _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_load_state128s_from_state32 +#define Hacl_Hash_Blake2s_Simd128_malloc _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_malloc +#define Hacl_Hash_Blake2s_Simd128_malloc_internal_state_with_key _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_malloc_internal_state_with_key +#define Hacl_Hash_Blake2s_Simd128_malloc_with_key _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_malloc_with_key +#define Hacl_Hash_Blake2s_Simd128_malloc_with_key0 _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_malloc_with_key0 +#define Hacl_Hash_Blake2s_Simd128_malloc_with_params_and_key _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_malloc_with_params_and_key +#define Hacl_Hash_Blake2s_Simd128_reset _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_reset +#define Hacl_Hash_Blake2s_Simd128_reset_with_key _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_reset_with_key +#define Hacl_Hash_Blake2s_Simd128_reset_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_reset_with_key_and_params +#define Hacl_Hash_Blake2s_Simd128_store_state128s_to_state32 _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_store_state128s_to_state32 +#define Hacl_Hash_Blake2s_Simd128_update _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_update +#define Hacl_Hash_Blake2s_Simd128_update_last _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_update_last +#define Hacl_Hash_Blake2s_Simd128_update_last_no_inline _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_update_last_no_inline +#define Hacl_Hash_Blake2s_Simd128_update_multi _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_update_multi +#define Hacl_Hash_Blake2s_Simd128_update_multi_no_inline _Py_LibHacl_Hacl_Hash_Blake2s_Simd128_update_multi_no_inline +#define Hacl_Hash_Blake2s_copy _Py_LibHacl_Hacl_Hash_Blake2s_copy +#define Hacl_Hash_Blake2s_digest _Py_LibHacl_Hacl_Hash_Blake2s_digest +#define Hacl_Hash_Blake2s_finish _Py_LibHacl_Hacl_Hash_Blake2s_finish +#define Hacl_Hash_Blake2s_free _Py_LibHacl_Hacl_Hash_Blake2s_free +#define Hacl_Hash_Blake2s_hash_with_key _Py_LibHacl_Hacl_Hash_Blake2s_hash_with_key +#define Hacl_Hash_Blake2s_hash_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2s_hash_with_key_and_params +#define Hacl_Hash_Blake2s_info _Py_LibHacl_Hacl_Hash_Blake2s_info +#define Hacl_Hash_Blake2s_init _Py_LibHacl_Hacl_Hash_Blake2s_init +#define Hacl_Hash_Blake2s_malloc _Py_LibHacl_Hacl_Hash_Blake2s_malloc +#define Hacl_Hash_Blake2s_malloc_with_key _Py_LibHacl_Hacl_Hash_Blake2s_malloc_with_key +#define Hacl_Hash_Blake2s_malloc_with_params_and_key _Py_LibHacl_Hacl_Hash_Blake2s_malloc_with_params_and_key +#define Hacl_Hash_Blake2s_reset _Py_LibHacl_Hacl_Hash_Blake2s_reset +#define Hacl_Hash_Blake2s_reset_with_key _Py_LibHacl_Hacl_Hash_Blake2s_reset_with_key +#define Hacl_Hash_Blake2s_reset_with_key_and_params _Py_LibHacl_Hacl_Hash_Blake2s_reset_with_key_and_params +#define Hacl_Hash_Blake2s_update _Py_LibHacl_Hacl_Hash_Blake2s_update +#define Hacl_Hash_Blake2s_update_last _Py_LibHacl_Hacl_Hash_Blake2s_update_last +#define Hacl_Hash_Blake2s_update_multi _Py_LibHacl_Hacl_Hash_Blake2s_update_multi +#define Hacl_Hash_MD5_finish _Py_LibHacl_Hacl_Hash_MD5_finish +#define Hacl_Hash_MD5_hash_oneshot _Py_LibHacl_Hacl_Hash_MD5_hash_oneshot +#define Hacl_Hash_MD5_reset _Py_LibHacl_Hacl_Hash_MD5_reset +#define Hacl_Hash_MD5_update_last _Py_LibHacl_Hacl_Hash_MD5_update_last +#define Hacl_Hash_MD5_update_multi _Py_LibHacl_Hacl_Hash_MD5_update_multi +#define Hacl_Hash_SHA1_finish _Py_LibHacl_Hacl_Hash_SHA1_finish +#define Hacl_Hash_SHA1_hash_oneshot _Py_LibHacl_Hacl_Hash_SHA1_hash_oneshot +#define Hacl_Hash_SHA1_reset _Py_LibHacl_Hacl_Hash_SHA1_reset +#define Hacl_Hash_SHA1_update_last _Py_LibHacl_Hacl_Hash_SHA1_update_last +#define Hacl_Hash_SHA1_update_multi _Py_LibHacl_Hacl_Hash_SHA1_update_multi +#define Hacl_Hash_SHA2_hash_224 _Py_LibHacl_Hacl_Hash_SHA2_hash_224 +#define Hacl_Hash_SHA2_hash_256 _Py_LibHacl_Hacl_Hash_SHA2_hash_256 +#define Hacl_Hash_SHA2_hash_384 _Py_LibHacl_Hacl_Hash_SHA2_hash_384 +#define Hacl_Hash_SHA2_hash_512 _Py_LibHacl_Hacl_Hash_SHA2_hash_512 +#define Hacl_Hash_SHA2_reset_224 _Py_LibHacl_Hacl_Hash_SHA2_reset_224 +#define Hacl_Hash_SHA2_reset_256 _Py_LibHacl_Hacl_Hash_SHA2_reset_256 +#define Hacl_Hash_SHA2_reset_384 _Py_LibHacl_Hacl_Hash_SHA2_reset_384 +#define Hacl_Hash_SHA2_reset_512 _Py_LibHacl_Hacl_Hash_SHA2_reset_512 +#define Hacl_Hash_SHA2_sha224_finish _Py_LibHacl_Hacl_Hash_SHA2_sha224_finish +#define Hacl_Hash_SHA2_sha224_init _Py_LibHacl_Hacl_Hash_SHA2_sha224_init +#define Hacl_Hash_SHA2_sha224_update_last _Py_LibHacl_Hacl_Hash_SHA2_sha224_update_last +#define Hacl_Hash_SHA2_sha224_update_nblocks _Py_LibHacl_Hacl_Hash_SHA2_sha224_update_nblocks +#define Hacl_Hash_SHA2_sha256_finish _Py_LibHacl_Hacl_Hash_SHA2_sha256_finish +#define Hacl_Hash_SHA2_sha256_init _Py_LibHacl_Hacl_Hash_SHA2_sha256_init +#define Hacl_Hash_SHA2_sha256_update_last _Py_LibHacl_Hacl_Hash_SHA2_sha256_update_last +#define Hacl_Hash_SHA2_sha256_update_nblocks _Py_LibHacl_Hacl_Hash_SHA2_sha256_update_nblocks +#define Hacl_Hash_SHA2_sha384_finish _Py_LibHacl_Hacl_Hash_SHA2_sha384_finish +#define Hacl_Hash_SHA2_sha384_init _Py_LibHacl_Hacl_Hash_SHA2_sha384_init +#define Hacl_Hash_SHA2_sha384_update_last _Py_LibHacl_Hacl_Hash_SHA2_sha384_update_last +#define Hacl_Hash_SHA2_sha384_update_nblocks _Py_LibHacl_Hacl_Hash_SHA2_sha384_update_nblocks +#define Hacl_Hash_SHA2_sha512_finish _Py_LibHacl_Hacl_Hash_SHA2_sha512_finish +#define Hacl_Hash_SHA2_sha512_init _Py_LibHacl_Hacl_Hash_SHA2_sha512_init +#define Hacl_Hash_SHA2_sha512_update_last _Py_LibHacl_Hacl_Hash_SHA2_sha512_update_last +#define Hacl_Hash_SHA2_sha512_update_nblocks _Py_LibHacl_Hacl_Hash_SHA2_sha512_update_nblocks +#define Hacl_Hash_SHA3_absorb_inner_32 _Py_LibHacl_Hacl_Hash_SHA3_absorb_inner_32 +#define Hacl_Hash_SHA3_keccak_piln _Py_LibHacl_Hacl_Hash_SHA3_keccak_piln +#define Hacl_Hash_SHA3_keccak_rndc _Py_LibHacl_Hacl_Hash_SHA3_keccak_rndc +#define Hacl_Hash_SHA3_keccak_rotc _Py_LibHacl_Hacl_Hash_SHA3_keccak_rotc +#define Hacl_Hash_SHA3_sha3_224 _Py_LibHacl_Hacl_Hash_SHA3_sha3_224 +#define Hacl_Hash_SHA3_sha3_256 _Py_LibHacl_Hacl_Hash_SHA3_sha3_256 +#define Hacl_Hash_SHA3_sha3_384 _Py_LibHacl_Hacl_Hash_SHA3_sha3_384 +#define Hacl_Hash_SHA3_sha3_512 _Py_LibHacl_Hacl_Hash_SHA3_sha3_512 +#define Hacl_Hash_SHA3_shake128 _Py_LibHacl_Hacl_Hash_SHA3_shake128 +#define Hacl_Hash_SHA3_shake128_absorb_final _Py_LibHacl_Hacl_Hash_SHA3_shake128_absorb_final +#define Hacl_Hash_SHA3_shake128_absorb_nblocks _Py_LibHacl_Hacl_Hash_SHA3_shake128_absorb_nblocks +#define Hacl_Hash_SHA3_shake128_squeeze_nblocks _Py_LibHacl_Hacl_Hash_SHA3_shake128_squeeze_nblocks +#define Hacl_Hash_SHA3_shake256 _Py_LibHacl_Hacl_Hash_SHA3_shake256 +#define Hacl_Hash_SHA3_state_free _Py_LibHacl_Hacl_Hash_SHA3_state_free +#define Hacl_Hash_SHA3_state_malloc _Py_LibHacl_Hacl_Hash_SHA3_state_malloc // Streaming HMAC -#define Hacl_Streaming_HMAC_malloc_ python_hashlib_Hacl_Streaming_HMAC_malloc_ -#define Hacl_Streaming_HMAC_get_impl python_hashlib_Hacl_Streaming_HMAC_get_impl -#define Hacl_Streaming_HMAC_reset python_hashlib_Hacl_Streaming_HMAC_reset -#define Hacl_Streaming_HMAC_update python_hashlib_Hacl_Streaming_HMAC_update -#define Hacl_Streaming_HMAC_digest python_hashlib_Hacl_Streaming_HMAC_digest -#define Hacl_Streaming_HMAC_copy python_hashlib_Hacl_Streaming_HMAC_copy -#define Hacl_Streaming_HMAC_free python_hashlib_Hacl_Streaming_HMAC_free +#define Hacl_Streaming_HMAC_index_of_state _Py_LibHacl_Hacl_Streaming_HMAC_index_of_state +#define Hacl_Streaming_HMAC_malloc_ _Py_LibHacl_Hacl_Streaming_HMAC_malloc_ +#define Hacl_Streaming_HMAC_get_impl _Py_LibHacl_Hacl_Streaming_HMAC_get_impl +#define Hacl_Streaming_HMAC_reset _Py_LibHacl_Hacl_Streaming_HMAC_reset +#define Hacl_Streaming_HMAC_update _Py_LibHacl_Hacl_Streaming_HMAC_update +#define Hacl_Streaming_HMAC_digest _Py_LibHacl_Hacl_Streaming_HMAC_digest +#define Hacl_Streaming_HMAC_copy _Py_LibHacl_Hacl_Streaming_HMAC_copy +#define Hacl_Streaming_HMAC_free _Py_LibHacl_Hacl_Streaming_HMAC_free +#define Hacl_Streaming_HMAC_s1 _Py_LibHacl_Hacl_Streaming_HMAC_s1 +#define Hacl_Streaming_HMAC_s2 _Py_LibHacl_Hacl_Streaming_HMAC_s2 // HMAC-MD5 -#define Hacl_HMAC_compute_md5 python_hashlib_Hacl_HMAC_compute_md5 +#define Hacl_HMAC_compute_md5 _Py_LibHacl_Hacl_HMAC_compute_md5 // HMAC-SHA-1 -#define Hacl_HMAC_compute_sha1 python_hashlib_Hacl_HMAC_compute_sha1 +#define Hacl_HMAC_compute_sha1 _Py_LibHacl_Hacl_HMAC_compute_sha1 // HMAC-SHA-2 -#define Hacl_HMAC_compute_sha2_224 python_hashlib_Hacl_HMAC_compute_sha2_224 -#define Hacl_HMAC_compute_sha2_256 python_hashlib_Hacl_HMAC_compute_sha2_256 -#define Hacl_HMAC_compute_sha2_384 python_hashlib_Hacl_HMAC_compute_sha2_384 -#define Hacl_HMAC_compute_sha2_512 python_hashlib_Hacl_HMAC_compute_sha2_512 +#define Hacl_HMAC_compute_sha2_224 _Py_LibHacl_Hacl_HMAC_compute_sha2_224 +#define Hacl_HMAC_compute_sha2_256 _Py_LibHacl_Hacl_HMAC_compute_sha2_256 +#define Hacl_HMAC_compute_sha2_384 _Py_LibHacl_Hacl_HMAC_compute_sha2_384 +#define Hacl_HMAC_compute_sha2_512 _Py_LibHacl_Hacl_HMAC_compute_sha2_512 // HMAC-SHA-3 -#define Hacl_HMAC_compute_sha3_224 python_hashlib_Hacl_HMAC_compute_sha3_224 -#define Hacl_HMAC_compute_sha3_256 python_hashlib_Hacl_HMAC_compute_sha3_256 -#define Hacl_HMAC_compute_sha3_384 python_hashlib_Hacl_HMAC_compute_sha3_384 -#define Hacl_HMAC_compute_sha3_512 python_hashlib_Hacl_HMAC_compute_sha3_512 +#define Hacl_HMAC_compute_sha3_224 _Py_LibHacl_Hacl_HMAC_compute_sha3_224 +#define Hacl_HMAC_compute_sha3_256 _Py_LibHacl_Hacl_HMAC_compute_sha3_256 +#define Hacl_HMAC_compute_sha3_384 _Py_LibHacl_Hacl_HMAC_compute_sha3_384 +#define Hacl_HMAC_compute_sha3_512 _Py_LibHacl_Hacl_HMAC_compute_sha3_512 // HMAC-BLAKE -#define Hacl_HMAC_compute_blake2s_32 python_hashlib_Hacl_HMAC_compute_blake2s_32 -#define Hacl_HMAC_compute_blake2b_32 python_hashlib_Hacl_HMAC_compute_blake2b_32 +#define Hacl_HMAC_compute_blake2s_32 _Py_LibHacl_Hacl_HMAC_compute_blake2s_32 +#define Hacl_HMAC_compute_blake2b_32 _Py_LibHacl_Hacl_HMAC_compute_blake2b_32 #endif // _PYTHON_HACL_NAMESPACES_H diff --git a/Modules/_hacl/refresh.sh b/Modules/_hacl/refresh.sh index 903d7fb2afd362..b50c9288aa9e43 100755 --- a/Modules/_hacl/refresh.sh +++ b/Modules/_hacl/refresh.sh @@ -145,6 +145,9 @@ $sed -i -z 's!#include <string.h>!#include <string.h>\n#include "python_hacl_nam Hacl_HMAC.h \ Hacl_Streaming_HMAC.h +$sed -i -z 's!#include <inttypes.h>!#include <inttypes.h>\n#include "python_hacl_namespaces.h"!' \ + lib_memzero0.h + # Step 3: trim whitespace (for the linter) find . -name '*.c' -or -name '*.h' | xargs $sed -i 's![[:space:]]\+$!!' diff --git a/Modules/makesetup b/Modules/makesetup index 8bb971b152a522..f6cf695b457cbf 100755 --- a/Modules/makesetup +++ b/Modules/makesetup @@ -252,11 +252,13 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | case $doconfig in no) cc="$cc $cpps \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)" - rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(MODULE_DEPS_SHARED) \$(PYTHON_HEADERS); $cc -c $src -o $obj" + rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(MODULE_DEPS_SHARED) \$(PYTHON_HEADERS)" + rule="$rule; $cc -c $src -o $obj" ;; *) cc="$cc $cpps \$(PY_BUILTIN_MODULE_CFLAGS)" - rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(MODULE_DEPS_STATIC) \$(PYTHON_HEADERS); $cc -c $src -o $obj" + rule="$obj: $src \$(MODULE_${mods_upper}_DEPS) \$(MODULE_DEPS_STATIC) \$(PYTHON_HEADERS)" + rule="$rule; $cc -c $src -o $obj" ;; esac echo "$rule" >>$rulesf @@ -273,7 +275,7 @@ sed -e 's/[ ]*#.*//' -e '/^[ ]*$/d' | BUILT_SHARED="$BUILT_SHARED $mod" ;; esac - rule="$file: $objs" + rule="$file: $objs \$(MODULE_${mods_upper}_LDEPS)" rule="$rule; \$(BLDSHARED) $objs $libs \$(LIBPYTHON) -o $file" echo "$rule" >>$rulesf done diff --git a/configure b/configure index decb8f2449d162..284263dff48f87 100755 --- a/configure +++ b/configure @@ -708,11 +708,6 @@ MODULE__CTYPES_FALSE MODULE__CTYPES_TRUE MODULE__HMAC_FALSE MODULE__HMAC_TRUE -LIBHACL_SIMD256_OBJS -LIBHACL_SIMD256_FLAGS -LIBHACL_SIMD128_OBJS -LIBHACL_SIMD128_FLAGS -LIBHACL_CFLAGS MODULE__BLAKE2_FALSE MODULE__BLAKE2_TRUE MODULE__SHA3_FALSE @@ -723,6 +718,13 @@ MODULE__SHA1_FALSE MODULE__SHA1_TRUE MODULE__MD5_FALSE MODULE__MD5_TRUE +LIBHACL_LDEPS_LIBTYPE +LIBHACL_BLAKE2_SIMD256_OBJS +LIBHACL_SIMD256_FLAGS +LIBHACL_BLAKE2_SIMD128_OBJS +LIBHACL_SIMD128_FLAGS +LIBHACL_LDFLAGS +LIBHACL_CFLAGS MODULE_UNICODEDATA_FALSE MODULE_UNICODEDATA_TRUE MODULE__MULTIBYTECODEC_FALSE @@ -31912,6 +31914,221 @@ then : fi +############################################################################### +# HACL* compilation and linking configuration (contact: @picnixz) +# +# Used by the HACL*-based implementations of cryptographic primitives. +# +# CPython provides a vendored copy of a subset of the HACL* project used +# to build extension modules of cryptographic primitives. On WASI, HACL* +# sources must be statically linked with the extension modules; on other +# platforms, the extension modules may assume that HACL* has been compiled +# as a shared library. +# +# Example for MD5: +# +# * Compile Modules/_hacl/Hacl_Hash_MD5.c into Modules/_hacl/Hacl_Hash_MD5.o. +# * Decide whether the object files are to be passed to the linker (emulate +# a shared library without having to install it) or if we need to create +# a static library for WASI. The following summarizes the values taken by +# the MODULE_<NAME>_LDFLAGS variable depending on the linkage type: +# - shared: MODULE__MD5_LDFLAGS is set to LIBHACL_MD5_OBJS +# - static: MODULE__MD5_LDFLAGS is set to Modules/_hacl/libHacl_Hash_MD5.a +# * Compile Modules/md5module.c into Modules/md5module.o. +# * Link Modules/md5module.o using $(MODULE__MD5_LDFLAGS) +# and get Modules/_md5$(EXT_SUFFIX). +# +# LIBHACL_FLAG_I: '-I' flags passed to $(CC) for HACL* and HACL*-based modules +# LIBHACL_FLAG_D: '-D' flags passed to $(CC) for HACL* and HACL*-based modules +# LIBHACL_CFLAGS: compiler flags passed for HACL* and HACL*-based modules +# LIBHACL_LDFLAGS: linker flags passed for HACL* and HACL*-based modules +LIBHACL_FLAG_I='-I$(srcdir)/Modules/_hacl -I$(srcdir)/Modules/_hacl/include' +LIBHACL_FLAG_D='-D_BSD_SOURCE -D_DEFAULT_SOURCE' +case "$ac_sys_system" in + Linux*) + if test "$ac_cv_func_explicit_bzero" = "no"; then + LIBHACL_FLAG_D="${LIBHACL_FLAG_D} -DLINUX_NO_EXPLICIT_BZERO" + fi + ;; +esac +LIBHACL_CFLAGS="${LIBHACL_FLAG_I} ${LIBHACL_FLAG_D} \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)" + +LIBHACL_LDFLAGS= # for now, no specific linker flags are needed + + +# The SIMD files use aligned_alloc, which is not available on older versions of +# Android. +# The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || \ + { test -n "$ANDROID_API_LEVEL" && test "$ANDROID_API_LEVEL" -ge 28; } +then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2" >&5 +printf %s "checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2... " >&6; } +if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -msse -msse2 -msse3 -msse4.1 -msse4.2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2=yes +else case e in #( + e) ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" >&5 +printf "%s\n" "$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" >&6; } +if test "x$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" = xyes +then : + + LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" + + +printf "%s\n" "#define HACL_CAN_COMPILE_SIMD128 1" >>confdefs.h + + + # macOS universal2 builds *support* the -msse etc flags because they're + # available on x86_64. However, performance of the HACL SIMD128 implementation + # isn't great, so it's disabled on ARM64. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD128 implementation" >&5 +printf %s "checking for HACL* SIMD128 implementation... " >&6; } + if test "$UNIVERSAL_ARCHS" == "universal2"; then + LIBHACL_BLAKE2_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 +printf "%s\n" "universal2" >&6; } + else + LIBHACL_BLAKE2_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 +printf "%s\n" "standard" >&6; } + fi + + +else case e in #( + e) : ;; +esac +fi + +fi + + + +# The SIMD files use aligned_alloc, which is not available on older versions of +# Android. +# The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. +# +# Although AVX support is not guaranteed on Android +# (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a +# runtime CPUID check. +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || \ + { test -n "$ANDROID_API_LEVEL" && test "$ANDROID_API_LEVEL" -ge 28; } +then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 +printf %s "checking whether C compiler accepts -mavx2... " >&6; } +if test ${ax_cv_check_cflags__Werror__mavx2+y} +then : + printf %s "(cached) " >&6 +else case e in #( + e) + ax_check_save_flags=$CFLAGS + CFLAGS="$CFLAGS -Werror -mavx2" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main (void) +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO" +then : + ax_cv_check_cflags__Werror__mavx2=yes +else case e in #( + e) ax_cv_check_cflags__Werror__mavx2=no ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext + CFLAGS=$ax_check_save_flags ;; +esac +fi +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__mavx2" >&5 +printf "%s\n" "$ax_cv_check_cflags__Werror__mavx2" >&6; } +if test "x$ax_cv_check_cflags__Werror__mavx2" = xyes +then : + + LIBHACL_SIMD256_FLAGS="-mavx2" + +printf "%s\n" "#define HACL_CAN_COMPILE_SIMD256 1" >>confdefs.h + + + # macOS universal2 builds *support* the -mavx2 compiler flag because it's + # available on x86_64; but the HACL SIMD256 build then fails because the + # implementation requires symbols that aren't available on ARM64. Use a + # wrapped implementation if we're building for universal2. + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD256 implementation" >&5 +printf %s "checking for HACL* SIMD256 implementation... " >&6; } + if test "$UNIVERSAL_ARCHS" == "universal2"; then + LIBHACL_BLAKE2_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 +printf "%s\n" "universal2" >&6; } + else + LIBHACL_BLAKE2_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o" + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 +printf "%s\n" "standard" >&6; } + fi + +else case e in #( + e) : ;; +esac +fi + +fi + + +### end(HACL* configuration) + +############################################################################### +# HACL*-based cryptographic primitives + +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* library linking type" >&5 +printf %s "checking for HACL* library linking type... " >&6; } +if test "$ac_sys_system" = "WASI"; then + LIBHACL_LDEPS_LIBTYPE=STATIC + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: static" >&5 +printf "%s\n" "static" >&6; } +else + LIBHACL_LDEPS_LIBTYPE=SHARED + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: shared" >&5 +printf "%s\n" "shared" >&6; } +fi +# Used to complete the "MODULE_<NAME>_LDEPS" Makefile variable. +# The LDEPS variable is a Makefile rule prerequisite. + + + + + + + LIBHACL_MD5_LDFLAGS=LIBHACL_MD5_LIB_${LIBHACL_LDEPS_LIBTYPE} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _md5" >&5 printf %s "checking for stdlib extension module _md5... " >&6; } @@ -31937,8 +32154,8 @@ fi if test "x$py_cv_module__md5" = xyes then : - - + as_fn_append MODULE_BLOCK "MODULE__MD5_CFLAGS=$LIBHACL_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__MD5_LDFLAGS=\$($LIBHACL_MD5_LDFLAGS)$as_nl" fi if test "$py_cv_module__md5" = yes; then @@ -31953,6 +32170,11 @@ fi printf "%s\n" "$py_cv_module__md5" >&6; } + + + + LIBHACL_SHA1_LDFLAGS=LIBHACL_SHA1_LIB_${LIBHACL_LDEPS_LIBTYPE} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _sha1" >&5 printf %s "checking for stdlib extension module _sha1... " >&6; } if test "$py_cv_module__sha1" != "n/a" @@ -31977,8 +32199,8 @@ fi if test "x$py_cv_module__sha1" = xyes then : - - + as_fn_append MODULE_BLOCK "MODULE__SHA1_CFLAGS=$LIBHACL_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__SHA1_LDFLAGS=\$($LIBHACL_SHA1_LDFLAGS)$as_nl" fi if test "$py_cv_module__sha1" = yes; then @@ -31993,6 +32215,11 @@ fi printf "%s\n" "$py_cv_module__sha1" >&6; } + + + + LIBHACL_SHA2_LDFLAGS=LIBHACL_SHA2_LIB_${LIBHACL_LDEPS_LIBTYPE} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _sha2" >&5 printf %s "checking for stdlib extension module _sha2... " >&6; } if test "$py_cv_module__sha2" != "n/a" @@ -32017,8 +32244,8 @@ fi if test "x$py_cv_module__sha2" = xyes then : - - + as_fn_append MODULE_BLOCK "MODULE__SHA2_CFLAGS=$LIBHACL_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__SHA2_LDFLAGS=\$($LIBHACL_SHA2_LDFLAGS)$as_nl" fi if test "$py_cv_module__sha2" = yes; then @@ -32033,6 +32260,11 @@ fi printf "%s\n" "$py_cv_module__sha2" >&6; } + + + + LIBHACL_SHA3_LDFLAGS=LIBHACL_SHA3_LIB_${LIBHACL_LDEPS_LIBTYPE} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _sha3" >&5 printf %s "checking for stdlib extension module _sha3... " >&6; } if test "$py_cv_module__sha3" != "n/a" @@ -32057,8 +32289,8 @@ fi if test "x$py_cv_module__sha3" = xyes then : - - + as_fn_append MODULE_BLOCK "MODULE__SHA3_CFLAGS=$LIBHACL_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__SHA3_LDFLAGS=\$($LIBHACL_SHA3_LDFLAGS)$as_nl" fi if test "$py_cv_module__sha3" = yes; then @@ -32073,6 +32305,11 @@ fi printf "%s\n" "$py_cv_module__sha3" >&6; } + + + + LIBHACL_BLAKE2_LDFLAGS=LIBHACL_BLAKE2_LIB_${LIBHACL_LDEPS_LIBTYPE} + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _blake2" >&5 printf %s "checking for stdlib extension module _blake2... " >&6; } if test "$py_cv_module__blake2" != "n/a" @@ -32097,8 +32334,8 @@ fi if test "x$py_cv_module__blake2" = xyes then : - - + as_fn_append MODULE_BLOCK "MODULE__BLAKE2_CFLAGS=$LIBHACL_CFLAGS$as_nl" + as_fn_append MODULE_BLOCK "MODULE__BLAKE2_LDFLAGS=\$($LIBHACL_BLAKE2_LDFLAGS)$as_nl" fi if test "$py_cv_module__blake2" = yes; then @@ -32113,161 +32350,11 @@ fi printf "%s\n" "$py_cv_module__blake2" >&6; } -LIBHACL_CFLAGS='-I$(srcdir)/Modules/_hacl -I$(srcdir)/Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE $(PY_STDMODULE_CFLAGS) $(CCSHARED)' -case "$ac_sys_system" in - Linux*) - if test "$ac_cv_func_explicit_bzero" = "no"; then - LIBHACL_CFLAGS="$LIBHACL_CFLAGS -DLINUX_NO_EXPLICIT_BZERO" - fi - ;; -esac - - -# The SIMD files use aligned_alloc, which is not available on older versions of -# Android. -# The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. -if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2" >&5 -printf %s "checking whether C compiler accepts -msse -msse2 -msse3 -msse4.1 -msse4.2... " >&6; } -if test ${ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -Werror -msse -msse2 -msse3 -msse4.1 -msse4.2" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2=yes -else case e in #( - e) ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS=$ax_check_save_flags ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" >&5 -printf "%s\n" "$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" >&6; } -if test "x$ax_cv_check_cflags__Werror__msse__msse2__msse3__msse4_1__msse4_2" = xyes -then : - LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2" - - -printf "%s\n" "#define HACL_CAN_COMPILE_SIMD128 1" >>confdefs.h - - - # macOS universal2 builds *support* the -msse etc flags because they're - # available on x86_64. However, performance of the HACL SIMD128 implementation - # isn't great, so it's disabled on ARM64. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD128 implementation" >&5 -printf %s "checking for HACL* SIMD128 implementation... " >&6; } - if test "$UNIVERSAL_ARCHS" == "universal2"; then - LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 -printf "%s\n" "universal2" >&6; } - else - LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 -printf "%s\n" "standard" >&6; } - fi - - -else case e in #( - e) : ;; -esac -fi - -fi - - - -# The SIMD files use aligned_alloc, which is not available on older versions of -# Android. -# The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. -# -# Although AVX support is not guaranteed on Android -# (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a -# runtime CPUID check. -if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -mavx2" >&5 -printf %s "checking whether C compiler accepts -mavx2... " >&6; } -if test ${ax_cv_check_cflags__Werror__mavx2+y} -then : - printf %s "(cached) " >&6 -else case e in #( - e) - ax_check_save_flags=$CFLAGS - CFLAGS="$CFLAGS -Werror -mavx2" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main (void) -{ - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO" -then : - ax_cv_check_cflags__Werror__mavx2=yes -else case e in #( - e) ax_cv_check_cflags__Werror__mavx2=no ;; -esac -fi -rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext - CFLAGS=$ax_check_save_flags ;; -esac -fi -{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags__Werror__mavx2" >&5 -printf "%s\n" "$ax_cv_check_cflags__Werror__mavx2" >&6; } -if test "x$ax_cv_check_cflags__Werror__mavx2" = xyes -then : - - LIBHACL_SIMD256_FLAGS="-mavx2" - -printf "%s\n" "#define HACL_CAN_COMPILE_SIMD256 1" >>confdefs.h - - - # macOS universal2 builds *support* the -mavx2 compiler flag because it's - # available on x86_64; but the HACL SIMD256 build then fails because the - # implementation requires symbols that aren't available on ARM64. Use a - # wrapped implementation if we're building for universal2. - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for HACL* SIMD256 implementation" >&5 -printf %s "checking for HACL* SIMD256 implementation... " >&6; } - if test "$UNIVERSAL_ARCHS" == "universal2"; then - LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: universal2" >&5 -printf "%s\n" "universal2" >&6; } - else - LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o" - { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: standard" >&5 -printf "%s\n" "standard" >&6; } - fi - -else case e in #( - e) : ;; -esac -fi - -fi + LIBHACL_HMAC_LDFLAGS=LIBHACL_HMAC_LIB_${LIBHACL_LDEPS_LIBTYPE} { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _hmac" >&5 printf %s "checking for stdlib extension module _hmac... " >&6; } @@ -32294,7 +32381,7 @@ fi then : as_fn_append MODULE_BLOCK "MODULE__HMAC_CFLAGS=$LIBHACL_CFLAGS$as_nl" - as_fn_append MODULE_BLOCK "MODULE__HMAC_LDFLAGS=$LIBHACL_CFLAGS Modules/_hacl/libHacl_HMAC.a$as_nl" + as_fn_append MODULE_BLOCK "MODULE__HMAC_LDFLAGS=\$($LIBHACL_HMAC_LDFLAGS)$as_nl" fi if test "$py_cv_module__hmac" = yes; then @@ -32310,6 +32397,9 @@ printf "%s\n" "$py_cv_module__hmac" >&6; } +### end(cryptographic primitives) + + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdlib extension module _ctypes" >&5 printf %s "checking for stdlib extension module _ctypes... " >&6; } if test "$py_cv_module__ctypes" != "n/a" diff --git a/configure.ac b/configure.ac index 004797b5233c20..99ebe111cfb184 100644 --- a/configure.ac +++ b/configure.ac @@ -7846,28 +7846,54 @@ PY_STDLIB_MOD_SIMPLE([_codecs_tw]) PY_STDLIB_MOD_SIMPLE([_multibytecodec]) PY_STDLIB_MOD_SIMPLE([unicodedata]) -dnl By default we always compile these even when OpenSSL is available -dnl (issue #14693). The modules are small. -PY_STDLIB_MOD([_md5], [test "$with_builtin_md5" = yes]) -PY_STDLIB_MOD([_sha1], [test "$with_builtin_sha1" = yes]) -PY_STDLIB_MOD([_sha2], [test "$with_builtin_sha2" = yes]) -PY_STDLIB_MOD([_sha3], [test "$with_builtin_sha3" = yes]) -PY_STDLIB_MOD([_blake2], [test "$with_builtin_blake2" = yes]) - -LIBHACL_CFLAGS='-I$(srcdir)/Modules/_hacl -I$(srcdir)/Modules/_hacl/include -D_BSD_SOURCE -D_DEFAULT_SOURCE $(PY_STDMODULE_CFLAGS) $(CCSHARED)' +############################################################################### +# HACL* compilation and linking configuration (contact: @picnixz) +# +# Used by the HACL*-based implementations of cryptographic primitives. +# +# CPython provides a vendored copy of a subset of the HACL* project used +# to build extension modules of cryptographic primitives. On WASI, HACL* +# sources must be statically linked with the extension modules; on other +# platforms, the extension modules may assume that HACL* has been compiled +# as a shared library. +# +# Example for MD5: +# +# * Compile Modules/_hacl/Hacl_Hash_MD5.c into Modules/_hacl/Hacl_Hash_MD5.o. +# * Decide whether the object files are to be passed to the linker (emulate +# a shared library without having to install it) or if we need to create +# a static library for WASI. The following summarizes the values taken by +# the MODULE_<NAME>_LDFLAGS variable depending on the linkage type: +# - shared: MODULE__MD5_LDFLAGS is set to LIBHACL_MD5_OBJS +# - static: MODULE__MD5_LDFLAGS is set to Modules/_hacl/libHacl_Hash_MD5.a +# * Compile Modules/md5module.c into Modules/md5module.o. +# * Link Modules/md5module.o using $(MODULE__MD5_LDFLAGS) +# and get Modules/_md5$(EXT_SUFFIX). +# +# LIBHACL_FLAG_I: '-I' flags passed to $(CC) for HACL* and HACL*-based modules +# LIBHACL_FLAG_D: '-D' flags passed to $(CC) for HACL* and HACL*-based modules +# LIBHACL_CFLAGS: compiler flags passed for HACL* and HACL*-based modules +# LIBHACL_LDFLAGS: linker flags passed for HACL* and HACL*-based modules +LIBHACL_FLAG_I='-I$(srcdir)/Modules/_hacl -I$(srcdir)/Modules/_hacl/include' +LIBHACL_FLAG_D='-D_BSD_SOURCE -D_DEFAULT_SOURCE' case "$ac_sys_system" in Linux*) if test "$ac_cv_func_explicit_bzero" = "no"; then - LIBHACL_CFLAGS="$LIBHACL_CFLAGS -DLINUX_NO_EXPLICIT_BZERO" + LIBHACL_FLAG_D="${LIBHACL_FLAG_D} -DLINUX_NO_EXPLICIT_BZERO" fi ;; esac +LIBHACL_CFLAGS="${LIBHACL_FLAG_I} ${LIBHACL_FLAG_D} \$(PY_STDMODULE_CFLAGS) \$(CCSHARED)" AC_SUBST([LIBHACL_CFLAGS]) +LIBHACL_LDFLAGS= # for now, no specific linker flags are needed +AC_SUBST([LIBHACL_LDFLAGS]) # The SIMD files use aligned_alloc, which is not available on older versions of # Android. # The *mmintrin.h headers are x86-family-specific, so can't be used on WASI. -if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || \ + { test -n "$ANDROID_API_LEVEL" && test "$ANDROID_API_LEVEL" -ge 28; } +then dnl This can be extended here to detect e.g. Power8, which HACL* should also support. AX_CHECK_COMPILE_FLAG([-msse -msse2 -msse3 -msse4.1 -msse4.2],[ [LIBHACL_SIMD128_FLAGS="-msse -msse2 -msse3 -msse4.1 -msse4.2"] @@ -7879,17 +7905,17 @@ if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || tes # isn't great, so it's disabled on ARM64. AC_MSG_CHECKING([for HACL* SIMD128 implementation]) if test "$UNIVERSAL_ARCHS" == "universal2"; then - [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"] + [LIBHACL_BLAKE2_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128_universal2.o"] AC_MSG_RESULT([universal2]) else - [LIBHACL_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"] + [LIBHACL_BLAKE2_SIMD128_OBJS="Modules/_hacl/Hacl_Hash_Blake2s_Simd128.o"] AC_MSG_RESULT([standard]) fi ], [], [-Werror]) fi AC_SUBST([LIBHACL_SIMD128_FLAGS]) -AC_SUBST([LIBHACL_SIMD128_OBJS]) +AC_SUBST([LIBHACL_BLAKE2_SIMD128_OBJS]) # The SIMD files use aligned_alloc, which is not available on older versions of # Android. @@ -7898,7 +7924,9 @@ AC_SUBST([LIBHACL_SIMD128_OBJS]) # Although AVX support is not guaranteed on Android # (https://developer.android.com/ndk/guides/abis#86-64), this is safe because we do a # runtime CPUID check. -if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || test "$ANDROID_API_LEVEL" -ge 28; then +if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || \ + { test -n "$ANDROID_API_LEVEL" && test "$ANDROID_API_LEVEL" -ge 28; } +then AX_CHECK_COMPILE_FLAG([-mavx2],[ [LIBHACL_SIMD256_FLAGS="-mavx2"] AC_DEFINE([HACL_CAN_COMPILE_SIMD256], [1], [HACL* library can compile SIMD256 implementations]) @@ -7909,23 +7937,57 @@ if test "$ac_sys_system" != "Linux-android" -a "$ac_sys_system" != "WASI" || tes # wrapped implementation if we're building for universal2. AC_MSG_CHECKING([for HACL* SIMD256 implementation]) if test "$UNIVERSAL_ARCHS" == "universal2"; then - [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"] + [LIBHACL_BLAKE2_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256_universal2.o"] AC_MSG_RESULT([universal2]) else - [LIBHACL_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] + [LIBHACL_BLAKE2_SIMD256_OBJS="Modules/_hacl/Hacl_Hash_Blake2b_Simd256.o"] AC_MSG_RESULT([standard]) fi ], [], [-Werror]) fi AC_SUBST([LIBHACL_SIMD256_FLAGS]) -AC_SUBST([LIBHACL_SIMD256_OBJS]) +AC_SUBST([LIBHACL_BLAKE2_SIMD256_OBJS]) +### end(HACL* configuration) + +############################################################################### +# HACL*-based cryptographic primitives + +AC_MSG_CHECKING([for HACL* library linking type]) +if test "$ac_sys_system" = "WASI"; then + LIBHACL_LDEPS_LIBTYPE=STATIC + AC_MSG_RESULT([static]) +else + LIBHACL_LDEPS_LIBTYPE=SHARED + AC_MSG_RESULT([shared]) +fi +# Used to complete the "MODULE_<NAME>_LDEPS" Makefile variable. +# The LDEPS variable is a Makefile rule prerequisite. +AC_SUBST([LIBHACL_LDEPS_LIBTYPE]) + +dnl PY_HACL_CREATE_MODULE([COMPONENT], [EXTNAME], [ENABLED-TEST]) +dnl The COMPONENT is the name of the HACL* component being built in uppercase. +dnl Corresponding Makefile variables are named as LIBHACL_<COMPONENT>_*. +dnl The EXTNAME is the name of the extension module being built. +AC_DEFUN([PY_HACL_CREATE_MODULE], [ + AS_VAR_PUSHDEF([v], [[LIBHACL_][$1][_LDFLAGS]]) + AS_VAR_SET([v], [[LIBHACL_][$1][_LIB_${LIBHACL_LDEPS_LIBTYPE}]]) + PY_STDLIB_MOD([$2], [$3], [], [$LIBHACL_CFLAGS], [\$($v)]) + AS_VAR_POPDEF([v]) +]) + +dnl By default we always compile these even when OpenSSL is available +dnl (see bpo-14693). The modules are small. +PY_HACL_CREATE_MODULE([MD5], [_md5], [test "$with_builtin_md5" = yes]) +PY_HACL_CREATE_MODULE([SHA1], [_sha1], [test "$with_builtin_sha1" = yes]) +PY_HACL_CREATE_MODULE([SHA2], [_sha2], [test "$with_builtin_sha2" = yes]) +PY_HACL_CREATE_MODULE([SHA3], [_sha3], [test "$with_builtin_sha3" = yes]) +PY_HACL_CREATE_MODULE([BLAKE2], [_blake2], [test "$with_builtin_blake2" = yes]) dnl HMAC builtin library does not need OpenSSL for now. In the future dnl we might want to rely on OpenSSL EVP/NID interface or implement dnl our own for algorithm resolution. -PY_STDLIB_MOD([_hmac], [], [], - [$LIBHACL_CFLAGS], - [$LIBHACL_CFLAGS Modules/_hacl/libHacl_HMAC.a]) +PY_HACL_CREATE_MODULE([HMAC], [_hmac], []) +### end(cryptographic primitives) PY_STDLIB_MOD([_ctypes], [], [test "$have_libffi" = yes], _______________________________________________ Python-checkins mailing list -- python-checkins@python.org To unsubscribe send an email to python-checkins-le...@python.org https://mail.python.org/mailman3/lists/python-checkins.python.org/ Member address: arch...@mail-archive.com