Go deepProStep 1 of 9

Inside Cachette: Argon2id, a hardware pepper and AES-256-GCM

How Cachette turns a pattern into a vault key with Argon2id and a hardware-held pepper, seals each file under its own AES-256-GCM key, and what it can't hide.

Cachette turns the pattern you draw into a 256-bit vault key in two steps: Argon2id, a function built to be slow and memory-hungry, then an HMAC with a "pepper" key that lives in your phone's hardware keystore and can't be copied out. Every photo, video and document gets its own random AES-256-GCM key, sealed under that vault key, and Cachette keeps no record of which vaults exist.

This is the full design, layer by layer: the parameters, the reason for each choice, and a plain list of what it doesn't hide. If you'd like the one-screen version first, the security page has it.

From pattern to key

The whole derivation fits in two lines:

stretched = Argon2id(pattern, salt, m = 128 MiB, t = 3, p = 4)
K         = HMAC-SHA256(key = pepper, message = stretched)

Each input has a job.

  • The pattern goes in as an ordered list of dot numbers on the 5 by 5 grid. Order matters, so the same shape drawn in reverse is a different key. In memory it's an array of integers, never text, for reasons covered below.
  • The salt is 16 random bytes created at install. It's stored with the Argon2id parameters in a plain configuration file, and that's by design: a salt isn't a secret. It makes each installation's derivation unique, so nobody can precompute a table of pattern-to-key answers that works on every phone. RFC 9106, the Argon2 standard, recommends a 128-bit salt, which is exactly 16 bytes.
  • Argon2id is a key derivation function: it turns a guessable secret into key material and makes every attempt expensive. Cachette runs it with 128 MiB of memory (m), 3 passes over that memory (t) and 4 lanes (p), parallel chains that can share the work across CPU cores. RFC 9106's recommended setting for systems short on memory is 64 MiB, 3 passes and 4 lanes, so this is twice the memory of that baseline.
  • HMAC-SHA256 (RFC 2104) is a keyed hash: its output depends on the message and on a secret key. Here the key is the pepper, and the 32-byte output is K, the vault key.

Why both steps? A pattern is a short secret. Argon2id makes each guess cost real memory and time, and the pepper means the vault's files can only be attacked on your phone. Argon2id vs PBKDF2 explains why short secrets need both.

The pepper and its fallback ladder

A pepper is a secret mixed into a password hash and kept apart from the data it guards. NIST's current guidance, SP 800-63B-4, recommends this kind of extra keyed step and says the key "SHOULD be stored and used within a hardware-protected area, such as a hardware security module or trusted execution environment (TEE)."

Cachette keeps its pepper as an HMAC key in the Android Keystore. Android's documentation spells out what that buys. Key material "never enters the application process", and when a key is bound to secure hardware, someone who compromises Android or reads the phone's storage "might be able to use any app's Android Keystore keys on the Android device, but it can't extract them from the device." The design rests on that sentence: files copied off the phone, salt included, give nobody a way to compute K for even one guess anywhere else. Backups, which are built to leave the phone, are the deliberate exception, covered below.

The pepper can live in one of three places, tried in this order on first run:

  1. StrongBox, a separate secure chip with its own CPU, secure storage and a true random number generator, on phones that include one (possible since Android 9). It supports HMAC-SHA256 keys.
  2. The TEE, or trusted execution environment: an isolated operating system that, in Google's description of its own Trusty TEE, "runs on the same processor as the Android OS" but is isolated "from the rest of the system by both hardware and software."
  3. Software, on a phone with neither. The key then has only Android's software protection, so the hardware guarantee quoted above doesn't apply.

The level is chosen once and fixed for the life of the installation. Moving the pepper would mean a new pepper, a new pepper would mean a new K for every pattern, and every existing vault would stop opening. Android Keystore, StrongBox and the TEE goes deeper into the hardware and shows how to check which of the three your phone has.

StrongBox has a documented cost: Android says it is "slower, more resource-constrained, and supports fewer concurrent operations." That suits this job, because an unlock uses the pepper once, for one short HMAC.

How each item is stored

Every photo, video or document becomes a record with two parts.

