]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/SecurityManagementLib.h
MdeModulePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdeModulePkg / Include / Library / SecurityManagementLib.h
index 8800082a0fba95eab9398daa2cbbe8535cb22598..c6ef8c38b9b797cfca44ed20c631604d2d6a000e 100644 (file)
@@ -1,26 +1,28 @@
 /** @file\r
-  This library class defines a set of interfaces to abstract the policy of \r
+  This library class defines a set of interfaces to abstract the policy of\r
   security measurement by managing the different security measurement services.\r
   The library instances can be implemented according to the different security policy.\r
 \r
-Copyright (c) 2009 - 2010, Intel Corporation.  All rights reserved<BR>\r
-This program and the accompanying materials are licensed and made available under \r
-the terms and conditions of the BSD License that accompanies this distribution.  \r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.                                            \r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
 \r
 #ifndef __SECURITY_MANAGEMENT_LIB_H__\r
 #define __SECURITY_MANAGEMENT_LIB_H__\r
 \r
+//\r
+// Authentication Operation defintions for User Identity (UID), Measured and Secure boot.\r
+//\r
 #define EFI_AUTH_OPERATION_NONE                0x00\r
 #define EFI_AUTH_OPERATION_VERIFY_IMAGE        0x01\r
 #define EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD    0x02\r
 #define EFI_AUTH_OPERATION_MEASURE_IMAGE       0x04\r
+#define EFI_AUTH_OPERATION_CONNECT_POLICY      0x08\r
+//\r
+// Authentication State Operation will check the authentication status of a file.\r
+//\r
+#define EFI_AUTH_OPERATION_AUTHENTICATION_STATE  0x10\r
 \r
 ///\r
 /// Image buffer is required by the security handler.\r
@@ -28,33 +30,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #define EFI_AUTH_OPERATION_IMAGE_REQUIRED      0x80000000\r
 \r
 /**\r
-  The security handler is used to abstract platform-specific policy \r
-  from the DXE core response to an attempt to use a file that returns a \r
-  given status for the authentication check from the section extraction protocol.  \r
+  The security handler is used to abstract platform-specific policy\r
+  from the DXE core response to an attempt to use a file that returns a\r
+  given status for the authentication check from the section extraction protocol.\r
 \r
-  The possible responses in a given SAP implementation may include locking \r
-  flash upon failure to authenticate, attestation logging for all signed drivers, \r
-  and other exception operations.  The File parameter allows for possible logging \r
+  The possible responses in a given SAP implementation may include locking\r
+  flash upon failure to authenticate, attestation logging for all signed drivers,\r
+  and other exception operations.  The File parameter allows for possible logging\r
   within the SAP of the driver.\r
-  \r
+\r
   If File is NULL, then EFI_INVALID_PARAMETER is returned.\r
 \r
-  If the file specified by File with an authentication status specified by \r
+  If the file specified by File with an authentication status specified by\r
   AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r
 \r
-  If the file specified by File with an authentication status specified by \r
-  AuthenticationStatus is not safe for the DXE Core to use under any circumstances, \r
+  If the file specified by File with an authentication status specified by\r
+  AuthenticationStatus is not safe for the DXE Core to use under any circumstances,\r
   then EFI_ACCESS_DENIED is returned.\r
 \r
-  If the file specified by File with an authentication status specified by \r
-  AuthenticationStatus is not safe for the DXE Core to use at the time, but it \r
-  might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is \r
+  If the file specified by File with an authentication status specified by\r
+  AuthenticationStatus is not safe for the DXE Core to use at the time, but it\r
+  might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is\r
   returned.\r
 \r
-  FileBuffer will be NULL and FileSize will be 0 if the handler being called \r
+  FileBuffer will be NULL and FileSize will be 0 if the handler being called\r
   did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.\r
 \r
-  @param[in]    AuthenticationStatus \r
+  @param[in]    AuthenticationStatus\r
                            The authentication status returned from the security\r
                            measurement services for the input file.\r
   @param[in]    File       The pointer to the device path of the file that is\r
@@ -75,7 +77,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
                                  used for any purpose.\r
 \r
 **/\r
