Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Private Key import fails for CngKey with ECDSA

2,056 views
Skip to first unread message

Bob Gregory

unread,
Jan 6, 2011, 8:39:57 AM1/6/11
to
Using both .Net 3.5 and 4.0, I am able to generate a ECDSA key using
the following code.

var p = new CngKeyCreationParameters
{
ExportPolicy =
CngExportPolicies.AllowPlaintextExport
};
var cnk = CngKey.Create(CngAlgorithm.ECDsaP384, "key-name", p);


I am then able to open the key and use it for generating a signature.
If I export the private key,

cnk.Export(CngKeyBlobFormat.EccPrivateBlob);

I am able to persist the raw bytes to disk, but I am then unable to
reimport the key,

var bytes = File.ReadAllBytes("mykey.ecckey");
var k = CngKey.Import(bytes, CngKeyBlobFormat.EccPrivateBlob);

as I receive a CryptographicException with the message "The requested
operation is not supported".

I've seen a few people commenting on the same issue hither and thither
on the internets, but no solutions. Can anyone confirm that importing
private ECC keys is not supported? Public key import with the same
method works perfectly.

-- Bob Gregory

John Smith

unread,
Feb 3, 2011, 5:13:06 PM2/3/11
to
Probably your file is not valid i tried this (C#) and it works

byte[] priv = dsaSigner.Key.Export(CngKeyBlobFormat.EccPrivateBlob); //Export private key

//Next Seance
CngKey key2 = CngKey.Import(priv, CngKeyBlobFormat.EccPrivateBlob);
ECDsaCng dsaSigner2 = new ECDsaCng(key2);

> On Thursday, January 06, 2011 8:39 AM Bob Gregory wrote:

> Using both .Net 3.5 and 4.0, I am able to generate a ECDSA key using
> the following code.
>
> var p = new CngKeyCreationParameters
> {
> ExportPolicy =
> CngExportPolicies.AllowPlaintextExport
> };
> var cnk = CngKey.Create(CngAlgorithm.ECDsaP384, "key-name", p);
>
>
> I am then able to open the key and use it for generating a signature.
> If I export the private key,
>
> cnk.Export(CngKeyBlobFormat.EccPrivateBlob);
>
> I am able to persist the raw bytes to disk, but I am then unable to
> reimport the key,
>
> var bytes = File.ReadAllBytes("mykey.ecckey");
> var k = CngKey.Import(bytes, CngKeyBlobFormat.EccPrivateBlob);
>
> as I receive a CryptographicException with the message "The requested
> operation is not supported".
>

> I have seen a few people commenting on the same issue hither and thither


> on the internets, but no solutions. Can anyone confirm that importing
> private ECC keys is not supported? Public key import with the same
> method works perfectly.
>
> -- Bob Gregory


> Submitted via EggHeadCafe
> ASP.NET Drawing a chart using OWC11 - Office Web Components
> http://www.eggheadcafe.com/tutorials/aspnet/601e9bc2-40ed-405e-b1b0-f416046b6698/aspnet-drawing-a-chart-using-owc11--office-web-components.aspx

ft.ja...@gmail.com

unread,
Dec 14, 2014, 7:42:15 AM12/14/14
to
Hi
I have this problem too.
Can U help me?

0 new messages