CPCreateHash

The CPCreateHash function is used by applications to initiate the hashing of a stream of data.

BOOL CPCreateHash(
  HCRYPTPROV hProv,  // in
  ALG_ID Algid,      // in
  HCRYPTKEY hKey,    // in
  DWORD dwFlags,     // in
  HCRYPTHASH *phHash // out
);
 

Parameters

hProv
Handle to a particular key container (or "context") within the CSP. This handle is obtained via a call to CPAcquireContext.
Algid
Algorithm identifier of the hash algorithm to be used.
hKey
If the type of hash algorithm is a keyed hash (such as a MAC algorithm), the session key for the hash is passed in this parameter. For non-keyed algorithms, this parameter should be set to zero.
dwFlags
Flag values. No flags are currently defined.
phHash
Address to which the function copies a handle to the new hash object.

Return Values

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_ALGID The Algid parameter specifies an algorithm that this CSP does not support.
NTE_BAD_FLAGS The dwFlags parameter is non-zero.
NTE_BAD_KEY A keyed hash algorithm (for example, CALG_MAC) is specified by Algid, and the hKey parameter is either zero or it specifies an invalid key handle. This error code will also be returned if the key is to a stream cipher, or if the cipher mode is one that doesn't use feedback.
NTE_NO_MEMORY The CSP ran out of memory during the operation.

See Also

CPDestroyHash, CPHashData, CryptCreateHash