]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.c
37dfad8cd8648ded8957c3f2443797d4b0685dde
[mirror_edk2.git] / MdeModulePkg / Universal / Security / SecurityStub / Dxe / SecurityStub.c
1 /*++
2
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12 Module Name:
13
14 SecurityStub.c
15
16 Abstract:
17
18 This driver supports platform security service
19
20 --*/
21
22 //
23 // Include common header file for this module.
24 //
25 #include "CommonHeader.h"
26
27 #include "SecurityStub.h"
28
29 //
30 // Handle for the Security Architectural Protocol instance produced by this driver
31 //
32 EFI_HANDLE mSecurityArchProtocolHandle = NULL;
33
34 //
35 // Security Architectural Protocol instance produced by this driver
36 //
37 EFI_SECURITY_ARCH_PROTOCOL mSecurityStub = {
38 SecurityStubAuthenticateState
39 };
40
41 //
42 // Worker functions
43 //
44 EFI_STATUS
45 EFIAPI
46 SecurityStubAuthenticateState (
47 IN EFI_SECURITY_ARCH_PROTOCOL *This,
48 IN UINT32 AuthenticationStatus,
49 IN EFI_DEVICE_PATH_PROTOCOL *File
50 )
51 /*++
52
53 Routine Description:
54
55 The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific
56 policy from the DXE core response to an attempt to use a file that returns a
57 given status for the authentication check from the section extraction protocol.
58
59 The possible responses in a given SAP implementation may include locking
60 flash upon failure to authenticate, attestation logging for all signed drivers,
61 and other exception operations. The File parameter allows for possible logging
62 within the SAP of the driver.
63
64 If File is NULL, then EFI_INVALID_PARAMETER is returned.
65
66 If the file specified by File with an authentication status specified by
67 AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
68
69 If the file specified by File with an authentication status specified by
70 AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
71 then EFI_ACCESS_DENIED is returned.
72
73 If the file specified by File with an authentication status specified by
74 AuthenticationStatus is not safe for the DXE Core to use right now, but it
75 might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
76 returned.
77
78 Arguments:
79
80 This - The EFI_SECURITY_ARCH_PROTOCOL instance.
81
82 AuthenticationStatus - This is the authentication type returned from the Section
83 Extraction protocol. See the Section Extraction Protocol
84 Specification for details on this type.
85
86 File - This is a pointer to the device path of the file that is
87 being dispatched. This will optionally be used for logging.
88
89 Returns:
90
91 EFI_SUCCESS - The file specified by File did authenticate, and the
92 platform policy dictates that the DXE Core may use File.
93
94 EFI_INVALID_PARAMETER - File is NULL.
95
96 EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and
97 the platform policy dictates that File should be placed
98 in the untrusted state. A file may be promoted from
99 the untrusted to the trusted state at a future time
100 with a call to the Trust() DXE Service.
101
102 EFI_ACCESS_DENIED - The file specified by File did not authenticate, and
103 the platform policy dictates that File should not be
104 used for any purpose.
105
106 --*/
107 {
108 if (File == NULL) {
109 return EFI_INVALID_PARAMETER;
110 }
111
112 return EFI_SUCCESS;
113 }
114
115 EFI_STATUS
116 EFIAPI
117 SecurityStubInitialize (
118 IN EFI_HANDLE ImageHandle,
119 IN EFI_SYSTEM_TABLE *SystemTable
120 )
121 /*++
122
123 Routine Description:
124
125 Initialize the state information for the Security Architectural Protocol
126
127 Arguments:
128
129 ImageHandle of the loaded driver
130 Pointer to the System Table
131
132 Returns:
133
134 Status
135
136 EFI_SUCCESS - successful installation of the service
137 EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure
138 EFI_DEVICE_ERROR - cannot create the timer service
139
140 --*/
141 {
142 EFI_STATUS Status;
143
144 //
145 // Make sure the Security Architectural Protocol is not already installed in the system
146 //
147 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid);
148
149 //
150 // Install the Security Architectural Protocol onto a new handle
151 //
152 Status = gBS->InstallMultipleProtocolInterfaces (
153 &mSecurityArchProtocolHandle,
154 &gEfiSecurityArchProtocolGuid,
155 &mSecurityStub,
156 NULL
157 );
158 ASSERT_EFI_ERROR (Status);
159
160 return Status;
161 }