TianoCore EDK2 master
Loading...
Searching...
No Matches
DxeSecurityManagementLib.c File Reference

Go to the source code of this file.

Data Structures

struct  SECURITY_INFO
 
struct  SECURITY2_INFO
 

Macros

#define SECURITY_HANDLER_TABLE_SIZE   0x10
 
#define EFI_AUTH_IMAGE_OPERATION_MASK
 
#define EFI_AUTH_NONE_IMAGE_OPERATION_MASK
 

Functions

RETURN_STATUS EFIAPI ReallocateSecurityHandlerTable (VOID)
 
BOOLEAN CheckAuthenticationOperation (IN UINT32 CurrentAuthOperation, IN UINT32 CheckAuthOperation)
 
EFI_STATUS EFIAPI RegisterSecurityHandler (IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler, IN UINT32 AuthenticationOperation)
 
EFI_STATUS EFIAPI ExecuteSecurityHandlers (IN UINT32 AuthenticationStatus, IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath)
 
RETURN_STATUS EFIAPI ReallocateSecurity2HandlerTable (VOID)
 
BOOLEAN CheckAuthentication2Operation (IN UINT32 CurrentAuthOperation, IN UINT32 CheckAuthOperation)
 
EFI_STATUS EFIAPI RegisterSecurity2Handler (IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler, IN UINT32 AuthenticationOperation)
 
EFI_STATUS EFIAPI ExecuteSecurity2Handlers (IN UINT32 AuthenticationOperation, IN UINT32 AuthenticationStatus, IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL, IN VOID *FileBuffer, IN UINTN FileSize, IN BOOLEAN BootPolicy)
 

Variables

UINT32 mCurrentAuthOperation = 0
 
UINT32 mNumberOfSecurityHandler = 0
 
UINT32 mMaxNumberOfSecurityHandler = 0
 
SECURITY_INFOmSecurityTable = NULL
 
UINT32 mCurrentAuthOperation2 = 0
 
UINT32 mNumberOfSecurity2Handler = 0
 
UINT32 mMaxNumberOfSecurity2Handler = 0
 
SECURITY2_INFOmSecurity2Table = NULL
 

Detailed Description

Provides generic security measurement functions for DXE module.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file DxeSecurityManagementLib.c.

Macro Definition Documentation

◆ EFI_AUTH_IMAGE_OPERATION_MASK

#define EFI_AUTH_IMAGE_OPERATION_MASK
Value:
(EFI_AUTH_OPERATION_VERIFY_IMAGE \
| EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD \
| EFI_AUTH_OPERATION_MEASURE_IMAGE)

Definition at line 23 of file DxeSecurityManagementLib.c.

◆ EFI_AUTH_NONE_IMAGE_OPERATION_MASK

#define EFI_AUTH_NONE_IMAGE_OPERATION_MASK
Value:
(EFI_AUTH_OPERATION_CONNECT_POLICY \
| EFI_AUTH_OPERATION_AUTHENTICATION_STATE)

Definition at line 26 of file DxeSecurityManagementLib.c.

◆ SECURITY_HANDLER_TABLE_SIZE

#define SECURITY_HANDLER_TABLE_SIZE   0x10

Definition at line 18 of file DxeSecurityManagementLib.c.

Function Documentation

◆ CheckAuthentication2Operation()

BOOLEAN CheckAuthentication2Operation ( IN UINT32  CurrentAuthOperation,
IN UINT32  CheckAuthOperation 
)

Check whether an operation is valid according to the requirement of current operation, which must make sure that the measure image operation is the last one.

If AuthenticationOperation is not recongnized, return FALSE. If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, return FALSE. If AuthenticationOperation includes security operation and authentication operation, return FALSE. If the previous register handler can't be executed before the later register handler, return FALSE.

Parameters
CurrentAuthOperationCurrent operation.
CheckAuthOperationOperation to be checked.
Return values
TRUEOperation is valid for current operation.
FALSEOperation is invalid for current operation.

Definition at line 345 of file DxeSecurityManagementLib.c.

◆ CheckAuthenticationOperation()

