blob: d9a8ea265394f0bfc6fe821db7fdd1eff5aee96c [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 },
Juan Castillobe801202015-12-03 10:19:21 +0000123 [NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
124 .oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
Juan Castillo11abdcd2014-10-21 11:30:42 +0100125 .sn = "NonTrustedFirmwareContentCertPK",
126 .ln = "Non-Trusted Firmware content certificate public key",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100127 .asn1_type = V_ASN1_OCTET_STRING,
128 .type = EXT_TYPE_PKEY,
Juan Castillo43529982016-01-22 11:05:24 +0000129 .attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
Juan Castillo11abdcd2014-10-21 11:30:42 +0100130 },
Juan Castillobe801202015-12-03 10:19:21 +0000131 [NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
132 .oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
133 .opt = "nt-fw",
Juan Castillo212f7382015-12-15 16:37:57 +0000134 .help_msg = "Non-Trusted World Bootloader image file",
Juan Castillo11abdcd2014-10-21 11:30:42 +0100135 .sn = "NonTrustedWorldBootloaderHash",
Juan Castillobe801202015-12-03 10:19:21 +0000136 .ln = "Non-Trusted World hash (SHA256)",
Juan Castilloe6d30e92015-06-12 11:27:59 +0100137 .asn1_type = V_ASN1_OCTET_STRING,
138 .type = EXT_TYPE_HASH
Yatharth Kochar5752b592015-08-21 15:30:55 +0100139 },
Juan Castillobe801202015-12-03 10:19:21 +0000140 [SCP_FWU_CFG_HASH_EXT] = {
141 .oid = SCP_FWU_CFG_HASH_OID,
142 .opt = "scp-fwu-cfg",
Juan Castillo212f7382015-12-15 16:37:57 +0000143 .help_msg = "SCP Firmware Update Config image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100144 .sn = "SCPFWUpdateConfig",
Juan Castillobe801202015-12-03 10:19:21 +0000145 .ln = "SCP Firmware Update Config hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100146 .asn1_type = V_ASN1_OCTET_STRING,
147 .type = EXT_TYPE_HASH,
148 .optional = 1
149 },
Juan Castillobe801202015-12-03 10:19:21 +0000150 [AP_FWU_CFG_HASH_EXT] = {
151 .oid = AP_FWU_CFG_HASH_OID,
152 .opt = "ap-fwu-cfg",
Juan Castillo212f7382015-12-15 16:37:57 +0000153 .help_msg = "AP Firmware Update Config image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100154 .sn = "APFWUpdateConfig",
Juan Castillobe801202015-12-03 10:19:21 +0000155 .ln = "AP Firmware Update Config hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100156 .asn1_type = V_ASN1_OCTET_STRING,
157 .type = EXT_TYPE_HASH,
158 .optional = 1
159 },
Juan Castillobe801202015-12-03 10:19:21 +0000160 [FWU_HASH_EXT] = {
161 .oid = FWU_HASH_OID,
162 .opt = "fwu",
Juan Castillo212f7382015-12-15 16:37:57 +0000163 .help_msg = "Firmware Updater image file",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100164 .sn = "FWUpdaterHash",
Juan Castillobe801202015-12-03 10:19:21 +0000165 .ln = "Firmware Updater hash (SHA256)",
Yatharth Kochar5752b592015-08-21 15:30:55 +0100166 .asn1_type = V_ASN1_OCTET_STRING,
167 .type = EXT_TYPE_HASH,
168 .optional = 1
Juan Castilloe6d30e92015-06-12 11:27:59 +0100169 }
Juan Castillo11abdcd2014-10-21 11:30:42 +0100170};
Juan Castilloe6d30e92015-06-12 11:27:59 +0100171
172REGISTER_EXTENSIONS(tbb_ext);