CryptExportPublicKeyInfoEx (Windows Embedded CE 6.0)
1/6/2010
This function exports the public key information associated with the provider's corresponding private key. This function allows the application to specify the public key algorithm, overriding the default provided by the cryptographic service provider (CSP).
Syntax
BOOL WINAPI CryptExportPublicKeyInfoEx(
HCRYPTPROV hCryptProv,
DWORD dwKeySpec,
DWORD dwCertEncodingType,
LPSTR pszPublicKeyObjId,
DWORD dwFlags,
void* pvAuxInfo,
PCERT_PUBLIC_KEY_INFO pInfo,
DWORD* pcbInfo
);
Parameters
- hCryptProv
[in] Handle to the CSP to use when exporting the public key information. This handle must have already been created using the CryptAcquireContext function.
- dwKeySpec
[in] Specifies the private key to use from the provider's container. The value can be AT_KEYEXCHANGE or AT_SIGNATURE.
- dwCertEncodingType
[in] Specifies the encoding type used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.
pszPublicKeyObjId
[in] Pointer to the null-terminated string that contains the public key algorithm.ThepszPublicKeyObjId and dwCertEncodingType parameters are used together in determining the installable CRYPT_OID_EXPORT_PUBLIC_KEY_INFO_FUNC to call. If an installable function was not found for the pszPublicKeyObjId parameter, an attempt is made to export the key as an RSA Public Key (szOID_RSA_RSA).
- dwFlags
[in] Reserved for future use and must be set to zero.
- pvAuxInfo
[in] Reserved for future use and must be set to NULL.
pInfo
[out] Pointer to a CERT_PUBLIC_KEY_INFO structure to receive the public key information to be exported.This parameter can be NULL to set the size of this information for memory allocation purposes.
pcbInfo
[in, out] On input, pointer to a DWORD that contains the size, in bytes, of the buffer pointed to by the pInfo parameter. On output, the DWORD contains the number of bytes stored in the buffer.When processing the data returned in the buffer, applications need to use the actual size of the data returned. The actual size can be slightly smaller than the size of the buffer specified on input. On input, buffer sizes are usually specified large enough to ensure that the largest possible output data will fit in the buffer. On output, the variable pointed to by this parameter is updated to reflect the actual size of the data copied to the buffer.
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 can be propagated to this function.
The following table shows the error codes for this function.
Error code | Description |
---|---|
ERROR_FILE_NOT_FOUND |
An installable or registerable export function could not be found for the specified dwCertEncodingType and pszPublicKeyObjId parameters. |
ERROR_MORE_DATA |
If the buffer specified by the pInfo parameter is not large enough to hold the returned data, the function sets the ERROR_MORE_DATA code and stores the required buffer size, in bytes, in the variable pointed to by the pcbInfo parameter. |
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 |
See Also
Reference
Certificates Functions
CryptAcquireContext
CryptExportKey
CryptGetUserKey
CryptImportPublicKeyInfoEx
CERT_PUBLIC_KEY_INFO