1 /*
2  * Copyright 2021 NXP
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <stdio.h>
8 #include <string.h>
9 #include <openssl/err.h>
10 #include <openssl/x509v3.h>
11 
12 #if USE_TBBR_DEFS
13 #include <tbbr_oid.h>
14 #else
15 #include <platform_oid.h>
16 #endif
17 
18 #include "ext.h"
19 #include "tbbr/tbb_ext.h"
20 #include "tbbr/tbb_key.h"
21 
22 #include <pdef_tbb_ext.h>
23 #include <pdef_tbb_key.h>
24 
25 static ext_t pdef_tbb_ext[] = {
26 	[DDR_FW_CONTENT_CERT_PK_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
27 		.oid = DDR_FW_CONTENT_CERT_PK_OID,
28 		.sn = "DDR FirmwareContentCertPK",
29 		.ln = "DDR Firmware content certificate public key",
30 		.asn1_type = V_ASN1_OCTET_STRING,
31 		.type = EXT_TYPE_PKEY,
32 		.attr.key = DDR_FW_CONTENT_KEY
33 	},
34 	[DDR_IMEM_UDIMM_1D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
35 		.oid = DDR_IMEM_UDIMM_1D_HASH_OID,
36 		.opt = "ddr-immem-udimm-1d",
37 		.help_msg = "DDR Firmware IMEM UDIMM 1D image file",
38 		.sn = "DDR UDIMM IMEM 1D FirmwareHash",
39 		.ln = "DDR UDIMM IMEM 1D Firmware hash (SHA256)",
40 		.asn1_type = V_ASN1_OCTET_STRING,
41 		.type = EXT_TYPE_HASH
42 	},
43 	[DDR_IMEM_UDIMM_2D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
44 		.oid = DDR_IMEM_UDIMM_2D_HASH_OID,
45 		.opt = "ddr-immem-udimm-2d",
46 		.help_msg = "DDR Firmware IMEM UDIMM 2D image file",
47 		.sn = "DDR UDIMM IMEM 2D FirmwareHash",
48 		.ln = "DDR UDIMM IMEM 2D Firmware hash (SHA256)",
49 		.asn1_type = V_ASN1_OCTET_STRING,
50 		.type = EXT_TYPE_HASH
51 	},
52 	[DDR_DMEM_UDIMM_1D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
53 		.oid = DDR_DMEM_UDIMM_1D_HASH_OID,
54 		.opt = "ddr-dmmem-udimm-1d",
55 		.help_msg = "DDR Firmware DMEM UDIMM 1D image file",
56 		.sn = "DDR UDIMM DMEM 1D FirmwareHash",
57 		.ln = "DDR UDIMM DMEM 1D Firmware hash (SHA256)",
58 		.asn1_type = V_ASN1_OCTET_STRING,
59 		.type = EXT_TYPE_HASH
60 	},
61 	[DDR_DMEM_UDIMM_2D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
62 		.oid = DDR_DMEM_UDIMM_2D_HASH_OID,
63 		.opt = "ddr-dmmem-udimm-2d",
64 		.help_msg = "DDR Firmware DMEM UDIMM 2D image file",
65 		.sn = "DDR UDIMM DMEM 2D FirmwareHash",
66 		.ln = "DDR UDIMM DMEM 2D Firmware hash (SHA256)",
67 		.asn1_type = V_ASN1_OCTET_STRING,
68 		.type = EXT_TYPE_HASH
69 	},
70 	[DDR_IMEM_RDIMM_1D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
71 		.oid = DDR_IMEM_RDIMM_1D_HASH_OID,
72 		.opt = "ddr-immem-rdimm-1d",
73 		.help_msg = "DDR Firmware IMEM RDIMM 1D image file",
74 		.sn = "DDR RDIMM IMEM 1D FirmwareHash",
75 		.ln = "DDR RDIMM IMEM 1D Firmware hash (SHA256)",
76 		.asn1_type = V_ASN1_OCTET_STRING,
77 		.type = EXT_TYPE_HASH
78 	},
79 	[DDR_IMEM_RDIMM_2D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
80 		.oid = DDR_IMEM_RDIMM_2D_HASH_OID,
81 		.opt = "ddr-immem-rdimm-2d",
82 		.help_msg = "DDR Firmware IMEM RDIMM 2D image file",
83 		.sn = "DDR RDIMM IMEM 2D FirmwareHash",
84 		.ln = "DDR RDIMM IMEM 2D Firmware hash (SHA256)",
85 		.asn1_type = V_ASN1_OCTET_STRING,
86 		.type = EXT_TYPE_HASH
87 	},
88 	[DDR_DMEM_RDIMM_1D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
89 		.oid = DDR_DMEM_RDIMM_1D_HASH_OID,
90 		.opt = "ddr-dmmem-rdimm-1d",
91 		.help_msg = "DDR Firmware DMEM RDIMM 1D image file",
92 		.sn = "DDR RDIMM DMEM 1D FirmwareHash",
93 		.ln = "DDR RDIMM DMEM 1D Firmware hash (SHA256)",
94 		.asn1_type = V_ASN1_OCTET_STRING,
95 		.type = EXT_TYPE_HASH
96 	},
97 	[DDR_DMEM_RDIMM_2D_HASH_EXT - DDR_FW_CONTENT_CERT_PK_EXT] = {
98 		.oid = DDR_DMEM_RDIMM_2D_HASH_OID,
99 		.opt = "ddr-dmmem-rdimm-2d",
100 		.help_msg = "DDR Firmware DMEM RDIMM 2D image file",
101 		.sn = "DDR RDIMM DMEM 2D FirmwareHash",
102 		.ln = "DDR RDIMM DMEM 2D Firmware hash (SHA256)",
103 		.asn1_type = V_ASN1_OCTET_STRING,
104 		.type = EXT_TYPE_HASH
105 	}
106 };
107 
108 PLAT_REGISTER_EXTENSIONS(pdef_tbb_ext);
109