HACL* HMAC does not properly use vectorized BLAKE-2
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 77.2k
- Fork
- 35.9k
- Metriche di merge delle PR
- Metriche PR in attesa
Descrizione
Bug report
Bug description:
First of all, it doesn't really make sense to support HMAC-BLAKE-2 because BLAKE-2 is already a keyed hash function so it already has the properties expected by HMAC. Since HACL* provides it (I don't remember if I actually asked them to, so if I did, it's my fault), I decided to expose it anyway.
HACL* provides SIMD-accelerated implementation for BLAKE-2 which is exposed if the HACL_CAN_COMPILE_VEC128 and HACL_CAN_COMPILE_VEC256 macros are defined. CPython, however, needs to do a bit more work to be able to know whether we can define those macros or not. The work is achieved in two steps:
- In
configure, depending on the host capabilities, the macros are defined. - When compiling, depending on the host capabilities once again, the macros are undefined.
The generic headers are afterwards included, e.g.:
#define HACL_CAN_COMPILE_VEC128 _Py_HACL_CAN_COMPILE_VEC128
#define HACL_CAN_COMPILE_VEC256 _Py_HACL_CAN_COMPILE_VEC256
#include "_hacl/Hacl_HMAC.h"
#include "_hacl/Hacl_Streaming_HMAC.h" // Hacl_Agile_Hash_* identifiers
#include "_hacl/Hacl_Streaming_Types.h" // Hacl_Streaming_Types_error_code
Now, there is a slight issue. The conditional code is actually inside the .c file and not the .h. However, that .c file is an HACL* file that is compiled separately and doesn't have any defines. It also unconditionally includes Hacl_Hash_Blake2s_Simd128.h and Hacl_Hash_Blake2s_Simd256.h files. So I'm not entirely sure about what to do :(
Am I incorrectly using the files @msprotz?
CPython versions tested on:
CPython main branch, 3.14, 3.15
Operating systems tested on:
No response
Linked PRs
- gh-146118
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia leggendo configure e l’integrazione HACL* HMAC attorno a Hacl_HMAC.h, Hacl_Streaming_HMAC.h, Hacl_Streaming_Types.h e al file .c HACL* compilato separatamente. Segui come vengono definiti o non definiti HACL_CAN_COMPILE_VEC128 e HACL_CAN_COMPILE_VEC256, quindi verifica che HMAC-BLAKE-2 utilizzi l’implementazione vettorializzata supportata sugli host compatibili senza compromettere le altre build.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- c
- Ambito
- build-system, cryptography
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100