]> git.proxmox.com Git - mirror_edk2.git/blob - SecurityPkg/Include/Guid/AuthenticatedVariableFormat.h
1. Reset system when user changes secure boot state in secure boot configuration...
[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 /// This variable is used for allowing a physically present user to disable
34 /// Secure Boot via firmware setup without the possession of PKpriv.
35 ///
36 #define EFI_SECURE_BOOT_ENABLE_NAME L"SecureBootEnable"
37 #define SECURE_BOOT_ENABLE 1
38 #define SECURE_BOOT_DISABLE 0
39
40 extern EFI_GUID gEfiCustomModeEnableGuid;
41
42 ///
43 /// "CustomMode" variable for two Secure Boot modes feature: "Custom" and "Standard".
44 /// Standard Secure Boot mode is the default mode as UEFI Spec's description.
45 /// Custom Secure Boot mode allows for more flexibility as specified in the following:
46 /// Can enroll or delete PK without existing PK's private key.
47 /// Can enroll or delete KEK without existing PK's private key.
48 /// Can enroll or delete signature from DB/DBX without KEK's private key.
49 ///
50 #define EFI_CUSTOM_MODE_NAME L"CustomMode"
51 #define CUSTOM_SECURE_BOOT_MODE 1
52 #define STANDARD_SECURE_BOOT_MODE 0
53
54 ///
55 /// "certdb" variable stores the signer's certificates for non PK/KEK/DB/DBX
56 /// variables with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.
57 ///
58 ///
59 #define EFI_CERT_DB_NAME L"certdb"
60
61 extern EFI_GUID gEfiCertDbGuid;
62
63 ///
64 /// Alignment of variable name and data, according to the architecture:
65 /// * For IA-32 and Intel(R) 64 architectures: 1.
66 /// * For IA-64 architecture: 8.
67 ///
68 #if defined (MDE_CPU_IPF)
69 #define ALIGNMENT 8
70 #else
71 #define ALIGNMENT 1
72 #endif
73
74 //
75 // GET_PAD_SIZE calculates the miminal pad bytes needed to make the current pad size satisfy the alignment requirement.
76 //
77 #if (ALIGNMENT == 1)
78 #define GET_PAD_SIZE(a) (0)
79 #else
80 #define GET_PAD_SIZE(a) (((~a) + 1) & (ALIGNMENT - 1))
81 #endif
82
83 ///
84 /// Alignment of Variable Data Header in Variable Store region.
85 ///
86 #define HEADER_ALIGNMENT 4
87 #define HEADER_ALIGN(Header) (((UINTN) (Header) + HEADER_ALIGNMENT - 1) & (~(HEADER_ALIGNMENT - 1)))
88
89 ///
90 /// Status of Variable Store Region.
91 ///
92 typedef enum {
93 EfiRaw,
94 EfiValid,
95 EfiInvalid,
96 EfiUnknown
97 } VARIABLE_STORE_STATUS;
98
99 #pragma pack(1)
100
101 #define VARIABLE_STORE_SIGNATURE EFI_AUTHENTICATED_VARIABLE_GUID
102
103 ///
104 /// Variable Store Header Format and State.
105 ///
106 #define VARIABLE_STORE_FORMATTED 0x5a
107 #define VARIABLE_STORE_HEALTHY 0xfe
108
109 ///
110 /// Variable Store region header.
111 ///
112 typedef struct {
113 ///
114 /// Variable store region signature.
115 ///
116 EFI_GUID Signature;
117 ///
118 /// Size of entire variable store,
119 /// including size of variable store header but not including the size of FvHeader.
120 ///
121 UINT32 Size;
122 ///
123 /// Variable region format state.
124 ///
125 UINT8 Format;
126 ///
127 /// Variable region healthy state.
128 ///
129 UINT8 State;
130 UINT16 Reserved;
131 UINT32 Reserved1;
132 } VARIABLE_STORE_HEADER;
133
134 ///
135 /// Variable data start flag.
136 ///
137 #define VARIABLE_DATA 0x55AA
138
139 ///
140 /// Variable State flags.
141 ///
142 #define VAR_IN_DELETED_TRANSITION 0xfe ///< Variable is in obsolete transition.
143 #define VAR_DELETED 0xfd ///< Variable is obsolete.
144 #define VAR_HEADER_VALID_ONLY 0x7f ///< Variable header has been valid.
145 #define VAR_ADDED 0x3f ///< Variable has been completely added.
146
147 ///
148 /// Single Variable Data Header Structure.
149 ///
150 typedef struct {
151 ///
152 /// Variable Data Start Flag.
153 ///
154 UINT16 StartId;
155 ///
156 /// Variable State defined above.
157 ///
158 UINT8 State;
159 UINT8 Reserved;
160 ///
161 /// Attributes of variable defined in UEFI specification.
162 ///
163 UINT32 Attributes;
164 ///
165 /// Associated monotonic count value against replay attack.
166 ///
167 UINT64 MonotonicCount;
168 ///
169 /// Associated TimeStamp value against replay attack.
170 ///
171 EFI_TIME TimeStamp;
172 ///
173 /// Index of associated public key in database.
174 ///
175 UINT32 PubKeyIndex;
176 ///
177 /// Size of variable null-terminated Unicode string name.
178 ///
179 UINT32 NameSize;
180 ///
181 /// Size of the variable data without this header.
182 ///
183 UINT32 DataSize;
184 ///
185 /// A unique identifier for the vendor that produces and consumes this varaible.
186 ///
187 EFI_GUID VendorGuid;
188 } VARIABLE_HEADER;
189
190 #pragma pack()
191
192 typedef struct _VARIABLE_INFO_ENTRY VARIABLE_INFO_ENTRY;
193
194 ///
195 /// This structure contains the variable list that is put in EFI system table.
196 /// The variable driver collects all variables that were used at boot service time and produces this list.
197 /// This is an optional feature to dump all used variables in shell environment.
198 ///
199 struct _VARIABLE_INFO_ENTRY {
200 VARIABLE_INFO_ENTRY *Next; ///< Pointer to next entry.
201 EFI_GUID VendorGuid; ///< Guid of Variable.
202 CHAR16 *Name; ///< Name of Variable.
203 UINT32 Attributes; ///< Attributes of variable defined in UEFI spec.
204 UINT32 ReadCount; ///< Number of times to read this variable.
205 UINT32 WriteCount; ///< Number of times to write this variable.
206 UINT32 DeleteCount; ///< Number of times to delete this variable.
207 UINT32 CacheCount; ///< Number of times that cache hits this variable.
208 BOOLEAN Volatile; ///< TRUE if volatile, FALSE if non-volatile.
209 };
210
211 #endif // __AUTHENTICATED_VARIABLE_FORMAT_H__