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 #include "tee_ext_api.h"
13 #include "tee_log.h"
14 #include "permsrv_api.h"
15 #include "permsrv_api_imp.h"
16 /* follow function for global task */
17
tee_ext_register_ta(const TEE_UUID * uuid,uint32_t task_id,uint32_t user_id)18 void tee_ext_register_ta(const TEE_UUID *uuid, uint32_t task_id, uint32_t user_id)
19 {
20 if (uuid == NULL) {
21 tloge("register TA with NULL uuid\n");
22 return;
23 }
24
25 permsrv_registerta(uuid, task_id, user_id, REGISTER_TA);
26 }
27
tee_ext_unregister_ta(const TEE_UUID * uuid,uint32_t task_id,uint32_t user_id)28 void tee_ext_unregister_ta(const TEE_UUID *uuid, uint32_t task_id, uint32_t user_id)
29 {
30 if (uuid == NULL) {
31 tloge("unregister TA with NULL uuid\n");
32 return;
33 }
34
35 permsrv_registerta(uuid, task_id, user_id, UNREGISTER_TA);
36 }
37
tee_ext_notify_unload_ta(const TEE_UUID * uuid)38 void tee_ext_notify_unload_ta(const TEE_UUID *uuid)
39 {
40 if (uuid == NULL) {
41 tloge("uuid is NULL.\n");
42 return;
43 }
44 permsrv_notify_unload_ta(uuid);
45 }
46
tee_ext_load_file(void)47 void tee_ext_load_file(void)
48 {
49 permsrv_load_file();
50 }
51
tee_ext_crl_cert_process(const char * crl_cert,uint32_t crl_cert_size)52 TEE_Result tee_ext_crl_cert_process(const char *crl_cert, uint32_t crl_cert_size)
53 {
54 TEE_Result ret;
55
56 if (crl_cert == NULL) {
57 tloge("crl cert process bad parameter!\n");
58 return TEE_ERROR_BAD_PARAMETERS;
59 }
60
61 if (crl_cert_size == 0) {
62 tloge("crl cert process bad parameter, size error!\n");
63 return TEE_ERROR_BAD_PARAMETERS;
64 }
65
66 ret = tee_crl_cert_process(crl_cert, crl_cert_size);
67 if (ret != TEE_SUCCESS) {
68 tloge("Failed to do crl cert process\n");
69 return ret;
70 }
71
72 return ret;
73 }
74
tee_ext_elf_verify_req(const void * req,uint32_t len)75 TEE_Result tee_ext_elf_verify_req(const void *req, uint32_t len)
76 {
77 return permsrv_elf_verify(req, len);
78 }
79