Exporting a Diffie-Hellman Private (secret) Key
The steps necessary are shown in the following procedure.
To export a D-H private key
-
Get a handle to a D-H provider.
-
Get a handle to a D-H key. This can be done by calling CryptGenKey (see Generating Diffie-Hellman Keys) to create a new key, or by calling CryptGetUserKey to retrieve an existing one.
-
Create a D-H public-key blob by calling CryptExportKey, passing PRIVATEKEYBLOB in the dwBlobType parameter and the handle to the D-H key in the hKey parameter.
-
When finished with the key, call CryptDestroyKey to destroy the handle (HCRYPTKEY) to the key.