summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/UserIdentification/UserIdentifyManagerDxe/UserIdentifyManager.h
blob: b1e078a03e4fd0665424ab8ea7cbaa1c586cd422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
/** @file
  The header file for User identify Manager driver.
    
Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials 
are licensed and made available under the terms and conditions of the BSD License 
which accompanies this distribution.  The full text of the license may be found at 
http://opensource.org/licenses/bsd-license.php

THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, 
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.

**/

#ifndef _USER_IDENTIFY_MANAGER_H_
#define _USER_IDENTIFY_MANAGER_H_

#include <Uefi.h>

#include <Guid/GlobalVariable.h>
#include <Guid/MdeModuleHii.h>

#include <Protocol/FormBrowser2.h>
#include <Protocol/HiiDatabase.h>
#include <Protocol/HiiConfigAccess.h>
#include <Protocol/HiiString.h>
#include <Protocol/HiiConfigRouting.h>
#include <Protocol/UserCredential.h>
#include <Protocol/UserManager.h>
#include <Protocol/DeferredImageLoad.h>
#include <Protocol/SimpleTextOut.h>
#include <Protocol/SimpleTextIn.h>
#include <Protocol/SimpleTextInEx.h>

#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/DevicePathLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/PrintLib.h>
#include <Library/HiiLib.h>

#include "UserIdentifyManagerData.h"

//
// This is the generated IFR binary data for each formset defined in VFR.
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist.
//
extern UINT8                UserIdentifyManagerVfrBin[];

//
// This is the generated String package data for all .UNI files.
// This data array is ready to be used as input of HiiAddPackages() to
// create a packagelist.
//
extern UINT8                UserIdentifyManagerStrings[];

#define   USER_NUMBER_INC           32
#define   DEFAULT_PROFILE_SIZE      512
#define   INFO_PAYLOAD_SIZE         64

//
// Credential Provider Information.
//
typedef struct {
  UINTN                         Count;
  EFI_USER_CREDENTIAL_PROTOCOL  *Provider[1];
} CREDENTIAL_PROVIDER_INFO;

//
// Internal user profile entry.
//
typedef struct {
  UINTN   MaxProfileSize;
  UINTN   UserProfileSize;
  CHAR16  UserVarName[9];
  UINT8   *ProfileInfo;
} USER_PROFILE_ENTRY;

//
// Internal user profile database.
//
typedef struct {
  UINTN                   UserProfileNum;
  UINTN                   MaxProfileNum;
  EFI_USER_PROFILE_HANDLE UserProfile[1];
} USER_PROFILE_DB;

#define USER_MANAGER_SIGNATURE  SIGNATURE_32 ('U', 'I', 'M', 'S')

typedef struct {
  UINTN                           Signature;
  EFI_HANDLE                      DriverHandle;
  EFI_HII_HANDLE                  HiiHandle;

  //
  // Consumed protocol.
  //
  EFI_HII_DATABASE_PROTOCOL       *HiiDatabase;
  EFI_HII_STRING_PROTOCOL         *HiiString;
  EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
  EFI_FORM_BROWSER2_PROTOCOL      *FormBrowser2;

  //
  // Produced protocol.
  //
  EFI_HII_CONFIG_ACCESS_PROTOCOL  ConfigAccess;
} USER_MANAGER_CALLBACK_INFO;

///
/// HII specific Vendor Device Path definition.
///
typedef struct {
  VENDOR_DEVICE_PATH        VendorDevicePath;
  EFI_DEVICE_PATH_PROTOCOL  End;
} HII_VENDOR_DEVICE_PATH;

/**
  Register an event notification function for the user profile changed.

  @param[in]  ImageHandle     Image handle this driver.

**/
VOID
LoadDeferredImageInit (
  IN EFI_HANDLE        ImageHandle
  );


