02-Jun-2009 11:06
With Java, you must get a Cypher:
Cipher decryptCipher = Cipher.getInstance("AES");
decryptCipher.init(Cipher.DECRYPT_MODE, getSecretKey());
byte[] deciphertext = decryptCipher.doFinal(encripted);
String decryptedString = new String(deciphertext);
But this code causes this error:
javax.crypto.IllegalBlockSizeException: 9 trailing bytes
at gnu.javax.crypto.jce.cipher.CipherAdapter.engineDoFinal(libgcj.so.90)
at javax.crypto.Cipher.doFinal(libgcj.so.90)
at javax.crypto.Cipher.doFinal(libgcj.so.90)
The problem is with PADDING, but I don't know exactly where does the problem is.
When I get the Cipher, I can choose with diferent options:
Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
Cipher decryptCipher = Cipher.getInstance("AES/CBC/PKCS7Padding");
Cipher decryptCipher = Cipher.getInstance("AES/CFB8/NoPadding");
...
Maybe the problem is I don't get the good Cipher.
Can anybody help me?
Thanks.
02-Jun-2009 17:06
05-Jan-2012 13:48
09-Jan-2012 10:13
Glad you found the new crypto commands! They're pretty powerful, and we're excited to have them available. What extra documentation would help you make use of the new commands? If there is something specific I can look into getting it added, depending on what it is.
Colin
05-Jun-2013 14:19
18-Aug-2014 04:53
Hi Spark,
We are having a similar issue between F5 and our Java application. Do you know if there is a way to make encryption and decryption work between systems?
Our developers are using AES-128-CBC with PKCS5 padding. However when decrypting the data with an iRule on F5 we are not capable of decrypting the data correctly.
Is there a way to know which type of PKCS, F5 is using please?
14-Dec-2022 12:47
Please Help its urgent!!!
Cheers, Bob