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.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Sachin Chauhan
  • 356
  • 1
  • 11

1 Answers1

12

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);

StoneLi
  • 136
  • 2
  • 4