Export (0) Print
Expand All
Expand Minimize

CryptImportPublicKeyInfoEx2 function

The CryptImportPublicKeyInfoEx2 function imports a public key into the 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.

This parameter can be the following currently defined certificate encoding type.

ValueMeaning
X509_ASN_ENCODING
1 (0x1)

Specifies X.509 certificate encoding.

 

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.

ValueMeaning
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 it by calling the BCryptDestroyKey function.

Return value

If the function succeeds, the function 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.

Return codeDescription
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

Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2008 [desktop apps only]

Header

Wincrypt.h

Library

Crypt32.lib

DLL

Crypt32.dll

See also

CERT_PUBLIC_KEY_INFO

 

 

Community Additions

ADD
Show:
© 2014 Microsoft