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 TEE_ELF_VERIFY_H 13 #define TEE_ELF_VERIFY_H 14 15 #include <ta_lib_img_unpack.h> 16 #include "tee_defines.h" 17 #include "ta_framework.h" 18 19 #define SN_MAX_SIZE 64 20 #define ISSUER_MAX_SIZE 256 21 22 typedef struct { 23 uint32_t version; 24 uint32_t img_size; 25 char tmp_file[MAX_TAFS_NAME_LEN]; 26 } __attribute__((__packed__)) elf_verify_req; 27 28 typedef struct { 29 char service_name[SERVICE_NAME_MAX_IN_MANIFEST]; 30 uint32_t service_name_len; 31 TEE_UUID srv_uuid; 32 manifest_extension_t mani_ext; 33 ta_property_t ta_property; 34 ta_payload_hdr_t payload_hdr; 35 int32_t off_manifest_buf; 36 int32_t off_ta_elf; 37 TEE_Result verify_result; 38 bool conf_registed; 39 bool dyn_conf_registed; 40 } elf_verify_reply; 41 42 typedef struct { 43 uint8_t *elf_hash; 44 uint32_t hash_size; 45 } elf_hash_data; 46 #define MAX_IMAGE_HASH_SIZE 64 47 48 struct cert_subjects { 49 uint8_t cn[SN_MAX_SIZE]; 50 uint32_t cn_size; 51 uint8_t ou[SN_MAX_SIZE]; 52 uint32_t ou_size; 53 }; 54 55 TEE_Result secure_elf_verify(const elf_verify_req *req, elf_verify_reply *rep); 56 57 TEE_Result tee_secure_img_parse_manifest_v3(const uint8_t *manifest_ext, uint32_t *ext_size, 58 bool control, const uint32_t config_target_type); 59 60 #endif 61