Merge "Fix deleting legacy key blobs" am: c24a4b5f44

am: b3c61fac5f

Change-Id: I90950d0ecd4b5995ae513ed343f4d8b250183ff5
This commit is contained in:
Janis Danisevskis
2018-11-21 15:06:01 -08:00
committed by android-build-merger
2 changed files with 13 additions and 6 deletions

View File

@@ -282,8 +282,11 @@ public class Credentials {
* Returns {@code true} if the entry no longer exists. * Returns {@code true} if the entry no longer exists.
*/ */
public static boolean deleteUserKeyTypeForAlias(KeyStore keystore, String alias, int uid) { public static boolean deleteUserKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid) || int ret = keystore.delete2(Credentials.USER_PRIVATE_KEY + alias, uid);
keystore.delete(Credentials.USER_SECRET_KEY + alias, uid); if (ret == KeyStore.KEY_NOT_FOUND) {
return keystore.delete(Credentials.USER_SECRET_KEY + alias, uid);
}
return ret == KeyStore.NO_ERROR;
} }
/** /**

View File

@@ -255,16 +255,20 @@ public class KeyStore {
} }
} }
public boolean delete(String key, int uid) { int delete2(String key, int uid) {
try { try {
int ret = mBinder.del(key, uid); return mBinder.del(key, uid);
return (ret == NO_ERROR || ret == KEY_NOT_FOUND);
} catch (RemoteException e) { } catch (RemoteException e) {
Log.w(TAG, "Cannot connect to keystore", e); Log.w(TAG, "Cannot connect to keystore", e);
return false; return SYSTEM_ERROR;
} }
} }
public boolean delete(String key, int uid) {
int ret = delete2(key, uid);
return ret == NO_ERROR || ret == KEY_NOT_FOUND;
}
@UnsupportedAppUsage @UnsupportedAppUsage
public boolean delete(String key) { public boolean delete(String key) {
return delete(key, UID_SELF); return delete(key, UID_SELF);