DecodeBytes decodes in place and overwrites the caller's ciphertext (non-GCM modes)
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 2/5
- Geschätzter Aufwand
- 1-3 Stunden
- Anfängerfreundlichkeit
- 68/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Bereich
- cryptography, testing
Rechercherichtung
Beginne mit TDECFormattedCipher.DecodeBytes, wo Result := Source dazu führt, dass beide Arrays denselben Speicher teilen. Nur der cmGCM-Zweig ruft SetLength auf, daher muss die Eingabe vor Decode in allen Modi nach Result kopiert werden. Die Nebenkorrektur betrifft TestTFormat_UU.TestIsValidTypeless, wo @SrcBuf durch @SrcBuf[0] ersetzt werden sollte. Fertig ist, wenn das Eingabearray des Aufrufers nach dem Dekodieren in allen Modi unverändert ist und die Tests unter Win64 bestehen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
TDECFormattedCipher.DecodeBytes overwrites the caller's input array for every mode except GCM.
Cause
DecodeBytes starts with Result := Source. For dynamic arrays this only copies the reference, so Result and Source point to the same memory. Only for cmGCM is SetLength(Result, Length(Source)) called, which creates a separate copy. For all other modes Decode(Source[0], Result[0], ...) writes the plaintext straight into the caller's array.
Effect
After Plain := Cipher.DecodeBytes(CipherText), CipherText contains the plaintext too. Code that decodes the same buffer twice, or keeps the ciphertext for later use (logging, retry, comparing), silently works on wrong data.
Repro
Cipher := TCipher_Twofish.Create;
Cipher.Mode := cmCBCx;
Cipher.Init(Key, IV, $FF);
Original := Copy(Source);
Plain := Cipher.DecodeBytes(Source);
// Source is now equal to Plain instead of Original
I came across this in the ChaCha20 speed tests on development_chacha20poly1305, which decode the same buffer once per CPU mode. Every decode after the first one failed.
Side note
TestTFormat_UU.TestIsValidTypeless fails now and then on Win64. It uses p := @SrcBuf, which points at the array variable instead of the data, so IsValid checks the bytes of a heap pointer. It should be @SrcBuf[0]. I fix that in the same PR.
- Vorherrschende Sprache
- HTML
- Sterne
- 286
- Forks
- 78
- Ø Merge
- 1 T. 4 Std.
- Gemergte PRs (30 T.)
- 4
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 149 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 161 Tagen übernommen, und es ist kein Pull Request offen. Offenbug delphi
MHumm/DelphiEncryptionCompendium#92 · 2 Kommentare · 1 zugewiesene Person ·
-
Help with demoOffenquestion
Schwierigkeit 4/5 1-2 Tage Anfängerfreundlichkeit 25/100
MHumm/DelphiEncryptionCompendium#91 · 6 Kommentare ·
-
Chacha20 Poly1305Evtl. wieder frei @MHumm hat das vor 459 Tagen übernommen, und es ist kein Pull Request offen. Offenenhancement
MHumm/DelphiEncryptionCompendium#89 · 1 Kommentar · 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 ·
Alle Issues in MHumm/DelphiEncryptionCompendium
Ähnliche Issues
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 2 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 74/100
btclib-org/btclib-secp256k1#1208 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug QA & Testing Rust Implementation
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
georgegoldman/Soroban-ZK-Std#559 ·
Maintainer antworten meist innerhalb von 1 Tag
-
bug
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
-
verify_input accepts a negative input index and raises IndexError past the endEvtl. vergeben @aryansinha1908 hat das vor 1 Tag übernommen. Offengood first issue
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
btclib-org/btclib#2672 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag