]>
Commit | Line | Data |
---|---|---|
cd98f305 LG |
1 | /** @file\r |
2 | This library class defines a set of interfaces to abstract the policy of \r | |
3 | security measurement by managing the different security measurement services.\r | |
4 | The library instances can be implemented according to the different security policy.\r | |
5 | \r | |
bc2dfdbc | 6 | Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r |
64a80549 | 7 | This program and the accompanying materials are licensed and made available under \r |
8 | the terms and conditions of the BSD License that accompanies this distribution. \r | |
9 | The full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php. \r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
cd98f305 LG |
14 | \r |
15 | **/\r | |
16 | \r | |
17 | #ifndef __SECURITY_MANAGEMENT_LIB_H__\r | |
18 | #define __SECURITY_MANAGEMENT_LIB_H__\r | |
19 | \r | |
bc2dfdbc LG |
20 | //\r |
21 | // Authentication Operation defintions for User Identity (UID), Measured and Secure boot.\r | |
22 | //\r | |
cd98f305 LG |
23 | #define EFI_AUTH_OPERATION_NONE 0x00\r |
24 | #define EFI_AUTH_OPERATION_VERIFY_IMAGE 0x01\r | |
25 | #define EFI_AUTH_OPERATION_DEFER_IMAGE_LOAD 0x02\r | |
26 | #define EFI_AUTH_OPERATION_MEASURE_IMAGE 0x04\r | |
bc2dfdbc LG |
27 | #define EFI_AUTH_OPERATION_CONNECT_POLICY 0x08\r |
28 | //\r | |
29 | // Authentication State Operation will check the authentication status of a file.\r | |
30 | //\r | |
31 | #define EFI_AUTH_OPERATION_AUTHENTICATION_STATE 0x10\r | |
cd98f305 LG |
32 | \r |
33 | ///\r | |
64a80549 | 34 | /// Image buffer is required by the security handler.\r |
cd98f305 LG |
35 | ///\r |
36 | #define EFI_AUTH_OPERATION_IMAGE_REQUIRED 0x80000000\r | |
37 | \r | |
38 | /**\r | |
39 | The security handler is used to abstract platform-specific policy \r | |
40 | from the DXE core response to an attempt to use a file that returns a \r | |
41 | given status for the authentication check from the section extraction protocol. \r | |
42 | \r | |
43 | The possible responses in a given SAP implementation may include locking \r | |
44 | flash upon failure to authenticate, attestation logging for all signed drivers, \r | |
45 | and other exception operations. The File parameter allows for possible logging \r | |
46 | within the SAP of the driver.\r | |
47 | \r | |
48 | If File is NULL, then EFI_INVALID_PARAMETER is returned.\r | |
49 | \r | |
50 | If the file specified by File with an authentication status specified by \r | |
51 | AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.\r | |
52 | \r | |
53 | If the file specified by File with an authentication status specified by \r | |
54 | AuthenticationStatus is not safe for the DXE Core to use under any circumstances, \r | |
55 | then EFI_ACCESS_DENIED is returned.\r | |
56 | \r | |
57 | If the file specified by File with an authentication status specified by \r | |
64a80549 | 58 | AuthenticationStatus is not safe for the DXE Core to use at the time, but it \r |
cd98f305 LG |
59 | might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is \r |
60 | returned.\r | |
61 | \r | |
62 | FileBuffer will be NULL and FileSize will be 0 if the handler being called \r | |
64a80549 | 63 | did not set EFI_AUTH_OPERATION_IMAGE_REQUIRED when it was registered.\r |
cd98f305 LG |
64 | \r |
65 | @param[in] AuthenticationStatus \r | |
64a80549 | 66 | The authentication status returned from the security\r |
cd98f305 | 67 | measurement services for the input file.\r |
64a80549 | 68 | @param[in] File The pointer to the device path of the file that is\r |
cd98f305 | 69 | being dispatched. This will optionally be used for logging.\r |
64a80549 | 70 | @param[in] FileBuffer The file buffer matches the input file device path.\r |
71 | @param[in] FileSize The size of File buffer matches the input file device path.\r | |
cd98f305 LG |
72 | \r |
73 | @retval EFI_SUCCESS The file specified by File did authenticate, and the\r | |
74 | platform policy dictates that the DXE Core may use File.\r | |
64a80549 | 75 | @retval EFI_INVALID_PARAMETER The file is NULL.\r |
cd98f305 LG |
76 | @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and\r |
77 | the platform policy dictates that File should be placed\r | |
78 | in the untrusted state. A file may be promoted from\r | |
79 | the untrusted to the trusted state at a future time\r | |
80 | with a call to the Trust() DXE Service.\r | |
81 | @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and\r | |
82 | the platform policy dictates that File should not be\r | |
83 | used for any purpose.\r | |
84 | \r | |
85 | **/\r | |
86 | typedef \r | |
87 | EFI_STATUS\r | |
88 | (EFIAPI *SECURITY_FILE_AUTHENTICATION_STATE_HANDLER)(\r | |
89 | IN OUT UINT32 AuthenticationStatus,\r | |
90 | IN CONST EFI_DEVICE_PATH_PROTOCOL *File,\r | |
91 | IN VOID *FileBuffer,\r | |
92 | IN UINTN FileSize\r | |
93 | );\r | |
94 | \r | |
95 | /**\r | |
64a80549 | 96 | Register security measurement handler with its operation type. Different\r |
97 | handlers with the same operation can all be registered.\r | |
cd98f305 LG |
98 | \r |
99 | If SecurityHandler is NULL, then ASSERT().\r | |
100 | If no enough resources available to register new handler, then ASSERT().\r | |
101 | If AuthenticationOperation is not recongnized, then ASSERT().\r | |
102 | If the previous register handler can't be executed before the later register handler, then ASSERT().\r | |
103 | \r | |
64a80549 | 104 | @param[in] SecurityHandler The security measurement service handler to be registered.\r |
105 | @param[in] AuthenticationOperation Theoperation type is specified for the registered handler.\r | |
cd98f305 LG |
106 | \r |
107 | @retval EFI_SUCCESS The handlers were registered successfully.\r | |
108 | **/\r | |
109 | EFI_STATUS\r | |
110 | EFIAPI\r | |
111 | RegisterSecurityHandler (\r | |
112 | IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,\r | |
113 | IN UINT32 AuthenticationOperation\r | |
114 | );\r | |
115 | \r | |
116 | /**\r | |
117 | Execute registered handlers until one returns an error and that error is returned.\r | |
118 | If none of the handlers return an error, then EFI_SUCCESS is returned.\r | |
119 | \r | |
120 | Before exectue handler, get the image buffer by file device path if a handler \r | |
121 | requires the image file. And return the image buffer to each handler when exectue handler.\r | |
122 | \r | |
123 | The handlers are executed in same order to their registered order.\r | |
124 | \r | |
125 | @param[in] AuthenticationStatus \r | |
126 | This is the authentication type returned from the Section\r | |
127 | Extraction protocol. See the Section Extraction Protocol\r | |
128 | Specification for details on this type.\r | |
129 | @param[in] FilePath This is a pointer to the device path of the file that is\r | |
130 | being dispatched. This will optionally be used for logging.\r | |
131 | \r | |
64a80549 | 132 | @retval EFI_SUCCESS The file specified by File authenticated when more\r |
cd98f305 LG |
133 | than one security handler services were registered, \r |
134 | or the file did not authenticate when no security \r | |
135 | handler service was registered. And the platform policy \r | |
136 | dictates that the DXE Core may use File.\r | |
137 | @retval EFI_INVALID_PARAMETER File is NULL.\r | |
138 | @retval EFI_SECURITY_VIOLATION The file specified by File did not authenticate, and\r | |
139 | the platform policy dictates that File should be placed\r | |
140 | in the untrusted state. A file may be promoted from\r | |
141 | the untrusted to the trusted state at a future time\r | |
142 | with a call to the Trust() DXE Service.\r | |
143 | @retval EFI_ACCESS_DENIED The file specified by File did not authenticate, and\r | |
144 | the platform policy dictates that File should not be\r | |
145 | used for any purpose.\r | |
146 | **/\r | |
147 | EFI_STATUS\r | |
148 | EFIAPI\r | |
149 | ExecuteSecurityHandlers (\r | |
150 | IN UINT32 AuthenticationStatus,\r | |
151 | IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath\r | |
152 | );\r | |
153 | \r | |
bc2dfdbc LG |
154 | /**\r |
155 | The security handler is used to abstracts security-specific functions from the DXE \r | |
156 | Foundation of UEFI Image Verification, Trusted Computing Group (TCG) measured boot, \r | |
157 | User Identity policy for image loading and consoles, and for purposes of \r | |
158 | handling GUIDed section encapsulations. \r | |
159 | \r | |
160 | @param[in] AuthenticationStatus \r | |
161 | The authentication status for the input file. \r | |
162 | @param[in] File The pointer to the device path of the file that is\r | |
163 | being dispatched. This will optionally be used for logging.\r | |
164 | @param[in] FileBuffer A pointer to the buffer with the UEFI file image\r | |
165 | @param[in] FileSize The size of File buffer.\r | |
166 | @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.\r | |
167 | \r | |
168 | @retval EFI_SUCCESS The file specified by DevicePath and non-NULL\r | |
169 | FileBuffer did authenticate, and the platform policy dictates\r | |
170 | that the DXE Foundation may use the file.\r | |
171 | @retval EFI_SUCCESS The device path specified by NULL device path DevicePath\r | |
172 | and non-NULL FileBuffer did authenticate, and the platform\r | |
173 | policy dictates that the DXE Foundation may execute the image in\r | |
174 | FileBuffer.\r | |
175 | @retval EFI_SUCCESS FileBuffer is NULL and current user has permission to start\r | |
176 | UEFI device drivers on the device path specified by DevicePath.\r | |
177 | @retval EFI_SECURITY_VIOLATION The file specified by DevicePath and FileBuffer did not\r | |
178 | authenticate, and the platform policy dictates that the file should be\r | |
179 | placed in the untrusted state. The image has been added to the file\r | |
180 | execution table.\r | |
181 | @retval EFI_ACCESS_DENIED The file specified by File and FileBuffer did not\r | |
182 | authenticate, and the platform policy dictates that the DXE\r | |
183 | Foundation may not use File.\r | |
184 | @retval EFI_SECURITY_VIOLATION FileBuffer is NULL and the user has no\r | |
185 | permission to start UEFI device drivers on the device path specified\r | |
186 | by DevicePath.\r | |
187 | @retval EFI_SECURITY_VIOLATION FileBuffer is not NULL and the user has no permission to load\r | |
188 | drivers from the device path specified by DevicePath. The\r | |
189 | image has been added into the list of the deferred images.\r | |
190 | **/\r | |
191 | typedef \r | |
192 | EFI_STATUS\r | |
193 | (EFIAPI *SECURITY2_FILE_AUTHENTICATION_HANDLER) (\r | |
194 | IN UINT32 AuthenticationStatus,\r | |
195 | IN CONST EFI_DEVICE_PATH_PROTOCOL *File,\r | |
196 | IN VOID *FileBuffer,\r | |
197 | IN UINTN FileSize,\r | |
198 | IN BOOLEAN BootPolicy\r | |
199 | );\r | |
200 | \r | |
201 | /**\r | |
202 | Register security measurement handler with its operation type. Different\r | |
203 | handlers with the same operation can all be registered.\r | |
204 | \r | |
205 | If SecurityHandler is NULL, then ASSERT().\r | |
206 | If no enough resources available to register new handler, then ASSERT().\r | |
207 | If AuthenticationOperation is not recongnized, then ASSERT().\r | |
208 | If AuthenticationOperation is EFI_AUTH_OPERATION_NONE, then ASSERT().\r | |
209 | If the previous register handler can't be executed before the later register handler, then ASSERT().\r | |
210 | \r | |
211 | @param[in] Security2Handler The security measurement service handler to be registered.\r | |
212 | @param[in] AuthenticationOperation The operation type is specified for the registered handler.\r | |
213 | \r | |
214 | @retval EFI_SUCCESS The handlers were registered successfully.\r | |
215 | **/\r | |
216 | EFI_STATUS\r | |
217 | EFIAPI\r | |
218 | RegisterSecurity2Handler (\r | |
219 | IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,\r | |
220 | IN UINT32 AuthenticationOperation\r | |
221 | );\r | |
222 | \r | |
223 | /**\r | |
224 | Execute registered handlers based on input AuthenticationOperation until \r | |
225 | one returns an error and that error is returned. \r | |
226 | \r | |
227 | If none of the handlers return an error, then EFI_SUCCESS is returned.\r | |
228 | The handlers those satisfy AuthenticationOperation will only be executed.\r | |
229 | The handlers are executed in same order to their registered order.\r | |
230 | \r | |
231 | @param[in] AuthenticationOperation \r | |
232 | The operation type specifies which handlers will be executed.\r | |
233 | @param[in] AuthenticationStatus \r | |
234 | The authentication status for the input file.\r | |
235 | @param[in] File This is a pointer to the device path of the file that is\r | |
236 | being dispatched. This will optionally be used for logging.\r | |
237 | @param[in] FileBuffer A pointer to the buffer with the UEFI file image\r | |
238 | @param[in] FileSize The size of File buffer.\r | |
239 | @param[in] BootPolicy A boot policy that was used to call LoadImage() UEFI service.\r | |
240 | \r | |
241 | @retval EFI_SUCCESS The file specified by DevicePath and non-NULL\r | |
242 | FileBuffer did authenticate, and the platform policy dictates\r | |
243 | that the DXE Foundation may use the file.\r | |
244 | @retval EFI_SUCCESS The device path specified by NULL device path DevicePath\r | |
245 | and non-NULL FileBuffer did authenticate, and the platform\r | |
246 | policy dictates that the DXE Foundation may execute the image in\r | |
247 | FileBuffer.\r | |
248 | @retval EFI_SUCCESS FileBuffer is NULL and current user has permission to start\r | |
249 | UEFI device drivers on the device path specified by DevicePath.\r | |
250 | @retval EFI_SECURITY_VIOLATION The file specified by DevicePath and FileBuffer did not\r | |
251 | authenticate, and the platform policy dictates that the file should be\r | |
252 | placed in the untrusted state. The image has been added to the file\r | |
253 | execution table.\r | |
254 | @retval EFI_ACCESS_DENIED The file specified by File and FileBuffer did not\r | |
255 | authenticate, and the platform policy dictates that the DXE\r | |
256 | Foundation may not use File.\r | |
257 | @retval EFI_SECURITY_VIOLATION FileBuffer is NULL and the user has no\r | |
258 | permission to start UEFI device drivers on the device path specified\r | |
259 | by DevicePath.\r | |
260 | @retval EFI_SECURITY_VIOLATION FileBuffer is not NULL and the user has no permission to load\r | |
261 | drivers from the device path specified by DevicePath. The\r | |
262 | image has been added into the list of the deferred images.\r | |
263 | @retval EFI_INVALID_PARAMETER File and FileBuffer are both NULL. \r | |
264 | **/\r | |
265 | EFI_STATUS\r | |
266 | EFIAPI\r | |
267 | ExecuteSecurity2Handlers (\r | |
268 | IN UINT32 AuthenticationOperation,\r | |
269 | IN UINT32 AuthenticationStatus,\r | |
270 | IN CONST EFI_DEVICE_PATH_PROTOCOL *File,\r | |
271 | IN VOID *FileBuffer,\r | |
272 | IN UINTN FileSize,\r | |
273 | IN BOOLEAN BootPolicy\r | |
274 | );\r | |
275 | \r | |
cd98f305 | 276 | #endif\r |