tbb_ext.c 6.83 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
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
69
70
71
	[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
	},
72
73
	[TRUSTED_WORLD_PK_EXT] = {
		.oid = TRUSTED_WORLD_PK_OID,
74
75
		.sn = "TrustedWorldPublicKey",
		.ln = "Trusted World Public Key",
76
77
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
78
		.attr.key = TRUSTED_WORLD_KEY
79
	},
80
81
	[NON_TRUSTED_WORLD_PK_EXT] = {
		.oid = NON_TRUSTED_WORLD_PK_OID,
82
83
		.sn = "NonTrustedWorldPublicKey",
		.ln = "Non-Trusted World Public Key",
84
85
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
86
		.attr.key = NON_TRUSTED_WORLD_KEY
87
	},
88
89
	[SCP_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SCP_FW_CONTENT_CERT_PK_OID,
90
91
		.sn = "SCPFirmwareContentCertPK",
		.ln = "SCP Firmware content certificate public key",
92
93
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
94
		.attr.key = SCP_FW_CONTENT_CERT_KEY
95
	},
96
97
98
	[SCP_FW_HASH_EXT] = {
		.oid = SCP_FW_HASH_OID,
		.opt = "scp-fw",
99
		.help_msg = "SCP Firmware image file",
100
		.sn = "SCPFirmwareHash",
101
		.ln = "SCP Firmware hash (SHA256)",
102
103
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
104
	},
105
106
	[SOC_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SOC_FW_CONTENT_CERT_PK_OID,
107
108
109
110
		.sn = "SoCFirmwareContentCertPK",
		.ln = "SoC Firmware content certificate public key",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
111
		.attr.key = SOC_FW_CONTENT_CERT_KEY
112
	},
113
114
115
	[SOC_AP_FW_HASH_EXT] = {
		.oid = SOC_AP_FW_HASH_OID,
		.opt = "soc-fw",
116
		.help_msg = "SoC AP Firmware image file",
117
		.sn = "SoCAPFirmwareHash",
118
		.ln = "SoC AP Firmware hash (SHA256)",
119
120
121
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
	},
122
123
124
125
126
127
128
129
130
131
	[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
	},
132
133
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
134
135
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
136
137
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
138
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
139
	},
140
141
142
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
143
		.help_msg = "Trusted OS image file",
144
		.sn = "TrustedOSHash",
145
		.ln = "Trusted OS hash (SHA256)",
146
147
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
148
	},
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
	[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
	},
169
170
171
172
173
174
175
176
177
178
	[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
	},
179
180
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
181
182
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
183
184
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
185
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
186
	},
187
188
189
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
190
		.help_msg = "Non-Trusted World Bootloader image file",
191
		.sn = "NonTrustedWorldBootloaderHash",
192
		.ln = "Non-Trusted World hash (SHA256)",
193
194
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
195
	},
196
197
198
199
200
201
202
203
204
205
	[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
	},
206
207
208
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
209
		.help_msg = "SCP Firmware Update Config image file",
210
		.sn = "SCPFWUpdateConfig",
211
		.ln = "SCP Firmware Update Config hash (SHA256)",
212
213
214
215
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
216
217
218
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
219
		.help_msg = "AP Firmware Update Config image file",
220
		.sn = "APFWUpdateConfig",
221
		.ln = "AP Firmware Update Config hash (SHA256)",
222
223
224
225
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
226
227
228
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
229
		.help_msg = "Firmware Updater image file",
230
		.sn = "FWUpdaterHash",
231
		.ln = "Firmware Updater hash (SHA256)",
232
233
234
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
235
	}
236
};
237
238

REGISTER_EXTENSIONS(tbb_ext);