]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Include/Library/SecurityManagementLib.h
Add PI1.2.1 SAP2 support and UEFI231B mantis 896
[mirror_edk2.git] / MdeModulePkg / Include / Library / SecurityManagementLib.h
index 9f3b4886100516f1ed1385320a5ec257f7385776..de87d09c54c737f2a6f0a9e83a9719c3088aff7e 100644 (file)
@@ -3,7 +3,7 @@
   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
+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
@@ -17,10 +17,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #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
@@ -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