Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Problems in C# and Java SSL Asymmetric encryption

843811Dec 31 2009 — edited Jan 4 2010
Hi,
I have a C# SSL server(SSPI) and Java JSSE based client. Both of them are able to complete their handshaking successfully. I am encrypting data in java using following code,

Cipher cipher = Cipher.getInstance("RSA/NONE/PKCS1PADDING");
cipher.init(Cipher.ENCRYPT_MODE, servercert.getPublicKey());
cipher.doFinal(inpBytes);

In C# using this code I am trying to decrypt,

RSACryptoServiceProvider rsa = pfxcert2.PrivateKey as RSACryptoServiceProvider;
byte[] decryptedBytes = rsa.Decrypt(inpBytes, true);

I am getting this error while decryption "The data to be decrypted exceeds the maximum for this modulus of 128 bytes."

I know this is java forum, but I want to make this to work between Java and C# only. I have no other choice.

If anyone has suggestion about this issue, please reply.

I searched a lot on internet about this issue, but haven't found any solution.

Thanks in advance
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 1 2010
Added on Dec 31 2009
5 comments
531 views