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