I'm encrypting strings via an oracle package that uses a java class loaded into the database.
Database jvm is 1.5. Oracle database version is 11.2.0.3.0. The operating system is Solaris.
The encryption algorithm is AES with CBC and PKCS5PADDING padding.
The provider is SunJCE.
This is the code:
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
final SecretKeySpec secretKey = new SecretKeySpec(key, "AES");
cipher.init(Cipher.ENCRYPT_MODE, secretKey, new IvParameterSpec(iv));
cipher.doFinal(strToEncrypt.getBytes());
The problem is that the encryption output cannot be decrypted using the same algorithm/key/iv etc.
The encryption output bytes seem to corrupted in the following manner:
correct result: x1,x2, ....xn, a,b,c,d
actual result: x1,x2, .... ,xn,c,b,0,d
where x1,..xn, a,b,c,d are bytes and 0 is the 0x00 byte.
Did anyone encountered this issue? I would appreciate any hint on how to isolate/troubleshoot it.