/**
  This function creates a new user profile with only
  a new user identifier attached and returns its handle.
  The user profile is non-volatile, but the handle User
  can change across reboots.

  @param[in]   This               Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param[out]  User               Handle of a new user profile.

  @retval EFI_SUCCESS             User profile was successfully created.
  @retval EFI_ACCESS_DENIED       Current user does not have sufficient permissions
                                  to create a user profile.
  @retval EFI_UNSUPPORTED         Creation of new user profiles is not supported.
  @retval EFI_INVALID_PARAMETER   User is NULL.

**/
EFI_STATUS
EFIAPI
UserProfileCreate (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  OUT       EFI_USER_PROFILE_HANDLE             *User
  );


/**
  Delete an existing user profile.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param  User                    User profile handle.

  @retval EFI_SUCCESS             User profile was successfully deleted.
  @retval EFI_ACCESS_DENIED       Current user does not have sufficient permissions
                                  to delete a user profile or there is only one
                                  user profile.
  @retval EFI_UNSUPPORTED         Deletion of new user profiles is not supported.
  @retval EFI_INVALID_PARAMETER   User does not refer to a valid user profile.

**/
EFI_STATUS
EFIAPI
UserProfileDelete (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_USER_PROFILE_HANDLE             User
  );


/**
  Get next user profile from the user profile database.

  @param[in]       This           Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param[in, out]  User           User profile handle.

  @retval EFI_SUCCESS             Next enrolled user profile successfully returned.
  @retval EFI_INVALID_PARAMETER   User is NULL.

**/
EFI_STATUS
EFIAPI
UserProfileGetNext (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN OUT    EFI_USER_PROFILE_HANDLE             *User
  );


/**
  This function returns the current user profile handle.

  @param[in]  This                Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
  @param[out]  CurrentUser        User profile handle.

  @retval EFI_SUCCESS             Current user profile handle returned successfully.
  @retval EFI_INVALID_PARAMETER   CurrentUser is NULL.

**/
EFI_STATUS
EFIAPI
UserProfileCurrent (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  OUT       EFI_USER_PROFILE_HANDLE             *CurrentUser
  );


/**
  Identify the user and, if authenticated, returns the user handle and changes
  the current user profile.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
  @param  CurrentUser             User profile handle.

  @retval EFI_SUCCESS             User was successfully identified.
  @retval EFI_INVALID_PARAMETER   User is NULL.
  @retval EFI_ACCESS_DENIED       User was not successfully identified.

**/
EFI_STATUS
EFIAPI
UserProfileIdentify (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  OUT       EFI_USER_PROFILE_HANDLE             *User
  );


/**
  Find a user using a user information record.

  This function searches all user profiles for the specified user information record.
  The search starts with the user information record handle following UserInfo and 
  continues until either the information is found or there are no more user profiles.
  A match occurs when the Info.InfoType field matches the user information record
  type and the user information record data matches the portion of Info passed the 
  EFI_USER_INFO header.

  @param[in]      This     Points to this instance of the EFI_USER_MANAGER_PROTOCOL.
  @param[in, out] User     On entry, points to the previously returned user profile 
                           handle, or NULL to start searching with the first user profile.
                           On return, points to the user profile handle, or NULL if not
                           found.
  @param[in, out] UserInfo On entry, points to the previously returned user information
                           handle, or NULL to start searching with the first. On return, 
                           points to the user information handle of the user information
                           record, or NULL if not found. Can be NULL, in which case only 
                           one user information record per user can be returned. 
  @param[in]      Info     Points to the buffer containing the user information to be 
                           compared to the user information record. If NULL, then only 
                           the user information record type is compared. If InfoSize is 0, 
                           then the user information record must be empty.

  @param[in]      InfoSize The size of Info, in bytes. 

  @retval EFI_SUCCESS      User information was found. User points to the user profile handle,
                           and UserInfo points to the user information handle.
  @retval EFI_NOT_FOUND    User information was not found. User points to NULL and UserInfo 
                           points to NULL.
  
**/
EFI_STATUS
EFIAPI
UserProfileFind (
  IN     CONST EFI_USER_MANAGER_PROTOCOL        *This,
  IN OUT EFI_USER_PROFILE_HANDLE                *User,
  IN OUT EFI_USER_INFO_HANDLE                   *UserInfo OPTIONAL,
  IN     CONST EFI_USER_INFO                    *Info,
  IN     UINTN                                  InfoSize
  );


