Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

CryptSetHashParam (Windows CE 5.0)

Windows CE 5.0
Send Feedback

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] HCRYPTHASH handle to the hash object on which to set parameters.
dwParam
[in] Specifies the parameter value.

The following table shows the possible values.

ValueDescription
HP_HASHVALByte array containing a hash value to place directly into the hash object. Before setting this value, the size of the hash value must be determined by reading the HP_HASHSIZE value with the CryptGetHashParam function.

Some CSPs do not support this capability.

HP_HMAC_INFOHMAC_INFO structure that specifies the underlying hash algorithm and any optional parameters.

Some cryptographic service provider (CSP) types can add additional values that can be set with this function.

pbData
[in] Pointer to a parameter data buffer. Place the parameter data in this buffer before calling the CryptSetHashParam function. The form of this data varies depending on the parameter number.
dwFlags
[in] Reserved for future use and must be set to zero.

Return Values

TRUE indicates success. FALSE indicates failure. To get extended error information, call the GetLastError function.

The following table shows the common values for the GetLastError function. The error values prefaced by NTE are generated by the particular CSP you are using.

ValueDescription
ERROR_INVALID_HANDLEOne of the parameters specifies an invalid handle.
ERROR_BUSYThe CSP context is currently being used by another process.
ERROR_INVALID_PARAMETEROne of the parameters contains an invalid value. This is most often an illegal pointer.
NTE_BAD_FLAGSThe dwFlags parameter is nonzero or the pbData buffer contains an invalid value.
NTE_BAD_HASHThe hash object specified by the hHash parameter is invalid.
NTE_BAD_TYPEThe dwParam parameter specifies an unknown parameter.
NTE_BAD_UIDThe CSP context that was specified when the hKey key was created cannot be found.
NTE_FAILThe function failed in some unexpected way.

Remarks

Occasionally, a hash value that has been generated elsewhere must be signed. The following sequence of operations accomplishes the task:

  1. Create a hash object with CryptCreateHash.
  2. Set the dwParam parameter to HP_HASHVAL.
  3. Sign the hash value by using CryptSignHash, thereby obtaining a digital signature block.
  4. Destroy the hash object by using CryptDestroyHash.

Example Code

// 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

OS Versions: Windows CE 2.10 and later.
Header: Wincrypt.h.
Link Library: Coredll.lib.

See Also

CryptCreateHash | CryptDestroyHash | CryptGetHashParam | CryptSetKeyParam | CryptSignHash | HMAC_INFO


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.