BOOLEAN CheckAuthenticationOperation ( IN UINT32  CurrentAuthOperation,
IN UINT32  CheckAuthOperation 
)

Check whether an operation is valid according to the requirement of current operation, which must make sure that the measure image operation is the last one.

Parameters
CurrentAuthOperationCurrent operation.
CheckAuthOperationOperation to be checked.
Return values
TRUEOperation is valid for current operation.
FALSEOperation is invalid for current operation.

Definition at line 95 of file DxeSecurityManagementLib.c.

◆ ExecuteSecurity2Handlers()

EFI_STATUS EFIAPI ExecuteSecurity2Handlers ( IN UINT32  AuthenticationOperation,
IN UINT32  AuthenticationStatus,
IN CONST EFI_DEVICE_PATH_PROTOCOL *File  OPTIONAL,
IN VOID *  FileBuffer,
IN UINTN  FileSize,
IN BOOLEAN  BootPolicy 
)

Execute registered handlers based on input AuthenticationOperation until one returns an error and that error is returned.

If none of the handlers return an error, then EFI_SUCCESS is returned. The handlers those satisfy AuthenticationOperation will only be executed. The handlers are executed in same order to their registered order.

Parameters
[in]AuthenticationOperationThe operation type specifies which handlers will be executed.
[in]AuthenticationStatusThe authentication status for the input file.
[in]FileThis is a pointer to the device path of the file that is being dispatched. This will optionally be used for logging.
[in]FileBufferA pointer to the buffer with the UEFI file image
[in]FileSizeThe size of File buffer.
[in]BootPolicyA boot policy that was used to call LoadImage() UEFI service.
Return values
EFI_SUCCESSThe file specified by DevicePath and non-NULL FileBuffer did authenticate, and the platform policy dictates that the DXE Foundation may use the file.
EFI_SUCCESSThe device path specified by NULL device path DevicePath and non-NULL FileBuffer did authenticate, and the platform policy dictates that the DXE Foundation may execute the image in FileBuffer.
EFI_SUCCESSFileBuffer is NULL and current user has permission to start UEFI device drivers on the device path specified by DevicePath.
EFI_SECURITY_VIOLATIONThe file specified by File or FileBuffer did not authenticate, and the platform policy dictates that the file should be placed in the untrusted state.
EFI_SECURITY_VIOLATIONFileBuffer FileBuffer is NULL and the user has no permission to start UEFI device drivers on the device path specified by DevicePath.
EFI_SECURITY_VIOLATIONFileBuffer is not NULL and the user has no permission to load drivers from the device path specified by DevicePath. The image has been added into the list of the deferred images.
EFI_ACCESS_DENIEDThe file specified by File did not authenticate, and the platform policy dictates that the DXE Foundation may not use File.
EFI_INVALID_PARAMETERFile and FileBuffer are both NULL.

Definition at line 480 of file DxeSecurityManagementLib.c.

◆ ExecuteSecurityHandlers()

EFI_STATUS EFIAPI ExecuteSecurityHandlers ( IN UINT32  AuthenticationStatus,
IN CONST EFI_DEVICE_PATH_PROTOCOL FilePath 
)

Execute registered handlers until one returns an error and that error is returned. If none of the handlers return an error, then EFI_SUCCESS is returned.

Before exectue handler, get the image buffer by file device path if a handler requires the image file. And return the image buffer to each handler when exectue handler.

The handlers are executed in same order to their registered order.

Parameters
[in]AuthenticationStatusThis is the authentication type returned from the Section Extraction protocol. See the Section Extraction Protocol Specification for details on this type.
[in]FilePathThis is a pointer to the device path of the file that is being dispatched. This will optionally be used for logging.
Return values
EFI_SUCCESSThe file specified by File did authenticate when more than one security handler services were registered, or the file did not authenticate when no security handler service was registered. And the platform policy dictates that the DXE Core may use File.
EFI_INVALID_PARAMETERFile is NULL.
EFI_SECURITY_VIOLATIONThe file specified by File did not authenticate, and the platform policy dictates that File should be placed in the untrusted state. A file may be promoted from the untrusted to the trusted state at a future time with a call to the Trust() DXE Service.
EFI_ACCESS_DENIEDThe file specified by File did not authenticate, and the platform policy dictates that File should not be used for any purpose.