/**
  This function returns user information.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param  User                    Handle of the user whose profile will be
                                  retrieved.
  @param  UserInfo                Handle of the user information data record.
  @param  Info                    On entry, points to a buffer of at least
                                  *InfoSize bytes.  On exit, holds the user
                                  information.
  @param  InfoSize                On entry, points to the size of Info. On return,
                                  points to the size of the user information.

  @retval EFI_SUCCESS             Information returned successfully.
  @retval EFI_ACCESS_DENIED       The information about the specified user cannot
                                  be accessed  by the current user.
                                  EFI_BUFFER_TOO_SMALL- The number of bytes
                                  specified by *InfoSize is too small to hold the
                                  returned data.

**/
EFI_STATUS
EFIAPI
UserProfileGetInfo (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_USER_PROFILE_HANDLE             User,
  IN        EFI_USER_INFO_HANDLE                UserInfo,
  OUT       EFI_USER_INFO                       *Info,
  IN OUT    UINTN                               *InfoSize
  );


/**
  This function changes user information.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param  User                    Handle of the user whose profile will be
                                  retrieved.
  @param  UserInfo                Handle of the user information data record.
  @param  Info                    Points to the user information.
  @param  InfoSize                The size of Info, in bytes.

  @retval EFI_SUCCESS             User profile information was successfully
                                  changed/added.
  @retval EFI_ACCESS_DENIED       The record is exclusive.
  @retval EFI_SECURITY_VIOLATION  The current user does not have permission to
                                  change  the specified user profile or user
                                  information record.

**/
EFI_STATUS
EFIAPI
UserProfileSetInfo (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_USER_PROFILE_HANDLE             User,
  IN OUT    EFI_USER_INFO_HANDLE                *UserInfo,
  IN CONST  EFI_USER_INFO                       *Info,
  IN        UINTN                               InfoSize
  );


/**
  This function allows the credential provider to notify the User Identity Manager
  when user status has changed while deselected.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance
                                  pointer.
  @param  Changed                 Points to the instance of the
                                  EFI_USER_CREDENTIAL_PROTOCOL  where the user has
                                  changed.

  @retval EFI_SUCCESS             The User Identity Manager has handled the
                                  notification.
  @retval EFI_NOT_READY           The function was called while the specified
                                  credential  provider was not selected.
  @retval EFI_UNSUPPORTED         The User Identity Manager doesn't support
                                  asynchronous  notifications.

**/
EFI_STATUS
EFIAPI
UserProfileNotify (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_HANDLE                          Changed
  );


/**
  Delete the user information attached to the user profile specified by the UserInfo.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
  @param  User                    Handle of the user whose profile will be retrieved.
  @param  UserInfo                Handle of the user information data record.

  @retval EFI_SUCCESS             User information deleted successfully.
  @retval EFI_ACCESS_DENIED       The current user does not have permission to
                                  delete this user in-formation.
  @retval EFI_NOT_FOUND           User information record UserInfo does not exist
                                  in the user pro-file.

**/
EFI_STATUS
EFIAPI
UserProfileDeleteInfo (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_USER_PROFILE_HANDLE             User,
  IN        EFI_USER_INFO_HANDLE                UserInfo
  );


/**
  This function returns the next user information record.

  @param  This                    Protocol EFI_USER_MANAGER_PROTOCOL instance pointer.
  @param  User                    Handle of the user whose profile will be retrieved.
  @param  UserInfo                Handle of the user information data record.

  @retval EFI_SUCCESS             User information returned.
  @retval EFI_NOT_FOUND           No more user information found.

**/
EFI_STATUS
EFIAPI
UserProfileGetNextInfo (
  IN CONST  EFI_USER_MANAGER_PROTOCOL           *This,
  IN        EFI_USER_PROFILE_HANDLE             User,
  IN OUT    EFI_USER_INFO_HANDLE                *UserInfo
  );
  
#endif