Re: Suggested additional constructor for RSACryptoServiceProvider

From: Steven Grayson [MSFT] (sgrayson_at_online.microsoft.com)
Date: 06/12/03


Date: Thu, 12 Jun 2003 08:55:01 -0700


Since we're on the subject of the RSACryptoServiceProvider class, I thought
I would include here information that will be in the next release regarding
this class. Some folks stated they didn't know some of this information.

- default RSACryptoServiceProvider rsa = RSACryptoServiceProvider()
constructor
generates new RSA public/private transient key-pairs each time invoked.

- if rsa.PersistKeyInCsp = true is used, a random key container name,
prepended
with "CLR" is persisted

- overloaded RSACryptoServiceProvider rsa =
RSACryptoServiceProvider(CspParameters cp)
creates (or reuses an existing) a persistent key container with the name
specified
in cp.KeyContainerName

- for this overloaded constructor, if the only CspParameters field specified
is
KeyContainerName, the RSA key-pair generated (or re-used) is the key pair of
type AT_KEYEXCHANGE. CryptoAPI key containers using the MS CSPs can contain
two types of key-pairs (key spec): AT_KEYEXCHANGE and AT_SIGNATURE which the
WinCrypt.h header file defines as 1 and 2 respectively.

- although not clearly documented, it appears that the key type is specified
as
CspParameters.KeyNumber
with KeyNumber= 1 (AT_KEYEXCHANGE) and KeyNumber=2 (AT_SIGNATURE)
and with AT_EXCHANGE being the default.

- if a RSACryptoServiceProvider is instantiated twice, once with KeyNumber=1
and then
2, supplying the same cp.KeyContainerName, then the same CryptoAPI
keycontainer
will be populated with 2 sets of keys in the same named key container. (This
is
similar to the PSDK sample code for generating a key container with both
Signature
and Exchange key pairs).

-- 
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"Pieter Philippaerts" <pieter@nospam.mentalis.org> wrote in message
news:u5mzBDBMDHA.3144@tk2msftngp13.phx.gbl...
> "Michel Gallant" <neutron@istar.ca> wrote in message
> > Currently with 1.0/1.1 .NET Framework classes,  RSACryptoServiceProvider
> > constructors support initializing with existing RSA credentials using
the
> CspParameters
> > argument.
> > I think it would be very useful to have a constructor supporting an
> > exported  public-key file argument. This would be very handy, for
example,
> > in using signature verification where end-users currently need to
populate
> > CspParameters explicitly with modulus and exponent properties.
>
> While we're at the subject of RSACryptoServiceProvider improvements, why
not
> implement the EncryptValue and DecryptValue methods? I'm still wondering
why
> MS didn't implement those in the first place...
>
> Regards,
> Pieter Philippaerts
>
>


Relevant Pages

  • RE: Using the Public Key embedded in the Assembly?
    ... ImportCspBlob method on RSACryptoServiceProvider, ... CspParameters object that specifies the key container name you installed ... Using the Public Key embedded in the Assembly? ... The license file is unique to each ...
    (microsoft.public.dotnet.security)
  • Re: Private key different; Public key same on Different Machines
    ... Then you install that, using sn -i into CryptoAPI keycontainer ... Solution is to specify the key type for RSA constructor like: ... > KeyPair.snk" some time back and installed into a machine key container on ... > each of these machines) and the public key is the same for each machine from ...
    (microsoft.public.dotnet.security)
  • private Key aus P12 Datei
    ... public string Sign(string TextToSign, string PrivateKey) ... RSACryptoServiceProvider rsaCryptoServiceProvider = new ... RSA RSA = RSA.Create; ... ASCIIEncoding Encoding = new ASCIIEncoding; ...
    (microsoft.public.de.german.entwickler.dotnet.csharp)
  • RE: Implementing RSACryptoServiceProvider *and* JavaScript
    ... One of the things I discovered is the 'standard' RSA algorithms, ... I've more-or-less come to the conclusion that the RSACryptoServiceProvider ... >> passwords and other sensitive information is passed from the client back to ... >> a JavaScript RSA implementation that works with the RSACryptoServiceProvider. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • 2.0 breaking change. Cant figure it out.
    ... If you create a new RSA, ... private const int magic_size = 4; ... RSACryptoServiceProvider rsa = GetRSAFromSnkBytes; ... RSAParameters ret = new RSAParameters; ...
    (microsoft.public.dotnet.languages.csharp)