]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Library / DxeSecurityManagementLib / DxeSecurityManagementLib.c
CommitLineData
cd98f305
LG
1/** @file\r
2 Provides generic security measurement functions for DXE module.\r
3\r
d1102dba 4Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
cd5ebaa0 5This program and the accompanying materials\r
cd98f305
LG
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <PiDxe.h>\r
2b75e8cd 16#include <Protocol/LoadFile.h>\r
cd98f305
LG
17#include <Library/DebugLib.h>\r
18#include <Library/DxeServicesLib.h>\r
19#include <Library/MemoryAllocationLib.h>\r
20#include <Library/SecurityManagementLib.h>\r
2b75e8cd
LG
21#include <Library/DevicePathLib.h>\r
22#include <Library/UefiBootServicesTableLib.h>\r
cd98f305
LG
23\r
24#define SECURITY_HANDLER_TABLE_SIZE 0x10\r
25\r
bc2dfdbc
LG
26//\r
27// Secruity Operation on Image and none Image.\r
28//\r
29#define EFI_AUTH_IMAGE_OPERATION_MASK (EFI_AUTH_OPERATION_VERIFY_IMAGE \\r
30 | EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD \\r
31 | EFI_AUTH_OPERATION_MEASURE_IMAGE)\r
32#define EFI_AUTH_NONE_IMAGE_OPERATION_MASK (EFI_AUTH_OPERATION_CONNECT_POLICY \\r
33 | EFI_AUTH_OPERATION_AUTHENTICATION_STATE)\r
cd98f305
LG
34\r
35typedef struct {\r
36 UINT32 SecurityOperation;\r
37 SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler;\r
38} SECURITY_INFO;\r
39\r
bc2dfdbc
LG
40typedef struct {\r
41 UINT32 Security2Operation;\r
42 SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler;\r
43} SECURITY2_INFO;\r
44\r
cd98f305
LG
45UINT32 mCurrentAuthOperation = 0;\r
46UINT32 mNumberOfSecurityHandler = 0;\r
47UINT32 mMaxNumberOfSecurityHandler = 0;\r
48SECURITY_INFO *mSecurityTable = NULL;\r
49\r
bc2dfdbc
LG
50UINT32 mCurrentAuthOperation2 = 0;\r
51UINT32 mNumberOfSecurity2Handler = 0;\r
52UINT32 mMaxNumberOfSecurity2Handler = 0;\r
53SECURITY2_INFO *mSecurity2Table = NULL;\r
54\r
cd98f305
LG
55/**\r
56 Reallocates more global memory to store the registered Handler list.\r
57\r
58 @retval RETURN_SUCCESS Reallocate memory successfully.\r
59 @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.\r
60**/\r
61RETURN_STATUS\r
62EFIAPI\r
63ReallocateSecurityHandlerTable (\r
f826516d 64 VOID\r
cd98f305
LG
65 )\r
66{\r
67 //\r
68 // Reallocate memory for security info structure.\r
69 //\r
70 mSecurityTable = ReallocatePool (\r
d1102dba
LG
71 mMaxNumberOfSecurityHandler * sizeof (SECURITY_INFO),\r
72 (mMaxNumberOfSecurityHandler + SECURITY_HANDLER_TABLE_SIZE) * sizeof (SECURITY_INFO),\r
cd98f305
LG
73 mSecurityTable\r
74 );\r
75\r
76 //\r
77 // No enough resource is allocated.\r
78 //\r
79 if (mSecurityTable == NULL) {\r
80 return RETURN_OUT_OF_RESOURCES;\r
81 }\r
82\r
83 //\r
84 // Increase max handler number\r
85 //\r
86 mMaxNumberOfSecurityHandler = mMaxNumberOfSecurityHandler + SECURITY_HANDLER_TABLE_SIZE;\r
87 return RETURN_SUCCESS;\r
88}\r
89\r
90/**\r
d1102dba 91 Check whether an operation is valid according to the requirement of current operation,\r
cd98f305
LG
92 which must make sure that the measure image operation is the last one.\r
93\r
94 @param CurrentAuthOperation Current operation.\r
95 @param CheckAuthOperation Operation to be checked.\r
96\r
97 @retval TRUE Operation is valid for current operation.\r
98 @retval FALSE Operation is invalid for current operation.\r
99**/\r
100BOOLEAN\r
101CheckAuthenticationOperation (\r
102 IN UINT32 CurrentAuthOperation,\r
103 IN UINT32 CheckAuthOperation\r
104 )\r
d1102dba 105{\r
cd98f305
LG
106 //\r
107 // Make sure new auth operation can be recognized.\r
108 //\r
c9e88815 109 ASSERT ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK | EFI_AUTH_OPERATION_AUTHENTICATION_STATE | EFI_AUTH_OPERATION_IMAGE_REQUIRED)) == 0);\r
d1102dba 110\r
cd98f305 111 //\r
d1102dba 112 // When current operation includes measure image operation,\r
cd98f305
LG
113 // only another measure image operation or none operation will be allowed.\r
114 //\r
115 if ((CurrentAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) {\r
116 if (((CheckAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) ||\r
bc2dfdbc 117 ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == EFI_AUTH_OPERATION_NONE)) {\r
cd98f305
LG
118 return TRUE;\r
119 } else {\r
120 return FALSE;\r
121 }\r
122 }\r
d1102dba 123\r
cd98f305 124 //\r
d1102dba 125 // When current operation doesn't include measure image operation,\r
cd98f305
LG
126 // any new operation will be allowed.\r
127 //\r
128 return TRUE;\r
129}\r
130\r
131/**\r
132 Register security measurement handler with its operation type. The different\r
133 handler with the same operation can all be registered.\r
134\r
135 If SecurityHandler is NULL, then ASSERT().\r
136 If no enough resources available to register new handler, then ASSERT().\r
137 If AuthenticationOperation is not recongnized, then ASSERT().\r
138 If the previous register handler can't be executed before the later register handler, then ASSERT().\r
139\r
140 @param[in] SecurityHandler Security measurement service handler to be registered.\r
141 @param[in] AuthenticationOperation Operation type is specified for the registered handler.\r
142\r
143 @retval EFI_SUCCESS The handlers were registered successfully.\r
144**/\r
145EFI_STATUS\r
146EFIAPI\r
147RegisterSecurityHandler (\r
148 IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,\r
149 IN UINT32 AuthenticationOperation\r
150 )\r
151{\r
152 EFI_STATUS Status;\r
153\r
154 ASSERT (SecurityHandler != NULL);\r
155\r
156 //\r
157 // Make sure AuthenticationOperation is valid in the register order.\r
158 //\r
159 ASSERT (CheckAuthenticationOperation (mCurrentAuthOperation, AuthenticationOperation));\r
160 mCurrentAuthOperation = mCurrentAuthOperation | AuthenticationOperation;\r
161\r
162 //\r
163 // Check whether the handler lists is enough to store new handler.\r
164 //\r
165 if (mNumberOfSecurityHandler == mMaxNumberOfSecurityHandler) {\r
166 //\r
167 // Allocate more resources for new handler.\r
168 //\r
169 Status = ReallocateSecurityHandlerTable();\r
170 ASSERT_EFI_ERROR (Status);\r
171 }\r
172\r
173 //\r
174 // Register new handler into the handler list.\r
175 //\r
176 mSecurityTable[mNumberOfSecurityHandler].SecurityOperation = AuthenticationOperation;\r
177 mSecurityTable[mNumberOfSecurityHandler].SecurityHandler = SecurityHandler;\r
178 mNumberOfSecurityHandler ++;\r
179\r
180 return EFI_SUCCESS;\r
181}\r
182\r
183/**\r
184 Execute registered handlers until one returns an error and that error is returned.\r
185 If none of the handlers return an error, then EFI_SUCCESS is returned.\r
186\r
d1102dba 187 Before exectue handler, get the image buffer by file device path if a handler\r
cd98f305
LG
188 requires the image file. And return the image buffer to each handler when exectue handler.\r
189\r
190 The handlers are executed in same order to their registered order.\r
191\r
d1102dba 192 @param[in] AuthenticationStatus\r
cd98f305
LG
193 This is the authentication type returned from the Section\r
194 Extraction protocol. See the Section Extraction Protocol\r
195 Specification for details on this type.\r
196 @param[in] FilePath This is a pointer to the device path of the file that is\r
197 being dispatched. This will optionally be used for logging.\r
198\r
199 @retval EFI_SUCCESS The file specified by File did authenticate when more\r
d1102dba
LG
200 than one security handler services were registered,\r
201 or the file did not authenticate when no security\r
202 handler service was registered. And the platform policy\r
cd98f305
LG
203 dictates that the DXE Core may use File.\r
204 @retval EFI_INVALID_PARAMETER File is NULL.\r
205 @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and\r
206 the platform policy dictates that File should be placed\r
207 in the untrusted state. A file may be promoted from\r
208 the untrusted to the trusted state at a future time\r
209 with a call to the Trust() DXE Service.\r
210 @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and\r
211 the platform policy dictates that File should not be\r
212 used for any purpose.\r
213**/\r
214EFI_STATUS\r
215EFIAPI\r
216ExecuteSecurityHandlers (\r
217 IN UINT32 AuthenticationStatus,\r
218 IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath\r
219 )\r
220{\r
221 UINT32 Index;\r
222 EFI_STATUS Status;\r
223 UINT32 HandlerAuthenticationStatus;\r
224 VOID *FileBuffer;\r
225 UINTN FileSize;\r
2b75e8cd
LG
226 EFI_HANDLE Handle;\r
227 EFI_DEVICE_PATH_PROTOCOL *Node;\r
228 EFI_DEVICE_PATH_PROTOCOL *FilePathToVerfiy;\r
d1102dba 229\r
cd98f305
LG
230 if (FilePath == NULL) {\r
231 return EFI_INVALID_PARAMETER;\r
232 }\r
233\r
234 //\r
235 // Directly return successfully when no handler is registered.\r
236 //\r
237 if (mNumberOfSecurityHandler == 0) {\r
238 return EFI_SUCCESS;\r
239 }\r
d1102dba 240\r
cd98f305
LG
241 Status = EFI_SUCCESS;\r
242 FileBuffer = NULL;\r
243 FileSize = 0;\r
244 HandlerAuthenticationStatus = AuthenticationStatus;\r
2b75e8cd 245 FilePathToVerfiy = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;\r
cd98f305
LG
246 //\r
247 // Run security handler in same order to their registered list\r
248 //\r
249 for (Index = 0; Index < mNumberOfSecurityHandler; Index ++) {\r
250 if ((mSecurityTable[Index].SecurityOperation & EFI_AUTH_OPERATION_IMAGE_REQUIRED) == EFI_AUTH_OPERATION_IMAGE_REQUIRED) {\r
251 //\r
252 // Try get file buffer when the handler requires image buffer.\r
253 //\r
254 if (FileBuffer == NULL) {\r
2b75e8cd
LG
255 Node = FilePathToVerfiy;\r
256 Status = gBS->LocateDevicePath (&gEfiLoadFileProtocolGuid, &Node, &Handle);\r
2983a79d
LG
257 //\r
258 // Try to get image by FALSE boot policy for the exact boot file path.\r
259 //\r
cd98f305 260 FileBuffer = GetFileBufferByFilePath (FALSE, FilePath, &FileSize, &AuthenticationStatus);\r
2983a79d
LG
261 if (FileBuffer == NULL) {\r
262 //\r
263 // Try to get image by TRUE boot policy for the inexact boot file path.\r
264 //\r
265 FileBuffer = GetFileBufferByFilePath (TRUE, FilePath, &FileSize, &AuthenticationStatus);\r
266 }\r
2b75e8cd
LG
267 if ((FileBuffer != NULL) && (!EFI_ERROR (Status))) {\r
268 //\r
269 // LoadFile () may cause the device path of the Handle be updated.\r
270 //\r
271 FilePathToVerfiy = AppendDevicePath (DevicePathFromHandle (Handle), Node);\r
272 }\r
cd98f305
LG
273 }\r
274 }\r
275 Status = mSecurityTable[Index].SecurityHandler (\r
276 HandlerAuthenticationStatus,\r
2b75e8cd 277 FilePathToVerfiy,\r
cd98f305
LG
278 FileBuffer,\r
279 FileSize\r
280 );\r
281 if (EFI_ERROR (Status)) {\r
282 break;\r
283 }\r
284 }\r
285\r
286 if (FileBuffer != NULL) {\r
287 FreePool (FileBuffer);\r
288 }\r
2b75e8cd
LG
289 if (FilePathToVerfiy != FilePath) {\r
290 FreePool (FilePathToVerfiy);\r
291 }\r
cd98f305
LG
292\r
293 return Status;\r
294}\r
bc2dfdbc
LG
295\r
296/**\r
297 Reallocates more global memory to store the registered Securit2Handler list.\r
298\r
299 @retval RETURN_SUCCESS Reallocate memory successfully.\r
300 @retval RETURN_OUT_OF_RESOURCES No enough memory to allocated.\r
301**/\r
302RETURN_STATUS\r
303EFIAPI\r
304ReallocateSecurity2HandlerTable (\r
f826516d 305 VOID\r
bc2dfdbc
LG
306 )\r
307{\r
308 //\r
309 // Reallocate memory for security info structure.\r
310 //\r
311 mSecurity2Table = ReallocatePool (\r
d1102dba
LG
312 mMaxNumberOfSecurity2Handler * sizeof (SECURITY2_INFO),\r
313 (mMaxNumberOfSecurity2Handler + SECURITY_HANDLER_TABLE_SIZE) * sizeof (SECURITY2_INFO),\r
bc2dfdbc
LG
314 mSecurity2Table\r
315 );\r
316\r
317 //\r
318 // No enough resource is allocated.\r
319 //\r
320 if (mSecurity2Table == NULL) {\r
321 return RETURN_OUT_OF_RESOURCES;\r
322 }\r
323\r
324 //\r
325 // Increase max handler number\r
326 //\r
327 mMaxNumberOfSecurity2Handler = mMaxNumberOfSecurity2Handler + SECURITY_HANDLER_TABLE_SIZE;\r
328 return RETURN_SUCCESS;\r
329}\r
330\r
331/**\r
d1102dba 332 Check whether an operation is valid according to the requirement of current operation,\r
bc2dfdbc 333 which must make sure that the measure image operation is the last one.\r
d1102dba 334\r
bc2dfdbc
LG
335 If AuthenticationOperation is not recongnized, return FALSE.\r
336 If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, return FALSE.\r
337 If AuthenticationOperation includes security operation and authentication operation, return FALSE.\r
338 If the previous register handler can't be executed before the later register handler, return FALSE.\r
d1102dba 339\r
bc2dfdbc
LG
340 @param CurrentAuthOperation Current operation.\r
341 @param CheckAuthOperation Operation to be checked.\r
d1102dba 342\r
bc2dfdbc
LG
343 @retval TRUE Operation is valid for current operation.\r
344 @retval FALSE Operation is invalid for current operation.\r
345**/\r
346BOOLEAN\r
347CheckAuthentication2Operation (\r
348 IN UINT32 CurrentAuthOperation,\r
349 IN UINT32 CheckAuthOperation\r
350 )\r
d1102dba 351{\r
bc2dfdbc
LG
352 //\r
353 // Make sure new auth operation can be recognized.\r
354 //\r
355 if (CheckAuthOperation == EFI_AUTH_OPERATION_NONE) {\r
356 return FALSE;\r
357 }\r
d1102dba
LG
358 if ((CheckAuthOperation & ~(EFI_AUTH_IMAGE_OPERATION_MASK |\r
359 EFI_AUTH_NONE_IMAGE_OPERATION_MASK |\r
bc2dfdbc
LG
360 EFI_AUTH_OPERATION_IMAGE_REQUIRED)) != 0) {\r
361 return FALSE;\r
362 }\r
363\r
364 //\r
d1102dba 365 // When current operation includes measure image operation,\r
bc2dfdbc
LG
366 // only another measure image or none image operation will be allowed.\r
367 //\r
368 if ((CurrentAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) {\r
369 if (((CheckAuthOperation & EFI_AUTH_OPERATION_MEASURE_IMAGE) == EFI_AUTH_OPERATION_MEASURE_IMAGE) ||\r
370 ((CheckAuthOperation & EFI_AUTH_IMAGE_OPERATION_MASK) == 0)) {\r
371 return TRUE;\r
372 } else {\r
373 return FALSE;\r
374 }\r
375 }\r
d1102dba 376\r
bc2dfdbc
LG
377 //\r
378 // Any other operation will be allowed.\r
379 //\r
380 return TRUE;\r
381}\r
382\r
383/**\r
384 Register security measurement handler with its operation type. Different\r
385 handlers with the same operation can all be registered.\r
386\r
387 If Security2Handler is NULL, then ASSERT().\r
388 If no enough resources available to register new handler, then ASSERT().\r
389 If AuthenticationOperation is not recongnized, then ASSERT().\r
390 If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, then ASSERT().\r
391 If the previous register handler can't be executed before the later register handler, then ASSERT().\r
392\r
393 @param[in] Security2Handler The security measurement service handler to be registered.\r
394 @param[in] AuthenticationOperation The operation type is specified for the registered handler.\r
395\r
396 @retval EFI_SUCCESS The handlers were registered successfully.\r
397**/\r
398EFI_STATUS\r
399EFIAPI\r
400RegisterSecurity2Handler (\r
401 IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,\r
402 IN UINT32 AuthenticationOperation\r
403 )\r
404{\r
405 EFI_STATUS Status;\r
406\r
407 ASSERT (Security2Handler != NULL);\r
408\r
409 //\r
410 // Make sure AuthenticationOperation is valid in the register order.\r
411 //\r
412 ASSERT (CheckAuthentication2Operation (mCurrentAuthOperation2, AuthenticationOperation));\r
413 mCurrentAuthOperation2 = mCurrentAuthOperation2 | AuthenticationOperation;\r
414\r
415 //\r
416 // Check whether the handler lists is enough to store new handler.\r
417 //\r
418 if (mNumberOfSecurity2Handler == mMaxNumberOfSecurity2Handler) {\r
419 //\r
420 // Allocate more resources for new handler.\r
421 //\r
422 Status = ReallocateSecurity2HandlerTable();\r
423 ASSERT_EFI_ERROR (Status);\r
424 }\r
425\r
426 //\r
427 // Register new handler into the handler list.\r
428 //\r
429 mSecurity2Table[mNumberOfSecurity2Handler].Security2Operation = AuthenticationOperation;\r
430 mSecurity2Table[mNumberOfSecurity2Handler].Security2Handler = Security2Handler;\r
431 mNumberOfSecurity2Handler ++;\r
432\r
433 return EFI_SUCCESS;\r
434}\r
435\r
436/**\r
d1102dba
LG
437 Execute registered handlers based on input AuthenticationOperation until\r
438 one returns an error and that error is returned.\r
439\r
bc2dfdbc
LG
440 If none of the handlers return an error, then EFI_SUCCESS is returned.\r
441 The handlers those satisfy AuthenticationOperation will only be executed.\r
442 The handlers are executed in same order to their registered order.\r
443\r
d1102dba 444 @param[in] AuthenticationOperation\r
bc2dfdbc 445 The operation type specifies which handlers will be executed.\r
d1102dba 446 @param[in] AuthenticationStatus\r
bc2dfdbc
LG
447 The authentication status for the input file.\r
448 @param[in] File This is a pointer to the device path of the file that is\r
449 being dispatched. This will optionally be used for logging.\r
450 @param[in] FileBuffer A pointer to the buffer with the UEFI file image\r
451 @param[in] FileSize The size of File buffer.\r
452 @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.\r
453\r
454 @retval EFI_SUCCESS The file specified by DevicePath and non-NULL\r
455 FileBuffer did authenticate, and the platform policy dictates\r
456 that the DXE Foundation may use the file.\r
457 @retval EFI_SUCCESS The device path specified by NULL device path DevicePath\r
458 and non-NULL FileBuffer did authenticate, and the platform\r
459 policy dictates that the DXE Foundation may execute the image in\r
460 FileBuffer.\r
461 @retval EFI_SUCCESS FileBuffer is NULL and current user has permission to start\r
462 UEFI device drivers on the device path specified by DevicePath.\r
463 @retval EFI_SECURITY_VIOLATION The file specified by File or FileBuffer did not\r
d1102dba 464 authenticate, and the platform policy dictates that\r
bc2dfdbc
LG
465 the file should be placed in the untrusted state.\r
466 @retval EFI_SECURITY_VIOLATION FileBuffer FileBuffer is NULL and the user has no\r
467 permission to start UEFI device drivers on the device path specified\r
468 by DevicePath.\r
469 @retval EFI_SECURITY_VIOLATION FileBuffer is not NULL and the user has no permission to load\r
470 drivers from the device path specified by DevicePath. The\r
471 image has been added into the list of the deferred images.\r
472 @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and\r
473 the platform policy dictates that the DXE\r
474 Foundation may not use File.\r
d1102dba 475 @retval EFI_INVALID_PARAMETER File and FileBuffer are both NULL.\r
bc2dfdbc
LG
476**/\r
477EFI_STATUS\r
478EFIAPI\r
479ExecuteSecurity2Handlers (\r
480 IN UINT32 AuthenticationOperation,\r
481 IN UINT32 AuthenticationStatus,\r
482 IN CONST EFI_DEVICE_PATH_PROTOCOL *File,\r
483 IN VOID *FileBuffer,\r
484 IN UINTN FileSize,\r
485 IN BOOLEAN BootPolicy\r
486 )\r
487{\r
488 UINT32 Index;\r
489 EFI_STATUS Status;\r
490\r
491 //\r
492 // Invalid case if File and FileBuffer are both NULL.\r
493 //\r
494 if (File == NULL && FileBuffer == NULL) {\r
495 return EFI_INVALID_PARAMETER;\r
496 }\r
497\r
498 //\r
499 // Directly return successfully when no handler is registered.\r
500 //\r
501 if (mNumberOfSecurity2Handler == 0) {\r
502 return EFI_SUCCESS;\r
503 }\r
504\r
505 //\r
506 // Run security handler in same order to their registered list\r
507 //\r
508 for (Index = 0; Index < mNumberOfSecurity2Handler; Index ++) {\r
509 //\r
510 // If FileBuffer is not NULL, the input is Image, which will be handled by EFI_AUTH_IMAGE_OPERATION_MASK operation.\r
511 // If FileBuffer is NULL, the input is not Image, which will be handled by EFI_AUTH_NONE_IMAGE_OPERATION_MASK operation.\r
512 // Other cases are ignored.\r
513 //\r
514 if ((FileBuffer != NULL && (mSecurity2Table[Index].Security2Operation & EFI_AUTH_IMAGE_OPERATION_MASK) != 0) ||\r
515 (FileBuffer == NULL && (mSecurity2Table[Index].Security2Operation & EFI_AUTH_NONE_IMAGE_OPERATION_MASK) != 0)) {\r
516 //\r
517 // Execute registered handlers based on input AuthenticationOperation\r
518 //\r
519 if ((mSecurity2Table[Index].Security2Operation & AuthenticationOperation) != 0) {\r
520 Status = mSecurity2Table[Index].Security2Handler (\r
521 AuthenticationStatus,\r
522 File,\r
523 FileBuffer,\r
524 FileSize,\r
525 BootPolicy\r
526 );\r
527 if (EFI_ERROR (Status)) {\r
528 return Status;\r
529 }\r
530 }\r
531 }\r
532 }\r
533\r
534 return EFI_SUCCESS;\r
535}\r