CryptSetHashParam

Windows CE 3.0

This function customizes the operations of a hash object. Currently, only a single parameter is defined for this function.

BOOL WINAPI CryptSetHashParam( 
HCRYPTHASH hHash,
DWORD dwParam, 
BYTE *pbData, 
DWORD dwFlags);

Parameters

hHash
[in] Handle to the hash object on which to set parameters.
dwParam
[in] Specifies the parameter number. See the Remarks section for a list of valid parameters.
pbData
[in] Pointer to a 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
[in] Specifies a bitmask of flags. This parameter is reserved for future use and should always be zero.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call GetLastError. Common values for GetLastError are described in the following table. The error values prefaced by "NTE" are generated by the particular CSP you are using.

Value 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:

HP_HMAC_INFO
The pbData buffer should contain a pointer to an HMAC_INFO structure that specifies the cryptographic hash algorithm and the inner and outer strings to be used.
HP_HASHVAL
Hash value. The pbData buffer should contain a byte array containing a hash value to place directly into the hash object. Before setting this parameter, the size of the hash value should be determined by reading the HP_HASHSIZE parameter with the CryptGetHashParam function.

Some CSPs will not support this capability. Occasionally, it is convenient to sign a hash value that has been generated elsewhere. This is the usual sequence of operations:

  1. The application creates a hash object with CryptCreateHash.
  2. It specifies a hash value by setting the HP_HASHVAL parameter.
  3. It signs the hash value by using CryptSignHash, obtaining a digital signature block.
  4. It destroys the hash object by using CryptDestroyHash.
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;
}

Requirements

Runs On Versions Defined in Include Link to
Windows CE OS 2.10 and later Wincrypt.h   Cryptapi.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CryptCreateHash, CryptDestroyHash, CryptGetHashParam, CryptSetKeyParam, CryptSignHash, HMAC_INFO


 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.

Show: