

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Difficulty: 4
click for more info
Not enough gems
Cost: 6 gems
1: Feistel Network
incomplete
2: Feistel Network
incomplete
3: Data Encryption Standard
incomplete
4: DES Review
incomplete
5: Initialization Vectors
incomplete
6: DES Feistel Network
incomplete
7: Substitution Box
incomplete
8: Substitution Box
incomplete
Back
ctrl+,
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
As we briefly mentioned before, an iv, or initialization vector, is a random value that is used to initialize a block cipher. It is used to ensure that the same plaintext always encrypts to a different ciphertext.
If the iv doesn't need to be truly random, and the only requirement is that it's only used once, then it's often called a "nonce", which is just short for "a number used only once".
Whether the iv for an encryption algorithm needs to be cryptographically random, pseudorandom, or just unique will be specified in the documentation for that algorithm. It's important to read the documentation for the algorithm you're using to ensure that you're providing the correct level of security for your iv.
Update the generateIV function. It's currently returning unique values due to a global count variable, but it's not random, which is what Passly's cipher requires.
Use the math/rand package's rand.Read function to generate a random iv of the specified byte length.
In production, we would swap out the math/rand package for the crypto/rand package. The math/rand package is not cryptographically secure and should only be used for testing when we don't need to generate secure random values.