I want to save an ECC Prvivate key in PKCS8 format but with explicit domain parameters instead of named curve parameters, which is what the code below does.
CNG seems to give me the option of KeyFormat to be either PKCS8 (Pkcs8PrivateBlob
) with named curve parameters or EccFullPrivateBlob
with explicit Domain Parameters. But then it's not in PKCS8 format.
var curve = ECCurve.CreateFromOid(new Oid("1.3.36.3.3.2.8.1.1.7")); //oid for brain
using (var dsa = new ECDsaCng())
{
dsa.GenerateKey(curve);
var privateKey = dsa.Key.Export(CngKeyBlobFormat.Pkcs8PrivateBlob);
//store privateKey as file...
}
Is there any way to have both explicit parameters and the pkcs8 format?