Protection of an ECC Key in an Android Application

2019-05-29 13:41发布

问题:

I have done an Android Application using an ECC Key pair. When I have developed it last year, I wanted to create the ECC key in the Android Keystore. Unfortunately, this ECC key is used to generate a session key thanks to ECDH, and ECDH is not supported by Android Keystore (this is what I have been said here: ECDH with key in Android Key Store )

I have followed the recommendations: I have created an AES key in the Android KeyStore and I have used it to encrypt the ECC key before storing it in the SharedPreferences. Android KeyStore ensures that the AES key cannot be extracted and that only my application can use it to decrypt the ECC key.

I now have a concern for which I would like your advices:

What if someone install my application on a rooted phone, gets the APK, uncompile and modify it to print the ECC key after that has been read and decrypted? I don’t have this skill but I guess that some hackers do. If that’s feasible, it means that the protection that I have used is not efficient.

Using ECDH is non-negotiable in my case so what solution do I have to secure my ECC key pair?

Thanks

回答1:

There is no way to ensure that the key is non-extractable unless it's backed by secure hardware.

And for the rooted phone case, attacker doesn't need to modify and reinstall your APK in order to use your key. Any app on that device with the root permission can hook into your app and behaves like it. Even in trusted environment they can use your hardware backed key. Only thing they can't do is, extracting the key from the device.

You may want to read the relatively old paper about TEE and AndroidKeyStore: http://www.cs.ru.nl/~joeri/papers/spsm14.pdf . Especially "Overview of the results for Device-binding"

In order to reduce attack surface, you can:

  • Protect your key with the user-provided password along with the AndroidKeyStore AES key
  • Use SafetyNet API to check device integrity: https://developer.android.com/training/safetynet/attestation