• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

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
 
reply
    Bookmark Topic Watch Topic
  • New Topic