blob: 1400fbfdc92b859a1b95f74b482e786c0b1072fd [file] [log] [blame]
Juan Castillo6f971622014-10-21 11:30:42 +01001/*
2 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <stdio.h>
32#include <string.h>
33#include <openssl/err.h>
34#include <openssl/x509v3.h>
35#include "ext.h"
36#include "platform_oid.h"
Juan Castillo55e291a2015-06-12 11:27:59 +010037#include "tbbr/tbb_ext.h"
38#include "tbbr/tbb_key.h"
Juan Castillo6f971622014-10-21 11:30:42 +010039
Juan Castillo55e291a2015-06-12 11:27:59 +010040/* TODO: get these values from the command line */
41#define TRUSTED_WORLD_NVCTR_VALUE 0
42#define NORMAL_WORLD_NVCTR_VALUE 0
43
44static ext_t tbb_ext[] = {
Juan Castillo516beb52015-12-03 10:19:21 +000045 [TRUSTED_FW_NVCOUNTER_EXT] = {
46 .oid = TRUSTED_FW_NVCOUNTER_OID,
Juan Castillo55e291a2015-06-12 11:27:59 +010047 .sn = "TrustedWorldNVCounter",
48 .ln = "Trusted World Non-Volatile counter",
49 .asn1_type = V_ASN1_INTEGER,
50 .type = EXT_TYPE_NVCOUNTER,
51 .data.nvcounter = TRUSTED_WORLD_NVCTR_VALUE
Juan Castillo6f971622014-10-21 11:30:42 +010052 },
Juan Castillo516beb52015-12-03 10:19:21 +000053 [NON_TRUSTED_FW_NVCOUNTER_EXT] = {
54 .oid = NON_TRUSTED_FW_NVCOUNTER_OID,
Juan Castillo55e291a2015-06-12 11:27:59 +010055 .sn = "NormalWorldNVCounter",
56 .ln = "Normal World Non-Volatile counter",
57 .asn1_type = V_ASN1_INTEGER,
58 .type = EXT_TYPE_NVCOUNTER,
59 .data.nvcounter = NORMAL_WORLD_NVCTR_VALUE
Juan Castillo6f971622014-10-21 11:30:42 +010060 },
Juan Castillo516beb52015-12-03 10:19:21 +000061 [TRUSTED_BOOT_FW_HASH_EXT] = {
62 .oid = TRUSTED_BOOT_FW_HASH_OID,
63 .opt = "tb-fw",
Juan Castillo6f971622014-10-21 11:30:42 +010064 .sn = "TrustedBootFirmwareHash",
Juan Castillo516beb52015-12-03 10:19:21 +000065 .ln = "Trusted Boot Firmware hash (SHA256)",
Juan Castillo55e291a2015-06-12 11:27:59 +010066 .asn1_type = V_ASN1_OCTET_STRING,
67 .type = EXT_TYPE_HASH
Juan Castillo6f971622014-10-21 11:30:42 +010068 },
Juan Castillo516beb52015-12-03 10:19:21 +000069 [TRUSTED_WORLD_PK_EXT] = {
70 .oid = TRUSTED_WORLD_PK_OID,
Juan Castillo6f971622014-10-21 11:30:42 +010071 .sn = "TrustedWorldPublicKey",
72 .ln = "Trusted World Public Key",
Juan Castillo55e291a2015-06-12 11:27:59 +010073 .asn1_type = V_ASN1_OCTET_STRING,
74 .type = EXT_TYPE_PKEY,
75 .data.key = TRUSTED_WORLD_KEY
Juan Castillo6f971622014-10-21 11:30:42 +010076 },
Juan Castillo516beb52015-12-03 10:19:21 +000077 [NON_TRUSTED_WORLD_PK_EXT] = {
78 .oid = NON_TRUSTED_WORLD_PK_OID,
Juan Castillo6f971622014-10-21 11:30:42 +010079 .sn = "NonTrustedWorldPublicKey",
80 .ln = "Non-Trusted World Public Key",
Juan Castillo55e291a2015-06-12 11:27:59 +010081 .asn1_type = V_ASN1_OCTET_STRING,
82 .type = EXT_TYPE_PKEY,
83 .data.key = NON_TRUSTED_WORLD_KEY
Juan Castillo6f971622014-10-21 11:30:42 +010084 },
Juan Castillo516beb52015-12-03 10:19:21 +000085 [SCP_FW_CONTENT_CERT_PK_EXT] = {
86 .oid = SCP_FW_CONTENT_CERT_PK_OID,
Juan Castillo6f971622014-10-21 11:30:42 +010087 .sn = "SCPFirmwareContentCertPK",
88 .ln = "SCP Firmware content certificate public key",
Juan Castillo55e291a2015-06-12 11:27:59 +010089 .asn1_type = V_ASN1_OCTET_STRING,
90 .type = EXT_TYPE_PKEY,
Juan Castillo516beb52015-12-03 10:19:21 +000091 .data.key = SCP_FW_CONTENT_CERT_KEY
Juan Castillo6f971622014-10-21 11:30:42 +010092 },
Juan Castillo516beb52015-12-03 10:19:21 +000093 [SCP_FW_HASH_EXT] = {
94 .oid = SCP_FW_HASH_OID,
95 .opt = "scp-fw",
Juan Castillo6f971622014-10-21 11:30:42 +010096 .sn = "SCPFirmwareHash",
Juan Castillo516beb52015-12-03 10:19:21 +000097 .ln = "SCP Firmware hash (SHA256)",
Juan Castillo55e291a2015-06-12 11:27:59 +010098 .asn1_type = V_ASN1_OCTET_STRING,
99 .type = EXT_TYPE_HASH
Juan Castillo6f971622014-10-21 11:30:42 +0100100 },
Juan Castillo516beb52015-12-03 10:19:21 +0000101 [SOC_FW_CONTENT_CERT_PK_EXT] = {
102 .oid = SOC_FW_CONTENT_CERT_PK_OID,
Juan Castillo55e291a2015-06-12 11:27:59 +0100103 .sn = "SoCFirmwareContentCertPK",
104 .ln = "SoC Firmware content certificate public key",
105 .asn1_type = V_ASN1_OCTET_STRING,
106 .type = EXT_TYPE_PKEY,
Juan Castillo516beb52015-12-03 10:19:21 +0000107 .data.key = SOC_FW_CONTENT_CERT_KEY
Juan Castillo55e291a2015-06-12 11:27:59 +0100108 },
Juan Castillo516beb52015-12-03 10:19:21 +0000109 [SOC_AP_FW_HASH_EXT] = {
110 .oid = SOC_AP_FW_HASH_OID,
111 .opt = "soc-fw",
Juan Castillo55e291a2015-06-12 11:27:59 +0100112 .sn = "SoCAPFirmwareHash",
Juan Castillo516beb52015-12-03 10:19:21 +0000113 .ln = "SoC AP Firmware hash (SHA256)",
Juan Castillo55e291a2015-06-12 11:27:59 +0100114 .asn1_type = V_ASN1_OCTET_STRING,
115 .type = EXT_TYPE_HASH
116 },
Juan Castillo516beb52015-12-03 10:19:21 +0000117 [TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
118 .oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
Juan Castillo6f971622014-10-21 11:30:42 +0100119 .sn = "TrustedOSFirmwareContentCertPK",
120 .ln = "Trusted OS Firmware content certificate public key",
Juan Castillo55e291a2015-06-12 11:27:59 +0100121 .asn1_type = V_ASN1_OCTET_STRING,
122 .type = EXT_TYPE_PKEY,
Juan Castillo516beb52015-12-03 10:19:21 +0000123 .data.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
Juan Castillo6f971622014-10-21 11:30:42 +0100124 },
Juan Castillo516beb52015-12-03 10:19:21 +0000125 [TRUSTED_OS_FW_HASH_EXT] = {
126 .oid = TRUSTED_OS_FW_HASH_OID,
127 .opt = "tos-fw",
Juan Castillo6f971622014-10-21 11:30:42 +0100128 .sn = "TrustedOSHash",
Juan Castillo516beb52015-12-03 10:19:21 +0000129 .ln = "Trusted OS hash (SHA256)",
Juan Castillo55e291a2015-06-12 11:27:59 +0100130 .asn1_type = V_ASN1_OCTET_STRING,
131 .type = EXT_TYPE_HASH
Juan Castillo6f971622014-10-21 11:30:42 +0100132 },
Juan Castillo516beb52015-12-03 10:19:21 +0000133 [NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
134 .oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
Juan Castillo6f971622014-10-21 11:30:42 +0100135 .sn = "NonTrustedFirmwareContentCertPK",
136 .ln = "Non-Trusted Firmware content certificate public key",
Juan Castillo55e291a2015-06-12 11:27:59 +0100137 .asn1_type = V_ASN1_OCTET_STRING,
138 .type = EXT_TYPE_PKEY,
Juan Castillo516beb52015-12-03 10:19:21 +0000139 .data.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
Juan Castillo6f971622014-10-21 11:30:42 +0100140 },
Juan Castillo516beb52015-12-03 10:19:21 +0000141 [NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
142 .oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
143 .opt = "nt-fw",
Juan Castillo6f971622014-10-21 11:30:42 +0100144 .sn = "NonTrustedWorldBootloaderHash",
Juan Castillo516beb52015-12-03 10:19:21 +0000145 .ln = "Non-Trusted World hash (SHA256)",
Juan Castillo55e291a2015-06-12 11:27:59 +0100146 .asn1_type = V_ASN1_OCTET_STRING,
147 .type = EXT_TYPE_HASH
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100148 },
Juan Castillo516beb52015-12-03 10:19:21 +0000149 [SCP_FWU_CFG_HASH_EXT] = {
150 .oid = SCP_FWU_CFG_HASH_OID,
151 .opt = "scp-fwu-cfg",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100152 .sn = "SCPFWUpdateConfig",
Juan Castillo516beb52015-12-03 10:19:21 +0000153 .ln = "SCP Firmware Update Config hash (SHA256)",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100154 .asn1_type = V_ASN1_OCTET_STRING,
155 .type = EXT_TYPE_HASH,
156 .optional = 1
157 },
Juan Castillo516beb52015-12-03 10:19:21 +0000158 [AP_FWU_CFG_HASH_EXT] = {
159 .oid = AP_FWU_CFG_HASH_OID,
160 .opt = "ap-fwu-cfg",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100161 .sn = "APFWUpdateConfig",
Juan Castillo516beb52015-12-03 10:19:21 +0000162 .ln = "AP Firmware Update Config hash (SHA256)",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100163 .asn1_type = V_ASN1_OCTET_STRING,
164 .type = EXT_TYPE_HASH,
165 .optional = 1
166 },
Juan Castillo516beb52015-12-03 10:19:21 +0000167 [FWU_HASH_EXT] = {
168 .oid = FWU_HASH_OID,
169 .opt = "fwu",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100170 .sn = "FWUpdaterHash",
Juan Castillo516beb52015-12-03 10:19:21 +0000171 .ln = "Firmware Updater hash (SHA256)",
Yatharth Kocharcebe1f22015-08-21 15:30:55 +0100172 .asn1_type = V_ASN1_OCTET_STRING,
173 .type = EXT_TYPE_HASH,
174 .optional = 1
Juan Castillo55e291a2015-06-12 11:27:59 +0100175 }
Juan Castillo6f971622014-10-21 11:30:42 +0100176};
Juan Castillo55e291a2015-06-12 11:27:59 +0100177
178REGISTER_EXTENSIONS(tbb_ext);