Partager via


CryptCreateKeyIdentifierFromCSP (Windows Embedded CE 6.0)

1/6/2010

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.

Syntax

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

Parameters

  • dwCertEncodingType
    [in] Specifies the encoding type used. Currently, only X509_ASN_ENCODING is used; however, additional encoding types may be added in the future.
  • pszPubKeyOID
    [in] Pointer to the null-terminated string that contains 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.
  • pPubKeyStruc
    [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.
  • cbPubKeyStruc
    [in] Size, in bytes, of the PUBLICKEYSTRUC structure.
  • dwFlags
    [in] Reserved for future use and must be set to zero.
  • pvReserved
    [in] Reserved for future use and must be set to NULL.
  • pbHash
    [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.

  • pcbHash
    [in, out] On input, pointer to a DWORD specifying the size, in bytes, of the buffer pointed to by the pbHash parameter. On output, the DWORD contains the number of bytes stored in the buffer. Currently using SHA1 hashing, the length of the required buffer is 20.

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.

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
CryptEnumKeyIdentifierProperties
CryptGetKeyIdentifierProperty
CryptSetKeyIdentifierProperty
CERT_PUBLIC_KEY_INFO
PUBLICKEYSTRUC