17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef __TEE_DEFINES_H 177777dab0Sopenharmony_ci#define __TEE_DEFINES_H 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup TeeTrusted 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief TEE(Trusted Excution Environment) API. 247777dab0Sopenharmony_ci * Provides security capability APIs such as trusted storage, encryption and decryption, 257777dab0Sopenharmony_ci * and trusted time for trusted application development. 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 12 287777dab0Sopenharmony_ci */ 297777dab0Sopenharmony_ci 307777dab0Sopenharmony_ci/** 317777dab0Sopenharmony_ci * @file tee_defines.h 327777dab0Sopenharmony_ci * 337777dab0Sopenharmony_ci * @brief Defines basic data types and data structures of TEE. 347777dab0Sopenharmony_ci * 357777dab0Sopenharmony_ci * @library NA 367777dab0Sopenharmony_ci * @kit TEEKit 377777dab0Sopenharmony_ci * @syscap SystemCapability.Tee.TeeClient 387777dab0Sopenharmony_ci * @since 12 397777dab0Sopenharmony_ci * @version 1.0 407777dab0Sopenharmony_ci */ 417777dab0Sopenharmony_ci 427777dab0Sopenharmony_ci#include <stdint.h> 437777dab0Sopenharmony_ci#include <stdbool.h> 447777dab0Sopenharmony_ci#include <stddef.h> 457777dab0Sopenharmony_ci 467777dab0Sopenharmony_ci#ifdef __cplusplus 477777dab0Sopenharmony_ciextern "C" { 487777dab0Sopenharmony_ci#endif 497777dab0Sopenharmony_ci#ifndef TA_EXPORT 507777dab0Sopenharmony_ci#define TA_EXPORT 517777dab0Sopenharmony_ci#endif 527777dab0Sopenharmony_ci 537777dab0Sopenharmony_ci/** 547777dab0Sopenharmony_ci * @brief Defines the tee mutex handle. 557777dab0Sopenharmony_ci * 567777dab0Sopenharmony_ci * @since 12 577777dab0Sopenharmony_ci */ 587777dab0Sopenharmony_citypedef int *tee_mutex_handle; 597777dab0Sopenharmony_ci 607777dab0Sopenharmony_ci#define API_LEVEL1_1_1 2 617777dab0Sopenharmony_ci#define API_LEVEL1_2 3 627777dab0Sopenharmony_ci 637777dab0Sopenharmony_ci#define TEE_PARAMS_NUM 4 647777dab0Sopenharmony_ci#undef true 657777dab0Sopenharmony_ci#define true 1 667777dab0Sopenharmony_ci 677777dab0Sopenharmony_ci#undef false 687777dab0Sopenharmony_ci#define false 0 697777dab0Sopenharmony_ci 707777dab0Sopenharmony_ci#ifndef NULL 717777dab0Sopenharmony_ci#define NULL ((void *)0) 727777dab0Sopenharmony_ci#endif 737777dab0Sopenharmony_ci 747777dab0Sopenharmony_ci#define PARAM_NOT_USED(val) ((void)(val)) 757777dab0Sopenharmony_ci 767777dab0Sopenharmony_ci/** 777777dab0Sopenharmony_ci * @brief Enumerates the TEE parameter. 787777dab0Sopenharmony_ci * 797777dab0Sopenharmony_ci * @since 12 807777dab0Sopenharmony_ci */ 817777dab0Sopenharmony_citypedef union { 827777dab0Sopenharmony_ci struct { 837777dab0Sopenharmony_ci void *buffer; 847777dab0Sopenharmony_ci size_t size; 857777dab0Sopenharmony_ci } memref; 867777dab0Sopenharmony_ci struct { 877777dab0Sopenharmony_ci unsigned int a; 887777dab0Sopenharmony_ci unsigned int b; 897777dab0Sopenharmony_ci } value; 907777dab0Sopenharmony_ci struct { 917777dab0Sopenharmony_ci void *buffer; 927777dab0Sopenharmony_ci size_t size; 937777dab0Sopenharmony_ci } sharedmem; 947777dab0Sopenharmony_ci} TEE_Param; 957777dab0Sopenharmony_ci 967777dab0Sopenharmony_ci#define TEE_PARAM_TYPES(param0Type, param1Type, param2Type, param3Type) \ 977777dab0Sopenharmony_ci (((param3Type) << 12) | ((param2Type) << 8) | ((param1Type) << 4) | (param0Type)) 987777dab0Sopenharmony_ci 997777dab0Sopenharmony_ci#define TEE_PARAM_TYPE_GET(paramTypes, index) (((paramTypes) >> (4U * (index))) & 0x0F) 1007777dab0Sopenharmony_ci 1017777dab0Sopenharmony_ci/** 1027777dab0Sopenharmony_ci * @brief Checks parameter types. 1037777dab0Sopenharmony_ci * 1047777dab0Sopenharmony_ci * @param param_to_check Indicates the expected parameter values. 1057777dab0Sopenharmony_ci * @param valid0 Indicates the first parameter type to check. 1067777dab0Sopenharmony_ci * @param valid1 Indicates the second parameter type to check. 1077777dab0Sopenharmony_ci * @param valid2 Indicates the third parameter type to check. 1087777dab0Sopenharmony_ci * @param valid3 Indicates the fourth parameter type to check. 1097777dab0Sopenharmony_ci * 1107777dab0Sopenharmony_ci * @return Returns <b>true</b> if the parameter types are correct. 1117777dab0Sopenharmony_ci * Returns <b>false</b> otherwise. 1127777dab0Sopenharmony_ci * @since 12 1137777dab0Sopenharmony_ci */ 1147777dab0Sopenharmony_cistatic inline bool check_param_type(uint32_t param_to_check, uint32_t valid0, uint32_t valid1, uint32_t valid2, 1157777dab0Sopenharmony_ci uint32_t valid3) 1167777dab0Sopenharmony_ci{ 1177777dab0Sopenharmony_ci return (TEE_PARAM_TYPES(valid0, valid1, valid2, valid3) == param_to_check); 1187777dab0Sopenharmony_ci} 1197777dab0Sopenharmony_ci 1207777dab0Sopenharmony_ci/** 1217777dab0Sopenharmony_ci * @brief Enumerates the types of the TEE parameter. 1227777dab0Sopenharmony_ci * 1237777dab0Sopenharmony_ci * @since 12 1247777dab0Sopenharmony_ci */ 1257777dab0Sopenharmony_cienum TEE_ParamType { 1267777dab0Sopenharmony_ci TEE_PARAM_TYPE_NONE = 0x0, 1277777dab0Sopenharmony_ci TEE_PARAM_TYPE_VALUE_INPUT = 0x1, 1287777dab0Sopenharmony_ci TEE_PARAM_TYPE_VALUE_OUTPUT = 0x2, 1297777dab0Sopenharmony_ci TEE_PARAM_TYPE_VALUE_INOUT = 0x3, 1307777dab0Sopenharmony_ci TEE_PARAM_TYPE_MEMREF_INPUT = 0x5, 1317777dab0Sopenharmony_ci TEE_PARAM_TYPE_MEMREF_OUTPUT = 0x6, 1327777dab0Sopenharmony_ci TEE_PARAM_TYPE_MEMREF_INOUT = 0x7, 1337777dab0Sopenharmony_ci TEE_PARAM_TYPE_ION_INPUT = 0x8, 1347777dab0Sopenharmony_ci TEE_PARAM_TYPE_ION_SGLIST_INPUT = 0x9, 1357777dab0Sopenharmony_ci TEE_PARAM_TYPE_MEMREF_SHARED_INOUT = 0xa, 1367777dab0Sopenharmony_ci TEE_PARAM_TYPE_RESMEM_INPUT = 0xc, 1377777dab0Sopenharmony_ci TEE_PARAM_TYPE_RESMEM_OUTPUT = 0xd, 1387777dab0Sopenharmony_ci TEE_PARAM_TYPE_RESMEM_INOUT = 0xe, 1397777dab0Sopenharmony_ci}; 1407777dab0Sopenharmony_ci 1417777dab0Sopenharmony_ci#define S_VAR_NOT_USED(variable) \ 1427777dab0Sopenharmony_ci do { \ 1437777dab0Sopenharmony_ci (void)(variable); \ 1447777dab0Sopenharmony_ci } while (0) 1457777dab0Sopenharmony_ci 1467777dab0Sopenharmony_ci/** 1477777dab0Sopenharmony_ci * @brief Defines an object information. 1487777dab0Sopenharmony_ci * 1497777dab0Sopenharmony_ci * @since 12 1507777dab0Sopenharmony_ci */ 1517777dab0Sopenharmony_citypedef struct { 1527777dab0Sopenharmony_ci uint32_t objectType; 1537777dab0Sopenharmony_ci uint32_t objectSize; 1547777dab0Sopenharmony_ci uint32_t maxObjectSize; 1557777dab0Sopenharmony_ci uint32_t objectUsage; 1567777dab0Sopenharmony_ci uint32_t dataSize; 1577777dab0Sopenharmony_ci uint32_t dataPosition; 1587777dab0Sopenharmony_ci uint32_t handleFlags; 1597777dab0Sopenharmony_ci} TEE_ObjectInfo; 1607777dab0Sopenharmony_ci 1617777dab0Sopenharmony_ci/** 1627777dab0Sopenharmony_ci * @brief Defines an object attribute. 1637777dab0Sopenharmony_ci * 1647777dab0Sopenharmony_ci * @since 12 1657777dab0Sopenharmony_ci */ 1667777dab0Sopenharmony_citypedef struct { 1677777dab0Sopenharmony_ci uint32_t attributeID; 1687777dab0Sopenharmony_ci union { 1697777dab0Sopenharmony_ci struct { 1707777dab0Sopenharmony_ci void *buffer; 1717777dab0Sopenharmony_ci size_t length; 1727777dab0Sopenharmony_ci } ref; 1737777dab0Sopenharmony_ci struct { 1747777dab0Sopenharmony_ci uint32_t a; 1757777dab0Sopenharmony_ci uint32_t b; 1767777dab0Sopenharmony_ci } value; 1777777dab0Sopenharmony_ci } content; 1787777dab0Sopenharmony_ci} TEE_Attribute; 1797777dab0Sopenharmony_ci 1807777dab0Sopenharmony_ci/** 1817777dab0Sopenharmony_ci * @brief Enumerates the types of object attribute. 1827777dab0Sopenharmony_ci * 1837777dab0Sopenharmony_ci * @since 12 1847777dab0Sopenharmony_ci */ 1857777dab0Sopenharmony_cienum TEE_ObjectAttribute { 1867777dab0Sopenharmony_ci TEE_ATTR_SECRET_VALUE = 0xC0000000, 1877777dab0Sopenharmony_ci TEE_ATTR_RSA_MODULUS = 0xD0000130, 1887777dab0Sopenharmony_ci TEE_ATTR_RSA_PUBLIC_EXPONENT = 0xD0000230, 1897777dab0Sopenharmony_ci TEE_ATTR_RSA_PRIVATE_EXPONENT = 0xC0000330, 1907777dab0Sopenharmony_ci TEE_ATTR_RSA_PRIME1 = 0xC0000430, 1917777dab0Sopenharmony_ci TEE_ATTR_RSA_PRIME2 = 0xC0000530, 1927777dab0Sopenharmony_ci TEE_ATTR_RSA_EXPONENT1 = 0xC0000630, 1937777dab0Sopenharmony_ci TEE_ATTR_RSA_EXPONENT2 = 0xC0000730, 1947777dab0Sopenharmony_ci TEE_ATTR_RSA_COEFFICIENT = 0xC0000830, 1957777dab0Sopenharmony_ci TEE_ATTR_RSA_MGF1_HASH = 0xF0000830, 1967777dab0Sopenharmony_ci TEE_ATTR_DSA_PRIME = 0xD0001031, 1977777dab0Sopenharmony_ci TEE_ATTR_DSA_SUBPRIME = 0xD0001131, 1987777dab0Sopenharmony_ci TEE_ATTR_DSA_BASE = 0xD0001231, 1997777dab0Sopenharmony_ci TEE_ATTR_DSA_PUBLIC_VALUE = 0xD0000131, 2007777dab0Sopenharmony_ci TEE_ATTR_DSA_PRIVATE_VALUE = 0xC0000231, 2017777dab0Sopenharmony_ci TEE_ATTR_DH_PRIME = 0xD0001032, 2027777dab0Sopenharmony_ci TEE_ATTR_DH_SUBPRIME = 0xD0001132, 2037777dab0Sopenharmony_ci TEE_ATTR_DH_BASE = 0xD0001232, 2047777dab0Sopenharmony_ci TEE_ATTR_DH_X_BITS = 0xF0001332, 2057777dab0Sopenharmony_ci TEE_ATTR_DH_PUBLIC_VALUE = 0xD0000132, 2067777dab0Sopenharmony_ci TEE_ATTR_DH_PRIVATE_VALUE = 0xC0000232, 2077777dab0Sopenharmony_ci TEE_ATTR_RSA_OAEP_LABEL = 0xD0000930, 2087777dab0Sopenharmony_ci TEE_ATTR_RSA_PSS_SALT_LENGTH = 0xF0000A30, 2097777dab0Sopenharmony_ci TEE_ATTR_ECC_PUBLIC_VALUE_X = 0xD0000141, 2107777dab0Sopenharmony_ci TEE_ATTR_ECC_PUBLIC_VALUE_Y = 0xD0000241, 2117777dab0Sopenharmony_ci TEE_ATTR_ECC_PRIVATE_VALUE = 0xC0000341, 2127777dab0Sopenharmony_ci TEE_ATTR_ECC_CURVE = 0xF0000441, 2137777dab0Sopenharmony_ci TEE_ATTR_ED25519_CTX = 0xD0000643, 2147777dab0Sopenharmony_ci TEE_ATTR_ED25519_PUBLIC_VALUE = 0xD0000743, 2157777dab0Sopenharmony_ci TEE_ATTR_ED25519_PRIVATE_VALUE = 0xC0000843, 2167777dab0Sopenharmony_ci TEE_ATTR_ED25519_PH = 0xF0000543, 2177777dab0Sopenharmony_ci TEE_ATTR_X25519_PUBLIC_VALUE = 0xD0000944, 2187777dab0Sopenharmony_ci TEE_ATTR_X25519_PRIVATE_VALUE = 0xC0000A44, 2197777dab0Sopenharmony_ci TEE_ATTR_PBKDF2_HMAC_PASSWORD = 0xD0000133, 2207777dab0Sopenharmony_ci TEE_ATTR_PBKDF2_HMAC_SALT = 0xD0000134, 2217777dab0Sopenharmony_ci TEE_ATTR_PBKDF2_HMAC_DIGEST = 0xF0000135, 2227777dab0Sopenharmony_ci}; 2237777dab0Sopenharmony_ci 2247777dab0Sopenharmony_ci/** 2257777dab0Sopenharmony_ci * @brief Enumerates the types of object. 2267777dab0Sopenharmony_ci * 2277777dab0Sopenharmony_ci * @since 12 2287777dab0Sopenharmony_ci */ 2297777dab0Sopenharmony_cienum TEE_ObjectType { 2307777dab0Sopenharmony_ci TEE_TYPE_AES = 0xA0000010, 2317777dab0Sopenharmony_ci TEE_TYPE_DES = 0xA0000011, 2327777dab0Sopenharmony_ci TEE_TYPE_DES3 = 0xA0000013, 2337777dab0Sopenharmony_ci TEE_TYPE_HMAC_MD5 = 0xA0000001, 2347777dab0Sopenharmony_ci TEE_TYPE_HMAC_SHA1 = 0xA0000002, 2357777dab0Sopenharmony_ci TEE_TYPE_HMAC_SHA224 = 0xA0000003, 2367777dab0Sopenharmony_ci TEE_TYPE_HMAC_SHA256 = 0xA0000004, 2377777dab0Sopenharmony_ci TEE_TYPE_HMAC_SHA384 = 0xA0000005, 2387777dab0Sopenharmony_ci TEE_TYPE_HMAC_SHA512 = 0xA0000006, 2397777dab0Sopenharmony_ci TEE_TYPE_RSA_PUBLIC_KEY = 0xA0000030, 2407777dab0Sopenharmony_ci TEE_TYPE_RSA_KEYPAIR = 0xA1000030, 2417777dab0Sopenharmony_ci TEE_TYPE_DSA_PUBLIC_KEY = 0xA0000031, 2427777dab0Sopenharmony_ci TEE_TYPE_DSA_KEYPAIR = 0xA1000031, 2437777dab0Sopenharmony_ci TEE_TYPE_DH_KEYPAIR = 0xA1000032, 2447777dab0Sopenharmony_ci TEE_TYPE_GENERIC_SECRET = 0xA0000000, 2457777dab0Sopenharmony_ci TEE_TYPE_DATA = 0xA1000033, 2467777dab0Sopenharmony_ci TEE_TYPE_DATA_GP1_1 = 0xA00000BF, 2477777dab0Sopenharmony_ci TEE_TYPE_ECDSA_PUBLIC_KEY = 0xA0000041, 2487777dab0Sopenharmony_ci TEE_TYPE_ECDSA_KEYPAIR = 0xA1000041, 2497777dab0Sopenharmony_ci TEE_TYPE_ECDH_PUBLIC_KEY = 0xA0000042, 2507777dab0Sopenharmony_ci TEE_TYPE_ECDH_KEYPAIR = 0xA1000042, 2517777dab0Sopenharmony_ci TEE_TYPE_ED25519_PUBLIC_KEY = 0xA0000043, 2527777dab0Sopenharmony_ci TEE_TYPE_ED25519_KEYPAIR = 0xA1000043, 2537777dab0Sopenharmony_ci TEE_TYPE_X25519_PUBLIC_KEY = 0xA0000044, 2547777dab0Sopenharmony_ci TEE_TYPE_X25519_KEYPAIR = 0xA1000044, 2557777dab0Sopenharmony_ci TEE_TYPE_SM2_DSA_PUBLIC_KEY = 0xA0000045, 2567777dab0Sopenharmony_ci TEE_TYPE_SM2_DSA_KEYPAIR = 0xA1000045, 2577777dab0Sopenharmony_ci TEE_TYPE_SM2_KEP_PUBLIC_KEY = 0xA0000046, 2587777dab0Sopenharmony_ci TEE_TYPE_SM2_KEP_KEYPAIR = 0xA1000046, 2597777dab0Sopenharmony_ci TEE_TYPE_SM2_PKE_PUBLIC_KEY = 0xA0000047, 2607777dab0Sopenharmony_ci TEE_TYPE_SM2_PKE_KEYPAIR = 0xA1000047, 2617777dab0Sopenharmony_ci TEE_TYPE_HMAC_SM3 = 0xA0000007, 2627777dab0Sopenharmony_ci TEE_TYPE_SM4 = 0xA0000014, 2637777dab0Sopenharmony_ci TEE_TYPE_SIP_HASH = 0xF0000002, 2647777dab0Sopenharmony_ci TEE_TYPE_PBKDF2_HMAC = 0xF0000004, 2657777dab0Sopenharmony_ci 2667777dab0Sopenharmony_ci TEE_TYPE_CORRUPTED_OBJECT = 0xA00000BE, 2677777dab0Sopenharmony_ci}; 2687777dab0Sopenharmony_ci 2697777dab0Sopenharmony_ci#define OBJECT_NAME_LEN_MAX 255 2707777dab0Sopenharmony_ci 2717777dab0Sopenharmony_ci/** 2727777dab0Sopenharmony_ci * @brief Defines an object handle. 2737777dab0Sopenharmony_ci * 2747777dab0Sopenharmony_ci * @since 12 2757777dab0Sopenharmony_ci */ 2767777dab0Sopenharmony_cistruct __TEE_ObjectHandle { 2777777dab0Sopenharmony_ci void *dataPtr; 2787777dab0Sopenharmony_ci uint32_t dataLen; 2797777dab0Sopenharmony_ci uint8_t dataName[OBJECT_NAME_LEN_MAX]; 2807777dab0Sopenharmony_ci TEE_ObjectInfo *ObjectInfo; 2817777dab0Sopenharmony_ci TEE_Attribute *Attribute; 2827777dab0Sopenharmony_ci uint32_t attributesLen; 2837777dab0Sopenharmony_ci uint32_t CRTMode; 2847777dab0Sopenharmony_ci void *infoattrfd; 2857777dab0Sopenharmony_ci uint32_t generate_flag; 2867777dab0Sopenharmony_ci uint32_t storage_id; 2877777dab0Sopenharmony_ci}; 2887777dab0Sopenharmony_ci 2897777dab0Sopenharmony_ci/** 2907777dab0Sopenharmony_ci * @brief Defines the <b>__TEE_ObjectHandle</b> struct. 2917777dab0Sopenharmony_ci * 2927777dab0Sopenharmony_ci * @see __TEE_ObjectHandle 2937777dab0Sopenharmony_ci * 2947777dab0Sopenharmony_ci * @since 12 2957777dab0Sopenharmony_ci */ 2967777dab0Sopenharmony_citypedef struct __TEE_ObjectHandle *TEE_ObjectHandle; 2977777dab0Sopenharmony_ci 2987777dab0Sopenharmony_ci#define NODE_LEN 8 2997777dab0Sopenharmony_ci 3007777dab0Sopenharmony_ci/** 3017777dab0Sopenharmony_ci * @brief Defines an UUID of TA. 3027777dab0Sopenharmony_ci * 3037777dab0Sopenharmony_ci * @since 12 3047777dab0Sopenharmony_ci */ 3057777dab0Sopenharmony_citypedef struct tee_uuid { 3067777dab0Sopenharmony_ci uint32_t timeLow; 3077777dab0Sopenharmony_ci uint16_t timeMid; 3087777dab0Sopenharmony_ci uint16_t timeHiAndVersion; 3097777dab0Sopenharmony_ci uint8_t clockSeqAndNode[NODE_LEN]; 3107777dab0Sopenharmony_ci} TEE_UUID; 3117777dab0Sopenharmony_ci 3127777dab0Sopenharmony_ci/** 3137777dab0Sopenharmony_ci * @brief Defines the type of spawn UUID. 3147777dab0Sopenharmony_ci * 3157777dab0Sopenharmony_ci * @since 12 3167777dab0Sopenharmony_ci */ 3177777dab0Sopenharmony_citypedef struct spawn_uuid { 3187777dab0Sopenharmony_ci uint64_t uuid_valid; 3197777dab0Sopenharmony_ci TEE_UUID uuid; 3207777dab0Sopenharmony_ci} spawn_uuid_t; 3217777dab0Sopenharmony_ci 3227777dab0Sopenharmony_ci/** 3237777dab0Sopenharmony_ci * @brief Enumerates the result codes used in the TEEKit APIs. 3247777dab0Sopenharmony_ci * 3257777dab0Sopenharmony_ci * @since 12 3267777dab0Sopenharmony_ci */ 3277777dab0Sopenharmony_cienum TEE_Result_Value { 3287777dab0Sopenharmony_ci /* The operation is successful. */ 3297777dab0Sopenharmony_ci TEE_SUCCESS = 0x00000000, 3307777dab0Sopenharmony_ci /* The command is invalid. */ 3317777dab0Sopenharmony_ci TEE_ERROR_INVALID_CMD = 0x00000001, 3327777dab0Sopenharmony_ci /* The service does not exist. */ 3337777dab0Sopenharmony_ci TEE_ERROR_SERVICE_NOT_EXIST = 0x00000002, 3347777dab0Sopenharmony_ci /* The session does not exist. */ 3357777dab0Sopenharmony_ci TEE_ERROR_SESSION_NOT_EXIST = 0x00000003, 3367777dab0Sopenharmony_ci /* The number of sessions exceeds the limit. */ 3377777dab0Sopenharmony_ci TEE_ERROR_SESSION_MAXIMUM = 0x00000004, 3387777dab0Sopenharmony_ci /* The service has been already registered. */ 3397777dab0Sopenharmony_ci TEE_ERROR_REGISTER_EXIST_SERVICE = 0x00000005, 3407777dab0Sopenharmony_ci /* An internal error occurs. */ 3417777dab0Sopenharmony_ci TEE_ERROR_TARGET_DEAD_FATAL = 0x00000006, 3427777dab0Sopenharmony_ci /* Failed to read data. */ 3437777dab0Sopenharmony_ci TEE_ERROR_READ_DATA = 0x00000007, 3447777dab0Sopenharmony_ci /* Failed to write data. */ 3457777dab0Sopenharmony_ci TEE_ERROR_WRITE_DATA = 0x00000008, 3467777dab0Sopenharmony_ci /* Failed to truncate data. */ 3477777dab0Sopenharmony_ci TEE_ERROR_TRUNCATE_OBJECT = 0x00000009, 3487777dab0Sopenharmony_ci /* Failed to seek data. */ 3497777dab0Sopenharmony_ci TEE_ERROR_SEEK_DATA = 0x0000000A, 3507777dab0Sopenharmony_ci /* Failed to synchronize data. */ 3517777dab0Sopenharmony_ci TEE_ERROR_SYNC_DATA = 0x0000000B, 3527777dab0Sopenharmony_ci /* Failed to rename the file. */ 3537777dab0Sopenharmony_ci TEE_ERROR_RENAME_OBJECT = 0x0000000C, 3547777dab0Sopenharmony_ci /* An error occurs when the TA is loaded. */ 3557777dab0Sopenharmony_ci TEE_ERROR_TRUSTED_APP_LOAD_ERROR = 0x0000000D, 3567777dab0Sopenharmony_ci /* An I/O error occurs when data is stored. */ 3577777dab0Sopenharmony_ci TEE_ERROR_STORAGE_EIO = 0x80001001, 3587777dab0Sopenharmony_ci /* The storage section is unavailable. */ 3597777dab0Sopenharmony_ci TEE_ERROR_STORAGE_EAGAIN = 0x80001002, 3607777dab0Sopenharmony_ci /* The operation target is not a directory. */ 3617777dab0Sopenharmony_ci TEE_ERROR_STORAGE_ENOTDIR = 0x80001003, 3627777dab0Sopenharmony_ci /* This operation cannot be performed on a directory. */ 3637777dab0Sopenharmony_ci TEE_ERROR_STORAGE_EISDIR = 0x80001004, 3647777dab0Sopenharmony_ci /* The number of opened files exceeds the limit in system. */ 3657777dab0Sopenharmony_ci TEE_ERROR_STORAGE_ENFILE = 0x80001005, 3667777dab0Sopenharmony_ci /* The number of files opened for the process exceeds the limit.*/ 3677777dab0Sopenharmony_ci TEE_ERROR_STORAGE_EMFILE = 0x80001006, 3687777dab0Sopenharmony_ci /* The storage section is read only. */ 3697777dab0Sopenharmony_ci TEE_ERROR_STORAGE_EROFS = 0x80001007, 3707777dab0Sopenharmony_ci /* The file path is not correct. */ 3717777dab0Sopenharmony_ci TEE_ERROR_STORAGE_PATH_WRONG = 0x8000100A, 3727777dab0Sopenharmony_ci /* The service message queue overflows. */ 3737777dab0Sopenharmony_ci TEE_ERROR_MSG_QUEUE_OVERFLOW = 0x8000100B, 3747777dab0Sopenharmony_ci /* The file object is corrupted. */ 3757777dab0Sopenharmony_ci TEE_ERROR_CORRUPT_OBJECT = 0xF0100001, 3767777dab0Sopenharmony_ci /* The storage section is unavailable. */ 3777777dab0Sopenharmony_ci TEE_ERROR_STORAGE_NOT_AVAILABLE = 0xF0100003, 3787777dab0Sopenharmony_ci /* The cipher text is incorrect. */ 3797777dab0Sopenharmony_ci TEE_ERROR_CIPHERTEXT_INVALID = 0xF0100006, 3807777dab0Sopenharmony_ci /* Protocol error in socket connection. */ 3817777dab0Sopenharmony_ci TEE_ISOCKET_ERROR_PROTOCOL = 0xF1007001, 3827777dab0Sopenharmony_ci /* The socket is closed by the remote end. */ 3837777dab0Sopenharmony_ci TEE_ISOCKET_ERROR_REMOTE_CLOSED = 0xF1007002, 3847777dab0Sopenharmony_ci /* The socket connection timed out. */ 3857777dab0Sopenharmony_ci TEE_ISOCKET_ERROR_TIMEOUT = 0xF1007003, 3867777dab0Sopenharmony_ci /* There is no resource available for the socket connection. */ 3877777dab0Sopenharmony_ci TEE_ISOCKET_ERROR_OUT_OF_RESOURCES = 0xF1007004, 3887777dab0Sopenharmony_ci /* The buffer is too large for the socket connection. */ 3897777dab0Sopenharmony_ci TEE_ISOCKET_ERROR_LARGE_BUFFER = 0xF1007005, 3907777dab0Sopenharmony_ci /* A warning is given in the socket connection. */ 3917777dab0Sopenharmony_ci TEE_ISOCKET_WARNING_PROTOCOL = 0xF1007006, 3927777dab0Sopenharmony_ci /* Generic error. */ 3937777dab0Sopenharmony_ci TEE_ERROR_GENERIC = 0xFFFF0000, 3947777dab0Sopenharmony_ci /* The access is denied. */ 3957777dab0Sopenharmony_ci TEE_ERROR_ACCESS_DENIED = 0xFFFF0001, 3967777dab0Sopenharmony_ci /* The operation has been canceled. */ 3977777dab0Sopenharmony_ci TEE_ERROR_CANCEL = 0xFFFF0002, 3987777dab0Sopenharmony_ci /* An access conflict occurs. */ 3997777dab0Sopenharmony_ci TEE_ERROR_ACCESS_CONFLICT = 0xFFFF0003, 4007777dab0Sopenharmony_ci /* The data size exceeds the maximum. */ 4017777dab0Sopenharmony_ci TEE_ERROR_EXCESS_DATA = 0xFFFF0004, 4027777dab0Sopenharmony_ci /* Incorrect data format. */ 4037777dab0Sopenharmony_ci TEE_ERROR_BAD_FORMAT = 0xFFFF0005, 4047777dab0Sopenharmony_ci /* Incorrect parameters. */ 4057777dab0Sopenharmony_ci TEE_ERROR_BAD_PARAMETERS = 0xFFFF0006, 4067777dab0Sopenharmony_ci /* The current state does not support the operation. */ 4077777dab0Sopenharmony_ci TEE_ERROR_BAD_STATE = 0xFFFF0007, 4087777dab0Sopenharmony_ci /* Failed to find the target item. */ 4097777dab0Sopenharmony_ci TEE_ERROR_ITEM_NOT_FOUND = 0xFFFF0008, 4107777dab0Sopenharmony_ci /* The API is not implemented. */ 4117777dab0Sopenharmony_ci TEE_ERROR_NOT_IMPLEMENTED = 0xFFFF0009, 4127777dab0Sopenharmony_ci /* The API is not supported. */ 4137777dab0Sopenharmony_ci TEE_ERROR_NOT_SUPPORTED = 0xFFFF000A, 4147777dab0Sopenharmony_ci /* There is no data available for this operation. */ 4157777dab0Sopenharmony_ci TEE_ERROR_NO_DATA = 0xFFFF000B, 4167777dab0Sopenharmony_ci /* There is no memory available for this operation. */ 4177777dab0Sopenharmony_ci TEE_ERROR_OUT_OF_MEMORY = 0xFFFF000C, 4187777dab0Sopenharmony_ci /* The system does not respond to this operation. */ 4197777dab0Sopenharmony_ci TEE_ERROR_BUSY = 0xFFFF000D, 4207777dab0Sopenharmony_ci /* Failed to communicate with the target. */ 4217777dab0Sopenharmony_ci TEE_ERROR_COMMUNICATION = 0xFFFF000E, 4227777dab0Sopenharmony_ci /* A security error occurs. */ 4237777dab0Sopenharmony_ci TEE_ERROR_SECURITY = 0xFFFF000F, 4247777dab0Sopenharmony_ci /* The buffer is insufficient for this operation. */ 4257777dab0Sopenharmony_ci TEE_ERROR_SHORT_BUFFER = 0xFFFF0010, 4267777dab0Sopenharmony_ci /* The operation has been canceled. */ 4277777dab0Sopenharmony_ci TEE_ERROR_EXTERNAL_CANCEL = 0xFFFF0011, 4287777dab0Sopenharmony_ci /* The service is in the pending state (asynchronous state). */ 4297777dab0Sopenharmony_ci TEE_PENDING = 0xFFFF2000, 4307777dab0Sopenharmony_ci /* The service is in the pending state(). */ 4317777dab0Sopenharmony_ci TEE_PENDING2 = 0xFFFF2001, 4327777dab0Sopenharmony_ci /* Reserved. */ 4337777dab0Sopenharmony_ci TEE_PENDING3 = 0xFFFF2002, 4347777dab0Sopenharmony_ci /* The operation timed out. */ 4357777dab0Sopenharmony_ci TEE_ERROR_TIMEOUT = 0xFFFF3001, 4367777dab0Sopenharmony_ci /* Overflow occurs. */ 4377777dab0Sopenharmony_ci TEE_ERROR_OVERFLOW = 0xFFFF300f, 4387777dab0Sopenharmony_ci /* The TA is crashed. */ 4397777dab0Sopenharmony_ci TEE_ERROR_TARGET_DEAD = 0xFFFF3024, 4407777dab0Sopenharmony_ci /* There is no enough space to store data. */ 4417777dab0Sopenharmony_ci TEE_ERROR_STORAGE_NO_SPACE = 0xFFFF3041, 4427777dab0Sopenharmony_ci /* The MAC operation failed. */ 4437777dab0Sopenharmony_ci TEE_ERROR_MAC_INVALID = 0xFFFF3071, 4447777dab0Sopenharmony_ci /* The signature verification failed. */ 4457777dab0Sopenharmony_ci TEE_ERROR_SIGNATURE_INVALID = 0xFFFF3072, 4467777dab0Sopenharmony_ci /* Interrupted by CFC. Broken control flow is detected. */ 4477777dab0Sopenharmony_ci TEE_CLIENT_INTR = 0xFFFF4000, 4487777dab0Sopenharmony_ci /* Time is not set. */ 4497777dab0Sopenharmony_ci TEE_ERROR_TIME_NOT_SET = 0xFFFF5000, 4507777dab0Sopenharmony_ci /* Time needs to be reset. */ 4517777dab0Sopenharmony_ci TEE_ERROR_TIME_NEEDS_RESET = 0xFFFF5001, 4527777dab0Sopenharmony_ci /* System error. */ 4537777dab0Sopenharmony_ci TEE_FAIL = 0xFFFF5002, 4547777dab0Sopenharmony_ci /* Base value of the timer error code. */ 4557777dab0Sopenharmony_ci TEE_ERROR_TIMER = 0xFFFF6000, 4567777dab0Sopenharmony_ci /* Failed to create the timer. */ 4577777dab0Sopenharmony_ci TEE_ERROR_TIMER_CREATE_FAILED = 0xFFFF6001, 4587777dab0Sopenharmony_ci /* Failed to destroy the timer. */ 4597777dab0Sopenharmony_ci TEE_ERROR_TIMER_DESTORY_FAILED = 0xFFFF6002, 4607777dab0Sopenharmony_ci /* The timer is not found. */ 4617777dab0Sopenharmony_ci TEE_ERROR_TIMER_NOT_FOUND = 0xFFFF6003, 4627777dab0Sopenharmony_ci /* Generic error of RPMB operations. */ 4637777dab0Sopenharmony_ci TEE_ERROR_RPMB_GENERIC = 0xFFFF7001, 4647777dab0Sopenharmony_ci /* Verify MAC failed in RPMB operations. */ 4657777dab0Sopenharmony_ci TEE_ERROR_RPMB_MAC_FAIL = 0xFFFF7002, 4667777dab0Sopenharmony_ci /* Incorrect message data MAC in RPMB response. */ 4677777dab0Sopenharmony_ci TEE_ERROR_RPMB_RESP_UNEXPECT_MAC = 0xFFFF7105, 4687777dab0Sopenharmony_ci /* The file is not found in RPMB. */ 4697777dab0Sopenharmony_ci TEE_ERROR_RPMB_FILE_NOT_FOUND = 0xFFFF7106, 4707777dab0Sopenharmony_ci /* No spece left for RPMB operations. */ 4717777dab0Sopenharmony_ci TEE_ERROR_RPMB_NOSPC = 0xFFFF7107, 4727777dab0Sopenharmony_ci /* sec flash is not available. */ 4737777dab0Sopenharmony_ci TEE_ERROR_SEC_FLASH_NOT_AVAILABLE = 0xFFFF7118, 4747777dab0Sopenharmony_ci /* The BIO service is not available. */ 4757777dab0Sopenharmony_ci TEE_ERROR_BIOSRV_NOT_AVAILABLE = 0xFFFF711A, 4767777dab0Sopenharmony_ci /* The ROT service is not available. */ 4777777dab0Sopenharmony_ci TEE_ERROR_ROTSRV_NOT_AVAILABLE = 0xFFFF711B, 4787777dab0Sopenharmony_ci /* The TA Anti-Rollback service is not available. */ 4797777dab0Sopenharmony_ci TEE_ERROR_ARTSRV_NOT_AVAILABLE = 0xFFFF711C, 4807777dab0Sopenharmony_ci /* The HSM service is not available. */ 4817777dab0Sopenharmony_ci TEE_ERROR_HSMSRV_NOT_AVAILABLE = 0xFFFF711D, 4827777dab0Sopenharmony_ci /* Failed to verify AntiRoot response. */ 4837777dab0Sopenharmony_ci TEE_ERROR_ANTIROOT_RSP_FAIL = 0xFFFF9110, 4847777dab0Sopenharmony_ci /* AntiRoot error in invokeCmd(). */ 4857777dab0Sopenharmony_ci TEE_ERROR_ANTIROOT_INVOKE_ERROR = 0xFFFF9111, 4867777dab0Sopenharmony_ci /* Audit failed. */ 4877777dab0Sopenharmony_ci TEE_ERROR_AUDIT_FAIL = 0xFFFF9112, 4887777dab0Sopenharmony_ci /* Unused. */ 4897777dab0Sopenharmony_ci TEE_FAIL2 = 0xFFFF9113, 4907777dab0Sopenharmony_ci}; 4917777dab0Sopenharmony_ci 4927777dab0Sopenharmony_ci/** 4937777dab0Sopenharmony_ci * @brief Login type definitions 4947777dab0Sopenharmony_ci * 4957777dab0Sopenharmony_ci * @since 12 4967777dab0Sopenharmony_ci */ 4977777dab0Sopenharmony_cienum TEE_LoginMethod { 4987777dab0Sopenharmony_ci TEE_LOGIN_PUBLIC = 0x0, 4997777dab0Sopenharmony_ci TEE_LOGIN_USER, 5007777dab0Sopenharmony_ci TEE_LOGIN_GROUP, 5017777dab0Sopenharmony_ci TEE_LOGIN_APPLICATION = 0x4, 5027777dab0Sopenharmony_ci TEE_LOGIN_USER_APPLICATION = 0x5, 5037777dab0Sopenharmony_ci TEE_LOGIN_GROUP_APPLICATION = 0x6, 5047777dab0Sopenharmony_ci TEE_LOGIN_IDENTIFY = 0x7, /* Customized login type */ 5057777dab0Sopenharmony_ci}; 5067777dab0Sopenharmony_ci 5077777dab0Sopenharmony_ci/** 5087777dab0Sopenharmony_ci * @brief Definitions the TEE Identity. 5097777dab0Sopenharmony_ci * 5107777dab0Sopenharmony_ci * @since 12 5117777dab0Sopenharmony_ci */ 5127777dab0Sopenharmony_citypedef struct { 5137777dab0Sopenharmony_ci uint32_t login; 5147777dab0Sopenharmony_ci TEE_UUID uuid; 5157777dab0Sopenharmony_ci} TEE_Identity; 5167777dab0Sopenharmony_ci 5177777dab0Sopenharmony_ci/** 5187777dab0Sopenharmony_ci * @brief Defines the return values. 5197777dab0Sopenharmony_ci * 5207777dab0Sopenharmony_ci * @since 12 5217777dab0Sopenharmony_ci * @version 1.0 5227777dab0Sopenharmony_ci */ 5237777dab0Sopenharmony_citypedef uint32_t TEE_Result; 5247777dab0Sopenharmony_ci 5257777dab0Sopenharmony_ci/** 5267777dab0Sopenharmony_ci * @brief Defines the return values. 5277777dab0Sopenharmony_ci * 5287777dab0Sopenharmony_ci * @since 12 5297777dab0Sopenharmony_ci * @version 1.0 5307777dab0Sopenharmony_ci */ 5317777dab0Sopenharmony_citypedef TEE_Result TEEC_Result; 5327777dab0Sopenharmony_ci 5337777dab0Sopenharmony_ci#define TEE_ORIGIN_TEE 0x00000003 5347777dab0Sopenharmony_ci#define TEE_ORIGIN_TRUSTED_APP 0x00000004 5357777dab0Sopenharmony_ci 5367777dab0Sopenharmony_ci#ifndef _TEE_TA_SESSION_HANDLE 5377777dab0Sopenharmony_ci#define _TEE_TA_SESSION_HANDLE 5387777dab0Sopenharmony_ci/** 5397777dab0Sopenharmony_ci * @brief Defines the handle of TA session. 5407777dab0Sopenharmony_ci * 5417777dab0Sopenharmony_ci * @since 12 5427777dab0Sopenharmony_ci */ 5437777dab0Sopenharmony_citypedef uint32_t TEE_TASessionHandle; 5447777dab0Sopenharmony_ci#endif 5457777dab0Sopenharmony_ci 5467777dab0Sopenharmony_ci/** 5477777dab0Sopenharmony_ci * @brief Defines the pointer to <b>TEE_ObjectEnumHandle</b>. 5487777dab0Sopenharmony_ci * 5497777dab0Sopenharmony_ci * @see __TEE_ObjectEnumHandle 5507777dab0Sopenharmony_ci * 5517777dab0Sopenharmony_ci * @since 12 5527777dab0Sopenharmony_ci */ 5537777dab0Sopenharmony_citypedef struct __TEE_ObjectEnumHandle *TEE_ObjectEnumHandle; 5547777dab0Sopenharmony_ci 5557777dab0Sopenharmony_ci/** 5567777dab0Sopenharmony_ci * @brief Defines the pointer to <b>__TEE_OperationHandle</b>. 5577777dab0Sopenharmony_ci * 5587777dab0Sopenharmony_ci * @see __TEE_OperationHandle 5597777dab0Sopenharmony_ci * 5607777dab0Sopenharmony_ci * @since 12 5617777dab0Sopenharmony_ci */ 5627777dab0Sopenharmony_citypedef struct __TEE_OperationHandle *TEE_OperationHandle; 5637777dab0Sopenharmony_ci 5647777dab0Sopenharmony_ci#define TEE_TIMEOUT_INFINITE (0xFFFFFFFF) 5657777dab0Sopenharmony_ci 5667777dab0Sopenharmony_ci/** 5677777dab0Sopenharmony_ci * @brief Definitions the TEE time. 5687777dab0Sopenharmony_ci * 5697777dab0Sopenharmony_ci * @since 12 5707777dab0Sopenharmony_ci */ 5717777dab0Sopenharmony_citypedef struct { 5727777dab0Sopenharmony_ci uint32_t seconds; 5737777dab0Sopenharmony_ci uint32_t millis; 5747777dab0Sopenharmony_ci} TEE_Time; 5757777dab0Sopenharmony_ci 5767777dab0Sopenharmony_ci/** 5777777dab0Sopenharmony_ci * @brief Definitions the date time of TEE. 5787777dab0Sopenharmony_ci * 5797777dab0Sopenharmony_ci * @since 12 5807777dab0Sopenharmony_ci */ 5817777dab0Sopenharmony_citypedef struct { 5827777dab0Sopenharmony_ci int32_t seconds; 5837777dab0Sopenharmony_ci int32_t millis; 5847777dab0Sopenharmony_ci int32_t min; 5857777dab0Sopenharmony_ci int32_t hour; 5867777dab0Sopenharmony_ci int32_t day; 5877777dab0Sopenharmony_ci int32_t month; 5887777dab0Sopenharmony_ci int32_t year; 5897777dab0Sopenharmony_ci} TEE_Date_Time; 5907777dab0Sopenharmony_ci 5917777dab0Sopenharmony_ci/** 5927777dab0Sopenharmony_ci * @brief Definitions the timer property of TEE. 5937777dab0Sopenharmony_ci * 5947777dab0Sopenharmony_ci * @since 12 5957777dab0Sopenharmony_ci */ 5967777dab0Sopenharmony_citypedef struct { 5977777dab0Sopenharmony_ci uint32_t type; 5987777dab0Sopenharmony_ci uint32_t timer_id; 5997777dab0Sopenharmony_ci uint32_t timer_class; 6007777dab0Sopenharmony_ci uint32_t reserved2; 6017777dab0Sopenharmony_ci} TEE_timer_property; 6027777dab0Sopenharmony_ci 6037777dab0Sopenharmony_ci#ifdef __cplusplus 6047777dab0Sopenharmony_ci} 6057777dab0Sopenharmony_ci#endif 6067777dab0Sopenharmony_ci/** @} */ 6077777dab0Sopenharmony_ci#endif 608