Android4.3でサポートされたHardware Credential Storageの機能。
http://developer.android.com/intl/ja/about/versions/android-4.3.html#Security
ハードウェア側で保証された安全な領域にキーなどを保存してくれるようだが
どう使えばいいのか。
ドキュメントによると機能がサポートれされているかは
KeyChainクラスのisBoundKeyAlgorithm()を使えば分かるらしい。
if (KeyChain.isBoundKeyAlgorithm("RSA")) { //ここに処理を記述 }
引数のアルゴリズムに何を渡せばいいのかと思ったがソースを見る限りでは
どうやら"RSA"の一択らしい。
/** * Returns {@code true} if the current device's {@code KeyChain} binds any * {@code PrivateKey} of the given {@code algorithm} to the device once * imported or generated. This can be used to tell if there is special * hardware support that can be used to bind keys to the device in a way * that makes it non-exportable. */ public static boolean isBoundKeyAlgorithm(String algorithm) { if (!isKeyAlgorithmSupported(algorithm)) { return false; } return KeyStore.getInstance().isHardwareBacked(); } /** * Returns {@code true} if the current device's {@code KeyChain} supports a * specific {@code PrivateKey} type indicated by {@code algorithm} (e.g., * "RSA"). */ public static boolean isKeyAlgorithmSupported(String algorithm) { return "RSA".equals(algorithm); }
で、最新のNexus 7 2013で実行してみたらfalseが返ってきた。
サポートしてないのか。orz
と思いきや、OSをアップデータとしたらちゃんと対応してくれたようだ。
設定 > セキュリティ > 認証情報ストレージ > ストレージタイプ