tbbr_cot.c 13.1 KB
Newer Older
Juan Castillo's avatar
Juan Castillo committed
1
/*
2
 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Juan Castillo's avatar
Juan Castillo committed
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo's avatar
Juan Castillo committed
5
6
7
8
 */

#include <auth_mod.h>
#include <platform_def.h>
9
10
11
#if USE_TBBR_DEFS
#include <tbbr_oid.h>
#else
Juan Castillo's avatar
Juan Castillo committed
12
#include <platform_oid.h>
13
#endif
Juan Castillo's avatar
Juan Castillo committed
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <stddef.h>

/*
 * Maximum key and hash sizes (in DER format)
 */
#define PK_DER_LEN			294
#define HASH_DER_LEN			51

/*
 * The platform must allocate buffers to store the authentication parameters
 * extracted from the certificates. In this case, because of the way the CoT is
 * established, we can reuse some of the buffers on different stages
 */
27
28
29
30
31
32
33
34
static unsigned char tb_fw_hash_buf[HASH_DER_LEN];
static unsigned char scp_fw_hash_buf[HASH_DER_LEN];
static unsigned char soc_fw_hash_buf[HASH_DER_LEN];
static unsigned char tos_fw_hash_buf[HASH_DER_LEN];
static unsigned char nt_world_bl_hash_buf[HASH_DER_LEN];
static unsigned char trusted_world_pk_buf[PK_DER_LEN];
static unsigned char non_trusted_world_pk_buf[PK_DER_LEN];
static unsigned char content_pk_buf[PK_DER_LEN];
Juan Castillo's avatar
Juan Castillo committed
35
36
37
38

/*
 * Parameter type descriptors
 */
39
40
41
42
43
static auth_param_type_desc_t trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_NV_CTR, TRUSTED_FW_NVCOUNTER_OID);
static auth_param_type_desc_t non_trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_NV_CTR, NON_TRUSTED_FW_NVCOUNTER_OID);

Juan Castillo's avatar
Juan Castillo committed
44
45
46
47
48
49
50
51
52
static auth_param_type_desc_t subject_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, 0);
static auth_param_type_desc_t sig = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_SIG, 0);
static auth_param_type_desc_t sig_alg = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_SIG_ALG, 0);
static auth_param_type_desc_t raw_data = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_RAW_DATA, 0);

53
54
55
56
static auth_param_type_desc_t trusted_world_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, TRUSTED_WORLD_PK_OID);
static auth_param_type_desc_t non_trusted_world_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, NON_TRUSTED_WORLD_PK_OID);
Juan Castillo's avatar
Juan Castillo committed
57

58
59
60
61
62
63
64
65
static auth_param_type_desc_t scp_fw_content_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, SCP_FW_CONTENT_CERT_PK_OID);
static auth_param_type_desc_t soc_fw_content_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, SOC_FW_CONTENT_CERT_PK_OID);
static auth_param_type_desc_t tos_fw_content_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, TRUSTED_OS_FW_CONTENT_CERT_PK_OID);
static auth_param_type_desc_t nt_fw_content_pk = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_PUB_KEY, NON_TRUSTED_FW_CONTENT_CERT_PK_OID);
Juan Castillo's avatar
Juan Castillo committed
66

67
68
69
70
71
72
73
74
75
76
static auth_param_type_desc_t tb_fw_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, TRUSTED_BOOT_FW_HASH_OID);
static auth_param_type_desc_t scp_fw_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, SCP_FW_HASH_OID);
static auth_param_type_desc_t soc_fw_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, SOC_AP_FW_HASH_OID);
static auth_param_type_desc_t tos_fw_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, TRUSTED_OS_FW_HASH_OID);
static auth_param_type_desc_t nt_world_bl_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID);
77
static auth_param_type_desc_t scp_bl2u_hash = AUTH_PARAM_TYPE_DESC(
78
		AUTH_PARAM_HASH, SCP_FWU_CFG_HASH_OID);
79
static auth_param_type_desc_t bl2u_hash = AUTH_PARAM_TYPE_DESC(
80
		AUTH_PARAM_HASH, AP_FWU_CFG_HASH_OID);
81
static auth_param_type_desc_t ns_bl2u_hash = AUTH_PARAM_TYPE_DESC(
82
		AUTH_PARAM_HASH, FWU_HASH_OID);
