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 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_INFOstructure.

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 CryptAcquireContextfunction.

dwCertEncodingType

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

pInfo

[in] Pointer to a CERT_PUBLIC_KEY_INFOstructure containing the public key to import into the provider.

The pzObjIdmember of the structure pointed to by the pInfoparameter and the dwCertEncodingTypeparameter determine an installable CRYPT_OID_IMPORT_PUBLIC_KEY_INFO_FUNCcallback 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_IDstructure containing a CSP-specific algorithm to override the CALG_RSA_KEYX default algorithm.

dwFlags

[in] Reserved for future use and must be set to zero.

pvAuxInfo

[in] Reserved for future use and must be 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 GetLastErrorfunction.

Errors from the called CryptGetUserKeyand CryptExportKeyfunctions might be propagated to this function.

The GetLastErrorfunction can return ERROR_FILE_NOT_FOUND, which indicates that an installable or registerable import function could not be found for the specified dwCertEncodingTypeand pInfoparameters.

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