Throw UnrecoverableKeyException if key is missing.
During migration to KeyStore2 exception was converted to InternalRecoveryServiceException. Test: manual Bug: 207316987 Change-Id: I90a4c6745f2e3c1446c4c0fbac64035d582bb5a8
This commit is contained in:
@@ -264,6 +264,13 @@ public class RecoveryController {
|
||||
*/
|
||||
public static final int ERROR_DOWNGRADE_CERTIFICATE = 29;
|
||||
|
||||
/**
|
||||
* Requested key is not available in AndroidKeyStore.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public static final int ERROR_KEY_NOT_FOUND = 30;
|
||||
|
||||
private final ILockSettings mBinder;
|
||||
private final KeyStore mKeyStore;
|
||||
|
||||
@@ -703,6 +710,9 @@ public class RecoveryController {
|
||||
} catch (KeyPermanentlyInvalidatedException | UnrecoverableKeyException e) {
|
||||
throw new UnrecoverableKeyException(e.getMessage());
|
||||
} catch (ServiceSpecificException e) {
|
||||
if (e.errorCode == ERROR_KEY_NOT_FOUND) {
|
||||
throw new UnrecoverableKeyException(e.getMessage());
|
||||
}
|
||||
throw wrapUnexpectedServiceSpecificException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.android.server.locksettings.recoverablekeystore.storage;
|
||||
|
||||
import static android.security.keystore.recovery.RecoveryController.ERROR_KEY_NOT_FOUND;
|
||||
import static android.security.keystore.recovery.RecoveryController.ERROR_SERVICE_INTERNAL_ERROR;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
@@ -135,6 +136,11 @@ public class ApplicationKeyStorage {
|
||||
try {
|
||||
key = KeyStore2.getInstance().grant(key, uid, grantAccessVector);
|
||||
} catch (android.security.KeyStoreException e) {
|
||||
if (e.getNumericErrorCode()
|
||||
== android.security.KeyStoreException.ERROR_KEY_DOES_NOT_EXIST) {
|
||||
Log.e(TAG, "Failed to get grant for KeyStore key - key not found", e);
|
||||
throw new ServiceSpecificException(ERROR_KEY_NOT_FOUND, e.getMessage());
|
||||
}
|
||||
Log.e(TAG, "Failed to get grant for KeyStore key.", e);
|
||||
throw new ServiceSpecificException(ERROR_SERVICE_INTERNAL_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user