Platform SDK: Cryptography

CPCreateHash

The CPCreateHash function creates a hash object and initiates 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 within the CSP. This handle is obtained by a call to CPAcquireContext.
Algid
Algorithm identifier (ALG_ID) of the hash algorithm to be used.
hKey
If the hash is a keyed hash algorithm such as MAC, the key handle for the hash is passed in this parameter. For non-keyed algorithms, this parameter is set to zero.
dwFlags
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, 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 Algid parameter specifies an algorithm that this CSP does not support.
NTE_BAD_FLAGS The dwFlags parameter is non-zero.
NTE_BAD_KEY The algid parameter specifies a keyed hash algorithm, such as CALG_MAC, and the hKey parameter is either zero or 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 does not use feedback.
NTE_NO_MEMORY The CSP ran out of memory during the operation.

Remarks

For information on writing CPCreateHash for schannel applications, see Schannel CSP Reference.

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

CPDestroyHash, CPHashData, CryptCreateHash