xref: /optee_os/lib/libutee/include/tee_api_defines.h (revision fb4a92f1552dc81d9c7ba44d5b600ddfdf453620)
1b0104773SPascal Brand /*
2b0104773SPascal Brand  * Copyright (c) 2014, STMicroelectronics International N.V.
3b0104773SPascal Brand  * All rights reserved.
4b0104773SPascal Brand  *
5b0104773SPascal Brand  * Redistribution and use in source and binary forms, with or without
6b0104773SPascal Brand  * modification, are permitted provided that the following conditions are met:
7b0104773SPascal Brand  *
8b0104773SPascal Brand  * 1. Redistributions of source code must retain the above copyright notice,
9b0104773SPascal Brand  * this list of conditions and the following disclaimer.
10b0104773SPascal Brand  *
11b0104773SPascal Brand  * 2. Redistributions in binary form must reproduce the above copyright notice,
12b0104773SPascal Brand  * this list of conditions and the following disclaimer in the documentation
13b0104773SPascal Brand  * and/or other materials provided with the distribution.
14b0104773SPascal Brand  *
15b0104773SPascal Brand  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16b0104773SPascal Brand  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17b0104773SPascal Brand  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18b0104773SPascal Brand  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19b0104773SPascal Brand  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20b0104773SPascal Brand  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21b0104773SPascal Brand  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22b0104773SPascal Brand  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23b0104773SPascal Brand  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24b0104773SPascal Brand  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25b0104773SPascal Brand  * POSSIBILITY OF SUCH DAMAGE.
26b0104773SPascal Brand  */
27b0104773SPascal Brand 
28b0104773SPascal Brand /* Based on GP TEE Internal API Specification Version 0.11 */
29b0104773SPascal Brand #ifndef TEE_API_DEFINES_H
30b0104773SPascal Brand #define TEE_API_DEFINES_H
31b0104773SPascal Brand 
32b0104773SPascal Brand #define TEE_HANDLE_NULL                 0
33b0104773SPascal Brand 
34b0104773SPascal Brand #define TEE_TIMEOUT_INFINITE            0xFFFFFFFF
35b0104773SPascal Brand 
36b0104773SPascal Brand /* API Error Codes */
37b0104773SPascal Brand #define TEE_SUCCESS                     0x00000000
38b0104773SPascal Brand #define TEE_ERROR_GENERIC               0xFFFF0000
39b0104773SPascal Brand #define TEE_ERROR_ACCESS_DENIED         0xFFFF0001
40b0104773SPascal Brand #define TEE_ERROR_CANCEL                0xFFFF0002
41b0104773SPascal Brand #define TEE_ERROR_ACCESS_CONFLICT       0xFFFF0003
42b0104773SPascal Brand #define TEE_ERROR_EXCESS_DATA           0xFFFF0004
43b0104773SPascal Brand #define TEE_ERROR_BAD_FORMAT            0xFFFF0005
44b0104773SPascal Brand #define TEE_ERROR_BAD_PARAMETERS        0xFFFF0006
45b0104773SPascal Brand #define TEE_ERROR_BAD_STATE             0xFFFF0007
46b0104773SPascal Brand #define TEE_ERROR_ITEM_NOT_FOUND        0xFFFF0008
47b0104773SPascal Brand #define TEE_ERROR_NOT_IMPLEMENTED       0xFFFF0009
48b0104773SPascal Brand #define TEE_ERROR_NOT_SUPPORTED         0xFFFF000A
49b0104773SPascal Brand #define TEE_ERROR_NO_DATA               0xFFFF000B
50b0104773SPascal Brand #define TEE_ERROR_OUT_OF_MEMORY         0xFFFF000C
51b0104773SPascal Brand #define TEE_ERROR_BUSY                  0xFFFF000D
52b0104773SPascal Brand #define TEE_ERROR_COMMUNICATION         0xFFFF000E
53b0104773SPascal Brand #define TEE_ERROR_SECURITY              0xFFFF000F
54b0104773SPascal Brand #define TEE_ERROR_SHORT_BUFFER          0xFFFF0010
55b0104773SPascal Brand #define TEE_PENDING                     0xFFFF2000
56b0104773SPascal Brand #define TEE_ERROR_TIMEOUT               0xFFFF3001
57b0104773SPascal Brand #define TEE_ERROR_OVERFLOW              0xFFFF300F
58b0104773SPascal Brand #define TEE_ERROR_TARGET_DEAD           0xFFFF3024
59b0104773SPascal Brand #define TEE_ERROR_STORAGE_NO_SPACE      0xFFFF3041
60b0104773SPascal Brand #define TEE_ERROR_MAC_INVALID           0xFFFF3071
61b0104773SPascal Brand #define TEE_ERROR_SIGNATURE_INVALID     0xFFFF3072
62b0104773SPascal Brand #define TEE_ERROR_TIME_NOT_SET          0xFFFF5000
63b0104773SPascal Brand #define TEE_ERROR_TIME_NEEDS_RESET      0xFFFF5001
64b0104773SPascal Brand 
65b0104773SPascal Brand /*
66b0104773SPascal Brand  * Proprietary error codes.
67b0104773SPascal Brand  * All proprietary error codes should use the 0xF57E prefix.
68b0104773SPascal Brand  */
69*fb4a92f1SPascal Brand #define TEE_ERROR_SYSTEM_BUSY           0xF57E0000
70b0104773SPascal Brand #define TEE_ERROR_FILE_NOT_FOUND        0xF57E0010
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_KERNEL                0xA0000000
89b0104773SPascal Brand #define TEE_LOGIN_TRUSTED_APP           0xF0000000
90b0104773SPascal Brand 
91b0104773SPascal Brand /* Origin Code Constants */
92b0104773SPascal Brand #define TEE_ORIGIN_API                  0x00000001
93b0104773SPascal Brand #define TEE_ORIGIN_COMMS                0x00000002
94b0104773SPascal Brand #define TEE_ORIGIN_TEE                  0x00000003
95b0104773SPascal Brand #define TEE_ORIGIN_TRUSTED_APP          0x00000004
96b0104773SPascal Brand 
97b0104773SPascal Brand /* Property Sets pseudo handles */
98b0104773SPascal Brand #define TEE_PROPSET_CURRENT_TA          (TEE_PropSetHandle)0xFFFFFFFF
99b0104773SPascal Brand #define TEE_PROPSET_CURRENT_CLIENT      (TEE_PropSetHandle)0xFFFFFFFE
100b0104773SPascal Brand #define TEE_PROPSET_TEE_IMPLEMENTATION  (TEE_PropSetHandle)0xFFFFFFFD
101b0104773SPascal Brand 
102b0104773SPascal Brand /* Memory Access Rights Constants */
103b0104773SPascal Brand #define TEE_MEMORY_ACCESS_READ          0x00000001
104b0104773SPascal Brand #define TEE_MEMORY_ACCESS_WRITE         0x00000002
105b0104773SPascal Brand #define TEE_MEMORY_ACCESS_ANY_OWNER     0x00000004
106b0104773SPascal Brand 
107b0104773SPascal Brand /* Other constants */
108b0104773SPascal Brand #define TEE_STORAGE_PRIVATE             0x00000001
109b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_READ       0x00000001
110b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_WRITE      0x00000002
111b0104773SPascal Brand #define TEE_DATA_FLAG_ACCESS_WRITE_META 0x00000004
112b0104773SPascal Brand #define TEE_DATA_FLAG_SHARE_READ        0x00000010
113b0104773SPascal Brand #define TEE_DATA_FLAG_SHARE_WRITE       0x00000020
114b0104773SPascal Brand #define TEE_DATA_FLAG_CREATE            0x00000200
115b0104773SPascal Brand #define TEE_DATA_FLAG_EXCLUSIVE         0x00000400
116b0104773SPascal Brand #define TEE_DATA_MAX_POSITION           0xFFFFFFFF
117b0104773SPascal Brand #define TEE_OBJECT_ID_MAX_LEN           64
118b0104773SPascal Brand #define TEE_USAGE_EXTRACTABLE           0x00000001
119b0104773SPascal Brand #define TEE_USAGE_ENCRYPT               0x00000002
120b0104773SPascal Brand #define TEE_USAGE_DECRYPT               0x00000004
121b0104773SPascal Brand #define TEE_USAGE_MAC                   0x00000008
122b0104773SPascal Brand #define TEE_USAGE_SIGN                  0x00000010
123b0104773SPascal Brand #define TEE_USAGE_VERIFY                0x00000020
124b0104773SPascal Brand #define TEE_USAGE_DERIVE                0x00000040
125b0104773SPascal Brand #define TEE_HANDLE_FLAG_PERSISTENT      0x00010000
126b0104773SPascal Brand #define TEE_HANDLE_FLAG_INITIALIZED     0x00020000
127b0104773SPascal Brand #define TEE_HANDLE_FLAG_KEY_SET         0x00040000
128b0104773SPascal Brand #define TEE_HANDLE_FLAG_EXPECT_TWO_KEYS 0x00080000
129b0104773SPascal Brand #define TEE_OPERATION_CIPHER            1
130b0104773SPascal Brand #define TEE_OPERATION_MAC               3
131b0104773SPascal Brand #define TEE_OPERATION_AE                4
132b0104773SPascal Brand #define TEE_OPERATION_DIGEST            5
133b0104773SPascal Brand #define TEE_OPERATION_ASYMMETRIC_CIPHER 6
134b0104773SPascal Brand #define TEE_OPERATION_ASYMMETRIC_SIGNATURE 7
135b0104773SPascal Brand #define TEE_OPERATION_KEY_DERIVATION    8
136b0104773SPascal Brand 
137b0104773SPascal Brand /* Algorithm Identifiers */
138b0104773SPascal Brand #define TEE_ALG_AES_ECB_NOPAD                   0x10000010
139b0104773SPascal Brand #define TEE_ALG_AES_CBC_NOPAD                   0x10000110
140b0104773SPascal Brand #define TEE_ALG_AES_CTR                         0x10000210
141b0104773SPascal Brand #define TEE_ALG_AES_CTS                         0x10000310
142b0104773SPascal Brand #define TEE_ALG_AES_XTS                         0x10000410
143b0104773SPascal Brand #define TEE_ALG_AES_CBC_MAC_NOPAD               0x30000110
144b0104773SPascal Brand #define TEE_ALG_AES_CBC_MAC_PKCS5               0x30000510
145b0104773SPascal Brand #define TEE_ALG_AES_CMAC                        0x30000610
146b0104773SPascal Brand #define TEE_ALG_AES_CCM                         0x40000710
147b0104773SPascal Brand #define TEE_ALG_AES_GCM                         0x40000810
148b0104773SPascal Brand #define TEE_ALG_DES_ECB_NOPAD                   0x10000011
149b0104773SPascal Brand #define TEE_ALG_DES_CBC_NOPAD                   0x10000111
150b0104773SPascal Brand #define TEE_ALG_DES_CBC_MAC_NOPAD               0x30000111
151b0104773SPascal Brand #define TEE_ALG_DES_CBC_MAC_PKCS5               0x30000511
152b0104773SPascal Brand #define TEE_ALG_DES3_ECB_NOPAD                  0x10000013
153b0104773SPascal Brand #define TEE_ALG_DES3_CBC_NOPAD                  0x10000113
154b0104773SPascal Brand #define TEE_ALG_DES3_CBC_MAC_NOPAD              0x30000113
155b0104773SPascal Brand #define TEE_ALG_DES3_CBC_MAC_PKCS5              0x30000513
156b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_MD5           0x70001830
157b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA1          0x70002830
158b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA224        0x70003830
159b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA256        0x70004830
160b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA384        0x70005830
161b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_SHA512        0x70006830
162b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_V1_5_MD5SHA1       0x7000F830
163b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA1      0x70212930
164b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA224    0x70313930
165b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA256    0x70414930
166b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA384    0x70515930
167b0104773SPascal Brand #define TEE_ALG_RSASSA_PKCS1_PSS_MGF1_SHA512    0x70616930
168b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_V1_5                0x60000130
169b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA1      0x60210230
170b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA224    0x60310230
171b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA256    0x60410230
172b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA384    0x60510230
173b0104773SPascal Brand #define TEE_ALG_RSAES_PKCS1_OAEP_MGF1_SHA512    0x60610230
174b0104773SPascal Brand #define TEE_ALG_RSA_NOPAD                       0x60000030
175b0104773SPascal Brand #define TEE_ALG_DSA_SHA1                        0x70002131
176b0104773SPascal Brand #define TEE_ALG_DH_DERIVE_SHARED_SECRET         0x80000032
177b0104773SPascal Brand #define TEE_ALG_MD5                             0x50000001
178b0104773SPascal Brand #define TEE_ALG_SHA1                            0x50000002
179b0104773SPascal Brand #define TEE_ALG_SHA224                          0x50000003
180b0104773SPascal Brand #define TEE_ALG_SHA256                          0x50000004
181b0104773SPascal Brand #define TEE_ALG_SHA384                          0x50000005
182b0104773SPascal Brand #define TEE_ALG_SHA512                          0x50000006
183b0104773SPascal Brand #define TEE_ALG_MD5SHA1                         0x5000000F
184b0104773SPascal Brand #define TEE_ALG_HMAC_MD5                        0x30000001
185b0104773SPascal Brand #define TEE_ALG_HMAC_SHA1                       0x30000002
186b0104773SPascal Brand #define TEE_ALG_HMAC_SHA224                     0x30000003
187b0104773SPascal Brand #define TEE_ALG_HMAC_SHA256                     0x30000004
188b0104773SPascal Brand #define TEE_ALG_HMAC_SHA384                     0x30000005
189b0104773SPascal Brand #define TEE_ALG_HMAC_SHA512                     0x30000006
190b0104773SPascal Brand 
191b0104773SPascal Brand /* Object Types */
192b0104773SPascal Brand 
193b0104773SPascal Brand #define TEE_TYPE_AES                        0xA0000010
194b0104773SPascal Brand #define TEE_TYPE_DES                        0xA0000011
195b0104773SPascal Brand #define TEE_TYPE_DES3                       0xA0000013
196b0104773SPascal Brand #define TEE_TYPE_HMAC_MD5                   0xA0000001
197b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA1                  0xA0000002
198b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA224                0xA0000003
199b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA256                0xA0000004
200b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA384                0xA0000005
201b0104773SPascal Brand #define TEE_TYPE_HMAC_SHA512                0xA0000006
202b0104773SPascal Brand #define TEE_TYPE_RSA_PUBLIC_KEY             0xA0000030
203b0104773SPascal Brand #define TEE_TYPE_RSA_KEYPAIR                0xA1000030
204b0104773SPascal Brand #define TEE_TYPE_DSA_PUBLIC_KEY             0xA0000031
205b0104773SPascal Brand #define TEE_TYPE_DSA_KEYPAIR                0xA1000031
206b0104773SPascal Brand #define TEE_TYPE_DH_KEYPAIR                 0xA1000032
207b0104773SPascal Brand #define TEE_TYPE_GENERIC_SECRET             0xA0000000
208b0104773SPascal Brand 
209b0104773SPascal Brand /* List of Object or Operation Attributes */
210b0104773SPascal Brand 
211b0104773SPascal Brand #define TEE_ATTR_SECRET_VALUE               0xC0000000
212b0104773SPascal Brand #define TEE_ATTR_RSA_MODULUS                0xD0000130
213b0104773SPascal Brand #define TEE_ATTR_RSA_PUBLIC_EXPONENT        0xD0000230
214b0104773SPascal Brand #define TEE_ATTR_RSA_PRIVATE_EXPONENT       0xC0000330
215b0104773SPascal Brand #define TEE_ATTR_RSA_PRIME1                 0xC0000430
216b0104773SPascal Brand #define TEE_ATTR_RSA_PRIME2                 0xC0000530
217b0104773SPascal Brand #define TEE_ATTR_RSA_EXPONENT1              0xC0000630
218b0104773SPascal Brand #define TEE_ATTR_RSA_EXPONENT2              0xC0000730
219b0104773SPascal Brand #define TEE_ATTR_RSA_COEFFICIENT            0xC0000830
220b0104773SPascal Brand #define TEE_ATTR_DSA_PRIME                  0xD0001031
221b0104773SPascal Brand #define TEE_ATTR_DSA_SUBPRIME               0xD0001131
222b0104773SPascal Brand #define TEE_ATTR_DSA_BASE                   0xD0001231
223b0104773SPascal Brand #define TEE_ATTR_DSA_PUBLIC_VALUE           0xD0000131
224b0104773SPascal Brand #define TEE_ATTR_DSA_PRIVATE_VALUE          0xC0000231
225b0104773SPascal Brand #define TEE_ATTR_DH_PRIME                   0xD0001032
226b0104773SPascal Brand #define TEE_ATTR_DH_SUBPRIME                0xD0001132
227b0104773SPascal Brand #define TEE_ATTR_DH_BASE                    0xD0001232
228b0104773SPascal Brand #define TEE_ATTR_DH_X_BITS                  0xF0001332
229b0104773SPascal Brand #define TEE_ATTR_DH_PUBLIC_VALUE            0xD0000132
230b0104773SPascal Brand #define TEE_ATTR_DH_PRIVATE_VALUE           0xC0000232
231b0104773SPascal Brand #define TEE_ATTR_RSA_OAEP_LABEL             0xD0000930
232b0104773SPascal Brand #define TEE_ATTR_RSA_PSS_SALT_LENGTH        0xF0000A30
233b0104773SPascal Brand 
234b0104773SPascal Brand /*
235b0104773SPascal Brand  * The macro TEE_PARAM_TYPES can be used to construct a value that you can
236b0104773SPascal Brand  * compare against an incoming paramTypes to check the type of all the
237b0104773SPascal Brand  * parameters in one comparison, like in the following example:
238b0104773SPascal Brand  * if (paramTypes != TEE_PARAM_TYPES(TEE_PARAM_TYPE_MEMREF_INPUT,
239b0104773SPascal Brand  *                                  TEE_PARAM_TYPE_MEMREF_OUPUT,
240b0104773SPascal Brand  *                                  TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE)) {
241b0104773SPascal Brand  *      return TEE_ERROR_BAD_PARAMETERS;
242b0104773SPascal Brand  *  }
243b0104773SPascal Brand  */
244b0104773SPascal Brand #define TEE_PARAM_TYPES(t0,t1,t2,t3) \
245b0104773SPascal Brand    ((t0) | ((t1) << 4) | ((t2) << 8) | ((t3) << 12))
246b0104773SPascal Brand 
247b0104773SPascal Brand /*
248b0104773SPascal Brand  * The macro TEE_PARAM_TYPE_GET can be used to extract the type of a given
249b0104773SPascal Brand  * parameter from paramTypes if you need more fine-grained type checking.
250b0104773SPascal Brand  */
251b0104773SPascal Brand #define TEE_PARAM_TYPE_GET(t, i) ((((uint32_t)t) >> ((i)*4)) & 0xF)
252b0104773SPascal Brand 
253b0104773SPascal Brand /*
254b0104773SPascal Brand  * The macro TEE_PARAM_TYPE_SET can be used to load the type of a given
255b0104773SPascal Brand  * parameter from paramTypes without specifying all types (TEE_PARAM_TYPES)
256b0104773SPascal Brand  */
257b0104773SPascal Brand #define TEE_PARAM_TYPE_SET(t, i) (((uint32_t)(t) & 0xF) << ((i)*4))
258b0104773SPascal Brand 
259b0104773SPascal Brand /* Not specified in the standard */
260b0104773SPascal Brand #define TEE_NUM_PARAMS  4
261b0104773SPascal Brand 
262b0104773SPascal Brand /* TEE Arithmetical APIs */
263b0104773SPascal Brand 
264b0104773SPascal Brand #define TEE_BigIntSizeInU32(n) ((((n)+31)/32)+2)
265b0104773SPascal Brand 
266b0104773SPascal Brand #endif /* TEE_API_DEFINES_H */
267