1 /* 2 * Copyright 2017, Rockchip Electronics Co., Ltd 3 * hisping lin, <hisping.lin@rock-chips.com> 4 * 5 * SPDX-License-Identifier: GPL-2.0+ 6 */ 7 8 /* Based on GP TEE Internal API Specification Version 0.11 */ 9 #ifndef TEE_API_TYPES_H 10 #define TEE_API_TYPES_H 11 12 #include <optee_include/tee_base_types.h> 13 #include <optee_include/tee_api_defines.h> 14 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 uint32_t keySize; 86 uint32_t maxKeySize; 87 uint32_t objectUsage; 88 uint32_t dataSize; 89 uint32_t dataPosition; 90 uint32_t handleFlags; 91 } TEE_ObjectInfo; 92 93 typedef enum { 94 TEE_DATA_SEEK_SET = 0, 95 TEE_DATA_SEEK_CUR = 1, 96 TEE_DATA_SEEK_END = 2 97 } TEE_Whence; 98 99 typedef struct { 100 uint32_t attributeID; 101 union { 102 struct { 103 void *buffer; 104 uint32_t length; 105 } ref; 106 struct { 107 uint32_t a, b; 108 } value; 109 } content; 110 } TEE_Attribute; 111 112 /* Cryptographic Operations API */ 113 114 typedef enum { 115 TEE_MODE_ENCRYPT = 0, 116 TEE_MODE_DECRYPT = 1, 117 TEE_MODE_SIGN = 2, 118 TEE_MODE_VERIFY = 3, 119 TEE_MODE_MAC = 4, 120 TEE_MODE_DIGEST = 5, 121 TEE_MODE_DERIVE = 6 122 } TEE_OperationMode; 123 124 typedef struct { 125 uint32_t algorithm; 126 uint32_t operationClass; 127 uint32_t mode; 128 uint32_t digestLength; 129 uint32_t maxKeySize; 130 uint32_t keySize; 131 uint32_t requiredKeyUsage; 132 uint32_t handleState; 133 } TEE_OperationInfo; 134 135 typedef struct { 136 uint32_t keySize; 137 uint32_t requiredKeyUsage; 138 } TEE_OperationInfoKey; 139 140 typedef struct { 141 uint32_t algorithm; 142 uint32_t operationClass; 143 uint32_t mode; 144 uint32_t digestLength; 145 uint32_t maxKeySize; 146 uint32_t handleState; 147 uint32_t operationState; 148 uint32_t numberOfKeys; 149 TEE_OperationInfoKey keyInformation[]; 150 } TEE_OperationInfoMultiple; 151 152 /* Time & Date API */ 153 154 typedef struct { 155 uint32_t seconds; 156 uint32_t millis; 157 } TEE_Time; 158 159 /* TEE Arithmetical APIs */ 160 161 typedef uint32_t TEE_BigInt; 162 163 typedef uint32_t TEE_BigIntFMM; 164 165 typedef uint32_t TEE_BigIntFMMContext; 166 167 /* Tee Secure Element APIs */ 168 169 typedef struct __TEE_SEServiceHandle *TEE_SEServiceHandle; 170 typedef struct __TEE_SEReaderHandle *TEE_SEReaderHandle; 171 typedef struct __TEE_SESessionHandle *TEE_SESessionHandle; 172 typedef struct __TEE_SEChannelHandle *TEE_SEChannelHandle; 173 174 typedef struct { 175 bool sePresent; 176 bool teeOnly; 177 bool selectResponseEnable; 178 } TEE_SEReaderProperties; 179 180 typedef struct { 181 uint8_t *buffer; 182 size_t bufferLen; 183 } TEE_SEAID; 184 185 /* Other definitions */ 186 typedef uint32_t TEE_ErrorOrigin; 187 typedef void *TEE_Session; 188 189 #define TEE_MEM_INPUT 0x00000001 190 #define TEE_MEM_OUTPUT 0x00000002 191 192 #define TEE_MEMREF_0_USED 0x00000001 193 #define TEE_MEMREF_1_USED 0x00000002 194 #define TEE_MEMREF_2_USED 0x00000004 195 #define TEE_MEMREF_3_USED 0x00000008 196 197 #define TEE_SE_READER_NAME_MAX 20 198 199 #endif /* TEE_API_TYPES_H */ 200