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

Commit a258be67 authored by Janis Danisevskis's avatar Janis Danisevskis Committed by android-build-merger
Browse files

Merge "Fix deleting legacy key blobs" am: c24a4b5f am: b3c61fac

am: 4d8a0dec

Change-Id: I74ba06e7371696806a8ab1adbd7e65d806e208c4
parents bec8b4d1 4d8a0dec
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -282,8 +282,11 @@ public class Credentials {
     * Returns {@code true} if the entry no longer exists.
     */
    public static boolean deleteUserKeyTypeForAlias(KeyStore keystore, String alias, int uid) {
        return keystore.delete(Credentials.USER_PRIVATE_KEY + alias, uid) ||
                keystore.delete(Credentials.USER_SECRET_KEY + alias, uid);
        int ret = keystore.delete2(Credentials.USER_PRIVATE_KEY + alias, uid);
        if (ret == KeyStore.KEY_NOT_FOUND) {
            return keystore.delete(Credentials.USER_SECRET_KEY + alias, uid);
        }
        return ret == KeyStore.NO_ERROR;
    }

    /**
+8 −4
Original line number Diff line number Diff line
@@ -267,16 +267,20 @@ public class KeyStore {
        }
    }

    public boolean delete(String key, int uid) {
    int delete2(String key, int uid) {
        try {
            int ret = mBinder.del(key, uid);
            return (ret == NO_ERROR || ret == KEY_NOT_FOUND);
            return mBinder.del(key, uid);
        } catch (RemoteException 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
    public boolean delete(String key) {
        return delete(key, UID_SELF);