Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3188574c authored by Andres Morales's avatar Andres Morales Committed by Android (Google) Code Review
Browse files

Merge "[LockSettings] adjust legacy patterns to base 0 for unlocking keystore" into mnc-dev

parents eb60c42d 59ef126f
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        void setCredential(String credential, String savedCredential, int userId)
                throws RemoteException;
        byte[] toHash(String credential, int userId);
        String adjustForKeystore(String credential);
    }

    public LockSettingsService(Context context) {
@@ -528,6 +529,11 @@ public class LockSettingsService extends ILockSettings.Stub {
                       return LockPatternUtils.patternToHash(
                               LockPatternUtils.stringToPattern(pattern));
                   }

                   @Override
                   public String adjustForKeystore(String pattern) {
                       return LockPatternUtils.patternStringToBaseZero(pattern);
                   }
               }
       );

@@ -568,6 +574,11 @@ public class LockSettingsService extends ILockSettings.Stub {
                   public byte[] toHash(String password, int userId) {
                       return mLockPatternUtils.passwordToHash(password, userId);
                   }

                   @Override
                   public String adjustForKeystore(String password) {
                       return password;
                   }
               }
       );
    }
@@ -587,7 +598,7 @@ public class LockSettingsService extends ILockSettings.Stub {
        if (storedHash.version == CredentialHash.VERSION_LEGACY) {
            byte[] hash = credentialUtil.toHash(credential, userId);
            if (Arrays.equals(hash, storedHash.hash)) {
                unlockKeystore(credential, userId);
                unlockKeystore(credentialUtil.adjustForKeystore(credential), userId);
                // migrate credential to GateKeeper
                credentialUtil.setCredential(credential, null, userId);
                if (!hasChallenge) {