Share via


CryptHashPublicKeyInfo (Compact 2013)

3/28/2014

This function encodes the public key information in a CERT_PUBLIC_KEY_INFO structure and computes the hash of the encoded bytes. The hash created is used with key identifier functions.

Syntax

BOOL WINAPI CryptHashPublicKeyInfo(
  __in HCRYPTPROV_LEGACY hCryptProv,
  __in ALG_ID Algid,
  __in DWORD dwFlags,
  __in DWORD dwCertEncodingType,
  __in PCERT_PUBLIC_KEY_INFO pInfo,
  __out BYTE *pbComputedHash,
  __inout DWORD *pcbComputedHash
);

Parameters

  • hCryptProv
    [in] Parameter is not used and must be set to NULL.
  • Algid
    [in] Parameter ALG_ID that specifies the CryptoAPI hash algorithm to use. If the value of this parameter is zero, the default hash algorithm, SHA1, is used.
  • dwFlags
    [in] Specifies the values to be passed on to the CryptCreateHash function.
  • dwCertEncodingType
    [in] Specifies the encoding type used. Only X509_ASN_ENCODING is used.
  • pInfo
    [in] Pointer to a CERT_PUBLIC_KEY_INFO structure that contains the public key information to be encoded and hashed.
  • pbComputedHash
    [out] Pointer to a buffer to receive the computed hash.

    This parameter can be NULL to set the size of this information for memory allocation purposes.

  • pcbComputedHash
    [in, out] On input, pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by the pbComputedHash parameter. On output, the DWORD contains the number of bytes stored in the buffer.

    Note

    When processing the data returned in the buffer, applications need to use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer. On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.

Return Value

If the function succeeds, the return value is nonzero (TRUE); otherwise, it is zero (FALSE).

For extended error information, call the GetLastError function.

Note

Errors from the called CryptCreateHash, CryptGetHashParam, and CryptHashData functions can be propagated to this function.

The following table shows the error codes for the GetLastError function.

Error code

Description

ERROR_MORE_DATA

If the buffer specified by the pbComputedHash parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code and stores the required buffer size, in bytes, into the variable pointed to by the pcbComputedHash parameter.

ERROR_FILE_NOT_FOUND

Invalid certificate encoding type. Currently only X509_ASN_ENCODING is supported.

Remarks

The desktop version of Windows supports the flag PKCS_7_ASN_ENCODING, but Windows Embedded Compact does not and ignores the flag when it is specified.

Requirements

Header

wincrypt.h

Library

crypt32.lib

See Also

Reference

Certificates Functions
CryptCreateHash
CryptGetHashParam
CryptHashCertificate
CryptHashData
CryptHashToBeSigned
ALG_ID
CERT_PUBLIC_KEY_INFO