Re: PKI Question

From: Michel Gallant (neutron_at_nspxistar.ca)
Date: 09/29/03


Date: Mon, 29 Sep 2003 10:54:19 -0400


I think PEM public keys are simply b64 encoded binary DER standard
asn.1 encoded public keys (possibly with --- Begin Certificate ---- lines?)

PEM format for private keys varies a bit. See this site for some interesting
pointers:
  http://www.drh-consultancy.demon.co.uk/

To instantiate an RSACryptoServiceProvider from a PEM public key,
you can use convenience classes in WSE, or manually decode the
asn.1 public key data into a CryptoAPI PUBLICKEYBLOB, and then
extract the modulus and exponent from this and initialize like so:

      RSAParameters RSAKeyInfo = new RSAParameters();
      RSAKeyInfo.Modulus = modulus;
      RSAKeyInfo.Exponent = exponent;
      RSACryptoServiceProvider oRSA = new RSACryptoServiceProvider();
      oRSA.ImportParameters(RSAKeyInfo);

A forthcoming article at MSDN Security Centre:
  http://msdn.microsoft.com/security/
will discuss this in great detail (showing how to get this from certificate files, or any CryptoAPI
cert store).

Whidbey will have vastly improved support for X509 certificates and the current .NET Crypto classes.

Cheers,
 - Michel Gallant
   MVP Security

"mm" <mehulbv@hotmail.com> wrote in message news:ei4RpiihDHA.2296@TK2MSFTNGP09.phx.gbl...
> Hello Everyone,
>
> I am working on an application which needs to verify digitally signed MD5
> Hashes sent to us over HTTPS. Our clients application is written in Java and
> we are
> developing our side of the application in C#. They have supplied me with
> their public key in PEM format. I have two questions...
>
> 1. How do I generate a public and private key pair in PEM Format so I can
> provide my client with our public key. The only way I know is to use Open
> SSL to do this, can this be done through vs.net. I used the
> RSACryptoServiceProvider to generate the key pair and then dumped the keys
> into a text file using the ToXmlString() Method. but this gives me the
> Modules, Exponent, D, P,Q, ect. values in the file. How can I convert these
> into a PEM Format?
>
> 2. How do I import the public key supplied to us in PEM format into an
> instance of RSACryptoServiceProvider so I can use the
> RSAPKCS1SignatureFormatter class to verify the message (MD5 Hash)
>
> Thanks in advance for all your help
>
> -Zubin
>
>



Relevant Pages

  • PKI Question
    ... I am working on an application which needs to verify digitally signed MD5 ... Our clients application is written in Java and ... How do I generate a public and private key pair in PEM Format so I can ... provide my client with our public key. ...
    (microsoft.public.dotnet.security)
  • Re: PKI Question
    ... Here is an MSDN article on generating key pairs: ... I'm not sure these are in PEM format, ... How do I generate a public and private key pair in PEM Format so I can ... > provide my client with our public key. ...
    (microsoft.public.dotnet.security)
  • Re: RSA in python
    ... I tried the ezPyCrypto which is basically a higher level wrapper to pyCrypto ... but it fails to import public key in PEM format. ...
    (comp.lang.python)
  • Re: Using CryptoAPI to do a DH key exchange with OpenSSL
    ... a struct for the OpenSSL DH key blob format? ... But so far, CryptoAPI has gotten ... start to figure out what's the data difference between CAPI and OpenSSL ... the DH public key format in CAPI. ...
    (microsoft.public.platformsdk.security)
  • Re: Using CryptoAPI to do a DH key exchange with OpenSSL
    ... But so far, CryptoAPI has gotten ... start to figure out what's the data difference between CAPI and OpenSSL ... to cryptoapi obviously doesn't include the blob header info. So I ... the DH public key format in CAPI. ...
    (microsoft.public.platformsdk.security)