Re: Encrypting using RSA private Key
- From: "Joe Kaplan" <joseph.e.kaplan@xxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Tue, 8 Apr 2008 15:43:25 -0500
No, that is a violation of how RSA is intended to be used, so Windows
prevents you doing that. You sign and decrypt with the private key, not
encrypt.
Joe K.
--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
"Jeronimo Bertran" <jeronimo.bertran@xxxxxxxxxxxxxxxx> wrote in message
news:Xns9A7A85A2318ACpublicjbbertrancom@xxxxxxxxxxxxxxxx
Hi,
Is it possible to encrypt using the RSA private key and decrypt using the
public key? I am able to do the opposite but when I try to decrypt using
the private key I get a "Bad Key" Exception. Here is an example:
rsa = new RSACryptoServiceProvider();
RSAParameters publicKey = rsa.ExportParameters(false);
RSAParameters privateKey = rsa.ExportParameters(true);
byte[] testPlainData = new byte[] { 0x01, 0x02, 0x03 };
rsa.ImportParameters(publicKey);
byte[] enc = rsa.Encrypt(testPlainData, false);
rsa.ImportParameters(privateKey);
byte[] plain = rsa.Decrypt(enc, false);
enc = rsa.Encrypt(testPlainData, false);
rsa.ImportParameters(publicKey);
rsa.Decrypt(enc, false);
The first encryption and decryption work fine. The second encryption
(using the private key) seems to work but the decryption using the public
key throws the exception.
Thanks,
Jeronimo
.
- Follow-Ups:
- Re: Encrypting using RSA private Key
- From: Jeronimo Bertran
- Re: Encrypting using RSA private Key
- References:
- Encrypting using RSA private Key
- From: Jeronimo Bertran
- Encrypting using RSA private Key
- Prev by Date: Encrypting using RSA private Key
- Next by Date: Re: Encrypting using RSA private Key
- Previous by thread: Encrypting using RSA private Key
- Next by thread: Re: Encrypting using RSA private Key
- Index(es):
Relevant Pages
|