[Mono-list] Question about RSACryptoServiceProvider...

Giuseppe Greco giuseppe.greco@agamura.com
Sat, 06 Sep 2003 08:05:29 +0200


Hi all,

I'm trying to understand how RSACryptoServiceProvider works.

If I've well understood, the following code generates the
public/private key pair:

RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();

Then, the following code retrieves the public key:

RSAParamters publicKey = rsa.ExportParameters(false);

and the following code retrieves the private key:

RSAParametes privateKey = rsa.ExportParamters(true);

Well, the question is: How does the Encrypt/Decrypt
method know which key to use?

In my specific case, sometime I need to Encrypt with
the private key and Decrypt with the public key, and
sometime I need to Encrypt with the public key and
Decrypt with the private key...

Could somebody explain me this point one time for ever?
I've give a look at the msdn documentation, but it is
a little bit unclear, since it doesn't explain this
issue.

Thanks a lot,
Gius_.

-- 
----------------------------------------
Giuseppe Greco

::agamura::

phone:  +41 (0)91 604 67 65
mobile: +41 (0)76 390 60 32
email:  giuseppe.greco@agamura.com
web:    www.agamura.com
----------------------------------------