tbb_ext.c 6.04 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
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
128
129
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
130
131
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
132
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
133
	},
134
135
136
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
137
		.help_msg = "Trusted OS image file",
138
		.sn = "TrustedOSHash",
139
		.ln = "Trusted OS hash (SHA256)",
140
141
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
142
	},
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
	[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
	},
163
164
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
165
166
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
167
168
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
169
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
170
	},
171
172
173
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
174
		.help_msg = "Non-Trusted World Bootloader image file",
175
		.sn = "NonTrustedWorldBootloaderHash",
176
		.ln = "Non-Trusted World hash (SHA256)",
177
178
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
179
	},
180
181
182
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
183
		.help_msg = "SCP Firmware Update Config image file",
184
		.sn = "SCPFWUpdateConfig",
185
		.ln = "SCP Firmware Update Config hash (SHA256)",
186
187
188
189
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
190
191
192
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
193
		.help_msg = "AP Firmware Update Config image file",
194
		.sn = "APFWUpdateConfig",
195
		.ln = "AP Firmware Update Config hash (SHA256)",
196
197
198
199
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
200
201
202
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
203
		.help_msg = "Firmware Updater image file",
204
		.sn = "FWUpdaterHash",
205
		.ln = "Firmware Updater hash (SHA256)",
206
207
208
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
209
	}
210
};
211
212

REGISTER_EXTENSIONS(tbb_ext);