1 /* SPDX-License-Identifier: BSD-2-Clause */ 2 /* 3 * Copyright (c) 2014, STMicroelectronics International N.V. 4 */ 5 6 /* Based on GP TEE Internal API Specification Version 0.11 */ 7 #ifndef TEE_API_TYPES_H 8 #define TEE_API_TYPES_H 9 10 #include <compiler.h> 11 #include <inttypes.h> 12 #include <stdbool.h> 13 #include <stddef.h> 14 #include <tee_api_defines.h> 15 16 /* 17 * Common Definitions 18 */ 19 20 typedef uint32_t TEE_Result; 21 22 typedef struct { 23 uint32_t timeLow; 24 uint16_t timeMid; 25 uint16_t timeHiAndVersion; 26 uint8_t clockSeqAndNode[8]; 27 } TEE_UUID; 28 29 /* 30 * The TEE_Identity structure defines the full identity of a Client: 31 * - login is one of the TEE_LOGIN_XXX constants 32 * - uuid contains the client UUID or Nil if not applicable 33 */ 34 typedef struct { 35 uint32_t login; 36 TEE_UUID uuid; 37 } TEE_Identity; 38 39 /* 40 * This union describes one parameter passed by the Trusted Core Framework 41 * to the entry points TA_OpenSessionEntryPoint or 42 * TA_InvokeCommandEntryPoint or by the TA to the functions 43 * TEE_OpenTASession or TEE_InvokeTACommand. 44 * 45 * Which of the field value or memref to select is determined by the 46 * parameter type specified in the argument paramTypes passed to the entry 47 * point. 48 */ 49 typedef union { 50 struct { 51 void *buffer; 52 size_t size; 53 } memref; 54 struct { 55 uint32_t a; 56 uint32_t b; 57 } value; 58 } TEE_Param; 59 60 typedef union { 61 struct { 62 void *buffer; 63 uint32_t size; 64 } memref; 65 struct { 66 uint32_t a; 67 uint32_t b; 68 } value; 69 } __GP11_TEE_Param; 70 71 /* 72 * The type of opaque handles on TA Session. These handles are returned by 73 * the function TEE_OpenTASession. 74 */ 75 typedef struct __TEE_TASessionHandle *TEE_TASessionHandle; 76 77 /* 78 * The type of opaque handles on property sets or enumerators. These 79 * handles are either one of the pseudo handles TEE_PROPSET_XXX or are 80 * returned by the function TEE_AllocatePropertyEnumerator. 81 */ 82 typedef struct __TEE_PropSetHandle *TEE_PropSetHandle; 83 84 typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; 85 typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; 86 typedef struct __TEE_OperationHandle *TEE_OperationHandle; 87 88 /* 89 * Storage Definitions 90 */ 91 92 typedef uint32_t TEE_ObjectType; 93 94 typedef struct { 95 uint32_t objectType; 96 uint32_t objectSize; 97 uint32_t maxObjectSize; 98 uint32_t objectUsage; 99 size_t dataSize; 100 size_t dataPosition; 101 uint32_t handleFlags; 102 } TEE_ObjectInfo; 103 104 typedef struct { 105 uint32_t objectType; 106 __extension__ union { 107 uint32_t keySize; /* used in 1.1 spec */ 108 uint32_t objectSize; /* used in 1.1.1 spec */ 109 }; 110 __extension__ union { 111 uint32_t maxKeySize; /* used in 1.1 spec */ 112 uint32_t maxObjectSize; /* used in 1.1.1 spec */ 113 }; 114 uint32_t objectUsage; 115 uint32_t dataSize; 116 uint32_t dataPosition; 117 uint32_t handleFlags; 118 } __GP11_TEE_ObjectInfo; 119 120 typedef uint32_t TEE_Whence; 121 122 typedef struct { 123 uint32_t attributeID; 124 union { 125 struct { 126 void *buffer; 127 size_t length; 128 } ref; 129 struct { 130 uint32_t a, b; 131 } value; 132 } content; 133 } TEE_Attribute; 134 135 typedef struct { 136 uint32_t attributeID; 137 union { 138 struct { 139 void *buffer; 140 uint32_t length; 141 } ref; 142 struct { 143 uint32_t a, b; 144 } value; 145 } content; 146 } __GP11_TEE_Attribute; 147 148 /* Cryptographic Operations API */ 149 150 typedef uint32_t TEE_OperationMode; 151 152 typedef struct { 153 uint32_t algorithm; 154 uint32_t operationClass; 155 uint32_t mode; 156 uint32_t digestLength; 157 uint32_t maxKeySize; 158 uint32_t keySize; 159 uint32_t requiredKeyUsage; 160 uint32_t handleState; 161 } TEE_OperationInfo; 162 163 typedef struct { 164 uint32_t keySize; 165 uint32_t requiredKeyUsage; 166 } TEE_OperationInfoKey; 167 168 typedef struct { 169 uint32_t algorithm; 170 uint32_t operationClass; 171 uint32_t mode; 172 uint32_t digestLength; 173 uint32_t maxKeySize; 174 uint32_t handleState; 175 uint32_t operationState; 176 uint32_t numberOfKeys; 177 TEE_OperationInfoKey keyInformation[]; 178 } TEE_OperationInfoMultiple; 179 180 /* Time & Date API */ 181 182 typedef struct { 183 uint32_t seconds; 184 uint32_t millis; 185 } TEE_Time; 186 187 /* TEE Arithmetical APIs */ 188 189 typedef uint32_t TEE_BigInt; 190 191 typedef uint32_t TEE_BigIntFMM; 192 193 typedef uint32_t TEE_BigIntFMMContext; 194 195 /* Tee Secure Element APIs */ 196 197 typedef struct __TEE_SEServiceHandle *TEE_SEServiceHandle; 198 typedef struct __TEE_SEReaderHandle *TEE_SEReaderHandle; 199 typedef struct __TEE_SESessionHandle *TEE_SESessionHandle; 200 typedef struct __TEE_SEChannelHandle *TEE_SEChannelHandle; 201 202 typedef struct { 203 bool sePresent; 204 bool teeOnly; 205 bool selectResponseEnable; 206 } TEE_SEReaderProperties; 207 208 typedef struct { 209 uint8_t *buffer; 210 size_t bufferLen; 211 } TEE_SEAID; 212 213 /* Other definitions */ 214 typedef uint32_t TEE_ErrorOrigin; 215 typedef void *TEE_Session; 216 217 #define TEE_MEM_INPUT 0x00000001 218 #define TEE_MEM_OUTPUT 0x00000002 219 220 #define TEE_MEMREF_0_USED 0x00000001 221 #define TEE_MEMREF_1_USED 0x00000002 222 #define TEE_MEMREF_2_USED 0x00000004 223 #define TEE_MEMREF_3_USED 0x00000008 224 225 #define TEE_SE_READER_NAME_MAX 20 226 227 #endif /* TEE_API_TYPES_H */ 228