During my encryption app i've got the password creation bit:
PBEKeySpec spec = new PBEKeySpec(password.toCharArray(), salt, 10000, keyLength);
and later on the actual encryption part:
cipher.init(Cipher.ENCRYPT_MODE, secret, ivSpec);
The initialisation vector need random bytes, the salt needs random bytes, can I use the same (cryptographically secure) random bytes for the salt and the IV or would that weaken the encryption somehow? - It would make storage a little easier if I could.
I'm not talking about reusing the IV or the salt over multiple messages, for each separate message a new array of bytes would be generated, but could I for each individual message double up and use the same newly generated bytes for both the salt + the IV?
EG:
Message 1: Random bytes = h6ds .... Salt = h6ds / IV = h6ds
Message 2: Random bytes = djs9 .... Salt = djs9 / IV = djs9
Message 3: Random bytes = 9sdf .... Salt = 9sdf / IV = 9sdf
... and so on