私は、次のコードを使用してAndroidのセキュアエレメント内のテキストの短い部分を保存しようとしている:AndroidKeyStoreにテキストを保存する方法は?
KeyStore ks = KeyStore.getInstance("AndroidKeyStore");
ks.load(null);
PasswordProtection keyStorePP = new KeyStore.PasswordProtection(null);
SecretKeyFactory factory = SecretKeyFactory.getInstance("PBEwithHmacSHA1");
SecretKey generatedSecret = factory.generateSecret(newPBEKeySpec(mySecureText.toCharArray()));
ks.setEntry("alias", new KeyStore.SecretKeyEntry(generatedSecret), keyStorePP);
上記のコードは次の例外与える:
08-17 14:39:32.832: W/System.err(11713): java.security.KeyStoreException: Unsupported protection parameter class: java.security.KeyStore$PasswordProtection. Supported: android.security.keystore.KeyProtection
は、私は何かがあります間違っているかAndroidKeyStoreは文字列の格納をサポートしていませんか?
最後に、BKSに切り替えるとコードが実行されます。
ありがとうございました。
ドキュメントによると、PasswordProtection ctorは、char [] password(null可)を受け取る必要があります。エラーは、SecretKeyEntry(generatedSecret)、keyStorePP)から発生します。 – user3913439