gh-131876: extract _hashlib helpers into a separate directory (#136995)

The `Modules/hashlib.h` helper file is now removed and split into multiple files:

* `Modules/_hashlib/hashlib_buffer.[ch]` -- Utilities for getting a buffer view and handling buffer inputs.
* `Modules/_hashlib/hashlib_fetch.h` -- Utilities used when fetching a message digest from a digest-like identifier.
  Currently, this file only contains common error messages as the fetching API is not yet implemented.
* `Modules/_hashlib/hashlib_mutex.h` -- Utilities for managing the lock on cryptographic hash objects.
This commit is contained in:
Bénédikt Tran
2025-07-28 11:28:48 +02:00
committed by GitHub
parent eefd70f0ed
commit 45138d3584
20 changed files with 346 additions and 221 deletions

View File

@@ -7187,6 +7187,7 @@ SRCDIRS="\
Modules/_decimal \
Modules/_decimal/libmpdec \
Modules/_hacl \
Modules/_hashlib \
Modules/_io \
Modules/_multiprocessing \
Modules/_sqlite \
@@ -7957,6 +7958,15 @@ PY_STDLIB_MOD_SIMPLE([_codecs_tw])
PY_STDLIB_MOD_SIMPLE([_multibytecodec])
PY_STDLIB_MOD_SIMPLE([unicodedata])
###############################################################################
# Cryptographic primitives
LIBHASHLIB_INTERNAL_CFLAGS="-I\$(srcdir)/Modules/_hashlib"
LIBHASHLIB_INTERNAL_LDFLAGS="-lm \$(LIBHASHLIB_INTERNAL_A)"
LIBHASHLIB_INTERNAL="\$(LIBHASHLIB_INTERNAL_HEADERS) \$(LIBHASHLIB_INTERNAL_A)"
AC_SUBST([LIBHASHLIB_INTERNAL_CFLAGS])
AC_SUBST([LIBHASHLIB_INTERNAL])
###############################################################################
# HACL* compilation and linking configuration (contact: @picnixz)
#
@@ -8093,7 +8103,9 @@ 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)])
PY_STDLIB_MOD([$2], [$3], [],
[$LIBHACL_CFLAGS $LIBHASHLIB_INTERNAL_CFLAGS],
[\$($v) $LIBHASHLIB_INTERNAL_LDFLAGS])
AS_VAR_POPDEF([v])
])
@@ -8174,7 +8186,8 @@ dnl OpenSSL bindings
PY_STDLIB_MOD([_ssl], [], [test "$ac_cv_working_openssl_ssl" = yes],
[$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $OPENSSL_LIBS])
PY_STDLIB_MOD([_hashlib], [], [test "$ac_cv_working_openssl_hashlib" = yes],
[$OPENSSL_INCLUDES], [$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS])
[$OPENSSL_INCLUDES $LIBHASHLIB_INTERNAL_CFLAGS],
[$OPENSSL_LDFLAGS $OPENSSL_LDFLAGS_RPATH $LIBCRYPTO_LIBS $LIBHASHLIB_INTERNAL_LDFLAGS])
dnl test modules
PY_STDLIB_MOD([_testcapi],