_hmac module bypasses --with-builtin-hashlib-hashes by embedding all HACL hash implementations
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 77.2k
- Forks
- 35.9k
- PR-Merge-Kennzahlen
- PR-Kennzahlen ausstehend
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit dem verknüpften Abschnitt in configure.ac und den HACL-Quelleneinträgen in Makefile.pre.in. Konfiguriere CPython mit --with-builtin-hashlib-hashes=blake2, erstelle es und reproduziere das Verhalten von _hmac.compute_digest(..., 'md5'). Als erledigt gilt die Aufgabe, wenn die ausgewählte Hash-Konfiguration von _hmac respektiert wird und die ausgeschlossenen Implementierungen nicht mehr eingebettet sind.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- python
- Bereich
- build-system, cryptography
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 38/100