_hmac module bypasses --with-builtin-hashlib-hashes by embedding all HACL hash implementations
還沒有人認領這個 Issue。
- 主要語言
- Python
- 星號
- 77.2k
- 分支
- 36k
- PR 合併指標
- PR 指標待擷取
描述
Bug report
Bug description:
When configuring Python with e.g. --with-builtin-hashlib-hashes=blake2 to build only the blake2 builtin hash module, the _hmac module is still unconditionally built and embeds all HACL hash implementations (MD5, SHA1, SHA2, SHA3, Blake2).
While in these cases the excluded hashes are not built as extension modules, since they are compiled into _hmac, then md5 and other disabled digests can still be computed
>>> import _hmac
>>> _hmac.compute_digest(b'key', b'msg', 'md5')
b'\x18\xe3T\x8cY\xad@\xdd\x03\x90{z\xee\xe7\x1dg'
Not sure if that is intended behaviour or an oversight but it seems to defeat the purpose of excluding specific hashes. Also increases the size of _hmac substantially. Discovered it when working on a FIPS build.
On our FIPS build I opted for completely disabling _hmac in this case (FIPS builds only utilize OpenSSL anyway for hmac)
CPython versions tested on:
3.15, 3.14
Operating systems tested on:
Linux
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
研究方向
從連結的 configure.ac 區段以及 Makefile.pre.in 中的 HACL 原始碼項目開始。使用 --with-builtin-hashlib-hashes=blake2 設定 CPython,進行建置,並重現 _hmac.compute_digest(..., 'md5') 的行為。當 _hmac 遵循選取的雜湊設定,且被排除的實作不再嵌入時,即視為完成。
由索引模型根據 Issue 內容生成。
評估
- 技術堆疊
- python
- 領域
- build-system, cryptography
- Issue 類型
- 缺陷
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 活躍度
- 停滯
- 描述清晰度
- 基本清楚
- 新手友好度
- 38/100