CryptImportPublicKeyInfoEx

A version of this page is also available for

Windows Embedded CE 6.0 R3

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

CryptAcquireContext
CryptExportKey
CryptExportPublicKeyInfoEx
CryptGetUserKey
ALG_ID
CERT_PUBLIC_KEY_INFO