Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.


The PFN_CRYPT_EXPORT_PUBLIC_KEY_INFO_EX2_FUNC callback function is called by CryptExportPublicKeyInfoEx to export a public key BLOB and encode it.


  _In_      NCRYPT_KEY_HANDLE     hNCryptKey,
  _In_      DWORD                 dwCertEncodingType,
  _In_      LPSTR                 pszPublicKeyObjId,
  _In_      DWORD                 dwFlags,
  _In_opt_  void                  *pvAuxInfo,
  _Out_opt_ PCERT_PUBLIC_KEY_INFO pInfo,
  _Inout_   DWORD                 *pcbInfo


hNCryptKey [in]

A handle of the cryptographic service provider (CSP) to use when exporting the public key information. This handle must be an NCRYPT_KEY_HANDLE handle that has been created by using the NCryptOpenKey function.

dwCertEncodingType [in]

A value that 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:


Currently defined encoding types are:

pszPublicKeyObjId [in]

A pointer to a string that contains the public key algorithm.

dwFlags [in]

A value that indicates how the public key information is exported. This can be zero.

pvAuxInfo [in, optional]

This parameter is reserved for future use and must be set to NULL.

pInfo [out, optional]

A pointer to a CERT_PUBLIC_KEY_INFO structure to receive the public key information to be exported.

This parameter can be NULL to set the size of this information for memory allocation purposes. For more information, see Retrieving Data of Unknown Length.

pcbInfo [in, out]

A pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by the pInfo parameter. When the function returns, 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).

If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.

If this callback function does not support the signature algorithm, it must return FALSE and call SetLastError with ERROR_NOT_SUPPORTED.


You can use OID Support Functions to deploy this callback function. Wincrypt.h defines the following constant for this purpose.




Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]