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 | |
0b3cac32 | 18 | #include <ProcessorBind.h>\r |
19 | \r | |
8b13229b | 20 | ///\r |
21 | /// Enumeration of memory types introduced in UEFI.\r | |
22 | /// \r | |
959ccb23 | 23 | typedef enum {\r |
00edb218 A |
24 | EfiReservedMemoryType,\r |
25 | EfiLoaderCode,\r | |
26 | EfiLoaderData,\r | |
27 | EfiBootServicesCode,\r | |
28 | EfiBootServicesData,\r | |
29 | EfiRuntimeServicesCode,\r | |
30 | EfiRuntimeServicesData,\r | |
31 | EfiConventionalMemory,\r | |
32 | EfiUnusableMemory,\r | |
33 | EfiACPIReclaimMemory,\r | |
34 | EfiACPIMemoryNVS,\r | |
35 | EfiMemoryMappedIO,\r | |
36 | EfiMemoryMappedIOPortSpace,\r | |
37 | EfiPalCode,\r | |
38 | EfiMaxMemoryType\r | |
959ccb23 | 39 | } EFI_MEMORY_TYPE;\r |
40 | \r | |
41 | \r | |
8b13229b | 42 | ///\r |
43 | /// Data structure that precedes all of the standard EFI table types.\r | |
44 | /// \r | |
959ccb23 | 45 | typedef struct {\r |
00edb218 A |
46 | UINT64 Signature;\r |
47 | UINT32 Revision;\r | |
48 | UINT32 HeaderSize;\r | |
49 | UINT32 CRC32;\r | |
50 | UINT32 Reserved;\r | |
959ccb23 | 51 | } EFI_TABLE_HEADER;\r |
52 | \r | |
8b13229b | 53 | ///\r |
54 | /// Attributes of variable.\r | |
55 | /// \r | |
00edb218 A |
56 | #define EFI_VARIABLE_NON_VOLATILE 0x00000001\r |
57 | #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002\r | |
58 | #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004\r | |
59 | #define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008\r | |
959ccb23 | 60 | \r |
8b13229b | 61 | ///\r |
62 | /// This attribute is identified by the mnemonic 'HR' \r | |
63 | /// elsewhere in this specification.\r | |
64 | /// \r | |
00edb218 | 65 | #define EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS 0x00000010\r |
959ccb23 | 66 | \r |
959ccb23 | 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 | |
fb5148a0 | 107 | ///\r |
108 | /// WIN_CERTIFICATE_UEFI_GUID.CertType\r | |
109 | /// \r | |
959ccb23 | 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 |
fb5148a0 | 113 | ///\r |
114 | /// WIN_CERTIFICATE_UEFI_GUID.CertData\r | |
115 | /// \r | |
959ccb23 | 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 | |
959ccb23 | 138 | **/\r |
139 | typedef struct _WIN_CERTIFICATE_UEFI_GUID {\r | |
00edb218 A |
140 | WIN_CERTIFICATE Hdr;\r |
141 | EFI_GUID CertType;\r | |
142 | // UINT8 CertData[ANYSIZE_ARRAY];\r | |
959ccb23 | 143 | } WIN_CERTIFICATE_UEFI_GUID;\r |
144 | \r | |
145 | \r | |
959ccb23 | 146 | /**\r |
147 | \r | |
148 | Certificate which encapsulates the RSASSA_PKCS1-v1_5 digital\r | |
149 | signature.\r | |
150 | \r | |
151 | The WIN_CERTIFICATE_UEFI_PKCS1_15 structure is derived from\r | |
00edb218 A |
152 | WIN_CERTIFICATE and encapsulate the information needed to \r |
153 | implement the RSASSA-PKCS1-v1_5 digital signature algorithm as \r | |
154 | specified in RFC2437. \r | |
959ccb23 | 155 | \r |
156 | @param Hdr This is the standard WIN_CERTIFICATE header, where\r | |
157 | wCertificateType is set to\r | |
158 | WIN_CERT_TYPE_UEFI_PKCS1_15.\r | |
159 | \r | |
160 | @param HashAlgorithm This is the hashing algorithm which was\r | |
161 | performed on the UEFI executable when\r | |
162 | creating the digital signature. It is\r | |
163 | one of the enumerated values pre-defined\r | |
164 | in Section 26.4.1. See\r | |
165 | EFI_HASH_ALGORITHM_x.\r | |
166 | \r | |
00edb218 | 167 | @param Signature This is the actual digital signature. The\r |
959ccb23 | 168 | size of the signature is the same size as\r |
169 | the key (1024-bit key is 128 bytes) and can\r | |
170 | be determined by subtracting the length of\r | |
171 | the other parts of this header from the\r | |
172 | total length of the certificate as found in\r | |
173 | Hdr.dwLength.\r | |
174 | \r | |
175 | **/\r | |
176 | typedef struct _WIN_CERTIFICATE_EFI_PKCS1_15 {\r | |
00edb218 A |
177 | WIN_CERTIFICATE Hdr;\r |
178 | EFI_GUID HashAlgorithm;\r | |
179 | // UINT8 Signature[ANYSIZE_ARRAY];\r | |
959ccb23 | 180 | } WIN_CERTIFICATE_EFI_PKCS1_15;\r |
181 | \r | |
182 | \r | |
183 | /**\r | |
184 | \r | |
00edb218 A |
185 | AuthInfo is a WIN_CERTIFICATE using the wCertificateType\r |
186 | WIN_CERTIFICATE_UEFI_GUID and the CertType\r | |
187 | EFI_CERT_TYPE_RSA2048_SHA256. If the attribute specifies\r | |
188 | authenticated access, then the Data buffer should begin with an\r | |
189 | authentication descriptor prior to the data payload and DataSize\r | |
190 | should reflect the the data.and descriptor size. The caller\r | |
191 | shall digest the Monotonic Count value and the associated data\r | |
192 | for the variable update using the SHA-256 1-way hash algorithm.\r | |
193 | The ensuing the 32-byte digest will be signed using the private\r | |
194 | key associated w/ the public/private 2048-bit RSA key-pair. The\r | |
195 | WIN_CERTIFICATE shall be used to describe the signature of the\r | |
196 | Variable data *Data. In addition, the signature will also\r | |
959ccb23 | 197 | include the MonotonicCount value to guard against replay attacks\r |
198 | \r | |
00edb218 | 199 | @param MonotonicCount Included in the signature of\r |
959ccb23 | 200 | AuthInfo.Used to ensure freshness/no\r |
201 | replay. Incremented during each\r | |
202 | "Write" access.\r | |
203 | \r | |
00edb218 | 204 | @param AuthInfo Provides the authorization for the variable\r |
959ccb23 | 205 | access. It is a signature across the\r |
206 | variable data and the Monotonic Count\r | |
207 | value. Caller uses Private key that is\r | |
208 | associated with a public key that has been\r | |
209 | provisioned via the key exchange.\r | |
210 | \r | |
211 | **/\r | |
212 | typedef struct {\r | |
00edb218 A |
213 | UINT64 MonotonicCount;\r |
214 | WIN_CERTIFICATE_UEFI_GUID AuthInfo;\r | |
959ccb23 | 215 | } EFI_VARIABLE_AUTHENTICATION;\r |
216 | \r | |
217 | #endif\r | |
218 | \r |