Usage of software/hardware-backed Android Keystore and possible security/usability drawbacks

后端 未结 2 1575
鱼传尺愫
鱼传尺愫 2021-02-13 09:57

I\'m currently looking at the possibilities of storing/using secrets keys in an Android application. I\'ve found Nikolay Elenkov\'s blog very helpful regarding this topic and I\

相关标签:
2条回答
  • 2021-02-13 10:12
    • Does using the keystore enforce the use of a password-protected lock screen ?

    Yes, user is forced to use lock screen, protected with password, pin, or pattern.

    • Does the user have to input his/her password every time an access to the encrypted keys is required ?

    No, once the device is unloked, KeyStore becomes unlocked as well and there's no need to enter additional passwords. However, application should check if the KeyStore is unlocked, because user could disable the lock screen protection in Settings. Once key locked is disabled, KeyStore becomes uninitialized and must be unlocked again.

    Several times I faced a strange behavior, when the KeyStore was locked, but I didn't have lock screen protection set up. I was prompted to enter a password or pin code to enter the KeyStore. However, it was not possible, since I didn't have any passwords. I assume some system apps were locking the KeyStore. I had to reset it to re-initialize.

    • Given it's a software-only mechanism, I think a secret key will always end up decrypted in RAM whenever it's used for cryptographic operations, right ?

    Yes, all keys retrieved from the KeyStore will reside in RAM until garbage-collected or deinitialized. But you can obtain the key each time you need it, not keeping it in some long-living variable.

    Unfortunately, I'm not familiar with HW-backed KeyStore. Cannot say anything about it.

    0 讨论(0)
  • 2021-02-13 10:13

    Your analysis of the TEE-based hardware-backed scenario is correct. The private key bits generated in the TEE (which isn't necessarily compliant with the Global Platform specs) never leave the TEE and private key operations are performed inside it.

    You're also correct that the handles to the TEE-based keys are stored in Keystore, so it's possible for root to access and use any of them, or to move them around so any app can use them.

    0 讨论(0)
提交回复
热议问题