Code Comments
Programming Forum and web based access to our favorite programming groups.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?
Post Follow-up to this messagetry
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/
<gtornelas@utep.edu> wrote in message
news:1112934343.746065.8600@z14g2000cwz.googlegroups.com...
> 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?
>
Post Follow-up to this messageHi all,
I also have the same problem.
Error as follows:
Exception in thread "main" javax.crypto.BadPaddingException: Data must sta
rt with zero
I tried using
Cipher.getInstance("RSA/ECB/PKCS1Padding");.
But it is showing the same error.
Thanks in advance for any suggestions.
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.