HACL* HMAC does not properly use vectorized BLAKE-2
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
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
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
先閱讀 configure,以及圍繞 Hacl_HMAC.h、Hacl_Streaming_HMAC.h、Hacl_Streaming_Types.h 和個別編譯的 HACL* .c 檔案的 HACL* HMAC 整合。追蹤 HACL_CAN_COMPILE_VEC128 和 HACL_CAN_COMPILE_VEC256 如何被定義或取消定義,然後確認 HMAC-BLAKE-2 在支援的主機上使用受支援的向量化實作,同時不破壞其他建置。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- c
- 領域
- build-system, cryptography
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 需要釐清
- 新手友好度
- 25/100