I\'ve been looking around for hours on Google and Microsoft\'s Crypto API on how to generate a public and private ECC key pair. The ECDiffieHellmanCng
Class (ht
Elliptic Curve DiffieHellman is not an encryption algorithm, it is a key agreement protocol. Over an insecure channel, it gives you and the other party a common shared secret. This is frequently used for say an AES key to conduct secure communication.
Given another party's public key, you can get the derived shared secret key material with this api call. Note that as per the remarks section, the CNG APi does some post processing on the derived secret so it may or may not agree with what true-crypt generates.
To get the actual private key(which is not the shared secret), you can use use the following. You may want a different export format, they are listed here
using (ECDiffieHellmanCng alice = new ECDiffieHellmanCng())
{
// Any code you have specifies the key your using or generates one
var privatekey = alice.Key.Export(CngKeyBlobFormat.Pkcs8PrivateBlob)
}
Note you may wind up with an error saying that the export policy does not allow exporting the private key. In that case, you need to create and user a key with a policy that does allow export