Platform SDK: Cryptography

CPHashData

The CPHashData function feeds data into a specified hash object.

BOOL CPHashData(
  HCRYPTPROV hProv,       // in
  HCRYPTHASH hHash,       // in
  CONST BYTE *pbData,     // in
  DWORD dwDataLen,        // 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 a hash object. An application obtains this handle by using the CryptCreateHash function.
pbData
Address of a buffer containing the data to be hashed.
dwDataLen
Number of bytes of data to be hashed. This must be zero if dwFlags is set to CRYPT_USERDATA.
dwFlags
The following value is currently defined:
CRYPT_USERDATA
The CSP must prompt the user to enter directly the data to be added to the hash. Any data entered is used and destroyed within this function and the application has no access to it. This flag can be used to allow the user to enter a PIN, a password, or other unique identification into the system. Support for this flag is optional.

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_ALGID The hHash handle specifies an algorithm that this CSP does not support.
NTE_BAD_FLAGS The dwFlags parameter contains an invalid value.
NTE_BAD_HASH The hash object specified by the hHash parameter is invalid.
NTE_BAD_HASH_STATE An attempt was made to add data to a hash object that is already marked as "finished."
NTE_BAD_KEY A keyed hash algorithm is being used, but the session key is no longer valid. This error will be generated if the session key is destroyed before the hashing operating is complete.
NTE_BAD_LEN The CRYPT_USERDATA flag is set, and the dwDataLen parameter has a non-zero value.
NTE_BAD_UID The CSP context that was specified when the hash object was created cannot now be found.
NTE_FAIL The function failed in some unexpected way.
NTE_NO_MEMORY The CSP ran out of memory during the operation.

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, CPHashSessionKey, CryptHashData