28 #ifndef UTEE_DEFINES_H 29 #define UTEE_DEFINES_H 32 #include <types_ext.h> 38 #define TEE_MAIN_ALGO_MD5 0x01 39 #define TEE_MAIN_ALGO_SHA1 0x02 40 #define TEE_MAIN_ALGO_SHA224 0x03 41 #define TEE_MAIN_ALGO_SHA256 0x04 42 #define TEE_MAIN_ALGO_SHA384 0x05 43 #define TEE_MAIN_ALGO_SHA512 0x06 44 #define TEE_MAIN_ALGO_AES 0x10 45 #define TEE_MAIN_ALGO_DES 0x11 46 #define TEE_MAIN_ALGO_DES2 0x12 47 #define TEE_MAIN_ALGO_DES3 0x13 48 #define TEE_MAIN_ALGO_RSA 0x30 49 #define TEE_MAIN_ALGO_DSA 0x31 50 #define TEE_MAIN_ALGO_DH 0x32 51 #define TEE_MAIN_ALGO_ECDSA 0x41 52 #define TEE_MAIN_ALGO_ECDH 0x42 53 #define TEE_MAIN_ALGO_HKDF 0xC0 54 #define TEE_MAIN_ALGO_CONCAT_KDF 0xC1 55 #define TEE_MAIN_ALGO_PBKDF2 0xC2 58 #define TEE_CHAIN_MODE_ECB_NOPAD 0x0 59 #define TEE_CHAIN_MODE_CBC_NOPAD 0x1 60 #define TEE_CHAIN_MODE_CTR 0x2 61 #define TEE_CHAIN_MODE_CTS 0x3 62 #define TEE_CHAIN_MODE_XTS 0x4 63 #define TEE_CHAIN_MODE_CBC_MAC_PKCS5 0x5 64 #define TEE_CHAIN_MODE_CMAC 0x6 65 #define TEE_CHAIN_MODE_CCM 0x7 66 #define TEE_CHAIN_MODE_GCM 0x8 67 #define TEE_CHAIN_MODE_PKCS1_PSS_MGF1 0x9 70 #define TEE_ALG_GET_CLASS(algo) (((algo) >> 28) & 0xF) 72 #define TEE_ALG_GET_KEY_TYPE(algo, with_private_key) \ 73 (TEE_ALG_GET_MAIN_ALG(algo) | \ 74 ((with_private_key) ? 0xA1000000 : 0xA0000000)) 77 #define TEE_ALG_GET_MAIN_ALG(algo) ((algo) & 0xFF) 80 #define TEE_ALG_GET_CHAIN_MODE(algo) (((algo) >> 8) & 0xF) 83 #define TEE_ALG_GET_DIGEST_HASH(algo) (((algo) >> 12) & 0xF) 86 #define TEE_ALG_GET_INTERNAL_HASH(algo) (((algo) >> 20) & 0x7) 89 #define TEE_ALG_HASH_ALGO(main_hash) \ 90 (TEE_OPERATION_DIGEST << 28 | (main_hash)) 93 #define TEE_INTERNAL_HASH_TO_ALGO(algo) \ 94 TEE_ALG_HASH_ALGO(TEE_ALG_GET_INTERNAL_HASH(algo)) 97 #define TEE_DIGEST_HASH_TO_ALGO(algo) \ 98 TEE_ALG_HASH_ALGO(TEE_ALG_GET_DIGEST_HASH(algo)) 101 #define TEE_ALG_HMAC_ALGO(main_hash) \ 102 (TEE_OPERATION_MAC << 28 | (main_hash)) 104 #define TEE_AES_BLOCK_SIZE 16UL 105 #define TEE_DES_BLOCK_SIZE 8UL 107 #define TEE_AES_MAX_KEY_SIZE 32UL 110 #ifndef TEE_MD5_HASH_SIZE 112 TEE_MD5_HASH_SIZE = 16,
113 TEE_SHA1_HASH_SIZE = 20,
114 TEE_SHA224_HASH_SIZE = 28,
115 TEE_SHA256_HASH_SIZE = 32,
116 TEE_SHA384_HASH_SIZE = 48,
117 TEE_SHA512_HASH_SIZE = 64,
118 TEE_MD5SHA1_HASH_SIZE = (TEE_MD5_HASH_SIZE + TEE_SHA1_HASH_SIZE),
119 TEE_MAX_HASH_SIZE = 64,
123 #define TEE_MAC_SIZE_AES_CBC_MAC_NOPAD 124 #define TEE_MAC_SIZE_AES_CBC_MAC_PKCS5 125 #define TEE_MAC_SIZE_AES_CMAC 126 #define TEE_MAC_SIZE_DES_CBC_MAC_PKCS5 135 #ifdef __compiler_bswap64 136 #define TEE_U64_BSWAP(x) __compiler_bswap64((x)) 138 #define TEE_U64_BSWAP(x) ((uint64_t)( \ 139 (((uint64_t)(x) & UINT64_C(0xff00000000000000ULL)) >> 56) | \ 140 (((uint64_t)(x) & UINT64_C(0x00ff000000000000ULL)) >> 40) | \ 141 (((uint64_t)(x) & UINT64_C(0x0000ff0000000000ULL)) >> 24) | \ 142 (((uint64_t)(x) & UINT64_C(0x000000ff00000000ULL)) >> 8) | \ 143 (((uint64_t)(x) & UINT64_C(0x00000000ff000000ULL)) << 8) | \ 144 (((uint64_t)(x) & UINT64_C(0x0000000000ff0000ULL)) << 24) | \ 145 (((uint64_t)(x) & UINT64_C(0x000000000000ff00ULL)) << 40) | \ 146 (((uint64_t)(x) & UINT64_C(0x00000000000000ffULL)) << 56))) 149 #ifdef __compiler_bswap32 150 #define TEE_U32_BSWAP(x) __compiler_bswap32((x)) 152 #define TEE_U32_BSWAP(x) ((uint32_t)( \ 153 (((uint32_t)(x) & UINT32_C(0xff000000)) >> 24) | \ 154 (((uint32_t)(x) & UINT32_C(0x00ff0000)) >> 8) | \ 155 (((uint32_t)(x) & UINT32_C(0x0000ff00)) << 8) | \ 156 (((uint32_t)(x) & UINT32_C(0x000000ff)) << 24))) 159 #ifdef __compiler_bswap16 160 #define TEE_U16_BSWAP(x) __compiler_bswap16((x)) 162 #define TEE_U16_BSWAP(x) ((uint16_t)( \ 163 (((uint16_t)(x) & UINT16_C(0xff00)) >> 8) | \ 164 (((uint16_t)(x) & UINT16_C(0x00ff)) << 8))) 168 #define TEE_U64_FROM_BIG_ENDIAN(x) TEE_U64_BSWAP(x) 169 #define TEE_U32_FROM_BIG_ENDIAN(x) TEE_U32_BSWAP(x) 170 #define TEE_U16_FROM_BIG_ENDIAN(x) TEE_U16_BSWAP(x) 171 #define TEE_U64_TO_BIG_ENDIAN(x) TEE_U64_BSWAP(x) 172 #define TEE_U32_TO_BIG_ENDIAN(x) TEE_U32_BSWAP(x) 173 #define TEE_U16_TO_BIG_ENDIAN(x) TEE_U16_BSWAP(x) 175 #define TEE_TIME_MILLIS_BASE 1000 177 #define TEE_TIME_LT(t1, t2) \ 178 (((t1).seconds == (t2).seconds) ? \ 179 ((t1).millis < (t2).millis) : \ 180 ((t1).seconds < (t2).seconds)) 182 #define TEE_TIME_LE(t1, t2) \ 183 (((t1).seconds == (t2).seconds) ? \ 184 ((t1).millis <= (t2).millis) : \ 185 ((t1).seconds <= (t2).seconds)) 187 #define TEE_TIME_ADD(t1, t2, dst) do { \ 188 (dst).seconds = (t1).seconds + (t2).seconds; \ 189 (dst).millis = (t1).millis + (t2).millis; \ 190 if ((dst).millis >= TEE_TIME_MILLIS_BASE) { \ 192 (dst).millis -= TEE_TIME_MILLIS_BASE; \ 196 #define TEE_TIME_SUB(t1, t2, dst) do { \ 197 (dst).seconds = (t1).seconds - (t2).seconds; \ 198 if ((t1).millis < (t2).millis) { \ 200 (dst).millis = (t1).millis + TEE_TIME_MILLIS_BASE - (t2).millis;\ 202 (dst).millis = (t1).millis - (t2).millis; \ 209 #define HW_UNIQUE_KEY_WORD1 (8) 210 #define HW_UNIQUE_KEY_LENGTH (16) 211 #define HW_UNIQUE_KEY_WORD2 (HW_UNIQUE_KEY_WORD1 + 1) 212 #define HW_UNIQUE_KEY_WORD3 (HW_UNIQUE_KEY_WORD1 + 2) 213 #define HW_UNIQUE_KEY_WORD4 (HW_UNIQUE_KEY_WORD1 + 3) 215 #define UTEE_SE_READER_PRESENT (1 << 0) 216 #define UTEE_SE_READER_TEE_ONLY (1 << 1) 217 #define UTEE_SE_READER_SELECT_RESPONE_ENABLE (1 << 2)