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

Commit 01ac9e74 authored by Janis Danisevskis's avatar Janis Danisevskis
Browse files

Keystore 2.0 SPI: Fix NullPointerException in setKeyEntry.

Fix a NullPointerException when trying to insert SecretKey that already
exists.

Bug: 202146009
Test: atest android.keystore.cts.AndroidKeyStoreTest#testKeyStore_SetKeyEntry_ReplacedWithSameGeneratedSecretKey
Merged-In: If3a4bd6677ab3173c5c1a7c921ba567b7981662b
Change-Id: If3a4bd6677ab3173c5c1a7c921ba567b7981662b
parent db38b7fa
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -601,8 +601,6 @@ public class AndroidKeyStoreSpi extends KeyStoreSpi {
        }
        KeyProtection params = (KeyProtection) param;

        @SecurityLevel int securityLevel = params.isStrongBoxBacked() ? SecurityLevel.STRONGBOX :
                SecurityLevel.TRUSTED_ENVIRONMENT;
        @Domain int targetDomain = (getTargetDomain());

        if (key instanceof AndroidKeyStoreSecretKey) {
@@ -794,6 +792,9 @@ public class AndroidKeyStoreSpi extends KeyStoreSpi {
            flags |= IKeystoreSecurityLevel.KEY_FLAG_AUTH_BOUND_WITHOUT_CRYPTOGRAPHIC_LSKF_BINDING;
        }

        @SecurityLevel int securityLevel = params.isStrongBoxBacked() ? SecurityLevel.STRONGBOX :
                SecurityLevel.TRUSTED_ENVIRONMENT;

        try {
            KeyStoreSecurityLevel securityLevelInterface = mKeyStore.getSecurityLevel(
                    securityLevel);