1 /*
2 * Copyright (c) 2025 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License"),
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 /**
17 * @addtogroup TeeTrusted
18 * @{
19 *
20 * @brief TEE(Trusted Excution Environment) API.
21 * Provides security capability APIs such as trusted storage, encryption and decryption,
22 * and trusted time for trusted application development.
23 *
24 * @since 20
25 */
26
27 /**
28 * @file tee_defines.h
29 *
30 * @brief Defines basic data types and data structures of TEE.
31 *
32 * @library NA
33 * @kit TEEKit
34 * @syscap SystemCapability.Tee.TeeClient
35 * @since 20
36 */
37
38 #ifndef __TEE_DEFINES_H
39 #define __TEE_DEFINES_H
40
41 #include <stdint.h>
42 #include <stdbool.h>
43 #include <stddef.h>
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #ifndef TA_EXPORT
50
51 /**
52 * @brief Represents the export attribute for Trusted Applications.
53 *
54 * @since 20
55 */
56 #define TA_EXPORT
57 #endif
58
59 /**
60 * @brief Defines the tee mutex handle.
61 *
62 * @since 20
63 */
64 typedef int *tee_mutex_handle;
65
66 /**
67 * @brief Represents API level 1.1.1.
68 *
69 * @since 20
70 */
71 #define API_LEVEL1_1_1 2
72
73 /**
74 * @brief Represents API level 1.2.
75 *
76 * @since 20
77 */
78 #define API_LEVEL1_2 3
79
80 /**
81 * @brief Represents the number of TEE parameters.
82 *
83 * @since 20
84 */
85 #define TEE_PARAMS_NUM 4
86
87 #ifndef NULL
88 /**
89 * @brief Represents a null pointer constant.
90 *
91 * @since 20
92 */
93 #define NULL ((void*)0)
94 #endif
95
96 /**
97 * @brief Marks a parameter as unused.
98 *
99 * @since 20
100 */
101 #define PARAM_NOT_USED(val) ((void)(val))
102
103 /**
104 * @brief Enumerates the TEE parameter.
105 *
106 * @since 20
107 */
108 typedef union {
109 /**
110 * @brief Describes a memory reference.
111 *
112 * @since 20
113 */
114 struct {
115 /** Pointer to the memory buffer. */
116 void *buffer;
117 /** Size of the memory buffer. */
118 size_t size;
119 } memref;
120 /**
121 * @brief Describes value parameters.
122 *
123 * @since 20
124 */
125 struct {
126 /** First value. */
127 unsigned int a;
128 /** Second value. */
129 unsigned int b;
130 } value;
131 /**
132 * @brief Describes shared memory reference.
133 *
134 * @since 20
135 */
136 struct {
137 /** Pointer to the shared memory buffer. */
138 void *buffer;
139 /** Size of the shared memory buffer. */
140 size_t size;
141 } sharedmem;
142 } TEE_Param;
143
144 /**
145 * @brief Constructs the TEE parameter types from the provided types.
146 *
147 * @since 20
148 */
149 #define TEE_PARAM_TYPES(param0Type, param1Type, param2Type, param3Type) \
150 (((param3Type) << 12) | ((param2Type) << 8) | ((param1Type) << 4) | (param0Type))
151
152 /**
153 * @brief Extracts the parameter type at the specified index from the TEE parameter types.
154 *
155 * @since 20
156 */
157 #define TEE_PARAM_TYPE_GET(paramTypes, index) (((paramTypes) >> (4U * (index))) & 0x0F)
158
159 /**
160 * @brief Checks parameter types.
161 *
162 * @param param_to_check Indicates the expected parameter values.
163 * @param valid0 Indicates the first parameter type to check.
164 * @param valid1 Indicates the second parameter type to check.
165 * @param valid2 Indicates the third parameter type to check.
166 * @param valid3 Indicates the fourth parameter type to check.
167 *
168 * @return Returns <b>true</b> if the parameter types are correct.
169 * Returns <b>false</b> otherwise.
170 * @since 20
171 */
check_param_type(uint32_t param_to_check,uint32_t valid0,uint32_t valid1,uint32_t valid2,uint32_t valid3)172 static inline bool check_param_type(uint32_t param_to_check, uint32_t valid0, uint32_t valid1, uint32_t valid2,
173 uint32_t valid3)
174 {
175 return (TEE_PARAM_TYPES(valid0, valid1, valid2, valid3) == param_to_check);
176 }
177
178 /**
179 * @brief Enumerates the types of the TEE parameter.
180 *
181 * @since 20
182 */
183 enum TEE_ParamType {
184 /** Represents no parameter type. */
185 TEE_PARAM_TYPE_NONE = 0x0,
186 /** Represents a value input type. */
187 TEE_PARAM_TYPE_VALUE_INPUT = 0x1,
188 /** Represents a value output type. */
189 TEE_PARAM_TYPE_VALUE_OUTPUT = 0x2,
190 /** Represents a value inout type. */
191 TEE_PARAM_TYPE_VALUE_INOUT = 0x3,
192 /** Represents a memory reference input type. */
193 TEE_PARAM_TYPE_MEMREF_INPUT = 0x5,
194 /** Represents a memory reference output type. */
195 TEE_PARAM_TYPE_MEMREF_OUTPUT = 0x6,
196 /** Represents a memory reference inout type. */
197 TEE_PARAM_TYPE_MEMREF_INOUT = 0x7,
198 /** Represents an ION input type. */
199 TEE_PARAM_TYPE_ION_INPUT = 0x8,
200 /** Represents an ION single list input type. */
201 TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9,
202 /** Represents a shared memory reference inout type. */
203 TEE_PARAM_TYPE_MEMREF_SHARED_INOUT = 0xa,
204 /** Represents a resource memory input type. */
205 TEE_PARAM_TYPE_RESMEM_INPUT = 0xc,
206 /** Represents a resource memory output type. */
207 TEE_PARAM_TYPE_RESMEM_OUTPUT = 0xd,
208 /** Represents a resource memory inout type. */
209 TEE_PARAM_TYPE_RESMEM_INOUT = 0xe,
210 };
211
212 /**
213 * @brief Marks a variable as unused.
214 *
215 * @since 20
216 */
217 #define S_VAR_NOT_USED(variable) \
218 do { \
219 (void)(variable); \
220 } while (0)
221
222 /**
223 * @brief Defines an object information.
224 *
225 * @since 20
226 */
227 typedef struct {
228 /** Type of the object. */
229 uint32_t objectType;
230 /** Size of the object. */
231 uint32_t objectSize;
232 /** Maximum allowed size for the object. */
233 uint32_t maxObjectSize;
234 /** Usage flags of the object. */
235 uint32_t objectUsage;
236 /** Size of the data associated with the object. */
237 uint32_t dataSize;
238 /** Position of the data within the object. */
239 uint32_t dataPosition;
240 /** Flags associated with the handle. */
241 uint32_t handleFlags;
242 } TEE_ObjectInfo;
243
244 /**
245 * @brief Defines an object attribute.
246 *
247 * @since 20
248 */
249 typedef struct {
250 /** Attribute ID. */
251 uint32_t attributeID;
252 /**
253 * @brief Attribute content.
254 *
255 * @since 20
256 */
257 union {
258 /**
259 * @brief Reference type content.
260 *
261 * @since 20
262 */
263 struct {
264 /** Buffer pointer. */
265 void *buffer;
266 /** Length of the buffer. */
267 size_t length;
268 } ref;
269 /**
270 * @brief Value type content.
271 *
272 * @since 20
273 */
274 struct {
275 /** First value. */
276 uint32_t a;
277 /** Second value. */
278 uint32_t b;
279 } value;
280 } content;
281 } TEE_Attribute;
282
283 /**
284 * @brief Enumerates the types of object attribute.
285 *
286 * @since 20
287 */
288 enum TEE_ObjectAttribute {
289 /** Secret value attribute. */
290 TEE_ATTR_SECRET_VALUE = 0xC0000000,
291 /** RSA modulus attribute. */
292 TEE_ATTR_RSA_MODULUS = 0xD0000130,
293 /** RSA public exponent attribute. */
294 TEE_ATTR_RSA_PUBLIC_EXPONENT = 0xD0000230,
295 /** RSA private exponent attribute. */
296 TEE_ATTR_RSA_PRIVATE_EXPONENT = 0xC0000330,
297 /** RSA prime1 attribute. */
298 TEE_ATTR_RSA_PRIME1 = 0xC0000430,
299 /** RSA prime2 attribute. */
300 TEE_ATTR_RSA_PRIME2 = 0xC0000530,
301 /** RSA exponent1 attribute. */
302 TEE_ATTR_RSA_EXPONENT1 = 0xC0000630,
303 /** RSA exponent2 attribute. */
304 TEE_ATTR_RSA_EXPONENT2 = 0xC0000730,
305 /** RSA coefficient attribute. */
306 TEE_ATTR_RSA_COEFFICIENT = 0xC0000830,
307 /** RSA MGF1 hash attribute. */
308 TEE_ATTR_RSA_MGF1_HASH = 0xF0000830,
309 /** DSA prime attribute. */
310 TEE_ATTR_DSA_PRIME = 0xD0001031,
311 /** DSA subprime attribute. */
312 TEE_ATTR_DSA_SUBPRIME = 0xD0001131,
313 /** DSA base attribute. */
314 TEE_ATTR_DSA_BASE = 0xD0001231,
315 /** DSA public value attribute. */
316 TEE_ATTR_DSA_PUBLIC_VALUE = 0xD0000131,
317 /** DSA private value attribute. */
318 TEE_ATTR_DSA_PRIVATE_VALUE = 0xC0000231,
319 /** DH prime attribute. */
320 TEE_ATTR_DH_PRIME = 0xD0001032,
321 /** DH subprime attribute. */
322 TEE_ATTR_DH_SUBPRIME = 0xD0001132,
323 /** DH base attribute. */
324 TEE_ATTR_DH_BASE = 0xD0001232,
325 /** DH X bits attribute. */
326 TEE_ATTR_DH_X_BITS = 0xF0001332,
327 /** DH public value attribute. */
328 TEE_ATTR_DH_PUBLIC_VALUE = 0xD0000132,
329 /** DH private value attribute. */
330 TEE_ATTR_DH_PRIVATE_VALUE = 0xC0000232,
331 /** RSA OAEP label attribute. */
332 TEE_ATTR_RSA_OAEP_LABEL = 0xD0000930,
333 /** RSA PSS salt length attribute. */
334 TEE_ATTR_RSA_PSS_SALT_LENGTH = 0xF0000A30,
335 /** ECC public value X attribute. */
336 TEE_ATTR_ECC_PUBLIC_VALUE_X = 0xD0000141,
337 /** ECC public value Y attribute. */
338 TEE_ATTR_ECC_PUBLIC_VALUE_Y = 0xD0000241,
339 /** ECC private value attribute. */
340 TEE_ATTR_ECC_PRIVATE_VALUE = 0xC0000341,
341 /** ECC curve attribute. */
342 TEE_ATTR_ECC_CURVE = 0xF0000441,
343 /** ED25519 context attribute. */
344 TEE_ATTR_ED25519_CTX = 0xD0000643,
345 /** ED25519 public value attribute. */
346 TEE_ATTR_ED25519_PUBLIC_VALUE = 0xD0000743,
347 /** ED25519 private value attribute. */
348 TEE_ATTR_ED25519_PRIVATE_VALUE = 0xC0000843,
349 /** ED25519 PH attribute. */
350 TEE_ATTR_ED25519_PH = 0xF0000543,
351 /** X25519 public value attribute. */
352 TEE_ATTR_X25519_PUBLIC_VALUE = 0xD0000944,
353 /** X25519 private value attribute. */
354 TEE_ATTR_X25519_PRIVATE_VALUE = 0xC0000A44,
355 /** PBKDF2 HMAC password attribute. */
356 TEE_ATTR_PBKDF2_HMAC_PASSWORD = 0xD0000133,
357 /** PBKDF2 HMAC salt attribute. */
358 TEE_ATTR_PBKDF2_HMAC_SALT = 0xD0000134,
359 /** PRF label attribute. */
360 TEE_ATTR_PRF_LABEL = 0xD0000136,
361 /** PRF seed attribute. */
362 TEE_ATTR_PRF_SEED = 0xD0000137,
363 /** PRF hash algorithm attribute. */
364 TEE_ATTR_PRF_HASH_ALGORITHM = 0xF0000138,
365 /** HKDF salt attribute. */
366 TEE_ATTR_HKDF_SALT = 0xD0000946,
367 /** HKDF info attribute. */
368 TEE_ATTR_HKDF_INFO = 0xD0000A46,
369 /** PBKDF2 HMAC digest attribute. */
370 TEE_ATTR_PBKDF2_HMAC_DIGEST = 0xF0000135,
371 /** HKDF hash algorithm attribute. */
372 TEE_ATTR_HKDF_HASH_ALGORITHM = 0xF0000B46,
373 /** KDF key size attribute. */
374 TEE_ATTR_KDF_KEY_SIZE = 0xF0000C46,
375 };
376
377 /**
378 * @brief Enumerates the types of object.
379 *
380 * @since 20
381 */
382 enum TEE_ObjectType {
383 /** AES object type. */
384 TEE_TYPE_AES = 0xA0000010,
385 /** DES object type. */
386 TEE_TYPE_DES = 0xA0000011,
387 /** DES3 object type. */
388 TEE_TYPE_DES3 = 0xA0000013,
389 /** HMAC MD5 object type. */
390 TEE_TYPE_HMAC_MD5 = 0xA0000001,
391 /** HMAC SHA1 object type. */
392 TEE_TYPE_HMAC_SHA1 = 0xA0000002,
393 /** HMAC SHA224 object type. */
394 TEE_TYPE_HMAC_SHA224 = 0xA0000003,
395 /** HMAC SHA256 object type. */
396 TEE_TYPE_HMAC_SHA256 = 0xA0000004,
397 /** HMAC SHA384 object type. */
398 TEE_TYPE_HMAC_SHA384 = 0xA0000005,
399 /** HMAC SHA512 object type. */
400 TEE_TYPE_HMAC_SHA512 = 0xA0000006,
401 /** RSA public key object type. */
402 TEE_TYPE_RSA_PUBLIC_KEY = 0xA0000030,
403 /** RSA keypair object type. */
404 TEE_TYPE_RSA_KEYPAIR = 0xA1000030,
405 /** DSA public key object type. */
406 TEE_TYPE_DSA_PUBLIC_KEY = 0xA0000031,
407 /** DSA keypair object type. */
408 TEE_TYPE_DSA_KEYPAIR = 0xA1000031,
409 /** DH keypair object type. */
410 TEE_TYPE_DH_KEYPAIR = 0xA1000032,
411 /** Generic secret object type. */
412 TEE_TYPE_GENERIC_SECRET = 0xA0000000,
413 /** Data object type. */
414 TEE_TYPE_DATA = 0xA1000033,
415 /** Data GP1.1 object type. */
416 TEE_TYPE_DATA_GP1_1 = 0xA00000BF,
417 /** ECDSA public key object type. */
418 TEE_TYPE_ECDSA_PUBLIC_KEY = 0xA0000041,
419 /** ECDSA keypair object type. */
420 TEE_TYPE_ECDSA_KEYPAIR = 0xA1000041,
421 /** ECDH public key object type. */
422 TEE_TYPE_ECDH_PUBLIC_KEY = 0xA0000042,
423 /** ECDH keypair object type. */
424 TEE_TYPE_ECDH_KEYPAIR = 0xA1000042,
425 /** ED25519 public key object type. */
426 TEE_TYPE_ED25519_PUBLIC_KEY = 0xA0000043,
427 /** ED25519 keypair object type. */
428 TEE_TYPE_ED25519_KEYPAIR = 0xA1000043,
429 /** X25519 public key object type. */
430 TEE_TYPE_X25519_PUBLIC_KEY = 0xA0000044,
431 /** X25519 keypair object type. */
432 TEE_TYPE_X25519_KEYPAIR = 0xA1000044,
433 /** SM2 DSA public key object type. */
434 TEE_TYPE_SM2_DSA_PUBLIC_KEY = 0xA0000045,
435 /** SM2 DSA keypair object type. */
436 TEE_TYPE_SM2_DSA_KEYPAIR = 0xA1000045,
437 /** SM2 KEP public key object type. */
438 TEE_TYPE_SM2_KEP_PUBLIC_KEY = 0xA0000046,
439 /** SM2 KEP keypair object type. */
440 TEE_TYPE_SM2_KEP_KEYPAIR = 0xA1000046,
441 /** SM2 PKE public key object type. */
442 TEE_TYPE_SM2_PKE_PUBLIC_KEY = 0xA0000047,
443 /** SM2 PKE keypair object type. */
444 TEE_TYPE_SM2_PKE_KEYPAIR = 0xA1000047,
445 /** HMAC SM3 object type. */
446 TEE_TYPE_HMAC_SM3 = 0xA0000007,
447 /** SM4 object type. */
448 TEE_TYPE_SM4 = 0xA0000014,
449 /** HKDF object type. */
450 TEE_TYPE_HKDF = 0xA000004A,
451 /** SIP Hash object type. */
452 TEE_TYPE_SIP_HASH = 0xF0000002,
453 /** PBKDF2 HMAC object type. */
454 TEE_TYPE_PBKDF2_HMAC = 0xF0000004,
455 /** PRF object type. */
456 TEE_TYPE_PRF = 0xF0000005,
457 /** Corrupted object type. */
458 TEE_TYPE_CORRUPTED_OBJECT = 0xA00000BE,
459 };
460
461 /**
462 * @brief Maximum length for the object name.
463 *
464 * @since 20
465 */
466 #define OBJECT_NAME_LEN_MAX 256
467
468 /**
469 * @brief Defines an object handle.
470 *
471 * @since 20
472 */
473 struct __TEE_ObjectHandle {
474 /** Pointer to the data. */
475 void *dataPtr;
476 /** Length of the data. */
477 uint32_t dataLen;
478 /** Name of the data. */
479 uint8_t dataName[OBJECT_NAME_LEN_MAX];
480 /** Pointer to the object information. */
481 TEE_ObjectInfo *ObjectInfo;
482 /** Pointer to the attributes of the object. */
483 TEE_Attribute *Attribute;
484 /** Length of the attributes. */
485 uint32_t attributesLen;
486 /** CRT mode. */
487 uint32_t CRTMode;
488 /** File descriptor for info attributes. */
489 void *infoattrfd;
490 /** Flag for object generation. */
491 uint32_t generate_flag;
492 /** Storage ID for the object. */
493 uint32_t storage_id;
494 };
495
496 /**
497 * @brief Defines the <b>__TEE_ObjectHandle</b> struct.
498 *
499 * @see __TEE_ObjectHandle
500 *
501 * @since 20
502 */
503 typedef struct __TEE_ObjectHandle *TEE_ObjectHandle;
504
505 /**
506 * @brief Defines the length of the node.
507 *
508 * @since 20
509 */
510 #define NODE_LEN 8
511
512 /**
513 * @brief Defines an UUID of TA.
514 *
515 * @since 20
516 */
517 typedef struct tee_uuid {
518 /** Low part of the UUID time. */
519 uint32_t timeLow;
520 /** Mid part of the UUID time. */
521 uint16_t timeMid;
522 /** High part of the UUID time and version. */
523 uint16_t timeHiAndVersion;
524 /** Clock sequence and node of the UUID. */
525 uint8_t clockSeqAndNode[NODE_LEN];
526 } TEE_UUID;
527
528 /**
529 * @brief Defines the type of spawn UUID.
530 *
531 * @since 20
532 */
533 typedef struct spawn_uuid {
534 /** Indicates if the UUID is valid. */
535 uint64_t uuid_valid;
536 /** The spawn UUID. */
537 TEE_UUID uuid;
538 } spawn_uuid_t;
539
540 /**
541 * @brief Enumerates the result codes used in the TEEKit APIs.
542 *
543 * @since 20
544 */
545 enum TEE_Result_Value {
546 /** The operation is successful. */
547 TEE_SUCCESS = 0x00000000,
548 /** The command is invalid. */
549 TEE_ERROR_INVALID_CMD = 0x00000001,
550 /** The service does not exist. */
551 TEE_ERROR_SERVICE_NOT_EXIST = 0x00000002,
552 /** The session does not exist. */
553 TEE_ERROR_SESSION_NOT_EXIST = 0x00000003,
554 /** The number of sessions exceeds the limit. */
555 TEE_ERROR_SESSION_MAXIMUM = 0x00000004,
556 /** The service has been already registered. */
557 TEE_ERROR_REGISTER_EXIST_SERVICE = 0x00000005,
558 /** An internal error occurs. */
559 TEE_ERROR_TARGET_DEAD_FATAL = 0x00000006,
560 /** Failed to read data. */
561 TEE_ERROR_READ_DATA = 0x00000007,
562 /** Failed to write data. */
563 TEE_ERROR_WRITE_DATA = 0x00000008,
564 /** Failed to truncate data. */
565 TEE_ERROR_TRUNCATE_OBJECT = 0x00000009,
566 /** Failed to seek data. */
567 TEE_ERROR_SEEK_DATA = 0x0000000A,
568 /** Failed to synchronize data. */
569 TEE_ERROR_SYNC_DATA = 0x0000000B,
570 /** Failed to rename the file. */
571 TEE_ERROR_RENAME_OBJECT = 0x0000000C,
572 /** An error occurs when the TA is loaded. */
573 TEE_ERROR_TRUSTED_APP_LOAD_ERROR = 0x0000000D,
574 /** TA type is inconsistent with the loading mode. */
575 TEE_ERROR_OTRP_LOAD_NOT_MATCHED = 0x80000100,
576 /** The not open session's otrp service num exceeds. */
577 TEE_ERROR_OTRP_LOAD_EXCEED = 0x80000101,
578 /** UUID of load cmd is not inconsistent with the sec file. */
579 TEE_ERROR_OTRP_ACCESS_DENIED = 0x80000102,
580 /** Otrp service is aged. */
581 TEE_ERROR_OTRP_SERVICE_AGED = 0x80000103,
582 /** An I/O error occurs when data is stored. */
583 TEE_ERROR_STORAGE_EIO = 0x80001001,
584 /** The storage section is unavailable. */
585 TEE_ERROR_STORAGE_EAGAIN = 0x80001002,
586 /** The operation target is not a directory. */
587 TEE_ERROR_STORAGE_ENOTDIR = 0x80001003,
588 /** This operation cannot be performed on a directory. */
589 TEE_ERROR_STORAGE_EISDIR = 0x80001004,
590 /** The number of opened files exceeds the limit in system. */
591 TEE_ERROR_STORAGE_ENFILE = 0x80001005,
592 /** The number of files opened for the process exceeds the limit.*/
593 TEE_ERROR_STORAGE_EMFILE = 0x80001006,
594 /** The storage section is read only. */
595 TEE_ERROR_STORAGE_EROFS = 0x80001007,
596 /** The file object has been rolled back. */
597 TEE_ERROR_STORAGE_EROLLBACK = 0x80001008,
598 /** The file path is not correct. */
599 TEE_ERROR_STORAGE_PATH_WRONG = 0x8000100A,
600 /** The service message queue overflows. */
601 TEE_ERROR_MSG_QUEUE_OVERFLOW = 0x8000100B,
602 /** The subthread created by TA cannot access the service */
603 TEE_ERROR_SUBTHREAD_ACCESS = 0x8000100C,
604 /** Enable backup feature, original partition is inactive */
605 TEE_ERROR_ORIGIN_PARTITION_INACTIVE = 0x8000100D,
606 /** Enable backup feature, backup partition is inactive */
607 TEE_ERROR_BACKUP_PARTITION_INACTIVE = 0x8000100E,
608 /** The file object is corrupted. */
609 TEE_ERROR_CORRUPT_OBJECT = 0xF0100001,
610 /** The storage section is unavailable. */
611 TEE_ERROR_STORAGE_NOT_AVAILABLE = 0xF0100003,
612 /** The cipher text is incorrect. */
613 TEE_ERROR_CIPHERTEXT_INVALID = 0xF0100006,
614 /** Protocol error in socket connection. */
615 TEE_ISOCKET_ERROR_PROTOCOL = 0xF1007001,
616 /** The socket is closed by the remote end. */
617 TEE_ISOCKET_ERROR_REMOTE_CLOSED = 0xF1007002,
618 /** The socket connection timed out. */
619 TEE_ISOCKET_ERROR_TIMEOUT = 0xF1007003,
620 /** There is no resource available for the socket connection. */
621 TEE_ISOCKET_ERROR_OUT_OF_RESOURCES = 0xF1007004,
622 /** The buffer is too large for the socket connection. */
623 TEE_ISOCKET_ERROR_LARGE_BUFFER = 0xF1007005,
624 /** A warning is given in the socket connection. */
625 TEE_ISOCKET_WARNING_PROTOCOL = 0xF1007006,
626 /** Generic error. */
627 TEE_ERROR_GENERIC = 0xFFFF0000,
628 /** The access is denied. */
629 TEE_ERROR_ACCESS_DENIED = 0xFFFF0001,
630 /** The operation has been canceled. */
631 TEE_ERROR_CANCEL = 0xFFFF0002,
632 /** An access conflict occurs. */
633 TEE_ERROR_ACCESS_CONFLICT = 0xFFFF0003,
634 /** The data size exceeds the maximum. */
635 TEE_ERROR_EXCESS_DATA = 0xFFFF0004,
636 /** Incorrect data format. */
637 TEE_ERROR_BAD_FORMAT = 0xFFFF0005,
638 /** Incorrect parameters. */
639 TEE_ERROR_BAD_PARAMETERS = 0xFFFF0006,
640 /** The current state does not support the operation. */
641 TEE_ERROR_BAD_STATE = 0xFFFF0007,
642 /** Failed to find the target item. */
643 TEE_ERROR_ITEM_NOT_FOUND = 0xFFFF0008,
644 /** The API is not implemented. */
645 TEE_ERROR_NOT_IMPLEMENTED = 0xFFFF0009,
646 /** The API is not supported. */
647 TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A,
648 /** There is no data available for this operation. */
649 TEE_ERROR_NO_DATA = 0xFFFF000B,
650 /** There is no memory available for this operation. */
651 TEE_ERROR_OUT_OF_MEMORY = 0xFFFF000C,
652 /** The system does not respond to this operation. */
653 TEE_ERROR_BUSY = 0xFFFF000D,
654 /** Failed to communicate with the target. */
655 TEE_ERROR_COMMUNICATION = 0xFFFF000E,
656 /** A security error occurs. */
657 TEE_ERROR_SECURITY = 0xFFFF000F,
658 /** The buffer is insufficient for this operation. */
659 TEE_ERROR_SHORT_BUFFER = 0xFFFF0010,
660 /** The operation has been canceled. */
661 TEE_ERROR_EXTERNAL_CANCEL = 0xFFFF0011,
662 /** The service is in the pending state (asynchronous state). */
663 TEE_PENDING = 0xFFFF2000,
664 /** The service is in the pending state(). */
665 TEE_PENDING2 = 0xFFFF2001,
666 /** Reserved. */
667 TEE_PENDING3 = 0xFFFF2002,
668 /** The operation timed out. */
669 TEE_ERROR_TIMEOUT = 0xFFFF3001,
670 /** Overflow occurs. */
671 TEE_ERROR_OVERFLOW = 0xFFFF300f,
672 /** The TA is crashed. */
673 TEE_ERROR_TARGET_DEAD = 0xFFFF3024,
674 /** There is no enough space to store data. */
675 TEE_ERROR_STORAGE_NO_SPACE = 0xFFFF3041,
676 /** The MAC operation failed. */
677 TEE_ERROR_MAC_INVALID = 0xFFFF3071,
678 /** The signature verification failed. */
679 TEE_ERROR_SIGNATURE_INVALID = 0xFFFF3072,
680 /** Thecertificate verify failed. */
681 TEE_ERROR_CERTIFICATE_INVALID = 0xFFFF3073,
682 /** Interrupted by CFC. Broken control flow is detected. */
683 TEE_CLIENT_INTR = 0xFFFF4000,
684 /** Time is not set. */
685 TEE_ERROR_TIME_NOT_SET = 0xFFFF5000,
686 /** Time needs to be reset. */
687 TEE_ERROR_TIME_NEEDS_RESET = 0xFFFF5001,
688 /** System error. */
689 TEE_FAIL = 0xFFFF5002,
690 /** Base value of the timer error code. */
691 TEE_ERROR_TIMER = 0xFFFF6000,
692 /** Failed to create the timer. */
693 TEE_ERROR_TIMER_CREATE_FAILED = 0xFFFF6001,
694 /** Failed to destroy the timer. */
695 TEE_ERROR_TIMER_DESTROY_FAILED = 0xFFFF6002,
696 /** The timer is not found. */
697 TEE_ERROR_TIMER_NOT_FOUND = 0xFFFF6003,
698 /** Base value of RPMB error codes. */
699 TEE_ERROR_RPMB_BASE = 0xFFFF7000,
700 /** Generic error of RPMB operations. */
701 TEE_ERROR_RPMB_GENERIC = 0xFFFF7001,
702 /** Verify MAC failed in RPMB operations. */
703 TEE_ERROR_RPMB_MAC_FAIL = 0xFFFF7002,
704 /** Invalid counter in RPMB operations. */
705 TEE_ERROR_RPMB_COUNTER_FAIL = 0xFFFF7003,
706 /** Address check failed in RPMB operations. */
707 TEE_ERROR_RPMB_ADDR_FAIL = 0xFFFF7004,
708 /** Fail to write data to RPMB. */
709 TEE_ERROR_RPMB_WRITE_FAIL = 0xFFFF7005,
710 /** Fail to read data in RPMB. */
711 TEE_ERROR_RPMB_READ_FAIL = 0xFFFF7006,
712 /** Key is not provisioned in RPMB. */
713 TEE_ERROR_RPMB_KEY_NOT_PROGRAM = 0xFFFF7007,
714 /** Incorrect message type in RPMB response. */
715 TEE_ERROR_RPMB_RESP_UNEXPECT_MSGTYPE = 0xFFFF7100,
716 /** Incorrect message data block count in RPMB response. */
717 TEE_ERROR_RPMB_RESP_UNEXPECT_BLKCNT = 0xFFFF7101,
718 /** Incorrect message data block count in RPMB response. */
719 TEE_ERROR_RPMB_RESP_UNEXPECT_BLKIDX = 0xFFFF7102,
720 /** Incorrect message data counter in RPMB response. */
721 TEE_ERROR_RPMB_RESP_UNEXPECT_WRCNT = 0xFFFF7103,
722 /** Incorrect message data nonce in RPMB response. */
723 TEE_ERROR_RPMB_RESP_UNEXPECT_NONCE = 0xFFFF7104,
724 /** Incorrect message data MAC in RPMB response. */
725 TEE_ERROR_RPMB_RESP_UNEXPECT_MAC = 0xFFFF7105,
726 /** The file is not found in RPMB. */
727 TEE_ERROR_RPMB_FILE_NOT_FOUND = 0xFFFF7106,
728 /** No spece left for RPMB operations. */
729 TEE_ERROR_RPMB_NOSPC = 0xFFFF7107,
730 /** Exceeds max space of RPMB for this TA. */
731 TEE_ERROR_RPMB_SPC_CONFLICT = 0xFFFF7108,
732 /** RPMB service not ready. */
733 TEE_ERROR_RPMB_NOT_AVAILABLE = 0xFFFF7109,
734 /** RPMB partition is damaged. */
735 TEE_ERROR_RPMB_DAMAGED = 0xFFFF710A,
736 /** TUI is being used. */
737 TEE_ERROR_TUI_IN_USE = 0xFFFF7110,
738 /** Incorrect message switch channal in TUI response. */
739 TEE_ERROR_TUI_SWITCH_CHANNAL = 0xFFFF7111,
740 /** Incorrect message configurator driver in TUI response. */
741 TEE_ERROR_TUI_CFG_DRIVER = 0xFFFF7112,
742 /** Invalid TUI event. */
743 TEE_ERROR_TUI_INVALID_EVENT = 0xFFFF7113,
744 /** Incorrect message polling events in TUI response. */
745 TEE_ERROR_TUI_POLL_EVENT = 0xFFFF7114,
746 /** TUI is cancelled. */
747 TEE_ERROR_TUI_CANCELED = 0xFFFF7115,
748 /** TUI is exited. */
749 TEE_ERROR_TUI_EXIT = 0xFFFF7116,
750 /** TUI unavailable. */
751 TEE_ERROR_TUI_NOT_AVAILABLE = 0xFFFF7117,
752 /** sec flash is not available. */
753 TEE_ERROR_SEC_FLASH_NOT_AVAILABLE = 0xFFFF7118,
754 /** SE service has crashed or not enable. */
755 TEE_ERROR_SESRV_NOT_AVAILABLE = 0xFFFF7119,
756 /** The BIO service is not available. */
757 TEE_ERROR_BIOSRV_NOT_AVAILABLE = 0xFFFF711A,
758 /** The ROT service is not available. */
759 TEE_ERROR_ROTSRV_NOT_AVAILABLE = 0xFFFF711B,
760 /** The TA Anti-Rollback service is not available. */
761 TEE_ERROR_ARTSRV_NOT_AVAILABLE = 0xFFFF711C,
762 /** The HSM service is not available. */
763 TEE_ERROR_HSMSRV_NOT_AVAILABLE = 0xFFFF711D,
764 /** REE vrpmb agent check magic failed, maybe cache fail. */
765 TEE_ERROR_VRPMB_AGENT_FAIL = 0xFFFF7200,
766 /** REE ssd driver rw failed. */
767 TEE_ERROR_VRPMB_RW_FAIL = 0xFFFF7201,
768 /** vrpmb check super block mac failed. */
769 TEE_ERROR_VRPMB_SUPER_MAC_FAILED = 0xFFFF7202,
770 /** reject write to vrpmb. */
771 TEE_ERROR_VRPMB_WRITE_REJECT = 0xFFFF7203,
772 /** Failed to verify AntiRoot response. */
773 TEE_ERROR_ANTIROOT_RSP_FAIL = 0xFFFF9110,
774 /** AntiRoot error in invokeCmd(). */
775 TEE_ERROR_ANTIROOT_INVOKE_ERROR = 0xFFFF9111,
776 /** Audit failed. */
777 TEE_ERROR_AUDIT_FAIL = 0xFFFF9112,
778 /** Unused. */
779 TEE_FAIL2 = 0xFFFF9113,
780 /** IPC Channel overflow error. */
781 TEE_ERROR_IPC_OVERFLOW = 0xFFFF9114,
782 /** APM error. */
783 TEE_ERROR_APM = 0xFFFF9115,
784 /** CA auth file not exist. */
785 TEE_ERROR_CA_AUTHFILE_NOT_EXIST = 0xFFFF9116,
786 /** CA caller access is denied. */
787 TEE_ERROR_CA_CALLER_ACCESS_DENIED = 0xFFFF9117,
788 /** Invalid TA format. */
789 TEE_ERROR_INVALID_TA_FORMAT = 0xFFFF9118,
790 /** local dstb service sign report error. */
791 TEE_DSTB_LOCAL_SIGN_REPORT_ERROR = 0xFFFF9200,
792 /** remote dstb service sign report error. */
793 TEE_DSTB_REMOTE_SIGN_REPORT_ERROR = 0xFFFF9201,
794 /** local dstb service report cert chain error. */
795 TEE_DSTB_LOCAL_REPORT_CERT_CHAIN_ERROR = 0xFFFF9202,
796 /** remote dstb service report cert chain error. */
797 TEE_DSTB_REMOTE_REPORT_CERT_CHAIN_ERROR = 0xFFFF9203,
798 /** local dstb service verify report error. */
799 TEE_DSTB_LOCAL_REPORT_VERIFY_ERROR = 0xFFFF9204,
800 /** remote dstb service verify report error. */
801 TEE_DSTB_REMOTE_REPORT_VERIFY_ERROR = 0xFFFF9205,
802 /** local dstb service verify cert chain error. */
803 TEE_DSTB_LOCAL_CERT_CHAIN_VERIFY_ERROR = 0xFFFF9206,
804 /** remote dstb service verify cert chain error. */
805 TEE_DSTB_REMOTE_CERT_CHAIN_VERIFY_ERROR = 0xFFFF9207,
806 /** local dstb service key version error. */
807 TEE_DSTB_LOCAL_INVALID_KEY_VERSION_ERROR = 0xFFFF9208,
808 /** remote dstb service key version error. */
809 TEE_DSTB_REMOTE_INVALID_KEY_VERSION_ERROR = 0xFFFF9209,
810 /** udid is invalid. */
811 TEE_DSTB_INVALID_UDID = 0xFFFF920A,
812 /** dstb service derive key error. */
813 TEE_DSTB_DERIVE_KEY_ERROR = 0xFFFF920B,
814 /** dstb service of ree error. */
815 TEE_DSTB_REE_SRV_ERROR = 0xFFFF920C,
816 /** TA load fail becauce of anti-rollback. */
817 TEE_ERROR_TA_ANTI_ROLLBACK = 0xFFFF920D,
818 /** open_session fail becauce of race with close_session. */
819 TEE_ERROR_RETRY_OPEN_SESSION = 0xFFFF920E,
820 /** TA control file load fail. */
821 TEE_ERROR_TA_CTRL_FILE_LOAD_FAIL = 0xFFFF920F,
822 /** TA control file verify fail. */
823 TEE_ERROR_TA_CTRL_FILE_VERIFY_FAIL = 0xFFFF9210,
824 /** TA version is below the verison in control file. */
825 TEE_ERROR_TA_VER_BELOW_CONTROL_VER = 0xFFFF9211,
826 /** Local dstb cert chain validity check failed. */
827 TEE_DSTB_LOCAL_CERT_VALIDITY_ERROR = 0xFFFF9212,
828 /** Remote dstb cert chain validity check failed. */
829 TEE_DSTB_REMOTE_CERT_VALIDITY_ERROR = 0xFFFF9213,
830 };
831
832 /**
833 * @brief Login type definitions
834 *
835 * @since 20
836 */
837 enum TEE_LoginMethod {
838 /** Public login method. */
839 TEE_LOGIN_PUBLIC = 0x0,
840 /** User login method. */
841 TEE_LOGIN_USER,
842 /** Group login method. */
843 TEE_LOGIN_GROUP,
844 /** Application login method. */
845 TEE_LOGIN_APPLICATION = 0x4,
846 /** User-application login method. */
847 TEE_LOGIN_USER_APPLICATION = 0x5,
848 /** Group-application login method. */
849 TEE_LOGIN_GROUP_APPLICATION = 0x6,
850 /** Customized login type. */
851 TEE_LOGIN_IDENTIFY = 0x7,
852 /** Login type from the Linux kernel. */
853 TEEK_LOGIN_IDENTIFY = 0x80000001,
854 };
855
856 /**
857 * @brief Definitions the TEE Identity.
858 *
859 * @since 20
860 */
861 typedef struct {
862 /** Login method. */
863 uint32_t login;
864 /** The UUID of the identity. */
865 TEE_UUID uuid;
866 } TEE_Identity;
867
868 /**
869 * @brief Defines the return values.
870 *
871 * @since 20
872 */
873 typedef uint32_t TEE_Result;
874
875 /**
876 * @brief Defines the return values.
877 *
878 * @since 20
879 */
880 typedef TEE_Result TEEC_Result;
881
882 /**
883 * @brief Origin of the TEE.
884 *
885 * @since 20
886 */
887 #define TEE_ORIGIN_TEE 0x00000003
888
889 /**
890 * @brief Origin of the Trusted Application.
891 *
892 * @since 20
893 */
894 #define TEE_ORIGIN_TRUSTED_APP 0x00000004
895
896 #ifndef _TEE_TA_SESSION_HANDLE
897 /**
898 * @brief Defines the handle for a TA session.
899 *
900 * @since 20
901 */
902 #define _TEE_TA_SESSION_HANDLE
903 /**
904 * @brief Defines the handle of TA session.
905 *
906 * @since 20
907 */
908 typedef uint32_t TEE_TASessionHandle;
909 #endif
910
911 /**
912 * @brief Defines the pointer to <b>TEE_ObjectEnumHandle</b>.
913 *
914 * @see __TEE_ObjectEnumHandle
915 *
916 * @since 20
917 */
918 typedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle;
919
920 /**
921 * @brief Defines the pointer to <b>__TEE_OperationHandle</b>.
922 *
923 * @see __TEE_OperationHandle
924 *
925 * @since 20
926 */
927 typedef struct __TEE_OperationHandle *TEE_OperationHandle;
928
929 /**
930 * @brief Defines the infinite timeout value.
931 *
932 * @since 20
933 */
934 #define TEE_TIMEOUT_INFINITE (0xFFFFFFFF)
935
936 /**
937 * @brief Definitions the TEE time.
938 *
939 * @since 20
940 */
941 typedef struct {
942 /** Seconds part of the time. */
943 uint32_t seconds;
944 /** Milliseconds part of the time. */
945 uint32_t millis;
946 } TEE_Time;
947
948 /**
949 * @brief Definitions the date time of TEE.
950 *
951 * @since 20
952 */
953 typedef struct {
954 /** Seconds part of the date time. */
955 int32_t seconds;
956 /** Milliseconds part of the date time. */
957 int32_t millis;
958 /** Minutes part of the date time. */
959 int32_t min;
960 /** Hours part of the date time. */
961 int32_t hour;
962 /** Day part of the date time. */
963 int32_t day;
964 /** Month part of the date time. */
965 int32_t month;
966 /** Year part of the date time. */
967 int32_t year;
968 } TEE_Date_Time;
969
970 /**
971 * @brief Definitions the timer property of TEE.
972 *
973 * @since 20
974 */
975 typedef struct {
976 /** Type of the timer. */
977 uint32_t type;
978 /** Timer ID. */
979 uint32_t timer_id;
980 /** Timer class. */
981 uint32_t timer_class;
982 /** Reserved field for future use. */
983 uint32_t reserved2;
984 } TEE_timer_property;
985
986 #ifdef __cplusplus
987 }
988 #endif
989
990 #endif
991 /** @} */