Add security package to repository.
[mirror_edk2.git] / SecurityPkg / UserIdentification / UsbCredentialProviderDxe / UsbCredentialProvider.h
1 /** @file
2 Usb Credential Provider driver header file.
3
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 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 #ifndef _USB_CREDENTIAL_PROVIDER_H_
16 #define _USB_CREDENTIAL_PROVIDER_H_
17
18 #include <Uefi.h>
19
20 #include <Guid/GlobalVariable.h>
21 #include <Guid/MdeModuleHii.h>
22 #include <Guid/FileInfo.h>
23 #include <Guid/SecurityPkgTokenSpace.h>
24
25 #include <Protocol/SimpleFileSystem.h>
26 #include <Protocol/BlockIo.h>
27 #include <Protocol/UserCredential.h>
28 #include <Protocol/UserManager.h>
29
30 #include <Library/UefiRuntimeServicesTableLib.h>
31 #include <Library/UefiBootServicesTableLib.h>
32 #include <Library/MemoryAllocationLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/DevicePathLib.h>
35 #include <Library/BaseCryptLib.h>
36 #include <Library/DebugLib.h>
37 #include <Library/UefiLib.h>
38 #include <Library/PrintLib.h>
39 #include <Library/HiiLib.h>
40 #include <Library/PcdLib.h>
41
42 extern UINT8 UsbCredentialProviderStrings[];
43 extern UINT8 UsbCredentialProviderVfrBin[];
44
45 #define USB_TABLE_INC 16
46 #define HASHED_CREDENTIAL_LEN 20
47
48 #define USB_CREDENTIAL_PROVIDER_GUID \
49 { \
50 0xd0849ed1, 0xa88c, 0x4ba6, { 0xb1, 0xd6, 0xab, 0x50, 0xe2, 0x80, 0xb7, 0xa9 }\
51 }
52
53 //
54 // Save the enroll user credential Information.
55 //
56 typedef struct {
57 EFI_USER_INFO_IDENTIFIER UserId;
58 UINT8 Token[HASHED_CREDENTIAL_LEN];
59 } USB_INFO;
60
61 //
62 // USB Credential Table.
63 //
64 typedef struct {
65 UINTN Count;
66 UINTN MaxCount;
67 USB_INFO UserInfo[1];
68 } CREDENTIAL_TABLE;
69
70 //
71 // The user information on the USB provider.
72 //
73 typedef struct {
74 UINTN Count;
75 EFI_USER_INFO *Info[1];
76 } USB_CREDENTIAL_INFO;
77
78 ///
79 /// HII specific Vendor Device Path definition.
80 ///
81 typedef struct {
82 VENDOR_DEVICE_PATH VendorDevicePath;
83 EFI_DEVICE_PATH_PROTOCOL End;
84 } HII_VENDOR_DEVICE_PATH;
85
86 #define USB_PROVIDER_SIGNATURE SIGNATURE_32 ('U', 'S', 'B', 'P')
87
88 typedef struct {
89 UINTN Signature;
90 EFI_HANDLE DriverHandle;
91 EFI_HII_HANDLE HiiHandle;
92 } USB_PROVIDER_CALLBACK_INFO;
93
94 /**
95 Enroll a user on a credential provider.
96
97 This function enrolls and deletes a user profile using this credential provider.
98 If a user profile is successfully enrolled, it calls the User Manager Protocol
99 function Notify() to notify the user manager driver that credential information
100 has changed. If an enrolled user does exist, delete the user on the credential
101 provider.
102
103 @param[in] This Points to this instance of EFI_USER_CREDENTIAL_PROTOCOL.
104 @param[in] User The user profile to enroll.
105
106 @retval EFI_SUCCESS User profile was successfully enrolled.
107 @retval EFI_ACCESS_DENIED Current user profile does not permit enrollment on the
108 user profile handle. Either the user profile cannot enroll
109 on any user profile or cannot enroll on a user profile
110 other than the current user profile.
111 @retval EFI_UNSUPPORTED This credential provider does not support enrollment in
112 the pre-OS.
113 @retval EFI_DEVICE_ERROR The new credential could not be created because of a device
114 error.
115 @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.
116
117 **/
118 EFI_STATUS
119 EFIAPI
120 CredentialEnroll (
121 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
122 IN EFI_USER_PROFILE_HANDLE User
123 );
124
125 /**
126 Returns the user interface information used during user identification.
127
128 This function returns information about the form used when interacting with the
129 user during user identification. The form is the first enabled form in the form-set
130 class EFI_HII_USER_CREDENTIAL_FORMSET_GUID installed on the HII handle HiiHandle. If
131 the user credential provider does not require a form to identify the user, then this
132 function should return EFI_NOT_FOUND.
133
134 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
135 @param[out] Hii On return, holds the HII database handle.
136 @param[out] FormSetId On return, holds the identifier of the form set which contains
137 the form used during user identification.
138 @param[out] FormId On return, holds the identifier of the form used during user
139 identification.
140
141 @retval EFI_SUCCESS Form returned successfully.
142 @retval EFI_NOT_FOUND Form not returned.
143 @retval EFI_INVALID_PARAMETER Hii is NULL or FormSetId is NULL or FormId is NULL.
144
145 **/
146 EFI_STATUS
147 EFIAPI
148 CredentialForm (
149 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
150 OUT EFI_HII_HANDLE *Hii,
151 OUT EFI_GUID *FormSetId,
152 OUT EFI_FORM_ID *FormId
153 );
154
155 /**
156 Returns bitmap used to describe the credential provider type.
157
158 This optional function returns a bitmap which is less than or equal to the number
159 of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND
160 is returned.
161
162 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
163 @param[in, out] Width On entry, points to the desired bitmap width. If NULL then no
164 bitmap information will be returned. On exit, points to the
165 width of the bitmap returned.
166 @param[in, out] Height On entry, points to the desired bitmap height. If NULL then no
167 bitmap information will be returned. On exit, points to the
168 height of the bitmap returned.
169 @param[out] Hii On return, holds the HII database handle.
170 @param[out] Image On return, holds the HII image identifier.
171
172 @retval EFI_SUCCESS Image identifier returned successfully.
173 @retval EFI_NOT_FOUND Image identifier not returned.
174 @retval EFI_INVALID_PARAMETER Hii is NULL or Image is NULL.
175
176 **/
177 EFI_STATUS
178 EFIAPI
179 CredentialTile (
180 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
181 IN OUT UINTN *Width,
182 IN OUT UINTN *Height,
183 OUT EFI_HII_HANDLE *Hii,
184 OUT EFI_IMAGE_ID *Image
185 );
186
187 /**
188 Returns string used to describe the credential provider type.
189
190 This function returns a string which describes the credential provider. If no
191 such string exists, then EFI_NOT_FOUND is returned.
192
193 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
194 @param[out] Hii On return, holds the HII database handle.
195 @param[out] String On return, holds the HII string identifier.
196
197 @retval EFI_SUCCESS String identifier returned successfully.
198 @retval EFI_NOT_FOUND String identifier not returned.
199 @retval EFI_INVALID_PARAMETER Hii is NULL or String is NULL.
200
201 **/
202 EFI_STATUS
203 EFIAPI
204 CredentialTitle (
205 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
206 OUT EFI_HII_HANDLE *Hii,
207 OUT EFI_STRING_ID *String
208 );
209
210 /**
211 Return the user identifier associated with the currently authenticated user.
212
213 This function returns the user identifier of the user authenticated by this credential
214 provider. This function is called after the credential-related information has been
215 submitted on a form OR after a call to Default() has returned that this credential is
216 ready to log on.
217
218 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
219 @param[in] User The user profile handle of the user profile currently being
220 considered by the user identity manager. If NULL, then no user
221 profile is currently under consideration.
222 @param[out] Identifier On return, points to the user identifier.
223
224 @retval EFI_SUCCESS User identifier returned successfully.
225 @retval EFI_NOT_READY No user identifier can be returned.
226 @retval EFI_ACCESS_DENIED The user has been locked out of this user credential.
227 @retval EFI_INVALID_PARAMETER This is NULL, or Identifier is NULL.
228 @retval EFI_NOT_FOUND User is not NULL, and the specified user handle can't be
229 found in user profile database.
230
231 **/
232 EFI_STATUS
233 EFIAPI
234 CredentialUser (
235 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
236 IN EFI_USER_PROFILE_HANDLE User,
237 OUT EFI_USER_INFO_IDENTIFIER *Identifier
238 );
239
240 /**
241 Indicate that user interface interaction has begun for the specified credential.
242
243 This function is called when a credential provider is selected by the user. If
244 AutoLogon returns FALSE, then the user interface will be constructed by the User
245 Identity Manager.
246
247 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
248 @param[out] AutoLogon On return, points to the credential provider's capabilities
249 after the credential provider has been selected by the user.
250
251 @retval EFI_SUCCESS Credential provider successfully selected.
252 @retval EFI_INVALID_PARAMETER AutoLogon is NULL.
253
254 **/
255 EFI_STATUS
256 EFIAPI
257 CredentialSelect (
258 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
259 OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon
260 );
261
262 /**
263 Indicate that user interface interaction has ended for the specified credential.
264
265 This function is called when a credential provider is deselected by the user.
266
267 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
268
269 @retval EFI_SUCCESS Credential provider successfully deselected.
270
271 **/
272 EFI_STATUS
273 EFIAPI
274 CredentialDeselect (
275 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This
276 );
277
278 /**
279 Return the default logon behavior for this user credential.
280
281 This function reports the default login behavior regarding this credential provider.
282
283 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
284 @param[out] AutoLogon On return, holds whether the credential provider should be used
285 by default to automatically log on the user.
286
287 @retval EFI_SUCCESS Default information successfully returned.
288 @retval EFI_INVALID_PARAMETER AutoLogon is NULL.
289
290 **/
291 EFI_STATUS
292 EFIAPI
293 CredentialDefault (
294 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
295 OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon
296 );
297
298 /**
299 Return information attached to the credential provider.
300
301 This function returns user information.
302
303 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
304 @param[in] UserInfo Handle of the user information data record.
305 @param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On
306 exit, holds the user information. If the buffer is too small
307 to hold the information, then EFI_BUFFER_TOO_SMALL is returned
308 and InfoSize is updated to contain the number of bytes actually
309 required.
310 @param[in, out] InfoSize On entry, points to the size of Info. On return, points to the
311 size of the user information.
312
313 @retval EFI_SUCCESS Information returned successfully.
314 @retval EFI_BUFFER_TOO_SMALL The size specified by InfoSize is too small to hold all of the
315 user information. The size required is returned in *InfoSize.
316 @retval EFI_INVALID_PARAMETER Info is NULL or InfoSize is NULL.
317 @retval EFI_NOT_FOUND The specified UserInfo does not refer to a valid user info handle.
318
319 **/
320 EFI_STATUS
321 EFIAPI
322 CredentialGetInfo (
323 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
324 IN EFI_USER_INFO_HANDLE UserInfo,
325 OUT EFI_USER_INFO *Info,
326 IN OUT UINTN *InfoSize
327 );
328
329 /**
330 Enumerate all of the user informations on the credential provider.
331
332 This function returns the next user information record. To retrieve the first user
333 information record handle, point UserInfo at a NULL. Each subsequent call will retrieve
334 another user information record handle until there are no more, at which point UserInfo
335 will point to NULL.
336
337 @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
338 @param[in, out] UserInfo On entry, points to the previous user information handle or NULL
339 to start enumeration. On exit, points to the next user information
340 handle or NULL if there is no more user information.
341
342 @retval EFI_SUCCESS User information returned.
343 @retval EFI_NOT_FOUND No more user information found.
344 @retval EFI_INVALID_PARAMETER UserInfo is NULL.
345
346 **/
347 EFI_STATUS
348 EFIAPI
349 CredentialGetNextInfo (
350 IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
351 IN OUT EFI_USER_INFO_HANDLE *UserInfo
352 );
353
354 #endif