The CPSetHashParam function allows applications to customize various aspects of the operations of a hash object.
BOOL CPSetHashParam(
HCRYPTPROV hProv, // in
HCRYPTHASH hHash, // in
DWORD dwParam, // in
BYTE *pbData, // in
DWORD dwFlags // in
);
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_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. |
The dwParam parameter can be set to one of the following values:
Typically, the hash object specified by hHash will have just been created. If this isn't the case (that is, data has already been added to the hash object), an error may be returned.
This parameter was defined to give applications the ability to sign hash values, without having access to the base data. Because the application (much less the user) can have no idea what is being signed, this operation is intrinsically risky. It is envisioned that many CSPs will not support this parameter.
Additional parameters can be added as needed. If these are general-purpose in nature, rather than just 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.
CPCreateHash, CPGetHashParam, CPSignHash, CryptSetHashParam