Range Check Exception when using KDF with empty password
@MHumm arbeitet bereits daran.
Seit 12.5.2024.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
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")
- Vorherrschende Sprache
- HTML
- Sterne
- 286
- Forks
- 78
- Ø Merge
- 1 T. 23 Min.
- Gemergte PRs (30 T.)
- 5
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus MHumm/DelphiEncryptionCompendium
-
CRC64 - PKI AdditionEvtl. wieder frei @MHumm hat das vor 150 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement help wanted
MHumm/DelphiEncryptionCompendium#93 · 1 Kommentar · 1 zugewiesene Person ·
-
Missing PUInt8Array type in the GetIt version.Evtl. wieder frei @MHumm hat das vor 162 Tagen übernommen, und es ist kein Pull Request offen. Offenbug delphi
MHumm/DelphiEncryptionCompendium#92 · 2 Kommentare · 1 zugewiesene Person ·
-
Confused by NEXTGEN directiveEvtl. wieder frei @MHumm hat das vor 532 Tagen übernommen, und es ist kein Pull Request offen. Offenbug
MHumm/DelphiEncryptionCompendium#88 · 8 Kommentare · 1 zugewiesene Person ·
-
Authenticated tag is wrong on streamsEvtl. wieder frei @MHumm hat das vor 542 Tagen übernommen, und es ist kein Pull Request offen. Offenbug
MHumm/DelphiEncryptionCompendium#87 · 20 Kommentare · 1 zugewiesene Person ·
-
Support for AEGIS 256Evtl. wieder frei @MHumm hat das vor 853 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement help wanted
MHumm/DelphiEncryptionCompendium#77 · 3 Kommentare · 1 Reaktion · 1 zugewiesene Person ·