tbb_ext.c 9.07 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2020, 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
static ext_t tbb_ext[] = {
23
24
	[TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = TRUSTED_FW_NVCOUNTER_OID,
25
26
		.opt = "tfw-nvctr",
		.help_msg = "Trusted Firmware Non-Volatile counter value",
27
28
29
30
		.sn = "TrustedWorldNVCounter",
		.ln = "Trusted World Non-Volatile counter",
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
31
		.attr.nvctr_type = NVCTR_TYPE_TFW
32
	},
33
34
	[NON_TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = NON_TRUSTED_FW_NVCOUNTER_OID,
35
36
		.opt = "ntfw-nvctr",
		.help_msg = "Non-Trusted Firmware Non-Volatile counter value",
37
		.sn = "NormalWorldNVCounter",
38
		.ln = "Non-Trusted Firmware Non-Volatile counter",
39
40
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
41
		.attr.nvctr_type = NVCTR_TYPE_NTFW
42
	},
43
44
45
	[TRUSTED_BOOT_FW_HASH_EXT] = {
		.oid = TRUSTED_BOOT_FW_HASH_OID,
		.opt = "tb-fw",
46
		.help_msg = "Trusted Boot Firmware image file",
47
		.sn = "TrustedBootFirmwareHash",
48
		.ln = "Trusted Boot Firmware hash (SHA256)",
49
50
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
51
	},
Soby Mathew's avatar
Soby Mathew committed
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
	[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,
69
70
71
72
73
74
75
76
77
78
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[FW_CONFIG_HASH_EXT] = {
		.oid = FW_CONFIG_HASH_OID,
		.opt = "fw-config",
		.help_msg = "Firmware Config file",
		.sn = "FirmwareConfigHash",
		.ln = "Firmware Config hash",
		.asn1_type = V_ASN1_OCTET_STRING,
Soby Mathew's avatar
Soby Mathew committed
79
80
81
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
82
83
	[TRUSTED_WORLD_PK_EXT] = {
		.oid = TRUSTED_WORLD_PK_OID,
84
85
		.sn = "TrustedWorldPublicKey",
		.ln = "Trusted World Public Key",
86
87
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
88
		.attr.key = TRUSTED_WORLD_KEY
89
	},
90
91
	[NON_TRUSTED_WORLD_PK_EXT] = {
		.oid = NON_TRUSTED_WORLD_PK_OID,
92
93
		.sn = "NonTrustedWorldPublicKey",
		.ln = "Non-Trusted World Public Key",
94
95
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
96
		.attr.key = NON_TRUSTED_WORLD_KEY
97
	},
98
99
	[SCP_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SCP_FW_CONTENT_CERT_PK_OID,
100
101
		.sn = "SCPFirmwareContentCertPK",
		.ln = "SCP Firmware content certificate public key",
102
103
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
104
		.attr.key = SCP_FW_CONTENT_CERT_KEY
105
	},
106
107
108
	[SCP_FW_HASH_EXT] = {
		.oid = SCP_FW_HASH_OID,
		.opt = "scp-fw",
109
		.help_msg = "SCP Firmware image file",
110
		.sn = "SCPFirmwareHash",
111
		.ln = "SCP Firmware hash (SHA256)",
112
113
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
114
	},
115
116
	[SOC_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SOC_FW_CONTENT_CERT_PK_OID,
117
118
119
120
		.sn = "SoCFirmwareContentCertPK",
		.ln = "SoC Firmware content certificate public key",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
121
		.attr.key = SOC_FW_CONTENT_CERT_KEY
122
	},
123
124
125
	[SOC_AP_FW_HASH_EXT] = {
		.oid = SOC_AP_FW_HASH_OID,
		.opt = "soc-fw",
126
		.help_msg = "SoC AP Firmware image file",
127
		.sn = "SoCAPFirmwareHash",
128
		.ln = "SoC AP Firmware hash (SHA256)",
129
130
131
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
	},
132
133
134
135
136
137
138
139
140
141
	[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
	},
142
143
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
144
145
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
146
147
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
148
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
149
	},
150
151
152
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
153
		.help_msg = "Trusted OS image file",
154
		.sn = "TrustedOSHash",
155
		.ln = "Trusted OS hash (SHA256)",
156
157
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
158
	},
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
	[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
	},
179
180
181
182
183
184
185
186
187
188
	[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
	},
189
190
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
191
192
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
193
194
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
195
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
196
	},
197
198
199
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
200
		.help_msg = "Non-Trusted World Bootloader image file",
201
		.sn = "NonTrustedWorldBootloaderHash",
202
		.ln = "Non-Trusted World hash (SHA256)",
203
204
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
205
	},
206
207
208
209
210
211
212
213
214
215
	[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
	},
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
	[SP_PKG1_HASH_EXT] = {
		.oid = SP_PKG1_HASH_OID,
		.opt = "sp-pkg1",
		.help_msg = "Secure Partition Package1 file",
		.sn = "SPPkg1Hash",
		.ln = "SP Pkg1 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG2_HASH_EXT] = {
		.oid = SP_PKG2_HASH_OID,
		.opt = "sp-pkg2",
		.help_msg = "Secure Partition Package2 file",
		.sn = "SPPkg2Hash",
		.ln = "SP Pkg2 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG3_HASH_EXT] = {
		.oid = SP_PKG3_HASH_OID,
		.opt = "sp-pkg3",
		.help_msg = "Secure Partition Package3 file",
		.sn = "SPPkg3Hash",
		.ln = "SP Pkg3 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG4_HASH_EXT] = {
		.oid = SP_PKG4_HASH_OID,
		.opt = "sp-pkg4",
		.help_msg = "Secure Partition Package4 file",
		.sn = "SPPkg4Hash",
		.ln = "SP Pkg4 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG5_HASH_EXT] = {
		.oid = SP_PKG5_HASH_OID,
		.opt = "sp-pkg5",
		.help_msg = "Secure Partition Package5 file",
		.sn = "SPPkg5Hash",
		.ln = "SP Pkg5 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG6_HASH_EXT] = {
		.oid = SP_PKG6_HASH_OID,
		.opt = "sp-pkg6",
		.help_msg = "Secure Partition Package6 file",
		.sn = "SPPkg6Hash",
		.ln = "SP Pkg6 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG7_HASH_EXT] = {
		.oid = SP_PKG7_HASH_OID,
		.opt = "sp-pkg7",
		.help_msg = "Secure Partition Package7 file",
		.sn = "SPPkg7Hash",
		.ln = "SP Pkg7 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
	[SP_PKG8_HASH_EXT] = {
		.oid = SP_PKG8_HASH_OID,
		.opt = "sp-pkg8",
		.help_msg = "Secure Partition Package8 file",
		.sn = "SPPkg8Hash",
		.ln = "SP Pkg8 hash (SHA256)",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
296
297
298
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
299
		.help_msg = "SCP Firmware Update Config image file",
300
		.sn = "SCPFWUpdateConfig",
301
		.ln = "SCP Firmware Update Config hash (SHA256)",
302
303
304
305
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
306
307
308
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
309
		.help_msg = "AP Firmware Update Config image file",
310
		.sn = "APFWUpdateConfig",
311
		.ln = "AP Firmware Update Config hash (SHA256)",
312
313
314
315
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
316
317
318
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
319
		.help_msg = "Firmware Updater image file",
320
		.sn = "FWUpdaterHash",
321
		.ln = "Firmware Updater hash (SHA256)",
322
323
324
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
325
	}
326
};
327
328

REGISTER_EXTENSIONS(tbb_ext);