From c33e2a1cefa3a91c4e798b25c432ecf02914921a Mon Sep 17 00:00:00 2001 From: Rubin Xu Date: Fri, 30 Mar 2018 20:51:24 +0100 Subject: [PATCH] Switch to new checkPasswordHistory method This is part of the fix that upgrades the hashing of password history to a more secure design. Bug: 32826058 Test: manual Change-Id: Ib022c8db1f7b63f75b69d0177fa5f6be528a83c5 --- .../settings/password/ChooseLockPassword.java | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/com/android/settings/password/ChooseLockPassword.java b/src/com/android/settings/password/ChooseLockPassword.java index 14f7d6bd6c4..e60b4e6d0e5 100644 --- a/src/com/android/settings/password/ChooseLockPassword.java +++ b/src/com/android/settings/password/ChooseLockPassword.java @@ -193,6 +193,7 @@ public class ChooseLockPassword extends SettingsActivity { private int mPasswordMinLengthToFulfillAllPolicies = 0; protected int mUserId; private boolean mHideDrawer = false; + private byte[] mPasswordHistoryHashFactor; /** * Password requirements that we need to verify. */ @@ -667,7 +668,8 @@ public class ChooseLockPassword extends SettingsActivity { } } // Is the password recently used? - if (mLockPatternUtils.checkPasswordHistory(password, mUserId)) { + if (mLockPatternUtils.checkPasswordHistory(password, getPasswordHistoryHashFactor(), + mUserId)) { errorCode |= RECENTLY_USED; } } @@ -730,6 +732,18 @@ public class ChooseLockPassword extends SettingsActivity { return errorCode; } + /** + * Lazily compute and return the history hash factor of the current user (mUserId), used for + * password history check. + */ + private byte[] getPasswordHistoryHashFactor() { + if (mPasswordHistoryHashFactor == null) { + mPasswordHistoryHashFactor = mLockPatternUtils.getPasswordHistoryHashFactor( + mCurrentPassword, mUserId); + } + return mPasswordHistoryHashFactor; + } + public void handleNext() { if (mSaveAndFinishWorker != null) return; mChosenPassword = mPasswordEntry.getText().toString();