blob: 6ad00592d45acfc52612d6d11e7b68c01aa07703 [file] [log] [blame]
Juan Castillo9b265a82015-05-07 14:52:44 +01001/*
Soby Mathew0bdfef02017-11-07 17:03:57 +00002 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
Juan Castillo9b265a82015-05-07 14:52:44 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo9b265a82015-05-07 14:52:44 +01005 */
6
7#include <auth_mod.h>
8#include <platform_def.h>
Isla Mitchell99305012017-07-11 14:54:08 +01009#include <stddef.h>
10
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090011#if USE_TBBR_DEFS
12#include <tbbr_oid.h>
13#else
Juan Castillo9b265a82015-05-07 14:52:44 +010014#include <platform_oid.h>
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090015#endif
Isla Mitchell99305012017-07-11 14:54:08 +010016
Juan Castillo9b265a82015-05-07 14:52:44 +010017
18/*
19 * Maximum key and hash sizes (in DER format)
20 */
21#define PK_DER_LEN 294
Qixiang Xu1a1f2912017-11-09 13:56:29 +080022#define HASH_DER_LEN 83
Juan Castillo9b265a82015-05-07 14:52:44 +010023
24/*
25 * The platform must allocate buffers to store the authentication parameters
26 * extracted from the certificates. In this case, because of the way the CoT is
27 * established, we can reuse some of the buffers on different stages
28 */
Juan Castillobe801202015-12-03 10:19:21 +000029static unsigned char tb_fw_hash_buf[HASH_DER_LEN];
Soby Mathew0bdfef02017-11-07 17:03:57 +000030static unsigned char tb_fw_config_hash_buf[HASH_DER_LEN];
31static unsigned char hw_config_hash_buf[HASH_DER_LEN];
Juan Castillobe801202015-12-03 10:19:21 +000032static unsigned char scp_fw_hash_buf[HASH_DER_LEN];
33static unsigned char soc_fw_hash_buf[HASH_DER_LEN];
34static unsigned char tos_fw_hash_buf[HASH_DER_LEN];
Summer Qin80726782017-04-20 16:28:39 +010035static unsigned char tos_fw_extra1_hash_buf[HASH_DER_LEN];
36static unsigned char tos_fw_extra2_hash_buf[HASH_DER_LEN];
Juan Castillobe801202015-12-03 10:19:21 +000037static unsigned char nt_world_bl_hash_buf[HASH_DER_LEN];
38static unsigned char trusted_world_pk_buf[PK_DER_LEN];
39static unsigned char non_trusted_world_pk_buf[PK_DER_LEN];
40static unsigned char content_pk_buf[PK_DER_LEN];
Juan Castillo9b265a82015-05-07 14:52:44 +010041
42/*
43 * Parameter type descriptors
44 */
Juan Castillobfb7fa62016-01-22 11:05:57 +000045static auth_param_type_desc_t trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
46 AUTH_PARAM_NV_CTR, TRUSTED_FW_NVCOUNTER_OID);
47static auth_param_type_desc_t non_trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
48 AUTH_PARAM_NV_CTR, NON_TRUSTED_FW_NVCOUNTER_OID);
49
Juan Castillo9b265a82015-05-07 14:52:44 +010050static auth_param_type_desc_t subject_pk = AUTH_PARAM_TYPE_DESC(
51 AUTH_PARAM_PUB_KEY, 0);
52static auth_param_type_desc_t sig = AUTH_PARAM_TYPE_DESC(
53 AUTH_PARAM_SIG, 0);
54static auth_param_type_desc_t sig_alg = AUTH_PARAM_TYPE_DESC(
55 AUTH_PARAM_SIG_ALG, 0);
56static auth_param_type_desc_t raw_data = AUTH_PARAM_TYPE_DESC(
57 AUTH_PARAM_RAW_DATA, 0);
58
Juan Castillobe801202015-12-03 10:19:21 +000059static auth_param_type_desc_t trusted_world_pk = AUTH_PARAM_TYPE_DESC(
60 AUTH_PARAM_PUB_KEY, TRUSTED_WORLD_PK_OID);
61static auth_param_type_desc_t non_trusted_world_pk = AUTH_PARAM_TYPE_DESC(
62 AUTH_PARAM_PUB_KEY, NON_TRUSTED_WORLD_PK_OID);
Juan Castillo9b265a82015-05-07 14:52:44 +010063
Juan Castillobe801202015-12-03 10:19:21 +000064static auth_param_type_desc_t scp_fw_content_pk = AUTH_PARAM_TYPE_DESC(
65 AUTH_PARAM_PUB_KEY, SCP_FW_CONTENT_CERT_PK_OID);
66static auth_param_type_desc_t soc_fw_content_pk = AUTH_PARAM_TYPE_DESC(
67 AUTH_PARAM_PUB_KEY, SOC_FW_CONTENT_CERT_PK_OID);
68static auth_param_type_desc_t tos_fw_content_pk = AUTH_PARAM_TYPE_DESC(
69 AUTH_PARAM_PUB_KEY, TRUSTED_OS_FW_CONTENT_CERT_PK_OID);
70static auth_param_type_desc_t nt_fw_content_pk = AUTH_PARAM_TYPE_DESC(
71 AUTH_PARAM_PUB_KEY, NON_TRUSTED_FW_CONTENT_CERT_PK_OID);
Juan Castillo9b265a82015-05-07 14:52:44 +010072
Juan Castillobe801202015-12-03 10:19:21 +000073static auth_param_type_desc_t tb_fw_hash = AUTH_PARAM_TYPE_DESC(
74 AUTH_PARAM_HASH, TRUSTED_BOOT_FW_HASH_OID);
Soby Mathew0bdfef02017-11-07 17:03:57 +000075static auth_param_type_desc_t tb_fw_config_hash = AUTH_PARAM_TYPE_DESC(
76 AUTH_PARAM_HASH, TRUSTED_BOOT_FW_CONFIG_HASH_OID);
77static auth_param_type_desc_t hw_config_hash = AUTH_PARAM_TYPE_DESC(
78 AUTH_PARAM_HASH, HW_CONFIG_HASH_OID);
Juan Castillobe801202015-12-03 10:19:21 +000079static auth_param_type_desc_t scp_fw_hash = AUTH_PARAM_TYPE_DESC(
80 AUTH_PARAM_HASH, SCP_FW_HASH_OID);
81static auth_param_type_desc_t soc_fw_hash = AUTH_PARAM_TYPE_DESC(
82 AUTH_PARAM_HASH, SOC_AP_FW_HASH_OID);
83static auth_param_type_desc_t tos_fw_hash = AUTH_PARAM_TYPE_DESC(
84 AUTH_PARAM_HASH, TRUSTED_OS_FW_HASH_OID);
Summer Qin80726782017-04-20 16:28:39 +010085static auth_param_type_desc_t tos_fw_extra1_hash = AUTH_PARAM_TYPE_DESC(
86 AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA1_HASH_OID);
87static auth_param_type_desc_t tos_fw_extra2_hash = AUTH_PARAM_TYPE_DESC(
88 AUTH_PARAM_HASH, TRUSTED_OS_FW_EXTRA2_HASH_OID);
Juan Castillobe801202015-12-03 10:19:21 +000089static auth_param_type_desc_t nt_world_bl_hash = AUTH_PARAM_TYPE_DESC(
90 AUTH_PARAM_HASH, NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID);
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +010091static auth_param_type_desc_t scp_bl2u_hash = AUTH_PARAM_TYPE_DESC(
Juan Castillobe801202015-12-03 10:19:21 +000092 AUTH_PARAM_HASH, SCP_FWU_CFG_HASH_OID);
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +010093static auth_param_type_desc_t bl2u_hash = AUTH_PARAM_TYPE_DESC(
Juan Castillobe801202015-12-03 10:19:21 +000094 AUTH_PARAM_HASH, AP_FWU_CFG_HASH_OID);
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +010095static auth_param_type_desc_t ns_bl2u_hash = AUTH_PARAM_TYPE_DESC(
Juan Castillobe801202015-12-03 10:19:21 +000096 AUTH_PARAM_HASH, FWU_HASH_OID);
Juan Castillo9b265a82015-05-07 14:52:44 +010097
98/*
99 * TBBR Chain of trust definition
100 */
101static const auth_img_desc_t cot_desc[] = {
102 /*
103 * BL2
104 */
Juan Castillobe801202015-12-03 10:19:21 +0000105 [TRUSTED_BOOT_FW_CERT_ID] = {
106 .img_id = TRUSTED_BOOT_FW_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100107 .img_type = IMG_CERT,
108 .parent = NULL,
109 .img_auth_methods = {
110 [0] = {
111 .type = AUTH_METHOD_SIG,
112 .param.sig = {
113 .pk = &subject_pk,
114 .sig = &sig,
115 .alg = &sig_alg,
116 .data = &raw_data,
117 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000118 },
119 [1] = {
120 .type = AUTH_METHOD_NV_CTR,
121 .param.nv_ctr = {
122 .cert_nv_ctr = &trusted_nv_ctr,
123 .plat_nv_ctr = &trusted_nv_ctr
124 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100125 }
126 },
127 .authenticated_data = {
128 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000129 .type_desc = &tb_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100130 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000131 .ptr = (void *)tb_fw_hash_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100132 .len = (unsigned int)HASH_DER_LEN
133 }
Soby Mathew0bdfef02017-11-07 17:03:57 +0000134 },
135 [1] = {
136 .type_desc = &tb_fw_config_hash,
137 .data = {
138 .ptr = (void *)tb_fw_config_hash_buf,
139 .len = (unsigned int)HASH_DER_LEN
140 }
141 },
142 [2] = {
143 .type_desc = &hw_config_hash,
144 .data = {
145 .ptr = (void *)hw_config_hash_buf,
146 .len = (unsigned int)HASH_DER_LEN
147 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100148 }
149 }
150 },
151 [BL2_IMAGE_ID] = {
152 .img_id = BL2_IMAGE_ID,
153 .img_type = IMG_RAW,
Juan Castillobe801202015-12-03 10:19:21 +0000154 .parent = &cot_desc[TRUSTED_BOOT_FW_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100155 .img_auth_methods = {
156 [0] = {
157 .type = AUTH_METHOD_HASH,
158 .param.hash = {
159 .data = &raw_data,
Juan Castillobe801202015-12-03 10:19:21 +0000160 .hash = &tb_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100161 }
162 }
163 }
164 },
Soby Mathew0bdfef02017-11-07 17:03:57 +0000165 /* HW Config */
166 [HW_CONFIG_ID] = {
167 .img_id = HW_CONFIG_ID,
168 .img_type = IMG_RAW,
169 .parent = &cot_desc[TRUSTED_BOOT_FW_CERT_ID],
170 .img_auth_methods = {
171 [0] = {
172 .type = AUTH_METHOD_HASH,
173 .param.hash = {
174 .data = &raw_data,
175 .hash = &hw_config_hash,
176 }
177 }
178 }
179 },
180 /* TB FW Config */
181 [TB_FW_CONFIG_ID] = {
182 .img_id = TB_FW_CONFIG_ID,
183 .img_type = IMG_RAW,
184 .parent = &cot_desc[TRUSTED_BOOT_FW_CERT_ID],
185 .img_auth_methods = {
186 [0] = {
187 .type = AUTH_METHOD_HASH,
188 .param.hash = {
189 .data = &raw_data,
190 .hash = &tb_fw_config_hash,
191 }
192 }
193 }
194 },
Juan Castillo9b265a82015-05-07 14:52:44 +0100195 /*
196 * Trusted key certificate
197 */
198 [TRUSTED_KEY_CERT_ID] = {
199 .img_id = TRUSTED_KEY_CERT_ID,
200 .img_type = IMG_CERT,
201 .parent = NULL,
202 .img_auth_methods = {
203 [0] = {
204 .type = AUTH_METHOD_SIG,
205 .param.sig = {
206 .pk = &subject_pk,
207 .sig = &sig,
208 .alg = &sig_alg,
209 .data = &raw_data,
210 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000211 },
212 [1] = {
213 .type = AUTH_METHOD_NV_CTR,
214 .param.nv_ctr = {
215 .cert_nv_ctr = &trusted_nv_ctr,
216 .plat_nv_ctr = &trusted_nv_ctr
217 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100218 }
219 },
220 .authenticated_data = {
221 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000222 .type_desc = &trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100223 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000224 .ptr = (void *)trusted_world_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100225 .len = (unsigned int)PK_DER_LEN
226 }
227 },
228 [1] = {
Juan Castillobe801202015-12-03 10:19:21 +0000229 .type_desc = &non_trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100230 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000231 .ptr = (void *)non_trusted_world_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100232 .len = (unsigned int)PK_DER_LEN
233 }
234 }
235 }
236 },
237 /*
Juan Castillobe801202015-12-03 10:19:21 +0000238 * SCP Firmware
Juan Castillo9b265a82015-05-07 14:52:44 +0100239 */
Juan Castillobe801202015-12-03 10:19:21 +0000240 [SCP_FW_KEY_CERT_ID] = {
241 .img_id = SCP_FW_KEY_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100242 .img_type = IMG_CERT,
243 .parent = &cot_desc[TRUSTED_KEY_CERT_ID],
244 .img_auth_methods = {
245 [0] = {
246 .type = AUTH_METHOD_SIG,
247 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000248 .pk = &trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100249 .sig = &sig,
250 .alg = &sig_alg,
251 .data = &raw_data,
252 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000253 },
254 [1] = {
255 .type = AUTH_METHOD_NV_CTR,
256 .param.nv_ctr = {
257 .cert_nv_ctr = &trusted_nv_ctr,
258 .plat_nv_ctr = &trusted_nv_ctr
259 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100260 }
261 },
262 .authenticated_data = {
263 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000264 .type_desc = &scp_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100265 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000266 .ptr = (void *)content_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100267 .len = (unsigned int)PK_DER_LEN
268 }
269 }
270 }
271 },
Juan Castillobe801202015-12-03 10:19:21 +0000272 [SCP_FW_CONTENT_CERT_ID] = {
273 .img_id = SCP_FW_CONTENT_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100274 .img_type = IMG_CERT,
Juan Castillobe801202015-12-03 10:19:21 +0000275 .parent = &cot_desc[SCP_FW_KEY_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100276 .img_auth_methods = {
277 [0] = {
278 .type = AUTH_METHOD_SIG,
279 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000280 .pk = &scp_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100281 .sig = &sig,
282 .alg = &sig_alg,
283 .data = &raw_data,
284 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000285 },
286 [1] = {
287 .type = AUTH_METHOD_NV_CTR,
288 .param.nv_ctr = {
289 .cert_nv_ctr = &trusted_nv_ctr,
290 .plat_nv_ctr = &trusted_nv_ctr
291 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100292 }
293 },
294 .authenticated_data = {
295 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000296 .type_desc = &scp_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100297 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000298 .ptr = (void *)scp_fw_hash_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100299 .len = (unsigned int)HASH_DER_LEN
300 }
301 }
302 }
303 },
Juan Castilloa72b6472015-12-10 15:49:17 +0000304 [SCP_BL2_IMAGE_ID] = {
305 .img_id = SCP_BL2_IMAGE_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100306 .img_type = IMG_RAW,
Juan Castillobe801202015-12-03 10:19:21 +0000307 .parent = &cot_desc[SCP_FW_CONTENT_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100308 .img_auth_methods = {
309 [0] = {
310 .type = AUTH_METHOD_HASH,
311 .param.hash = {
312 .data = &raw_data,
Juan Castillobe801202015-12-03 10:19:21 +0000313 .hash = &scp_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100314 }
315 }
316 }
317 },
318 /*
Juan Castillobe801202015-12-03 10:19:21 +0000319 * SoC Firmware
Juan Castillo9b265a82015-05-07 14:52:44 +0100320 */
Juan Castillobe801202015-12-03 10:19:21 +0000321 [SOC_FW_KEY_CERT_ID] = {
322 .img_id = SOC_FW_KEY_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100323 .img_type = IMG_CERT,
324 .parent = &cot_desc[TRUSTED_KEY_CERT_ID],
325 .img_auth_methods = {
326 [0] = {
327 .type = AUTH_METHOD_SIG,
328 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000329 .pk = &trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100330 .sig = &sig,
331 .alg = &sig_alg,
332 .data = &raw_data,
333 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000334 },
335 [1] = {
336 .type = AUTH_METHOD_NV_CTR,
337 .param.nv_ctr = {
338 .cert_nv_ctr = &trusted_nv_ctr,
339 .plat_nv_ctr = &trusted_nv_ctr
340 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100341 }
342 },
343 .authenticated_data = {
344 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000345 .type_desc = &soc_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100346 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000347 .ptr = (void *)content_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100348 .len = (unsigned int)PK_DER_LEN
349 }
350 }
351 }
352 },
Juan Castillobe801202015-12-03 10:19:21 +0000353 [SOC_FW_CONTENT_CERT_ID] = {
354 .img_id = SOC_FW_CONTENT_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100355 .img_type = IMG_CERT,
Juan Castillobe801202015-12-03 10:19:21 +0000356 .parent = &cot_desc[SOC_FW_KEY_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100357 .img_auth_methods = {
358 [0] = {
359 .type = AUTH_METHOD_SIG,
360 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000361 .pk = &soc_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100362 .sig = &sig,
363 .alg = &sig_alg,
364 .data = &raw_data,
365 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000366 },
367 [1] = {
368 .type = AUTH_METHOD_NV_CTR,
369 .param.nv_ctr = {
370 .cert_nv_ctr = &trusted_nv_ctr,
371 .plat_nv_ctr = &trusted_nv_ctr
372 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100373 }
374 },
375 .authenticated_data = {
376 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000377 .type_desc = &soc_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100378 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000379 .ptr = (void *)soc_fw_hash_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100380 .len = (unsigned int)HASH_DER_LEN
381 }
382 }
383 }
384 },
385 [BL31_IMAGE_ID] = {
386 .img_id = BL31_IMAGE_ID,
387 .img_type = IMG_RAW,
Juan Castillobe801202015-12-03 10:19:21 +0000388 .parent = &cot_desc[SOC_FW_CONTENT_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100389 .img_auth_methods = {
390 [0] = {
391 .type = AUTH_METHOD_HASH,
392 .param.hash = {
393 .data = &raw_data,
Juan Castillobe801202015-12-03 10:19:21 +0000394 .hash = &soc_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100395 }
396 }
397 }
398 },
399 /*
Juan Castillobe801202015-12-03 10:19:21 +0000400 * Trusted OS Firmware
Juan Castillo9b265a82015-05-07 14:52:44 +0100401 */
Juan Castillobe801202015-12-03 10:19:21 +0000402 [TRUSTED_OS_FW_KEY_CERT_ID] = {
403 .img_id = TRUSTED_OS_FW_KEY_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100404 .img_type = IMG_CERT,
405 .parent = &cot_desc[TRUSTED_KEY_CERT_ID],
406 .img_auth_methods = {
407 [0] = {
408 .type = AUTH_METHOD_SIG,
409 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000410 .pk = &trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100411 .sig = &sig,
412 .alg = &sig_alg,
413 .data = &raw_data,
414 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000415 },
416 [1] = {
417 .type = AUTH_METHOD_NV_CTR,
418 .param.nv_ctr = {
419 .cert_nv_ctr = &trusted_nv_ctr,
420 .plat_nv_ctr = &trusted_nv_ctr
421 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100422 }
423 },
424 .authenticated_data = {
425 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000426 .type_desc = &tos_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100427 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000428 .ptr = (void *)content_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100429 .len = (unsigned int)PK_DER_LEN
430 }
431 }
432 }
433 },
Juan Castillobe801202015-12-03 10:19:21 +0000434 [TRUSTED_OS_FW_CONTENT_CERT_ID] = {
435 .img_id = TRUSTED_OS_FW_CONTENT_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100436 .img_type = IMG_CERT,
Juan Castillobe801202015-12-03 10:19:21 +0000437 .parent = &cot_desc[TRUSTED_OS_FW_KEY_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100438 .img_auth_methods = {
439 [0] = {
440 .type = AUTH_METHOD_SIG,
441 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000442 .pk = &tos_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100443 .sig = &sig,
444 .alg = &sig_alg,
445 .data = &raw_data,
446 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000447 },
448 [1] = {
449 .type = AUTH_METHOD_NV_CTR,
450 .param.nv_ctr = {
451 .cert_nv_ctr = &trusted_nv_ctr,
452 .plat_nv_ctr = &trusted_nv_ctr
453 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100454 }
455 },
456 .authenticated_data = {
457 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000458 .type_desc = &tos_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100459 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000460 .ptr = (void *)tos_fw_hash_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100461 .len = (unsigned int)HASH_DER_LEN
462 }
Summer Qin80726782017-04-20 16:28:39 +0100463 },
464 [1] = {
465 .type_desc = &tos_fw_extra1_hash,
466 .data = {
467 .ptr = (void *)tos_fw_extra1_hash_buf,
468 .len = (unsigned int)HASH_DER_LEN
469 }
470 },
471 [2] = {
472 .type_desc = &tos_fw_extra2_hash,
473 .data = {
474 .ptr = (void *)tos_fw_extra2_hash_buf,
475 .len = (unsigned int)HASH_DER_LEN
476 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100477 }
478 }
479 },
480 [BL32_IMAGE_ID] = {
481 .img_id = BL32_IMAGE_ID,
482 .img_type = IMG_RAW,
Juan Castillobe801202015-12-03 10:19:21 +0000483 .parent = &cot_desc[TRUSTED_OS_FW_CONTENT_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100484 .img_auth_methods = {
485 [0] = {
486 .type = AUTH_METHOD_HASH,
487 .param.hash = {
488 .data = &raw_data,
Juan Castillobe801202015-12-03 10:19:21 +0000489 .hash = &tos_fw_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100490 }
491 }
492 }
493 },
Summer Qin80726782017-04-20 16:28:39 +0100494 [BL32_EXTRA1_IMAGE_ID] = {
495 .img_id = BL32_EXTRA1_IMAGE_ID,
496 .img_type = IMG_RAW,
497 .parent = &cot_desc[TRUSTED_OS_FW_CONTENT_CERT_ID],
498 .img_auth_methods = {
499 [0] = {
500 .type = AUTH_METHOD_HASH,
501 .param.hash = {
502 .data = &raw_data,
503 .hash = &tos_fw_extra1_hash,
504 }
505 }
506 }
507 },
508 [BL32_EXTRA2_IMAGE_ID] = {
509 .img_id = BL32_EXTRA2_IMAGE_ID,
510 .img_type = IMG_RAW,
511 .parent = &cot_desc[TRUSTED_OS_FW_CONTENT_CERT_ID],
512 .img_auth_methods = {
513 [0] = {
514 .type = AUTH_METHOD_HASH,
515 .param.hash = {
516 .data = &raw_data,
517 .hash = &tos_fw_extra2_hash,
518 }
519 }
520 }
521 },
Juan Castillo9b265a82015-05-07 14:52:44 +0100522 /*
Juan Castillobe801202015-12-03 10:19:21 +0000523 * Non-Trusted Firmware
Juan Castillo9b265a82015-05-07 14:52:44 +0100524 */
Juan Castillobe801202015-12-03 10:19:21 +0000525 [NON_TRUSTED_FW_KEY_CERT_ID] = {
526 .img_id = NON_TRUSTED_FW_KEY_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100527 .img_type = IMG_CERT,
528 .parent = &cot_desc[TRUSTED_KEY_CERT_ID],
529 .img_auth_methods = {
530 [0] = {
531 .type = AUTH_METHOD_SIG,
532 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000533 .pk = &non_trusted_world_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100534 .sig = &sig,
535 .alg = &sig_alg,
536 .data = &raw_data,
537 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000538 },
539 [1] = {
540 .type = AUTH_METHOD_NV_CTR,
541 .param.nv_ctr = {
542 .cert_nv_ctr = &non_trusted_nv_ctr,
543 .plat_nv_ctr = &non_trusted_nv_ctr
544 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100545 }
546 },
547 .authenticated_data = {
548 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000549 .type_desc = &nt_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100550 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000551 .ptr = (void *)content_pk_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100552 .len = (unsigned int)PK_DER_LEN
553 }
554 }
555 }
556 },
Juan Castillobe801202015-12-03 10:19:21 +0000557 [NON_TRUSTED_FW_CONTENT_CERT_ID] = {
558 .img_id = NON_TRUSTED_FW_CONTENT_CERT_ID,
Juan Castillo9b265a82015-05-07 14:52:44 +0100559 .img_type = IMG_CERT,
Juan Castillobe801202015-12-03 10:19:21 +0000560 .parent = &cot_desc[NON_TRUSTED_FW_KEY_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100561 .img_auth_methods = {
562 [0] = {
563 .type = AUTH_METHOD_SIG,
564 .param.sig = {
Juan Castillobe801202015-12-03 10:19:21 +0000565 .pk = &nt_fw_content_pk,
Juan Castillo9b265a82015-05-07 14:52:44 +0100566 .sig = &sig,
567 .alg = &sig_alg,
568 .data = &raw_data,
569 }
Juan Castillobfb7fa62016-01-22 11:05:57 +0000570 },
571 [1] = {
572 .type = AUTH_METHOD_NV_CTR,
573 .param.nv_ctr = {
574 .cert_nv_ctr = &non_trusted_nv_ctr,
575 .plat_nv_ctr = &non_trusted_nv_ctr
576 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100577 }
578 },
579 .authenticated_data = {
580 [0] = {
Juan Castillobe801202015-12-03 10:19:21 +0000581 .type_desc = &nt_world_bl_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100582 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000583 .ptr = (void *)nt_world_bl_hash_buf,
Juan Castillo9b265a82015-05-07 14:52:44 +0100584 .len = (unsigned int)HASH_DER_LEN
585 }
586 }
587 }
588 },
589 [BL33_IMAGE_ID] = {
590 .img_id = BL33_IMAGE_ID,
591 .img_type = IMG_RAW,
Juan Castillobe801202015-12-03 10:19:21 +0000592 .parent = &cot_desc[NON_TRUSTED_FW_CONTENT_CERT_ID],
Juan Castillo9b265a82015-05-07 14:52:44 +0100593 .img_auth_methods = {
594 [0] = {
595 .type = AUTH_METHOD_HASH,
596 .param.hash = {
597 .data = &raw_data,
Juan Castillobe801202015-12-03 10:19:21 +0000598 .hash = &nt_world_bl_hash,
Juan Castillo9b265a82015-05-07 14:52:44 +0100599 }
600 }
601 }
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +0100602 },
603 /*
604 * FWU auth descriptor.
605 */
606 [FWU_CERT_ID] = {
607 .img_id = FWU_CERT_ID,
608 .img_type = IMG_CERT,
609 .parent = NULL,
610 .img_auth_methods = {
611 [0] = {
612 .type = AUTH_METHOD_SIG,
613 .param.sig = {
614 .pk = &subject_pk,
615 .sig = &sig,
616 .alg = &sig_alg,
617 .data = &raw_data,
618 }
619 }
620 },
621 .authenticated_data = {
622 [0] = {
623 .type_desc = &scp_bl2u_hash,
624 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000625 .ptr = (void *)scp_fw_hash_buf,
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +0100626 .len = (unsigned int)HASH_DER_LEN
627 }
628 },
629 [1] = {
630 .type_desc = &bl2u_hash,
631 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000632 .ptr = (void *)tb_fw_hash_buf,
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +0100633 .len = (unsigned int)HASH_DER_LEN
634 }
635 },
636 [2] = {
637 .type_desc = &ns_bl2u_hash,
638 .data = {
Juan Castillobe801202015-12-03 10:19:21 +0000639 .ptr = (void *)nt_world_bl_hash_buf,
Yatharth Kochar71c9a5e2015-10-10 19:06:53 +0100640 .len = (unsigned int)HASH_DER_LEN
641 }
642 }
643 }
644 },
645 /*
646 * SCP_BL2U
647 */
648 [SCP_BL2U_IMAGE_ID] = {
649 .img_id = SCP_BL2U_IMAGE_ID,
650 .img_type = IMG_RAW,
651 .parent = &cot_desc[FWU_CERT_ID],
652 .img_auth_methods = {
653 [0] = {
654 .type = AUTH_METHOD_HASH,
655 .param.hash = {
656 .data = &raw_data,
657 .hash = &scp_bl2u_hash,
658 }
659 }
660 }
661 },
662 /*
663 * BL2U
664 */
665 [BL2U_IMAGE_ID] = {
666 .img_id = BL2U_IMAGE_ID,
667 .img_type = IMG_RAW,
668 .parent = &cot_desc[FWU_CERT_ID],
669 .img_auth_methods = {
670 [0] = {
671 .type = AUTH_METHOD_HASH,
672 .param.hash = {
673 .data = &raw_data,
674 .hash = &bl2u_hash,
675 }
676 }
677 }
678 },
679 /*
680 * NS_BL2U
681 */
682 [NS_BL2U_IMAGE_ID] = {
683 .img_id = NS_BL2U_IMAGE_ID,
684 .img_type = IMG_RAW,
685 .parent = &cot_desc[FWU_CERT_ID],
686 .img_auth_methods = {
687 [0] = {
688 .type = AUTH_METHOD_HASH,
689 .param.hash = {
690 .data = &raw_data,
691 .hash = &ns_bl2u_hash,
692 }
693 }
694 }
Juan Castillo9b265a82015-05-07 14:52:44 +0100695 }
696};
697
698/* Register the CoT in the authentication module */
699REGISTER_COT(cot_desc);