blob: 504b0fc0a5f67f8fb0a156bc17498b0b79a59639 [file] [log] [blame]
Juan Castillo11abdcd2014-10-21 11:30:42 +01001/*
Masahiro Yamadaa27c1662017-05-22 12:11:24 +09002 * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved.
Juan Castillo11abdcd2014-10-21 11:30:42 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Juan Castillo11abdcd2014-10-21 11:30:42 +01005 */
6
7#include <stdio.h>
8#include <string.h>
9#include <openssl/err.h>
10#include <openssl/x509v3.h>
Masahiro Yamadaa27c1662017-05-22 12:11:24 +090011
12#if USE_TBBR_DEFS
13#include <tbbr_oid.h>
14#else
15#include <platform_oid.h>
16#endif
17
Juan Castillo11abdcd2014-10-21 11:30:42 +010018#include "ext.h"
Juan Castilloe6d30e92015-06-12 11:27:59 +010019#include "tbbr/tbb_ext.h"
20#include "tbbr/tbb_key.h"
Juan Castillo11abdcd2014-10-21 11:30:42 +010021
Juan Castilloe6d30e92015-06-12 11:27:59 +010022/* TODO: get these values from the command line */
23#define TRUSTED_WORLD_NVCTR_VALUE 0
24#define NORMAL_WORLD_NVCTR_VALUE 0
25
26static ext_t tbb_ext[] = {
Juan Castillobe801202015-12-03 10:19:21 +000027 [TRUSTED_FW_NVCOUNTER_EXT] = {
28 .oid = TRUSTED_FW_NVCOUNTER_OID,
Juan Castillo43529982016-01-22 11:05:24 +000029 .opt = "tfw-nvctr",
30 .help_msg = "Trusted Firmware Non-Volatile counter value",
Juan Castilloe6d30e92015-06-12 11:27:59 +010031 .sn = "TrustedWorldNVCounter",
32 .ln = "Trusted World Non-Volatile counter",
33 .asn1_type = V_ASN1_INTEGER,
34 .type = EXT_TYPE_NVCOUNTER,
Juan Castillo43529982016-01-22 11:05:24 +000035 .attr.nvctr_type = NVCTR_TYPE_TFW
Juan Castillo11abdcd2014-10-21 11:30:42 +010036 },
Juan Castillobe801202015-12-03 10:19:21 +000037 [NON_TRUSTED_FW_NVCOUNTER_EXT] = {
38 .oid = NON_TRUSTED_FW_NVCOUNTER_OID,
Juan Castillo43529982016-01-22 11:05:24 +000039 .opt = "ntfw-nvctr",
40 .help_msg = "Non-Trusted Firmware Non-Volatile counter value",
Juan Castilloe6d30e92015-06-12 11:27:59 +010041 .sn = "NormalWorldNVCounter",
Juan Castillo43529982016-01-22 11:05:24 +000042 .ln = "Non-Trusted Firmware Non-Volatile counter",
Juan Castilloe6d30e92015-06-12 11:27:59 +010043 .asn1_type = V_ASN1_INTEGER,
44 .type = EXT_TYPE_NVCOUNTER,
Juan Castillo43529982016-01-22 11:05:24 +000045 .attr.nvctr_type = NVCTR_TYPE_NTFW
Juan Castillo11abdcd2014-10-21 11:30:42 +010046 },
Juan Castillobe801202015-12-03 10:19:21 +000047 [TRUSTED_BOOT_FW_HASH_EXT] = {
48 .oid = TRUSTED_BOOT_FW_HASH_OID,
49 .opt = "tb-fw",
Juan Castillo212f7382015-12-15 16:37:57 +000050 .help_msg = "Trusted Boot Firmware image file",
Juan Castillo11abdcd2014-10-21 11:30:42 +010051 .sn = "TrustedBootFirmwareHash",
Juan Castillobe801202015-12-03 10:19:21 +000052 .ln = "Trusted Boot Firmware hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +010053 .asn1_type = V_ASN1_OCTET_STRING,
54 .type = EXT_TYPE_HASH
Juan Castillo11abdcd2014-10-21 11:30:42 +010055 },
Juan Castillobe801202015-12-03 10:19:21 +000056 [TRUSTED_WORLD_PK_EXT] = {
57 .oid = TRUSTED_WORLD_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +010058 .sn = "TrustedWorldPublicKey",
59 .ln = "Trusted World Public Key",
Juan Castilloe6d30e92015-06-12 11:27:59 +010060 .asn1_type = V_ASN1_OCTET_STRING,
61 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +000062 .attr.key = TRUSTED_WORLD_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +010063 },
Juan Castillobe801202015-12-03 10:19:21 +000064 [NON_TRUSTED_WORLD_PK_EXT] = {
65 .oid = NON_TRUSTED_WORLD_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +010066 .sn = "NonTrustedWorldPublicKey",
67 .ln = "Non-Trusted World Public Key",
Juan Castilloe6d30e92015-06-12 11:27:59 +010068 .asn1_type = V_ASN1_OCTET_STRING,
69 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +000070 .attr.key = NON_TRUSTED_WORLD_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +010071 },
Juan Castillobe801202015-12-03 10:19:21 +000072 [SCP_FW_CONTENT_CERT_PK_EXT] = {
73 .oid = SCP_FW_CONTENT_CERT_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +010074 .sn = "SCPFirmwareContentCertPK",
75 .ln = "SCP Firmware content certificate public key",
Juan Castilloe6d30e92015-06-12 11:27:59 +010076 .asn1_type = V_ASN1_OCTET_STRING,
77 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +000078 .attr.key = SCP_FW_CONTENT_CERT_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +010079 },
Juan Castillobe801202015-12-03 10:19:21 +000080 [SCP_FW_HASH_EXT] = {
81 .oid = SCP_FW_HASH_OID,
82 .opt = "scp-fw",
Juan Castillo212f7382015-12-15 16:37:57 +000083 .help_msg = "SCP Firmware image file",
Juan Castillo11abdcd2014-10-21 11:30:42 +010084 .sn = "SCPFirmwareHash",
Juan Castillobe801202015-12-03 10:19:21 +000085 .ln = "SCP Firmware hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +010086 .asn1_type = V_ASN1_OCTET_STRING,
87 .type = EXT_TYPE_HASH
Juan Castillo11abdcd2014-10-21 11:30:42 +010088 },
Juan Castillobe801202015-12-03 10:19:21 +000089 [SOC_FW_CONTENT_CERT_PK_EXT] = {
90 .oid = SOC_FW_CONTENT_CERT_PK_OID,
Juan Castilloe6d30e92015-06-12 11:27:59 +010091 .sn = "SoCFirmwareContentCertPK",
92 .ln = "SoC Firmware content certificate public key",
93 .asn1_type = V_ASN1_OCTET_STRING,
94 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +000095 .attr.key = SOC_FW_CONTENT_CERT_KEY
Juan Castilloe6d30e92015-06-12 11:27:59 +010096 },
Juan Castillobe801202015-12-03 10:19:21 +000097 [SOC_AP_FW_HASH_EXT] = {
98 .oid = SOC_AP_FW_HASH_OID,
99 .opt = "soc-fw",
Juan Castillo212f7382015-12-15 16:37:57 +0000100 .help_msg = "SoC AP Firmware image file",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100101 .sn = "SoCAPFirmwareHash",
Juan Castillobe801202015-12-03 10:19:21 +0000102 .ln = "SoC AP Firmware hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100103 .asn1_type = V_ASN1_OCTET_STRING,
104 .type = EXT_TYPE_HASH
105 },
Juan Castillobe801202015-12-03 10:19:21 +0000106 [TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
107 .oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +0100108 .sn = "TrustedOSFirmwareContentCertPK",
109 .ln = "Trusted OS Firmware content certificate public key",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100110 .asn1_type = V_ASN1_OCTET_STRING,
111 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +0000112 .attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +0100113 },
Juan Castillobe801202015-12-03 10:19:21 +0000114 [TRUSTED_OS_FW_HASH_EXT] = {
115 .oid = TRUSTED_OS_FW_HASH_OID,
116 .opt = "tos-fw",
Juan Castillo212f7382015-12-15 16:37:57 +0000117 .help_msg = "Trusted OS image file",
Juan Castillo11abdcd2014-10-21 11:30:42 +0100118 .sn = "TrustedOSHash",
Juan Castillobe801202015-12-03 10:19:21 +0000119 .ln = "Trusted OS hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100120 .asn1_type = V_ASN1_OCTET_STRING,
121 .type = EXT_TYPE_HASH
Juan Castillo11abdcd2014-10-21 11:30:42 +0100122 },
Summer Qin80726782017-04-20 16:28:39 +0100123 [TRUSTED_OS_FW_EXTRA1_HASH_EXT] = {
124 .oid = TRUSTED_OS_FW_EXTRA1_HASH_OID,
125 .opt = "tos-fw-extra1",
126 .help_msg = "Trusted OS Extra1 image file",
127 .sn = "TrustedOSExtra1Hash",
128 .ln = "Trusted OS Extra1 hash (SHA256)",
129 .asn1_type = V_ASN1_OCTET_STRING,
130 .type = EXT_TYPE_HASH,
131 .optional = 1
132 },
133 [TRUSTED_OS_FW_EXTRA2_HASH_EXT] = {
134 .oid = TRUSTED_OS_FW_EXTRA2_HASH_OID,
135 .opt = "tos-fw-extra2",
136 .help_msg = "Trusted OS Extra2 image file",
137 .sn = "TrustedOSExtra2Hash",
138 .ln = "Trusted OS Extra2 hash (SHA256)",
139 .asn1_type = V_ASN1_OCTET_STRING,
140 .type = EXT_TYPE_HASH,
141 .optional = 1
142 },
Juan Castillobe801202015-12-03 10:19:21 +0000143 [NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
144 .oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +0100145 .sn = "NonTrustedFirmwareContentCertPK",
146 .ln = "Non-Trusted Firmware content certificate public key",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100147 .asn1_type = V_ASN1_OCTET_STRING,
148 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +0000149 .attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +0100150 },
Juan Castillobe801202015-12-03 10:19:21 +0000151 [NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
152 .oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
153 .opt = "nt-fw",
Juan Castillo212f7382015-12-15 16:37:57 +0000154 .help_msg = "Non-Trusted World Bootloader image file",
Juan Castillo11abdcd2014-10-21 11:30:42 +0100155 .sn = "NonTrustedWorldBootloaderHash",
Juan Castillobe801202015-12-03 10:19:21 +0000156 .ln = "Non-Trusted World hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100157 .asn1_type = V_ASN1_OCTET_STRING,
158 .type = EXT_TYPE_HASH
Yatharth Kochar5752b592015-08-21 15:30:55 +0100159 },
Juan Castillobe801202015-12-03 10:19:21 +0000160 [SCP_FWU_CFG_HASH_EXT] = {
161 .oid = SCP_FWU_CFG_HASH_OID,
162 .opt = "scp-fwu-cfg",
Juan Castillo212f7382015-12-15 16:37:57 +0000163 .help_msg = "SCP Firmware Update Config image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100164 .sn = "SCPFWUpdateConfig",
Juan Castillobe801202015-12-03 10:19:21 +0000165 .ln = "SCP Firmware Update Config hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100166 .asn1_type = V_ASN1_OCTET_STRING,
167 .type = EXT_TYPE_HASH,
168 .optional = 1
169 },
Juan Castillobe801202015-12-03 10:19:21 +0000170 [AP_FWU_CFG_HASH_EXT] = {
171 .oid = AP_FWU_CFG_HASH_OID,
172 .opt = "ap-fwu-cfg",
Juan Castillo212f7382015-12-15 16:37:57 +0000173 .help_msg = "AP Firmware Update Config image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100174 .sn = "APFWUpdateConfig",
Juan Castillobe801202015-12-03 10:19:21 +0000175 .ln = "AP Firmware Update Config hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100176 .asn1_type = V_ASN1_OCTET_STRING,
177 .type = EXT_TYPE_HASH,
178 .optional = 1
179 },
Juan Castillobe801202015-12-03 10:19:21 +0000180 [FWU_HASH_EXT] = {
181 .oid = FWU_HASH_OID,
182 .opt = "fwu",
Juan Castillo212f7382015-12-15 16:37:57 +0000183 .help_msg = "Firmware Updater image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100184 .sn = "FWUpdaterHash",
Juan Castillobe801202015-12-03 10:19:21 +0000185 .ln = "Firmware Updater hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100186 .asn1_type = V_ASN1_OCTET_STRING,
187 .type = EXT_TYPE_HASH,
188 .optional = 1
Juan Castilloe6d30e92015-06-12 11:27:59 +0100189 }
Juan Castillo11abdcd2014-10-21 11:30:42 +0100190};
Juan Castilloe6d30e92015-06-12 11:27:59 +0100191
192REGISTER_EXTENSIONS(tbb_ext);