diff options
| author | Andres Morales <anmorales@google.com> | 2015-04-14 16:12:48 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-04-14 16:12:55 +0000 |
| commit | 317918e206b89f4a49bfa35af57607764f322347 (patch) | |
| tree | f56545620e341f21a86eedff65090b8124bbc4ad /core/java | |
| parent | 34e79c1e570673148e3e0bbd91df3180a00eeff1 (diff) | |
| parent | d9fc85ac27742adbe89e54fd35f3cb2469e94b91 (diff) | |
Merge changes from topic 'lss-update'
* changes:
Add challenge to IGateKeeperService
Wire up GateKeeper to LockSettingsService
Diffstat (limited to 'core/java')
3 files changed, 123 insertions, 12 deletions
diff --git a/core/java/android/service/gatekeeper/IGateKeeperService.aidl b/core/java/android/service/gatekeeper/IGateKeeperService.aidl new file mode 100644 index 000000000000..2f3e296f483f --- /dev/null +++ b/core/java/android/service/gatekeeper/IGateKeeperService.aidl @@ -0,0 +1,65 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package android.service.gatekeeper; + +/** + * Interface for communication with GateKeeper, the + * secure password storage daemon. + * + * This must be kept manually in sync with system/core/gatekeeperd + * until AIDL can generate both C++ and Java bindings. + * + * @hide + */ +interface IGateKeeperService { + /** + * Enrolls a password, returning the handle to the enrollment to be stored locally. + * @param uid The Android user ID associated to this enrollment + * @param currentPasswordHandle The previously enrolled handle, or null if none + * @param currentPassword The previously enrolled plaintext password, or null if none. + * If provided, must verify against the currentPasswordHandle. + * @param desiredPassword The new desired password, for which a handle will be returned + * upon success. + * @return the handle corresponding to desiredPassword, or null + */ + byte[] enroll(int uid, in byte[] currentPasswordHandle, in byte[] currentPassword, + in byte[] desiredPassword); + + /** + * Verifies an enrolled handle against a provided, plaintext blob. + * @param uid The Android user ID associated to this enrollment + * @param enrolledPasswordHandle The handle against which the provided password will be + * verified. + * @param The plaintext blob to verify against enrolledPassword. + * @return True if the authentication was successful + */ + boolean verify(int uid, in byte[] enrolledPasswordHandle, + in byte[] providedPassword); + /** + * Verifies an enrolled handle against a provided, plaintext blob. + * @param uid The Android user ID associated to this enrollment + * @param challenge a challenge to authenticate agaisnt the device credential. If successful + * authentication occurs, this value will be written to the returned + * authentication attestation. + * @param enrolledPasswordHandle The handle against which the provided password will be + * verified. + * @param The plaintext blob to verify against enrolledPassword. + * @return an opaque attestation of authentication on success, or null. + */ + byte[] verifyChallenge(int uid, long challenge, in byte[] enrolledPasswordHandle, + in byte[] providedPassword); +} diff --git a/core/java/com/android/internal/widget/ILockSettings.aidl b/core/java/com/android/internal/widget/ILockSettings.aidl index 0cb1f38cf11f..bfafff6ae903 100644 --- a/core/java/com/android/internal/widget/ILockSettings.aidl +++ b/core/java/com/android/internal/widget/ILockSettings.aidl @@ -24,10 +24,12 @@ interface ILockSettings { boolean getBoolean(in String key, in boolean defaultValue, in int userId); long getLong(in String key, in long defaultValue, in int userId); String getString(in String key, in String defaultValue, in int userId); - void setLockPattern(in String pattern, int userId); + void setLockPattern(in String pattern, in String savedPattern, int userId); boolean checkPattern(in String pattern, int userId); - void setLockPassword(in String password, int userId); + byte[] verifyPattern(in String pattern, long challenge, int userId); + void setLockPassword(in String password, in String savedPassword, int userId); boolean checkPassword(in String password, int userId); + byte[] verifyPassword(in String password, long challenge, int userId); boolean checkVoldPassword(int userId); boolean havePattern(int userId); boolean havePassword(int userId); diff --git a/core/java/com/android/internal/widget/LockPatternUtils.java b/core/java/com/android/internal/widget/LockPatternUtils.java index 2967876b0098..123d1ac21b97 100644 --- a/core/java/com/android/internal/widget/LockPatternUtils.java +++ b/core/java/com/android/internal/widget/LockPatternUtils.java @@ -280,6 +280,24 @@ public class LockPatternUtils { } /** + * Check to see if a pattern matches the saved pattern. + * If pattern matches, return an opaque attestation that the challenge + * was verified. + * + * @param pattern The pattern to check. + * @param challenge The challenge to verify against the pattern + * @return the attestation that the challenge was verified, or null. + */ + public byte[] verifyPattern(List<LockPatternView.Cell> pattern, long challenge) { + final int userId = getCurrentOrCallingUserId(); + try { + return getLockSettings().verifyPattern(patternToString(pattern), challenge, userId); + } catch (RemoteException re) { + return null; + } + } + + /** * Check to see if a pattern matches the saved pattern. If no pattern exists, * always returns true. * @param pattern The pattern to check. @@ -295,6 +313,24 @@ public class LockPatternUtils { } /** + * Check to see if a password matches the saved password. + * If password matches, return an opaque attestation that the challenge + * was verified. + * + * @param password The password to check. + * @param challenge The challenge to verify against the password + * @return the attestation that the challenge was verified, or null. + */ + public byte[] verifyPassword(String password, long challenge) { + final int userId = getCurrentOrCallingUserId(); + try { + return getLockSettings().verifyPassword(password, challenge, userId); + } catch (RemoteException re) { + return null; + } + } + + /** * Check to see if a password matches the saved password. If no password exists, * always returns true. * @param password The password to check. @@ -425,8 +461,8 @@ public class LockPatternUtils { setLong(PASSWORD_TYPE_KEY, DevicePolicyManager.PASSWORD_QUALITY_UNSPECIFIED, userHandle); try { - getLockSettings().setLockPassword(null, userHandle); - getLockSettings().setLockPattern(null, userHandle); + getLockSettings().setLockPassword(null, null, userHandle); + getLockSettings().setLockPattern(null, null, userHandle); } catch (RemoteException e) { // well, we tried... } @@ -477,24 +513,30 @@ public class LockPatternUtils { /** * Save a lock pattern. * @param pattern The new pattern to save. + * @param savedPattern The previously saved pattern, or null if none */ - public void saveLockPattern(List<LockPatternView.Cell> pattern) { - this.saveLockPattern(pattern, getCurrentOrCallingUserId()); + public void saveLockPattern(List<LockPatternView.Cell> pattern, + String savedPattern) { + this.saveLockPattern(pattern, savedPattern, getCurrentOrCallingUserId()); } + public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) { + this.saveLockPattern(pattern, null, userId); + } /** * Save a lock pattern. * @param pattern The new pattern to save. + * @param savedPattern The previously saved pattern, converted to String format * @param userId the user whose pattern is to be saved. */ - public void saveLockPattern(List<LockPatternView.Cell> pattern, int userId) { + public void saveLockPattern(List<LockPatternView.Cell> pattern, String savedPattern, int userId) { try { if (pattern == null || pattern.size() < MIN_LOCK_PATTERN_SIZE) { throw new IllegalArgumentException("pattern must not be null and at least " + MIN_LOCK_PATTERN_SIZE + " dots long."); } - getLockSettings().setLockPattern(patternToString(pattern), userId); + getLockSettings().setLockPattern(patternToString(pattern), savedPattern, userId); DevicePolicyManager dpm = getDevicePolicyManager(); // Update the device encryption password. @@ -685,10 +727,11 @@ public class LockPatternUtils { * as the requested mode, but will adjust the mode to be as good as the * pattern. * @param password The password to save + * @param savedPassword The previously saved lock password, or null if none * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} */ - public void saveLockPassword(String password, int quality) { - saveLockPassword(password, quality, getCurrentOrCallingUserId()); + public void saveLockPassword(String password, String savedPassword, int quality) { + saveLockPassword(password, savedPassword, quality, getCurrentOrCallingUserId()); } /** @@ -699,7 +742,8 @@ public class LockPatternUtils { * @param quality {@see DevicePolicyManager#getPasswordQuality(android.content.ComponentName)} * @param userHandle The userId of the user to change the password for */ - public void saveLockPassword(String password, int quality, int userHandle) { + public void saveLockPassword(String password, String savedPassword, int quality, + int userHandle) { try { DevicePolicyManager dpm = getDevicePolicyManager(); if (password == null || password.length() < MIN_LOCK_PASSWORD_SIZE) { @@ -707,7 +751,7 @@ public class LockPatternUtils { + "of length " + MIN_LOCK_PASSWORD_SIZE); } - getLockSettings().setLockPassword(password, userHandle); + getLockSettings().setLockPassword(password, savedPassword, userHandle); int computedQuality = computePasswordQuality(password); // Update the device encryption password. |
