Platform SDK: Cryptography

CPSetHashParam

The CPSetHashParam function customizes the operations of a hash object.

BOOL CPSetHashParam(
  HCRYPTPROV hProv,     // in
  HCRYPTHASH hHash,     // in
  DWORD dwParam,        // in
  BYTE *pbData,         // in
  DWORD dwFlags         // in
);

Parameters

hProv
Handle to a particular key container within the CSP. This handle is obtained by a call to CPAcquireContext.
hHash
Handle to the hash object on which to set parameters.
dwParam
The following defined dwParam parameter value can be set:
HP_HASHVAL
The pbData buffer contains a BYTE array to be added to the hash object. This data must be of the same size and format as the hash value returned by the CPGetHashParam function. This data is placed directly into the hash object.

Typically, the hash object specified by hHash will be empty. If this is not the case, an error can be returned.

This parameter gives applications the ability to sign hash values, without having access to the base data. Because the application and the user have no idea what is being signed, this operation is intrinsically risky. It is envisioned that most CSPs will not support this parameter.

Parameters can be added as needed. General-purpose parameters can be define in coordination with Microsoft to 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 explicitly specified but is implied by the dwParam parameter value.
dwFlags
No flags are currently defined.

Return Values

If the function succeeds, the return value is TRUE.

If the function fails, the return value is FALSE, and the appropriate error code from the following table must be set using SetLastError.

Error Description
NTE_BAD_FLAGS The dwFlags parameter is non-zero or the pbData buffer contains an invalid value.
NTE_BAD_HASH The hash object specified by the hHash parameter is invalid.
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 way.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 OSR2 or later (or Windows 95 with Internet Explorer 3.02 or later).
  Header: Declared in Wincrypt.h.

See Also

CPCreateHash, CPGetHashParam, CPSignHash, CryptSetHashParam