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 13 #ifndef TEE_CLIENT_CONSTANTS_H 14 #define TEE_CLIENT_CONSTANTS_H 15 /** 16 * @addtogroup TeeClient 17 * @{ 18 * 19 * @brief Provides APIs for the client applications (CAs) in the Rich Execution Environment (normal mode) to 20 * access the trusted applications (TAs) in a Trusted Execution Environment (TEE). 21 * 22 * @syscap SystemCapability.Tee.TeeClient 23 * @since 9 24 * @version 1.0 25 */ 26 27 /** 28 * @file tee_client_constants.h 29 * 30 * @brief Defines public data and constants. 31 * 32 * @since 9 33 * @version 1.0 34 */ 35 36 /** 37 * @brief Defines the number of <b>TEEC_Parameter</b>s in <b>TEEC_Operation</b>. 38 * 39 * @since 9 40 * @version 1.0 41 */ 42 #define TEEC_PARAM_NUM 4 43 44 /** 45 * @brief Defines the error codes returned. 46 * 47 * @since 9 48 * @version 1.0 49 */ 50 enum TEEC_ReturnCode { 51 /** The operation is successful. */ 52 TEEC_SUCCESS = 0x0, 53 /** Invalid command. The command is not supported by the TA. */ 54 TEEC_ERROR_INVALID_CMD, 55 /** The TA does not exist. */ 56 TEEC_ERROR_SERVICE_NOT_EXIST, 57 /** The session between the CA and TA does not exist. */ 58 TEEC_ERROR_SESSION_NOT_EXIST, 59 /** The number of connections to the TA has reached the limit. */ 60 TEEC_ERROR_SESSION_MAXIMUM, 61 /** The TA to be registered already exists. */ 62 TEEC_ERROR_REGISTER_EXIST_SERVICE, 63 /** Secure OS framework error. */ 64 TEEC_ERROR_TAGET_DEAD_FATAL, 65 /** Failed to read the file. */ 66 TEEC_ERROR_READ_DATA, 67 /** Failed to write the file. */ 68 TEEC_ERROR_WRITE_DATA, 69 /** Failed to truncate the file. */ 70 TEEC_ERROR_TRUNCATE_OBJECT, 71 /** Failed to seek data. */ 72 TEEC_ERROR_SEEK_DATA, 73 /** File synchronization error. */ 74 TEEC_ERROR_FSYNC_DATA, 75 /** Failed to rename the file. */ 76 TEEC_ERROR_RENAME_OBJECT, 77 /** Failed to load the TA when opening a session. */ 78 TEEC_ERROR_TRUSTED_APP_LOAD_ERROR, 79 /** Failed to initialize the TA. */ 80 TEEC_ERROR_GENERIC = 0xFFFF0000, 81 /** Permission verification failed. Permission verification is performed before a TEE or session is opened or a command is sent. */ 82 TEEC_ERROR_ACCESS_DENIED = 0xFFFF0001, 83 /** The operation is canceled. This error code is returned when you operate the parameter with the cancallation flag. */ 84 TEEC_ERROR_CANCEL = 0xFFFF0002, 85 /** Concurrent access causes permission conflict. Concurrent access to files in the trusted storage service may cause this error. */ 86 TEEC_ERROR_ACCESS_CONFLICT = 0xFFFF0003, 87 /** Too much data is passed in the requested operation for the TA to parse. */ 88 TEEC_ERROR_EXCESS_DATA = 0xFFFF0004, 89 /** Incorrect data format. The TA failed to parse the parameters sent from the CA. */ 90 TEEC_ERROR_BAD_FORMAT = 0xFFFF0005, 91 /** Invalid parameter. The input parameter is null or invalid. */ 92 TEEC_ERROR_BAD_PARAMETERS = 0xFFFF0006, 93 /** The operation in the current state is invalid. This error code is returned if the trusted storage service is not initialized when a trusted storage service operation is requested. */ 94 TEEC_ERROR_BAD_STATE = 0xFFFF0007, 95 /** The requested data is not found. */ 96 TEEC_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, 97 /** The requested operation has not been implemented yet. This error code is returned when <b>TEEC_RequestCancellation</b> is called. */ 98 TEEC_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, 99 /** The requested operation is valid but is not supported in this implementation. This error code is returned when certain algorithms of the secure encryption and decryption service, such as DSA, are requested. */ 100 TEEC_ERROR_NOT_SUPPORTED = 0xFFFF000A, 101 /** Expected data for the requested operation is not found. */ 102 TEEC_ERROR_NO_DATA = 0xFFFF000B, 103 /** The available system resources are insufficient. */ 104 TEEC_ERROR_OUT_OF_MEMORY = 0xFFFF000C, 105 /** The system is busy. Some resources are exclusively used by the system. */ 106 TEEC_ERROR_BUSY = 0xFFFF000D, 107 /** Communication between an application in the REE and a TA failed. */ 108 TEEC_ERROR_COMMUNICATION = 0xFFFF000E, 109 /** A security fault is detected in the TEE. */ 110 TEEC_ERROR_SECURITY = 0xFFFF000F, 111 /** The supplied buffer is too short for the output generated. This error may occur when {@code TEEC_MEMREF_TEMP_OUTPUT} is used. */ 112 TEEC_ERROR_SHORT_BUFFER = 0xFFFF0010, 113 /** MAC value check error. */ 114 TEEC_ERROR_MAC_INVALID = 0xFFFF3071, 115 /** The TA crashed. */ 116 TEEC_ERROR_TARGET_DEAD = 0xFFFF3024, 117 /** Common error. */ 118 TEEC_FAIL = 0xFFFF5002 119 }; 120 121 /** 122 * @brief Defines the sources of the error codes returned. 123 * 124 * @since 9 125 * @version 1.0 126 */ 127 enum TEEC_ReturnCodeOrigin { 128 /** The error code indicates an error originated from the client API. */ 129 TEEC_ORIGIN_API = 0x1, 130 /** The error code indicates an error originated from the communication between the REE and TEE. */ 131 TEEC_ORIGIN_COMMS = 0x2, 132 /** The error code indicates an error originated within the TEE code. */ 133 TEEC_ORIGIN_TEE = 0x3, 134 /** The error code indicates an error originated within the TA code. */ 135 TEEC_ORIGIN_TRUSTED_APP = 0x4, 136 }; 137 138 /** 139 * @brief Defines the identifiers of the shared memory. 140 * 141 * @since 9 142 * @version 1.0 143 */ 144 enum TEEC_SharedMemCtl { 145 /** The shared memory can carry data from CAs to TAs. */ 146 TEEC_MEM_INPUT = 0x1, 147 /** The shared memory can carry data from TAs to CAs. */ 148 TEEC_MEM_OUTPUT = 0x2, 149 /** The shared memory can carry data transmitted between CAs and TAs. */ 150 TEEC_MEM_INOUT = 0x3, 151 }; 152 153 /** 154 * @brief Defines the parameter types. 155 * 156 * @since 9 157 * @version 1.0 158 */ 159 enum TEEC_ParamType { 160 /** The parameter is not used. */ 161 TEEC_NONE = 0x0, 162 /** The parameter is a {@code TEEC_Value} tagged as input. Data flows from a CA to a TA. */ 163 TEEC_VALUE_INPUT = 0x01, 164 /** The parameter is a {@code TEEC_Value} tagged as output. Data flows from a TA to a CA. */ 165 TEEC_VALUE_OUTPUT = 0x02, 166 /** The parameter is a {@code TEEC_Value} tagged as both input and output. */ 167 TEEC_VALUE_INOUT = 0x03, 168 /** The parameter is a {@code TEEC_TempMemoryReference} tagged as input. Data flows from a CA to a TA. */ 169 TEEC_MEMREF_TEMP_INPUT = 0x05, 170 /** The parameter is a {@code TEEC_TempMemoryReference} tagged as output. Data flows from a TA to a CA. */ 171 TEEC_MEMREF_TEMP_OUTPUT = 0x06, 172 /** The parameter is a {@code TEEC_TempMemoryReference} tagged as both input and output. Data is transmitted between a TA and a CA. */ 173 TEEC_MEMREF_TEMP_INOUT = 0x07, 174 /** The parameter is a {@code TEEC_IonReference} tagged as input. Data flows from a CA to a TA**/ 175 TEEC_ION_INPUT = 0x08, 176 /** The parameter is a {@code TEEC_IonSglistReference} tagged as input. Data flows from a CA to a TA**/ 177 TEEC_ION_SGLIST_INPUT = 0x09, 178 /** The parameter is a {@code TEEC_RegisteredMemoryReference} that refers to the entire memory block. The data flow is the same as that of {@code TEEC_SharedMemCtl}. */ 179 TEEC_MEMREF_WHOLE = 0xc, 180 /** The parameter is a {@code TEEC_RegisteredMemoryReference} tagged as input. Data flows from a CA to a TA. */ 181 TEEC_MEMREF_PARTIAL_INPUT = 0xd, 182 /** The parameter is a {@code TEEC_RegisteredMemoryReference} tagged as output. Data flows from a TA to a CA. */ 183 TEEC_MEMREF_PARTIAL_OUTPUT = 0xe, 184 /** The parameter is a {@code TEEC_RegisteredMemoryReference} tagged as both input and output. Data is transmitted between a TA and a CA. */ 185 TEEC_MEMREF_PARTIAL_INOUT = 0xf 186 }; 187 188 /** 189 * @brief Defines the login methods. 190 * 191 * @since 9 192 * @version 1.0 193 */ 194 enum TEEC_LoginMethod { 195 /** No login data is provided. */ 196 TEEC_LOGIN_PUBLIC = 0x0, 197 /** The login data about the user running the CA process is provided. */ 198 TEEC_LOGIN_USER, 199 /** The login data about the group running the CA process is provided. */ 200 TEEC_LOGIN_GROUP, 201 /** The login data about the running CA is provided. */ 202 TEEC_LOGIN_APPLICATION = 0x4, 203 /** The login data about the user running the CA process and about the CA are provided. */ 204 TEEC_LOGIN_USER_APPLICATION = 0x5, 205 /** The login data about the group running the CA process and about the CA are provided. */ 206 TEEC_LOGIN_GROUP_APPLICATION = 0x6, 207 /** Login method reserved for TEEOS. */ 208 TEEC_LOGIN_IDENTIFY = 0x7, 209 }; 210 211 /** @} */ 212 #endif 213