Skip to content

Commit

Permalink
ta: pkcs11: define TA commands related to session management
Browse files Browse the repository at this point in the history
Define commands PKCS11_CMD_CLOSE_SESSION, PKCS11_CMD_CLOSE_SESSION,
PKCS11_CMD_CLOSE_SESSION and PKCS11_CMD_CLOSE_SESSION and related
resources in the PKCS11 TA API.

Signed-off-by: Etienne Carriere <[email protected]>
Acked-by: Jens Wiklander <[email protected]>
Acked-by: Rouven Czerwinski <[email protected]>
  • Loading branch information
etienne-lms authored and jforissier committed Mar 27, 2020
1 parent db49848 commit aaa6cf9
Showing 1 changed file with 74 additions and 0 deletions.
74 changes: 74 additions & 0 deletions ta/pkcs11/include/pkcs11_ta.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,52 @@ enum pkcs11_ta_cmd {
* C_GetMechanismInfo().
*/
PKCS11_CMD_MECHANISM_INFO = 5,

/*
* PKCS11_CMD_OPEN_SESSION - Open a session
*
* [in] memref[0] = [
* 32bit slot ID,
* 32bit session flags,
* ]
* [out] memref[0] = 32bit return code, enum pkcs11_rc
* [out] memref[2] = 32bit session handle
*
* This command relates to the PKCS#11 API function C_OpenSession().
*/
PKCS11_CMD_OPEN_SESSION = 6,

/*
* PKCS11_CMD_CLOSE_SESSION - Close an opened session
*
* [in] memref[0] = 32bit session handle
* [out] memref[0] = 32bit return code, enum pkcs11_rc
*
* This command relates to the PKCS#11 API function C_CloseSession().
*/
PKCS11_CMD_CLOSE_SESSION = 7,

/*
* PKCS11_CMD_CLOSE_ALL_SESSIONS - Close all client sessions on token
*
* [in] memref[0] = 32bit slot ID
* [out] memref[0] = 32bit return code, enum pkcs11_rc
*
* This command relates to the PKCS#11 API function
* C_CloseAllSessions().
*/
PKCS11_CMD_CLOSE_ALL_SESSIONS = 8,

/*
* PKCS11_CMD_SESSION_INFO - Get Cryptoki information on a session
*
* [in] memref[0] = 32bit session handle
* [out] memref[0] = 32bit return code, enum pkcs11_rc
* [out] memref[2] = (struct pkcs11_session_info)info
*
* This command relates to the PKCS#11 API function C_GetSessionInfo().
*/
PKCS11_CMD_SESSION_INFO = 9,
};

/*
Expand Down Expand Up @@ -289,6 +335,34 @@ enum pkcs11_user_type {
PKCS11_CKU_CONTEXT_SPECIFIC = 0x002,
};

/*
* Values for 32bit session flags argument to PKCS11_CMD_OPEN_SESSION
* and pkcs11_session_info::flags.
* PKCS11_CKFSS_<x> reflects CryptoKi client API session flags CKF_<x>.
*/
#define PKCS11_CKFSS_RW_SESSION (1U << 1)
#define PKCS11_CKFSS_SERIAL_SESSION (1U << 2)

/*
* Arguments for PKCS11_CMD_SESSION_INFO
*/

struct pkcs11_session_info {
uint32_t slot_id;
uint32_t state;
uint32_t flags;
uint32_t device_error;
};

/* Valid values for pkcs11_session_info::state */
enum pkcs11_session_state {
PKCS11_CKS_RO_PUBLIC_SESSION = 0,
PKCS11_CKS_RO_USER_FUNCTIONS = 1,
PKCS11_CKS_RW_PUBLIC_SESSION = 2,
PKCS11_CKS_RW_USER_FUNCTIONS = 3,
PKCS11_CKS_RW_SO_FUNCTIONS = 4,
};

/*
* Arguments for PKCS11_CMD_MECHANISM_INFO
*/
Expand Down

0 comments on commit aaa6cf9

Please sign in to comment.