tbbr_cot.c 14.4 KB
Newer Older
Juan Castillo's avatar
Juan Castillo committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice, this
 * list of conditions and the following disclaimer.
 *
 * Redistributions in binary form must reproduce the above copyright notice,
 * this list of conditions and the following disclaimer in the documentation
 * and/or other materials provided with the distribution.
 *
 * Neither the name of ARM nor the names of its contributors may be used
 * to endorse or promote products derived from this software without specific
 * prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#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
 */
47
48
49
50
51
52
53
54
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
55
56
57
58

/*
 * Parameter type descriptors
 */
59
60
61
62
63
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
64
65
66
67
68
69
70
71
72
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);

73
74
75
76
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
77

78
79
80
81
82
83
84
85
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
86

87
88
89
90
91
92
93
94
95
96
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);
97
static auth_param_type_desc_t scp_bl2u_hash = AUTH_PARAM_TYPE_DESC(
98
		AUTH_PARAM_HASH, SCP_FWU_CFG_HASH_OID);
99
static auth_param_type_desc_t bl2u_hash = AUTH_PARAM_TYPE_DESC(
100
		AUTH_PARAM_HASH, AP_FWU_CFG_HASH_OID);
101
static auth_param_type_desc_t ns_bl2u_hash = AUTH_PARAM_TYPE_DESC(
102
		AUTH_PARAM_HASH, FWU_HASH_OID);
Juan Castillo's avatar
Juan Castillo committed
103
104
105
106
107
108
109
110

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

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