Hi
I have a client that encrypts a message and sends it to the server. I
can encrypt fine:
byte[] dataToSend = new byte[somelength];
/*fill dataToSend with some data*/
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.ENCRYPT_MODE, serverPubKey); byte[]
ciphertext = cipher.doFinal(dataToSend);
However, when I try to decrypt on the server side with:
Cipher cipher = Cipher.getInstance("RSA");
cipher.init(Cipher.DECRYPT_MODE, serverPrivateKey);
byte[] dataReceived = cipher.doFinal(data);
The output alternates (most of the time is 1 but some times is 2)
between follong errors:
1. javax.crypto.BadPaddingException: Data must start with
zero
2. javax.crypto.BadPaddingException: Message is larger than
modulus.
Does anyone have any idea how I can fix this?
Karl Scheibelhofer - 08 Apr 2005 16:00 GMT
try
Cipher.getInstance("RSA/ECB/PKCS1Padding");
on both sides.
Karl
--
Karl Scheibelhofer, IAIK - Graz University of Technology
Inffeldgasse 16a, 8010 Graz, Austria
Fax: +43 316 873 5520
http://jce.iaik.tugraz.at/
> Hi
>
[quoted text clipped - 23 lines]
>
> Does anyone have any idea how I can fix this?