Access violation if GCM mode is set after cipher is initialized
@MHumm ci sta già lavorando.
Dal 8/5/2024.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
To Reproduce
- Open demo project Cipher_Console
- Change Cipher.Mode to cmGCM
- Run the code. You receive EAccessViolation
Usually, if you change the cipher mode after the cipher has been initialized, then TDECCipher.SetMode should call Done on the cipher and re-initialize it.
GCM Encode requires that TGCM.Init is called and has set FEncryptionMethod := EncryptionMethod. However, if Ciper.Mode is set after the cipher has been initialized, then TGCM is created but TGCM.Init has not been called.
procedure TDECCipherModes.InitMode;
begin
if FMode = TCipherMode.cmGCM then
begin
if Context.BlockSize = 16 then
FGCM := TGCM.Create
else
// GCM requires a cipher with 128 bit block size
raise EDECCipherException.CreateResFmt(@sInvalidBlockSize,
[128, GetEnumName(TypeInfo(TCipherMode),
Integer(FMode))]);
end
else
if Assigned(FGCM) then
FreeAndNil(FGCM);
end;
The program flow if Mode has been set before init:
- TDECCipher.Init()
- TDECCipher.Init()
- TDECCipherModes.OnAfterInitVectorInitialized ( calls
FGCM.Init(self.DoEncode, OriginalInitVector)) - TGCM.Init
The program flow if Mode has been set after init:
- TDECCipher.SetMode
- TDECCipherModes.InitMode
- TGCM.Create, but not TGCM.Init ( I am not sure where I get
OriginalInitVectorfrom )
So... what do we do? We probably need to preserve the InitVector, so we can call TGCM.Init with the correct parameters.
The other solution is to forbid to change the mode after the cipher has been initialized. But this is a code breaking change.
- 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
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
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 160 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 ·