Juan Castillo's avatar
Juan Castillo committed
83
84
85
86
87
88
89
90

/*
 * TBBR Chain of trust definition
 */
static const auth_img_desc_t cot_desc[] = {
	/*
	 * BL2
	 */
91
92
	[TRUSTED_BOOT_FW_CERT_ID] = {
		.img_id = TRUSTED_BOOT_FW_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
93
94
95
96
97
98
99
100
101
102
103
		.img_type = IMG_CERT,
		.parent = NULL,
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
					.pk = &subject_pk,
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
104
105
106
107
108
109
110
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
111
112
113
114
			}
		},
		.authenticated_data = {
			[0] = {
115
				.type_desc = &tb_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
116
				.data = {
117
					.ptr = (void *)tb_fw_hash_buf,
Juan Castillo's avatar
Juan Castillo committed
118
119
120
121
122
123
124
125
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
	[BL2_IMAGE_ID] = {
		.img_id = BL2_IMAGE_ID,
		.img_type = IMG_RAW,
126
		.parent = &cot_desc[TRUSTED_BOOT_FW_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
127
128
129
130
131
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
132
					.hash = &tb_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
				}
			}
		}
	},
	/*
	 * Trusted key certificate
	 */
	[TRUSTED_KEY_CERT_ID] = {
		.img_id = TRUSTED_KEY_CERT_ID,
		.img_type = IMG_CERT,
		.parent = NULL,
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
					.pk = &subject_pk,
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
153
154
155
156
157
158
159
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
160
161
162
163
			}
		},
		.authenticated_data = {
			[0] = {
164
				.type_desc = &trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
165
				.data = {
166
					.ptr = (void *)trusted_world_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
167
168
169
170
					.len = (unsigned int)PK_DER_LEN
				}
			},
			[1] = {
171
				.type_desc = &non_trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
172
				.data = {
173
					.ptr = (void *)non_trusted_world_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
174
175
176
177
178
179
					.len = (unsigned int)PK_DER_LEN
				}
			}
		}
	},
	/*
180
	 * SCP Firmware
Juan Castillo's avatar
Juan Castillo committed
181
	 */
182
183
	[SCP_FW_KEY_CERT_ID] = {
		.img_id = SCP_FW_KEY_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
184
185
186
187
188
189
		.img_type = IMG_CERT,
		.parent = &cot_desc[TRUSTED_KEY_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
190
					.pk = &trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
191
192
193
194
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
195
196
197
198
199
200
201
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
202
203
204
205
			}
		},
		.authenticated_data = {
			[0] = {
206
				.type_desc = &scp_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
207
				.data = {
208
					.ptr = (void *)content_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
209
210
211
212
213
					.len = (unsigned int)PK_DER_LEN
				}
			}
		}
	},
214
215
	[SCP_FW_CONTENT_CERT_ID] = {
		.img_id = SCP_FW_CONTENT_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
216
		.img_type = IMG_CERT,
217
		.parent = &cot_desc[SCP_FW_KEY_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
218
219
220
221
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
222
					.pk = &scp_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
223
224
225
226
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
227
228
229
230
231
232
233
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
234
235
236
237
			}
		},
		.authenticated_data = {
			[0] = {
238
				.type_desc = &scp_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
239
				.data = {
240
					.ptr = (void *)scp_fw_hash_buf,
Juan Castillo's avatar
Juan Castillo committed
241
242
243
244
245
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
246
247
	[SCP_BL2_IMAGE_ID] = {
		.img_id = SCP_BL2_IMAGE_ID,
Juan Castillo's avatar
Juan Castillo committed
248
		.img_type = IMG_RAW,
249
		.parent = &cot_desc[SCP_FW_CONTENT_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
250
251
252
253
254
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
255
					.hash = &scp_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
256
257
258
259
260
				}
			}
		}
	},
	/*
261
	 * SoC Firmware
Juan Castillo's avatar
Juan Castillo committed
262
	 */
263
264
	[SOC_FW_KEY_CERT_ID] = {
		.img_id = SOC_FW_KEY_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
265
266
267
268
269
270
		.img_type = IMG_CERT,
		.parent = &cot_desc[TRUSTED_KEY_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
271
					.pk = &trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
272
273
274
275
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
276
277
278
279
280
281
282
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
283
284
285
286
			}
		},
		.authenticated_data = {
			[0] = {
287
				.type_desc = &soc_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
288
				.data = {
289
					.ptr = (void *)content_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
290
291
292
293
294
					.len = (unsigned int)PK_DER_LEN
				}
			}
		}
	},
