tbb_ext.c 6.95 KB
Newer Older
1
/*
Soby Mathew's avatar
Soby Mathew committed
2
 * Copyright (c) 2015-2018, ARM Limited and Contributors. All rights reserved.
3
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
 */

#include <stdio.h>
#include <string.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
11
12
13
14
15
16
17

#if USE_TBBR_DEFS
#include <tbbr_oid.h>
#else
#include <platform_oid.h>
#endif

18
#include "ext.h"
19
20
#include "tbbr/tbb_ext.h"
#include "tbbr/tbb_key.h"
21

22
23
24
25
26
/* TODO: get these values from the command line */
#define TRUSTED_WORLD_NVCTR_VALUE	0
#define NORMAL_WORLD_NVCTR_VALUE	0

static ext_t tbb_ext[] = {
27
28
	[TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = TRUSTED_FW_NVCOUNTER_OID,
29
30
		.opt = "tfw-nvctr",
		.help_msg = "Trusted Firmware Non-Volatile counter value",
31
32
33
34
		.sn = "TrustedWorldNVCounter",
		.ln = "Trusted World Non-Volatile counter",
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
35
		.attr.nvctr_type = NVCTR_TYPE_TFW
36
	},
37
38
	[NON_TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = NON_TRUSTED_FW_NVCOUNTER_OID,
39
40
		.opt = "ntfw-nvctr",
		.help_msg = "Non-Trusted Firmware Non-Volatile counter value",
41
		.sn = "NormalWorldNVCounter",
42
		.ln = "Non-Trusted Firmware Non-Volatile counter",
43
44
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
45
		.attr.nvctr_type = NVCTR_TYPE_NTFW
46
	},
47
48
49
	[TRUSTED_BOOT_FW_HASH_EXT] = {
		.oid = TRUSTED_BOOT_FW_HASH_OID,
		.opt = "tb-fw",
50
		.help_msg = "Trusted Boot Firmware image file",
51
		.sn = "TrustedBootFirmwareHash",
52
		.ln = "Trusted Boot Firmware hash (SHA256)",
53
54
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
55
	},
Soby Mathew's avatar
Soby Mathew committed
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
	[TRUSTED_BOOT_FW_CONFIG_HASH_EXT] = {
		.oid = TRUSTED_BOOT_FW_CONFIG_HASH_OID,
		.opt = "tb-fw-config",
		.help_msg = "Trusted Boot Firmware Config file",
		.sn = "TrustedBootFirmwareConfigHash",
		.ln = "Trusted Boot Firmware Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[HW_CONFIG_HASH_EXT] = {
		.oid = HW_CONFIG_HASH_OID,
		.opt = "hw-config",
		.help_msg = "HW Config file",
		.sn = "HWConfigHash",
		.ln = "HW Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
76
77
	[TRUSTED_WORLD_PK_EXT] = {
		.oid = TRUSTED_WORLD_PK_OID,
78
79
		.sn = "TrustedWorldPublicKey",
		.ln = "Trusted World Public Key",
80
81
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
82
		.attr.key = TRUSTED_WORLD_KEY
83
	},
84
85
	[NON_TRUSTED_WORLD_PK_EXT] = {
		.oid = NON_TRUSTED_WORLD_PK_OID,
86
87
		.sn = "NonTrustedWorldPublicKey",
		.ln = "Non-Trusted World Public Key",
88
89
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
90
		.attr.key = NON_TRUSTED_WORLD_KEY
91
	},
92
93
	[SCP_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SCP_FW_CONTENT_CERT_PK_OID,
94
95
		.sn = "SCPFirmwareContentCertPK",
		.ln = "SCP Firmware content certificate public key",
96
97
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
98
		.attr.key = SCP_FW_CONTENT_CERT_KEY
99
	},
100
101
102
	[SCP_FW_HASH_EXT] = {
		.oid = SCP_FW_HASH_OID,
		.opt = "scp-fw",
103
		.help_msg = "SCP Firmware image file",
104
		.sn = "SCPFirmwareHash",
105
		.ln = "SCP Firmware hash (SHA256)",
106
107
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
108
	},
109
110
	[SOC_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SOC_FW_CONTENT_CERT_PK_OID,
111
112
113
114
		.sn = "SoCFirmwareContentCertPK",
		.ln = "SoC Firmware content certificate public key",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
115
		.attr.key = SOC_FW_CONTENT_CERT_KEY
116
	},
117
118
119
	[SOC_AP_FW_HASH_EXT] = {
		.oid = SOC_AP_FW_HASH_OID,
		.opt = "soc-fw",
120
		.help_msg = "SoC AP Firmware image file",
121
		.sn = "SoCAPFirmwareHash",
122
		.ln = "SoC AP Firmware hash (SHA256)",
123
124
125
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
	},
126
127
128
129
130
131
132
133
134
135
	[SOC_FW_CONFIG_HASH_EXT] = {
		.oid = SOC_FW_CONFIG_HASH_OID,
		.opt = "soc-fw-config",
		.help_msg = "SoC Firmware Config file",
		.sn = "SocFirmwareConfigHash",
		.ln = "SoC Firmware Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
136
137
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
138
139
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
140
141
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
142
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
143
	},
144
145
146
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
147
		.help_msg = "Trusted OS image file",
148
		.sn = "TrustedOSHash",
149
		.ln = "Trusted OS hash (SHA256)",
150
151
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
152
	},
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
	[TRUSTED_OS_FW_EXTRA1_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_EXTRA1_HASH_OID,
		.opt = "tos-fw-extra1",
		.help_msg = "Trusted OS Extra1 image file",
		.sn = "TrustedOSExtra1Hash",
		.ln = "Trusted OS Extra1 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[TRUSTED_OS_FW_EXTRA2_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_EXTRA2_HASH_OID,
		.opt = "tos-fw-extra2",
		.help_msg = "Trusted OS Extra2 image file",
		.sn = "TrustedOSExtra2Hash",
		.ln = "Trusted OS Extra2 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
173
174
175
176
177
178
179
180
181
182
	[TRUSTED_OS_FW_CONFIG_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_CONFIG_HASH_OID,
		.opt = "tos-fw-config",
		.help_msg = "Trusted OS Firmware Config file",
		.sn = "TrustedOSFirmwareConfigHash",
		.ln = "Trusted OS Firmware Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
183
184
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
185
186
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
187
188
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
189
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
190
	},
191
192
193
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
194
		.help_msg = "Non-Trusted World Bootloader image file",
195
		.sn = "NonTrustedWorldBootloaderHash",
196
		.ln = "Non-Trusted World hash (SHA256)",
197
198
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
199
	},
200
201
202
203
204
205
206
207
208
209
	[NON_TRUSTED_FW_CONFIG_HASH_EXT] = {
		.oid = NON_TRUSTED_FW_CONFIG_HASH_OID,
		.opt = "nt-fw-config",
		.help_msg = "Non Trusted OS Firmware Config file",
		.sn = "NonTrustedOSFirmwareConfigHash",
		.ln = "Non-Trusted OS Firmware Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
210
211
212
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
213
		.help_msg = "SCP Firmware Update Config image file",
214
		.sn = "SCPFWUpdateConfig",
215
		.ln = "SCP Firmware Update Config hash (SHA256)",
216
217
218
219
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
220
221
222
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
223
		.help_msg = "AP Firmware Update Config image file",
224
		.sn = "APFWUpdateConfig",
225
		.ln = "AP Firmware Update Config hash (SHA256)",
226
227
228
229
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
230
231
232
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
233
		.help_msg = "Firmware Updater image file",
234
		.sn = "FWUpdaterHash",
235
		.ln = "Firmware Updater hash (SHA256)",
236
237
238
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
239
	}
240
};
241
242

REGISTER_EXTENSIONS(tbb_ext);