]> git.proxmox.com Git - mirror_edk2.git/blob - EdkModulePkg/Universal/Security/SecurityStub/Dxe/SecurityStub.c
Initial import.
[mirror_edk2.git] / EdkModulePkg / 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 #include "SecurityStub.h"
23
24 //
25 // Handle for the Security Architectural Protocol instance produced by this driver
26 //
27 EFI_HANDLE mSecurityArchProtocolHandle = NULL;
28
29 //
30 // Security Architectural Protocol instance produced by this driver
31 //
32 EFI_SECURITY_ARCH_PROTOCOL mSecurityStub = {
33 SecurityStubAuthenticateState
34 };
35
36 //
37 // Worker functions
38 //
39 EFI_STATUS
40 EFIAPI
41 SecurityStubAuthenticateState (
42 IN EFI_SECURITY_ARCH_PROTOCOL *This,
43 IN UINT32 AuthenticationStatus,
44 IN EFI_DEVICE_PATH_PROTOCOL *File
45 )
46 /*++
47
48 Routine Description:
49
50 The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific
51 policy from the DXE core response to an attempt to use a file that returns a
52 given status for the authentication check from the section extraction protocol.
53
54 The possible responses in a given SAP implementation may include locking
55 flash upon failure to authenticate, attestation logging for all signed drivers,
56 and other exception operations. The File parameter allows for possible logging
57 within the SAP of the driver.
58
59 If File is NULL, then EFI_INVALID_PARAMETER is returned.
60
61 If the file specified by File with an authentication status specified by
62 AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
63
64 If the file specified by File with an authentication status specified by
65 AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
66 then EFI_ACCESS_DENIED is returned.
67
68 If the file specified by File with an authentication status specified by
69 AuthenticationStatus is not safe for the DXE Core to use right now, but it
70 might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
71 returned.
72
73 Arguments:
74
75 This - The EFI_SECURITY_ARCH_PROTOCOL instance.
76
77 AuthenticationStatus - This is the authentication type returned from the Section
78 Extraction protocol. See the Section Extraction Protocol
79 Specification for details on this type.
80
81 File - This is a pointer to the device path of the file that is
82 being dispatched. This will optionally be used for logging.
83
84 Returns:
85
86 EFI_SUCCESS - The file specified by File did authenticate, and the
87 platform policy dictates that the DXE Core may use File.
88
89 EFI_INVALID_PARAMETER - File is NULL.
90
91 EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and
92 the platform policy dictates that File should be placed
93 in the untrusted state. A file may be promoted from
94 the untrusted to the trusted state at a future time
95 with a call to the Trust() DXE Service.
96
97 EFI_ACCESS_DENIED - The file specified by File did not authenticate, and
98 the platform policy dictates that File should not be
99 used for any purpose.
100
101 --*/
102 {
103 if (File == NULL) {
104 return EFI_INVALID_PARAMETER;
105 }
106
107 return EFI_SUCCESS;
108 }
109
110 EFI_STATUS
111 EFIAPI
112 SecurityStubInitialize (
113 IN EFI_HANDLE ImageHandle,
114 IN EFI_SYSTEM_TABLE *SystemTable
115 )
116 /*++
117
118 Routine Description:
119
120 Initialize the state information for the Security Architectural Protocol
121
122 Arguments:
123
124 ImageHandle of the loaded driver
125 Pointer to the System Table
126
127 Returns:
128
129 Status
130
131 EFI_SUCCESS - successful installation of the service
132 EFI_OUT_OF_RESOURCES - cannot allocate protocol data structure
133 EFI_DEVICE_ERROR - cannot create the timer service
134
135 --*/
136 {
137 EFI_STATUS Status;
138
139 //
140 // Make sure the Security Architectural Protocol is not already installed in the system
141 //
142 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiSecurityArchProtocolGuid);
143
144 //
145 // Install the Security Architectural Protocol onto a new handle
146 //
147 Status = gBS->InstallMultipleProtocolInterfaces (
148 &mSecurityArchProtocolHandle,
149 &gEfiSecurityArchProtocolGuid,
150 &mSecurityStub,
151 NULL
152 );
153 ASSERT_EFI_ERROR (Status);
154
155 return Status;
156 }