]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
Update header file to match UEFI231B mantis 771, 850, 853 and 857.
[mirror_edk2.git] / SecurityPkg / Include / Guid / AuthenticatedVariableFormat.h
1 /** @file
2 The variable data structures are related to EDKII-specific
3 implementation of UEFI authenticated variables.
4 AuthenticatedVariableFormat.h defines variable data headers
5 and variable storage region headers.
6
7 Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #ifndef __AUTHENTICATED_VARIABLE_FORMAT_H__
19 #define __AUTHENTICATED_VARIABLE_FORMAT_H__
20
21 #define EFI_AUTHENTICATED_VARIABLE_GUID \
22 { 0xaaf32c78, 0x947b, 0x439a, { 0xa1, 0x80, 0x2e, 0x14, 0x4e, 0xc3, 0x77, 0x92 } }
23
24 #define EFI_SECURE_BOOT_ENABLE_DISABLE \
25 { 0xf0a30bc7, 0xaf08, 0x4556, { 0x99, 0xc4, 0x0, 0x10, 0x9, 0xc9, 0x3a, 0x44 } }
26
27
28 extern EFI_GUID gEfiAuthenticatedVariableGuid;
29 extern EFI_GUID gEfiSecureBootEnableDisableGuid;
30
31 ///
32 /// "SecureBootEnable" variable for the Secure boot feature enable/disable.
33 ///
34 #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable"
35 #define SECURE_BOOT_ENABLE 1
36 #define SECURE_BOOT_DISABLE 0
37
38 extern EFI_GUID gEfiCustomModeEnableGuid;
39
40 ///
41 /// "CustomMode" variable for two Secure Boot modes feature: "Custom" and "Standard".
42 /// Standard Secure Boot mode is the default mode as UEFI Spec's description.
43 /// Custom Secure Boot mode allows for more flexibility as specified in the following:
44 /// Can enroll or delete PK without existing PK's private key.
45 /// Can enroll or delete KEK without existing PK's private key.
46 /// Can enroll or delete signature from DB/DBX without KEK's private key.
47 ///
48 #define EFI_CUSTOM_MODE_NAME L"CustomMode"
49 #define CUSTOM_SECURE_BOOT_MODE 1
50 #define STANDARD_SECURE_BOOT_MODE 0
51
52 ///
53 /// "certdb" variable stores the signer's certificates for non PK/KEK/DB/DBX
54 /// variables with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.
55 ///
56 ///
57 #define EFI_CERT_DB_NAME L"certdb"
58
59 extern EFI_GUID gEfiCertDbGuid;
60
61 ///
62 /// Alignment of variable name and data, according to the architecture:
63 /// * For IA-32 and Intel(R) 64 architectures: 1.
64 /// * For IA-64 architecture: 8.
65 ///
66 #if defined (MDE_CPU_IPF)
67 #define ALIGNMENT 8
68 #else
69 #define ALIGNMENT 1
70 #endif
71
72 //
73 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
74 //
75 #if (ALIGNMENT == 1)
76 #define GET_PAD_SIZE(a) (0)
77 #else
78 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
79 #endif
80
81 ///
82 /// Alignment of Variable Data Header in Variable Store region.
83 ///
84 #define HEADER_ALIGNMENT 4
85 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
86
87 ///
88 /// Status of Variable Store Region.
89 ///
90 typedef enum {
91 EfiRaw,
92 EfiValid,
93 EfiInvalid,
94 EfiUnknown
95 } VARIABLE_STORE_STATUS;
96
97 #pragma pack(1)
98
99 #define VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID
100
101 ///
102 /// Variable Store Header Format and State.
103 ///
104 #define VARIABLE_STORE_FORMATTED 0x5a
105 #define VARIABLE_STORE_HEALTHY 0xfe
106
107 ///
108 /// Variable Store region header.
109 ///
110 typedef struct {
111 ///
112 /// Variable store region signature.
113 ///
114 EFI_GUID Signature;
115 ///
116 /// Size of entire variable store,
117 /// including size of variable store header but not including the size of FvHeader.
118 ///
119 UINT32 Size;
120 ///
121 /// Variable region format state.
122 ///
123 UINT8 Format;
124 ///
125 /// Variable region healthy state.
126 ///
127 UINT8 State;
128 UINT16 Reserved;
129 UINT32 Reserved1;
130 } VARIABLE_STORE_HEADER;
131
132 ///
133 /// Variable data start flag.
134 ///
135 #define VARIABLE_DATA 0x55AA
136
137 ///
138 /// Variable State flags.
139 ///
140 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
141 #define VAR_DELETED 0xfd ///< Variable is obsolete.
142 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
143 #define VAR_ADDED 0x3f ///< Variable has been completely added.
144
145 ///
146 /// Single Variable Data Header Structure.
147 ///
148 typedef struct {
149 ///
150 /// Variable Data Start Flag.
151 ///
152 UINT16 StartId;
153 ///
154 /// Variable State defined above.
155 ///
156 UINT8 State;
157 UINT8 Reserved;
158 ///
159 /// Attributes of variable defined in UEFI specification.
160 ///
161 UINT32 Attributes;
162 ///
163 /// Associated monotonic count value against replay attack.
164 ///
165 UINT64 MonotonicCount;
166 ///
167 /// Associated TimeStamp value against replay attack.
168 ///
169 EFI_TIME TimeStamp;
170 ///
171 /// Index of associated public key in database.
172 ///
173 UINT32 PubKeyIndex;
174 ///
175 /// Size of variable null-terminated Unicode string name.
176 ///
177 UINT32 NameSize;
178 ///
179 /// Size of the variable data without this header.
180 ///
181 UINT32 DataSize;
182 ///
183 /// A unique identifier for the vendor that produces and consumes this varaible.
184 ///
185 EFI_GUID VendorGuid;
186 } VARIABLE_HEADER;
187
188 #pragma pack()
189
190 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
191
192 ///
193 /// This structure contains the variable list that is put in EFI system table.
194 /// The variable driver collects all variables that were used at boot service time and produces this list.
195 /// This is an optional feature to dump all used variables in shell environment.
196 ///
197 struct _VARIABLE_INFO_ENTRY {
198 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
199 EFI_GUID VendorGuid; ///< Guid of Variable.
200 CHAR16 *Name; ///< Name of Variable.
201 UINT32 Attributes; ///< Attributes of variable defined in UEFI spec.
202 UINT32 ReadCount; ///< Number of times to read this variable.
203 UINT32 WriteCount; ///< Number of times to write this variable.
204 UINT32 DeleteCount; ///< Number of times to delete this variable.
205 UINT32 CacheCount; ///< Number of times that cache hits this variable.
206 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
207 };
208
209 #endif // __AUTHENTICATED_VARIABLE_FORMAT_H__