Definition at line 211 of file DxeSecurityManagementLib.c.

◆ ReallocateSecurity2HandlerTable()

RETURN_STATUS EFIAPI ReallocateSecurity2HandlerTable ( VOID  )

Reallocates more global memory to store the registered Securit2Handler list.

Return values
RETURN_SUCCESSReallocate memory successfully.
RETURN_OUT_OF_RESOURCESNo enough memory to allocated.

Definition at line 302 of file DxeSecurityManagementLib.c.

◆ ReallocateSecurityHandlerTable()

RETURN_STATUS EFIAPI ReallocateSecurityHandlerTable ( VOID  )

Reallocates more global memory to store the registered Handler list.

Return values
RETURN_SUCCESSReallocate memory successfully.
RETURN_OUT_OF_RESOURCESNo enough memory to allocated.

Definition at line 57 of file DxeSecurityManagementLib.c.

◆ RegisterSecurity2Handler()

EFI_STATUS EFIAPI RegisterSecurity2Handler ( IN SECURITY2_FILE_AUTHENTICATION_HANDLER  Security2Handler,
IN UINT32  AuthenticationOperation 
)

Register security measurement handler with its operation type. Different handlers with the same operation can all be registered.

If Security2Handler is NULL, then ASSERT(). If no enough resources available to register new handler, then ASSERT(). If AuthenticationOperation is not recongnized, then ASSERT(). If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, then ASSERT(). If the previous register handler can't be executed before the later register handler, then ASSERT().

Parameters
[in]Security2HandlerThe security measurement service handler to be registered.
[in]AuthenticationOperationThe operation type is specified for the registered handler.
Return values
EFI_SUCCESSThe handlers were registered successfully.

Definition at line 401 of file DxeSecurityManagementLib.c.

◆ RegisterSecurityHandler()

EFI_STATUS EFIAPI RegisterSecurityHandler ( IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER  SecurityHandler,
IN UINT32  AuthenticationOperation 
)

Register security measurement handler with its operation type. The different handler with the same operation can all be registered.

If SecurityHandler is NULL, then ASSERT(). If no enough resources available to register new handler, then ASSERT(). If AuthenticationOperation is not recongnized, then ASSERT(). If the previous register handler can't be executed before the later register handler, then ASSERT().

Parameters
[in]SecurityHandlerSecurity measurement service handler to be registered.
[in]AuthenticationOperationOperation type is specified for the registered handler.
Return values
EFI_SUCCESSThe handlers were registered successfully.

Definition at line 142 of file DxeSecurityManagementLib.c.

Variable Documentation

◆ mCurrentAuthOperation

UINT32 mCurrentAuthOperation = 0

Definition at line 39 of file DxeSecurityManagementLib.c.

◆ mCurrentAuthOperation2

UINT32 mCurrentAuthOperation2 = 0

Definition at line 44 of file DxeSecurityManagementLib.c.

◆ mMaxNumberOfSecurity2Handler

UINT32 mMaxNumberOfSecurity2Handler = 0

Definition at line 46 of file DxeSecurityManagementLib.c.

◆ mMaxNumberOfSecurityHandler

UINT32 mMaxNumberOfSecurityHandler = 0

Definition at line 41 of file DxeSecurityManagementLib.c.

◆ mNumberOfSecurity2Handler

UINT32 mNumberOfSecurity2Handler = 0

Definition at line 45 of file DxeSecurityManagementLib.c.

◆ mNumberOfSecurityHandler

UINT32 mNumberOfSecurityHandler = 0

Definition at line 40 of file DxeSecurityManagementLib.c.

◆ mSecurity2Table

SECURITY2_INFO* mSecurity2Table = NULL

Definition at line 47 of file DxeSecurityManagementLib.c.

◆ mSecurityTable

SECURITY_INFO* mSecurityTable = NULL

Definition at line 42 of file DxeSecurityManagementLib.c.