tbbr_cot.c 13 KB
Newer Older
Juan Castillo's avatar
Juan Castillo committed
1
2
3
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
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
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 */

#include <auth_mod.h>
#include <platform_def.h>
#include <platform_oid.h>
#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
 */
23
24
25
26
27
28
29
30
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
31
32
33
34

/*
 * Parameter type descriptors
 */
35
36
37
38
39
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
40
41
42
43
44
45
46
47
48
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);

49
50
51
52
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
53

54
55
56
57
58
59
60
61
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
62

63
64
65
66
67
68
69
70
71
72
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);
73
static auth_param_type_desc_t scp_bl2u_hash = AUTH_PARAM_TYPE_DESC(
74
		AUTH_PARAM_HASH, SCP_FWU_CFG_HASH_OID);
75
static auth_param_type_desc_t bl2u_hash = AUTH_PARAM_TYPE_DESC(
76
		AUTH_PARAM_HASH, AP_FWU_CFG_HASH_OID);
77
static auth_param_type_desc_t ns_bl2u_hash = AUTH_PARAM_TYPE_DESC(
78
		AUTH_PARAM_HASH, FWU_HASH_OID);
Juan Castillo's avatar
Juan Castillo committed
79
80
81
82
83
84
85
86

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

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