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