IX509PublicKey::ComputeKeyIdentifier method (certenroll.h)

The ComputeKeyIdentifier method creates an identifier from a 160-bit SHA-1 hash of the public key.

Syntax

HRESULT ComputeKeyIdentifier(
  [in]  KeyIdentifierHashAlgorithm Algorithm,
  [in]  EncodingType               Encoding,
  [out] BSTR                       *pValue
);

Parameters

[in] Algorithm

A value of the KeyIdentifierHashAlgorithm enumeration that specifies what hash algorithm to use to create the key identifier.

If this value is SKIHashDefault or SKIHashSha1, the identifier is created by hashing only the byte array that contains the key and excluding the Distinguished Encoding Rules (DER) tag, length, and unused bits fields.

If this value is SKIHashCapiSha1, the identifier is created by hashing the DER-encoded byte array that contains the tag, length, number of unused bits, and the public key.

[in] Encoding

An EncodingType enumeration value that specifies the type of Unicode-encoding to be applied to the hash contained in the pValue parameter. The default value is XCN_CRYPT_STRING_BASE64.

[out] pValue

Pointer to a BSTR variable that contains the key identifier.

Return value

If the function succeeds, the function returns S_OK.

If the function fails, it returns an HRESULT value that indicates the error. Possible values include, but are not limited to, those in the following table. For a list of common error codes, see Common HRESULT Values.

Return code/value Description
CERTSRV_E_PROPERTY_EMPTY
The algorithm object identifier or the public key parameters could not be found.

Remarks

You must call the InitializeFromEncodedPublicKeyInfo method or the Initialize method to initialize the public key object before calling ComputeKeyIdentifier.

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2008 [desktop apps only]
Target Platform Windows
Header certenroll.h
DLL CertEnroll.dll

See also

IX509PublicKey