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