1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements.  See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership.  The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License.  You may obtain a copy of the License at
8 //
9 //   http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing,
12 // software distributed under the License is distributed on an
13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 // KIND, either express or implied.  See the License for the
15 // specific language governing permissions and limitations
16 // under the License.
17 
18 use super::tee_api_types::*;
19 use std::ptr::null;
20 
21 pub const TEE_INT_CORE_API_SPEC_VERSION: u32 = 0x0000000A;
22 
23 pub const TEE_HANDLE_NULL: *const u32 = null();
24 
25 pub const TEE_TIMEOUT_INFINITE: u32 = 0xFFFFFFFF;
26 
27 // API Error Codes
28 pub const TEE_SUCCESS: u32 = 0x00000000;
29 pub const TEE_ERROR_CORRUPT_OBJECT: u32 = 0xF0100001;
30 pub const TEE_ERROR_CORRUPT_OBJECT_2: u32 = 0xF0100002;
31 pub const TEE_ERROR_STORAGE_NOT_AVAILABLE: u32 = 0xF0100003;
32 pub const TEE_ERROR_STORAGE_NOT_AVAILABLE_2: u32 = 0xF0100004;
33 pub const TEE_ERROR_CIPHERTEXT_INVALID: u32 = 0xF0100006;
34 pub const TEE_ERROR_GENERIC: u32 = 0xFFFF0000;
35 pub const TEE_ERROR_ACCESS_DENIED: u32 = 0xFFFF0001;
36 pub const TEE_ERROR_CANCEL: u32 = 0xFFFF0002;
37 pub const TEE_ERROR_ACCESS_CONFLICT: u32 = 0xFFFF0003;
38 pub const TEE_ERROR_EXCESS_DATA: u32 = 0xFFFF0004;
39 pub const TEE_ERROR_BAD_FORMAT: u32 = 0xFFFF0005;
40 pub const TEE_ERROR_BAD_PARAMETERS: u32 = 0xFFFF0006;
41 pub const TEE_ERROR_BAD_STATE: u32 = 0xFFFF0007;
42 pub const TEE_ERROR_ITEM_NOT_FOUND: u32 = 0xFFFF0008;
43 pub const TEE_ERROR_NOT_IMPLEMENTED: u32 = 0xFFFF0009;
44 pub const TEE_ERROR_NOT_SUPPORTED: u32 = 0xFFFF000A;
45 pub const TEE_ERROR_NO_DATA: u32 = 0xFFFF000B;
46 pub const TEE_ERROR_OUT_OF_MEMORY: u32 = 0xFFFF000C;
47 pub const TEE_ERROR_BUSY: u32 = 0xFFFF000D;
48 pub const TEE_ERROR_COMMUNICATION: u32 = 0xFFFF000E;
49 pub const TEE_ERROR_SECURITY: u32 = 0xFFFF000F;
50 pub const TEE_ERROR_SHORT_BUFFER: u32 = 0xFFFF0010;
51 pub const TEE_ERROR_EXTERNAL_CANCEL: u32 = 0xFFFF0011;
52 pub const TEE_ERROR_OVERFLOW: u32 = 0xFFFF300F;
53 pub const TEE_ERROR_TARGET_DEAD: u32 = 0xFFFF3024;
54 pub const TEE_ERROR_STORAGE_NO_SPACE: u32 = 0xFFFF3041;
55 pub const TEE_ERROR_MAC_INVALID: u32 = 0xFFFF3071;
56 pub const TEE_ERROR_SIGNATURE_INVALID: u32 = 0xFFFF3072;
57 pub const TEE_ERROR_TIME_NOT_SET: u32 = 0xFFFF5000;
58 pub const TEE_ERROR_TIME_NEEDS_RESET: u32 = 0xFFFF5001;
59 
60 // Parameter Type Constants
61 pub const TEE_PARAM_TYPE_NONE: u32 = 0;
62 pub const TEE_PARAM_TYPE_VALUE_INPUT: u32 = 1;
63 pub const TEE_PARAM_TYPE_VALUE_OUTPUT: u32 = 2;
64 pub const TEE_PARAM_TYPE_VALUE_INOUT: u32 = 3;
65 pub const TEE_PARAM_TYPE_MEMREF_INPUT: u32 = 5;
66 pub const TEE_PARAM_TYPE_MEMREF_OUTPUT: u32 = 6;
67 pub const TEE_PARAM_TYPE_MEMREF_INOUT: u32 = 7;
68 
69 // Login Type Constants
70 pub const TEE_LOGIN_PUBLIC: u32 = 0x00000000;
71 pub const TEE_LOGIN_USER: u32 = 0x00000001;
72 pub const TEE_LOGIN_GROUP: u32 = 0x00000002;
73 pub const TEE_LOGIN_APPLICATION: u32 = 0x00000004;
74 pub const TEE_LOGIN_APPLICATION_USER: u32 = 0x00000005;
75 pub const TEE_LOGIN_APPLICATION_GROUP: u32 = 0x00000006;
76 pub const TEE_LOGIN_TRUSTED_APP: u32 = 0xF0000000;
77 
78 // Origin Code Constants
79 pub const TEE_ORIGIN_API: u32 = 0x00000001;
80 pub const TEE_ORIGIN_COMMS: u32 = 0x00000002;
81 pub const TEE_ORIGIN_TEE: u32 = 0x00000003;
82 pub const TEE_ORIGIN_TRUSTED_APP: u32 = 0x00000004;
83 
84 // Property Sets pseudo handles
85 pub const TEE_PROPSET_TEE_IMPLEMENTATION: TEE_PropSetHandle = 0xFFFFFFFD as *mut _;
86 pub const TEE_PROPSET_CURRENT_CLIENT: TEE_PropSetHandle = 0xFFFFFFFE as *mut _;
87 pub const TEE_PROPSET_CURRENT_TA: TEE_PropSetHandle = 0xFFFFFFFF as *mut _;
88 
89 // Memory Access Rights Constants
90 pub const TEE_MEMORY_ACCESS_READ: u32 = 0x00000001;
91 pub const TEE_MEMORY_ACCESS_WRITE: u32 = 0x00000002;
92 pub const TEE_MEMORY_ACCESS_ANY_OWNER: u32 = 0x00000004;
93 
94 // Memory Management Constant
95 pub const TEE_MALLOC_FILL_ZERO: u32 = 0x00000000;
96 
97 // Other constants
98 pub const TEE_STORAGE_PRIVATE: u32 = 0x00000001;
99 
100 pub const TEE_DATA_FLAG_ACCESS_READ: u32 = 0x00000001;
101 pub const TEE_DATA_FLAG_ACCESS_WRITE: u32 = 0x00000002;
102 pub const TEE_DATA_FLAG_ACCESS_WRITE_META: u32 = 0x00000004;
103 pub const TEE_DATA_FLAG_SHARE_READ: u32 = 0x00000010;
104 pub const TEE_DATA_FLAG_SHARE_WRITE: u32 = 0x00000020;
105 pub const TEE_DATA_FLAG_OVERWRITE: u32 = 0x00000400;
106 pub const TEE_DATA_MAX_POSITION: u32 = 0xFFFFFFFF;
107 pub const TEE_OBJECT_ID_MAX_LEN: u32 = 64;
108 pub const TEE_USAGE_EXTRACTABLE: u32 = 0x00000001;
109 pub const TEE_USAGE_ENCRYPT: u32 = 0x00000002;
110 pub const TEE_USAGE_DECRYPT: u32 = 0x00000004;
111 pub const TEE_USAGE_MAC: u32 = 0x00000008;
112 pub const TEE_USAGE_SIGN: u32 = 0x00000010;
113 pub const TEE_USAGE_VERIFY: u32 = 0x00000020;
114 pub const TEE_USAGE_DERIVE: u32 = 0x00000040;
115 pub const TEE_HANDLE_FLAG_PERSISTENT: u32 = 0x00010000;
116 pub const TEE_HANDLE_FLAG_INITIALIZED: u32 = 0x00020000;
117 pub const TEE_HANDLE_FLAG_KEY_SET: u32 = 0x00040000;
118 pub const TEE_HANDLE_FLAG_EXPECT_TWO_KEYS: u32 = 0x00080000;
119 pub const TEE_OPERATION_CIPHER: u32 = 1;
120 pub const TEE_OPERATION_MAC: u32 = 3;
121 pub const TEE_OPERATION_AE: u32 = 4;
122 pub const TEE_OPERATION_DIGEST: u32 = 5;
123 pub const TEE_OPERATION_ASYMMETRIC_CIPHER: u32 = 6;
124 pub const TEE_OPERATION_ASYMMETRIC_SIGNATURE: u32 = 7;
125 pub const TEE_OPERATION_KEY_DERIVATION: u32 = 8;
126 pub const TEE_OPERATION_STATE_INITIAL: u32 = 0x00000000;
127 pub const TEE_OPERATION_STATE_ACTIVE: u32 = 0x00000001;
128 
129 // Algorithm Identifiers
130 pub const TEE_ALG_AES_ECB_NOPAD: u32 = 0x10000010;
131 pub const TEE_ALG_AES_CBC_NOPAD: u32 = 0x10000110;
132 pub const TEE_ALG_AES_CTR: u32 = 0x10000210;
133 pub const TEE_ALG_AES_CTS: u32 = 0x10000310;
134 pub const TEE_ALG_AES_XTS: u32 = 0x10000410;
135 pub const TEE_ALG_AES_CBC_MAC_NOPAD: u32 = 0x30000110;
136 pub const TEE_ALG_AES_CBC_MAC_PKCS5: u32 = 0x30000510;
137 pub const TEE_ALG_AES_CMAC: u32 = 0x30000610;
138 pub const TEE_ALG_AES_CCM: u32 = 0x40000710;
139 pub const TEE_ALG_AES_GCM: u32 = 0x40000810;
140 pub const TEE_ALG_DES_ECB_NOPAD: u32 = 0x10000011;
141 pub const TEE_ALG_DES_CBC_NOPAD: u32 = 0x10000111;
142 pub const TEE_ALG_DES_CBC_MAC_NOPAD: u32 = 0x30000111;
143 pub const TEE_ALG_DES_CBC_MAC_PKCS5: u32 = 0x30000511;
144 pub const TEE_ALG_DES3_ECB_NOPAD: u32 = 0x10000013;
145 pub const TEE_ALG_DES3_CBC_NOPAD: u32 = 0x10000113;
146 pub const TEE_ALG_DES3_CBC_MAC_NOPAD: u32 = 0x30000113;
147 pub const TEE_ALG_DES3_CBC_MAC_PKCS5: u32 = 0x30000513;
148 pub const TEE_ALG_SM4_ECB_NOPAD: u32 = 0x10000014;
149 pub const TEE_ALG_SM4_CBC_NOPAD: u32 = 0x10000114;
150 pub const TEE_ALG_SM4_CTR: u32 = 0x10000214;
151 pub const TEE_ALG_RSASSA_PKCS1_V1_5_MD5: u32 = 0x70001830;
152 pub const TEE_ALG_RSASSA_PKCS1_V1_5_SHA1: u32 = 0x70002830;
153 pub const TEE_ALG_RSASSA_PKCS1_V1_5_SHA224: u32 = 0x70003830;
154 pub const TEE_ALG_RSASSA_PKCS1_V1_5_SHA256: u32 = 0x70004830;
155 pub const TEE_ALG_RSASSA_PKCS1_V1_5_SHA384: u32 = 0x70005830;
156 pub const TEE_ALG_RSASSA_PKCS1_V1_5_SHA512: u32 = 0x70006830;
157 pub const TEE_ALG_RSASSA_PKCS1_V1_5_MD5SHA1: u32 = 0x7000F830;
158 pub const TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1: u32 = 0x70212930;
159 pub const TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224: u32 = 0x70313930;
160 pub const TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256: u32 = 0x70414930;
161 pub const TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384: u32 = 0x70515930;
162 pub const TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512: u32 = 0x70616930;
163 pub const TEE_ALG_RSAES_PKCS1_V1_5: u32 = 0x60000130;
164 pub const TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1: u32 = 0x60210230;
165 pub const TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224: u32 = 0x60310230;
166 pub const TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256: u32 = 0x60410230;
167 pub const TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384: u32 = 0x60510230;
168 pub const TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512: u32 = 0x60610230;
169 pub const TEE_ALG_RSA_NOPAD: u32 = 0x60000030;
170 pub const TEE_ALG_DSA_SHA1: u32 = 0x70002131;
171 pub const TEE_ALG_DSA_SHA224: u32 = 0x70003131;
172 pub const TEE_ALG_DSA_SHA256: u32 = 0x70004131;
173 pub const TEE_ALG_SM2_DSA_SM3: u32 = 0x70006045;
174 pub const TEE_ALG_DH_DERIVE_SHARED_SECRET: u32 = 0x80000032;
175 pub const TEE_ALG_SM2_KEP: u32 = 0x60000045;
176 pub const TEE_ALG_MD5: u32 = 0x50000001;
177 pub const TEE_ALG_SHA1: u32 = 0x50000002;
178 pub const TEE_ALG_SHA224: u32 = 0x50000003;
179 pub const TEE_ALG_SHA256: u32 = 0x50000004;
180 pub const TEE_ALG_SHA384: u32 = 0x50000005;
181 pub const TEE_ALG_SHA512: u32 = 0x50000006;
182 pub const TEE_ALG_MD5SHA1: u32 = 0x5000000F;
183 pub const TEE_ALG_HMAC_MD5: u32 = 0x30000001;
184 pub const TEE_ALG_HMAC_SHA1: u32 = 0x30000002;
185 pub const TEE_ALG_HMAC_SHA224: u32 = 0x30000003;
186 pub const TEE_ALG_HMAC_SHA256: u32 = 0x30000004;
187 pub const TEE_ALG_HMAC_SHA384: u32 = 0x30000005;
188 pub const TEE_ALG_HMAC_SHA512: u32 = 0x30000006;
189 pub const TEE_ALG_HMAC_SM3: u32 = 0x30000007;
190 pub const TEE_ALG_ECDSA_P192: u32 = 0x70001041;
191 pub const TEE_ALG_ECDSA_P224: u32 = 0x70002041;
192 pub const TEE_ALG_ECDSA_P256: u32 = 0x70003041;
193 pub const TEE_ALG_ECDSA_P384: u32 = 0x70004041;
194 pub const TEE_ALG_ECDSA_P521: u32 = 0x70005041;
195 pub const TEE_ALG_ECDH_P192: u32 = 0x80001042;
196 pub const TEE_ALG_ECDH_P224: u32 = 0x80002042;
197 pub const TEE_ALG_ECDH_P256: u32 = 0x80003042;
198 pub const TEE_ALG_ECDH_P384: u32 = 0x80004042;
199 pub const TEE_ALG_ECDH_P521: u32 = 0x80005042;
200 pub const TEE_ALG_SM2_PKE: u32 = 0x80000045;
201 pub const TEE_ALG_SM3: u32 = 0x50000007;
202 pub const TEE_ALG_ILLEGAL_VALUE: u32 = 0xEFFFFFFF;
203 
204 // Object Types
205 pub const TEE_TYPE_AES: u32 = 0xA0000010;
206 pub const TEE_TYPE_DES: u32 = 0xA0000011;
207 pub const TEE_TYPE_DES3: u32 = 0xA0000013;
208 pub const TEE_TYPE_SM4: u32 = 0xA0000014;
209 pub const TEE_TYPE_HMAC_MD5: u32 = 0xA0000001;
210 pub const TEE_TYPE_HMAC_SHA1: u32 = 0xA0000002;
211 pub const TEE_TYPE_HMAC_SHA224: u32 = 0xA0000003;
212 pub const TEE_TYPE_HMAC_SHA256: u32 = 0xA0000004;
213 pub const TEE_TYPE_HMAC_SHA384: u32 = 0xA0000005;
214 pub const TEE_TYPE_HMAC_SHA512: u32 = 0xA0000006;
215 pub const TEE_TYPE_HMAC_SM3: u32 = 0xA0000007;
216 pub const TEE_TYPE_RSA_PUBLIC_KEY: u32 = 0xA0000030;
217 pub const TEE_TYPE_RSA_KEYPAIR: u32 = 0xA1000030;
218 pub const TEE_TYPE_DSA_PUBLIC_KEY: u32 = 0xA0000031;
219 pub const TEE_TYPE_DSA_KEYPAIR: u32 = 0xA1000031;
220 pub const TEE_TYPE_DH_KEYPAIR: u32 = 0xA1000032;
221 pub const TEE_TYPE_ECDSA_PUBLIC_KEY: u32 = 0xA0000041;
222 pub const TEE_TYPE_ECDSA_KEYPAIR: u32 = 0xA1000041;
223 pub const TEE_TYPE_ECDH_PUBLIC_KEY: u32 = 0xA0000042;
224 pub const TEE_TYPE_ECDH_KEYPAIR: u32 = 0xA1000042;
225 pub const TEE_TYPE_SM2_DSA_PUBLIC_KEY: u32 = 0xA0000045;
226 pub const TEE_TYPE_SM2_DSA_KEYPAIR: u32 = 0xA1000045;
227 pub const TEE_TYPE_SM2_KEP_PUBLIC_KEY: u32 = 0xA0000046;
228 pub const TEE_TYPE_SM2_KEP_KEYPAIR: u32 = 0xA1000046;
229 pub const TEE_TYPE_SM2_PKE_PUBLIC_KEY: u32 = 0xA0000047;
230 pub const TEE_TYPE_SM2_PKE_KEYPAIR: u32 = 0xA1000047;
231 pub const TEE_TYPE_GENERIC_SECRET: u32 = 0xA0000000;
232 pub const TEE_TYPE_CORRUPTED_OBJECT: u32 = 0xA00000BE;
233 pub const TEE_TYPE_DATA: u32 = 0xA00000BF;
234 
235 // List of Object or Operation Attributes
236 pub const TEE_ATTR_SECRET_VALUE: u32 = 0xC0000000;
237 pub const TEE_ATTR_RSA_MODULUS: u32 = 0xD0000130;
238 pub const TEE_ATTR_RSA_PUBLIC_EXPONENT: u32 = 0xD0000230;
239 pub const TEE_ATTR_RSA_PRIVATE_EXPONENT: u32 = 0xC0000330;
240 pub const TEE_ATTR_RSA_PRIME1: u32 = 0xC0000430;
241 pub const TEE_ATTR_RSA_PRIME2: u32 = 0xC0000530;
242 pub const TEE_ATTR_RSA_EXPONENT1: u32 = 0xC0000630;
243 pub const TEE_ATTR_RSA_EXPONENT2: u32 = 0xC0000730;
244 pub const TEE_ATTR_RSA_COEFFICIENT: u32 = 0xC0000830;
245 pub const TEE_ATTR_DSA_PRIME: u32 = 0xD0001031;
246 pub const TEE_ATTR_DSA_SUBPRIME: u32 = 0xD0001131;
247 pub const TEE_ATTR_DSA_BASE: u32 = 0xD0001231;
248 pub const TEE_ATTR_DSA_PUBLIC_VALUE: u32 = 0xD0000131;
249 pub const TEE_ATTR_DSA_PRIVATE_VALUE: u32 = 0xC0000231;
250 pub const TEE_ATTR_DH_PRIME: u32 = 0xD0001032;
251 pub const TEE_ATTR_DH_SUBPRIME: u32 = 0xD0001132;
252 pub const TEE_ATTR_DH_BASE: u32 = 0xD0001232;
253 pub const TEE_ATTR_DH_X_BITS: u32 = 0xF0001332;
254 pub const TEE_ATTR_DH_PUBLIC_VALUE: u32 = 0xD0000132;
255 pub const TEE_ATTR_DH_PRIVATE_VALUE: u32 = 0xC0000232;
256 pub const TEE_ATTR_RSA_OAEP_LABEL: u32 = 0xD0000930;
257 pub const TEE_ATTR_RSA_PSS_SALT_LENGTH: u32 = 0xF0000A30;
258 pub const TEE_ATTR_ECC_PUBLIC_VALUE_X: u32 = 0xD0000141;
259 pub const TEE_ATTR_ECC_PUBLIC_VALUE_Y: u32 = 0xD0000241;
260 pub const TEE_ATTR_ECC_PRIVATE_VALUE: u32 = 0xC0000341;
261 pub const TEE_ATTR_ECC_CURVE: u32 = 0xF0000441;
262 pub const TEE_ATTR_SM2_ID_INITIATOR: u32 = 0xD0000446;
263 pub const TEE_ATTR_SM2_ID_RESPONDER: u32 = 0xD0000546;
264 pub const TEE_ATTR_SM2_KEP_USER: u32 = 0xF0000646;
265 pub const TEE_ATTR_SM2_KEP_CONFIRMATION_IN: u32 = 0xD0000746;
266 pub const TEE_ATTR_SM2_KEP_CONFIRMATION_OUT: u32 = 0xD0000846;
267 pub const TEE_ATTR_ECC_EPHEMERAL_PUBLIC_VALUE_X: u32 = 0xD0000946;
268 pub const TEE_ATTR_ECC_EPHEMERAL_PUBLIC_VALUE_Y: u32 = 0xD0000A46;
269 pub const TEE_ATTR_FLAG_PUBLIC: u32 = (1 << 28);
270 pub const TEE_ATTR_FLAG_VALUE: u32 = (1 << 29);
271 // Deprecated, but kept for backwards compatibility
272 pub const TEE_ATTR_BIT_PROTECTED: u32 = (1 << 28);
273 pub const TEE_ATTR_BIT_VALUE: u32 = (1 << 29);
274 
275 // List of Supported ECC Curves
276 pub const TEE_CRYPTO_ELEMENT_NONE: u32 = 0x00000000;
277 pub const TEE_ECC_CURVE_NIST_P192: u32 = 0x00000001;
278 pub const TEE_ECC_CURVE_NIST_P224: u32 = 0x00000002;
279 pub const TEE_ECC_CURVE_NIST_P256: u32 = 0x00000003;
280 pub const TEE_ECC_CURVE_NIST_P384: u32 = 0x00000004;
281 pub const TEE_ECC_CURVE_NIST_P521: u32 = 0x00000005;
282 pub const TEE_ECC_CURVE_SM2: u32 = 0x00000300;
283 
284 // Panicked Functions Identification
285 // TA Interface
286 pub const TEE_PANIC_ID_TA_CLOSESESSIONENTRYPOINT: u32 = 0x00000101;
287 pub const TEE_PANIC_ID_TA_CREATEENTRYPOINT: u32 = 0x00000102;
288 pub const TEE_PANIC_ID_TA_DESTROYENTRYPOINT: u32 = 0x00000103;
289 pub const TEE_PANIC_ID_TA_INVOKECOMMANDENTRYPOINT: u32 = 0x00000104;
290 pub const TEE_PANIC_ID_TA_OPENSESSIONENTRYPOINT: u32 = 0x00000105;
291 /* Property Access */
292 pub const TEE_PANIC_ID_TEE_ALLOCATEPROPERTYENUMERATOR: u32 = 0x00000201;
293 pub const TEE_PANIC_ID_TEE_FREEPROPERTYENUMERATOR: u32 = 0x00000202;
294 pub const TEE_PANIC_ID_TEE_GETNEXTPROPERTY: u32 = 0x00000203;
295 pub const TEE_PANIC_ID_TEE_GETPROPERTYASBINARYBLOCK: u32 = 0x00000204;
296 pub const TEE_PANIC_ID_TEE_GETPROPERTYASBOOL: u32 = 0x00000205;
297 pub const TEE_PANIC_ID_TEE_GETPROPERTYASIDENTITY: u32 = 0x00000206;
298 pub const TEE_PANIC_ID_TEE_GETPROPERTYASSTRING: u32 = 0x00000207;
299 pub const TEE_PANIC_ID_TEE_GETPROPERTYASU32: u32 = 0x00000208;
300 pub const TEE_PANIC_ID_TEE_GETPROPERTYASUUID: u32 = 0x00000209;
301 pub const TEE_PANIC_ID_TEE_GETPROPERTYNAME: u32 = 0x0000020A;
302 pub const TEE_PANIC_ID_TEE_RESETPROPERTYENUMERATOR: u32 = 0x0000020B;
303 pub const TEE_PANIC_ID_TEE_STARTPROPERTYENUMERATOR: u32 = 0x0000020C;
304 // Panic Function
305 pub const TEE_PANIC_ID_TEE_PANIC: u32 = 0x00000301;
306 // Internal Client API
307 pub const TEE_PANIC_ID_TEE_CLOSETASESSION: u32 = 0x00000401;
308 pub const TEE_PANIC_ID_TEE_INVOKETACOMMAND: u32 = 0x00000402;
309 pub const TEE_PANIC_ID_TEE_OPENTASESSION: u32 = 0x00000403;
310 // Cancellation
311 pub const TEE_PANIC_ID_TEE_GETCANCELLATIONFLAG: u32 = 0x00000501;
312 pub const TEE_PANIC_ID_TEE_MASKCANCELLATION: u32 = 0x00000502;
313 pub const TEE_PANIC_ID_TEE_UNMASKCANCELLATION: u32 = 0x00000503;
314 // Memory Management
315 pub const TEE_PANIC_ID_TEE_CHECKMEMORYACCESSRIGHTS: u32 = 0x00000601;
316 pub const TEE_PANIC_ID_TEE_FREE: u32 = 0x00000602;
317 pub const TEE_PANIC_ID_TEE_GETINSTANCEDATA: u32 = 0x00000603;
318 pub const TEE_PANIC_ID_TEE_MALLOC: u32 = 0x00000604;
319 pub const TEE_PANIC_ID_TEE_MEMCOMPARE: u32 = 0x00000605;
320 pub const TEE_PANIC_ID_TEE_MEMFILL: u32 = 0x00000606;
321 pub const TEE_PANIC_ID_TEE_MEMMOVE: u32 = 0x00000607;
322 pub const TEE_PANIC_ID_TEE_REALLOC: u32 = 0x00000608;
323 pub const TEE_PANIC_ID_TEE_SETINSTANCEDATA: u32 = 0x00000609;
324 // Generic Object
325 pub const TEE_PANIC_ID_TEE_CLOSEOBJECT: u32 = 0x00000701;
326 pub const TEE_PANIC_ID_TEE_GETOBJECTBUFFERATTRIBUTE: u32 = 0x00000702;
327 // deprecated
328 pub const TEE_PANIC_ID_TEE_GETOBJECTINFO: u32 = 0x00000703;
329 pub const TEE_PANIC_ID_TEE_GETOBJECTVALUEATTRIBUTE: u32 = 0x00000704;
330 // deprecated
331 pub const TEE_PANIC_ID_TEE_RESTRICTOBJECTUSAGE: u32 = 0x00000705;
332 pub const TEE_PANIC_ID_TEE_GETOBJECTINFO1: u32 = 0x00000706;
333 pub const TEE_PANIC_ID_TEE_RESTRICTOBJECTUSAGE1: u32 = 0x00000707;
334 // Transient Object
335 pub const TEE_PANIC_ID_TEE_ALLOCATETRANSIENTOBJECT: u32 = 0x00000801;
336 // deprecated
337 pub const TEE_PANIC_ID_TEE_COPYOBJECTATTRIBUTES: u32 = 0x00000802;
338 pub const TEE_PANIC_ID_TEE_FREETRANSIENTOBJECT: u32 = 0x00000803;
339 pub const TEE_PANIC_ID_TEE_GENERATEKEY: u32 = 0x00000804;
340 pub const TEE_PANIC_ID_TEE_INITREFATTRIBUTE: u32 = 0x00000805;
341 pub const TEE_PANIC_ID_TEE_INITVALUEATTRIBUTE: u32 = 0x00000806;
342 pub const TEE_PANIC_ID_TEE_POPULATETRANSIENTOBJECT: u32 = 0x00000807;
343 pub const TEE_PANIC_ID_TEE_RESETTRANSIENTOBJECT: u32 = 0x00000808;
344 pub const TEE_PANIC_ID_TEE_COPYOBJECTATTRIBUTES1: u32 = 0x00000809;
345 // Persistent Object
346 // deprecated
347 pub const TEE_PANIC_ID_TEE_CLOSEANDDELETEPERSISTENTOBJECT: u32 = 0x00000901;
348 pub const TEE_PANIC_ID_TEE_CREATEPERSISTENTOBJECT: u32 = 0x00000902;
349 pub const TEE_PANIC_ID_TEE_OPENPERSISTENTOBJECT: u32 = 0x00000903;
350 pub const TEE_PANIC_ID_TEE_RENAMEPERSISTENTOBJECT: u32 = 0x00000904;
351 pub const TEE_PANIC_ID_TEE_CLOSEANDDELETEPERSISTENTOBJECT1: u32 = 0x00000905;
352 // Persistent Object Enumeration
353 pub const TEE_PANIC_ID_TEE_ALLOCATEPERSISTENTOBJECTENUMERATOR: u32 = 0x00000A01;
354 pub const TEE_PANIC_ID_TEE_FREEPERSISTENTOBJECTENUMERATOR: u32 = 0x00000A02;
355 pub const TEE_PANIC_ID_TEE_GETNEXTPERSISTENTOBJECT: u32 = 0x00000A03;
356 pub const TEE_PANIC_ID_TEE_RESETPERSISTENTOBJECTENUMERATOR: u32 = 0x00000A04;
357 pub const TEE_PANIC_ID_TEE_STARTPERSISTENTOBJECTENUMERATOR: u32 = 0x00000A05;
358 // Data Stream Access
359 pub const TEE_PANIC_ID_TEE_READOBJECTDATA: u32 = 0x00000B01;
360 pub const TEE_PANIC_ID_TEE_SEEKOBJECTDATA: u32 = 0x00000B02;
361 pub const TEE_PANIC_ID_TEE_TRUNCATEOBJECTDATA: u32 = 0x00000B03;
362 pub const TEE_PANIC_ID_TEE_WRITEOBJECTDATA: u32 = 0x00000B04;
363 // Generic Operation
364 pub const TEE_PANIC_ID_TEE_ALLOCATEOPERATION: u32 = 0x00000C01;
365 pub const TEE_PANIC_ID_TEE_COPYOPERATION: u32 = 0x00000C02;
366 pub const TEE_PANIC_ID_TEE_FREEOPERATION: u32 = 0x00000C03;
367 pub const TEE_PANIC_ID_TEE_GETOPERATIONINFO: u32 = 0x00000C04;
368 pub const TEE_PANIC_ID_TEE_RESETOPERATION: u32 = 0x00000C05;
369 pub const TEE_PANIC_ID_TEE_SETOPERATIONKEY: u32 = 0x00000C06;
370 pub const TEE_PANIC_ID_TEE_SETOPERATIONKEY2: u32 = 0x00000C07;
371 pub const TEE_PANIC_ID_TEE_GETOPERATIONINFOMULTIPLE: u32 = 0x00000C08;
372 // Message Digest
373 pub const TEE_PANIC_ID_TEE_DIGESTDOFINAL: u32 = 0x00000D01;
374 pub const TEE_PANIC_ID_TEE_DIGESTUPDATE: u32 = 0x00000D02;
375 // Symmetric Cipher
376 pub const TEE_PANIC_ID_TEE_CIPHERDOFINAL: u32 = 0x00000E01;
377 pub const TEE_PANIC_ID_TEE_CIPHERINIT: u32 = 0x00000E02;
378 pub const TEE_PANIC_ID_TEE_CIPHERUPDATE: u32 = 0x00000E03;
379 // MAC
380 pub const TEE_PANIC_ID_TEE_MACCOMPAREFINAL: u32 = 0x00000F01;
381 pub const TEE_PANIC_ID_TEE_MACCOMPUTEFINAL: u32 = 0x00000F02;
382 pub const TEE_PANIC_ID_TEE_MACINIT: u32 = 0x00000F03;
383 pub const TEE_PANIC_ID_TEE_MACUPDATE: u32 = 0x00000F04;
384 // Authenticated Encryption
385 pub const TEE_PANIC_ID_TEE_AEDECRYPTFINAL: u32 = 0x00001001;
386 pub const TEE_PANIC_ID_TEE_AEENCRYPTFINAL: u32 = 0x00001002;
387 pub const TEE_PANIC_ID_TEE_AEINIT: u32 = 0x00001003;
388 pub const TEE_PANIC_ID_TEE_AEUPDATE: u32 = 0x00001004;
389 pub const TEE_PANIC_ID_TEE_AEUPDATEAAD: u32 = 0x00001005;
390 // Asymmetric
391 pub const TEE_PANIC_ID_TEE_ASYMMETRICDECRYPT: u32 = 0x00001101;
392 pub const TEE_PANIC_ID_TEE_ASYMMETRICENCRYPT: u32 = 0x00001102;
393 pub const TEE_PANIC_ID_TEE_ASYMMETRICSIGNDIGEST: u32 = 0x00001103;
394 pub const TEE_PANIC_ID_TEE_ASYMMETRICVERIFYDIGEST: u32 = 0x00001104;
395 // Key Derivation
396 pub const TEE_PANIC_ID_TEE_DERIVEKEY: u32 = 0x00001201;
397 // Random Data Generation
398 pub const TEE_PANIC_ID_TEE_GENERATERANDOM: u32 = 0x00001301;
399 // Time
400 pub const TEE_PANIC_ID_TEE_GETREETIME: u32 = 0x00001401;
401 pub const TEE_PANIC_ID_TEE_GETSYSTEMTIME: u32 = 0x00001402;
402 pub const TEE_PANIC_ID_TEE_GETTAPERSISTENTTIME: u32 = 0x00001403;
403 pub const TEE_PANIC_ID_TEE_SETTAPERSISTENTTIME: u32 = 0x00001404;
404 pub const TEE_PANIC_ID_TEE_WAIT: u32 = 0x00001405;
405 // Memory Allocation and Size of Objects
406 pub const TEE_PANIC_ID_TEE_BIGINTFMMCONTEXTSIZEINU32: u32 = 0x00001501;
407 pub const TEE_PANIC_ID_TEE_BIGINTFMMSIZEINU32: u32 = 0x00001502;
408 // Initialization
409 pub const TEE_PANIC_ID_TEE_BIGINTINIT: u32 = 0x00001601;
410 pub const TEE_PANIC_ID_TEE_BIGINTINITFMM: u32 = 0x00001602;
411 pub const TEE_PANIC_ID_TEE_BIGINTINITFMMCONTEXT: u32 = 0x00001603;
412 // Converter
413 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTFROMOCTETSTRING: u32 = 0x00001701;
414 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTFROMS32: u32 = 0x00001702;
415 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTTOOCTETSTRING: u32 = 0x00001703;
416 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTTOS32: u32 = 0x00001704;
417 // Logical Operation
418 pub const TEE_PANIC_ID_TEE_BIGINTCMP: u32 = 0x00001801;
419 pub const TEE_PANIC_ID_TEE_BIGINTCMPS32: u32 = 0x00001802;
420 pub const TEE_PANIC_ID_TEE_BIGINTGETBIT: u32 = 0x00001803;
421 pub const TEE_PANIC_ID_TEE_BIGINTGETBITCOUNT: u32 = 0x00001804;
422 pub const TEE_PANIC_ID_TEE_BIGINTSHIFTRIGHT: u32 = 0x00001805;
423 // Basic Arithmetic
424 pub const TEE_PANIC_ID_TEE_BIGINTADD: u32 = 0x00001901;
425 pub const TEE_PANIC_ID_TEE_BIGINTDIV: u32 = 0x00001902;
426 pub const TEE_PANIC_ID_TEE_BIGINTMUL: u32 = 0x00001903;
427 pub const TEE_PANIC_ID_TEE_BIGINTNEG: u32 = 0x00001904;
428 pub const TEE_PANIC_ID_TEE_BIGINTSQUARE: u32 = 0x00001905;
429 pub const TEE_PANIC_ID_TEE_BIGINTSUB: u32 = 0x00001906;
430 // Modular Arithmetic
431 pub const TEE_PANIC_ID_TEE_BIGINTADDMOD: u32 = 0x00001A01;
432 pub const TEE_PANIC_ID_TEE_BIGINTINVMOD: u32 = 0x00001A02;
433 pub const TEE_PANIC_ID_TEE_BIGINTMOD: u32 = 0x00001A03;
434 pub const TEE_PANIC_ID_TEE_BIGINTMULMOD: u32 = 0x00001A04;
435 pub const TEE_PANIC_ID_TEE_BIGINTSQUAREMOD: u32 = 0x00001A05;
436 pub const TEE_PANIC_ID_TEE_BIGINTSUBMOD: u32 = 0x00001A06;
437 // Other Arithmetic
438 pub const TEE_PANIC_ID_TEE_BIGINTCOMPUTEEXTENDEDGCD: u32 = 0x00001B01;
439 pub const TEE_PANIC_ID_TEE_BIGINTISPROBABLEPRIME: u32 = 0x00001B02;
440 pub const TEE_PANIC_ID_TEE_BIGINTRELATIVEPRIME: u32 = 0x00001B03;
441 // Fast Modular Multiplication
442 pub const TEE_PANIC_ID_TEE_BIGINTCOMPUTEFMM: u32 = 0x00001C01;
443 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTFROMFMM: u32 = 0x00001C02;
444 pub const TEE_PANIC_ID_TEE_BIGINTCONVERTTOFMM: u32 = 0x00001C03;
445 
TEE_PARAM_TYPES(t0: u32, t1: u32, t2: u32, t3: u32) -> u32446 pub fn TEE_PARAM_TYPES(t0: u32, t1: u32, t2: u32, t3: u32) -> u32 {
447     t0 | t1 << 4 | t2 << 8 | t3 << 12
448 }
449 
450 pub const TEE_NUM_PARAMS: u32 = 4;
451