This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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 Murach's Java Servlets and JSP this week in the Servlets 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.
 
jQuery in Action, 2nd edition
 
subject: Bad Padding Exception - Encryption / Decryption Keys generated in different JREs
 
Similar Threads
"javax.crypto.BadPaddingException: pad block corrupted" using BouncyCastle and DESede: How to avoid?
BadPaddingException with DES
How set java path for a perticular apache server ?
The RMI API isn't finding my classes?
Elliptic Curve Cryptography