How to check for StrongBox Keymaster hardware availability before key generation?
Asked Answered
T

1

6

I am looking for a solution where I can use StrongBox hardware if present in the device to store my cryptographic keys. Currently, I am creating keys having setIsStrongBoxBacked(true) method in KeyGenParameterSpec builder, and when the StrongBoxUnavailableException occurs I fallback to generate keys without it.

Thou answered 22/10, 2019 at 10:33 Comment(0)
E
15

You can check whether the device has feature of "PackageManager.FEATURE_STRONGBOX_KEYSTORE" like this:

boolean hasStrongBox() {
       return mActivity.getPackageManager()
           .hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE)
}

or

boolean hasStrongBox;
hasStrongBox = getContext().getPackageManager().hasSystemFeature(PackageManager.FEATURE_STRONGBOX_KEYSTORE);

Engrave answered 23/12, 2019 at 2:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.