• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Exception while decrypting data org.bouncycastle.crypto.InvalidCipherTextException: pad block corrup

 
Mike Newmann
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am trying to use BouncyCastle LightWeight API for AES 256 bit decryption, but I am getting an exception while trying to decrypt the data.

Following is my code:-


----------------------------- My main class -----------------------------





----------------------------- AESEncDec.java -----------------------------







org.bouncycastle.crypto.InvalidCipherTextException: pad block corrupted
at org.bouncycastle.crypto.paddings.PKCS7Padding.padCount(PKCS7Padding.java:63)
at org.bouncycastle.crypto.paddings.PaddedBufferedBlockCipher.doFinal(PaddedBufferedBlockCipher.java:287)



Really need some help on this.. have been stuck with it for the whole day and have no idea what is it that's going wrong.
 
Richard Tookey
Bartender
Posts: 1166
17
Java Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are certain that correct padding is being used then based on experience I suspect the key you are using is not the one used to encrypt the data. A key mismatch still allows basic decryption but the resulting padding will be invalid.

Of course if one had a view of the code used to encrypt then one might be able to give a more definite diagnosis.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic