7

I wish to use the Android hardware-backed KeyStore, but I'm concerned about security and usability. From what I've read here, KeyStore gets wiped when the user changes the device lock, unless setEncryptionRequired() is omitted. For usability sake, it seems this needs to be done, otherwise all hardware-backed keys would get wiped once the device lock is modified.

However, I've also read here that hardware-backed keys are not actually stored in the TEE, but rather, stored as key files in /data/misc/keystore/user_0/, encrypted by a device specific key that is stored within the TEE. Since a change in device lock wipes the KeyStore, it seems that the device specific key is derived from the device lock.

For security reasons, it makes sense to encrypt the key file, otherwise any root user would be able to read the key files and extract the private key, since they'd presumably be in they clear.

So I'm kind of in a dilemma. For usability sake, I should omit setEncryptionRequired(), but for security sake, I should set setEncryptionRequired().

Lastly, is it possible import a private key into the hardware-backed KeyStore using setKeyEntry()? I'm able to do so with no errors but I'm not sure if it's hardware-backed.

Is my understanding correct?

1 Answer 1

1

setEncryptionRequired(): It is used to encrypt the key pair at rest and the encryption key is derived from the secure lock screen credential(e.g., password, PIN, or pattern).

Hardware Backed-Keystore: The key-entry files generated by hardware-backed keystore are encrypted using device-specific keys that is only accessible to trustlets executing in the TEE.

From the Android Sources

TEE processors have become a mainstay in today's mobile devices. The main processor on these devices is considered "untrusted" and cannot access certain areas of RAM, hardware registers and fuses where secret data (such as device-specific cryptographic keys) is stored by the manufacturer.

So these are the two different encryption implementations using different encryption keys. The key-entry files generated by hardware backed keystore are encrypted using device-specific keys.

To implement another layer of security, Android allows developers to encrypt the keys further using encryption key derived from the screen lock through setEncryptionRequired() option. It is clearly a functionality/security tradeoff relationship.

I personally feel that setEncryptionRequired() must be enabled for the devices that do not support hardware-backed keystore.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .