diff options
Diffstat (limited to 'SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c')
-rw-r--r-- | SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c | 216 |
1 files changed, 140 insertions, 76 deletions
diff --git a/SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c b/SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c index b8513e9515..0016db8663 100644 --- a/SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c +++ b/SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c @@ -40,7 +40,7 @@ HII_VENDOR_DEVICE_PATH mHiiVendorDevicePath = { }
};
-EFI_USER_CREDENTIAL_PROTOCOL gPwdCredentialProviderDriver = {
+EFI_USER_CREDENTIAL2_PROTOCOL gPwdCredentialProviderDriver = {
PWD_CREDENTIAL_PROVIDER_GUID,
EFI_USER_CREDENTIAL_CLASS_PASSWORD,
CredentialEnroll,
@@ -52,7 +52,9 @@ EFI_USER_CREDENTIAL_PROTOCOL gPwdCredentialProviderDriver = { CredentialDeselect,
CredentialDefault,
CredentialGetInfo,
- CredentialGetNextInfo
+ CredentialGetNextInfo,
+ EFI_CREDENTIAL_CAPABILITIES_ENROLL,
+ CredentialDelete
};
@@ -117,12 +119,12 @@ ExpandTableSize ( /**
- Add or delete info in table, and sync with NV variable.
+ Add, update or delete info in table, and sync with NV variable.
- @param[in] Index The index of the password in table. The index begin from 1.
- If index is found in table, delete the info, else add the
- into to table.
- @param[in] Info The new password info to add into table.
+ @param[in] Index The index of the password in table. If index is found in
+ table, update the info, else add the into to table.
+ @param[in] Info The new password info to add into table.If Info is NULL,
+ delete the info by Index.
@retval EFI_INVALID_PARAMETER Info is NULL when save the info.
@retval EFI_SUCCESS Modify the table successfully.
@@ -135,23 +137,29 @@ ModifyTable ( IN PASSWORD_INFO * Info OPTIONAL
)
{
- EFI_STATUS Status;
-
+ EFI_STATUS Status;
+ PASSWORD_INFO *NewPasswordInfo;
+
+ NewPasswordInfo = NULL;
+
if (Index < mPwdTable->Count) {
- //
- // Delete the specified entry.
- //
- mPwdTable->Count--;
- if (Index != mPwdTable->Count) {
- CopyMem (
- &mPwdTable->UserInfo[Index],
- &mPwdTable->UserInfo[mPwdTable->Count],
- sizeof (PASSWORD_INFO)
- );
+ if (Info == NULL) {
+ //
+ // Delete the specified entry.
+ //
+ mPwdTable->Count--;
+ if (Index != mPwdTable->Count) {
+ NewPasswordInfo = &mPwdTable->UserInfo[mPwdTable->Count];
+ }
+ } else {
+ //
+ // Update the specified entry.
+ //
+ NewPasswordInfo = Info;
}
} else {
//
- // Add a new entry.
+ // Add a new password info.
//
if (Info == NULL) {
return EFI_INVALID_PARAMETER;
@@ -161,14 +169,14 @@ ModifyTable ( ExpandTableSize ();
}
- CopyMem (
- &mPwdTable->UserInfo[mPwdTable->Count],
- Info,
- sizeof (PASSWORD_INFO)
- );
+ NewPasswordInfo = Info;
mPwdTable->Count++;
}
+ if (NewPasswordInfo != NULL) {
+ CopyMem (&mPwdTable->UserInfo[Index], NewPasswordInfo, sizeof (PASSWORD_INFO));
+ }
+
//
// Save the credential table.
//
@@ -705,13 +713,11 @@ InitFormBrowser ( /**
Enroll a user on a credential provider.
- This function enrolls and deletes a user profile using this credential provider.
- If a user profile is successfully enrolled, it calls the User Manager Protocol
- function Notify() to notify the user manager driver that credential information
- has changed. If an enrolled user does exist, delete the user on the credential
- provider.
+ This function enrolls a user on this credential provider. If the user exists on
+ this credential provider, update the user information on this credential provider;
+ otherwise add the user information on credential provider.
- @param[in] This Points to this instance of EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.
@param[in] User The user profile to enroll.
@retval EFI_SUCCESS User profile was successfully enrolled.
@@ -729,7 +735,7 @@ InitFormBrowser ( EFI_STATUS
EFIAPI
CredentialEnroll (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
IN EFI_USER_PROFILE_HANDLE User
)
{
@@ -741,7 +747,6 @@ CredentialEnroll ( EFI_INPUT_KEY Key;
EFI_USER_MANAGER_PROTOCOL *UserManager;
UINT8 *UserId;
- UINT8 *NewUserId;
CHAR16 *QuestionStr;
CHAR16 *PromptStr;
@@ -771,23 +776,11 @@ CredentialEnroll ( return EFI_INVALID_PARAMETER;
}
- //
- // If User exists in mPwdTable, delete User.
- //
- for (Index = 0; Index < mPwdTable->Count; Index++) {
- UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;
- NewUserId = (UINT8 *) (UserInfo + 1);
- if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {
- //
- // Delete the existing password.
- //
- FreePool (UserInfo);
- return ModifyTable (Index, NULL);
- }
- }
+ CopyMem (PwdInfo.UserId, (UINT8 *) (UserInfo + 1), sizeof (EFI_USER_INFO_IDENTIFIER));
+ FreePool (UserInfo);
//
- // The User doesn't exist in mPwdTable; Enroll the new User.
+ // Get password from user.
//
while (TRUE) {
//
@@ -821,17 +814,23 @@ CredentialEnroll ( FreePool (PromptStr);
}
- CopyMem (
- PwdInfo.UserId,
- (UINT8 *) (UserInfo + 1),
- sizeof (EFI_USER_INFO_IDENTIFIER)
- );
- FreePool (UserInfo);
-
//
- // Save the new added entry.
+ // Check whether User is ever enrolled in the provider.
+ //
+ for (Index = 0; Index < mPwdTable->Count; Index++) {
+ UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;
+ if (CompareMem (UserId, (UINT8 *) &PwdInfo.UserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {
+ //
+ // User already exists, update the password.
+ //
+ break;
+ }
+ }
+
+ //
+ // Enroll the User to the provider.
//
- Status = ModifyTable (mPwdTable->Count, &PwdInfo);
+ Status = ModifyTable (Index, &PwdInfo);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -854,7 +853,7 @@ CredentialEnroll ( the user credential provider does not require a form to identify the user, then this
function should return EFI_NOT_FOUND.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[out] Hii On return, holds the HII database handle.
@param[out] FormSetId On return, holds the identifier of the form set which contains
the form used during user identification.
@@ -869,7 +868,7 @@ CredentialEnroll ( EFI_STATUS
EFIAPI
CredentialForm (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
OUT EFI_HII_HANDLE *Hii,
OUT EFI_GUID *FormSetId,
OUT EFI_FORM_ID *FormId
@@ -895,7 +894,7 @@ CredentialForm ( of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND
is returned.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[in, out] Width On entry, points to the desired bitmap width. If NULL then no
bitmap information will be returned. On exit, points to the
width of the bitmap returned.
@@ -913,7 +912,7 @@ CredentialForm ( EFI_STATUS
EFIAPI
CredentialTile (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
IN OUT UINTN *Width,
IN OUT UINTN *Height,
OUT EFI_HII_HANDLE *Hii,
@@ -933,7 +932,7 @@ CredentialTile ( This function returns a string which describes the credential provider. If no
such string exists, then EFI_NOT_FOUND is returned.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[out] Hii On return, holds the HII database handle.
@param[out] String On return, holds the HII string identifier.
@@ -945,7 +944,7 @@ CredentialTile ( EFI_STATUS
EFIAPI
CredentialTitle (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
OUT EFI_HII_HANDLE *Hii,
OUT EFI_STRING_ID *String
)
@@ -972,7 +971,7 @@ CredentialTitle ( submitted on a form, OR after a call to Default() has returned that this credential is
ready to log on.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[in] User The user profile handle of the user profile currently being
considered by the user identity manager. If NULL, then no user
profile is currently under consideration.
@@ -989,7 +988,7 @@ CredentialTitle ( EFI_STATUS
EFIAPI
CredentialUser (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
IN EFI_USER_PROFILE_HANDLE User,
OUT EFI_USER_INFO_IDENTIFIER *Identifier
)
@@ -1067,7 +1066,7 @@ CredentialUser ( AutoLogon returns FALSE, then the user interface will be constructed by the User
Identity Manager.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[out] AutoLogon On return, points to the credential provider's capabilities
after the credential provider has been selected by the user.
@@ -1078,7 +1077,7 @@ CredentialUser ( EFI_STATUS
EFIAPI
CredentialSelect (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon
)
{
@@ -1096,7 +1095,7 @@ CredentialSelect ( This function is called when a credential provider is deselected by the user.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@retval EFI_SUCCESS Credential provider successfully deselected.
@@ -1104,7 +1103,7 @@ CredentialSelect ( EFI_STATUS
EFIAPI
CredentialDeselect (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This
)
{
if (This == NULL) {
@@ -1119,7 +1118,7 @@ CredentialDeselect ( This function reports the default login behavior regarding this credential provider.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[out] AutoLogon On return, holds whether the credential provider should be used
by default to automatically log on the user.
@@ -1130,7 +1129,7 @@ CredentialDeselect ( EFI_STATUS
EFIAPI
CredentialDefault (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
OUT EFI_CREDENTIAL_LOGON_FLAGS *AutoLogon
)
{
@@ -1148,7 +1147,7 @@ CredentialDefault ( This function returns user information.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[in] UserInfo Handle of the user information data record.
@param[out] Info On entry, points to a buffer of at least *InfoSize bytes. On
exit, holds the user information. If the buffer is too small
@@ -1168,7 +1167,7 @@ CredentialDefault ( EFI_STATUS
EFIAPI
CredentialGetInfo (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
IN EFI_USER_INFO_HANDLE UserInfo,
OUT EFI_USER_INFO *Info,
IN OUT UINTN *InfoSize
@@ -1215,7 +1214,7 @@ CredentialGetInfo ( another user information record handle until there are no more, at which point UserInfo
will point to NULL.
- @param[in] This Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
@param[in, out] UserInfo On entry, points to the previous user information handle or NULL
to start enumeration. On exit, points to the next user information
handle or NULL if there is no more user information.
@@ -1228,7 +1227,7 @@ CredentialGetInfo ( EFI_STATUS
EFIAPI
CredentialGetNextInfo (
- IN CONST EFI_USER_CREDENTIAL_PROTOCOL *This,
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
IN OUT EFI_USER_INFO_HANDLE *UserInfo
)
{
@@ -1359,6 +1358,71 @@ CredentialGetNextInfo ( return EFI_NOT_FOUND;
}
+/**
+ Delete a user on this credential provider.
+
+ This function deletes a user on this credential provider.
+
+ @param[in] This Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.
+ @param[in] User The user profile handle to delete.
+
+ @retval EFI_SUCCESS User profile was successfully deleted.
+ @retval EFI_ACCESS_DENIED Current user profile does not permit deletion on the user profile handle.
+ Either the user profile cannot delete on any user profile or cannot delete
+ on a user profile other than the current user profile.
+ @retval EFI_UNSUPPORTED This credential provider does not support deletion in the pre-OS.
+ @retval EFI_DEVICE_ERROR The new credential could not be deleted because of a device error.
+ @retval EFI_INVALID_PARAMETER User does not refer to a valid user profile handle.
+**/
+EFI_STATUS
+EFIAPI
+CredentialDelete (
+ IN CONST EFI_USER_CREDENTIAL2_PROTOCOL *This,
+ IN EFI_USER_PROFILE_HANDLE User
+ )
+{
+ EFI_STATUS Status;
+ EFI_USER_INFO *UserInfo;
+ UINT8 *UserId;
+ UINT8 *NewUserId;
+ UINTN Index;
+
+ if ((This == NULL) || (User == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Get User Identifier.
+ //
+ UserInfo = NULL;
+ Status = FindUserInfoByType (
+ User,
+ EFI_USER_INFO_IDENTIFIER_RECORD,
+ &UserInfo
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Find the user by user identifier in mPwdTable.
+ //
+ for (Index = 0; Index < mPwdTable->Count; Index++) {
+ UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;
+ NewUserId = (UINT8 *) (UserInfo + 1);
+ if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {
+ //
+ // Found the user, delete it.
+ //
+ ModifyTable (Index, NULL);
+ break;
+ }
+ }
+
+ FreePool (UserInfo);
+ return EFI_SUCCESS;
+}
+
/**
Main entry for this driver.
@@ -1399,7 +1463,7 @@ PasswordProviderInit ( //
Status = gBS->InstallProtocolInterface (
&mCallbackInfo->DriverHandle,
- &gEfiUserCredentialProtocolGuid,
+ &gEfiUserCredential2ProtocolGuid,
EFI_NATIVE_INTERFACE,
&gPwdCredentialProviderDriver
);
|