python / python/cpython

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

Aberta
#143,634 5 comentários 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

build extension-modules type-bug
Linguagem predominante
Python
Estrelas
77.2k
Forks
35.9k
Métricas de merge de PRs
Métricas de PR pendentes

Descrição

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

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Direção de pesquisa

Comece pela seção vinculada de configure.ac e pelas entradas de código-fonte HACL em Makefile.pre.in. Configure o CPython com --with-builtin-hashlib-hashes=blake2, compile-o e reproduza o comportamento de _hmac.compute_digest(..., 'md5'). Considera-se concluído quando a configuração de hash selecionada é respeitada por _hmac e as implementações excluídas não são mais incorporadas.

Escrita pelo modelo de indexação a partir do texto da issue.

Avaliação

Stack de tecnologia
python
Domínio
build-system, cryptography
Tipo de issue
Bug
Dificuldade
4/5
Tempo estimado
3-5 dias
Status de atividade
Estagnada
Clareza
Razoavelmente clara
Facilidade para iniciantes
38/100

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.