295
296
	[SOC_FW_CONTENT_CERT_ID] = {
		.img_id = SOC_FW_CONTENT_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
297
		.img_type = IMG_CERT,
298
		.parent = &cot_desc[SOC_FW_KEY_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
299
300
301
302
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
303
					.pk = &soc_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
304
305
306
307
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
308
309
310
311
312
313
314
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
315
316
317
318
			}
		},
		.authenticated_data = {
			[0] = {
319
				.type_desc = &soc_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
320
				.data = {
321
					.ptr = (void *)soc_fw_hash_buf,
Juan Castillo's avatar
Juan Castillo committed
322
323
324
325
326
327
328
329
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
	[BL31_IMAGE_ID] = {
		.img_id = BL31_IMAGE_ID,
		.img_type = IMG_RAW,
330
		.parent = &cot_desc[SOC_FW_CONTENT_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
331
332
333
334
335
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
336
					.hash = &soc_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
337
338
339
340
341
				}
			}
		}
	},
	/*
342
	 * Trusted OS Firmware
Juan Castillo's avatar
Juan Castillo committed
343
	 */
344
345
	[TRUSTED_OS_FW_KEY_CERT_ID] = {
		.img_id = TRUSTED_OS_FW_KEY_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
346
347
348
349
350
351
		.img_type = IMG_CERT,
		.parent = &cot_desc[TRUSTED_KEY_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
352
					.pk = &trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
353
354
355
356
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
357
358
359
360
361
362
363
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
364
365
366
367
			}
		},
		.authenticated_data = {
			[0] = {
368
				.type_desc = &tos_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
369
				.data = {
370
					.ptr = (void *)content_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
371
372
373
374
375
					.len = (unsigned int)PK_DER_LEN
				}
			}
		}
	},
376
377
	[TRUSTED_OS_FW_CONTENT_CERT_ID] = {
		.img_id = TRUSTED_OS_FW_CONTENT_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
378
		.img_type = IMG_CERT,
379
		.parent = &cot_desc[TRUSTED_OS_FW_KEY_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
380
381
382
383
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
384
					.pk = &tos_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
385
386
387
388
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
389
390
391
392
393
394
395
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &trusted_nv_ctr,
					.plat_nv_ctr = &trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
396
397
398
399
			}
		},
		.authenticated_data = {
			[0] = {
400
				.type_desc = &tos_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
401
				.data = {
402
					.ptr = (void *)tos_fw_hash_buf,
Juan Castillo's avatar
Juan Castillo committed
403
404
405
406
407
408
409
410
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
	[BL32_IMAGE_ID] = {
		.img_id = BL32_IMAGE_ID,
		.img_type = IMG_RAW,
411
		.parent = &cot_desc[TRUSTED_OS_FW_CONTENT_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
412
413
414
415
416
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
417
					.hash = &tos_fw_hash,
Juan Castillo's avatar
Juan Castillo committed
418
419
420
421
422
				}
			}
		}
	},
	/*
423
	 * Non-Trusted Firmware
Juan Castillo's avatar
Juan Castillo committed
424
	 */
425
426
	[NON_TRUSTED_FW_KEY_CERT_ID] = {
		.img_id = NON_TRUSTED_FW_KEY_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
427
428
429
430
431
432
		.img_type = IMG_CERT,
		.parent = &cot_desc[TRUSTED_KEY_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
433
					.pk = &non_trusted_world_pk,
Juan Castillo's avatar
Juan Castillo committed
434
435
436
437
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
438
439
440
441
442
443
444
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &non_trusted_nv_ctr,
					.plat_nv_ctr = &non_trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
445
446
447
448
			}
		},
		.authenticated_data = {
			[0] = {
449
				.type_desc = &nt_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
450
				.data = {
451
					.ptr = (void *)content_pk_buf,
Juan Castillo's avatar
Juan Castillo committed
452
453
454
455
456
					.len = (unsigned int)PK_DER_LEN
				}
			}
		}
	},
