• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License"),
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup TeeTrusted
18  * @{
19  *
20  * @brief TEE(Trusted Excution Environment) API.
21  * Provides security capability APIs such as trusted storage, encryption and decryption,
22  * and trusted time for trusted application development.
23  *
24  * @since 20
25  */
26 
27  /**
28  * @file tee_core_api.h
29  *
30  * @brief Provides APIs for managing trusted application (TA) sessions.
31  *
32  * @library NA
33  * @kit TEEKit
34  * @syscap SystemCapability.Tee.TeeClient
35  * @since 20
36  */
37 
38 #ifndef __TEE_CORE_API_H
39 #define __TEE_CORE_API_H
40 
41 #include "tee_defines.h"
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #ifndef _TEE_TA_SESSION_HANDLE
48 /**
49  * @brief Represents the handle for a Trusted Application session.
50  *
51  * @since 20
52  */
53 #define _TEE_TA_SESSION_HANDLE
54 
55 /**
56  * @brief Defines the handle of TA session.
57  *
58  * @since 20
59  */
60 typedef uint32_t TEE_TASessionHandle;
61 #endif
62 
63 /**
64  * @brief Raises a panic in the TA instance.
65  *
66  * @param panicCode Indicates an informative panic code defined by the TA.
67  *
68  * @since 20
69  */
70 void TEE_Panic(TEE_Result panicCode);
71 
72 /**
73  * @brief Opens a new session with a TA.
74  *
75  * @param destination Indicates the pointer to the <b>TEE_UUID</b> structure that contains
76  * the Universal Unique Identifier (UUID) of the target TA.
77  * @param cancellationRequestTimeout Indicates the timeout period in milliseconds or a special value
78  * if there is no timeout.
79  * @param paramTypes Indicates the types of all parameters passed in the operation.
80  * @param params Indicates the parameters passed in the operation.
81  * @param session Indicates the pointer to the variable that will receive the client session handle.
82  * @param returnOrigin Indicates the pointer to the variable that holds the return origin.
83  *
84  * @return Returns <b>TEE_SUCCESS</b> if the session is opened.
85  *         Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the TA cannot be found in the Trusted Execution Environment (TEE).
86  *         Returns <b>TEE_ERROR_ACCESS_DENIED</b> if the access request to the TA is denied.
87  *
88  * @since 20
89  */
90 TEE_Result TEE_OpenTASession(const TEE_UUID *destination, uint32_t cancellationRequestTimeout, uint32_t paramTypes,
91                              TEE_Param params[TEE_PARAMS_NUM], TEE_TASessionHandle *session, uint32_t *returnOrigin);
92 
93 /**
94  * @brief Closes a client session.
95  *
96  * @param session Indicates the handle of the session to close.
97  *
98  * @since 20
99  */
100 void TEE_CloseTASession(TEE_TASessionHandle session);
101 
102 /**
103  * @brief Invokes a command in a session opened between this client TA instance and a target TA instance.
104  *
105  * @param session Indicates the handle of the opened session.
106  * @param cancellationRequestTimeout Indicates the timeout period in milliseconds or a special value
107  * if there is no timeout.
108  * @param commandID Indicates the identifier of the command to invoke.
109  * @param paramTypes Indicates the types of all parameters passed in the operation.
110  * @param params Indicates the parameters passed in the operation.
111  * @param returnOrigin Indicates the pointer to the variable that holds the return origin.
112  *
113  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
114  *         Returns <b>TEE_ERROR_ACCESS_DENIED</b> if the command fails to be invoked.
115  *
116  * @since 20
117  */
118 TEE_Result TEE_InvokeTACommand(TEE_TASessionHandle session, uint32_t cancellationRequestTimeout, uint32_t commandID,
119                                uint32_t paramTypes, TEE_Param params[TEE_PARAMS_NUM], uint32_t *returnOrigin);
120 
121 #ifdef __cplusplus
122 }
123 #endif
124 
125 #endif
126 /** @} */