]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/UserIdentification/PwdCredentialProviderDxe/PwdCredentialProvider.c
Update UID drivers to align with latest UEFI spec 2.3.1.
[mirror_edk2.git] / SecurityPkg / UserIdentification / PwdCredentialProviderDxe / PwdCredentialProvider.c
index 9d2e622f1338effee846aafc66faefe7c914fa22..afb090a919425fa013874cc3a1c447b467d4eda7 100644 (file)
@@ -18,12 +18,6 @@ CREDENTIAL_TABLE            *mPwdTable      = NULL;
 PWD_PROVIDER_CALLBACK_INFO  *mCallbackInfo  = NULL;\r
 PASSWORD_CREDENTIAL_INFO    *mPwdInfoHandle = NULL;\r
 \r
-//\r
-// Used for save password credential and form browser.\r
-// Also used as provider identifier.\r
-//\r
-EFI_GUID  mPwdCredentialGuid = PWD_CREDENTIAL_PROVIDER_GUID;\r
-\r
 HII_VENDOR_DEVICE_PATH      mHiiVendorDevicePath = {\r
   {\r
     {\r
@@ -34,7 +28,7 @@ HII_VENDOR_DEVICE_PATH      mHiiVendorDevicePath = {
         (UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)\r
       }\r
     },\r
-    { 0xeba7fc2b, 0xa465, 0x4d96, { 0x85, 0xa9, 0xd2, 0xf6, 0x64, 0xdf, 0x9b, 0x45 } }   \r
+    PWD_CREDENTIAL_PROVIDER_GUID\r
   },\r
   {\r
     END_DEVICE_PATH_TYPE,\r
@@ -46,7 +40,7 @@ HII_VENDOR_DEVICE_PATH      mHiiVendorDevicePath = {
   }\r
 };\r
 \r
-EFI_USER_CREDENTIAL_PROTOCOL  gPwdCredentialProviderDriver = {\r
+EFI_USER_CREDENTIAL2_PROTOCOL  gPwdCredentialProviderDriver = {\r
   PWD_CREDENTIAL_PROVIDER_GUID,\r
   EFI_USER_CREDENTIAL_CLASS_PASSWORD,\r
   CredentialEnroll,\r
@@ -58,7 +52,9 @@ EFI_USER_CREDENTIAL_PROTOCOL  gPwdCredentialProviderDriver = {
   CredentialDeselect,\r
   CredentialDefault,\r
   CredentialGetInfo,\r
-  CredentialGetNextInfo\r
+  CredentialGetNextInfo,\r
+  EFI_CREDENTIAL_CAPABILITIES_ENROLL,\r
+  CredentialDelete\r
 };\r
 \r
 \r
@@ -123,12 +119,12 @@ ExpandTableSize (
 \r
 \r
 /**\r
-  Add or delete info in table, and sync with NV variable.\r
+  Add, update or delete info in table, and sync with NV variable.\r
 \r
-  @param[in]  Index     The index of the password in table. The index begin from 1.\r
-                        If index is found in table, delete the info, else add the \r
-                        into to table. \r
-  @param[in]  Info      The new password info to add into table.\r
+  @param[in]  Index     The index of the password in table. If index is found in\r
+                        table, update the info, else add the into to table. \r
+  @param[in]  Info      The new password info to add into table.If Info is NULL, \r
+                        delete the info by Index.\r
 \r
   @retval EFI_INVALID_PARAMETER  Info is NULL when save the info.\r
   @retval EFI_SUCCESS            Modify the table successfully.\r
@@ -141,23 +137,29 @@ ModifyTable (
   IN  PASSWORD_INFO                             * Info OPTIONAL\r
   )\r
 {\r
-  EFI_STATUS  Status;\r
-  \r
+  EFI_STATUS       Status;\r
+  PASSWORD_INFO    *NewPasswordInfo;\r
+\r
+  NewPasswordInfo = NULL;\r
+\r
   if (Index < mPwdTable->Count) {\r
-    //\r
-    // Delete the specified entry.\r
-    //\r
-    mPwdTable->Count--;\r
-    if (Index != mPwdTable->Count) {\r
-      CopyMem (\r
-        &mPwdTable->UserInfo[Index],\r
-        &mPwdTable->UserInfo[mPwdTable->Count],\r
-        sizeof (PASSWORD_INFO)\r
-        );\r
+    if (Info == NULL) {\r
+      //\r
+      // Delete the specified entry.\r
+      //\r
+      mPwdTable->Count--;\r
+      if (Index != mPwdTable->Count) {\r
+        NewPasswordInfo = &mPwdTable->UserInfo[mPwdTable->Count];\r
+      } \r
+    } else {\r
+      //\r
+      // Update the specified entry.\r
+      //\r
+      NewPasswordInfo = Info;\r
     }\r
   } else {\r
     //\r
-    // Add a new entry.\r
+    // Add a new password info.\r
     //\r
     if (Info == NULL) {\r
       return EFI_INVALID_PARAMETER;\r
@@ -167,20 +169,20 @@ ModifyTable (
       ExpandTableSize ();\r
     }\r
 \r
-    CopyMem (\r
-      &mPwdTable->UserInfo[mPwdTable->Count], \r
-      Info, \r
-      sizeof (PASSWORD_INFO)\r
-      );\r
+    NewPasswordInfo = Info;\r
     mPwdTable->Count++;\r
   }\r
 \r
+  if (NewPasswordInfo != NULL) {\r
+    CopyMem (&mPwdTable->UserInfo[Index], NewPasswordInfo, sizeof (PASSWORD_INFO));\r
+  }\r
+\r
   //\r
   // Save the credential table.\r
   //\r
   Status = gRT->SetVariable (\r
                   L"PwdCredential",\r
-                  &mPwdCredentialGuid,\r
+                  &gPwdCredentialProviderGuid,\r
                   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS,\r
                   mPwdTable->Count * sizeof (PASSWORD_INFO),\r
                   &mPwdTable->UserInfo\r
@@ -212,7 +214,7 @@ InitCredentialTable (
   Var     = NULL;\r
   Status  = gRT->GetVariable (\r
                    L"PwdCredential", \r
-                   &mPwdCredentialGuid, \r
+                   &gPwdCredentialProviderGuid, \r
                    NULL, \r
                    &VarSize,\r
                    Var\r
@@ -224,7 +226,7 @@ InitCredentialTable (
     }\r
     Status = gRT->GetVariable (\r
                     L"PwdCredential", \r
-                    &mPwdCredentialGuid, \r
+                    &gPwdCredentialProviderGuid, \r
                     NULL, \r
                     &VarSize,\r
                     Var\r
@@ -693,7 +695,7 @@ InitFormBrowser (
   // Publish HII data.\r
   //\r
   CallbackInfo->HiiHandle = HiiAddPackages (\r
-                              &mPwdCredentialGuid,\r
+                              &gPwdCredentialProviderGuid,\r
                               CallbackInfo->DriverHandle,\r
                               PwdCredentialProviderStrings,\r
                               PwdCredentialProviderVfrBin,\r
@@ -711,13 +713,11 @@ InitFormBrowser (
 /**\r
   Enroll a user on a credential provider.\r
 \r
-  This function enrolls and deletes a user profile using this credential provider. \r
-  If a user profile is successfully enrolled, it calls the User Manager Protocol \r
-  function Notify() to notify the user manager driver that credential information \r
-  has changed. If an enrolled user does exist, delete the user on the credential \r
-  provider.\r
+  This function enrolls a user on this credential provider. If the user exists on \r
+  this credential provider, update the user information on this credential provider; \r
+  otherwise add the user information on credential provider.\r
   \r
-  @param[in] This                Points to this instance of EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in] This                Points to this instance of EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[in] User                The user profile to enroll.\r
  \r
   @retval EFI_SUCCESS            User profile was successfully enrolled.\r
@@ -735,7 +735,7 @@ InitFormBrowser (
 EFI_STATUS\r
 EFIAPI\r
 CredentialEnroll (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   IN        EFI_USER_PROFILE_HANDLE             User\r
   )\r
 {\r
@@ -745,9 +745,7 @@ CredentialEnroll (
   EFI_USER_INFO             *UserInfo;\r
   CHAR8                     Password[CREDENTIAL_LEN];\r
   EFI_INPUT_KEY             Key;\r
-  EFI_USER_MANAGER_PROTOCOL *UserManager;\r
   UINT8                     *UserId;\r
-  UINT8                     *NewUserId;\r
   CHAR16                    *QuestionStr;\r
   CHAR16                    *PromptStr;\r
 \r
@@ -755,15 +753,6 @@ CredentialEnroll (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  Status = gBS->LocateProtocol (\r
-                  &gEfiUserManagerProtocolGuid,\r
-                  NULL,\r
-                  (VOID **) &UserManager\r
-                  );\r
-  if (EFI_ERROR (Status)) {\r
-    return EFI_UNSUPPORTED;\r
-  }\r
-\r
   //\r
   // Get User Identifier.\r
   //\r
@@ -777,23 +766,11 @@ CredentialEnroll (
     return EFI_INVALID_PARAMETER;\r
   }\r
 \r
-  //\r
-  // If User exists in mPwdTable, delete User.\r
-  // \r
-  for (Index = 0; Index < mPwdTable->Count; Index++) {\r
-    UserId    = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
-    NewUserId = (UINT8 *) (UserInfo + 1);\r
-    if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
-      //\r
-      // Delete the existing password.\r
-      //\r
-      FreePool (UserInfo);\r
-      return ModifyTable (Index, NULL);\r
-    }\r
-  }\r
+  CopyMem (PwdInfo.UserId, (UINT8 *) (UserInfo + 1), sizeof (EFI_USER_INFO_IDENTIFIER)); \r
+  FreePool (UserInfo);\r
 \r
   //\r
-  // The User doesn't exist in mPwdTable; Enroll the new User.\r
+  // Get password from user.\r
   //  \r
   while (TRUE) {\r
     //\r
@@ -827,26 +804,27 @@ CredentialEnroll (
     FreePool (PromptStr);\r
   }\r
 \r
-  CopyMem (\r
-    PwdInfo.UserId, \r
-    (UINT8 *) (UserInfo + 1), \r
-    sizeof (EFI_USER_INFO_IDENTIFIER)\r
-    );  \r
-  FreePool (UserInfo);\r
-  \r
   //\r
-  // Save the new added entry.\r
+  // Check whether User is ever enrolled in the provider.\r
+  // \r
+  for (Index = 0; Index < mPwdTable->Count; Index++) {\r
+    UserId = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
+    if (CompareMem (UserId, (UINT8 *) &PwdInfo.UserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
+      //\r
+      // User already exists, update the password.\r
+      //      \r
+      break;\r
+    }\r
+  }\r
+   \r
+  //\r
+  // Enroll the User to the provider.\r
   //\r
-  Status = ModifyTable (mPwdTable->Count, &PwdInfo);\r
+  Status = ModifyTable (Index, &PwdInfo);\r
   if (EFI_ERROR (Status)) {\r
     return Status;\r
   }\r
 \r
-  //\r
-  // Notify the user manager driver that credential information has changed.\r
-  //\r
-  UserManager->Notify (UserManager, mCallbackInfo->DriverHandle);  \r
-\r
   return EFI_SUCCESS;\r
 }\r
 \r
@@ -860,7 +838,7 @@ CredentialEnroll (
   the user credential provider does not require a form to identify the user, then this\r
   function should return EFI_NOT_FOUND.\r
 \r
-  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[out] Hii        On return, holds the HII database handle.\r
   @param[out] FormSetId  On return, holds the identifier of the form set which contains\r
                          the form used during user identification.\r
@@ -875,7 +853,7 @@ CredentialEnroll (
 EFI_STATUS\r
 EFIAPI\r
 CredentialForm (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   OUT       EFI_HII_HANDLE                      *Hii,\r
   OUT       EFI_GUID                            *FormSetId,\r
   OUT       EFI_FORM_ID                         *FormId\r
@@ -888,7 +866,7 @@ CredentialForm (
 \r
   *Hii       = mCallbackInfo->HiiHandle;\r
   *FormId    = FORMID_GET_PASSWORD_FORM;\r
-  CopyGuid (FormSetId, &mPwdCredentialGuid);\r
+  CopyGuid (FormSetId, &gPwdCredentialProviderGuid);\r
   \r
   return EFI_SUCCESS;\r
 }\r
@@ -901,7 +879,7 @@ CredentialForm (
   of pixels specified by Width and Height. If no such bitmap exists, then EFI_NOT_FOUND\r
   is returned. \r
 \r
-  @param[in]      This    Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]      This    Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[in, out] Width   On entry, points to the desired bitmap width. If NULL then no \r
                           bitmap information will be returned. On exit, points to the \r
                           width of the bitmap returned.\r
@@ -919,7 +897,7 @@ CredentialForm (
 EFI_STATUS\r
 EFIAPI\r
 CredentialTile (\r
-  IN  CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN  CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   IN  OUT    UINTN                               *Width,\r
   IN  OUT    UINTN                               *Height,\r
       OUT    EFI_HII_HANDLE                      *Hii,\r
@@ -939,7 +917,7 @@ CredentialTile (
   This function returns a string which describes the credential provider. If no\r
   such string exists, then EFI_NOT_FOUND is returned. \r
 \r
-  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[out] Hii        On return, holds the HII database handle.\r
   @param[out] String     On return, holds the HII string identifier.\r
  \r
@@ -951,7 +929,7 @@ CredentialTile (
 EFI_STATUS\r
 EFIAPI\r
 CredentialTitle (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   OUT       EFI_HII_HANDLE                      *Hii,\r
   OUT       EFI_STRING_ID                       *String\r
   )\r
@@ -978,7 +956,7 @@ CredentialTitle (
   submitted on a form, OR after a call to Default() has returned that this credential is\r
   ready to log on.\r
 \r
-  @param[in]  This           Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]  This           Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[in]  User           The user profile handle of the user profile currently being \r
                              considered by the user identity manager. If NULL, then no user\r
                              profile is currently under consideration.\r
@@ -995,7 +973,7 @@ CredentialTitle (
 EFI_STATUS\r
 EFIAPI\r
 CredentialUser (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   IN        EFI_USER_PROFILE_HANDLE             User,\r
   OUT       EFI_USER_INFO_IDENTIFIER            *Identifier\r
   )\r
@@ -1073,7 +1051,7 @@ CredentialUser (
   AutoLogon returns FALSE, then the user interface will be constructed by the User\r
   Identity Manager. \r
 \r
-  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[out] AutoLogon  On return, points to the credential provider's capabilities \r
                          after the credential provider has been selected by the user. \r
  \r
@@ -1084,7 +1062,7 @@ CredentialUser (
 EFI_STATUS\r
 EFIAPI\r
 CredentialSelect (\r
-  IN  CONST  EFI_USER_CREDENTIAL_PROTOCOL    *This,\r
+  IN  CONST  EFI_USER_CREDENTIAL2_PROTOCOL   *This,\r
   OUT        EFI_CREDENTIAL_LOGON_FLAGS      *AutoLogon\r
   )\r
 {\r
@@ -1102,7 +1080,7 @@ CredentialSelect (
 \r
   This function is called when a credential provider is deselected by the user.\r
 \r
-  @param[in] This        Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in] This        Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
  \r
   @retval EFI_SUCCESS    Credential provider successfully deselected.\r
   \r
@@ -1110,7 +1088,7 @@ CredentialSelect (
 EFI_STATUS\r
 EFIAPI\r
 CredentialDeselect (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This\r
   )\r
 {\r
   if (This == NULL) {\r
@@ -1125,7 +1103,7 @@ CredentialDeselect (
 \r
   This function reports the default login behavior regarding this credential provider.  \r
 \r
-  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]  This       Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[out] AutoLogon  On return, holds whether the credential provider should be used\r
                          by default to automatically log on the user.  \r
  \r
@@ -1136,7 +1114,7 @@ CredentialDeselect (
 EFI_STATUS\r
 EFIAPI\r
 CredentialDefault (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   OUT       EFI_CREDENTIAL_LOGON_FLAGS          *AutoLogon\r
   )\r
 {\r
@@ -1154,7 +1132,7 @@ CredentialDefault (
 \r
   This function returns user information. \r
 \r
-  @param[in]      This          Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]      This          Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[in]      UserInfo      Handle of the user information data record. \r
   @param[out]     Info          On entry, points to a buffer of at least *InfoSize bytes. On\r
                                 exit, holds the user information. If the buffer is too small\r
@@ -1174,7 +1152,7 @@ CredentialDefault (
 EFI_STATUS\r
 EFIAPI\r
 CredentialGetInfo (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   IN        EFI_USER_INFO_HANDLE                UserInfo,\r
   OUT       EFI_USER_INFO                       *Info,\r
   IN OUT    UINTN                               *InfoSize\r
@@ -1221,7 +1199,7 @@ CredentialGetInfo (
   another user information record handle until there are no more, at which point UserInfo\r
   will point to NULL. \r
 \r
-  @param[in]      This     Points to this instance of the EFI_USER_CREDENTIAL_PROTOCOL.\r
+  @param[in]      This     Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
   @param[in, out] UserInfo On entry, points to the previous user information handle or NULL\r
                            to start enumeration. On exit, points to the next user information\r
                            handle or NULL if there is no more user information.\r
@@ -1234,7 +1212,7 @@ CredentialGetInfo (
 EFI_STATUS\r
 EFIAPI\r
 CredentialGetNextInfo (\r
-  IN CONST  EFI_USER_CREDENTIAL_PROTOCOL        *This,\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
   IN OUT    EFI_USER_INFO_HANDLE                *UserInfo\r
   )\r
 {\r
@@ -1269,8 +1247,8 @@ CredentialGetNextInfo (
     Info->InfoType    = EFI_USER_INFO_CREDENTIAL_PROVIDER_RECORD;\r
     Info->InfoSize    = (UINT32) InfoLen;\r
     Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
-    CopyGuid (&Info->Credential, &mPwdCredentialGuid);\r
-    CopyGuid ((EFI_GUID *)(Info + 1), &mPwdCredentialGuid);\r
+    CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
+    CopyGuid ((EFI_GUID *)(Info + 1), &gPwdCredentialProviderGuid);\r
     \r
     mPwdInfoHandle->Info[0] = Info;\r
     mPwdInfoHandle->Count++;\r
@@ -1287,7 +1265,7 @@ CredentialGetNextInfo (
     Info->InfoType    = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
     Info->InfoSize    = (UINT32) InfoLen;\r
     Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
-    CopyGuid (&Info->Credential, &mPwdCredentialGuid);\r
+    CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
     CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
     FreePool (ProvNameStr);\r
 \r
@@ -1304,7 +1282,7 @@ CredentialGetNextInfo (
     Info->InfoType    = EFI_USER_INFO_CREDENTIAL_TYPE_RECORD;\r
     Info->InfoSize    = (UINT32) InfoLen;\r
     Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
-    CopyGuid (&Info->Credential, &mPwdCredentialGuid);\r
+    CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
     CopyGuid ((EFI_GUID *)(Info + 1), &gEfiUserCredentialClassPasswordGuid);\r
     \r
     mPwdInfoHandle->Info[2] = Info;\r
@@ -1322,7 +1300,7 @@ CredentialGetNextInfo (
     Info->InfoType    = EFI_USER_INFO_CREDENTIAL_PROVIDER_NAME_RECORD;\r
     Info->InfoSize    = (UINT32) InfoLen;\r
     Info->InfoAttribs = EFI_USER_INFO_PROTECTED;\r
-    CopyGuid (&Info->Credential, &mPwdCredentialGuid);\r
+    CopyGuid (&Info->Credential, &gPwdCredentialProviderGuid);\r
     CopyMem ((UINT8*)(Info + 1), ProvNameStr, ProvStrLen);\r
     FreePool (ProvNameStr);\r
     \r
@@ -1365,6 +1343,71 @@ CredentialGetNextInfo (
   return EFI_NOT_FOUND;\r
 }\r
 \r
+/**\r
+  Delete a user on this credential provider.\r
+\r
+  This function deletes a user on this credential provider. \r
+\r
+  @param[in]     This            Points to this instance of the EFI_USER_CREDENTIAL2_PROTOCOL.\r
+  @param[in]     User            The user profile handle to delete.\r
+\r
+  @retval EFI_SUCCESS            User profile was successfully deleted.\r
+  @retval EFI_ACCESS_DENIED      Current user profile does not permit deletion on the user profile handle. \r
+                                 Either the user profile cannot delete on any user profile or cannot delete \r
+                                 on a user profile other than the current user profile. \r
+  @retval EFI_UNSUPPORTED        This credential provider does not support deletion in the pre-OS.\r
+  @retval EFI_DEVICE_ERROR       The new credential could not be deleted because of a device error.\r
+  @retval EFI_INVALID_PARAMETER  User does not refer to a valid user profile handle.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CredentialDelete (\r
+  IN CONST  EFI_USER_CREDENTIAL2_PROTOCOL       *This,\r
+  IN        EFI_USER_PROFILE_HANDLE             User\r
+  )\r
+{\r
+  EFI_STATUS                Status;\r
+  EFI_USER_INFO             *UserInfo;\r
+  UINT8                     *UserId;\r
+  UINT8                     *NewUserId;\r
+  UINTN                     Index;\r
+  \r
+  if ((This == NULL) || (User == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Get User Identifier.\r
+  //\r
+  UserInfo = NULL;\r
+  Status = FindUserInfoByType (\r
+             User,\r
+             EFI_USER_INFO_IDENTIFIER_RECORD,\r
+             &UserInfo\r
+             );\r
+  if (EFI_ERROR (Status)) {\r
+    return EFI_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Find the user by user identifier in mPwdTable.\r
+  // \r
+  for (Index = 0; Index < mPwdTable->Count; Index++) {\r
+    UserId    = (UINT8 *) &mPwdTable->UserInfo[Index].UserId;\r
+    NewUserId = (UINT8 *) (UserInfo + 1);\r
+    if (CompareMem (UserId, NewUserId, sizeof (EFI_USER_INFO_IDENTIFIER)) == 0) {\r
+      //\r
+      // Found the user, delete it.\r
+      //\r
+      ModifyTable (Index, NULL);\r
+      break;\r
+    }\r
+  }\r
+\r
+  FreePool (UserInfo);\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 \r
 /**\r
   Main entry for this driver.\r
@@ -1405,7 +1448,7 @@ PasswordProviderInit (
   //\r
   Status = gBS->InstallProtocolInterface (\r
                   &mCallbackInfo->DriverHandle,\r
-                  &gEfiUserCredentialProtocolGuid,\r
+                  &gEfiUserCredential2ProtocolGuid,\r
                   EFI_NATIVE_INTERFACE,\r
                   &gPwdCredentialProviderDriver\r
                   );\r