If you have a PEM encoded key, just use the PEMReader, e.g.:

>>>>>

    IPasswordFinder pwd = new Password ( password );
    PemReader prd = new PemReader ( trd, pwd );

    while ( ( o = prd.ReadObject () ) != null )
    {
        if ( o is AsymmetricKeyParameter )
        {
            if ( ( (AsymmetricKeyParameter) o ).IsPrivate )
            {
                if ( (AsymmetricKeyParameter) o is RsaKeyParameters )
                {
                    // store to as RsaPrivateCrtKeyParameters
                }
                else   // an EC key
                {
                    // store as ECPrivateKeyParameters
                }
            }
        }
    }

<<<<<


If it's already a binary file, create the AsymmetricKeyParameter from your key:

>>>>>

AsymmetricKeyParameter privkey = PrivateKeyFactory.CreateKey ( binaryKeyBytes );

<<<<<

This works with RSA and EC keys.

Regards,
Torsten





Am 13.01.2013 23:04, schrieb Ignacio Ocampo:
Torsten,

How I can load my privateKey?

Regards.

On Sun, Jan 13, 2013 at 3:14 PM, Moschny, Torsten <[email protected]
<mailto:[email protected]>> wrote:

         // get your private key
         AsymmetricKeyParameter privateKey = .. // add your private key here


--
Ignacio Ocampo Millán


Reply via email to