tbb_ext.c 4.9 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
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
125
126
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
127
128
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
129
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
130
	},
131
132
133
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
134
		.help_msg = "Non-Trusted World Bootloader image file",
135
		.sn = "NonTrustedWorldBootloaderHash",
136
		.ln = "Non-Trusted World hash (SHA256)",
137
138
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
139
	},
140
141
142
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
143
		.help_msg = "SCP Firmware Update Config image file",
144
		.sn = "SCPFWUpdateConfig",
145
		.ln = "SCP Firmware Update Config hash (SHA256)",
146
147
148
149
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
150
151
152
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
153
		.help_msg = "AP Firmware Update Config image file",
154
		.sn = "APFWUpdateConfig",
155
		.ln = "AP Firmware Update Config hash (SHA256)",
156
157
158
159
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
160
161
162
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
163
		.help_msg = "Firmware Updater image file",
164
		.sn = "FWUpdaterHash",
165
		.ln = "Firmware Updater hash (SHA256)",
166
167
168
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
169
	}
170
};
171
172

REGISTER_EXTENSIONS(tbb_ext);