I have to decrypt in java a string crypted in AES 256 from a c# class.
I know the init vector and the passphrase, both are 32 bytes string.
I made a try with this code:
byte [] iv = "1234567812345678".getBytes("UTF-8");
byte [] keyBytes = "1234567812345678".getBytes("UTF-8");
SecretKey aesKey = new SecretKeySpec(keyBytes, "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/NOPADDING");
cipher.init(Cipher.DECRYPT_MODE, aesKey, new IvParameterSpec(iv));
byte[] result = cipher.doFinal(cipherBytes);
But when i put iv and keyBytes of 32 bytes i get this error
Exception in thread "main" java.security.InvalidAlgorithmParameterException: Wrong IV length: must be 16 bytes long
at com.sun.crypto.provider.SunJCE_h.a(DashoA12275)
at com.sun.crypto.provider.AESCipher.engineInit(DashoA12275)
at javax.crypto.Cipher.a(DashoA12275)
at javax.crypto.Cipher.a(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
at javax.crypto.Cipher.init(DashoA12275)
Can anyone help me?
Thank you
Lorenzo