Partager via


CryptImportPublicKeyInfoEx (Compact 2013)

3/28/2014

This function imports public key information into the cryptographic service provider (CSP) and returns a handle of the public key. Additional parameters to override defaults are provided to supplement those in the CERT_PUBLIC_KEY_INFO structure.

Syntax

BOOL WINAPI CryptImportPublicKeyInfoEx(
  HCRYPTPROV hCryptProv,
  DWORD dwCertEncodingType,
  PCERT_PUBLIC_KEY_INFO pInfo,
  ALG_ID aiKeyAlg,
  DWORD dwFlags,
  void* pvAuxInfo,
  HCRYPTKEY* phKey
);

Parameters

  • hCryptProv
    [in] Handle to the CSP that will receive the imported public key. This handle must have already been created using the CryptAcquireContext function.
  • dwCertEncodingType
    [in] Specifies the encoding type used. Only X509_ASN_ENCODING is used.
  • pInfo
    [in] Pointer to a CERT_PUBLIC_KEY_INFO structure containing the public key to import into the provider.

    The pzObjId member of the structure pointed to by the pInfo parameter and the dwCertEncodingType parameter determine an installable CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNC callback function. If an installable function is not found, an attempt is made to import the key as a szOID_RSA_RSA, RSA Public Key.

  • aiKeyAlg
    [in] ALG_ID structure containing a CSP-specific algorithm to override the CALG_RSA_KEYX default algorithm.
  • dwFlags
    [in] Reserved; set to 0 (zero).
  • pvAuxInfo
    [in] Reserved; set to NULL.
  • phKey
    [out] Pointer to the handle to the imported public key.

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 CryptGetUserKey and CryptExportKey functions might be propagated to this function.

The GetLastError function can return ERROR_FILE_NOT_FOUND, which indicates that an installable or registerable import function could not be found for the specified dwCertEncodingType and pInfo parameters.

Remarks

The desktop operating system 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
CryptAcquireContext
CryptExportKey
CryptExportPublicKeyInfoEx
CryptGetUserKey
ALG_ID
CERT_PUBLIC_KEY_INFO