Share via


CryptHashToBeSigned

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

This function computes the hash of the encoded content from a signed and encoded certificate. The hash is performed on only the to-be-signed encoded content and its signature.

Syntax

BOOL WINAPI CryptHashToBeSigned(
  HCRYPTPROV hCryptProv,
  DWORD dwCertEncodingType,
  const BYTE* pbEncoded,
  DWORD cbEncoded,
  BYTE* pbComputedHash,
  DWORD* pcbComputedHash
);

Parameters

  • hCryptProv
    [in] Handle to the CSP used to compute the hash.

    Unless there is a strong reason for passing in a specific cryptographic provider in the hCryptProv parameter, zero is passed in. Passing in zero causes the default RSA or DSS provider to be acquired before doing hash, signature verification or recipient encryption operations.

  • dwCertEncodingType
    [in] Specifies the encoding type used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.
  • pbEncoded
    [in] Address of a buffer containing the content to be hashed. This is the encoded form of a CERT_SIGNED_CONTENT_INFO.
  • cbEncoded
    [in] Size, in bytes, of the buffer.
  • 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.

    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, or TRUE.

If the function fails, the return value is zero, or FALSE.

For extended error information, call the GetLastError function.

Errors from the called CryptCreateHash, CryptGetHashParam, and CryptHashData functions might be propagated to this function. The following table shows the error codes for this 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.

NTE_BAD_ALGID

The signature algorithm's object identifier does not map to a known or supported hash algorithm.

Remarks

The desktop operating system supports the flag PKCS_7_ASN_ENCODING, but Windows Embedded CE does not and ignores the flag when it is specified.

Requirements

Header wincrypt.h
Library crypt32.lib
Windows Embedded CE Windows CE 3.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also

Reference

CryptCreateHash
CryptGetHashParam
CryptHashCertificate
CryptHashData
CryptHashPublicKeyInfo