A sealed header

The header holds the item's own random key and its metadata, sealed under K. Sealed means authenticated encryption: without K the header can't be read, and the wrong key fails an integrity check instead of producing garbage. That property is what lets Cachette work without an index, as the next section shows.

Content in 1 MiB segments

The content is encrypted with AES-256-GCM under the item's key. GCM, standardised by NIST in SP 800-38D, is "an algorithm for authenticated encryption with associated data": it encrypts, and it adds a tag that exposes any change to the ciphertext.

A GCM tag covers a whole message, which is awkward for a long video. You'd either decrypt the entire file before showing a frame, or show data you haven't verified yet. So content is split into 1 MiB segments, each authenticated on its own. When the player asks for a stretch of video, Cachette verifies and decrypts just those segments, so playback and seeking work without a plaintext copy of the file ever being written.

Thumbnails are encrypted with their file. There's no thumbnail cache and no plaintext temporary file: what you see was decrypted into memory for that moment.

What the stored files show

File names are random. Sizes are padded, to the next 256 KiB step below 8 MiB and to the next 1 MiB step above. A 3.1 MiB photo and a 3.2 MiB photo both take up 3.25 MiB, so an exact size can't be used to recognise a known image.

Records go into uniformly random free slots among pre-allocated filler records, which look like random data. Write order therefore says nothing about which records belong together: a hundred photos imported in one go don't end up side by side.

Unlocking without a list of vaults

Cachette keeps no index of vaults, no count and no names. When you lift your finger, it derives K once, which is the expensive part, then tries to open every stored header with it. Headers that authenticate belong to the vault you just opened. Everything else stays closed, and in a copy of the storage, another vault's records and filler look alike.

A pattern that has never been used opens nothing, which is simply an empty vault: "Nothing here yet. Tap + to add photos, videos or files. Every pattern opens its own vault. Go back to draw a different one." There is no wrong pattern, so there is no wrong-pattern message.

Timing gets the same treatment. The screen holds for a fixed 1,000 ms from the moment your finger lifts to the vault's first frame, whatever the store holds, so a full vault, an empty one and a new one look identical to anyone watching. Deniable storage without a vault index covers why an index leaks and how this compares with VeraCrypt's hidden volumes.

Deleting, locking and memory

Deletion destroys the key

Deleting an item destroys its key, which leaves its content as ciphertext that nobody can open, Cachette included. NIST's media sanitisation guide, SP 800-88 Rev. 2, calls this cryptographic erase, which "is based on the sanitization of keys used to encrypt data." It also notes that where the data owner has no direct access to the physical storage, cryptographic erase may be the only viable option. An app is in exactly that position: Android and the flash memory's controller decide where bytes physically live, so overwriting a file doesn't prove the old bits are gone.

One honest footnote: flash storage can hold an older copy of a block for a while. An old copy of a header is still sealed under K, so reading it would take your pattern and your phone as well.

Keys in memory

Cachette holds the pattern as an integer array and key material in byte arrays, and overwrites them with zeros after use. In a managed runtime like Android's, where a garbage collector decides what happens to memory, that is best effort, and Cachette describes it that way. Two documented reasons:

  • Text can't be wiped. Oracle's cryptography guide explains that a String is immutable, with "no methods defined that allow you to change (overwrite) or zero out the contents". That's why the pattern never becomes one.
  • The runtime moves objects. Since Android 8, Android's runtime defragments its heap by "concurrently copying objects", so no app can be certain an earlier copy of an array wasn't left behind.

What Cachette can control, it does. Turning the screen off locks the vault and clears keys and thumbnails from memory, and leaving the app locks it. Every window is marked FLAG_SECURE, so screenshots, screen recording and casting are blocked and the recent-apps preview is blank.

The backup track

