DecodeBytes decodes in place and overwrites the caller's ciphertext (non-GCM modes)
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- cryptography, testing
Direzione di ricerca
Inizia da TDECFormattedCipher.DecodeBytes, dove Result := Source fa sì che entrambi gli array condividano la memoria. Solo il ramo cmGCM chiama SetLength, quindi copia l'input in Result prima di Decode per tutte le modalità. La correzione collaterale riguarda TestTFormat_UU.TestIsValidTypeless, dove @SrcBuf deve diventare @SrcBuf[0]. È completata quando l'array di input del chiamante resta invariato dopo la decodifica in tutte le modalità e i test passano su Win64.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- HTML
- Stelle
- 286
- Fork
- 78
- Merge medio
- 1g 4h
- PR unite (30g)
- 4
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MHumm/DelphiEncryptionCompendium
-
CRC64 - PKI AdditionForse di nuovo libera @MHumm l’ha presa 148 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement help wanted
MHumm/DelphiEncryptionCompendium#93 · 1 commento · 1 assegnatario ·
-
Missing PUInt8Array type in the GetIt version.Forse di nuovo libera @MHumm l’ha presa 159 giorni fa e non c’è nessuna pull request aperta. Apertabug delphi
MHumm/DelphiEncryptionCompendium#92 · 2 commenti · 1 assegnatario ·
-
Help with demoApertaquestion
Difficoltà 4/5 1-2 giorni Idoneità per principianti 25/100
MHumm/DelphiEncryptionCompendium#91 · 6 commenti ·
-
Chacha20 Poly1305Forse di nuovo libera @MHumm l’ha presa 458 giorni fa e non c’è nessuna pull request aperta. Apertaenhancement
MHumm/DelphiEncryptionCompendium#89 · 1 commento · 1 assegnatario ·
-
Confused by NEXTGEN directiveForse di nuovo libera @MHumm l’ha presa 530 giorni fa e non c’è nessuna pull request aperta. Apertabug
MHumm/DelphiEncryptionCompendium#88 · 8 commenti · 1 assegnatario ·
Tutte le issue di MHumm/DelphiEncryptionCompendium
Issue simili
-
Client customer-reported KeyVault needs-team-attention question Service Attention
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
Azure/azure-sdk-for-net#63861 · 3 commenti · 1 reazione ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
raspberrypi/picotool#365 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 70/100
SpecterOps/BloodHound#3462 ·
I maintainer di solito rispondono entro 2 giorni
-
Good First Issue hacktoberfest
Difficoltà 1/5 1-3 ore Idoneità per principianti 92/100
hiero-ledger/hiero-sdk-js#4508 ·
I maintainer di solito rispondono entro 1 giorno
-
dev-tools
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
iotaledger/iota-rust-sdk#1709 ·
I maintainer di solito rispondono entro 1 giorno