1 /* 2 * Copyright (C) 2022 Huawei Technologies Co., Ltd. 3 * Licensed under the Mulan PSL v2. 4 * You can use this software according to the terms and conditions of the Mulan PSL v2. 5 * You may obtain a copy of Mulan PSL v2 at: 6 * http://license.coscl.org.cn/MulanPSL2 7 * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR 8 * IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR 9 * PURPOSE. 10 * See the Mulan PSL v2 for more details. 11 */ 12 #ifndef PERM_SRV_TA_CONFIG_H 13 #define PERM_SRV_TA_CONFIG_H 14 15 #include <dlist.h> 16 #include <stddef.h> 17 #include <tee_defines.h> 18 #include <ta_config_builder.h> 19 #include "permission_service.h" 20 #include "tee_elf_verify.h" 21 22 #define PERMSRV_OK 0 23 #define PERMSRV_ERROR (-1) 24 25 struct task_config { 26 uint32_t taskid; 27 uint32_t userid; 28 struct dlist_node head; 29 }; 30 31 struct perm_config { 32 const uint8_t *tlv_buf; 33 uint32_t tlv_len; 34 uint32_t policy_version; 35 uint8_t cn[SN_MAX_SIZE]; 36 size_t cn_size; 37 ta_cert_t cert_type; 38 }; 39 40 /* define TAG values for TLV Parser */ 41 #define TLV_TAG_CONFIG_INFO 0x00 42 #define TLV_TAG_TA_BASIC_INFO 0x01 43 #define TLV_TAG_TA_MANIFEST_INFO 0x02 44 #define TLV_TAG_TA_CONTROL_INFO 0x03 45 46 #define TLV_TAG_CALLEETA_INFO 0x04 47 #define TLV_TAG_SFS_INFO 0x32 48 #define TLV_TAG_SE_INFO 0x33 49 #define TLV_TAG_DEBUG_INFO 0x35 50 #define TLV_TAG_CERT_INFO 0x36 51 52 #define TLV_TAG_SFS_PERMISSION 0x72 53 #define TLV_TAG_CERT_PERMISSION 0x73 54 #define TLV_TAG_CALLEETA_UUID 0x41 55 56 #define TLV_TAG_UUID (0x01 + 0xFF) 57 #define TLV_TAG_SERVICE_NAME (0x02 + 0xFF) 58 #define TLV_TAG_SINGLE_INSTANCE (0x11 + 0xFF) 59 #define TLV_TAG_MULTI_SESSION (0x12 + 0xFF) 60 #define TLV_TAG_MULTI_COMMAND (0x13 + 0xFF) 61 #define TLV_TAG_HEAP_SIZE (0x14 + 0xFF) 62 #define TLV_TAG_STACK_SIZE (0x15 + 0xFF) 63 #define TLV_TAG_INSTANCE_KEEP_ALIVE (0x16 + 0xFF) 64 #define TLV_TAG_MEM_PAGE_ALIGN (0x17 + 0xFF) 65 #define TLV_TAG_TARGET_TYPE (0x18 + 0xFF) 66 #define TLV_TAG_SYS_VERIFY_TA (0x19 + 0xFF) 67 #define TLV_TAG_SFS_PROVISION_KEY (0x31 + 0xFF) 68 #define TLV_TAG_SFS_INSE (0x32 + 0xFF) 69 #define TLV_TAG_SE_OPEN_SESSION (0x41 + 0xFF) 70 #define TLV_TAG_TA_MANAGER (0x71 + 0xFF) 71 #define TLV_TAG_CALLEETA_COMMAND_ID (0x81 + 0xFF) 72 #define TLV_TAG_DEBUG_STATUS (0x51 + 0xFF) 73 #define TLV_TAG_DEBUG_DEVICE_ID (0x52 + 0xFF) 74 75 TEE_Result perm_srv_parse_config_body(const TEE_UUID *uuid, struct perm_config *perm_config); 76 TEE_Result perm_srv_get_config_by_uuid(const TEE_UUID *uuid, struct config_info *config); 77 TEE_Result perm_srv_convert_uuid_to_str(const TEE_UUID *uuid, char *buff, uint32_t len); 78 TEE_Result perm_srv_get_config_by_taskid(uint32_t taskid, struct config_info *config); 79 void perm_srv_clear_ta_permissions(const TEE_UUID *uuid); 80 TEE_Result perm_srv_register_ta_taskid(const TEE_UUID *uuid, uint32_t taskid, uint32_t userid); 81 TEE_Result perm_srv_unregister_ta_taskid(const TEE_UUID *uuid, uint32_t taskid); 82 #endif 83