Cryptoki: a cryptographic Token Interface



Download 360.55 Kb.
Page109/196
Date22.12.2023
Size360.55 Kb.
#63026
1   ...   105   106   107   108   109   110   111   112   ...   196
v201-95
pkcs11-base-v2.40-cos01

C_DigestFinal


CK_DEFINE_FUNCTION(CK_RV, C_DigestFinal)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pDigest,
CK_ULONG_PTR pulDigestLen
);
C_DigestFinal finishes a multiple-part message-digesting operation, returning the message digest. hSession is the session’s handle; pDigest points to the location that receives the message digest; pulDigestLen points to the location that holds the length of the message digest.
C_DigestFinal uses the convention described in Section on producing output.
The digest operation must have been initialized with C_DigestInit. A call to C_DigestFinal always terminates the active digest operation unless it returns CKR_BUFFER_TOO_SMALL or is a successful call (i.e., one which returns CKR_OK) to determine the length of the buffer needed to hold the message digest.
Return values: CKR_BUFFER_TOO_SMALL, CKR_CRYPTOKI_NOT_INITIALIZED, CKR_DEVICE_ERROR, CKR_DEVICE_MEMORY, CKR_DEVICE_REMOVED, CKR_FUNCTION_CANCELED, CKR_FUNCTION_FAILED, CKR_GENERAL_ERROR, CKR_HOST_MEMORY, CKR_OK, CKR_OPERATION_NOT_INITIALIZED, CKR_SESSION_CLOSED, CKR_SESSION_HANDLE_INVALID.
Example:
CK_SESSION_HANDLE hSession;
CK_MECHANISM mechanism = {
CKM_MD5, NULL_PTR, 0
};
CK_BYTE data[] = {...};
CK_BYTE digest[16];
CK_ULONG ulDigestLen;
CK_RV rv;

.
.
.


rv = C_DigestInit(hSession, &mechanism);
if (rv != CKR_OK) {
.
.
.
}

rv = C_DigestUpdate(hSession, data, sizeof(data));


if (rv != CKR_OK) {
.
.
.
}

rv = C_DigestKey(hSession, hKey);


if (rv != CKR_OK) {
.
.
.
}

ulDigestLen = sizeof(digest);


rv = C_DigestFinal(hSession, digest, &ulDigestLen);
.
.
.

10.11. Signing and MACing functions


Cryptoki provides the following functions for signing data (for the purposes of Cryptoki, these operations also encompass message authentication codes):
1   ...   105   106   107   108   109   110   111   112   ...   196




The database is protected by copyright ©ininet.org 2024
send message

    Main page