nakov / Practical-Cryptography-for-Developers-Book

Practical Cryptography for Developers: Hashes, MAC, Key Derivation, DHKE, Symmetric and Asymmetric Ciphers, Public Key Cryptosystems, RSA, Elliptic Curves, ECC, secp256k1, ECDH, ECIES, Digital Signatures, ECDSA, EdDSA
https://cryptobook.nakov.com
MIT License
3.42k stars 409 forks source link

Wording: "aesIV" vs. "nonce" #57

Open daniel-kun opened 2 years ago

daniel-kun commented 2 years ago

Hello Svetlin!

First of all, thank you for your great work. I'm using it extensively on my current deep-dive journey into cryptography.

In the python examples for AES GCM encryption/decryption, in the print() of the encrypted message, you call the "nonce" an "IV", which are different things that have different attributes. So if I don't get it wrong, "aesIV" should be renamed to "aesNonce" in this code sample:

https://github.com/nakov/Practical-Cryptography-for-Developers-Book/blob/a05a5176a5db86885d6119832b73bea93aee45c5/symmetric-key-ciphers/aes-encrypt-decrypt-examples.md?plain=1#L153

From what I've learned so far, when talking about an IV it is important that it is random - and, at least in many scenarios, it should be used only once per key, too - while when talking about a nonce the randomness is not the important part, but it is important that it is never, ever re-used.

Source (for example): https://crypto.stackexchange.com/questions/16000/difference-between-a-nonce-and-iv

Greetings from Germany, and stay motivated and healthy! Daniel Albuschat