Use case: Initialising a token
Description
This use case describes the steps taken internally within SoftHSM v2 to initialise a token when a caller of the library calls C_InitToken
Sequence diagram

Steps in the sequence diagram
- An external application calls C_GetSlotList on the PKCS#11 interface
- This triggers a call to the Slot Manager component to obtain a list of available slots
- The PKCS#11 interface component translates this result to PKCS#11 primitives and returns from the call to C_GetSlotList
- The external application calls C_GetTokenInfo on the PKCS#11 interface
- This triggers a call to the Slot Manager component to obtain information about the requested slot
- The PKCS#11 interface component translates the result to PKCS#11 primitives and returns from the call to C_GetTokenInfo
- The external application calls C_InitToken on the PKCS#11 interface
- This triggers a call to the Slot Manager component
- The Slot Manager calls the Secure Object Store to request the creation of a new token
- The Secure Object Store returns a new token object
- The Slot Manager calls the User Manager to set a new SO PIN on the newly created token
- The User Manager calls the Crypto Abstraction to hash the SO PIN
- The User Manager calls the Secure Object Store to store the hashed SO PIN
- The call to C_InitToken on the PKCS#11 interface returns succesfully
- The external application calls C_OpenSession to open a session to the new token in the specified slot
- The PKCS#11 interface calls the Session Manager to open a session
- The Session Manager calls the Slot Manager to check if a token is present in the specified slot
- The Slot Manager calls the Secure Object Store to check if a token is present
- The call to C_OpenSession returns succesfully
- The external application calls C_Login to login with the SO PIN
- The PKCS#11 interface calls the Session Manager to log the session in
- The Session Manager calls the User Manager to verify the PIN
- The call to C_Login returns successfully
- The external application calls C_InitPIN to initialise the user PIN
- The PKCS#11 interface calls the Session Manager to initialise the PIN for the token in that session
- The Session Manager calls the User Manager to initialise the user PIN
- The User Manager calls the Crypto Abstraction to hash the user PIN
- The User Manager calls the Secure Object Store to store the hashed PIN
- The User Manager calls the Secure Data Manager to create a new secret key derived from the PIN
- The Secure Data Manager derives a new key from the PIN using the Crypto Abstraction
- The Secure Data Manager generates a new secret key which it encrypts using the key derived from the PIN
- The Secure Data Manager returns the encrypted key which is stored by the User Manager in the Secure Object Store
- The call to C_InitPIN returns successfully