]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Library/SecurityManagementLib.h
Clean up DEC files:
[mirror_edk2.git] / MdeModulePkg / Include / Library / SecurityManagementLib.h
1 /** @file
2 This library class defines a set of interfaces to abstract the policy of
3 security measurement by managing the different security measurement services.
4 The library instances can be implemented according to the different security policy.
5
6 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
7 This program and the accompanying materials are licensed and made available under
8 the terms and conditions of the BSD License that accompanies this distribution.
9 The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php.
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #ifndef __SECURITY_MANAGEMENT_LIB_H__
18 #define __SECURITY_MANAGEMENT_LIB_H__
19
20 #define EFI_AUTH_OPERATION_NONE 0x00
21 #define EFI_AUTH_OPERATION_VERIFY_IMAGE 0x01
22 #define EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD 0x02
23 #define EFI_AUTH_OPERATION_MEASURE_IMAGE 0x04
24
25 ///
26 /// Image buffer is required by the security handler.
27 ///
28 #define EFI_AUTH_OPERATION_IMAGE_REQUIRED 0x80000000
29
30 /**
31 The security handler is used to abstract platform-specific policy
32 from the DXE core response to an attempt to use a file that returns a
33 given status for the authentication check from the section extraction protocol.
34
35 The possible responses in a given SAP implementation may include locking
36 flash upon failure to authenticate, attestation logging for all signed drivers,
37 and other exception operations. The File parameter allows for possible logging
38 within the SAP of the driver.
39
40 If File is NULL, then EFI_INVALID_PARAMETER is returned.
41
42 If the file specified by File with an authentication status specified by
43 AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
44
45 If the file specified by File with an authentication status specified by
46 AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
47 then EFI_ACCESS_DENIED is returned.
48
49 If the file specified by File with an authentication status specified by
50 AuthenticationStatus is not safe for the DXE Core to use at the time, but it
51 might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
52 returned.
53
54 FileBuffer will be NULL and FileSize will be 0 if the handler being called
55 did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.
56
57 @param[in] AuthenticationStatus
58 The authentication status returned from the security
59 measurement services for the input file.
60 @param[in] File The pointer to the device path of the file that is
61 being dispatched. This will optionally be used for logging.
62 @param[in] FileBuffer The file buffer matches the input file device path.
63 @param[in] FileSize The size of File buffer matches the input file device path.
64
65 @retval EFI_SUCCESS The file specified by File did authenticate, and the
66 platform policy dictates that the DXE Core may use File.
67 @retval EFI_INVALID_PARAMETER The file is NULL.
68 @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
69 the platform policy dictates that File should be placed
70 in the untrusted state. A file may be promoted from
71 the untrusted to the trusted state at a future time
72 with a call to the Trust() DXE Service.
73 @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and
74 the platform policy dictates that File should not be
75 used for any purpose.
76
77 **/
78 typedef
79 EFI_STATUS
80 (EFIAPI *SECURITY_FILE_AUTHENTICATION_STATE_HANDLER)(
81 IN OUT UINT32 AuthenticationStatus,
82 IN CONST EFI_DEVICE_PATH_PROTOCOL *File,
83 IN VOID *FileBuffer,
84 IN UINTN FileSize
85 );
86
87 /**
88 Register security measurement handler with its operation type. Different
89 handlers with the same operation can all be registered.
90
91 If SecurityHandler is NULL, then ASSERT().
92 If no enough resources available to register new handler, then ASSERT().
93 If AuthenticationOperation is not recongnized, then ASSERT().
94 If the previous register handler can't be executed before the later register handler, then ASSERT().
95
96 @param[in] SecurityHandler The security measurement service handler to be registered.
97 @param[in] AuthenticationOperation Theoperation type is specified for the registered handler.
98
99 @retval EFI_SUCCESS The handlers were registered successfully.
100 **/
101 EFI_STATUS
102 EFIAPI
103 RegisterSecurityHandler (
104 IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,
105 IN UINT32 AuthenticationOperation
106 );
107
108 /**
109 Execute registered handlers until one returns an error and that error is returned.
110 If none of the handlers return an error, then EFI_SUCCESS is returned.
111
112 Before exectue handler, get the image buffer by file device path if a handler
113 requires the image file. And return the image buffer to each handler when exectue handler.
114
115 The handlers are executed in same order to their registered order.
116
117 @param[in] AuthenticationStatus
118 This is the authentication type returned from the Section
119 Extraction protocol. See the Section Extraction Protocol
120 Specification for details on this type.
121 @param[in] FilePath This is a pointer to the device path of the file that is
122 being dispatched. This will optionally be used for logging.
123
124 @retval EFI_SUCCESS The file specified by File authenticated when more
125 than one security handler services were registered,
126 or the file did not authenticate when no security
127 handler service was registered. And the platform policy
128 dictates that the DXE Core may use File.
129 @retval EFI_INVALID_PARAMETER File is NULL.
130 @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and
131 the platform policy dictates that File should be placed
132 in the untrusted state. A file may be promoted from
133 the untrusted to the trusted state at a future time
134 with a call to the Trust() DXE Service.
135 @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and
136 the platform policy dictates that File should not be
137 used for any purpose.
138 **/
139 EFI_STATUS
140 EFIAPI
141 ExecuteSecurityHandlers (
142 IN UINT32 AuthenticationStatus,
143 IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath
144 );
145
146 #endif