It is said that cipher IV does not have to be secret and the only secret component of the encryption scheme should be a cipher key.
Question: is it safe to generate IV using PBKDF2 function, which takes password and randomly generated salt as input (Scheme 2)? Or do I have to use only completely random IV which has no relationship to password whatsoever (Scheme 1)? In other words, is Scheme 2 less secure, equally secure or more secure than Scheme 1?
NOTE: To generate entropy based on password/salt I use a hybrid PBKDF2/HKDF approach described here, where PBKDF2 generates PRK which has the same length as used hash function (SHA-2) and then expands PRK to obtain sufficient entropy to populate KEY (Scheme 1) or IV + KEY (Scheme 2).
Example of Encryption Scheme 1 - traditional approach:
- Input data: Password and Message (e.g. plaintext to encrypt).
- Generate completely random SALT (using system entropy provider).
- Generate completely random IV (using system entropy provider).
- Use Password and SALT as input for PBKDF2/HKDF function, which generates and expands entropy based on input data.
- Use obtained entropy to set cipher KEY, use IV that was generated in step 3.
- Encrypt Message, send SALT + IV + cipher text to the receiver.
Example of Encryption Scheme 2 - generating IV with PBKDF2:
- Input data: Password and Message (e.g. plaintext to encrypt)
- Generate completely random SALT (using system entropy provider).
- Use Password and SALT as input for PBKDF2/HKDF function, which generates and expands entropy based on input data.
- Use obtained entropy to set cipher IV and KEY.
- Encrypt Message, send SALT + cipher text to the receiver.
For decrypting, we use received SALT (and possibly, IV - if Scheme 2 is used), setup cipher according to the used scheme and decrypt message.
So, is Scheme 2 less secure, equally secure or more secure than Scheme 1? In my opinion, it should not be less secure, since for every message SALT, IV and KEY are going to be completely different. Besides, IV is unpredictable, since to generate it, we use SALT - which is unpredictable, since it is considered to be completely random. It is probably more secure, since in Scheme 1, SALT and IV are known to an attacker, and in Scheme 2 an attacker knows only SALT. Even if it is said that IV does not have to be secret, is it not better to try to reveal to an attacker as little information as possible?
Can Scheme 2 help an attacker to determine password more easily than in Scheme 1?