Merge "Keystore 2.0: isKeystore2Enabled returned wrong value." am: 51bf93a35a

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1572822

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: Id8742a4f74a0e5339af6d35f03a2d6173a700680
This commit is contained in:
Treehugger Robot
2021-02-03 23:00:35 +00:00
committed by Automerger Merge Worker

View File

@@ -23,7 +23,6 @@ import android.security.KeyStore;
import android.security.keymaster.ExportResult; import android.security.keymaster.ExportResult;
import android.security.keymaster.KeyCharacteristics; import android.security.keymaster.KeyCharacteristics;
import android.security.keymaster.KeymasterDefs; import android.security.keymaster.KeymasterDefs;
import android.sysprop.Keystore2Properties;
import java.io.IOException; import java.io.IOException;
import java.security.KeyFactory; import java.security.KeyFactory;
@@ -117,8 +116,6 @@ public class AndroidKeyStoreProvider extends Provider {
putSecretKeyFactoryImpl("HmacSHA512"); putSecretKeyFactoryImpl("HmacSHA512");
} }
private static boolean sKeystore2Enabled;
/** /**
* This function indicates whether or not Keystore 2.0 is enabled. Some parts of the * This function indicates whether or not Keystore 2.0 is enabled. Some parts of the
* Keystore SPI must behave subtly differently when Keystore 2.0 is enabled. However, * Keystore SPI must behave subtly differently when Keystore 2.0 is enabled. However,
@@ -133,10 +130,9 @@ public class AndroidKeyStoreProvider extends Provider {
* @hide * @hide
*/ */
public static boolean isKeystore2Enabled() { public static boolean isKeystore2Enabled() {
return sKeystore2Enabled; return android.security.keystore2.AndroidKeyStoreProvider.isInstalled();
} }
/** /**
* Installs a new instance of this provider (and the * Installs a new instance of this provider (and the
* {@link AndroidKeyStoreBCWorkaroundProvider}). * {@link AndroidKeyStoreBCWorkaroundProvider}).
@@ -164,11 +160,6 @@ public class AndroidKeyStoreProvider extends Provider {
// priority. // priority.
Security.addProvider(workaroundProvider); Security.addProvider(workaroundProvider);
} }
// {@code install()} is run by zygote when this property is still accessible. We store its
// value so that the Keystore SPI can act accordingly without having to access an internal
// property.
sKeystore2Enabled = Keystore2Properties.keystore2_enabled().orElse(false);
} }
private void putSecretKeyFactoryImpl(String algorithm) { private void putSecretKeyFactoryImpl(String algorithm) {