tbb_ext.c 4.84 KB
Newer Older
1
2
3
/*
 * Copyright (c) 2015, ARM Limited and Contributors. All rights reserved.
 *
dp-arm's avatar
dp-arm committed
4
 * SPDX-License-Identifier: BSD-3-Clause
5
6
7
8
9
10
11
12
 */

#include <stdio.h>
#include <string.h>
#include <openssl/err.h>
#include <openssl/x509v3.h>
#include "ext.h"
#include "platform_oid.h"
13
14
#include "tbbr/tbb_ext.h"
#include "tbbr/tbb_key.h"
15

16
17
18
19
20
/* 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[] = {
21
22
	[TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = TRUSTED_FW_NVCOUNTER_OID,
23
24
		.opt = "tfw-nvctr",
		.help_msg = "Trusted Firmware Non-Volatile counter value",
25
26
27
28
		.sn = "TrustedWorldNVCounter",
		.ln = "Trusted World Non-Volatile counter",
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
29
		.attr.nvctr_type = NVCTR_TYPE_TFW
30
	},
31
32
	[NON_TRUSTED_FW_NVCOUNTER_EXT] = {
		.oid = NON_TRUSTED_FW_NVCOUNTER_OID,
33
34
		.opt = "ntfw-nvctr",
		.help_msg = "Non-Trusted Firmware Non-Volatile counter value",
35
		.sn = "NormalWorldNVCounter",
36
		.ln = "Non-Trusted Firmware Non-Volatile counter",
37
38
		.asn1_type = V_ASN1_INTEGER,
		.type = EXT_TYPE_NVCOUNTER,
39
		.attr.nvctr_type = NVCTR_TYPE_NTFW
40
	},
41
42
43
	[TRUSTED_BOOT_FW_HASH_EXT] = {
		.oid = TRUSTED_BOOT_FW_HASH_OID,
		.opt = "tb-fw",
44
		.help_msg = "Trusted Boot Firmware image file",
45
		.sn = "TrustedBootFirmwareHash",
46
		.ln = "Trusted Boot Firmware hash (SHA256)",
47
48
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
49
	},
50
51
	[TRUSTED_WORLD_PK_EXT] = {
		.oid = TRUSTED_WORLD_PK_OID,
52
53
		.sn = "TrustedWorldPublicKey",
		.ln = "Trusted World Public Key",
54
55
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
56
		.attr.key = TRUSTED_WORLD_KEY
57
	},
58
59
	[NON_TRUSTED_WORLD_PK_EXT] = {
		.oid = NON_TRUSTED_WORLD_PK_OID,
60
61
		.sn = "NonTrustedWorldPublicKey",
		.ln = "Non-Trusted World Public Key",
62
63
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
64
		.attr.key = NON_TRUSTED_WORLD_KEY
65
	},
66
67
	[SCP_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SCP_FW_CONTENT_CERT_PK_OID,
68
69
		.sn = "SCPFirmwareContentCertPK",
		.ln = "SCP Firmware content certificate public key",
70
71
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
72
		.attr.key = SCP_FW_CONTENT_CERT_KEY
73
	},
74
75
76
	[SCP_FW_HASH_EXT] = {
		.oid = SCP_FW_HASH_OID,
		.opt = "scp-fw",
77
		.help_msg = "SCP Firmware image file",
78
		.sn = "SCPFirmwareHash",
79
		.ln = "SCP Firmware hash (SHA256)",
80
81
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
82
	},
83
84
	[SOC_FW_CONTENT_CERT_PK_EXT] = {
		.oid = SOC_FW_CONTENT_CERT_PK_OID,
85
86
87
88
		.sn = "SoCFirmwareContentCertPK",
		.ln = "SoC Firmware content certificate public key",
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
89
		.attr.key = SOC_FW_CONTENT_CERT_KEY
90
	},
91
92
93
	[SOC_AP_FW_HASH_EXT] = {
		.oid = SOC_AP_FW_HASH_OID,
		.opt = "soc-fw",
94
		.help_msg = "SoC AP Firmware image file",
95
		.sn = "SoCAPFirmwareHash",
96
		.ln = "SoC AP Firmware hash (SHA256)",
97
98
99
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
	},
100
101
	[TRUSTED_OS_FW_CONTENT_CERT_PK_EXT] = {
		.oid = TRUSTED_OS_FW_CONTENT_CERT_PK_OID,
102
103
		.sn = "TrustedOSFirmwareContentCertPK",
		.ln = "Trusted OS Firmware content certificate public key",
104
105
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
106
		.attr.key = TRUSTED_OS_FW_CONTENT_CERT_KEY
107
	},
108
109
110
	[TRUSTED_OS_FW_HASH_EXT] = {
		.oid = TRUSTED_OS_FW_HASH_OID,
		.opt = "tos-fw",
111
		.help_msg = "Trusted OS image file",
112
		.sn = "TrustedOSHash",
113
		.ln = "Trusted OS hash (SHA256)",
114
115
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
116
	},
117
118
	[NON_TRUSTED_FW_CONTENT_CERT_PK_EXT] = {
		.oid = NON_TRUSTED_FW_CONTENT_CERT_PK_OID,
119
120
		.sn = "NonTrustedFirmwareContentCertPK",
		.ln = "Non-Trusted Firmware content certificate public key",
121
122
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_PKEY,
123
		.attr.key = NON_TRUSTED_FW_CONTENT_CERT_KEY
124
	},
125
126
127
	[NON_TRUSTED_WORLD_BOOTLOADER_HASH_EXT] = {
		.oid = NON_TRUSTED_WORLD_BOOTLOADER_HASH_OID,
		.opt = "nt-fw",
128
		.help_msg = "Non-Trusted World Bootloader image file",
129
		.sn = "NonTrustedWorldBootloaderHash",
130
		.ln = "Non-Trusted World hash (SHA256)",
131
132
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH
133
	},
134
135
136
	[SCP_FWU_CFG_HASH_EXT] = {
		.oid = SCP_FWU_CFG_HASH_OID,
		.opt = "scp-fwu-cfg",
137
		.help_msg = "SCP Firmware Update Config image file",
138
		.sn = "SCPFWUpdateConfig",
139
		.ln = "SCP Firmware Update Config hash (SHA256)",
140
141
142
143
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
144
145
146
	[AP_FWU_CFG_HASH_EXT] = {
		.oid = AP_FWU_CFG_HASH_OID,
		.opt = "ap-fwu-cfg",
147
		.help_msg = "AP Firmware Update Config image file",
148
		.sn = "APFWUpdateConfig",
149
		.ln = "AP Firmware Update Config hash (SHA256)",
150
151
152
153
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
	},
154
155
156
	[FWU_HASH_EXT] = {
		.oid = FWU_HASH_OID,
		.opt = "fwu",
157
		.help_msg = "Firmware Updater image file",
158
		.sn = "FWUpdaterHash",
159
		.ln = "Firmware Updater hash (SHA256)",
160
161
162
		.asn1_type = V_ASN1_OCTET_STRING,
		.type = EXT_TYPE_HASH,
		.optional = 1
163
	}
164
};
165
166

REGISTER_EXTENSIONS(tbb_ext);