Range Check Exception when using KDF with empty password
@MHumm ya está trabajando en esto.
Desde el 12/5/2024.
Evaluación
Este issue todavía no se ha evaluado.
Descripción
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")
- Lenguaje dominante
- HTML
- Estrellas
- 286
- Forks
- 78
- Merge medio
- 1 d 4 h
- PR fusionados (30 d)
- 4
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de MHumm/DelphiEncryptionCompendium
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
-
CRC64 - PKI AdditionQuizá libre de nuevo @MHumm la tomó hace 149 días y no hay ningún pull request abierto. Abiertoenhancement help wanted
MHumm/DelphiEncryptionCompendium#93 · 1 comentario · 1 asignado ·
-
Missing PUInt8Array type in the GetIt version.Quizá libre de nuevo @MHumm la tomó hace 161 días y no hay ningún pull request abierto. Abiertobug delphi
MHumm/DelphiEncryptionCompendium#92 · 2 comentarios · 1 asignado ·
-
Help with demoAbiertoquestion
Dificultad 4/5 1-2 días Aptitud para principiantes 25/100
MHumm/DelphiEncryptionCompendium#91 · 6 comentarios ·
-
Chacha20 Poly1305Quizá libre de nuevo @MHumm la tomó hace 459 días y no hay ningún pull request abierto. Abiertoenhancement
MHumm/DelphiEncryptionCompendium#89 · 1 comentario · 1 asignado ·