gh-135004: rewrite and cleanup blake2module.c (#135006)

* Cleanup imports and update module docstring.
* Simplify detection of SIMD support.
* Correctly guard `update()` cases.
* Rewrite `py_blake2b_or_s_new` and rename it to `py_blake2_new`.
* Rewrite `blake2_blake2b_copy_locked` and `py_blake2_clear`.
* Refactor computations of `digest` and `hexdigest`.
* Simplify `py_blake2b_get_name` and `py_blake2b_get_block_size`.
* Add `hacl_get_blake2_info` to extract static BLAKE-2 information.
   This new helper is used by `py_blake2b_get_digest_size`, but can
   be later used to expose `key_length` more easily.
This commit is contained in:
Bénédikt Tran 2025-06-09 09:17:43 +02:00 committed by GitHub
parent 83b94e856e
commit 3cb109796d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 377 additions and 381 deletions

View File

@ -0,0 +1,3 @@
Rewrite and cleanup the internal :mod:`!_blake2` module. Some exception
messages were changed but their types were left untouched. Patch by Bénédikt
Tran.

File diff suppressed because it is too large Load Diff

View File

@ -1715,11 +1715,11 @@ hmacmodule_init_cpu_features(hmacmodule_state *state)
__cpuid_count(1, 0, eax1, ebx1, ecx1, edx1);
__cpuid_count(7, 0, eax7, ebx7, ecx7, edx7);
#elif defined(_M_X64)
int info1[4] = { 0 };
int info1[4] = {0};
__cpuidex(info1, 1, 0);
eax1 = info1[0], ebx1 = info1[1], ecx1 = info1[2], edx1 = info1[3];
int info7[4] = { 0 };
int info7[4] = {0};
__cpuidex(info7, 7, 0);
eax7 = info7[0], ebx7 = info7[1], ecx7 = info7[2], edx7 = info7[3];
#endif