• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 #ifndef __TEE_CORE_API_H
17 #define __TEE_CORE_API_H
18 
19 /**
20  * @addtogroup TeeTrusted
21  * @{
22  *
23  * @brief TEE(Trusted Excution Environment) API.
24  * Provides security capability APIs such as trusted storage, encryption and decryption,
25  * and trusted time for trusted application development.
26  *
27  * @since 12
28  * @version 1.0
29  */
30 
31  /**
32  * @file tee_core_api.h
33  *
34  * @brief Provides APIs for managing trusted application (TA) sessions.
35  *
36  * @library NA
37  * @kit TEE Kit
38  * @syscap SystemCapability.Tee.TeeClient
39  * @since 12
40  * @version 1.0
41  */
42 
43 #include "tee_defines.h"
44 
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48 #ifndef _TEE_TA_SESSION_HANDLE
49 #define _TEE_TA_SESSION_HANDLE
50 /**
51  * @brief Defines the handle of TA session.
52  *
53  * @since 12
54  */
55 typedef uint32_t TEE_TASessionHandle;
56 #endif
57 
58 /**
59  * @brief Raises a panic in the TA instance.
60  *
61  * @param panicCode Indicates an informative panic code defined by the TA.
62  *
63  * @since 12
64  * @version 1.0
65  */
66 void TEE_Panic(TEE_Result panicCode);
67 
68 /**
69  * @brief Opens a new session with a TA.
70  *
71  * @param destination Indicates the pointer to the <b>TEE_UUID</b> structure that contains
72  * the Universal Unique Identifier (UUID) of the target TA.
73  * @param cancellationRequestTimeout Indicates the timeout period in milliseconds or a special value
74  * if there is no timeout.
75  * @param paramTypes Indicates the types of all parameters passed in the operation.
76  * @param params Indicates the parameters passed in the operation.
77  * @param session Indicates the pointer to the variable that will receive the client session handle.
78  * @param returnOrigin Indicates the pointer to the variable that holds the return origin.
79  *
80  * @return Returns <b>TEE_SUCCESS</b> if the session is opened.
81  *         Returns <b>TEE_ERROR_ITEM_NOT_FOUND</b> if the TA cannot be found in the Trusted Execution Environment (TEE).
82  *         Returns <b>TEE_ERROR_ACCESS_DENIED</b> if the access request to the TA is denied.
83  *
84  * @since 12
85  * @version 1.0
86  */
87 TEE_Result TEE_OpenTASession(const TEE_UUID *destination, uint32_t cancellationRequestTimeout, uint32_t paramTypes,
88                              TEE_Param params[TEE_PARAMS_NUM], TEE_TASessionHandle *session, uint32_t *returnOrigin);
89 
90 /**
91  * @brief Closes a client session.
92  *
93  * @param session Indicates the handle of the session to close.
94  *
95  * @since 12
96  * @version 1.0
97  */
98 void TEE_CloseTASession(TEE_TASessionHandle session);
99 
100 /**
101  * @brief Invokes a command in a session opened between this client TA instance and a target TA instance.
102  *
103  * @param session Indicates the handle of the opened session.
104  * @param cancellationRequestTimeout Indicates the timeout period in milliseconds or a special value
105  * if there is no timeout.
106  * @param commandID Indicates the identifier of the command to invoke.
107  * @param paramTypes Indicates the types of all parameters passed in the operation.
108  * @param params Indicates the parameters passed in the operation.
109  * @param returnOrigin Indicates the pointer to the variable that holds the return origin.
110  *
111  * @return Returns <b>TEE_SUCCESS</b> if the operation is successful.
112  *         Returns <b>TEE_ERROR_ACCESS_DENIED</b> if the command fails to be invoked.
113  *
114  * @since 12
115  * @version 1.0
116  */
117 TEE_Result TEE_InvokeTACommand(TEE_TASessionHandle session, uint32_t cancellationRequestTimeout, uint32_t commandID,
118                                uint32_t paramTypes, TEE_Param params[TEE_PARAMS_NUM], uint32_t *returnOrigin);
119 
120 #ifdef __cplusplus
121 }
122 #endif
123 /** @} */
124 #endif
125