Security and privacy

5 concepts · 15 practice questions

Secrets and tokens on the device

Anything inside the APK can be read by anyone who unpacks it, so real secrets live on a server. Keys generated in the Android Keystore cannot be extracted from the device; use one to encrypt tokens before storing them, and keep tokens out of backups and logs.

val spec = KeyGenParameterSpec.Builder(
    "token_key",
    KeyProperties.PURPOSE_ENCRYPT or KeyProperties.PURPOSE_DECRYPT,
)
    .setBlockModes(KeyProperties.BLOCK_MODE_GCM)
    .setEncryptionPaddings(KeyProperties.ENCRYPTION_PADDING_NONE)
    .build()
KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_AES, "AndroidKeyStore")
    .apply { init(spec) }
    .generateKey()

Also covered

Network security
Exported components and intents
Permissions and privacy
Authentication

Sign in to read the rest and take the 15-question test.

Sign in to continue