Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
CTCaer
GitHub Repository: CTCaer/hekate
Path: blob/master/bdk/sec/se_t210.h
1476 views
1
/*
2
* Copyright (c) 2018 naehrwert
3
* Copyright (c) 2018-2021 CTCaer
4
*
5
* This program is free software; you can redistribute it and/or modify it
6
* under the terms and conditions of the GNU General Public License,
7
* version 2, as published by the Free Software Foundation.
8
*
9
* This program is distributed in the hope it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12
* more details.
13
*
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
*/
17
18
#ifndef _SE_T210_H
19
#define _SE_T210_H
20
21
#include <utils/types.h>
22
23
#define SE_CRYPTO_QUEUE_LENGTH 50
24
#define SE_MAX_SRC_SG_COUNT 50
25
#define SE_MAX_DST_SG_COUNT 50
26
27
#define SE_AES_KEYSLOT_COUNT 16
28
#define SE_RSA_KEYSLOT_COUNT 2
29
#define SE_MAX_LAST_BLOCK_SIZE 0xFFFFF
30
31
#define SE_AES_BLOCK_SIZE 16
32
#define SE_AES_IV_SIZE 16
33
#define SE_AES_MIN_KEY_SIZE 16
34
#define SE_AES_MAX_KEY_SIZE 32
35
#define SE_KEY_128_SIZE 16
36
#define SE_KEY_192_SIZE 24
37
#define SE_KEY_256_SIZE 32
38
#define SE_SHA_192_SIZE 24
39
#define SE_SHA_256_SIZE 32
40
#define SE_SHA_384_SIZE 48
41
#define SE_SHA_512_SIZE 64
42
#define SE_RNG_IV_SIZE 16
43
#define SE_RNG_DT_SIZE 16
44
#define SE_RNG_KEY_SIZE 16
45
#define SE_RNG_SEED_SIZE (SE_RNG_IV_SIZE + SE_RNG_KEY_SIZE + SE_RNG_DT_SIZE)
46
47
#define SE_AES_CMAC_DIGEST_SIZE 16
48
#define SE_RSA512_DIGEST_SIZE 64
49
#define SE_RSA1024_DIGEST_SIZE 128
50
#define SE_RSA1536_DIGEST_SIZE 192
51
#define SE_RSA2048_DIGEST_SIZE 256
52
53
#define DECRYPT 0
54
#define ENCRYPT 1
55
56
/* SE register definitions */
57
#define SE_SE_SECURITY_REG 0x000
58
#define SE_HARD_SETTING BIT(0)
59
#define SE_ENG_DIS BIT(1)
60
#define SE_PERKEY_SETTING BIT(2)
61
#define SE_SOFT_SETTING BIT(16)
62
63
#define SE_TZRAM_SECURITY_REG 0x004
64
#define SE_TZRAM_HARD_SETTING BIT(0)
65
#define SE_TZRAM_ENG_DIS BIT(1)
66
67
#define SE_OPERATION_REG 0x008
68
#define SE_OP_ABORT 0
69
#define SE_OP_START 1
70
#define SE_OP_RESTART_OUT 2
71
#define SE_OP_CTX_SAVE 3
72
#define SE_OP_RESTART_IN 4
73
74
#define SE_INT_ENABLE_REG 0x00C
75
#define SE_INT_STATUS_REG 0x010
76
#define SE_INT_IN_LL_BUF_RD BIT(0)
77
#define SE_INT_IN_DONE BIT(1)
78
#define SE_INT_OUT_LL_BUF_WR BIT(2)
79
#define SE_INT_OUT_DONE BIT(3)
80
#define SE_INT_OP_DONE BIT(4)
81
#define SE_INT_RESEED_NEEDED BIT(5)
82
#define SE_INT_ERR_STAT BIT(16)
83
84
#define SE_CONFIG_REG 0x014
85
#define DST_MEMORY 0
86
#define DST_HASHREG 1
87
#define DST_KEYTABLE 2
88
#define DST_SRK 3
89
#define DST_RSAREG 4
90
#define SE_CONFIG_DST(x) ((x) << 2)
91
#define ALG_NOP 0
92
#define ALG_AES_DEC 1
93
#define SE_CONFIG_DEC_ALG(x) ((x) << 8)
94
#define ALG_NOP 0
95
#define ALG_AES_ENC 1
96
#define ALG_RNG 2
97
#define ALG_SHA 3
98
#define ALG_RSA 4
99
#define SE_CONFIG_ENC_ALG(x) ((x) << 12)
100
#define MODE_KEY128 0
101
#define MODE_KEY192 1
102
#define MODE_KEY256 2
103
#define MODE_SHA1 0
104
#define MODE_SHA224 4
105
#define MODE_SHA256 5
106
#define MODE_SHA384 6
107
#define MODE_SHA512 7
108
#define SE_CONFIG_DEC_MODE(x) ((x) << 16)
109
#define SE_CONFIG_ENC_MODE(x) ((x) << 24)
110
111
#define SE_IN_LL_ADDR_REG 0x018
112
#define SE_IN_CUR_BYTE_ADDR_REG 0x01C
113
#define SE_IN_CUR_LL_ID_REG 0x020
114
#define SE_OUT_LL_ADDR_REG 0x024
115
#define SE_OUT_CUR_BYTE_ADDR_REG 0x028
116
#define SE_OUT_CUR_LL_ID_REG 0x02C
117
118
#define SE_HASH_RESULT_REG 0x030
119
#define SE_HASH_RESULT_REG_COUNT 16
120
121
#define SE_CONTEXT_SAVE_CONFIG_REG 0x070
122
#define KEYS_0_3 0
123
#define KEYS_4_7 1
124
#define ORIGINAL_IV 2
125
#define UPDATED_IV 3
126
#define SE_CONTEXT_AES_WORD_QUAD(x) ((x) << 0)
127
#define SE_CONTEXT_AES_KEY_INDEX(x) ((x) << 8)
128
#define KEYS_0_3 0
129
#define KEYS_4_7 1
130
#define KEYS_8_11 2
131
#define KEYS_12_15 3
132
#define SE_CONTEXT_RSA_WORD_QUAD(x) ((x) << 12)
133
#define SLOT0_EXPONENT 0
134
#define SLOT0_MODULUS 1
135
#define SLOT1_EXPONENT 2
136
#define SLOT1_MODULUS 3
137
#define SE_CONTEXT_RSA_KEY_INDEX(x) ((x) << 16)
138
#define STICKY_0_3 0
139
#define STICKY_4_7 1
140
#define SE_CONTEXT_STICKY_WORD_QUAD(x) ((x) << 24)
141
#define STICKY_BITS 0
142
#define RSA_KEYTABLE 1
143
#define AES_KEYTABLE 2
144
#define MEM 4
145
#define SRK 6
146
#define SE_CONTEXT_SRC(x) ((x) << 29)
147
148
#define SE_CTX_SAVE_AUTO_T210B01_REG 0x074
149
#define SE_CTX_SAVE_AUTO_ENABLE BIT(0)
150
#define SE_CTX_SAVE_AUTO_LOCK BIT(8)
151
#define SE_CTX_SAVE_AUTO_CURR_CNT_MASK (0x3FF << 16)
152
153
#define SE_CRYPTO_LAST_BLOCK 0x080
154
155
#define SE_SHA_CONFIG_REG 0x200
156
#define SHA_CONTINUE 0
157
#define SHA_INIT_HASH 1
158
159
#define SE_SHA_MSG_LENGTH_0_REG 0x204
160
#define SE_SHA_MSG_LENGTH_1_REG 0x208
161
#define SE_SHA_MSG_LENGTH_2_REG 0x20C
162
#define SE_SHA_MSG_LENGTH_3_REG 0x210
163
#define SE_SHA_MSG_LEFT_0_REG 0x214
164
#define SE_SHA_MSG_LEFT_1_REG 0x218
165
#define SE_SHA_MSG_LEFT_2_REG 0x21C
166
#define SE_SHA_MSG_LEFT_3_REG 0x220
167
168
#define SE_CRYPTO_SECURITY_PERKEY_REG 0x280
169
#define SE_KEY_LOCK_FLAG 0x80
170
#define SE_CRYPTO_KEYTABLE_ACCESS_REG 0x284
171
#define SE_CRYPTO_KEYTABLE_ACCESS_REG_COUNT 16
172
#define SE_KEY_TBL_DIS_KEYREAD_FLAG BIT(0)
173
#define SE_KEY_TBL_DIS_KEYUPDATE_FLAG BIT(1)
174
#define SE_KEY_TBL_DIS_OIVREAD_FLAG BIT(2)
175
#define SE_KEY_TBL_DIS_OIVUPDATE_FLAG BIT(3)
176
#define SE_KEY_TBL_DIS_UIVREAD_FLAG BIT(4)
177
#define SE_KEY_TBL_DIS_UIVUPDATE_FLAG BIT(5)
178
#define SE_KEY_TBL_DIS_KEYUSE_FLAG BIT(6)
179
#define SE_KEY_TBL_DIS_KEY_ACCESS_FLAG 0x7F
180
181
#define SE_CRYPTO_CONFIG_REG 0x304
182
#define HASH_DISABLE 0
183
#define HASH_ENABLE 1
184
#define SE_CRYPTO_HASH(x) ((x) << 0)
185
#define XOR_BYPASS 0
186
#define XOR_TOP 2
187
#define XOR_BOTTOM 3
188
#define SE_CRYPTO_XOR_POS(x) ((x) << 1)
189
#define INPUT_MEMORY 0
190
#define INPUT_RANDOM 1
191
#define INPUT_AESOUT 2
192
#define INPUT_LNR_CTR 3
193
#define SE_CRYPTO_INPUT_SEL(x) ((x) << 3)
194
#define VCTRAM_MEM 0
195
#define VCTRAM_AESOUT 2
196
#define VCTRAM_PREVMEM 3
197
#define SE_CRYPTO_VCTRAM_SEL(x) ((x) << 5)
198
#define IV_ORIGINAL 0
199
#define IV_UPDATED 1
200
#define SE_CRYPTO_IV_SEL(x) ((x) << 7)
201
#define CORE_DECRYPT 0
202
#define CORE_ENCRYPT 1
203
#define SE_CRYPTO_CORE_SEL(x) ((x) << 8)
204
#define SE_CRYPTO_KEYSCH_BYPASS BIT(10)
205
#define SE_CRYPTO_CTR_CNTN(x) ((x) << 11)
206
#define SE_CRYPTO_KEY_INDEX(x) ((x) << 24)
207
#define MEMIF_AHB 0
208
#define MEMIF_MCCIF 1
209
#define SE_CRYPTO_MEMIF(x) ((x) << 31)
210
211
#define SE_CRYPTO_LINEAR_CTR_REG 0x308
212
#define SE_CRYPTO_LINEAR_CTR_REG_COUNT 4
213
214
#define SE_CRYPTO_BLOCK_COUNT_REG 0x318
215
216
#define SE_CRYPTO_KEYTABLE_ADDR_REG 0x31C
217
#define SE_KEYTABLE_PKT(x) ((x) << 0)
218
#define KEYS_0_3 0
219
#define KEYS_4_7 1
220
#define ORIGINAL_IV 2
221
#define UPDATED_IV 3
222
#define SE_KEYTABLE_QUAD(x) ((x) << 2)
223
#define SE_KEYTABLE_SLOT(x) ((x) << 4)
224
225
#define SE_CRYPTO_KEYTABLE_DATA_REG 0x320
226
227
#define SE_CRYPTO_KEYTABLE_DST_REG 0x330
228
#define KEYS_0_3 0
229
#define KEYS_4_7 1
230
#define ORIGINAL_IV 2
231
#define UPDATED_IV 3
232
#define SE_KEYTABLE_DST_WORD_QUAD(x) ((x) << 0)
233
#define SE_KEYTABLE_DST_KEY_INDEX(x) ((x) << 8)
234
235
#define SE_RNG_CONFIG_REG 0x340
236
#define MODE_NORMAL 0
237
#define MODE_FORCE_INSTANTION 1
238
#define MODE_FORCE_RESEED 2
239
#define SE_RNG_CONFIG_MODE(x) ((x) << 0)
240
#define SRC_NONE 0
241
#define SRC_ENTROPY 1
242
#define SRC_LFSR 2
243
#define SE_RNG_CONFIG_SRC(x) ((x) << 2)
244
245
#define SE_RNG_SRC_CONFIG_REG 0x344
246
#define RO_ENTR_LOCK_DISABLE 0
247
#define RO_ENTR_LOCK_ENABLE 1
248
#define SE_RNG_SRC_CONFIG_ENTR_SRC_LOCK(x) ((x) << 0)
249
#define RO_ENTR_DISABLE 0
250
#define RO_ENTR_ENABLE 1
251
#define SE_RNG_SRC_CONFIG_ENTR_SRC(x) ((x) << 1)
252
#define RO_HW_DIS_CYA_DISABLE 0
253
#define RO_HW_DIS_CYA_ENABLE 1
254
#define SE_RNG_SRC_CONFIG_HW_DIS_CYA(x) ((x) << 2)
255
#define SE_RNG_SRC_CONFIG_ENTR_SUBSMPL(x) ((x) << 4)
256
#define SE_RNG_SRC_CONFIG_ENTR_DATA_FLUSH BIT(8)
257
258
#define SE_RNG_RESEED_INTERVAL_REG 0x348
259
260
#define SE_RSA_CONFIG 0x400
261
#define RSA_KEY_SLOT_ONE 0
262
#define RSA_KEY_SLOT_TW0 1
263
#define RSA_KEY_SLOT(x) ((x) << 24)
264
265
#define SE_RSA_KEY_SIZE_REG 0x404
266
#define RSA_KEY_WIDTH_512 0
267
#define RSA_KEY_WIDTH_1024 1
268
#define RSA_KEY_WIDTH_1536 2
269
#define RSA_KEY_WIDTH_2048 3
270
271
#define SE_RSA_EXP_SIZE_REG 0x408
272
273
#define SE_RSA_SECURITY_PERKEY_REG 0x40C
274
#define SE_RSA_KEY_LOCK_FLAG 0x80
275
#define SE_RSA_KEYTABLE_ACCESS_REG 0x410
276
#define SE_RSA_KEY_TBL_DIS_KEYREAD_FLAG BIT(0)
277
#define SE_RSA_KEY_TBL_DIS_KEYUPDATE_FLAG BIT(1)
278
#define SE_RSA_KEY_TBL_DIS_KEYUSE_FLAG BIT(2)
279
#define SE_RSA_KEY_TBL_DIS_KEY_ACCESS_FLAG 0x7F
280
#define SE_RSA_KEY_TBL_DIS_KEY_READ_UPDATE_FLAG (SE_RSA_KEY_TBL_DIS_KEYREAD_FLAG | SE_RSA_KEY_TBL_DIS_KEYUPDATE_FLAG)
281
#define SE_RSA_KEY_TBL_DIS_KEY_READ_UPDATE_USE_FLAG (SE_RSA_KEY_TBL_DIS_KEYREAD_FLAG | SE_RSA_KEY_TBL_DIS_KEYUPDATE_FLAG | SE_RSA_KEY_TBL_DIS_KEYUSE_FLAG)
282
283
#define SE_RSA_KEYTABLE_ADDR_REG 0x420
284
#define SE_RSA_KEYTABLE_PKT(x) ((x) << 0)
285
#define RSA_KEY_TYPE_EXP 0
286
#define RSA_KEY_TYPE_MOD 1
287
#define SE_RSA_KEYTABLE_TYPE(x) ((x) << 6)
288
#define RSA_KEY_NUM(x) ((x) << 7)
289
#define RSA_KEY_INPUT_MODE_REG 0
290
#define RSA_KEY_INPUT_MODE_DMA 1
291
#define SE_RSA_KEYTABLE_INPUT_MODE(x) ((x) << 8)
292
#define RSA_KEY_READ 0
293
#define RSA_KEY_WRITE 1
294
#define SE_RSA_KEY_OP(x) ((x) << 10)
295
296
#define SE_RSA_KEYTABLE_DATA_REG 0x424
297
298
#define SE_RSA_OUTPUT_REG 0x428
299
#define SE_RSA_OUTPUT_REG_COUNT 64
300
301
#define SE_STATUS_REG 0x800
302
#define SE_STATUS_STATE_IDLE 0
303
#define SE_STATUS_STATE_BUSY 1
304
#define SE_STATUS_STATE_WAIT_OUT 2
305
#define SE_STATUS_STATE_WAIT_IN 3
306
#define SE_STATUS_STATE_MASK 3
307
#define SE_STATUS_MEM_IF_IDLE (0 << 2)
308
#define SE_STATUS_MEM_IF_BUSY BIT(2)
309
310
#define SE_ERR_STATUS_REG 0x804
311
#define SE_ERR_STATUS_SE_NS_ACCESS BIT(0)
312
#define SE_ERR_STATUS_BUSY_REG_WR BIT(1)
313
#define SE_ERR_STATUS_DST BIT(2)
314
#define SE_ERR_STATUS_SRK_USAGE_LIMIT BIT(3)
315
#define SE_ERR_STATUS_TZRAM_NS_ACCESS BIT(24)
316
#define SE_ERR_STATUS_TZRAM_ADDRESS BIT(25)
317
318
#define SE_MISC_REG 0x808
319
#define SE_ENTROPY_NEXT_192BIT BIT(0)
320
#define SE_ENTROPY_VN_BYPASS BIT(1)
321
#define SE_CLK_OVR_ON BIT(2)
322
323
#define SE_SPARE_REG 0x80C
324
#define SE_ERRATA_FIX_DISABLE 0
325
#define SE_ERRATA_FIX_ENABLE 1
326
#define SE_ECO(x) ((x) << 0)
327
328
#endif
329
330