Range Check Exception when using KDF with empty password
@MHumm já está trabalhando nisso.
Desde 12/5/2024.
Avaliação
Esta issue ainda não foi avaliada.
Descrição
In my app, I noticed a "Range Check Exception" when the user didn't enter a password (which I clearly forgot to check), and therefore the, empty password was tried to be processed through KDF. The reason for the Range Check Exception is that Data[0] is accessed, which does not exist if Data is empty.
class function TDECHashAuthentication.KDFx(const Data, Seed: TBytes;
MaskSize: Integer;
Index: UInt32 = 1): TBytes;
begin
if (length(Seed) > 0) then
Result := KDFx(Data[0], Length(Data), Seed[0], Length(Seed), MaskSize, Index)
else
Result := KDFx(Data[0], Length(Data), NullStr, Length(Seed), MaskSize, Index)
end;
(This is just an example. Not only KDFx is affected. Other methods are affected too.)
It is dangerous that a method can fail this way, especially because "range check" can be disabled in the compiler settings for performance reasons.
In my opinion we should do the following: Find out (from official sources / reference implementation) what KDF123x/PBKDF/MGF1 is supposed to do if the input is 0 bytes. Is it supposed to fail, or is it supposed to return a key "X"?
- If it shall output a key "X", then we should implement it this way
- If it is supposed to fail, then we must throw an Exception instead of risking a memory-corruption if range checks are disabled
(edit: typo. of course I meant "instead of risking")
- Linguagem predominante
- HTML
- Estrelas
- 286
- Forks
- 78
- Merge médio
- 1d 23min
- PRs com merge (30d)
- 5
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de MHumm/DelphiEncryptionCompendium
-
CRC64 - PKI AdditionTalvez livre de novo @MHumm assumiu há 151 dias e não há nenhum pull request aberto. Abertaenhancement help wanted
MHumm/DelphiEncryptionCompendium#93 · 1 comentário · 1 responsável ·
-
Missing PUInt8Array type in the GetIt version.Talvez livre de novo @MHumm assumiu há 162 dias e não há nenhum pull request aberto. Abertabug delphi
MHumm/DelphiEncryptionCompendium#92 · 2 comentários · 1 responsável ·
-
Confused by NEXTGEN directiveTalvez livre de novo @MHumm assumiu há 533 dias e não há nenhum pull request aberto. Abertabug
MHumm/DelphiEncryptionCompendium#88 · 8 comentários · 1 responsável ·
-
Authenticated tag is wrong on streamsTalvez livre de novo @MHumm assumiu há 543 dias e não há nenhum pull request aberto. Abertabug
MHumm/DelphiEncryptionCompendium#87 · 20 comentários · 1 responsável ·
-
Support for AEGIS 256Talvez livre de novo @MHumm assumiu há 854 dias e não há nenhum pull request aberto. Abertaenhancement help wanted
MHumm/DelphiEncryptionCompendium#77 · 3 comentários · 1 reação · 1 responsável ·