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]

> 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!
> 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.
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