CryptImportPublicKeyInfoEx2 (Compact 2013)

3/28/2014

This function imports a public key into the Cryptography Next Generation (CNG) asymmetric provider that corresponds to the public key object identifier (OID) and returns a CNG handle to the key.

Syntax

BOOL WINAPI CryptImportPublicKeyInfoEx2(
    __in DWORD dwCertEncodingType,
    __in PCERT_PUBLIC_KEY_INFO pInfo,
    __in DWORD dwFlags,
    __in void *pvAuxInfo,
    __out BCRYPT_KEY_HANDLE *phKey
);

Parameters

  • dwCertEncodingType
    [in] The certificate encoding type that was used to encrypt the subject. The message encoding type identifier, contained in the high WORD of this value, is ignored by this function.
  • pInfo
    [in] The address of a CERT_PUBLIC_KEY_INFO structure that contains the public key information to import into the provider.
  • dwFlags
    [in] A set of flags that modify the behavior of this function. This can be zero or a combination of one or more of the following values.

    Value

    Description

    CRYPT_OID_INFO_PUBKEY_SIGN_KEY_FLAG

    Skips public keys in the CRYPT_PUBKEY_ALG_OID_GROUP_ID group that are explicitly flagged with the CRYPT_OID_PUBKEY_ENCRYPT_ONLY_FLAG flag.

    CRYPT_OID_INFO_PUBKEY_ENCRYPT_KEY_FLAG

    Skips public keys in the CRYPT_PUBKEY_ALG_OID_GROUP_ID group that are explicitly flagged with the CRYPT_OID_PUBKEY_SIGN_ONLY_FLAG flag.

    These flags are passed in the dwKeyType parameter of the CryptFindOIDInfo function when mapping the public key object identifier to the corresponding CNG public key algorithm identifier.

  • pvAuxInfo
    [in] This parameter is reserved for future use and must be set to NULL.
  • phKey
    [out] The address of a BCRYPT_KEY_HANDLE variable that receives the handle of the imported key.

    When this handle is no longer needed, you must release by calling the BCryptDestroyKey function.

Return Value

If the function succeeds, it returns nonzero (TRUE).

If the function fails, it returns zero (FALSE). For extended error information, call GetLastError. Possible error codes include, but are not limited to, the following.

Error code

Description

ERROR_FILE_NOT_FOUND

An import function that can be installed or registered could not be found for the specified dwCertEncodingType and pInfo parameters.

E_INVALIDARG

One or more parameters are not valid.

Requirements

Header

wincrypt.h

Library

crypt32.lib

See Also

Reference

Certificates Functions