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