python / python/cpython

_hmac module bypasses --with-builtin-hashlib-hashes by embedding all HACL hash implementations

Abierto
#143,634 5 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

build extension-modules type-bug
Lenguaje dominante
Python
Estrellas
77.2k
Forks
35.9k
Métricas de merge de PR
Métricas de PR pendientes

Descripción

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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con la sección enlazada de configure.ac y las entradas de código fuente de HACL en Makefile.pre.in. Configura CPython con --with-builtin-hashlib-hashes=blake2, compílalo y reproduce el comportamiento de _hmac.compute_digest(..., 'md5'). Se considera completado cuando _hmac respeta la configuración de hash seleccionada y las implementaciones excluidas ya no están integradas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
build-system, cryptography
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
38/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.