MHumm / DelphiEncryptionCompendium

Cryptographic library for Embarcadero Delphi and potentially for FPC as well
Apache License 2.0
249 stars 65 forks source link

Change IV #75

Open EdAdvokat opened 2 months ago

EdAdvokat commented 2 months ago

The literature describes that the initial vector (IV) should not be constant. I have therefore changed the code so that the IV is also changed each time the key is changed. I realized this with the help of a hash of the key in truncated length (12). Then I set OnChange and OnTyping of the editKey. I hope that I have communicated this correctly.

procedure TFormMain.EditInitVectorChange(Sender: TObject); var InitV : string; //vom Key wird ein Hash genutzt, um den InitVector zu bestimmen (OnChange und OnTyping von editKey setzen) begin InitV := THashSHA2.GetHashString(EditKey.Text, THashSHA2.TSHA2Version.SHA224).ToLower; EditInitVector.text:=Copy (InitV,0,12); end;

MHumm commented 2 months ago

I'm not 100% sure yet what you want me to tell with this. Yes, IV shoudl always be anew one, that's something the samples don't really describe/convey yet. But what do you want me to tell with the code above? Is this a proposed modification of one of the samples?

EdAdvokat commented 2 months ago

I thought that every time the key input is changed, the IV also changes automatically. the IV also changes automatically. This was meant as a suggestion for Cipher_FMX. Yes, you can also assume that the demo has no entry for the key and the IV and therefore the user has to enter the key and IV himself. However, if he then continues to work and only redefines the key, the IV always remains the same and that should not be the case. That was the idea behind my proposed change.