CertGetPublicKeyLength function (wincrypt.h)

The CertGetPublicKeyLength function acquires the bit length of public/private keys from a public key BLOB.

Syntax

DWORD CertGetPublicKeyLength(
  [in] DWORD                 dwCertEncodingType,
  [in] PCERT_PUBLIC_KEY_INFO pPublicKey
);

Parameters

[in] dwCertEncodingType

Specifies the encoding type used. It is always acceptable to specify both the certificate and message encoding types by combining them with a bitwise-OR operation as shown in the following example:

X509_ASN_ENCODING | PKCS_7_ASN_ENCODING Currently defined encoding types are:

  • X509_ASN_ENCODING
  • PKCS_7_ASN_ENCODING

[in] pPublicKey

A pointer to the public key BLOB containing the keys for which the length is being retrieved.

Return value

Returns the length of the public/private keys in bits. If unable to determine the key's length, returns zero.

Call GetLastError to see the reason for any failures.

Requirements

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

See also

Data Management Functions