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