-typedef \r
+typedef\r
 EFI_STATUS\r
 (EFIAPI *SECURITY_FILE_AUTHENTICATION_STATE_HANDLER)(\r
   IN  OUT   UINT32                     AuthenticationStatus,\r
@@ -109,12 +111,12 @@ RegisterSecurityHandler (
   Execute registered handlers until one returns an error and that error is returned.\r
   If none of the handlers return an error, then EFI_SUCCESS is returned.\r
 \r
-  Before exectue handler, get the image buffer by file device path if a handler \r
+  Before exectue handler, get the image buffer by file device path if a handler\r
   requires the image file. And return the image buffer to each handler when exectue handler.\r
 \r
   The handlers are executed in same order to their registered order.\r
 \r
-  @param[in]  AuthenticationStatus \r
+  @param[in]  AuthenticationStatus\r
                            This is the authentication type returned from the Section\r
                            Extraction protocol. See the Section Extraction Protocol\r
                            Specification for details on this type.\r
@@ -122,9 +124,9 @@ RegisterSecurityHandler (
                            being dispatched. This will optionally be used for logging.\r
 \r
   @retval EFI_SUCCESS            The file specified by File authenticated when more\r
-                                 than one security handler services were registered, \r
-                                 or the file did not authenticate when no security \r
-                                 handler service was registered. And the platform policy \r
+                                 than one security handler services were registered,\r
+                                 or the file did not authenticate when no security\r
+                                 handler service was registered. And the platform policy\r
                                  dictates that the DXE Core may use File.\r
   @retval EFI_INVALID_PARAMETER  File is NULL.\r
   @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and\r
@@ -143,4 +145,126 @@ ExecuteSecurityHandlers (
   IN  CONST EFI_DEVICE_PATH_PROTOCOL    *FilePath\r
   );\r
 \r
+/**\r
+  The security handler is used to abstracts security-specific functions from the DXE\r
+  Foundation of UEFI Image Verification, Trusted Computing Group (TCG) measured boot,\r
+  User Identity policy for image loading and consoles, and for purposes of\r
+  handling GUIDed section encapsulations.\r
+\r
+  @param[in]    AuthenticationStatus\r
+                           The authentication status for the input file.\r
+  @param[in]    File       The pointer to the device path of the file that is\r
+                           being dispatched. This will optionally be used for logging.\r
+  @param[in]    FileBuffer A pointer to the buffer with the UEFI file image\r
+  @param[in]    FileSize   The size of File buffer.\r
+  @param[in]    BootPolicy A boot policy that was used to call LoadImage() UEFI service.\r
+\r
+  @retval EFI_SUCCESS             The file specified by DevicePath and non-NULL\r
+                                  FileBuffer did authenticate, and the platform policy dictates\r
+                                  that the DXE Foundation may use the file.\r
+  @retval EFI_SUCCESS             The device path specified by NULL device path DevicePath\r
+                                  and non-NULL FileBuffer did authenticate, and the platform\r
+                                  policy dictates that the DXE Foundation may execute the image in\r
+                                  FileBuffer.\r
+  @retval EFI_SUCCESS             FileBuffer is NULL and current user has permission to start\r
+                                  UEFI device drivers on the device path specified by DevicePath.\r
+  @retval EFI_SECURITY_VIOLATION  The file specified by DevicePath and FileBuffer did not\r
+                                  authenticate, and the platform policy dictates that the file should be\r
+                                  placed in the untrusted state. The image has been added to the file\r
+                                  execution table.\r
+  @retval EFI_ACCESS_DENIED       The file specified by File and FileBuffer did not\r
+                                  authenticate, and the platform policy dictates that the DXE\r
+                                  Foundation may not use File.\r
+  @retval EFI_SECURITY_VIOLATION  FileBuffer is NULL and the user has no\r
+                                  permission to start UEFI device drivers on the device path specified\r
+                                  by DevicePath.\r
+  @retval EFI_SECURITY_VIOLATION  FileBuffer is not NULL and the user has no permission to load\r
+                                  drivers from the device path specified by DevicePath. The\r
+                                  image has been added into the list of the deferred images.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SECURITY2_FILE_AUTHENTICATION_HANDLER) (\r
+  IN  UINT32                           AuthenticationStatus,\r
+  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File,\r
+  IN  VOID                             *FileBuffer,\r
+  IN  UINTN                            FileSize,\r
+  IN  BOOLEAN                          BootPolicy\r
+  );\r
+\r
+/**\r
+  Register security measurement handler with its operation type. Different\r
+  handlers with the same operation can all be registered.\r
+\r
+  If SecurityHandler is NULL, then ASSERT().\r
+  If no enough resources available to register new handler, then ASSERT().\r
+  If AuthenticationOperation is not recongnized, then ASSERT().\r
+  If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, then ASSERT().\r
+  If the previous register handler can't be executed before the later register handler, then ASSERT().\r
+\r
+  @param[in]  Security2Handler          The security measurement service handler to be registered.\r
+  @param[in]  AuthenticationOperation   The operation type is specified for the registered handler.\r
+\r
+  @retval EFI_SUCCESS              The handlers were registered successfully.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RegisterSecurity2Handler (\r
+  IN  SECURITY2_FILE_AUTHENTICATION_HANDLER       Security2Handler,\r
+  IN  UINT32                                      AuthenticationOperation\r
+  );\r
+\r
+/**\r
+  Execute registered handlers based on input AuthenticationOperation until\r
+  one returns an error and that error is returned.\r
+\r
+  If none of the handlers return an error, then EFI_SUCCESS is returned.\r
+  The handlers those satisfy AuthenticationOperation will only be executed.\r
+  The handlers are executed in same order to their registered order.\r
+\r
+  @param[in]  AuthenticationOperation\r
+                           The operation type specifies which handlers will be executed.\r
+  @param[in]  AuthenticationStatus\r
+                           The authentication status for the input file.\r
+  @param[in]  File         This is a pointer to the device path of the file that is\r
+                           being dispatched. This will optionally be used for logging.\r
+  @param[in]  FileBuffer   A pointer to the buffer with the UEFI file image\r
+  @param[in]  FileSize     The size of File buffer.\r
+  @param[in]  BootPolicy   A boot policy that was used to call LoadImage() UEFI service.\r
+\r
+  @retval EFI_SUCCESS             The file specified by DevicePath and non-NULL\r
+                                  FileBuffer did authenticate, and the platform policy dictates\r
+                                  that the DXE Foundation may use the file.\r
+  @retval EFI_SUCCESS             The device path specified by NULL device path DevicePath\r
+                                  and non-NULL FileBuffer did authenticate, and the platform\r
+                                  policy dictates that the DXE Foundation may execute the image in\r
+                                  FileBuffer.\r
+  @retval EFI_SUCCESS             FileBuffer is NULL and current user has permission to start\r
+                                  UEFI device drivers on the device path specified by DevicePath.\r
+  @retval EFI_SECURITY_VIOLATION  The file specified by DevicePath and FileBuffer did not\r
+                                  authenticate, and the platform policy dictates that the file should be\r
+                                  placed in the untrusted state. The image has been added to the file\r
+                                  execution table.\r
+  @retval EFI_ACCESS_DENIED       The file specified by File and FileBuffer did not\r
+                                  authenticate, and the platform policy dictates that the DXE\r
+                                  Foundation may not use File.\r
+  @retval EFI_SECURITY_VIOLATION  FileBuffer is NULL and the user has no\r
+                                  permission to start UEFI device drivers on the device path specified\r
+                                  by DevicePath.\r
+  @retval EFI_SECURITY_VIOLATION  FileBuffer is not NULL and the user has no permission to load\r
+                                  drivers from the device path specified by DevicePath. The\r
+                                  image has been added into the list of the deferred images.\r
+  @retval EFI_INVALID_PARAMETER   File and FileBuffer are both NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ExecuteSecurity2Handlers (\r
+  IN  UINT32                           AuthenticationOperation,\r
+  IN  UINT32                           AuthenticationStatus,\r
+  IN  CONST EFI_DEVICE_PATH_PROTOCOL   *File,\r
+  IN  VOID                             *FileBuffer,\r
+  IN  UINTN                            FileSize,\r
+  IN  BOOLEAN                          BootPolicy\r
+  );\r
+\r
 #endif\r