Skip to content

Commit

Permalink
ta: pkcs11: add mechanism info and session command to helpers
Browse files Browse the repository at this point in the history
Add mechanism info and session management command IDs in debug
helpers of the PKCS11 TA.

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 aaa6cf9 commit d21ec5f
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
29 changes: 29 additions & 0 deletions ta/pkcs11/src/pkcs11_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,12 @@ static const struct any_id __maybe_unused string_ta_cmd[] = {
PKCS11_ID(PKCS11_CMD_SLOT_LIST),
PKCS11_ID(PKCS11_CMD_SLOT_INFO),
PKCS11_ID(PKCS11_CMD_TOKEN_INFO),
PKCS11_ID(PKCS11_CMD_MECHANISM_IDS),
PKCS11_ID(PKCS11_CMD_MECHANISM_INFO),
PKCS11_ID(PKCS11_CMD_OPEN_SESSION),
PKCS11_ID(PKCS11_CMD_SESSION_INFO),
PKCS11_ID(PKCS11_CMD_CLOSE_SESSION),
PKCS11_ID(PKCS11_CMD_CLOSE_ALL_SESSIONS),
};

static const struct any_id __maybe_unused string_slot_flags[] = {
Expand Down Expand Up @@ -94,6 +100,19 @@ static const struct any_id __maybe_unused string_token_flags[] = {
PKCS11_ID(PKCS11_CKFT_ERROR_STATE),
};

static const struct any_id __maybe_unused string_session_flags[] = {
PKCS11_ID(PKCS11_CKFSS_RW_SESSION),
PKCS11_ID(PKCS11_CKFSS_SERIAL_SESSION),
};

static const struct any_id __maybe_unused string_session_state[] = {
PKCS11_ID(PKCS11_CKS_RO_PUBLIC_SESSION),
PKCS11_ID(PKCS11_CKS_RO_USER_FUNCTIONS),
PKCS11_ID(PKCS11_CKS_RW_PUBLIC_SESSION),
PKCS11_ID(PKCS11_CKS_RW_USER_FUNCTIONS),
PKCS11_ID(PKCS11_CKS_RW_SO_FUNCTIONS),
};

static const struct any_id __maybe_unused string_rc[] = {
PKCS11_ID(PKCS11_CKR_OK),
PKCS11_ID(PKCS11_CKR_GENERAL_ERROR),
Expand Down Expand Up @@ -162,4 +181,14 @@ const char *id2str_token_flag(uint32_t id)
{
return ID2STR(id, string_token_flags, "PKCS11_CKFT_");
}

const char *id2str_session_flag(uint32_t id)
{
return ID2STR(id, string_session_flags, "PKCS11_CKFSS_");
}

const char *id2str_session_state(uint32_t id)
{
return ID2STR(id, string_session_state, "PKCS11_CKS_");
}
#endif /*CFG_TEE_TA_LOG_LEVEL*/
3 changes: 3 additions & 0 deletions ta/pkcs11/src/pkcs11_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const char *id2str_ta_cmd(uint32_t id);
const char *id2str_rc(uint32_t id);
const char *id2str_slot_flag(uint32_t id);
const char *id2str_token_flag(uint32_t id);
const char *id2str_session_flag(uint32_t id);
const char *id2str_session_state(uint32_t id);

static inline const char *id2str_mechanism(enum pkcs11_mechanism_id id)
{
return mechanism_string_id(id);
Expand Down

0 comments on commit d21ec5f

Please sign in to comment.