mTower
tee_api_types.h
1 /* SPDX-License-Identifier: BSD-2-Clause */
2 /*
3  * Copyright (c) 2014, STMicroelectronics International N.V.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright notice,
10  * this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright notice,
13  * this list of conditions and the following disclaimer in the documentation
14  * and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26  * POSSIBILITY OF SUCH DAMAGE.
27  */
28 
29 /* Based on GP TEE Internal API Specification Version 0.11 */
30 #ifndef TEE_API_TYPES_H
31 #define TEE_API_TYPES_H
32 
33 #include <compiler.h>
34 #include <stdint.h>
35 #include <stdbool.h>
36 #include <stddef.h>
37 #include <tee_api_defines.h>
38 
39 /*
40  * Common Definitions
41  */
42 
43 typedef uint32_t TEE_Result;
44 
45 typedef struct {
46  uint32_t timeLow;
47  uint16_t timeMid;
48  uint16_t timeHiAndVersion;
49  uint8_t clockSeqAndNode[8];
50 } TEE_UUID;
51 
52 /*
53  * The TEE_Identity structure defines the full identity of a Client:
54  * - login is one of the TEE_LOGIN_XXX constants
55  * - uuid contains the client UUID or Nil if not applicable
56  */
57 typedef struct {
58  uint32_t login;
59  TEE_UUID uuid;
60 } TEE_Identity;
61 
62 /*
63  * This union describes one parameter passed by the Trusted Core Framework
64  * to the entry points TA_OpenSessionEntryPoint or
65  * TA_InvokeCommandEntryPoint or by the TA to the functions
66  * TEE_OpenTASession or TEE_InvokeTACommand.
67  *
68  * Which of the field value or memref to select is determined by the
69  * parameter type specified in the argument paramTypes passed to the entry
70  * point.
71 */
72 typedef union {
73  struct {
74  void *buffer;
75  uint32_t size;
76  } memref;
77  struct {
78  uint32_t a;
79  uint32_t b;
80  } value;
81 } TEE_Param;
82 
83 /*
84  * The type of opaque handles on TA Session. These handles are returned by
85  * the function TEE_OpenTASession.
86  */
87 typedef struct __TEE_TASessionHandle *TEE_TASessionHandle;
88 
89 /*
90  * The type of opaque handles on property sets or enumerators. These
91  * handles are either one of the pseudo handles TEE_PROPSET_XXX or are
92  * returned by the function TEE_AllocatePropertyEnumerator.
93 */
94 typedef struct __TEE_PropSetHandle *TEE_PropSetHandle;
95 
96 typedef struct __TEE_ObjectHandle *TEE_ObjectHandle;
97 typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle;
98 typedef struct __TEE_OperationHandle *TEE_OperationHandle;
99 
100 /*
101  * Storage Definitions
102  */
103 
104 typedef uint32_t TEE_ObjectType;
105 
106 typedef struct {
107  uint32_t objectType;
108  __extension__ union {
109  uint32_t keySize; /* used in 1.1 spec */
110  uint32_t objectSize; /* used in 1.1.1 spec */
111  };
112  __extension__ union {
113  uint32_t maxKeySize; /* used in 1.1 spec */
114  uint32_t maxObjectSize; /* used in 1.1.1 spec */
115  };
116  uint32_t objectUsage;
117  uint32_t dataSize;
118  uint32_t dataPosition;
119  uint32_t handleFlags;
121 
122 typedef enum {
123  TEE_DATA_SEEK_SET = 0,
124  TEE_DATA_SEEK_CUR = 1,
125  TEE_DATA_SEEK_END = 2
126 } TEE_Whence;
127 
128 typedef struct {
129  uint32_t attributeID;
130  union {
131  struct {
132  void *buffer;
133  uint32_t length;
134  } ref;
135  struct {
136  uint32_t a, b;
137  } value;
138  } content;
139 } TEE_Attribute;
140 
141 /* Cryptographic Operations API */
142 
143 typedef enum {
144  TEE_MODE_ENCRYPT = 0,
145  TEE_MODE_DECRYPT = 1,
146  TEE_MODE_SIGN = 2,
147  TEE_MODE_VERIFY = 3,
148  TEE_MODE_MAC = 4,
149  TEE_MODE_DIGEST = 5,
150  TEE_MODE_DERIVE = 6
151 } TEE_OperationMode;
152 
153 typedef struct {
154  uint32_t algorithm;
155  uint32_t operationClass;
156  uint32_t mode;
157  uint32_t digestLength;
158  uint32_t maxKeySize;
159  uint32_t keySize;
160  uint32_t requiredKeyUsage;
161  uint32_t handleState;
163 
164 typedef struct {
165  uint32_t keySize;
166  uint32_t requiredKeyUsage;
168 
169 typedef struct {
170  uint32_t algorithm;
171  uint32_t operationClass;
172  uint32_t mode;
173  uint32_t digestLength;
174  uint32_t maxKeySize;
175  uint32_t handleState;
176  uint32_t operationState;
177  uint32_t numberOfKeys;
178  TEE_OperationInfoKey keyInformation[];
180 
181 /* Time & Date API */
182 
183 typedef struct {
184  uint32_t seconds;
185  uint32_t millis;
186 } TEE_Time;
187 
188 /* TEE Arithmetical APIs */
189 
190 typedef uint32_t TEE_BigInt;
191 
192 typedef uint32_t TEE_BigIntFMM;
193 
194 //typedef uint32_t TEE_BigIntFMMContext __aligned(__alignof__(void *));
195 
196 /* Tee Secure Element APIs */
197 
198 typedef struct __TEE_SEServiceHandle *TEE_SEServiceHandle;
199 typedef struct __TEE_SEReaderHandle *TEE_SEReaderHandle;
200 typedef struct __TEE_SESessionHandle *TEE_SESessionHandle;
201 typedef struct __TEE_SEChannelHandle *TEE_SEChannelHandle;
202 
203 typedef struct {
204  bool sePresent;
205  bool teeOnly;
206  bool selectResponseEnable;
208 
209 typedef struct {
210  uint8_t *buffer;
211  size_t bufferLen;
212 } TEE_SEAID;
213 
214 /* Other definitions */
215 typedef uint32_t TEE_ErrorOrigin;
216 typedef void *TEE_Session;
217 
218 #define TEE_MEM_INPUT 0x00000001
219 #define TEE_MEM_OUTPUT 0x00000002
220 
221 #define TEE_MEMREF_0_USED 0x00000001
222 #define TEE_MEMREF_1_USED 0x00000002
223 #define TEE_MEMREF_2_USED 0x00000004
224 #define TEE_MEMREF_3_USED 0x00000008
225 
226 #define TEE_SE_READER_NAME_MAX 20
227 
228 #endif /* TEE_API_TYPES_H */
Definition: tee_api_types.h:153
Definition: tee_api_types.h:183
Definition: tee_api_types.h:72
Definition: tee_api_types.h:203
Definition: tee_api_types.h:57
Definition: tee_api_types.h:209
Definition: tee_api_types.h:164
Definition: tee_api_types.h:169
Definition: tee_api_types.h:45
Definition: tee_api_types.h:106
Definition: tee_api_types.h:128