The CPGetUserKey function retrieves a handle to one of the permanent key pairs in the hProv key container, such as the key exchange key pair.
BOOL CPGetUserKey(
HCRYPTPROV hProv, // in
DWORD dwKeySpec, // in
HCRYPTKEY *phUserKey // out
);
If the function succeeds, TRUE should be returned; otherwise, return FALSE. When FALSE is returned, the appropriate error code (see the following table) must be set via SetLastError.
Error | Description |
---|---|
NTE_BAD_KEY | The key specified by the hKey parameter is invalid. |
NTE_BAD_UID | The CSP context that was specified when the key was created cannot now be found. |
NTE_NO_KEY | The key specified by the dwKeySpec parameter does not exist. |
CPExportKey, CPGenKey, CryptGetUserKey