Exporting a Diffie-Hellman/Schannel Agreed (secret) Key
To export a Diffie-Hellman/Schannel agreed key
-
Get a handle to a D-H provider. Do this by calling CryptAcquireContext to get a pointer to the Microsoft DH Schannel Cryptographic Provider.
-
Get a handle to a D-H key. Do this 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.