laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 1 | /* |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 2 | * Copyright (c) 2022-2024, Arm Limited. All rights reserved. |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <stddef.h> |
| 8 | |
Govindraj Raja | a8eadc5 | 2023-01-11 18:34:58 +0000 | [diff] [blame] | 9 | #include <mbedtls/version.h> |
| 10 | |
| 11 | #include <common/tbbr/cot_def.h> |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 12 | #include <drivers/auth/auth_mod.h> |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 13 | #include <tools_share/cca_oid.h> |
| 14 | |
| 15 | #include <platform_def.h> |
| 16 | |
| 17 | /* |
| 18 | * Allocate static buffers to store the authentication parameters extracted from |
| 19 | * the certificates. |
| 20 | */ |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 21 | static unsigned char hw_config_hash_buf[HASH_DER_LEN]; |
| 22 | static unsigned char soc_fw_hash_buf[HASH_DER_LEN]; |
| 23 | static unsigned char soc_fw_config_hash_buf[HASH_DER_LEN]; |
| 24 | static unsigned char rmm_hash_buf[HASH_DER_LEN]; |
| 25 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 26 | static unsigned char nt_world_bl_hash_buf[HASH_DER_LEN]; |
| 27 | static unsigned char tos_fw_hash_buf[HASH_DER_LEN]; |
| 28 | static unsigned char tos_fw_config_hash_buf[HASH_DER_LEN]; |
| 29 | static unsigned char nt_fw_config_hash_buf[HASH_DER_LEN]; |
| 30 | #if defined(SPD_spmd) |
| 31 | static unsigned char sp_pkg_hash_buf[MAX_SP_IDS][HASH_DER_LEN]; |
| 32 | #endif /* SPD_spmd */ |
| 33 | |
| 34 | static unsigned char core_swd_pk_buf[PK_DER_LEN]; |
| 35 | static unsigned char plat_pk_buf[PK_DER_LEN]; |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * Parameter type descriptors. |
| 39 | */ |
laurenw-arm | e3b1cc0 | 2023-05-02 14:40:15 -0500 | [diff] [blame] | 40 | static auth_param_type_desc_t cca_nv_ctr = AUTH_PARAM_TYPE_DESC( |
| 41 | AUTH_PARAM_NV_CTR, CCA_FW_NVCOUNTER_OID); |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 42 | static auth_param_type_desc_t subject_pk = AUTH_PARAM_TYPE_DESC( |
| 43 | AUTH_PARAM_PUB_KEY, 0); |
| 44 | static auth_param_type_desc_t sig = AUTH_PARAM_TYPE_DESC( |
| 45 | AUTH_PARAM_SIG, 0); |
| 46 | static auth_param_type_desc_t sig_alg = AUTH_PARAM_TYPE_DESC( |
| 47 | AUTH_PARAM_SIG_ALG, 0); |
| 48 | static auth_param_type_desc_t raw_data = AUTH_PARAM_TYPE_DESC( |
| 49 | AUTH_PARAM_RAW_DATA, 0); |
| 50 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 51 | static auth_param_type_desc_t hw_config_hash = AUTH_PARAM_TYPE_DESC( |
| 52 | AUTH_PARAM_HASH, HW_CONFIG_HASH_OID); |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 53 | static auth_param_type_desc_t soc_fw_hash = AUTH_PARAM_TYPE_DESC( |
| 54 | AUTH_PARAM_HASH, SOC_AP_FW_HASH_OID); |
| 55 | static auth_param_type_desc_t soc_fw_config_hash = AUTH_PARAM_TYPE_DESC( |
| 56 | AUTH_PARAM_HASH, SOC_FW_CONFIG_HASH_OID); |
| 57 | static auth_param_type_desc_t rmm_hash = AUTH_PARAM_TYPE_DESC( |
| 58 | AUTH_PARAM_HASH, RMM_HASH_OID); |
| 59 | |
laurenw-arm | e3b1cc0 | 2023-05-02 14:40:15 -0500 | [diff] [blame] | 60 | static auth_param_type_desc_t trusted_nv_ctr = AUTH_PARAM_TYPE_DESC( |
| 61 | AUTH_PARAM_NV_CTR, TRUSTED_FW_NVCOUNTER_OID); |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 62 | static auth_param_type_desc_t non_trusted_nv_ctr = AUTH_PARAM_TYPE_DESC( |
| 63 | AUTH_PARAM_NV_CTR, NON_TRUSTED_FW_NVCOUNTER_OID); |
| 64 | |
| 65 | static auth_param_type_desc_t prot_pk = AUTH_PARAM_TYPE_DESC( |
| 66 | AUTH_PARAM_PUB_KEY, PROT_PK_OID); |
| 67 | static auth_param_type_desc_t swd_rot_pk = AUTH_PARAM_TYPE_DESC( |
| 68 | AUTH_PARAM_PUB_KEY, SWD_ROT_PK_OID); |
| 69 | static auth_param_type_desc_t core_swd_pk = AUTH_PARAM_TYPE_DESC( |
| 70 | AUTH_PARAM_PUB_KEY, CORE_SWD_PK_OID); |
| 71 | static auth_param_type_desc_t plat_pk = AUTH_PARAM_TYPE_DESC( |
| 72 | AUTH_PARAM_PUB_KEY, PLAT_PK_OID); |
| 73 | |
| 74 | static auth_param_type_desc_t tos_fw_hash = AUTH_PARAM_TYPE_DESC( |
| 75 | AUTH_PARAM_HASH, TRUSTED_OS_FW_HASH_OID); |
| 76 | static auth_param_type_desc_t tos_fw_config_hash = AUTH_PARAM_TYPE_DESC( |
| 77 | AUTH_PARAM_HASH, TRUSTED_OS_FW_CONFIG_HASH_OID); |
| 78 | static auth_param_type_desc_t nt_world_bl_hash = AUTH_PARAM_TYPE_DESC( |
| 79 | AUTH_PARAM_HASH, NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID); |
| 80 | static auth_param_type_desc_t nt_fw_config_hash = AUTH_PARAM_TYPE_DESC( |
| 81 | AUTH_PARAM_HASH, NON_TRUSTED_FW_CONFIG_HASH_OID); |
| 82 | #if defined(SPD_spmd) |
| 83 | static auth_param_type_desc_t sp_pkg1_hash = AUTH_PARAM_TYPE_DESC( |
| 84 | AUTH_PARAM_HASH, SP_PKG1_HASH_OID); |
| 85 | static auth_param_type_desc_t sp_pkg2_hash = AUTH_PARAM_TYPE_DESC( |
| 86 | AUTH_PARAM_HASH, SP_PKG2_HASH_OID); |
| 87 | static auth_param_type_desc_t sp_pkg3_hash = AUTH_PARAM_TYPE_DESC( |
| 88 | AUTH_PARAM_HASH, SP_PKG3_HASH_OID); |
| 89 | static auth_param_type_desc_t sp_pkg4_hash = AUTH_PARAM_TYPE_DESC( |
| 90 | AUTH_PARAM_HASH, SP_PKG4_HASH_OID); |
| 91 | static auth_param_type_desc_t sp_pkg5_hash = AUTH_PARAM_TYPE_DESC( |
| 92 | AUTH_PARAM_HASH, SP_PKG5_HASH_OID); |
| 93 | static auth_param_type_desc_t sp_pkg6_hash = AUTH_PARAM_TYPE_DESC( |
| 94 | AUTH_PARAM_HASH, SP_PKG6_HASH_OID); |
| 95 | static auth_param_type_desc_t sp_pkg7_hash = AUTH_PARAM_TYPE_DESC( |
| 96 | AUTH_PARAM_HASH, SP_PKG7_HASH_OID); |
| 97 | static auth_param_type_desc_t sp_pkg8_hash = AUTH_PARAM_TYPE_DESC( |
| 98 | AUTH_PARAM_HASH, SP_PKG8_HASH_OID); |
| 99 | #endif /* SPD_spmd */ |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 100 | |
| 101 | /* CCA Content Certificate */ |
| 102 | static const auth_img_desc_t cca_content_cert = { |
| 103 | .img_id = CCA_CONTENT_CERT_ID, |
| 104 | .img_type = IMG_CERT, |
| 105 | .parent = NULL, |
| 106 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 107 | [0] = { |
| 108 | .type = AUTH_METHOD_SIG, |
| 109 | .param.sig = { |
| 110 | .pk = &subject_pk, |
| 111 | .sig = &sig, |
| 112 | .alg = &sig_alg, |
| 113 | .data = &raw_data |
| 114 | } |
| 115 | }, |
| 116 | [1] = { |
| 117 | .type = AUTH_METHOD_NV_CTR, |
| 118 | .param.nv_ctr = { |
laurenw-arm | e3b1cc0 | 2023-05-02 14:40:15 -0500 | [diff] [blame] | 119 | .cert_nv_ctr = &cca_nv_ctr, |
| 120 | .plat_nv_ctr = &cca_nv_ctr |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 121 | } |
| 122 | } |
| 123 | }, |
| 124 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 125 | [0] = { |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 126 | .type_desc = &hw_config_hash, |
| 127 | .data = { |
| 128 | .ptr = (void *)hw_config_hash_buf, |
| 129 | .len = (unsigned int)HASH_DER_LEN |
| 130 | } |
| 131 | }, |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 132 | [1] = { |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 133 | .type_desc = &soc_fw_hash, |
| 134 | .data = { |
| 135 | .ptr = (void *)soc_fw_hash_buf, |
| 136 | .len = (unsigned int)HASH_DER_LEN |
| 137 | } |
| 138 | }, |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 139 | [2] = { |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 140 | .type_desc = &soc_fw_config_hash, |
| 141 | .data = { |
| 142 | .ptr = (void *)soc_fw_config_hash_buf, |
| 143 | .len = (unsigned int)HASH_DER_LEN |
| 144 | } |
| 145 | }, |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 146 | [3] = { |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 147 | .type_desc = &rmm_hash, |
| 148 | .data = { |
| 149 | .ptr = (void *)rmm_hash_buf, |
| 150 | .len = (unsigned int)HASH_DER_LEN |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | }; |
| 155 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 156 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 157 | /* HW Config */ |
| 158 | static const auth_img_desc_t hw_config = { |
| 159 | .img_id = HW_CONFIG_ID, |
| 160 | .img_type = IMG_RAW, |
| 161 | .parent = &cca_content_cert, |
| 162 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 163 | [0] = { |
| 164 | .type = AUTH_METHOD_HASH, |
| 165 | .param.hash = { |
| 166 | .data = &raw_data, |
| 167 | .hash = &hw_config_hash |
| 168 | } |
| 169 | } |
| 170 | } |
| 171 | }; |
| 172 | |
| 173 | /* BL31 */ |
| 174 | static const auth_img_desc_t bl31_image = { |
| 175 | .img_id = BL31_IMAGE_ID, |
| 176 | .img_type = IMG_RAW, |
| 177 | .parent = &cca_content_cert, |
| 178 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 179 | [0] = { |
| 180 | .type = AUTH_METHOD_HASH, |
| 181 | .param.hash = { |
| 182 | .data = &raw_data, |
| 183 | .hash = &soc_fw_hash |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | }; |
| 188 | |
| 189 | /* BL31 Config */ |
| 190 | static const auth_img_desc_t soc_fw_config = { |
| 191 | .img_id = SOC_FW_CONFIG_ID, |
| 192 | .img_type = IMG_RAW, |
| 193 | .parent = &cca_content_cert, |
| 194 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 195 | [0] = { |
| 196 | .type = AUTH_METHOD_HASH, |
| 197 | .param.hash = { |
| 198 | .data = &raw_data, |
| 199 | .hash = &soc_fw_config_hash |
| 200 | } |
| 201 | } |
| 202 | } |
| 203 | }; |
| 204 | |
| 205 | /* RMM */ |
| 206 | static const auth_img_desc_t rmm_image = { |
| 207 | .img_id = RMM_IMAGE_ID, |
| 208 | .img_type = IMG_RAW, |
| 209 | .parent = &cca_content_cert, |
| 210 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 211 | [0] = { |
| 212 | .type = AUTH_METHOD_HASH, |
| 213 | .param.hash = { |
| 214 | .data = &raw_data, |
| 215 | .hash = &rmm_hash |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | }; |
| 220 | |
| 221 | /* Core SWD Key Certificate */ |
| 222 | static const auth_img_desc_t core_swd_key_cert = { |
| 223 | .img_id = CORE_SWD_KEY_CERT_ID, |
| 224 | .img_type = IMG_CERT, |
| 225 | .parent = NULL, /* SWD ROOT CERT */ |
| 226 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 227 | [0] = { |
| 228 | .type = AUTH_METHOD_SIG, |
| 229 | .param.sig = { |
| 230 | .pk = &swd_rot_pk, |
| 231 | .sig = &sig, |
| 232 | .alg = &sig_alg, |
| 233 | .data = &raw_data |
| 234 | } |
| 235 | }, |
| 236 | [1] = { |
| 237 | .type = AUTH_METHOD_NV_CTR, |
| 238 | .param.nv_ctr = { |
| 239 | .cert_nv_ctr = &trusted_nv_ctr, |
| 240 | .plat_nv_ctr = &trusted_nv_ctr |
| 241 | } |
| 242 | } |
| 243 | }, |
| 244 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 245 | [0] = { |
| 246 | .type_desc = &core_swd_pk, |
| 247 | .data = { |
| 248 | .ptr = (void *)core_swd_pk_buf, |
| 249 | .len = (unsigned int)PK_DER_LEN |
| 250 | } |
| 251 | } |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | /* SPMC Content Certificate */ |
| 256 | static const auth_img_desc_t trusted_os_fw_content_cert = { |
| 257 | .img_id = TRUSTED_OS_FW_CONTENT_CERT_ID, |
| 258 | .img_type = IMG_CERT, |
| 259 | .parent = &core_swd_key_cert, |
| 260 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 261 | [0] = { |
| 262 | .type = AUTH_METHOD_SIG, |
| 263 | .param.sig = { |
| 264 | .pk = &core_swd_pk, |
| 265 | .sig = &sig, |
| 266 | .alg = &sig_alg, |
| 267 | .data = &raw_data |
| 268 | } |
| 269 | }, |
| 270 | [1] = { |
| 271 | .type = AUTH_METHOD_NV_CTR, |
| 272 | .param.nv_ctr = { |
| 273 | .cert_nv_ctr = &trusted_nv_ctr, |
| 274 | .plat_nv_ctr = &trusted_nv_ctr |
| 275 | } |
| 276 | } |
| 277 | }, |
| 278 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 279 | [0] = { |
| 280 | .type_desc = &tos_fw_hash, |
| 281 | .data = { |
| 282 | .ptr = (void *)tos_fw_hash_buf, |
| 283 | .len = (unsigned int)HASH_DER_LEN |
| 284 | } |
| 285 | }, |
| 286 | [1] = { |
| 287 | .type_desc = &tos_fw_config_hash, |
| 288 | .data = { |
| 289 | .ptr = (void *)tos_fw_config_hash_buf, |
| 290 | .len = (unsigned int)HASH_DER_LEN |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | }; |
| 295 | |
| 296 | /* SPMC */ |
| 297 | static const auth_img_desc_t bl32_image = { |
| 298 | .img_id = BL32_IMAGE_ID, |
| 299 | .img_type = IMG_RAW, |
| 300 | .parent = &trusted_os_fw_content_cert, |
| 301 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 302 | [0] = { |
| 303 | .type = AUTH_METHOD_HASH, |
| 304 | .param.hash = { |
| 305 | .data = &raw_data, |
| 306 | .hash = &tos_fw_hash |
| 307 | } |
| 308 | } |
| 309 | } |
| 310 | }; |
| 311 | |
| 312 | /* SPM Config */ |
| 313 | static const auth_img_desc_t tos_fw_config = { |
| 314 | .img_id = TOS_FW_CONFIG_ID, |
| 315 | .img_type = IMG_RAW, |
| 316 | .parent = &trusted_os_fw_content_cert, |
| 317 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 318 | [0] = { |
| 319 | .type = AUTH_METHOD_HASH, |
| 320 | .param.hash = { |
| 321 | .data = &raw_data, |
| 322 | .hash = &tos_fw_config_hash |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | }; |
| 327 | |
| 328 | /* Platform Key Certificate */ |
| 329 | static const auth_img_desc_t plat_key_cert = { |
| 330 | .img_id = PLAT_KEY_CERT_ID, |
| 331 | .img_type = IMG_CERT, |
| 332 | .parent = NULL, /* PLATFORM ROOT CERT */ |
| 333 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 334 | [0] = { |
| 335 | .type = AUTH_METHOD_SIG, |
| 336 | .param.sig = { |
| 337 | .pk = &prot_pk, |
| 338 | .sig = &sig, |
| 339 | .alg = &sig_alg, |
| 340 | .data = &raw_data |
| 341 | } |
| 342 | }, |
| 343 | [1] = { |
| 344 | .type = AUTH_METHOD_NV_CTR, |
| 345 | .param.nv_ctr = { |
| 346 | .cert_nv_ctr = &non_trusted_nv_ctr, |
| 347 | .plat_nv_ctr = &non_trusted_nv_ctr |
| 348 | } |
| 349 | } |
| 350 | }, |
| 351 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 352 | [0] = { |
| 353 | .type_desc = &plat_pk, |
| 354 | .data = { |
| 355 | .ptr = (void *)plat_pk_buf, |
| 356 | .len = (unsigned int)PK_DER_LEN |
| 357 | } |
| 358 | } |
| 359 | } |
| 360 | }; |
| 361 | |
| 362 | /* Non-Trusted Firmware */ |
| 363 | static const auth_img_desc_t non_trusted_fw_content_cert = { |
| 364 | .img_id = NON_TRUSTED_FW_CONTENT_CERT_ID, |
| 365 | .img_type = IMG_CERT, |
| 366 | .parent = &plat_key_cert, |
| 367 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 368 | [0] = { |
| 369 | .type = AUTH_METHOD_SIG, |
| 370 | .param.sig = { |
| 371 | .pk = &plat_pk, |
| 372 | .sig = &sig, |
| 373 | .alg = &sig_alg, |
| 374 | .data = &raw_data |
| 375 | } |
| 376 | }, |
| 377 | [1] = { |
| 378 | .type = AUTH_METHOD_NV_CTR, |
| 379 | .param.nv_ctr = { |
| 380 | .cert_nv_ctr = &non_trusted_nv_ctr, |
| 381 | .plat_nv_ctr = &non_trusted_nv_ctr |
| 382 | } |
| 383 | } |
| 384 | }, |
| 385 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 386 | [0] = { |
| 387 | .type_desc = &nt_world_bl_hash, |
| 388 | .data = { |
| 389 | .ptr = (void *)nt_world_bl_hash_buf, |
| 390 | .len = (unsigned int)HASH_DER_LEN |
| 391 | } |
| 392 | }, |
| 393 | [1] = { |
| 394 | .type_desc = &nt_fw_config_hash, |
| 395 | .data = { |
| 396 | .ptr = (void *)nt_fw_config_hash_buf, |
| 397 | .len = (unsigned int)HASH_DER_LEN |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | }; |
| 402 | |
| 403 | static const auth_img_desc_t bl33_image = { |
| 404 | .img_id = BL33_IMAGE_ID, |
| 405 | .img_type = IMG_RAW, |
| 406 | .parent = &non_trusted_fw_content_cert, |
| 407 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 408 | [0] = { |
| 409 | .type = AUTH_METHOD_HASH, |
| 410 | .param.hash = { |
| 411 | .data = &raw_data, |
| 412 | .hash = &nt_world_bl_hash |
| 413 | } |
| 414 | } |
| 415 | } |
| 416 | }; |
| 417 | |
| 418 | /* NT FW Config */ |
| 419 | static const auth_img_desc_t nt_fw_config = { |
| 420 | .img_id = NT_FW_CONFIG_ID, |
| 421 | .img_type = IMG_RAW, |
| 422 | .parent = &non_trusted_fw_content_cert, |
| 423 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 424 | [0] = { |
| 425 | .type = AUTH_METHOD_HASH, |
| 426 | .param.hash = { |
| 427 | .data = &raw_data, |
| 428 | .hash = &nt_fw_config_hash |
| 429 | } |
| 430 | } |
| 431 | } |
| 432 | }; |
| 433 | |
| 434 | /* |
| 435 | * Secure Partitions |
| 436 | */ |
| 437 | #if defined(SPD_spmd) |
| 438 | static const auth_img_desc_t sip_sp_content_cert = { |
| 439 | .img_id = SIP_SP_CONTENT_CERT_ID, |
| 440 | .img_type = IMG_CERT, |
| 441 | .parent = &core_swd_key_cert, |
| 442 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 443 | [0] = { |
| 444 | .type = AUTH_METHOD_SIG, |
| 445 | .param.sig = { |
| 446 | .pk = &core_swd_pk, |
| 447 | .sig = &sig, |
| 448 | .alg = &sig_alg, |
| 449 | .data = &raw_data |
| 450 | } |
| 451 | }, |
| 452 | [1] = { |
| 453 | .type = AUTH_METHOD_NV_CTR, |
| 454 | .param.nv_ctr = { |
| 455 | .cert_nv_ctr = &trusted_nv_ctr, |
| 456 | .plat_nv_ctr = &trusted_nv_ctr |
| 457 | } |
| 458 | } |
| 459 | }, |
| 460 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 461 | [0] = { |
| 462 | .type_desc = &sp_pkg1_hash, |
| 463 | .data = { |
| 464 | .ptr = (void *)sp_pkg_hash_buf[0], |
| 465 | .len = (unsigned int)HASH_DER_LEN |
| 466 | } |
| 467 | }, |
| 468 | [1] = { |
| 469 | .type_desc = &sp_pkg2_hash, |
| 470 | .data = { |
| 471 | .ptr = (void *)sp_pkg_hash_buf[1], |
| 472 | .len = (unsigned int)HASH_DER_LEN |
| 473 | } |
| 474 | }, |
| 475 | [2] = { |
| 476 | .type_desc = &sp_pkg3_hash, |
| 477 | .data = { |
| 478 | .ptr = (void *)sp_pkg_hash_buf[2], |
| 479 | .len = (unsigned int)HASH_DER_LEN |
| 480 | } |
| 481 | }, |
| 482 | [3] = { |
| 483 | .type_desc = &sp_pkg4_hash, |
| 484 | .data = { |
| 485 | .ptr = (void *)sp_pkg_hash_buf[3], |
| 486 | .len = (unsigned int)HASH_DER_LEN |
| 487 | } |
| 488 | } |
| 489 | } |
| 490 | }; |
| 491 | |
| 492 | DEFINE_SIP_SP_PKG(1); |
| 493 | DEFINE_SIP_SP_PKG(2); |
| 494 | DEFINE_SIP_SP_PKG(3); |
| 495 | DEFINE_SIP_SP_PKG(4); |
| 496 | |
| 497 | static const auth_img_desc_t plat_sp_content_cert = { |
| 498 | .img_id = PLAT_SP_CONTENT_CERT_ID, |
| 499 | .img_type = IMG_CERT, |
| 500 | .parent = &plat_key_cert, |
| 501 | .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) { |
| 502 | [0] = { |
| 503 | .type = AUTH_METHOD_SIG, |
| 504 | .param.sig = { |
| 505 | .pk = &plat_pk, |
| 506 | .sig = &sig, |
| 507 | .alg = &sig_alg, |
| 508 | .data = &raw_data |
| 509 | } |
| 510 | }, |
| 511 | [1] = { |
| 512 | .type = AUTH_METHOD_NV_CTR, |
| 513 | .param.nv_ctr = { |
| 514 | .cert_nv_ctr = &non_trusted_nv_ctr, |
| 515 | .plat_nv_ctr = &non_trusted_nv_ctr |
| 516 | } |
| 517 | } |
| 518 | }, |
| 519 | .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) { |
| 520 | [0] = { |
| 521 | .type_desc = &sp_pkg5_hash, |
| 522 | .data = { |
| 523 | .ptr = (void *)sp_pkg_hash_buf[4], |
| 524 | .len = (unsigned int)HASH_DER_LEN |
| 525 | } |
| 526 | }, |
| 527 | [1] = { |
| 528 | .type_desc = &sp_pkg6_hash, |
| 529 | .data = { |
| 530 | .ptr = (void *)sp_pkg_hash_buf[5], |
| 531 | .len = (unsigned int)HASH_DER_LEN |
| 532 | } |
| 533 | }, |
| 534 | [2] = { |
| 535 | .type_desc = &sp_pkg7_hash, |
| 536 | .data = { |
| 537 | .ptr = (void *)sp_pkg_hash_buf[6], |
| 538 | .len = (unsigned int)HASH_DER_LEN |
| 539 | } |
| 540 | }, |
| 541 | [3] = { |
| 542 | .type_desc = &sp_pkg8_hash, |
| 543 | .data = { |
| 544 | .ptr = (void *)sp_pkg_hash_buf[7], |
| 545 | .len = (unsigned int)HASH_DER_LEN |
| 546 | } |
| 547 | } |
| 548 | } |
| 549 | }; |
| 550 | |
| 551 | DEFINE_PLAT_SP_PKG(5); |
| 552 | DEFINE_PLAT_SP_PKG(6); |
| 553 | DEFINE_PLAT_SP_PKG(7); |
| 554 | DEFINE_PLAT_SP_PKG(8); |
| 555 | #endif /* SPD_spmd */ |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 556 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 557 | /* |
| 558 | * Chain of trust definition |
| 559 | */ |
Xialin Liu | 3146a70 | 2024-06-27 12:07:10 -0500 | [diff] [blame] | 560 | |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 561 | static const auth_img_desc_t * const cot_desc[] = { |
| 562 | [CCA_CONTENT_CERT_ID] = &cca_content_cert, |
| 563 | [HW_CONFIG_ID] = &hw_config, |
| 564 | [BL31_IMAGE_ID] = &bl31_image, |
| 565 | [SOC_FW_CONFIG_ID] = &soc_fw_config, |
| 566 | [RMM_IMAGE_ID] = &rmm_image, |
| 567 | [CORE_SWD_KEY_CERT_ID] = &core_swd_key_cert, |
| 568 | [TRUSTED_OS_FW_CONTENT_CERT_ID] = &trusted_os_fw_content_cert, |
| 569 | [BL32_IMAGE_ID] = &bl32_image, |
| 570 | [TOS_FW_CONFIG_ID] = &tos_fw_config, |
| 571 | [PLAT_KEY_CERT_ID] = &plat_key_cert, |
| 572 | [NON_TRUSTED_FW_CONTENT_CERT_ID] = &non_trusted_fw_content_cert, |
| 573 | [BL33_IMAGE_ID] = &bl33_image, |
| 574 | [NT_FW_CONFIG_ID] = &nt_fw_config, |
| 575 | #if defined(SPD_spmd) |
| 576 | [SIP_SP_CONTENT_CERT_ID] = &sip_sp_content_cert, |
| 577 | [PLAT_SP_CONTENT_CERT_ID] = &plat_sp_content_cert, |
| 578 | [SP_PKG1_ID] = &sp_pkg1, |
| 579 | [SP_PKG2_ID] = &sp_pkg2, |
| 580 | [SP_PKG3_ID] = &sp_pkg3, |
| 581 | [SP_PKG4_ID] = &sp_pkg4, |
| 582 | [SP_PKG5_ID] = &sp_pkg5, |
| 583 | [SP_PKG6_ID] = &sp_pkg6, |
| 584 | [SP_PKG7_ID] = &sp_pkg7, |
| 585 | [SP_PKG8_ID] = &sp_pkg8, |
| 586 | #endif |
| 587 | }; |
laurenw-arm | 56b741d | 2022-04-21 15:49:00 -0500 | [diff] [blame] | 588 | |
| 589 | /* Register the CoT in the authentication module */ |
| 590 | REGISTER_COT(cot_desc); |