Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

This function acquires the intended key usage bytes from a certificate. The intended key usage can be in either the szOID_KEY_USAGE (2.5.29.15) or szOID_KEY_ATTRIBUTES (2.5.29.2) extension.

Syntax

BOOL WINAPI CertGetIntendedKeyUsage(
  DWORD 
dwCertEncodingType,
  PCERT_INFO 
pCertInfo,
  BYTE* 
pbKeyUsage,
  DWORD 
cbKeyUsage
);

Parameters

dwCertEncodingType

[in] Specifies the encoding type used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.

pCertInfo

[in] Pointer to the CERT_INFOstructure of the specified certificate.

pbKeyUsage

[in] Pointer to a buffer containing the intended key usage. The following list shows the currently defined values, which can be combined using bitwise ORoperations:

CERT_DATA_ENCIPHERMENT_KEY_USAGE

CERT_DIGITAL_SIGNATURE_KEY_USAGE

CERT_KEY_AGREEMENT_KEY_USAGE

CERT_KEY_CERT_SIGN_KEY_USAGE

CERT_KEY_ENCIPHERMENT_KEY_USAGE

CERT_NON_REPUDIATION_KEY_USAGE

CERT_OFFLINE_CRL_SIGN_KEY_USAGE

cbKeyUsage

[in] Size, in bytes, of the intended key usage. Currently, the intended key usage occupies only 1 byte of data.

Return Value

If the certificate does not have any intended key usage bytes, FALSE is returned and the pbKeyUsageparameter is set to zero. Otherwise, TRUE is returned and up to the cbKeyUsagenumber of bytes are copied into the pbKeyUsageparameter. Any remaining bytes not copied are set to zero.

For extended error information, call the GetLastErrorfunction.

The GetLastErrorfunction can return ERROR_FILE_NOT_FOUND, which indicates an invalid certificate encoding type. Currently only X509_ASN_ENCODING is supported.

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

CERT_INFO