From 986c5022ab164a2cea46637af7fe48a82f25fa2b Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Wed, 5 Oct 2022 19:34:30 +0000 Subject: [PATCH] SyntheticPasswordCrypto: be less picky about Keystore error codes Don't assume that the error code for rollback resistance being unavailable is actually KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE, as devices that still use the reference implementation of Keymaster 3 don't use this error code. Bug: 232452368 Bug: 239632930 Bug: 251043073 Change-Id: I0574a376a97a204504614ea01b3d197faade8b78 --- .../server/locksettings/SyntheticPasswordCrypto.java | 8 -------- 1 file changed, 8 deletions(-) diff --git a/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java b/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java index 2a6ae44a99e87..cb6e43ce7d05f 100644 --- a/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java +++ b/services/core/java/com/android/server/locksettings/SyntheticPasswordCrypto.java @@ -17,7 +17,6 @@ package com.android.server.locksettings; import android.security.AndroidKeyStoreMaintenance; -import android.security.keymaster.KeymasterDefs; import android.security.keystore.KeyProperties; import android.security.keystore.KeyProtection; import android.security.keystore2.AndroidKeyStoreLoadStoreParameter; @@ -223,13 +222,6 @@ public class SyntheticPasswordCrypto { keyStore.setEntry(protectorKeyAlias, entry, protRollbackResistant); Slog.i(TAG, "Using rollback-resistant key"); } catch (KeyStoreException e) { - if (!(e.getCause() instanceof android.security.KeyStoreException)) { - throw e; - } - int errorCode = ((android.security.KeyStoreException) e.getCause()).getErrorCode(); - if (errorCode != KeymasterDefs.KM_ERROR_ROLLBACK_RESISTANCE_UNAVAILABLE) { - throw e; - } Slog.w(TAG, "Rollback-resistant keys unavailable. Falling back to " + "non-rollback-resistant key"); keyStore.setEntry(protectorKeyAlias, entry, protNonRollbackResistant);