Skip to main content

Session Storage

This guide covers securely storing and restoring Privacy Boost sessions using Android Keystore, expanding on the persistence options in Key Management.

Why Keystore?

Session data includes sensitive cryptographic keys. Android Keystore provides:
  • Hardware-backed encryption (TEE/Secure Element)
  • Key material never leaves secure hardware
  • Biometric authentication support
  • Protection against extraction

EncryptedSharedPreferences

The simplest approach using AndroidX Security:

Setup

Add dependency:

Implementation

Biometric Authentication

Add biometric protection for session access:

Setup

Add dependencies:

BiometricSessionStorage

Usage in Repository

ViewModel Integration

Security Best Practices

  1. Use BIOMETRIC_STRONG - Requires Class 3 biometrics
  2. Set invalidatedByBiometricEnrollment - Invalidate key if new biometric enrolled
  3. No timeout - Require auth every time for sensitive data
  4. Handle key invalidation - Clear session if key is invalidated
  5. Don’t store unencrypted - Always encrypt sensitive data

Next Steps