CryptSetHashParam

The CryptSetHashParam function, in theory, customizes the operations of a hash object. Currently, only a single parameter is defined for this function.

#include <wincrypt.h>
BOOL WINAPI CryptSetHashParam(
  HCRYPTHASH hHash,  // in
  DWORD dwParam,     // in
  BYTE *pbData,      // in
  DWORD dwFlags      // in
);
 

Parameters

hHash
Handle to the hash object on which to set parameters.
dwParam
Parameter number. See the "Remarks" section for a list of valid parameters.
pbData
Parameter data buffer. Place the parameter data in this buffer before calling CryptSetHashParam. The form of this data will vary, depending on the parameter number.
dwFlags
Flag values. This parameter is reserved for future use and should always be zero.

Return Values

If the function succeeds, the return value is TRUE. If it fails, the return value is FALSE. To retrieve extended error information, use the GetLastError function.

The following table lists the error codes most commonly returned by the GetLastError function. The error codes prefaced by "NTE" are generated by the particular CSP you are using.

Error code Description
ERROR_INVALID_HANDLE One of the parameters specifies an invalid handle.
ERROR_BUSY The CSP context is currently being used by another process.
ERROR_INVALID_PARAMETER One of the parameters contains an invalid value. This is most often an illegal pointer.
NTE_BAD_FLAGS The dwFlags parameter is nonzero 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 be found.
NTE_FAIL The function failed in some unexpected way.

Remarks

The dwParam parameter can be set to one of the following values:

Note  Some CSP types may add additional parameters that can be set with this function.

Example

// EXAMPLE CODE FOR USING CryptSetHashParam
// Set up the variables.
HCRYPTHASH     hHash;      // A handle to the hash object on which to set
                        // parameters
DWORD       dwParam;    // dwParam- paramater # can be HP_HMAC_INFO-
                        // initialized elsewhere
BYTE        pbData[16]; // The parameter data buffer
DWORD       dwFlags = 0;// set to zero
BOOL        Return;
Return = CryptSetHashParam(hHash, dwParam, pbData, dwFlags);
if (Return) {
 cout<< "function succeeds"<< endl;
}
else {
 cout<< "retrieve error"<< endl;
}
 

QuickInfo

  Windows NT: Requires version 4.0 or later.
  Windows: Requires Windows 95 OSR2 or later (or Windows 95 with IE 3.02 or later).
  Windows CE: Unsupported.
  Header: Declared in wincrypt.h.
  Import Library: Use advapi32.lib.

See Also

CryptCreateHash, CryptDestroyHash, CryptGetHashParam, CryptSetKeyParam, CryptSignHash