Skip to content

Encrypted device token storage (Keystore AES-GCM) #4

Closed

Description

@mikahatdichlieb

Store the dcd_... device token encrypted, as agreed (variant A):

  • Key: AndroidKeyStore, AES-256-GCM, 12-byte IV generated randomly by the Keystore. No setUserAuthenticationRequired and no setUnlockedDeviceRequired, because the background sync needs the key. StrongBox is tried first, falling back to the hardware or software Keystore.
  • File: in noBackupFilesDir, written via AtomicFile. It is excluded from backups, in addition to allowBackup="false".
  • Format: IV ‖ ciphertext. The associated data is a fixed context string plus the format version.
  • If the key is missing or decryption fails (for example after a restore or a Keystore reset), the state is treated like a 401: the device has to be re-paired. The event buffer is kept. There is no retry loop.
  • The token is never logged.

Threat model: this protects against file extraction (backups, ADB on unrooted devices, disk images, other apps). It does not protect against root or against malware running under the app's UID. A student who roots their own device can extract the token.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions