This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

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:
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)

Any suggestions?

/Svend Rost
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic