UID | title | description | helpviewer_keywords | old-location | tech.root | ms.assetid | ms.date | ms.keywords | req.header | req.include-header | req.target-type | req.target-min-winverclnt | req.target-min-winversvr | req.kmdf-ver | req.umdf-ver | req.ddi-compliance | req.unicode-ansi | req.idl | req.max-support | req.namespace | req.assembly | req.type-library | req.lib | req.dll | req.irql | targetos | req.typenames | req.redist | ms.custom | f1_keywords | dev_langs | topic_type | api_type | api_location | api_name | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
NF:wincrypt.CryptImportPublicKeyInfo |
CryptImportPublicKeyInfo function (wincrypt.h) |
Converts and imports the public key information into the provider and returns a handle of the public key. |
|
security\cryptimportpublickeyinfo.htm |
security |
f5f8ebb6-c838-404b-9b61-3ec36fdaef01 |
12/05/2018 |
CryptImportPublicKeyInfo, CryptImportPublicKeyInfo function [Security], _crypto2_cryptimportpublickeyinfo, security.cryptimportpublickeyinfo, wincrypt/CryptImportPublicKeyInfo |
wincrypt.h |
Windows |
Windows XP [desktop apps only] |
Windows Server 2003 [desktop apps only] |
Crypt32.lib |
Crypt32.dll |
Windows |
19H1 |
|
|
|
|
|
|
The handle of the cryptographic service provider (CSP) to use when importing the public key. This handle must have already been created using CryptAcquireContext.
Specifies the encoding type used. It is always acceptable to specify both the certificate and message encoding types by combining them with a bitwise-OR operation as shown in the following example:
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING
Currently defined encoding types are:
- X509_ASN_ENCODING
- PKCS_7_ASN_ENCODING
The address of a CERT_PUBLIC_KEY_INFO structure that contains the public key to import into the provider.
The address of an HCRYPTKEY variable that receives the handle of the imported public key. When you have finished using the public key, release the handle by calling the CryptDestroyKey function.
If the function succeeds, the return value is nonzero (TRUE).
If the function fails, the return value is zero (FALSE). For extended error information, call GetLastError.
Return code | Description |
---|---|
|
An import function that can be installed or registered could not be found for the specified dwCertEncodingType and pInfo->Algorithm.pszObjId parameters. |
If the function fails, GetLastError may return an Abstract Syntax Notation One (ASN.1) encoding/decoding error. For information about these errors, see ASN.1 Encoding/Decoding Return Values.
This function is normally used to retrieve the public key from a certificate. This is done by passing the CERT_PUBLIC_KEY_INFO structure from a filled-in certificate structure as shown in the following pseudocode.
PCCERT_CONTEXT pCertContext
// Get the certificate context structure from a certificate.
pCertContext = CertCreateCertificateContext(...)
if(pCertContext)
{
HCRYPTKEY hCertPubKey
// Get the public key information for the certificate.
CryptImportPublicKeyInfo(
hCryptProv,
X509_ASN_ENCODING,
&pCertContext->pCertInfo->SubjectPublicKeyInfo,
&hCertPubKey)
CertFreeCertificateContext(pCertContext)
}