aspose file tools*
The moose likes Java Micro Edition and the fly likes Bouncycastle AES - output isn't the same as input! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Bouncycastle AES - output isn Watch "Bouncycastle AES - output isn New topic
Author

Bouncycastle AES - output isn't the same as input!

Svend Rost
Ranch Hand

Joined: Oct 23, 2002
Posts: 904
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)



Any suggestions?

/Svend Rost
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bouncycastle AES - output isn't the same as input!