CPSetKeyParam

The CPSetKeyParam function allows applications to customize various aspects of the operations of a key.

BOOL CPSetKeyParam(
  HCRYPTPROV hProv,  // in
  HCRYPTKEY hKey,    // in
  DWORD dwParam,     // in
  BYTE *pbData,      // in
  DWORD dwFlags      // in
);
 

Parameters

hProv
Handle to a particular key container (or "context") within the CSP. This handle is obtained via a call to CPAcquireContext.
hKey
Handle to the key on which to set parameters.
dwParam
Parameter number. Currently, the following parameters have been defined:

These are described along with the CPGetKeyParam function.

Additional parameters can be added as needed. If these are general-purpose in nature, rather than applying to a single provider type, you should define these in coordination with Microsoft. This will promote cross-vendor standardization, and allow the new parameter numbers to be added to the standard Win32 header files.

pbData
Parameter data buffer. Upon entry to the function, this buffer will contain the data that corresponds to the dwParam parameter number. Notice that the length of this data is not specified explicitly, but instead is implied by the dwParam parameter number.
dwFlags
Flag values. No flags are currently defined.

Return Values

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_FLAGS The dwFlags parameter is non-zero or the pbData buffer contains an invalid value.
NTE_BAD_TYPE The dwParam parameter specifies an unknown parameter.
NTE_BAD_UID The CSP context that was specified when the hKey key was created cannot now be found.
NTE_FAIL The function failed in some unexpected manner.

See Also

CPGenKey, CPGetKeyParam, CryptSetKeyParam