]>
Commit | Line | Data |
---|---|---|
30fdf114 | 1 | /** @file\r |
f7496d71 | 2 | This includes some definitions introduced in UEFI that will be used in both PEI\r |
97fa0ee9 | 3 | and DXE phases.\r |
30fdf114 | 4 | \r |
7b6dad32 | 5 | (C) Copyright 2015 Hewlett-Packard Development Company, L.P.<BR>\r |
a16f7f47 | 6 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
30fdf114 | 7 | \r |
2e351cbe | 8 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
30fdf114 | 9 | \r |
30fdf114 LG |
10 | **/\r |
11 | \r | |
12 | #ifndef __UEFI_MULTIPHASE_H__\r | |
13 | #define __UEFI_MULTIPHASE_H__\r | |
14 | \r | |
15 | //\r | |
16 | // Enumeration of memory types introduced in UEFI.\r | |
f7496d71 | 17 | //\r |
30fdf114 LG |
18 | typedef enum {\r |
19 | EfiReservedMemoryType,\r | |
20 | EfiLoaderCode,\r | |
21 | EfiLoaderData,\r | |
22 | EfiBootServicesCode,\r | |
23 | EfiBootServicesData,\r | |
24 | EfiRuntimeServicesCode,\r | |
25 | EfiRuntimeServicesData,\r | |
26 | EfiConventionalMemory,\r | |
27 | EfiUnusableMemory,\r | |
28 | EfiACPIReclaimMemory,\r | |
29 | EfiACPIMemoryNVS,\r | |
30 | EfiMemoryMappedIO,\r | |
31 | EfiMemoryMappedIOPortSpace,\r | |
32 | EfiPalCode,\r | |
7b6dad32 | 33 | EfiPersistentMemory,\r |
30fdf114 LG |
34 | EfiMaxMemoryType\r |
35 | } EFI_MEMORY_TYPE;\r | |
36 | \r | |
37 | \r | |
38 | //\r | |
39 | // Data structure that precedes all of the standard EFI table types.\r | |
f7496d71 | 40 | //\r |
30fdf114 LG |
41 | typedef struct {\r |
42 | UINT64 Signature;\r | |
43 | UINT32 Revision;\r | |
44 | UINT32 HeaderSize;\r | |
45 | UINT32 CRC32;\r | |
46 | UINT32 Reserved;\r | |
47 | } EFI_TABLE_HEADER;\r | |
48 | \r | |
49 | //\r | |
50 | // Attributes of variable.\r | |
f7496d71 | 51 | //\r |
30fdf114 LG |
52 | #define EFI_VARIABLE_NON_VOLATILE 0x00000001\r |
53 | #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002\r | |
54 | #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004\r | |
55 | #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008\r | |
56 | \r | |
57 | //\r | |
f7496d71 | 58 | // This attribute is identified by the mnemonic 'HR'\r |
30fdf114 | 59 | // elsewhere in this specification.\r |
f7496d71 | 60 | //\r |
30fdf114 LG |
61 | #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010\r |
62 | \r | |
63 | \r | |
64 | \r | |
65 | //\r | |
66 | // _WIN_CERTIFICATE.wCertificateType\r | |
f7496d71 | 67 | //\r |
30fdf114 LG |
68 | #define WIN_CERT_TYPE_EFI_PKCS115 0x0EF0\r |
69 | #define WIN_CERT_TYPE_EFI_GUID 0x0EF1\r | |
70 | \r | |
71 | /**\r | |
f7496d71 | 72 | \r |
30fdf114 LG |
73 | The WIN_CERTIFICATE structure is part of the PE/COFF\r |
74 | specification and has the following definition:\r | |
75 | \r | |
76 | @param dwLength The length of the entire certificate,\r | |
77 | including the length of the header, in\r | |
78 | bytes.\r | |
79 | \r | |
80 | @param wRevision The revision level of the WIN_CERTIFICATE\r | |
81 | structure. The current revision level is\r | |
82 | 0x0200.\r | |
83 | \r | |
84 | @param wCertificateType The certificate type. See\r | |
85 | WIN_CERT_TYPE_xxx for the UEFI\r | |
86 | certificate types. The UEFI\r | |
87 | specification reserves the range of\r | |
88 | certificate type values from 0x0EF0\r | |
89 | to 0x0EFF.\r | |
90 | \r | |
91 | @param bCertificate The actual certificate. The format of\r | |
92 | the certificate depends on\r | |
93 | wCertificateType. The format of the UEFI\r | |
94 | certificates is defined below.\r | |
95 | \r | |
96 | \r | |
97 | **/\r | |
98 | typedef struct _WIN_CERTIFICATE {\r | |
99 | UINT32 dwLength;\r | |
100 | UINT16 wRevision;\r | |
101 | UINT16 wCertificateType;\r | |
102 | //UINT8 bCertificate[ANYSIZE_ARRAY];\r | |
103 | } WIN_CERTIFICATE;\r | |
104 | \r | |
105 | //\r | |
106 | // WIN_CERTIFICATE_UEFI_GUID.CertType\r | |
f7496d71 | 107 | //\r |
30fdf114 LG |
108 | #define EFI_CERT_TYPE_RSA2048_SHA256_GUID \\r |
109 | {0xa7717414, 0xc616, 0x4977, {0x94, 0x20, 0x84, 0x47, 0x12, 0xa7, 0x35, 0xbf } }\r | |
110 | \r | |
111 | //\r | |
112 | // WIN_CERTIFICATE_UEFI_GUID.CertData\r | |
f7496d71 | 113 | //\r |
30fdf114 | 114 | typedef struct _EFI_CERT_BLOCK_RSA_2048_SHA256 {\r |
4afd3d04 LG |
115 | EFI_GUID HashType;\r |
116 | UINT8 PublicKey[256];\r | |
117 | UINT8 Signature[256];\r | |
30fdf114 LG |
118 | } EFI_CERT_BLOCK_RSA_2048_SHA256;\r |
119 | \r | |
120 | \r | |
121 | /**\r | |
f7496d71 | 122 | \r |
30fdf114 LG |
123 | @param Hdr This is the standard WIN_CERTIFICATE header, where\r |
124 | wCertificateType is set to\r | |
4afd3d04 | 125 | WIN_CERT_TYPE_EFI_GUID.\r |
30fdf114 LG |
126 | \r |
127 | @param CertType This is the unique id which determines the\r | |
128 | format of the CertData. In this case, the\r | |
129 | value is EFI_CERT_TYPE_RSA2048_SHA256_GUID.\r | |
130 | \r | |
131 | @param CertData This is the certificate data. The format of\r | |
132 | the data is determined by the CertType. In\r | |
133 | this case the value is\r | |
134 | EFI_CERT_BLOCK_RSA_2048_SHA256.\r | |
135 | \r | |
136 | @param Information The WIN_CERTIFICATE_UEFI_GUID certificate\r | |
137 | type allows new types of certificates to\r | |
138 | be developed for driver authentication\r | |
139 | without requiring a new certificate type.\r | |
140 | The CertType defines the format of the\r | |
141 | CertData, which length is defined by the\r | |
142 | size of the certificate less the fixed\r | |
143 | size of the WIN_CERTIFICATE_UEFI_GUID\r | |
144 | structure.\r | |
145 | \r | |
146 | **/\r | |
147 | typedef struct _WIN_CERTIFICATE_UEFI_GUID {\r | |
148 | WIN_CERTIFICATE Hdr;\r | |
149 | EFI_GUID CertType;\r | |
a16f7f47 | 150 | UINT8 CertData[1];\r |
30fdf114 LG |
151 | } WIN_CERTIFICATE_UEFI_GUID;\r |
152 | \r | |
153 | \r | |
154 | /**\r | |
f7496d71 | 155 | \r |
30fdf114 LG |
156 | Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital\r |
157 | signature.\r | |
f7496d71 | 158 | \r |
30fdf114 | 159 | The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from\r |
f7496d71 LG |
160 | WIN_CERTIFICATE and encapsulate the information needed to\r |
161 | implement the RSASSA-PKCS1-v1_5 digital signature algorithm as\r | |
162 | specified in RFC2437.\r | |
163 | \r | |
30fdf114 LG |
164 | @param Hdr This is the standard WIN_CERTIFICATE header, where\r |
165 | wCertificateType is set to\r | |
166 | WIN_CERT_TYPE_UEFI_PKCS1_15.\r | |
f7496d71 | 167 | \r |
30fdf114 LG |
168 | @param HashAlgorithm This is the hashing algorithm which was\r |
169 | performed on the UEFI executable when\r | |
170 | creating the digital signature. It is\r | |
171 | one of the enumerated values pre-defined\r | |
172 | in Section 26.4.1. See\r | |
173 | EFI_HASH_ALGORITHM_x.\r | |
f7496d71 | 174 | \r |
30fdf114 LG |
175 | @param Signature This is the actual digital signature. The\r |
176 | size of the signature is the same size as\r | |
177 | the key (1024-bit key is 128 bytes) and can\r | |
178 | be determined by subtracting the length of\r | |
179 | the other parts of this header from the\r | |
180 | total length of the certificate as found in\r | |
181 | Hdr.dwLength.\r | |
182 | \r | |
183 | **/\r | |
184 | typedef struct _WIN_CERTIFICATE_EFI_PKCS1_15 {\r | |
185 | WIN_CERTIFICATE Hdr;\r | |
186 | EFI_GUID HashAlgorithm;\r | |
187 | // UINT8 Signature[ANYSIZE_ARRAY];\r | |
188 | } WIN_CERTIFICATE_EFI_PKCS1_15;\r | |
189 | \r | |
190 | \r | |
191 | /**\r | |
f7496d71 | 192 | \r |
30fdf114 LG |
193 | AuthInfo is a WIN_CERTIFICATE using the wCertificateType\r |
194 | WIN_CERTIFICATE_UEFI_GUID and the CertType\r | |
195 | EFI_CERT_TYPE_RSA2048_SHA256. If the attribute specifies\r | |
196 | authenticated access, then the Data buffer should begin with an\r | |
197 | authentication descriptor prior to the data payload and DataSize\r | |
fb0b35e0 | 198 | should reflect the data.and descriptor size. The caller\r |
30fdf114 LG |
199 | shall digest the Monotonic Count value and the associated data\r |
200 | for the variable update using the SHA-256 1-way hash algorithm.\r | |
201 | The ensuing the 32-byte digest will be signed using the private\r | |
202 | key associated w/ the public/private 2048-bit RSA key-pair. The\r | |
203 | WIN_CERTIFICATE shall be used to describe the signature of the\r | |
204 | Variable data *Data. In addition, the signature will also\r | |
205 | include the MonotonicCount value to guard against replay attacks\r | |
f7496d71 | 206 | \r |
30fdf114 LG |
207 | @param MonotonicCount Included in the signature of\r |
208 | AuthInfo.Used to ensure freshness/no\r | |
209 | replay. Incremented during each\r | |
210 | "Write" access.\r | |
f7496d71 | 211 | \r |
30fdf114 LG |
212 | @param AuthInfo Provides the authorization for the variable\r |
213 | access. It is a signature across the\r | |
214 | variable data and the Monotonic Count\r | |
215 | value. Caller uses Private key that is\r | |
216 | associated with a public key that has been\r | |
217 | provisioned via the key exchange.\r | |
218 | \r | |
219 | **/\r | |
220 | typedef struct {\r | |
221 | UINT64 MonotonicCount;\r | |
222 | WIN_CERTIFICATE_UEFI_GUID AuthInfo;\r | |
223 | } EFI_VARIABLE_AUTHENTICATION;\r | |
224 | \r | |
225 | #endif\r | |
226 | \r |