CryptHashCertificate2 function (wincrypt.h)

The CryptHashCertificate2 function hashes a block of data by using a CNG hash provider.

Syntax

BOOL CryptHashCertificate2(
  [in]      LPCWSTR    pwszCNGHashAlgid,
  [in]      DWORD      dwFlags,
            void       *pvReserved,
  [in]      const BYTE *pbEncoded,
  [in]      DWORD      cbEncoded,
  [out]     BYTE       *pbComputedHash,
  [in, out] DWORD      *pcbComputedHash
);

Parameters

[in] pwszCNGHashAlgid

The address of a null-terminated Unicode string that contains the CNG hash algorithm identifier of the hash algorithm to use to hash the certificate. This can be one of the CNG Algorithm Identifiers that represents a hash algorithm or any other registered hash algorithm identifier.

[in] dwFlags

A set of flags that modify the behavior of this function. No flags are defined for this function.

pvReserved

Reserved for future use and must be NULL.

[in] pbEncoded

The address of an array of bytes to be hashed. The cbEncoded parameter contains the size of this array.

[in] cbEncoded

The number of elements in the pbEncoded array.

[out] pbComputedHash

The address of a buffer that receives the computed hash. The variable pointed to by the pcbComputedHash parameter contains the size of this buffer.

[in, out] pcbComputedHash

The address of a DWORD variable that, on entry, contains the size, in bytes, of the pbComputedHash buffer. After this function returns, this variable contains the number of bytes copied to the pbComputedHash buffer.

Return value

If the function succeeds, the function returns nonzero (TRUE).

If the function fails, it returns zero (FALSE). For extended error information, call GetLastError. Some of the possible error codes are identified in the following topics.

BCryptOpenAlgorithmProvider
BCryptCreateHash
BCryptGetProperty
BCryptHashData
BCryptFinishHash

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps | UWP apps]
Minimum supported server Windows Server 2008 [desktop apps | UWP apps]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also

Data Management Functions