OMEMO: generate IV more flexible

This commit is contained in:
Paul Schaub 2019-05-03 03:31:03 +02:00
parent c6c904cc3e
commit 8a74aec32a
1 changed files with 6 additions and 1 deletions

View File

@ -277,8 +277,13 @@ public class OmemoMessageBuilder<T_IdKeyPair, T_IdKey, T_PreKey, T_SigPreKey, T_
* @return iv
*/
public static byte[] generateIv() {
// TODO: Switch to 12 once ChatSecure supports decrypting msgs with 12 byte IV.
return generateIv(16);
}
public static byte[] generateIv(int len) {
SecureRandom random = new SecureRandom();
byte[] iv = new byte[16];
byte[] iv = new byte[len];
random.nextBytes(iv);
return iv;
}