gh-99108: Implement HACL* HMAC (#130157)

A new extension module, `_hmac`, now exposes the HACL* HMAC (formally verified) implementation.

The HACL* implementation is used as a fallback implementation when the OpenSSL implementation of HMAC
is not available or disabled. For now, only named hash algorithms are recognized and SIMD support provided
by HACL* for the BLAKE2 hash functions is not yet used.
This commit is contained in:
Bénédikt Tran 2025-04-04 19:04:00 +02:00 committed by GitHub
parent 7099c75550
commit 0a97427ee5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 7702 additions and 103 deletions

View file

@ -209,4 +209,31 @@
#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
// 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
// HMAC-MD5
#define Hacl_HMAC_compute_md5 python_hashlib_Hacl_HMAC_compute_md5
// HMAC-SHA-1
#define Hacl_HMAC_compute_sha1 python_hashlib_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
// 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
// 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
#endif // _PYTHON_HACL_NAMESPACES_H