]>
Commit | Line | Data |
---|---|---|
0c18794e | 1 | /** @file\r |
2 | The internal header file includes the common header files, defines\r | |
3 | internal structure and functions used by AuthService module.\r | |
4 | \r | |
5 | Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r | |
2d3fb919 | 6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
0c18794e | 9 | http://opensource.org/licenses/bsd-license.php\r |
10 | \r | |
2d3fb919 | 11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
0c18794e | 12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #ifndef _AUTHSERVICE_H_\r | |
17 | #define _AUTHSERVICE_H_\r | |
18 | \r | |
19 | #define EFI_CERT_TYPE_RSA2048_SHA256_SIZE 256\r | |
20 | #define EFI_CERT_TYPE_RSA2048_SIZE 256\r | |
21 | \r | |
22 | ///\r | |
2d3fb919 | 23 | /// Size of AuthInfo prior to the data payload.\r |
0c18794e | 24 | ///\r |
2d3fb919 | 25 | #define AUTHINFO_SIZE ((OFFSET_OF (EFI_VARIABLE_AUTHENTICATION, AuthInfo)) + \\r |
26 | (OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)) + \\r | |
27 | sizeof (EFI_CERT_BLOCK_RSA_2048_SHA256))\r | |
28 | \r | |
29 | #define AUTHINFO2_SIZE(VarAuth2) ((OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo)) + \\r | |
30 | (UINTN) ((EFI_VARIABLE_AUTHENTICATION_2 *) (VarAuth2))->AuthInfo.Hdr.dwLength)\r | |
31 | \r | |
32 | #define OFFSET_OF_AUTHINFO2_CERT_DATA ((OFFSET_OF (EFI_VARIABLE_AUTHENTICATION_2, AuthInfo)) + \\r | |
33 | (OFFSET_OF (WIN_CERTIFICATE_UEFI_GUID, CertData)))\r | |
0c18794e | 34 | \r |
35 | ///\r | |
36 | /// "AuthVarKeyDatabase" variable for the Public Key store.\r | |
37 | ///\r | |
38 | #define AUTHVAR_KEYDB_NAME L"AuthVarKeyDatabase"\r | |
39 | #define AUTHVAR_KEYDB_NAME_SIZE 38\r | |
40 | \r | |
41 | ///\r | |
42 | /// Max size of public key database, restricted by max individal EFI varible size, exclude variable header and name size.\r | |
43 | ///\r | |
44 | #define MAX_KEYDB_SIZE (FixedPcdGet32 (PcdMaxVariableSize) - sizeof (VARIABLE_HEADER) - AUTHVAR_KEYDB_NAME_SIZE)\r | |
45 | #define MAX_KEY_NUM (MAX_KEYDB_SIZE / EFI_CERT_TYPE_RSA2048_SIZE)\r | |
46 | \r | |
47 | ///\r | |
48 | /// Item number of support signature types.\r | |
49 | ///\r | |
50 | #define SIGSUPPORT_NUM 2\r | |
51 | \r | |
52 | \r | |
53 | /**\r | |
54 | Process variable with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS/EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set.\r | |
55 | \r | |
56 | @param[in] VariableName Name of Variable to be found.\r | |
57 | @param[in] VendorGuid Variable vendor GUID.\r | |
58 | \r | |
59 | @param[in] Data Data pointer.\r | |
60 | @param[in] DataSize Size of Data found. If size is less than the\r | |
61 | data, this value contains the required size.\r | |
62 | @param[in] Variable The variable information which is used to keep track of variable usage.\r | |
63 | @param[in] Attributes Attribute value of the variable.\r | |
64 | \r | |
65 | @return EFI_INVALID_PARAMETER Invalid parameter\r | |
66 | @return EFI_WRITE_PROTECTED Variable is write-protected and needs authentication with\r | |
67 | EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS set.\r | |
68 | @return EFI_SECURITY_VIOLATION The variable is with EFI_VARIABLE_AUTHENTICATED_WRITE_ACCESS\r | |
2d3fb919 | 69 | set, but the AuthInfo does NOT pass the validation\r |
70 | check carried out by the firmware.\r | |
0c18794e | 71 | @return EFI_SUCCESS Variable is not write-protected, or passed validation successfully.\r |
72 | \r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | ProcessVariable (\r | |
76 | IN CHAR16 *VariableName,\r | |
77 | IN EFI_GUID *VendorGuid,\r | |
78 | IN VOID *Data,\r | |
79 | IN UINTN DataSize,\r | |
80 | IN VARIABLE_POINTER_TRACK *Variable,\r | |
81 | IN UINT32 Attributes\r | |
82 | );\r | |
83 | \r | |
2d3fb919 | 84 | /**\r |
85 | Update platform mode.\r | |
86 | \r | |
87 | @param[in] Mode SETUP_MODE or USER_MODE.\r | |
88 | \r | |
89 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
90 | @return EFI_SUCCESS Update platform mode successfully.\r | |
91 | \r | |
92 | **/\r | |
93 | EFI_STATUS\r | |
94 | UpdatePlatformMode (\r | |
95 | IN UINT32 Mode\r | |
96 | );\r | |
97 | \r | |
0c18794e | 98 | /**\r |
99 | Initializes for authenticated varibale service.\r | |
100 | \r | |
101 | @retval EFI_SUCCESS Function successfully executed.\r | |
102 | @retval EFI_OUT_OF_RESOURCES Fail to allocate enough memory resource.\r | |
103 | \r | |
104 | **/\r | |
105 | EFI_STATUS\r | |
106 | AutenticatedVariableServiceInitialize (\r | |
107 | VOID\r | |
108 | );\r | |
109 | \r | |
110 | /**\r | |
111 | Initializes for cryptlib service before use, include register algrithm and allocate scratch.\r | |
112 | \r | |
113 | **/\r | |
114 | VOID\r | |
115 | CryptLibraryInitialize (\r | |
116 | VOID\r | |
117 | );\r | |
118 | \r | |
119 | /**\r | |
120 | Process variable with platform key for verification.\r | |
121 | \r | |
122 | @param[in] VariableName Name of Variable to be found.\r | |
123 | @param[in] VendorGuid Variable vendor GUID.\r | |
124 | @param[in] Data Data pointer.\r | |
125 | @param[in] DataSize Size of Data found. If size is less than the\r | |
126 | data, this value contains the required size.\r | |
127 | @param[in] Variable The variable information which is used to keep track of variable usage.\r | |
128 | @param[in] Attributes Attribute value of the variable.\r | |
129 | @param[in] IsPk Indicate whether it is to process pk.\r | |
130 | \r | |
131 | @return EFI_INVALID_PARAMETER Invalid parameter\r | |
2d3fb919 | 132 | @return EFI_SECURITY_VIOLATION The variable does NOT pass the validation\r |
133 | check carried out by the firmware.\r | |
0c18794e | 134 | @return EFI_SUCCESS Variable passed validation successfully.\r |
135 | \r | |
136 | **/\r | |
137 | EFI_STATUS\r | |
138 | ProcessVarWithPk (\r | |
139 | IN CHAR16 *VariableName,\r | |
140 | IN EFI_GUID *VendorGuid,\r | |
141 | IN VOID *Data,\r | |
142 | IN UINTN DataSize,\r | |
143 | IN VARIABLE_POINTER_TRACK *Variable,\r | |
144 | IN UINT32 Attributes OPTIONAL,\r | |
145 | IN BOOLEAN IsPk\r | |
146 | );\r | |
147 | \r | |
148 | /**\r | |
149 | Process variable with key exchange key for verification.\r | |
150 | \r | |
151 | @param[in] VariableName Name of Variable to be found.\r | |
152 | @param[in] VendorGuid Variable vendor GUID.\r | |
153 | @param[in] Data Data pointer.\r | |
154 | @param[in] DataSize Size of Data found. If size is less than the\r | |
155 | data, this value contains the required size.\r | |
156 | @param[in] Variable The variable information that is used to keep track of variable usage.\r | |
157 | @param[in] Attributes Attribute value of the variable.\r | |
158 | \r | |
159 | @return EFI_INVALID_PARAMETER Invalid parameter.\r | |
2d3fb919 | 160 | @return EFI_SECURITY_VIOLATION The variable does NOT pass the validation\r |
161 | check carried out by the firmware.\r | |
0c18794e | 162 | @return EFI_SUCCESS Variable passed validation successfully.\r |
163 | \r | |
164 | **/\r | |
165 | EFI_STATUS\r | |
166 | ProcessVarWithKek (\r | |
167 | IN CHAR16 *VariableName,\r | |
168 | IN EFI_GUID *VendorGuid,\r | |
169 | IN VOID *Data,\r | |
170 | IN UINTN DataSize,\r | |
171 | IN VARIABLE_POINTER_TRACK *Variable,\r | |
172 | IN UINT32 Attributes OPTIONAL\r | |
173 | );\r | |
174 | \r | |
2d3fb919 | 175 | /**\r |
176 | Merge two buffers which formatted as EFI_SIGNATURE_LIST. Only the new EFI_SIGNATURE_DATA\r | |
177 | will be appended to the original EFI_SIGNATURE_LIST, duplicate EFI_SIGNATURE_DATA\r | |
178 | will be ignored.\r | |
179 | \r | |
180 | @param[in, out] Data Pointer to original EFI_SIGNATURE_LIST.\r | |
181 | @param[in] DataSize Size of Data buffer.\r | |
182 | @param[in] NewData Pointer to new EFI_SIGNATURE_LIST to be appended.\r | |
183 | @param[in] NewDataSize Size of NewData buffer.\r | |
184 | \r | |
185 | @return Size of the merged buffer.\r | |
186 | \r | |
187 | **/\r | |
188 | UINTN\r | |
189 | AppendSignatureList (\r | |
190 | IN OUT VOID *Data,\r | |
191 | IN UINTN DataSize,\r | |
192 | IN VOID *NewData,\r | |
193 | IN UINTN NewDataSize\r | |
194 | );\r | |
195 | \r | |
0c18794e | 196 | /**\r |
197 | Compare two EFI_TIME data.\r | |
198 | \r | |
199 | \r | |
200 | @param FirstTime A pointer to the first EFI_TIME data.\r | |
201 | @param SecondTime A pointer to the second EFI_TIME data.\r | |
202 | \r | |
203 | @retval TRUE The FirstTime is not later than the SecondTime.\r | |
204 | @retval FALSE The FirstTime is later than the SecondTime.\r | |
205 | \r | |
206 | **/\r | |
207 | BOOLEAN\r | |
208 | CompareTimeStamp (\r | |
209 | IN EFI_TIME *FirstTime,\r | |
210 | IN EFI_TIME *SecondTime\r | |
211 | );\r | |
212 | \r | |
213 | \r | |
214 | /**\r | |
215 | Process variable with EFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS set\r | |
216 | \r | |
217 | @param[in] VariableName Name of Variable to be found.\r | |
218 | @param[in] VendorGuid Variable vendor GUID.\r | |
219 | @param[in] Data Data pointer.\r | |
220 | @param[in] DataSize Size of Data found. If size is less than the\r | |
221 | data, this value contains the required size.\r | |
222 | @param[in] Variable The variable information which is used to keep track of variable usage.\r | |
223 | @param[in] Attributes Attribute value of the variable.\r | |
224 | @param[in] Pk Verify against PK or KEK database.\r | |
225 | @param[out] VarDel Delete the variable or not.\r | |
226 | \r | |
227 | @retval EFI_INVALID_PARAMETER Invalid parameter.\r | |
2d3fb919 | 228 | @retval EFI_SECURITY_VIOLATION The variable does NOT pass the validation\r |
229 | check carried out by the firmware.\r | |
0c18794e | 230 | @retval EFI_OUT_OF_RESOURCES Failed to process variable due to lack\r |
231 | of resources.\r | |
232 | @retval EFI_SUCCESS Variable pass validation successfully.\r | |
233 | \r | |
234 | **/\r | |
235 | EFI_STATUS\r | |
236 | VerifyTimeBasedPayload (\r | |
237 | IN CHAR16 *VariableName,\r | |
238 | IN EFI_GUID *VendorGuid,\r | |
239 | IN VOID *Data,\r | |
240 | IN UINTN DataSize,\r | |
241 | IN VARIABLE_POINTER_TRACK *Variable,\r | |
242 | IN UINT32 Attributes,\r | |
243 | IN BOOLEAN Pk,\r | |
244 | OUT BOOLEAN *VarDel\r | |
245 | );\r | |
246 | \r | |
247 | extern UINT8 mPubKeyStore[MAX_KEYDB_SIZE];\r | |
248 | extern UINT32 mPubKeyNumber;\r | |
249 | extern VOID *mHashCtx;\r | |
250 | extern VOID *mStorageArea;\r | |
2d3fb919 | 251 | extern UINT8 *mSerializationRuntimeBuffer;\r |
252 | \r | |
0c18794e | 253 | #endif\r |