457
458
	[NON_TRUSTED_FW_CONTENT_CERT_ID] = {
		.img_id = NON_TRUSTED_FW_CONTENT_CERT_ID,
Juan Castillo's avatar
Juan Castillo committed
459
		.img_type = IMG_CERT,
460
		.parent = &cot_desc[NON_TRUSTED_FW_KEY_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
461
462
463
464
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
465
					.pk = &nt_fw_content_pk,
Juan Castillo's avatar
Juan Castillo committed
466
467
468
469
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
470
471
472
473
474
475
476
			},
			[1] = {
				.type = AUTH_METHOD_NV_CTR,
				.param.nv_ctr = {
					.cert_nv_ctr = &non_trusted_nv_ctr,
					.plat_nv_ctr = &non_trusted_nv_ctr
				}
Juan Castillo's avatar
Juan Castillo committed
477
478
479
480
			}
		},
		.authenticated_data = {
			[0] = {
481
				.type_desc = &nt_world_bl_hash,
Juan Castillo's avatar
Juan Castillo committed
482
				.data = {
483
					.ptr = (void *)nt_world_bl_hash_buf,
Juan Castillo's avatar
Juan Castillo committed
484
485
486
487
488
489
490
491
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
	[BL33_IMAGE_ID] = {
		.img_id = BL33_IMAGE_ID,
		.img_type = IMG_RAW,
492
		.parent = &cot_desc[NON_TRUSTED_FW_CONTENT_CERT_ID],
Juan Castillo's avatar
Juan Castillo committed
493
494
495
496
497
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
498
					.hash = &nt_world_bl_hash,
Juan Castillo's avatar
Juan Castillo committed
499
500
501
				}
			}
		}
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
	},
	/*
	 * FWU auth descriptor.
	 */
	[FWU_CERT_ID] = {
		.img_id = FWU_CERT_ID,
		.img_type = IMG_CERT,
		.parent = NULL,
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_SIG,
				.param.sig = {
					.pk = &subject_pk,
					.sig = &sig,
					.alg = &sig_alg,
					.data = &raw_data,
				}
			}
		},
		.authenticated_data = {
			[0] = {
				.type_desc = &scp_bl2u_hash,
				.data = {
525
					.ptr = (void *)scp_fw_hash_buf,
526
527
528
529
530
531
					.len = (unsigned int)HASH_DER_LEN
				}
			},
			[1] = {
				.type_desc = &bl2u_hash,
				.data = {
532
					.ptr = (void *)tb_fw_hash_buf,
533
534
535
536
537
538
					.len = (unsigned int)HASH_DER_LEN
				}
			},
			[2] = {
				.type_desc = &ns_bl2u_hash,
				.data = {
539
					.ptr = (void *)nt_world_bl_hash_buf,
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
					.len = (unsigned int)HASH_DER_LEN
				}
			}
		}
	},
	/*
	 * SCP_BL2U
	 */
	[SCP_BL2U_IMAGE_ID] = {
		.img_id = SCP_BL2U_IMAGE_ID,
		.img_type = IMG_RAW,
		.parent = &cot_desc[FWU_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
					.hash = &scp_bl2u_hash,
				}
			}
		}
	},
	/*
	 * BL2U
	 */
	[BL2U_IMAGE_ID] = {
		.img_id = BL2U_IMAGE_ID,
		.img_type = IMG_RAW,
		.parent = &cot_desc[FWU_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
					.hash = &bl2u_hash,
				}
			}
		}
	},
	/*
	 * NS_BL2U
	 */
	[NS_BL2U_IMAGE_ID] = {
		.img_id = NS_BL2U_IMAGE_ID,
		.img_type = IMG_RAW,
		.parent = &cot_desc[FWU_CERT_ID],
		.img_auth_methods = {
			[0] = {
				.type = AUTH_METHOD_HASH,
				.param.hash = {
					.data = &raw_data,
					.hash = &ns_bl2u_hash,
				}
			}
		}
Juan Castillo's avatar
Juan Castillo committed
595
596
597
598
599
	}
};

/* Register the CoT in the authentication module */
REGISTER_COT(cot_desc);