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

Commit b6a9ed2f authored by Janis Danisevskis's avatar Janis Danisevskis
Browse files

Keystore 2.0: Fix getKey returns null on key not found.

Test: CTS test.
Change-Id: I2a1edcf275da02cf005b6600450d152530eceaa9
parent 84da5781
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
@@ -352,11 +352,14 @@ public class AndroidKeyStoreProvider extends Provider {
        try {
            response = keyStore.getKeyEntry(descriptor);
        } catch (android.security.KeyStoreException e) {
            if (e.getErrorCode() == ResponseCode.KEY_PERMANENTLY_INVALIDATED) {
            switch (e.getErrorCode()) {
                case ResponseCode.KEY_NOT_FOUND:
                    return null;
                case ResponseCode.KEY_PERMANENTLY_INVALIDATED:
                    throw new KeyPermanentlyInvalidatedException(
                            "User changed or deleted their auth credentials",
                            e);
            } else {
                default:
                    throw (UnrecoverableKeyException)
                            new UnrecoverableKeyException("Failed to obtain information about key")
                                    .initCause(e);