Group: Cryptography Reference - Library: advapi32
Generates a random cryptographic session key or a public/private key pair. A handle to the key or key pair is returned in phKey. This handle can then be used as needed with any CryptoAPI function that requires a key handle.
CryptoAPI: Collection of Providers class
Generating random cryptographic keys
BOOL WINAPI CryptGenKey(
HCRYPTPROV hProv,
ALG_ID Algid,
DWORD dwFlags,
HCRYPTKEY* phKey
);
DECLARE INTEGER CryptGenKey IN advapi32;
INTEGER hProv,;
INTEGER Algid,;
INTEGER dwFlags,;
INTEGER @ phKey
hProv [in] Handle to a cryptographic service provider (CSP) created by a call to CryptAcquireContext.
Algid [in] A ALG_ID structure that identifies the algorithm for which the key is to be generated.
dwFlags [in] Specifies the type of key generated.
phKey [out] Address to which the function copies the handle of the newly generated key.
If the function succeeds, the return value is nonzero (TRUE).
When you have finished using the key, delete the handle to the key by calling the CryptDestroyKey function.