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