Home All Groups Group Topic Archive Search About

How to decipher data in .NET using "RSA/ECB/PKCS1Padding"?

Author
22 Apr 2009 9:24 AM
Ajay Jadhav
Hi,

I am receiving RSA encrypted data with the digital signature. The data and
signature is encrypted in Java using RSA Public key encryption. I have to
verify the signature in C#.NET and decrypt the data and process. I am able
to verify the signature using sender's Public key. But I am facing problems
in decrypting data using my Private Key. I am not not able to an equivalent
C# API which deciphers the data using "RSA/ECB/PKCS1Padding" transformation.

I am able to do it in Java using following code. Does anybody know, What
will be the equivallent .NET code for follwing Java Code?.

Java Code:
========
byte[] dataBytes = new BASE64Decoder().decodeBuffer(decodedToken);
RSAPrivateKey privateKey = getPrivateKey(keystoreFile, aliasName, password,
keyPassword);
Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
cipher.init(Cipher.DECRYPT_MODE, privateKey);
String plaintext = new String(cipher.doFinal(dataBytes));

Any help would really be appreciated.

Thanks in advance.
-----
Ajay Jadhav
http://www.divinet.co.in

Author
22 Apr 2009 2:06 PM
Mitch Gallant
It's been a while since I have been involved with crypto and .NET but have a
look at the info here:
  http://www.jensign.com/JavaScience/dotnet/RSAEncrypt/
- Mitch

Show quoteHide quote
"Ajay Jadhav" <a***@itcube.net> wrote in message
news:9D5FA9F2-2EF1-48ED-835E-EC1261440246@microsoft.com...
> Hi,
>
> I am receiving RSA encrypted data with the digital signature. The data and
> signature is encrypted in Java using RSA Public key encryption. I have to
> verify the signature in C#.NET and decrypt the data and process. I am able
> to verify the signature using sender's Public key. But I am facing
> problems in decrypting data using my Private Key. I am not not able to an
> equivalent C# API which deciphers the data using "RSA/ECB/PKCS1Padding"
> transformation.
>
> I am able to do it in Java using following code. Does anybody know, What
> will be the equivallent .NET code for follwing Java Code?.
>
> Java Code:
> ========
> byte[] dataBytes = new BASE64Decoder().decodeBuffer(decodedToken);
> RSAPrivateKey privateKey = getPrivateKey(keystoreFile, aliasName,
> password, keyPassword);
> Cipher cipher = Cipher.getInstance("RSA/ECB/PKCS1Padding");
> cipher.init(Cipher.DECRYPT_MODE, privateKey);
> String plaintext = new String(cipher.doFinal(dataBytes));
>
> Any help would really be appreciated.
>
> Thanks in advance.
> -----
> Ajay Jadhav
> http://www.divinet.co.in