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 uint32_t size; 53 } memref; 54 struct { 55 uint32_t a; 56 uint32_t b; 57 } value; 58 } TEE_Param; 59 60 /* 61 * The type of opaque handles on TA Session. These handles are returned by 62 * the function TEE_OpenTASession. 63 */ 64 typedef struct __TEE_TASessionHandle *TEE_TASessionHandle; 65 66 /* 67 * The type of opaque handles on property sets or enumerators. These 68 * handles are either one of the pseudo handles TEE_PROPSET_XXX or are 69 * returned by the function TEE_AllocatePropertyEnumerator. 70 */ 71 typedef struct __TEE_PropSetHandle *TEE_PropSetHandle; 72 73 typedef struct __TEE_ObjectHandle *TEE_ObjectHandle; 74 typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; 75 typedef struct __TEE_OperationHandle *TEE_OperationHandle; 76 77 /* 78 * Storage Definitions 79 */ 80 81 typedef uint32_t TEE_ObjectType; 82 83 typedef struct { 84 uint32_t objectType; 85 __extension__ union { 86 uint32_t keySize; /* used in 1.1 spec */ 87 uint32_t objectSize; /* used in 1.1.1 spec */ 88 }; 89 __extension__ union { 90 uint32_t maxKeySize; /* used in 1.1 spec */ 91 uint32_t maxObjectSize; /* used in 1.1.1 spec */ 92 }; 93 uint32_t objectUsage; 94 uint32_t dataSize; 95 uint32_t dataPosition; 96 uint32_t handleFlags; 97 } TEE_ObjectInfo; 98 99 typedef enum { 100 TEE_DATA_SEEK_SET = 0, 101 TEE_DATA_SEEK_CUR = 1, 102 TEE_DATA_SEEK_END = 2 103 } TEE_Whence; 104 105 typedef struct { 106 uint32_t attributeID; 107 union { 108 struct { 109 void *buffer; 110 uint32_t length; 111 } ref; 112 struct { 113 uint32_t a, b; 114 } value; 115 } content; 116 } TEE_Attribute; 117 118 /* Cryptographic Operations API */ 119 120 typedef enum { 121 TEE_MODE_ENCRYPT = 0, 122 TEE_MODE_DECRYPT = 1, 123 TEE_MODE_SIGN = 2, 124 TEE_MODE_VERIFY = 3, 125 TEE_MODE_MAC = 4, 126 TEE_MODE_DIGEST = 5, 127 TEE_MODE_DERIVE = 6 128 } TEE_OperationMode; 129 130 typedef struct { 131 uint32_t algorithm; 132 uint32_t operationClass; 133 uint32_t mode; 134 uint32_t digestLength; 135 uint32_t maxKeySize; 136 uint32_t keySize; 137 uint32_t requiredKeyUsage; 138 uint32_t handleState; 139 } TEE_OperationInfo; 140 141 typedef struct { 142 uint32_t keySize; 143 uint32_t requiredKeyUsage; 144 } TEE_OperationInfoKey; 145 146 typedef struct { 147 uint32_t algorithm; 148 uint32_t operationClass; 149 uint32_t mode; 150 uint32_t digestLength; 151 uint32_t maxKeySize; 152 uint32_t handleState; 153 uint32_t operationState; 154 uint32_t numberOfKeys; 155 TEE_OperationInfoKey keyInformation[]; 156 } TEE_OperationInfoMultiple; 157 158 /* Time & Date API */ 159 160 typedef struct { 161 uint32_t seconds; 162 uint32_t millis; 163 } TEE_Time; 164 165 /* TEE Arithmetical APIs */ 166 167 typedef uint32_t TEE_BigInt; 168 169 typedef uint32_t TEE_BigIntFMM; 170 171 typedef uint32_t TEE_BigIntFMMContext __aligned(__alignof__(void *)); 172 173 /* Tee Secure Element APIs */ 174 175 typedef struct __TEE_SEServiceHandle *TEE_SEServiceHandle; 176 typedef struct __TEE_SEReaderHandle *TEE_SEReaderHandle; 177 typedef struct __TEE_SESessionHandle *TEE_SESessionHandle; 178 typedef struct __TEE_SEChannelHandle *TEE_SEChannelHandle; 179 180 typedef struct { 181 bool sePresent; 182 bool teeOnly; 183 bool selectResponseEnable; 184 } TEE_SEReaderProperties; 185 186 typedef struct { 187 uint8_t *buffer; 188 size_t bufferLen; 189 } TEE_SEAID; 190 191 /* Other definitions */ 192 typedef uint32_t TEE_ErrorOrigin; 193 typedef void *TEE_Session; 194 195 #define TEE_MEM_INPUT 0x00000001 196 #define TEE_MEM_OUTPUT 0x00000002 197 198 #define TEE_MEMREF_0_USED 0x00000001 199 #define TEE_MEMREF_1_USED 0x00000002 200 #define TEE_MEMREF_2_USED 0x00000004 201 #define TEE_MEMREF_3_USED 0x00000008 202 203 #define TEE_SE_READER_NAME_MAX 20 204 205 #endif /* TEE_API_TYPES_H */ 206