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
Post by Ignacio OcampoTorsten,
How I can load my privateKey?
Regards.
// get your private key
AsymmetricKeyParameter privateKey = .. // add your private key here
--
Ignacio Ocampo Millán