Mobile apps

What are the iOS Keychain and Android Keystore?

The iOS Keychain and the Android Keystore are protected storage areas that apps use for sensitive values such as login tokens and encryption keys. Data is encrypted with keys backed by secure hardware, not kept in plain app files.

What belongs there

Refresh tokens, API session credentials, encryption keys and small secrets tied to the user. Not large data and not secrets that are the same for every installation, which can be extracted from a published app.

How they differ

The Keychain stores items and can sync them across a user's devices through iCloud if allowed; data can survive app deletion in some cases. Android's Keystore holds cryptographic keys that never leave secure hardware, and apps use them to encrypt a token saved in private storage. Libraries such as flutter_secure_storage and EncryptedSharedPreferences wrap both.

Pitfalls

  • Plain SharedPreferences or UserDefaults are not secure storage.
  • Define when items are readable: only while the device is unlocked is the safe default.
  • Clear stored values on logout, and think about what a restored backup does.
  • A rooted or jailbroken device weakens every on-device protection, so keep authorization checks on the server.

Questions, answered

Anything shipped inside the app can eventually be extracted; keep powerful keys on the server.

On iOS Keychain items may; on Android they are removed with the app.

By the Stegnor team · Updated