Functions
C_DigestInit
Initializes a digest operation on a session.Handle of the open session.
Pointer to a
CK_MECHANISM structure that specifies the hash algorithm. No mechanism parameters are required; pParameter should be NULL_PTR and ulParameterLen should be 0.C_DigestInit before any other digest function. If another operation is already active on the session, CKR_OPERATION_ACTIVE is returned.
C_Digest
Computes the hash of data in a single-part operation.Pointer to the data to hash.
Length of
pData in bytes.Buffer to receive the digest. Pass
NULL_PTR on the first call to obtain the required buffer size.On input: size of
pDigest. On output: number of bytes written (or required size if pDigest is NULL_PTR).C_DigestUpdate
Continues a multi-part digest with an additional chunk of data.Pointer to the next chunk of data.
Length of this chunk in bytes.
C_DigestUpdate one or more times, then call C_DigestFinal to obtain the digest.
C_DigestKey
Includes the value of a secret key in the ongoing digest computation.Handle of a secret key whose value is to be included in the digest. The key must be a
CKO_SECRET_KEY object.C_DigestKey is typically used to hash the raw key material of a secret key without ever exposing the key value to the calling application. You can interleave calls to C_DigestKey and C_DigestUpdate freely during a multi-part operation.
C_DigestFinal
Finishes a multi-part digest operation and returns the resulting hash.Buffer to receive the final digest. Pass
NULL_PTR to query the required size without consuming the operation.On input: size of
pDigest. On output: number of bytes written (or required size).C_DigestFinal returns successfully, the digest operation is cleared. You must call C_DigestInit again before starting another digest.
Supported hash mechanisms
| Mechanism | Output size | Notes |
|---|---|---|
CKM_MD5 | 16 bytes | Not available in FIPS mode |
CKM_SHA_1 | 20 bytes | |
CKM_SHA224 | 28 bytes | |
CKM_SHA256 | 32 bytes | |
CKM_SHA384 | 48 bytes | |
CKM_SHA512 | 64 bytes | |
CKM_GOSTR3411 | 32 bytes | GOST R 34.11-94; requires WITH_GOST build |
pMechanism->pParameter = NULL_PTR and pMechanism->ulParameterLen = 0; any non-NULL parameter returns CKR_ARGUMENTS_BAD.
Error codes
| Return value | Meaning |
|---|---|
CKR_OK | Success |
CKR_ARGUMENTS_BAD | pData or pulDigestLen is NULL_PTR |
CKR_MECHANISM_INVALID | Hash algorithm not supported |
CKR_OPERATION_ACTIVE | Another operation is already running on this session |
CKR_OPERATION_NOT_INITIALIZED | C_DigestInit was not called |
CKR_BUFFER_TOO_SMALL | Output buffer too small; required size written to *pulDigestLen |