0
$\begingroup$

I'm developing a program to encrypt and decrypt a file with AES-256/CBC in Java. And I want it to be safe enough. In my case, I generated random AES key for each file to encrypt and decrypt them.

My question is if it is necessary to generate a random IV for encrypt/decrypt or it is already secure enough with a random AES key and fixed IV.

$\endgroup$
2
$\begingroup$

You can use a null IV for all files ONLY if each file will be encrypted with a unique key. If you want to reuse the key, it's safer use a random IV for each file.

The issue is reusing the IV with the same key, when you do that, you reveal which files have the same first bytes. When you use a different key for each file, you don't have this problem.

$\endgroup$
-1
$\begingroup$

No, you can't use a fixed IV, the IV needs to be unpredicatable. There are two good answers why this is the case here.

$\endgroup$
  • 2
    $\begingroup$ The question states that the key is random for each invocation of the encryption function. Can you explain why this doesn't mitigate the attacks explained on the linked page? $\endgroup$ – Ella Rose Feb 13 at 16:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.