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