xref: /optee_os/ta/pkcs11/src/pkcs11_helpers.h (revision 5b25c76ac40f830867e3d60800120ffd7874e8dc)
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 #if CFG_TEE_TA_LOG_LEVEL > 0
21 /* Id-to-string conversions only for trace support */
22 const char *id2str_ta_cmd(uint32_t id);
23 const char *id2str_rc(uint32_t id);
24 const char *id2str_slot_flag(uint32_t id);
25 const char *id2str_token_flag(uint32_t id);
26 const char *id2str_session_flag(uint32_t id);
27 const char *id2str_session_state(uint32_t id);
28 
29 static inline const char *id2str_mechanism(enum pkcs11_mechanism_id id)
30 {
31 	return mechanism_string_id(id);
32 }
33 #endif /* CFG_TEE_TA_LOG_LEVEL > 0 */
34 #endif /*PKCS11_HELPERS_H*/
35