tbbr_cot.c 14.3 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>
Isla Mitchell's avatar
Isla Mitchell committed
9
10
#include <stddef.h>

11
12
13
#if USE_TBBR_DEFS
#include <tbbr_oid.h>
#else
Juan Castillo's avatar
Juan Castillo committed
14
#include <platform_oid.h>
15
#endif
Isla Mitchell's avatar
Isla Mitchell committed
16

Juan Castillo's avatar
Juan Castillo committed
17
18
19
20
21
22
23
24
25
26
27
28

/*
 * 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
 */
29
30
31
32
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];
33
34
static unsigned char tos_fw_extra1_hash_buf[HASH_DER_LEN];
static unsigned char tos_fw_extra2_hash_buf[HASH_DER_LEN];
35
36
37
38
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
39
40
41
42

/*
 * Parameter type descriptors
 */
43
44
45
46
47
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
48
49
50
51
52
53
54
55
56
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);

57
58
59
60
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
61

62
63
64
65
66
67
68
69
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
70

71
72
73
74
75
76
77
78
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);
79
80
81
82
static auth_param_type_desc_t tos_fw_extra1_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA1_HASH_OID);
static auth_param_type_desc_t tos_fw_extra2_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA2_HASH_OID);
83
84
static auth_param_type_desc_t nt_world_bl_hash = AUTH_PARAM_TYPE_DESC(
		AUTH_PARAM_HASH, NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID);
85
static auth_param_type_desc_t scp_bl2u_hash = AUTH_PARAM_TYPE_DESC(
86
		AUTH_PARAM_HASH, SCP_FWU_CFG_HASH_OID);
87
static auth_param_type_desc_t bl2u_hash = AUTH_PARAM_TYPE_DESC(
88
		AUTH_PARAM_HASH, AP_FWU_CFG_HASH_OID);
89
static auth_param_type_desc_t ns_bl2u_hash = AUTH_PARAM_TYPE_DESC(
90
		AUTH_PARAM_HASH, FWU_HASH_OID);
Juan Castillo's avatar
Juan Castillo committed
91
92
93
94
95
96
97
98

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

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