]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/SecurityStubDxe/SecurityStub.c
Add new SecurityManagementLib, and update SecurityStub driver to use this lib.
[mirror_edk2.git] / MdeModulePkg / Universal / SecurityStubDxe / SecurityStub.c
CommitLineData
ce2f5557 1/** @file\r
cd98f305
LG
2 This driver produces security architectural protocol based on SecurityManagementLib.\r
3 \r
4 Copyright (c) 2006 - 2009, Intel Corporation \r
ce2f5557 5 All rights reserved. This program and the accompanying materials \r
6 are licensed and made available under the terms and conditions of the BSD License \r
7 which accompanies this distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15\r
109e9a61
LG
16#include <Uefi.h>\r
17#include <Protocol/Security.h>\r
18#include <Library/DebugLib.h>\r
19#include <Library/UefiBootServicesTableLib.h>\r
20#include <Library/UefiDriverEntryPoint.h>\r
cd98f305 21#include <Library/SecurityManagementLib.h>\r
ce2f5557 22\r
23//\r
24// Handle for the Security Architectural Protocol instance produced by this driver\r
25//\r
26EFI_HANDLE mSecurityArchProtocolHandle = NULL;\r
27\r
ce2f5557 28/**\r
29 The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific \r
30 policy from the DXE core response to an attempt to use a file that returns a \r
31 given status for the authentication check from the section extraction protocol. \r
32\r
33 The possible responses in a given SAP implementation may include locking \r
34 flash upon failure to authenticate, attestation logging for all signed drivers, \r
35 and other exception operations. The File parameter allows for possible logging \r
36 within the SAP of the driver.\r
37\r
38 If File is NULL, then EFI_INVALID_PARAMETER is returned.\r
39\r
40 If the file specified by File with an authentication status specified by \r
41 AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r
42\r
43 If the file specified by File with an authentication status specified by \r
44 AuthenticationStatus is not safe for the DXE Core to use under any circumstances, \r
45 then EFI_ACCESS_DENIED is returned.\r
46\r
47 If the file specified by File with an authentication status specified by \r
48 AuthenticationStatus is not safe for the DXE Core to use right now, but it \r
49 might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is \r
50 returned.\r
51\r
52 @param This The EFI_SECURITY_ARCH_PROTOCOL instance.\r
53 @param AuthenticationStatus \r
54 This is the authentication type returned from the Section\r
55 Extraction protocol. See the Section Extraction Protocol\r
56 Specification for details on this type.\r
57 @param File This is a pointer to the device path of the file that is\r
58 being dispatched. This will optionally be used for logging.\r
59\r
109e9a61 60 @retval EFI_SUCCESS Do nothing and return success.\r
5d69642d 61 @retval EFI_INVALID_PARAMETER File is NULL.\r
ce2f5557 62**/\r
63EFI_STATUS\r
64EFIAPI\r
65SecurityStubAuthenticateState (\r
c48d41d2
LG
66 IN CONST EFI_SECURITY_ARCH_PROTOCOL *This,\r
67 IN UINT32 AuthenticationStatus,\r
68 IN CONST EFI_DEVICE_PATH_PROTOCOL *File\r
ce2f5557 69 )\r
70{\r
cd98f305 71 return ExecuteSecurityHandlers (AuthenticationStatus, File);\r
ce2f5557 72}\r
73\r
109e9a61
LG
74//\r
75// Security Architectural Protocol instance produced by this driver\r
76//\r
77EFI_SECURITY_ARCH_PROTOCOL mSecurityStub = { \r
78 SecurityStubAuthenticateState \r
79};\r
ce2f5557 80\r
81/**\r
109e9a61 82 Installs Security Architectural Protocol.\r
ce2f5557 83\r
109e9a61
LG
84 @param ImageHandle The image handle of this driver.\r
85 @param SystemTable A pointer to the EFI System Table.\r
ce2f5557 86 \r
5d69642d 87 @retval EFI_SUCCESS Install the sample Security Architectural Protocol successfully.\r
ce2f5557 88\r
89**/\r
90EFI_STATUS\r
91EFIAPI\r
92SecurityStubInitialize (\r
93 IN EFI_HANDLE ImageHandle,\r
94 IN EFI_SYSTEM_TABLE *SystemTable\r
95 )\r
96{\r
97 EFI_STATUS Status;\r
98\r
99 //\r
100 // Make sure the Security Architectural Protocol is not already installed in the system\r
101 //\r
102 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid);\r
103\r
104 //\r
105 // Install the Security Architectural Protocol onto a new handle\r
106 //\r
107 Status = gBS->InstallMultipleProtocolInterfaces (\r
108 &mSecurityArchProtocolHandle,\r
109 &gEfiSecurityArchProtocolGuid,\r
110 &mSecurityStub,\r
111 NULL\r
112 );\r
113 ASSERT_EFI_ERROR (Status);\r
114\r
5d69642d 115 return EFI_SUCCESS;\r
ce2f5557 116}\r