tbb_ext.c 5.49 KB
Newer Older
1
/*
2
 * Copyright (c) 2015-2017, 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
	},
56
57
	[TRUSTED_WORLD_PK_EXT] = {
		.oid = TRUSTED_WORLD_PK_OID,
58
59
		.sn = "TrustedWorldPublicKey",
		.ln = "Trusted World Public Key",
60
61
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
62
		.attr.key = TRUSTED_WORLD_KEY
63
	},
64
65
	[NON_TRUSTED_WORLD_PK_EXT] = {
		.oid = NON_TRUSTED_WORLD_PK_OID,
66
67
		.sn = "NonTrustedWorldPublicKey",
		.ln = "Non-Trusted World Public Key",
68
69
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
70
		.attr.key = NON_TRUSTED_WORLD_KEY
71
	},
72
73
	[SCP_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SCP_FW_CONTENT_CERT_PK_OID,
74
75
		.sn = "SCPFirmwareContentCertPK",
		.ln = "SCP Firmware content certificate public key",
76
77
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
78
		.attr.key = SCP_FW_CONTENT_CERT_KEY
79
	},
80
81
82
	[SCP_FW_HASH_EXT] = {
		.oid = SCP_FW_HASH_OID,
		.opt = "scp-fw",
83
		.help_msg = "SCP Firmware image file",
84
		.sn = "SCPFirmwareHash",
85
		.ln = "SCP Firmware hash (SHA256)",
86
87
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
88
	},
89
90
	[SOC_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SOC_FW_CONTENT_CERT_PK_OID,
91
92
93
94
		.sn = "SoCFirmwareContentCertPK",
		.ln = "SoC Firmware content certificate public key",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
95
		.attr.key = SOC_FW_CONTENT_CERT_KEY
96
	},
97
98
99
	[SOC_AP_FW_HASH_EXT] = {
		.oid = SOC_AP_FW_HASH_OID,
		.opt = "soc-fw",
100
		.help_msg = "SoC AP Firmware image file",
101
		.sn = "SoCAPFirmwareHash",
102
		.ln = "SoC AP Firmware hash (SHA256)",
103
104
105
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
	},
106
107
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
108
109
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
110
111
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
112
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
113
	},
114
115
116
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
117
		.help_msg = "Trusted OS image file",
118
		.sn = "TrustedOSHash",
119
		.ln = "Trusted OS hash (SHA256)",
120
121
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
122
	},
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
	[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
	},
143
144
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
145
146
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
147
148
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
149
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
150
	},
151
152
153
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
154
		.help_msg = "Non-Trusted World Bootloader image file",
155
		.sn = "NonTrustedWorldBootloaderHash",
156
		.ln = "Non-Trusted World hash (SHA256)",
157
158
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
159
	},
160
161
162
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
163
		.help_msg = "SCP Firmware Update Config image file",
164
		.sn = "SCPFWUpdateConfig",
165
		.ln = "SCP Firmware Update Config hash (SHA256)",
166
167
168
169
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
170
171
172
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
173
		.help_msg = "AP Firmware Update Config image file",
174
		.sn = "APFWUpdateConfig",
175
		.ln = "AP Firmware Update Config hash (SHA256)",
176
177
178
179
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
180
181
182
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
183
		.help_msg = "Firmware Updater image file",
184
		.sn = "FWUpdaterHash",
185
		.ln = "Firmware Updater hash (SHA256)",
186
187
188
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
189
	}
190
};
191
192

REGISTER_EXTENSIONS(tbb_ext);