]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/SecurityManagementLib.h
MdeModulePkg/TcpIoLib: Check input Timeout before calling CheckEvent() service.
[mirror_edk2.git] / MdeModulePkg / Include / Library / SecurityManagementLib.h
index 0d24a730b7af3bc2908276796f4709a1dea0e756..de87d09c54c737f2a6f0a9e83a9719c3088aff7e 100644 (file)
@@ -3,27 +3,35 @@
   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, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  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 - 2012, 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
 \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 security handler.\r
+/// Image buffer is required by the security handler.\r
 ///\r
 #define EFI_AUTH_OPERATION_IMAGE_REQUIRED      0x80000000\r
 \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 right now, but it \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
-  has did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.\r
+  did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.\r
 \r
   @param[in]    AuthenticationStatus \r
-                           This is the authentication status returned from the security\r
+                           The authentication status returned from the security\r
                            measurement services for the input file.\r
-  @param[in]    File       This is a pointer to the device path of the file that is\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 File buffer matches the input file device path.\r
-  @param[in]    FileSize   Size of File buffer matches the input file device path.\r
+  @param[in]    FileBuffer The file buffer matches the input file device path.\r
+  @param[in]    FileSize   The size of File buffer matches the input file device path.\r
 \r
   @retval EFI_SUCCESS            The file specified by File did authenticate, and the\r
                                  platform policy dictates that the DXE Core may use File.\r
-  @retval EFI_INVALID_PARAMETER  File is NULL.\r
+  @retval EFI_INVALID_PARAMETER  The file is NULL.\r
   @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and\r
                                  the platform policy dictates that File should be placed\r
                                  in the untrusted state. A file may be promoted from\r
@@ -85,16 +93,16 @@ EFI_STATUS
   );\r
 \r
 /**\r
-  Register security measurement handler with its operation type. The different\r
-  handler with the same operation can all be registered.\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 the previous register handler can't be executed before the later register handler, then ASSERT().\r
 \r
-  @param[in]  SecurityHandler           Security measurement service handler to be registered.\r
-  @param[in]  AuthenticationOperation   Operation type is specified for the registered handler.\r
+  @param[in]  SecurityHandler           The security measurement service handler to be registered.\r
+  @param[in]  AuthenticationOperation   Theoperation type is specified for the registered handler.\r
 \r
   @retval EFI_SUCCESS              The handlers were registered successfully.\r
 **/\r
@@ -121,7 +129,7 @@ RegisterSecurityHandler (
   @param[in]  FilePath     This is a pointer to the device path of the file that is\r
                            being dispatched. This will optionally be used for logging.\r
 \r
-  @retval EFI_SUCCESS            The file specified by File did authenticate when more\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
@@ -143,4 +151,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