BadPaddingException: Data must start with zero exception in clustered env.

Hi All,

While decrypting the password with the private key I am getting the javax.crypto.BadPaddingException: Data must start with zero

in the clustered environment in the weblogic.

I am not getting the above error in non clustered environment.

I am using the algorithm as "RSA".

Following is the code:

Cipher cipher = Cipher.getInstance(algo);

cipher.init(Cipher.DECRYPT_MODE, privateKey);

cipher.doFinal(cryptData);

Any help in solving the error will be appriciated.

Thanks in advance.

Thanks,

Deepesh

[586 byte] By [deep12a] at [2007-10-3 11:44:04]
# 1
A shot in the dark - I bet that at some point you are converting the bytes that constitute the encrypted data into a String using something likeString encryptedDataAsString = new String(encryptedDataAsBytes);
sabre150a at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...
# 2
Thanks for the reply.It is working in non clustered environment I getting the error in clustered environment.
deep12a at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...
# 3

> Thanks for the reply.

No problem.

> It is working in non clustered environment I getting

> the error in clustered environment.

But that may only be highlighting the problem, not the cause of the problem. You have not indicated whether or my shot in the dark hit the target!

sabre150a at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...
# 4
We are not converting the bytes that constitute the encrypted data into a Strings.I have checked at my end.Any clue to solve the problem.....
deep12a at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...
# 5

> We are not converting the bytes that constitute the

> encrypted data into a Strings.I have checked at my

> end.

:-( So my shot missed the target.

>

> Any clue to solve the problem.....

Sorry, not really! Could be any number of things. You could make sure that the servers have the 'unlimited jurisdiction policy files' installed but this is low probability.

sabre150a at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...
# 6

Every thread I've seen discussing this has eventually lead to things like "Oh, I was using the wrong key" or "Oh, the modulus was specified incorrectly" or "Oh, data was a hex-string that needed to be -converted- to a byte[]".

An example thread:

http://forum.java.sun.com/thread.jspa?threadID=763631&start=0

I suspect the "Data must start with zero" is misleading and can be ignored. (Misleading exception messages in Java? Surely not!) "BadPaddingException" is the algorithm telling you that Something Went Wrong - wrong key, corrupted ciphertext, and mismatched padding or mode on the two sides are your most likely culprits. But without knowing exactly what you're doing on both ends, it's impossible for us to tell.

Regarding "only happens in a clustered environment" - that screams "race condition" to me. How do your nodes share data? Could someone be modifying a key between the time you decide to use it, and the time you actually get the key bytes?

Good luck,

Grant

ggaineya at 2007-7-15 14:16:07 > top of Java-index,Security,Cryptography...