@startuml
skinparam classFontSize 8
skinparam classFontName Helvetica
autonumber

participant "Application" as app
participant "PKCS #11" as pkcs

box "PKCS #11 - Creating A Message Digest" #LightBlue
    participant app
    participant pkcs
end box

app -> pkcs: Acquire function list with C_GetFunctionList
pkcs -> app: Return CK_FUNCTION_LIST_PTR with supported functions

app -> pkcs: Initialize with C_Initialize

app -> pkcs: Query for a slot with C_GetSlotList
pkcs -> app: Return an array of CK_SLOT_IDs

app -> pkcs: Open a new session with a slot using C_OpenSession
pkcs -> app: Return a CK_SESSION_HANDLE

app -> pkcs: Log in to current session with C_Login

app -> pkcs: Query for supported mechanisms with C_GetMechanismInfo
pkcs -> app: Return CK_MECHANISM_INFO

app -> pkcs: Start a digest operation using SHA-256 by passing CKM_SHA256 to C_DigestInit
app -> pkcs: Pass bytes buffer of message to C_DigestUpdate
app -> pkcs: Pass bytes buffer for storing the digest to C_DigestFinal
pkcs -> app: Fill buffer with digest bytes

app -> pkcs: Close session with C_CloseSession
app -> pkcs: Uninitialize with C_Finalize

@enduml
