aspose file tools*
The moose likes Security and the fly likes Bad Padding Exception - Encryption / Decryption Keys generated in different JREs Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Engineering » Security
Bookmark "Bad Padding Exception - Encryption / Decryption Keys generated in different JREs" Watch "Bad Padding Exception - Encryption / Decryption Keys generated in different JREs" New topic
Author

Bad Padding Exception - Encryption / Decryption Keys generated in different JREs

Anish Pyne
Greenhorn

Joined: Aug 23, 2010
Posts: 15
I have a "DH" algorithm based encryption/decryption logic where, the encryption happens on client machine through an applet and the decryption happens on server component. The cryptography components that finally interact with Java Security APIs are modularized as "common" components and deployed as part of both the applet code and server side code.

Issue -

Scenario 1 - The applet and the server components (including the cryptography code common to both) compiled on Java 1.6, server component running on Java 1.6, applet running on JRE 1.6 - Encryption/decryption works fine.

Scenario 2 - The applet and the server components (including the cryptography code common to both) compiled on Java 1.5, server component running on Java 1.5, applet running on JRE 1.6 - Encryption no error, decryption throws a "bad padding exception".

In both scenarios its same code, same setup only differences in Java run time as stated. Is the padding implementation different across Java 1.5 vs Java 1.6? Current padding option set is "PKCS5"

I am planning to test by setting "NoPadding" and seeing if that makes a difference. Would appreciate inputs from anyone who might have faced similar issue before.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Bad Padding Exception - Encryption / Decryption Keys generated in different JREs
 
Similar Threads
The RMI API isn't finding my classes?
BadPaddingException with DES
"javax.crypto.BadPaddingException: pad block corrupted" using BouncyCastle and DESede: How to avoid?
Elliptic Curve Cryptography
How set java path for a perticular apache server ?