Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Decrypting with Cipher
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?


Report this thread to moderator Post Follow-up to this message
Old Post
gtornelas@utep.edu
04-08-05 08:59 AM


Re: Decrypting with Cipher
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/



<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?
>



Report this thread to moderator Post Follow-up to this message
Old Post
Karl Scheibelhofer
04-08-05 09:01 PM


Decrypting with Cipher
Hi 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.

Report this thread to moderator Post Follow-up to this message
Old Post
Ana
08-09-05 08:42 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Java Security archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:02 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.