CryptCreateKeyIdentifierFromCSP function (wincrypt.h)

Important  This API is deprecated. New and existing software should start using Cryptography Next Generation APIs. Microsoft may remove this API in future releases.
 
The CryptCreateKeyIdentifierFromCSP function creates a key identifier from a cryptographic service provider (CSP) public key CRYPT_INTEGER_BLOB.

This function converts a PUBLICKEYSTRUC of a CSP 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.

Syntax

BOOL CryptCreateKeyIdentifierFromCSP(
  [in]      DWORD                dwCertEncodingType,
  [in]      LPCSTR               pszPubKeyOID,
  [in]      const PUBLICKEYSTRUC *pPubKeyStruc,
  [in]      DWORD                cbPubKeyStruc,
  [in]      DWORD                dwFlags,
  [in]      void                 *pvReserved,
  [out]     BYTE                 *pbHash,
  [in, out] DWORD                *pcbHash
);

Parameters

[in] dwCertEncodingType

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

[in] pszPubKeyOID

A pointer to the public key object identifier (OID). A value that is not NULL overrides the default OID obtained from the aiKeyAlg member of the structure pointed to by pPubKeyStruc. To use the default OID, set pszPubKeyOID to NULL.

[in] pPubKeyStruc

A pointer to a PUBLICKEYSTRUC structure. In the default case, the aiKeyAlg member of the structure pointed to by pPubKeyStruc is used to find the public key OID. When the value of pszPubKeyOID is not NULL, it overrides the default.

[in] cbPubKeyStruc

The size, in bytes, of the PUBLICKEYSTRUC.

[in] dwFlags

Reserved for future use and must be zero.

[in] pvReserved

Reserved for future use and must be NULL.

[out] pbHash

A pointer to a buffer to receive the hash of the public key and the key identifier.

To get the size of this information for memory allocation purposes, set this parameter to NULL. For more information, see Retrieving Data of Unknown Length.

[in, out] pcbHash

A pointer to a DWORD that specifies 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. Using SHA1 hashing, the length of the required buffer is twenty.

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.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header wincrypt.h
Library Crypt32.lib
DLL Crypt32.dll

See also

CryptEnumKeyIdentifierProperties

CryptGetKeyIdentifierProperty

CryptSetKeyIdentifierProperty

Key Identifier Functions