Bouncycastle AES - output isn't the same as input!
posted 11 years ago
To quote Sir Elton Johns "Your Song", it's a little bit funny, this feeling inside.
Im using Bouncycastle's AES algorithm (AESFast to be exact), and my input string isn't the same as the string I get after encryption and decryption.
At times, it looks like the same though.
The difference between encryption and decryption can be seen in the the bold line ( cipher.init(encrypt, piv) ). If true we'll encrypt.
Tests: input: "svend svend" The strings arn't the same (accoring to string1.toString() == string2.toString()) but both strings contain the exact same chars!
input: "this is a secret text which has be to encrypted. It'll be encrypted with AES!" The string I get when I encrypted-> decrypt is: ����QK*��$�g�G���?z��9���S fbe t� encrypted. It'll be encrypted with AES!
And if I compare the chars you see a big difference in the two strings.
input: "123456789" This gives me the following exception: org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted at org.bouncycastle.crypto.paddings.PKCS7Padding.padCount(+26) at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(+190) at MyCryptoEngine.AESFastDecrypt(+91) at MyMIDlet.aes_test(+294) at MyMIDlet.run(+17)