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