4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/** @file
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This library class defines a set of interfaces to abstract the policy of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync security measurement by managing the different security measurement services.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The library instances can be implemented according to the different security policy.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncCopyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThis program and the accompanying materials are licensed and made available under
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncthe terms and conditions of the BSD License that accompanies this distribution.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThe full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynchttp://opensource.org/licenses/bsd-license.php.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#ifndef __SECURITY_MANAGEMENT_LIB_H__
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define __SECURITY_MANAGEMENT_LIB_H__
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EFI_AUTH_OPERATION_NONE 0x00
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EFI_AUTH_OPERATION_VERIFY_IMAGE 0x01
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD 0x02
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EFI_AUTH_OPERATION_MEASURE_IMAGE 0x04
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync///
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/// Image buffer is required by the security handler.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync///
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#define EFI_AUTH_OPERATION_IMAGE_REQUIRED 0x80000000
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/**
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The security handler is used to abstract platform-specific policy
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync from the DXE core response to an attempt to use a file that returns a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync given status for the authentication check from the section extraction protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The possible responses in a given SAP implementation may include locking
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync flash upon failure to authenticate, attestation logging for all signed drivers,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and other exception operations. The File parameter allows for possible logging
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync within the SAP of the driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If File is NULL, then EFI_INVALID_PARAMETER is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the file specified by File with an authentication status specified by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the file specified by File with an authentication status specified by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync then EFI_ACCESS_DENIED is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the file specified by File with an authentication status specified by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync AuthenticationStatus is not safe for the DXE Core to use at the time, but it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync FileBuffer will be NULL and FileSize will be 0 if the handler being called
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] AuthenticationStatus
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The authentication status returned from the security
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync measurement services for the input file.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] File The pointer to the device path of the file that is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync being dispatched. This will optionally be used for logging.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] FileBuffer The file buffer matches the input file device path.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] FileSize The size of File buffer matches the input file device path.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The file specified by File did authenticate, and the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync platform policy dictates that the DXE Core may use File.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER The file is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the platform policy dictates that File should be placed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the untrusted state. A file may be promoted from
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the untrusted to the trusted state at a future time
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync with a call to the Trust() DXE Service.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the platform policy dictates that File should not be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync used for any purpose.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsynctypedef
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFI_STATUS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync(EFIAPI *SECURITY_FILE_AUTHENTICATION_STATE_HANDLER)(
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN OUT UINT32 AuthenticationStatus,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN VOID *FileBuffer,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN UINTN FileSize
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync );
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/**
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Register security measurement handler with its operation type. Different
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync handlers with the same operation can all be registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If SecurityHandler is NULL, then ASSERT().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If no enough resources available to register new handler, then ASSERT().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If AuthenticationOperation is not recongnized, then ASSERT().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the previous register handler can't be executed before the later register handler, then ASSERT().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] SecurityHandler The security measurement service handler to be registered.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] AuthenticationOperation Theoperation type is specified for the registered handler.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The handlers were registered successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFI_STATUS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFIAPI
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncRegisterSecurityHandler (
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN UINT32 AuthenticationOperation
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync );
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync/**
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Execute registered handlers until one returns an error and that error is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If none of the handlers return an error, then EFI_SUCCESS is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Before exectue handler, get the image buffer by file device path if a handler
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync requires the image file. And return the image buffer to each handler when exectue handler.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The handlers are executed in same order to their registered order.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] AuthenticationStatus
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This is the authentication type returned from the Section
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Extraction protocol. See the Section Extraction Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Specification for details on this type.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] FilePath This is a pointer to the device path of the file that is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync being dispatched. This will optionally be used for logging.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The file specified by File authenticated when more
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync than one security handler services were registered,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or the file did not authenticate when no security
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync handler service was registered. And the platform policy
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync dictates that the DXE Core may use File.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER File is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the platform policy dictates that File should be placed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the untrusted state. A file may be promoted from
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the untrusted to the trusted state at a future time
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync with a call to the Trust() DXE Service.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the platform policy dictates that File should not be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync used for any purpose.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync**/
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFI_STATUS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncEFIAPI
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncExecuteSecurityHandlers (
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN UINT32 AuthenticationStatus,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync );
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync#endif