1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2018-2020, Linaro Limited 4 */ 5 6 #ifndef PKCS11_HELPERS_H 7 #define PKCS11_HELPERS_H 8 9 #include <stdint.h> 10 #include <stddef.h> 11 12 #include <token_capabilities.h> 13 14 /* 15 * TEE invocation parameter#0 is an in/out buffer of at least 32bit 16 * to store the TA PKCS#11 compliant return value. 17 */ 18 #define TEE_PARAM0_SIZE_MIN sizeof(uint32_t) 19 20 /* GPD TEE to PKCS11 status conversion */ 21 enum pkcs11_rc tee2pkcs_error(TEE_Result res); 22 23 #if CFG_TEE_TA_LOG_LEVEL > 0 24 /* Id-to-string conversions only for trace support */ 25 const char *id2str_ta_cmd(uint32_t id); 26 const char *id2str_rc(uint32_t id); 27 const char *id2str_slot_flag(uint32_t id); 28 const char *id2str_token_flag(uint32_t id); 29 const char *id2str_session_flag(uint32_t id); 30 const char *id2str_session_state(uint32_t id); 31 32 static inline const char *id2str_mechanism(enum pkcs11_mechanism_id id) 33 { 34 return mechanism_string_id(id); 35 } 36 #endif /* CFG_TEE_TA_LOG_LEVEL > 0 */ 37 #endif /*PKCS11_HELPERS_H*/ 38