Search code examples
androidsecurityandroid-keystore

Android Keystore LoadStore and ProtectionParameter implementation examples?


A docs say:

The information stored in a ProtectionParameter object protects the contents of a keystore. For example, protection parameters may be used to check the integrity of keystore data, or to protect the confidentiality of sensitive keystore data (such as a PrivateKey).

But every single example is just passing null where this parameter may be used:

keystore.load(null);// here
KeyStore.Entry entry = keystore.getEntry(alias, null);//and here

Please any examples with not null parameters (like implemented interface that really does something)? Are the only possibility as for now is the PasswordProtection or there are custom implementations? And maybe some explanation why it is not critical in all the documentation and when it might become critical? Your suggestions are really valuable. Thanks.


Solution

  • Actually, there is a non-null example in KeyStore Documentation using the KeyStore.PasswordProtection.

    Another "implementation" (this is only a marker interface) is KeyProtection, where you can find, in addition to other examples, an explanation of it's purpose:

    Specification of how a key or key pair is secured when imported into the Android Keystore system. This class specifies authorized uses of the imported key, such as whether user authentication is required for using the key, what operations the key is authorized for (e.g., decryption, but not signing) with what parameters (e.g., only with a particular padding scheme or digest), and the key's validity start and end dates.