Windows CE 3.0

This function creates a key identifier from a cryptographic service provider (CSP) public key BLOB.

This function converts a CSP's PUBLICKEYSTRUC structure into an X.509 CERT_PUBLIC_KEY_INFO structure and encodes it. The encoded structure is then hashed with the SHA1 algorithm to obtain the key identifier.

BOOL WINAPI CryptCreateKeyIdentifierFromCSP(
DWORD dwCertEncodingType,
const PUBLICKEYSTRUC *pPubKeyStruc,
DWORD cbPubKeyStruc,
DWORD dwFlags,
void *pvReserved,
BYTE *pbHash,
DWORD *pcbHash


[in] Specifies the encoding type used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.
[in] Pointer to the public key object identifier (OID). A non-NULL value overrides the default OID obtained from the aiKeyAlg member of the structure pointed to by the pPubKeyStruc parameter. Set the pszPubKeyOID parameter to NULL to use the default OID.
[in] Pointer to a PUBLICKEYSTRUC structure. In the default case, the aiKeyAlg member of the structure pointed to by the pPubKeyStruc parameter is used to find the public key OID. A non-NULL pszPubKeyOID parameter overrides the default.
[in] Size, in bytes, of the PUBLICKEYSTRUC structure.
[in] Reserved for future use and must be zero.
[in] Reserved for future use and must be NULL.
[out] Pointer to a buffer to receive the hash of the public key and the key identifier.

This parameter can be NULL to get the size of this information for memory allocation purposes.

[in/out] Pointer to a DWORD specifying the size, in bytes, of the buffer pointed to by the pbHash parameter. When the function returns, the DWORD contains the number of bytes stored in the buffer. Currently using SHA1 hashing, the length of the required buffer is 20.

Return Values

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 the GetLastError function.


The desktop platform supports the PKCS_7_ASN_ENCODING flag, but Windows CE does not. Windows CE ignores the flag when it is specified.


Runs on Versions Defined in Include Link to
Windows CE OS 3.0 or later Wincrypt.h   Crypt32.lib
Note   This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.

See Also

CryptEnumKeyIdentifierProperties, CryptGetKeyIdentifierProperty, CryptSetKeyIdentifierProperty, CERT_PUBLIC_KEY_INFO, PUBLICKEYSTRUC

 Last updated on Tuesday, July 13, 2004

© 1992-2000 Microsoft Corporation. All rights reserved.