xref: /optee_os/lib/libutee/include/tee_api_defines.h (revision 1bb929836182ecb96d2d9d268daa807c67596396)
1*1bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */
2b0104773SPascal Brand /*
3b0104773SPascal Brand  * Copyright (c) 2014, STMicroelectronics International N.V.
4b0104773SPascal Brand  * All rights reserved.
5b0104773SPascal Brand  *
6b0104773SPascal Brand  * Redistribution and use in source and binary forms, with or without
7b0104773SPascal Brand  * modification, are permitted provided that the following conditions are met:
8b0104773SPascal Brand  *
9b0104773SPascal Brand  * 1. Redistributions of source code must retain the above copyright notice,
10b0104773SPascal Brand  * this list of conditions and the following disclaimer.
11b0104773SPascal Brand  *
12b0104773SPascal Brand  * 2. Redistributions in binary form must reproduce the above copyright notice,
13b0104773SPascal Brand  * this list of conditions and the following disclaimer in the documentation
14b0104773SPascal Brand  * and/or other materials provided with the distribution.
15b0104773SPascal Brand  *
16b0104773SPascal Brand  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17b0104773SPascal Brand  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18b0104773SPascal Brand  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19b0104773SPascal Brand  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
20b0104773SPascal Brand  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21b0104773SPascal Brand  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22b0104773SPascal Brand  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23b0104773SPascal Brand  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24b0104773SPascal Brand  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25b0104773SPascal Brand  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26b0104773SPascal Brand  * POSSIBILITY OF SUCH DAMAGE.
27b0104773SPascal Brand  */
28b0104773SPascal Brand 
2979a3c601SCedric Chaumont /* Based on GP TEE Internal Core API Specification Version 1.1 */
3079a3c601SCedric Chaumont 
31b0104773SPascal Brand #ifndef TEE_API_DEFINES_H
32b0104773SPascal Brand #define TEE_API_DEFINES_H
33b0104773SPascal Brand 
3479a3c601SCedric Chaumont #define TEE_INT_CORE_API_SPEC_VERSION     0x0000000A
3579a3c601SCedric Chaumont 
36b0104773SPascal Brand #define TEE_HANDLE_NULL                   0
37b0104773SPascal Brand 
38b0104773SPascal Brand #define TEE_TIMEOUT_INFINITE              0xFFFFFFFF
39b0104773SPascal Brand 
40b0104773SPascal Brand /* API Error Codes */
41b0104773SPascal Brand #define TEE_SUCCESS                       0x00000000
4279a3c601SCedric Chaumont #define TEE_ERROR_CORRUPT_OBJECT          0xF0100001
4379a3c601SCedric Chaumont #define TEE_ERROR_CORRUPT_OBJECT_2        0xF0100002
4479a3c601SCedric Chaumont #define TEE_ERROR_STORAGE_NOT_AVAILABLE   0xF0100003
4579a3c601SCedric Chaumont #define TEE_ERROR_STORAGE_NOT_AVAILABLE_2 0xF0100004
46b0104773SPascal Brand #define TEE_ERROR_GENERIC                 0xFFFF0000
47b0104773SPascal Brand #define TEE_ERROR_ACCESS_DENIED           0xFFFF0001
48b0104773SPascal Brand #define TEE_ERROR_CANCEL                  0xFFFF0002
49b0104773SPascal Brand #define TEE_ERROR_ACCESS_CONFLICT         0xFFFF0003
50b0104773SPascal Brand #define TEE_ERROR_EXCESS_DATA             0xFFFF0004
51b0104773SPascal Brand #define TEE_ERROR_BAD_FORMAT              0xFFFF0005
52b0104773SPascal Brand #define TEE_ERROR_BAD_PARAMETERS          0xFFFF0006
53b0104773SPascal Brand #define TEE_ERROR_BAD_STATE               0xFFFF0007
54b0104773SPascal Brand #define TEE_ERROR_ITEM_NOT_FOUND          0xFFFF0008
55b0104773SPascal Brand #define TEE_ERROR_NOT_IMPLEMENTED         0xFFFF0009
56b0104773SPascal Brand #define TEE_ERROR_NOT_SUPPORTED           0xFFFF000A
57b0104773SPascal Brand #define TEE_ERROR_NO_DATA                 0xFFFF000B
58b0104773SPascal Brand #define TEE_ERROR_OUT_OF_MEMORY           0xFFFF000C
59b0104773SPascal Brand #define TEE_ERROR_BUSY                    0xFFFF000D
60b0104773SPascal Brand #define TEE_ERROR_COMMUNICATION           0xFFFF000E
61b0104773SPascal Brand #define TEE_ERROR_SECURITY                0xFFFF000F
62b0104773SPascal Brand #define TEE_ERROR_SHORT_BUFFER            0xFFFF0010
6379a3c601SCedric Chaumont #define TEE_ERROR_EXTERNAL_CANCEL         0xFFFF0011
64b0104773SPascal Brand #define TEE_ERROR_OVERFLOW                0xFFFF300F
65b0104773SPascal Brand #define TEE_ERROR_TARGET_DEAD             0xFFFF3024
66b0104773SPascal Brand #define TEE_ERROR_STORAGE_NO_SPACE        0xFFFF3041
67b0104773SPascal Brand #define TEE_ERROR_MAC_INVALID             0xFFFF3071
68b0104773SPascal Brand #define TEE_ERROR_SIGNATURE_INVALID       0xFFFF3072
69b0104773SPascal Brand #define TEE_ERROR_TIME_NOT_SET            0xFFFF5000
70b0104773SPascal Brand #define TEE_ERROR_TIME_NEEDS_RESET        0xFFFF5001
71b0104773SPascal Brand 
72b0104773SPascal Brand /* Parameter Type Constants */
73b0104773SPascal Brand #define TEE_PARAM_TYPE_NONE             0
74b0104773SPascal Brand #define TEE_PARAM_TYPE_VALUE_INPUT      1
75b0104773SPascal Brand #define TEE_PARAM_TYPE_VALUE_OUTPUT     2
76b0104773SPascal Brand #define TEE_PARAM_TYPE_VALUE_INOUT      3
77b0104773SPascal Brand #define TEE_PARAM_TYPE_MEMREF_INPUT     5
78b0104773SPascal Brand #define TEE_PARAM_TYPE_MEMREF_OUTPUT    6
79b0104773SPascal Brand #define TEE_PARAM_TYPE_MEMREF_INOUT     7
80b0104773SPascal Brand 
81b0104773SPascal Brand /* Login Type Constants */
82b0104773SPascal Brand #define TEE_LOGIN_PUBLIC                0x00000000
83b0104773SPascal Brand #define TEE_LOGIN_USER                  0x00000001
84b0104773SPascal Brand #define TEE_LOGIN_GROUP                 0x00000002
85b0104773SPascal Brand #define TEE_LOGIN_APPLICATION           0x00000004
86b0104773SPascal Brand #define TEE_LOGIN_APPLICATION_USER      0x00000005
87b0104773SPascal Brand #define TEE_LOGIN_APPLICATION_GROUP     0x00000006
88b0104773SPascal Brand #define TEE_LOGIN_TRUSTED_APP           0xF0000000
89b0104773SPascal Brand 
90b0104773SPascal Brand /* Origin Code Constants */
91b0104773SPascal Brand #define TEE_ORIGIN_API                  0x00000001
92b0104773SPascal Brand #define TEE_ORIGIN_COMMS                0x00000002
93b0104773SPascal Brand #define TEE_ORIGIN_TEE                  0x00000003
94b0104773SPascal Brand #define TEE_ORIGIN_TRUSTED_APP          0x00000004
95b0104773SPascal Brand 
96b0104773SPascal Brand /* Property Sets pseudo handles */
97b0104773SPascal Brand #define TEE_PROPSET_TEE_IMPLEMENTATION  (TEE_PropSetHandle)0xFFFFFFFD
9879a3c601SCedric Chaumont #define TEE_PROPSET_CURRENT_CLIENT      (TEE_PropSetHandle)0xFFFFFFFE
9979a3c601SCedric Chaumont #define TEE_PROPSET_CURRENT_TA          (TEE_PropSetHandle)0xFFFFFFFF
100b0104773SPascal Brand 
101b0104773SPascal Brand /* Memory Access Rights Constants */
102b0104773SPascal Brand #define TEE_MEMORY_ACCESS_READ             0x00000001
103b0104773SPascal Brand #define TEE_MEMORY_ACCESS_WRITE            0x00000002
104b0104773SPascal Brand #define TEE_MEMORY_ACCESS_ANY_OWNER        0x00000004
105b0104773SPascal Brand 
10645d7fb1cSCedric Chaumont /* Memory Management Constant */
10745d7fb1cSCedric Chaumont #define TEE_MALLOC_FILL_ZERO               0x00000000
10845d7fb1cSCedric Chaumont 
109b0104773SPascal Brand /* Other constants */
110b0104773SPascal Brand #define TEE_STORAGE_PRIVATE                0x00000001
11179a3c601SCedric Chaumont 
112b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_READ          0x00000001
113b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_WRITE         0x00000002
114b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_WRITE_META    0x00000004
115b0104773SPascal Brand #define TEE_DATA_FLAG_SHARE_READ           0x00000010
116b0104773SPascal Brand #define TEE_DATA_FLAG_SHARE_WRITE          0x00000020
11784431ae3SCedric Chaumont #define TEE_DATA_FLAG_OVERWRITE            0x00000400
118b0104773SPascal Brand #define TEE_DATA_MAX_POSITION              0xFFFFFFFF
119b0104773SPascal Brand #define TEE_OBJECT_ID_MAX_LEN              64
120b0104773SPascal Brand #define TEE_USAGE_EXTRACTABLE              0x00000001
121b0104773SPascal Brand #define TEE_USAGE_ENCRYPT                  0x00000002
122b0104773SPascal Brand #define TEE_USAGE_DECRYPT                  0x00000004
123b0104773SPascal Brand #define TEE_USAGE_MAC                      0x00000008
124b0104773SPascal Brand #define TEE_USAGE_SIGN                     0x00000010
125b0104773SPascal Brand #define TEE_USAGE_VERIFY                   0x00000020
126b0104773SPascal Brand #define TEE_USAGE_DERIVE                   0x00000040
127b0104773SPascal Brand #define TEE_HANDLE_FLAG_PERSISTENT         0x00010000
128b0104773SPascal Brand #define TEE_HANDLE_FLAG_INITIALIZED        0x00020000
129b0104773SPascal Brand #define TEE_HANDLE_FLAG_KEY_SET            0x00040000
130b0104773SPascal Brand #define TEE_HANDLE_FLAG_EXPECT_TWO_KEYS    0x00080000
131b0104773SPascal Brand #define TEE_OPERATION_CIPHER               1
132b0104773SPascal Brand #define TEE_OPERATION_MAC                  3
133b0104773SPascal Brand #define TEE_OPERATION_AE                   4
134b0104773SPascal Brand #define TEE_OPERATION_DIGEST               5
135b0104773SPascal Brand #define TEE_OPERATION_ASYMMETRIC_CIPHER    6
136b0104773SPascal Brand #define TEE_OPERATION_ASYMMETRIC_SIGNATURE 7
137b0104773SPascal Brand #define TEE_OPERATION_KEY_DERIVATION       8
13879a3c601SCedric Chaumont #define TEE_OPERATION_STATE_INITIAL        0x00000000
13979a3c601SCedric Chaumont #define TEE_OPERATION_STATE_ACTIVE         0x00000001
140b0104773SPascal Brand 
141b0104773SPascal Brand /* Algorithm Identifiers */
142b0104773SPascal Brand #define TEE_ALG_AES_ECB_NOPAD                   0x10000010
143b0104773SPascal Brand #define TEE_ALG_AES_CBC_NOPAD                   0x10000110
144b0104773SPascal Brand #define TEE_ALG_AES_CTR                         0x10000210
145b0104773SPascal Brand #define TEE_ALG_AES_CTS                         0x10000310
146b0104773SPascal Brand #define TEE_ALG_AES_XTS                         0x10000410
147b0104773SPascal Brand #define TEE_ALG_AES_CBC_MAC_NOPAD               0x30000110
148b0104773SPascal Brand #define TEE_ALG_AES_CBC_MAC_PKCS5               0x30000510
149b0104773SPascal Brand #define TEE_ALG_AES_CMAC                        0x30000610
150b0104773SPascal Brand #define TEE_ALG_AES_CCM                         0x40000710
151b0104773SPascal Brand #define TEE_ALG_AES_GCM                         0x40000810
152b0104773SPascal Brand #define TEE_ALG_DES_ECB_NOPAD                   0x10000011
153b0104773SPascal Brand #define TEE_ALG_DES_CBC_NOPAD                   0x10000111
154b0104773SPascal Brand #define TEE_ALG_DES_CBC_MAC_NOPAD               0x30000111
155b0104773SPascal Brand #define TEE_ALG_DES_CBC_MAC_PKCS5               0x30000511
156b0104773SPascal Brand #define TEE_ALG_DES3_ECB_NOPAD                  0x10000013
157b0104773SPascal Brand #define TEE_ALG_DES3_CBC_NOPAD                  0x10000113
158b0104773SPascal Brand #define TEE_ALG_DES3_CBC_MAC_NOPAD              0x30000113
159b0104773SPascal Brand #define TEE_ALG_DES3_CBC_MAC_PKCS5              0x30000513
160b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_MD5           0x70001830
161b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA1          0x70002830
162b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA224        0x70003830
163b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA256        0x70004830
164b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA384        0x70005830
165b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA512        0x70006830
166b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_MD5SHA1       0x7000F830
167b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1      0x70212930
168b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224    0x70313930
169b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256    0x70414930
170b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384    0x70515930
171b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512    0x70616930
172b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_V1_5                0x60000130
173b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1      0x60210230
174b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224    0x60310230
175b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256    0x60410230
176b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384    0x60510230
177b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512    0x60610230
178b0104773SPascal Brand #define TEE_ALG_RSA_NOPAD                       0x60000030
179b0104773SPascal Brand #define TEE_ALG_DSA_SHA1                        0x70002131
18079a3c601SCedric Chaumont #define TEE_ALG_DSA_SHA224                      0x70003131
18179a3c601SCedric Chaumont #define TEE_ALG_DSA_SHA256                      0x70004131
182b0104773SPascal Brand #define TEE_ALG_DH_DERIVE_SHARED_SECRET         0x80000032
183b0104773SPascal Brand #define TEE_ALG_MD5                             0x50000001
184b0104773SPascal Brand #define TEE_ALG_SHA1                            0x50000002
185b0104773SPascal Brand #define TEE_ALG_SHA224                          0x50000003
186b0104773SPascal Brand #define TEE_ALG_SHA256                          0x50000004
187b0104773SPascal Brand #define TEE_ALG_SHA384                          0x50000005
188b0104773SPascal Brand #define TEE_ALG_SHA512                          0x50000006
189b0104773SPascal Brand #define TEE_ALG_MD5SHA1                         0x5000000F
190b0104773SPascal Brand #define TEE_ALG_HMAC_MD5                        0x30000001
191b0104773SPascal Brand #define TEE_ALG_HMAC_SHA1                       0x30000002
192b0104773SPascal Brand #define TEE_ALG_HMAC_SHA224                     0x30000003
193b0104773SPascal Brand #define TEE_ALG_HMAC_SHA256                     0x30000004
194b0104773SPascal Brand #define TEE_ALG_HMAC_SHA384                     0x30000005
195b0104773SPascal Brand #define TEE_ALG_HMAC_SHA512                     0x30000006
196c988227aSPascal Brand /*
197c988227aSPascal Brand  * Fix GP Internal Core API v1.1
198c988227aSPascal Brand  *     "Table 6-12:  Structure of Algorithm Identifier"
199c988227aSPascal Brand  *     indicates ECDSA have the algorithm "0x41" and ECDH "0x42"
200c988227aSPascal Brand  * whereas
201c988227aSPascal Brand  *     "Table 6-11:  List of Algorithm Identifiers" defines
202c988227aSPascal Brand  *     TEE_ALG_ECDSA_P192 as 0x70001042
203c988227aSPascal Brand  *
204c988227aSPascal Brand  * We chose to define TEE_ALG_ECDSA_P192 as 0x70001041 (conform to table 6-12)
205c988227aSPascal Brand  */
206c988227aSPascal Brand #define TEE_ALG_ECDSA_P192                      0x70001041
207c988227aSPascal Brand #define TEE_ALG_ECDSA_P224                      0x70002041
208c988227aSPascal Brand #define TEE_ALG_ECDSA_P256                      0x70003041
209c988227aSPascal Brand #define TEE_ALG_ECDSA_P384                      0x70004041
210c988227aSPascal Brand #define TEE_ALG_ECDSA_P521                      0x70005041
21179a3c601SCedric Chaumont #define TEE_ALG_ECDH_P192                       0x80001042
21279a3c601SCedric Chaumont #define TEE_ALG_ECDH_P224                       0x80002042
21379a3c601SCedric Chaumont #define TEE_ALG_ECDH_P256                       0x80003042
21479a3c601SCedric Chaumont #define TEE_ALG_ECDH_P384                       0x80004042
21579a3c601SCedric Chaumont #define TEE_ALG_ECDH_P521                       0x80005042
216b0104773SPascal Brand 
217b0104773SPascal Brand /* Object Types */
218b0104773SPascal Brand 
219b0104773SPascal Brand #define TEE_TYPE_AES                        0xA0000010
220b0104773SPascal Brand #define TEE_TYPE_DES                        0xA0000011
221b0104773SPascal Brand #define TEE_TYPE_DES3                       0xA0000013
222b0104773SPascal Brand #define TEE_TYPE_HMAC_MD5                   0xA0000001
223b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA1                  0xA0000002
224b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA224                0xA0000003
225b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA256                0xA0000004
226b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA384                0xA0000005
227b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA512                0xA0000006
228b0104773SPascal Brand #define TEE_TYPE_RSA_PUBLIC_KEY             0xA0000030
229b0104773SPascal Brand #define TEE_TYPE_RSA_KEYPAIR                0xA1000030
230b0104773SPascal Brand #define TEE_TYPE_DSA_PUBLIC_KEY             0xA0000031
231b0104773SPascal Brand #define TEE_TYPE_DSA_KEYPAIR                0xA1000031
232b0104773SPascal Brand #define TEE_TYPE_DH_KEYPAIR                 0xA1000032
23379a3c601SCedric Chaumont #define TEE_TYPE_ECDSA_PUBLIC_KEY           0xA0000041
23479a3c601SCedric Chaumont #define TEE_TYPE_ECDSA_KEYPAIR              0xA1000041
23579a3c601SCedric Chaumont #define TEE_TYPE_ECDH_PUBLIC_KEY            0xA0000042
23679a3c601SCedric Chaumont #define TEE_TYPE_ECDH_KEYPAIR               0xA1000042
237b0104773SPascal Brand #define TEE_TYPE_GENERIC_SECRET             0xA0000000
23879a3c601SCedric Chaumont #define TEE_TYPE_CORRUPTED_OBJECT           0xA00000BE
23979a3c601SCedric Chaumont #define TEE_TYPE_DATA                       0xA00000BF
240b0104773SPascal Brand 
241b0104773SPascal Brand /* List of Object or Operation Attributes */
242b0104773SPascal Brand 
243b0104773SPascal Brand #define TEE_ATTR_SECRET_VALUE               0xC0000000
244b0104773SPascal Brand #define TEE_ATTR_RSA_MODULUS                0xD0000130
245b0104773SPascal Brand #define TEE_ATTR_RSA_PUBLIC_EXPONENT        0xD0000230
246b0104773SPascal Brand #define TEE_ATTR_RSA_PRIVATE_EXPONENT       0xC0000330
247b0104773SPascal Brand #define TEE_ATTR_RSA_PRIME1                 0xC0000430
248b0104773SPascal Brand #define TEE_ATTR_RSA_PRIME2                 0xC0000530
249b0104773SPascal Brand #define TEE_ATTR_RSA_EXPONENT1              0xC0000630
250b0104773SPascal Brand #define TEE_ATTR_RSA_EXPONENT2              0xC0000730
251b0104773SPascal Brand #define TEE_ATTR_RSA_COEFFICIENT            0xC0000830
252b0104773SPascal Brand #define TEE_ATTR_DSA_PRIME                  0xD0001031
253b0104773SPascal Brand #define TEE_ATTR_DSA_SUBPRIME               0xD0001131
254b0104773SPascal Brand #define TEE_ATTR_DSA_BASE                   0xD0001231
255b0104773SPascal Brand #define TEE_ATTR_DSA_PUBLIC_VALUE           0xD0000131
256b0104773SPascal Brand #define TEE_ATTR_DSA_PRIVATE_VALUE          0xC0000231
257b0104773SPascal Brand #define TEE_ATTR_DH_PRIME                   0xD0001032
258b0104773SPascal Brand #define TEE_ATTR_DH_SUBPRIME                0xD0001132
259b0104773SPascal Brand #define TEE_ATTR_DH_BASE                    0xD0001232
260b0104773SPascal Brand #define TEE_ATTR_DH_X_BITS                  0xF0001332
261b0104773SPascal Brand #define TEE_ATTR_DH_PUBLIC_VALUE            0xD0000132
262b0104773SPascal Brand #define TEE_ATTR_DH_PRIVATE_VALUE           0xC0000232
263b0104773SPascal Brand #define TEE_ATTR_RSA_OAEP_LABEL             0xD0000930
264b0104773SPascal Brand #define TEE_ATTR_RSA_PSS_SALT_LENGTH        0xF0000A30
26579a3c601SCedric Chaumont #define TEE_ATTR_ECC_PUBLIC_VALUE_X         0xD0000141
26679a3c601SCedric Chaumont #define TEE_ATTR_ECC_PUBLIC_VALUE_Y         0xD0000241
26779a3c601SCedric Chaumont #define TEE_ATTR_ECC_PRIVATE_VALUE          0xC0000341
26879a3c601SCedric Chaumont #define TEE_ATTR_ECC_CURVE                  0xF0000441
269b0104773SPascal Brand 
270177603c7SJens Wiklander #define TEE_ATTR_BIT_PROTECTED		(1 << 28)
271177603c7SJens Wiklander #define TEE_ATTR_BIT_VALUE		(1 << 29)
2727583c59eSCedric Chaumont 
273316a94e7SPascal Brand /* List of Supported ECC Curves */
274316a94e7SPascal Brand #define TEE_ECC_CURVE_NIST_P192             0x00000001
275316a94e7SPascal Brand #define TEE_ECC_CURVE_NIST_P224             0x00000002
276316a94e7SPascal Brand #define TEE_ECC_CURVE_NIST_P256             0x00000003
277316a94e7SPascal Brand #define TEE_ECC_CURVE_NIST_P384             0x00000004
278316a94e7SPascal Brand #define TEE_ECC_CURVE_NIST_P521             0x00000005
279316a94e7SPascal Brand 
280316a94e7SPascal Brand 
2817583c59eSCedric Chaumont /* Panicked Functions Identification */
2827583c59eSCedric Chaumont /* TA Interface */
2837583c59eSCedric Chaumont #define TEE_PANIC_ID_TA_CLOSESESSIONENTRYPOINT      0x00000101
2847583c59eSCedric Chaumont #define TEE_PANIC_ID_TA_CREATEENTRYPOINT            0x00000102
2857583c59eSCedric Chaumont #define TEE_PANIC_ID_TA_DESTROYENTRYPOINT           0x00000103
2867583c59eSCedric Chaumont #define TEE_PANIC_ID_TA_INVOKECOMMANDENTRYPOINT     0x00000104
2877583c59eSCedric Chaumont #define TEE_PANIC_ID_TA_OPENSESSIONENTRYPOINT       0x00000105
2887583c59eSCedric Chaumont /* Property Access */
2897583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ALLOCATEPROPERTYENUMERATOR 0x00000201
2907583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_FREEPROPERTYENUMERATOR     0x00000202
2917583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETNEXTPROPERTY            0x00000203
2927583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASBINARYBLOCK   0x00000204
2937583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASBOOL          0x00000205
2947583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASIDENTITY      0x00000206
2957583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASSTRING        0x00000207
2967583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASU32           0x00000208
2977583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYASUUID          0x00000209
2987583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETPROPERTYNAME            0x0000020A
2997583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESETPROPERTYENUMERATOR    0x0000020B
3007583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_STARTPROPERTYENUMERATOR    0x0000020C
3017583c59eSCedric Chaumont /* Panic Function */
3027583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_PANIC                      0x00000301
3037583c59eSCedric Chaumont /* Internal Client API */
3047583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CLOSETASESSION             0x00000401
3057583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_INVOKETACOMMAND            0x00000402
3067583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_OPENTASESSION              0x00000403
3077583c59eSCedric Chaumont /* Cancellation */
3087583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETCANCELLATIONFLAG        0x00000501
3097583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MASKCANCELLATION           0x00000502
3107583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_UNMASKCANCELLATION         0x00000503
3117583c59eSCedric Chaumont /* Memory Management */
3127583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CHECKMEMORYACCESSRIGHTS    0x00000601
3137583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_FREE                       0x00000602
3147583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETINSTANCEDATA            0x00000603
3157583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MALLOC                     0x00000604
3167583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MEMCOMPARE                 0x00000605
3177583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MEMFILL                    0x00000606
3187583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MEMMOVE                    0x00000607
3197583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_REALLOC                    0x00000608
3207583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_SETINSTANCEDATA            0x00000609
3217583c59eSCedric Chaumont /* Generic Object */
3227583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CLOSEOBJECT                0x00000701
3237583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOBJECTBUFFERATTRIBUTE   0x00000702
3247583c59eSCedric Chaumont /* deprecated */
3257583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOBJECTINFO              0x00000703
3267583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOBJECTVALUEATTRIBUTE    0x00000704
3277583c59eSCedric Chaumont /* deprecated */
3287583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESTRICTOBJECTUSAGE        0x00000705
3297583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOBJECTINFO1             0x00000706
3307583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESTRICTOBJECTUSAGE1       0x00000707
3317583c59eSCedric Chaumont /* Transient Object */
3327583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ALLOCATETRANSIENTOBJECT    0x00000801
3337583c59eSCedric Chaumont /* deprecated */
3347583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_COPYOBJECTATTRIBUTES       0x00000802
3357583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_FREETRANSIENTOBJECT        0x00000803
3367583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GENERATEKEY                0x00000804
3377583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_INITREFATTRIBUTE           0x00000805
3387583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_INITVALUEATTRIBUTE         0x00000806
3397583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_POPULATETRANSIENTOBJECT    0x00000807
3407583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESETTRANSIENTOBJECT       0x00000808
3417583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_COPYOBJECTATTRIBUTES1      0x00000809
3427583c59eSCedric Chaumont /* Persistent Object */
3437583c59eSCedric Chaumont /* deprecated */
3447583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CLOSEANDDELETEPERSISTENTOBJECT  0x00000901
3457583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CREATEPERSISTENTOBJECT          0x00000902
3467583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_OPENPERSISTENTOBJECT            0x00000903
3477583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RENAMEPERSISTENTOBJECT          0x00000904
3487583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CLOSEANDDELETEPERSISTENTOBJECT1 0x00000905
3497583c59eSCedric Chaumont /* Persistent Object Enumeration */
3507583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ALLOCATEPERSISTENTOBJECTENUMERATOR 0x00000A01
3517583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_FREEPERSISTENTOBJECTENUMERATOR     0x00000A02
3527583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETNEXTPERSISTENTOBJECT            0x00000A03
3537583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESETPERSISTENTOBJECTENUMERATOR    0x00000A04
3547583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_STARTPERSISTENTOBJECTENUMERATOR    0x00000A05
3557583c59eSCedric Chaumont /* Data Stream Access */
3567583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_READOBJECTDATA             0x00000B01
3577583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_SEEKOBJECTDATA             0x00000B02
3587583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_TRUNCATEOBJECTDATA         0x00000B03
3597583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_WRITEOBJECTDATA            0x00000B04
3607583c59eSCedric Chaumont /* Generic Operation */
3617583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ALLOCATEOPERATION          0x00000C01
3627583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_COPYOPERATION              0x00000C02
3637583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_FREEOPERATION              0x00000C03
3647583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOPERATIONINFO           0x00000C04
3657583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_RESETOPERATION             0x00000C05
3667583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_SETOPERATIONKEY            0x00000C06
3677583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_SETOPERATIONKEY2           0x00000C07
3687583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETOPERATIONINFOMULTIPLE   0x00000C08
3697583c59eSCedric Chaumont /* Message Digest */
3707583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_DIGESTDOFINAL              0x00000D01
3717583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_DIGESTUPDATE               0x00000D02
3727583c59eSCedric Chaumont /* Symmetric Cipher */
3737583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CIPHERDOFINAL              0x00000E01
3747583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CIPHERINIT                 0x00000E02
3757583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_CIPHERUPDATE               0x00000E03
3767583c59eSCedric Chaumont /* MAC */
3777583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MACCOMPAREFINAL            0x00000F01
3787583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MACCOMPUTEFINAL            0x00000F02
3797583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MACINIT                    0x00000F03
3807583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_MACUPDATE                  0x00000F04
3817583c59eSCedric Chaumont /* Authenticated Encryption */
3827583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_AEDECRYPTFINAL             0x00001001
3837583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_AEENCRYPTFINAL             0x00001002
3847583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_AEINIT                     0x00001003
3857583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_AEUPDATE                   0x00001004
3867583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_AEUPDATEAAD                0x00001005
3877583c59eSCedric Chaumont /* Asymmetric */
3887583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ASYMMETRICDECRYPT          0x00001101
3897583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ASYMMETRICENCRYPT          0x00001102
3907583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ASYMMETRICSIGNDIGEST       0x00001103
3917583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_ASYMMETRICVERIFYDIGEST     0x00001104
3927583c59eSCedric Chaumont /* Key Derivation */
3937583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_DERIVEKEY                  0x00001201
3947583c59eSCedric Chaumont /* Random Data Generation */
3957583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GENERATERANDOM             0x00001301
3967583c59eSCedric Chaumont /* Time */
3977583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETREETIME                 0x00001401
3987583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETSYSTEMTIME              0x00001402
3997583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_GETTAPERSISTENTTIME        0x00001403
4007583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_SETTAPERSISTENTTIME        0x00001404
4017583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_WAIT                       0x00001405
4027583c59eSCedric Chaumont /* Memory Allocation and Size of Objects */
4037583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTFMMCONTEXTSIZEINU32  0x00001501
4047583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTFMMSIZEINU32         0x00001502
4057583c59eSCedric Chaumont /* Initialization */
4067583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTINIT                 0x00001601
4077583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTINITFMM              0x00001602
4087583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTINITFMMCONTEXT       0x00001603
4097583c59eSCedric Chaumont /* Converter */
4107583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTFROMOCTETSTRING 0x00001701
4117583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTFROMS32         0x00001702
4127583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTTOOCTETSTRING   0x00001703
4137583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTTOS32           0x00001704
4147583c59eSCedric Chaumont /* Logical Operation */
4157583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCMP                  0x00001801
4167583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCMPS32               0x00001802
4177583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTGETBIT               0x00001803
4187583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTGETBITCOUNT          0x00001804
4197583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTSHIFTRIGHT           0x00001805
4207583c59eSCedric Chaumont /* Basic Arithmetic */
4217583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTADD                  0x00001901
4227583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTDIV                  0x00001902
4237583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTMUL                  0x00001903
4247583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTNEG                  0x00001904
4257583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTSQUARE               0x00001905
4267583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTSUB                  0x00001906
4277583c59eSCedric Chaumont /* Modular Arithmetic */
4287583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTADDMOD               0x00001A01
4297583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTINVMOD               0x00001A02
4307583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTMOD                  0x00001A03
4317583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTMULMOD               0x00001A04
4327583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTSQUAREMOD            0x00001A05
4337583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTSUBMOD               0x00001A06
4347583c59eSCedric Chaumont /* Other Arithmetic */
4357583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCOMPUTEEXTENDEDGCD   0x00001B01
4367583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTISPROBABLEPRIME      0x00001B02
4377583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTRELATIVEPRIME        0x00001B03
4387583c59eSCedric Chaumont /* Fast Modular Multiplication */
4397583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCOMPUTEFMM           0x00001C01
4407583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTFROMFMM       0x00001C02
4417583c59eSCedric Chaumont #define TEE_PANIC_ID_TEE_BIGINTCONVERTTOFMM         0x00001C03
442177603c7SJens Wiklander 
443b0104773SPascal Brand /*
444b0104773SPascal Brand  * The macro TEE_PARAM_TYPES can be used to construct a value that you can
445b0104773SPascal Brand  * compare against an incoming paramTypes to check the type of all the
446b0104773SPascal Brand  * parameters in one comparison, like in the following example:
447b0104773SPascal Brand  * if (paramTypes != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
448b0104773SPascal Brand  *                                  TEE_PARAM_TYPE_MEMREF_OUPUT,
449b0104773SPascal Brand  *                                  TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE)) {
450b0104773SPascal Brand  *      return TEE_ERROR_BAD_PARAMETERS;
451b0104773SPascal Brand  *  }
452b0104773SPascal Brand  */
453b0104773SPascal Brand #define TEE_PARAM_TYPES(t0,t1,t2,t3) \
454b0104773SPascal Brand    ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12))
455b0104773SPascal Brand 
456b0104773SPascal Brand /*
457b0104773SPascal Brand  * The macro TEE_PARAM_TYPE_GET can be used to extract the type of a given
458b0104773SPascal Brand  * parameter from paramTypes if you need more fine-grained type checking.
459b0104773SPascal Brand  */
460b0104773SPascal Brand #define TEE_PARAM_TYPE_GET(t, i) ((((uint32_t)t) >> ((i)*4)) & 0xF)
461b0104773SPascal Brand 
462b0104773SPascal Brand /*
463b0104773SPascal Brand  * The macro TEE_PARAM_TYPE_SET can be used to load the type of a given
464b0104773SPascal Brand  * parameter from paramTypes without specifying all types (TEE_PARAM_TYPES)
465b0104773SPascal Brand  */
466b0104773SPascal Brand #define TEE_PARAM_TYPE_SET(t, i) (((uint32_t)(t) & 0xF) << ((i)*4))
467b0104773SPascal Brand 
468b0104773SPascal Brand /* Not specified in the standard */
469b0104773SPascal Brand #define TEE_NUM_PARAMS  4
470b0104773SPascal Brand 
471b0104773SPascal Brand /* TEE Arithmetical APIs */
472b0104773SPascal Brand 
473b0104773SPascal Brand #define TEE_BigIntSizeInU32(n) ((((n)+31)/32)+2)
474b0104773SPascal Brand 
475b0104773SPascal Brand #endif /* TEE_API_DEFINES_H */
476