The Diffie-Hellman algorithm makes it possible for two or more hosts to create and share an identical, secret encryption key, by simply sharing information over an insecure network. The information shared over the network is in the form of a couple of constant values and a D-H public key. The process used by two key-exchange participants is as follows:
If a call to CryptGetKeyParam is made on the key handle returned from the call to CryptImportKey and prior to calling CryptSetKeyParam (as described in this step), the ALG_ID returned by the call to CryptGetKeyParam will be CALG_AGREEDKEY_ANY. If all the preceding function calls were successful, the agreed key is now ready to be used for encryption or decryption.
The SSL 3.0 or TLS 1.0 key length is 48 bytes. To obtain the required length, take the 384 Least Significant Bits of the returned HCRYPTKEY for this agreed key.