blob: 8c3724880aa8f46a80eefc67e9419a1fa45bb162 [file] [log] [blame]
Manish V Badarkhe043fd622020-05-16 16:36:39 +01001/*
Govindraj Raja9c7dfb02023-01-11 18:34:58 +00002 * Copyright (c) 2015-2023, Arm Limited and Contributors. All rights reserved.
Manish V Badarkhe043fd622020-05-16 16:36:39 +01003 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <stddef.h>
8
Govindraj Raja9c7dfb02023-01-11 18:34:58 +00009#include <mbedtls/version.h>
Manish V Badarkhe043fd622020-05-16 16:36:39 +010010
11#include <drivers/auth/auth_mod.h>
12#include <drivers/auth/tbbr_cot_common.h>
Govindraj Raja9c7dfb02023-01-11 18:34:58 +000013
Manish V Badarkhe043fd622020-05-16 16:36:39 +010014#if USE_TBBR_DEFS
15#include <tools_share/tbbr_oid.h>
16#else
17#include <platform_oid.h>
18#endif
19
Govindraj Raja9c7dfb02023-01-11 18:34:58 +000020#include <platform_def.h>
Manish V Badarkhe043fd622020-05-16 16:36:39 +010021/*
22 * The platform must allocate buffers to store the authentication parameters
23 * extracted from the certificates. In this case, because of the way the CoT is
24 * established, we can reuse some of the buffers on different stages
25 */
26
Louis Mayencourt244027d2020-06-11 21:15:15 +010027static unsigned char fw_config_hash_buf[HASH_DER_LEN];
28static unsigned char tb_fw_config_hash_buf[HASH_DER_LEN];
29static unsigned char hw_config_hash_buf[HASH_DER_LEN];
Manish V Badarkhe043fd622020-05-16 16:36:39 +010030unsigned char tb_fw_hash_buf[HASH_DER_LEN];
Manish V Badarkhe043fd622020-05-16 16:36:39 +010031unsigned char scp_fw_hash_buf[HASH_DER_LEN];
32unsigned char nt_world_bl_hash_buf[HASH_DER_LEN];
33
34/*
35 * common Parameter type descriptors across BL1 and BL2
36 */
37auth_param_type_desc_t trusted_nv_ctr = AUTH_PARAM_TYPE_DESC(
38 AUTH_PARAM_NV_CTR, TRUSTED_FW_NVCOUNTER_OID);
39auth_param_type_desc_t subject_pk = AUTH_PARAM_TYPE_DESC(
40 AUTH_PARAM_PUB_KEY, 0);
41auth_param_type_desc_t sig = AUTH_PARAM_TYPE_DESC(
42 AUTH_PARAM_SIG, 0);
43auth_param_type_desc_t sig_alg = AUTH_PARAM_TYPE_DESC(
44 AUTH_PARAM_SIG_ALG, 0);
45auth_param_type_desc_t raw_data = AUTH_PARAM_TYPE_DESC(
46 AUTH_PARAM_RAW_DATA, 0);
47
48/* common hash used across BL1 and BL2 */
49auth_param_type_desc_t tb_fw_hash = AUTH_PARAM_TYPE_DESC(
50 AUTH_PARAM_HASH, TRUSTED_BOOT_FW_HASH_OID);
51auth_param_type_desc_t tb_fw_config_hash = AUTH_PARAM_TYPE_DESC(
52 AUTH_PARAM_HASH, TRUSTED_BOOT_FW_CONFIG_HASH_OID);
Louis Mayencourt244027d2020-06-11 21:15:15 +010053auth_param_type_desc_t fw_config_hash = AUTH_PARAM_TYPE_DESC(
54 AUTH_PARAM_HASH, FW_CONFIG_HASH_OID);
55static auth_param_type_desc_t hw_config_hash = AUTH_PARAM_TYPE_DESC(
Manish V Badarkhe043fd622020-05-16 16:36:39 +010056 AUTH_PARAM_HASH, HW_CONFIG_HASH_OID);
57
58/* trusted_boot_fw_cert */
59const auth_img_desc_t trusted_boot_fw_cert = {
60 .img_id = TRUSTED_BOOT_FW_CERT_ID,
61 .img_type = IMG_CERT,
62 .parent = NULL,
63 .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
64 [0] = {
65 .type = AUTH_METHOD_SIG,
66 .param.sig = {
67 .pk = &subject_pk,
68 .sig = &sig,
69 .alg = &sig_alg,
70 .data = &raw_data
71 }
72 },
73 [1] = {
74 .type = AUTH_METHOD_NV_CTR,
75 .param.nv_ctr = {
76 .cert_nv_ctr = &trusted_nv_ctr,
77 .plat_nv_ctr = &trusted_nv_ctr
78 }
79 }
80 },
81 .authenticated_data = (const auth_param_desc_t[COT_MAX_VERIFIED_PARAMS]) {
82 [0] = {
83 .type_desc = &tb_fw_hash,
84 .data = {
85 .ptr = (void *)tb_fw_hash_buf,
86 .len = (unsigned int)HASH_DER_LEN
87 }
88 },
89 [1] = {
90 .type_desc = &tb_fw_config_hash,
91 .data = {
92 .ptr = (void *)tb_fw_config_hash_buf,
93 .len = (unsigned int)HASH_DER_LEN
94 }
95 },
96 [2] = {
97 .type_desc = &hw_config_hash,
98 .data = {
99 .ptr = (void *)hw_config_hash_buf,
100 .len = (unsigned int)HASH_DER_LEN
101 }
Louis Mayencourt244027d2020-06-11 21:15:15 +0100102 },
103 [3] = {
104 .type_desc = &fw_config_hash,
105 .data = {
106 .ptr = (void *)fw_config_hash_buf,
107 .len = (unsigned int)HASH_DER_LEN
108 }
Manish V Badarkhe043fd622020-05-16 16:36:39 +0100109 }
110 }
111};
112
113/* HW Config */
114const auth_img_desc_t hw_config = {
115 .img_id = HW_CONFIG_ID,
116 .img_type = IMG_RAW,
117 .parent = &trusted_boot_fw_cert,
118 .img_auth_methods = (const auth_method_desc_t[AUTH_METHOD_NUM]) {
119 [0] = {
120 .type = AUTH_METHOD_HASH,
121 .param.hash = {
122 .data = &raw_data,
123 .hash = &hw_config_hash
124 }
125 }
126 }
127};