我需要在 Android 9 中支持安全元素和 StrongBox 的 Android 手机列表。我在哪里或如何找到它?
我用三星 Galaxy S9 和 AVD Google Pixle XL API 28 尝试了下面的代码
KeyPairGenerator kpg = null;
kpg = KeyPairGenerator.getInstance(
KeyProperties.KEY_ALGORITHM_RSA, "AndroidKeyStore");
kpg.initialize(new KeyGenParameterSpec.Builder("keystore1", KeyProperties.PURPOSE_SIGN)
.setCertificateSerialNumber(BigInteger.valueOf(1L))
.setCertificateSubject(new X500Principal("CN=MyCompany"))
.setIsStrongBoxBacked(true) /* Enable StrongBox */
.setInvalidatedByBiometricEnrollment(true)
.build());
KeyPair kp = kpg.generateKeyPair();
KeyFactory factory = KeyFactory.getInstance(KeyProperties.KEY_ALGORITHM_EC, "AndroidKeyStore");
KeyInfo keyInfo = factory.getKeySpec(kp.getPrivate(), KeyInfo.class);
keyInfo.isInsideSecureHardware();
它抛出以下异常:
android.security.keystore.StrongBoxUnavailableException:无法生成密钥对