A backup can't use the pepper, because the pepper never leaves the phone that made it. A backup sealed with it would die with the phone it's meant to replace. So backups take a separate path:

  1. A backup holds one vault: the one that's open when you make it. To back up another vault, open it and back it up as well.
  2. Every backup gets its own new, random 24-word recovery phrase from the BIP-39 English word list. Each word encodes 11 bits, so 24 words carry 256 bits of entropy plus an 8-bit checksum.
  3. The backup is sealed under a key derived from that phrase's entropy with the same Argon2id settings, 128 MiB, 3 passes and 4 lanes, and no pepper. Sealed inside, ahead of the contents, is a check value for the vault's pattern, made with the same Argon2id settings and no pepper, so a new phone can confirm the pattern without the old phone's hardware.
  4. Restoring takes that file, its 24 words and that vault's pattern. It adds and never deletes.

Leaving out the pepper is what lets a backup restore on a new phone, so the phrase carries the weight instead. 256 random bits are far beyond any search, and because the pattern's check value sits inside the sealed part, a copy of the file on its own gives nothing to test pattern guesses against. Someone holding both the file and its 24 words is a different case: they can open the backup, and could test patterns against the check on their own hardware, paying a full 128 MiB Argon2id for every guess. A pattern found that way would open that vault on your phone, which is why the words belong on paper, apart from the file, and why a pattern that isn't a common shape still matters; the math of pattern locks shows why.

Write the words on paper (screenshots are blocked on that screen) with a note of which backup they open, and store the paper apart from the file. A backup is a snapshot, so back up again after adding things, and note which new words go with the new file. And know the one thing a backup can't do: it covers a lost, broken or reset phone, not a forgotten pattern, because restoring needs the pattern too.

What this design does not hide

Good security writing ends with the limits. These are Cachette's:

  • That the app is installed. Cachette doesn't disguise itself. On Android 15 and newer, Private Space can hide it, and the app shows how.
  • The total amount of encrypted data. Someone with a full forensic copy of the phone's storage can measure it. Padding hides exact sizes, not rough ones.
  • A phone that's already compromised. On a rooted phone or one running spyware, whoever controls it can watch the screen and use the phone's keys just as the app does.
  • A software pepper. Without StrongBox or a TEE, the pepper has only software protection. The Keystore post linked above shows how to check whether that's your phone.
  • A backup file together with its words. A backup can't use the pepper, so its 24 words are what seal it. Whoever has both the file and the words can open it, and test guesses at that vault's pattern away from the phone, at a full Argon2id each.
  • What happens outside the vault. Copies a cloud gallery uploaded before you imported a photo still exist there. Someone who watches you draw learns the pattern, and with a screen reader on, dot positions are spoken aloud, so headphones help near other people.
  • A forgotten pattern. Nobody can reset it, the developer included.

Some of this you can check for yourself today. adb shell dumpsys package app.cachette prints Cachette's permissions as Android records them, and android.permission.INTERNET is not among them. Checking an app's permissions with adb walks through it, and the security page lists the other ways to confirm it.

Check yourself

  1. Someone copies Cachette's vault storage off a phone, salt and settings included. Why can't they test patterns on a fast computer?

    Show the answer

    The last step of the derivation is an HMAC with a pepper key held in the phone's keystore, and that key can't be exported. Without it no guess produces the vault key, so every guess has to run on that phone.

  2. Why does Cachette split content into 1 MiB segments?

    Show the answer

    A GCM tag covers a whole message. Segments that are each authenticated let the app check and decrypt only the part a video player asks for, so playback starts without decrypting, or trusting, the whole file first.

Questions

What encryption does Cachette use?

Each photo, video or document is encrypted with AES-256-GCM under its own random key. That key is sealed under a vault key derived from your pattern with Argon2id (128 MiB, 3 passes, 4 lanes) and HMAC-SHA256 with a pepper held in the phone's hardware keystore.

Where does Cachette store the encryption key?

Nowhere. The vault key is derived each time you draw your pattern and cleared from memory when the vault locks. The pepper, one ingredient of it, stays inside Android's keystore, in StrongBox or the TEE where the phone has them, and cannot be exported.

Can a Cachette backup be restored on a different phone?

Yes. Each backup holds the vault that was open when you made it and is sealed under a key derived from its own 24-word recovery phrase instead of the phone-bound pepper, so it doesn't depend on the old phone's hardware. Restoring needs that file, its 24 words and that vault's pattern.