I'm making private/public key using ecdh
var ecdh = new ECDiffieHellmanCng(CngKey.Create(CngAlgorithm.ECDiffieHellmanP256, null, new CngKeyCreationParameters { ExportPolicy = CngExportPolicies.AllowPlaintextExport }));
var privateKey = ecdh.Key.Export(CngKeyBlobFormat.EccPrivateBlob);
var publickey = ecdh.Key.Export(CngKeyBlobFormat.EccPublicBlob);
This code works fine, but I want to use Algorithm prime256v1
and CngAlgorithm
has no such option.
How can I do that ?
According to the docs, CngAlgorithm.ECDiffieHellmanP256 specifies the P-256 curve :
This answer in crypto.stackexchange.com explains what those names come from different sources and that P-256 in NIST notation corresponds to
prime256v1
in "ANSI X9.62 : Public Key Cryptography For The Financial Services Industry".