Cryptoki: a cryptographic Token Interface


Message digesting functions



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

10.10. Message digesting functions


Cryptoki provides the following functions for digesting data:
  • C_DigestInit


CK_DEFINE_FUNCTION(CK_RV, C_DigestInit)(
CK_SESSION_HANDLE hSession,
CK_MECHANISM_PTR pMechanism
);
C_DigestInit initializes a message-digesting operation. hSession is the session’s handle; pMechanism points to the digesting mechanism.
After calling C_DigestInit, the application can either call C_Digest to digest data in a single part; or call C_DigestUpdate zero or more times, followed by C_DigestFinal, to digest data in multiple parts. The message-digesting operation is active until the application uses a call to C_Digest or C_DigestFinal to actually obtain the final piece of ciphertext. To process additional data (in single or multiple parts), the application must call C_DigestInit again.
Return values: 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_MECHANISM_INVALID, CKR_MECHANISM_PARAM_INVALID, CKR_OK, CKR_OPERATION_ACTIVE, CKR_SESSION_CLOSED, CKR_SESSION_HANDLE_INVALID, CKR_USER_NOT_LOGGED_IN.
Example: see C_DigestFinal.
  • C_Digest


CK_DEFINE_FUNCTION(CK_RV, C_Digest)(
CK_SESSION_HANDLE hSession,
CK_BYTE_PTR pData,
CK_ULONG ulDataLen,
CK_BYTE_PTR pDigest,
CK_ULONG_PTR pulDigestLen
);
C_Digest digests data in a single part. hSession is the session’s handle, pData points to the data; ulDataLen is the length of the data; pDigest points to the location that receives the message digest; pulDigestLen points to the location that holds the length of the message digest.
C_Digest uses the convention described in Section on producing output.
The digest operation must have been initialized with C_DigestInit. A call to C_Digest 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.
The input data and digest output can be in the same place, i.e., it is OK if pData and pDigest point to the same location.

Download 360.55 Kb.

Share with your friends:
1   ...   103   104   105   106   107   108   109   110   ...   196




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

    Main page