An Android app's keys live in one of three places. Software means Android itself guards the key. The trusted execution environment (TEE) is a walled-off mode of the phone's main processor that runs its own small operating system. StrongBox is a separate secure chip with its own processor, storage and random number generator, built to resist physical attacks.
The Android Keystore puts one interface in front of all three, keeps the key away from the app that uses it, and lets the app ask which one holds it. That last part lets an app learn what guards your data on your phone, and Cachette uses it to record where its own key ended up.
What the Android Keystore does
The Android Keystore is a system service that creates, stores and uses cryptographic keys for apps. Google's Keystore documentation states the core promise in one line: "Key material never enters the application process." The app hands data in and gets a result back, such as a signature or a keyed hash, but it never holds the key itself.
Keys can also be bound to secure hardware. Then, Google says, the key material "is never exposed outside of secure hardware." Even if Android is compromised or someone can read the phone's internal storage, the attacker "might be able to use any app's Android Keystore keys on the Android device, but it can't extract them from the device." That is what a non-exportable key means: usable here, impossible to carry away.
The feature grew in steps, according to Android's platform documentation. Android 6.0 added hardware-backed AES and HMAC keys, Android 7.0 added key attestation, Android 9 added support for embedded secure elements, and Android 12 replaced the old Keymaster hardware interface with KeyMint, the one current phones use.
Software, TEE or StrongBox: the three places a key can live
Google's attestation documentation rates each level, summarised below.
| Level, as Android reports it | Where the key is used | What keeps it apart | How Google rates it |
|---|---|---|---|
| Software | Inside Android | Android's own app sandbox and permissions | Holds while Android itself follows its security model |
| TEE (trusted environment) | A protected mode of the main processor | Hardware isolation on the same chip | "Highly resistant to remote compromise and moderately resistant to compromise by direct hardware attack" |
| StrongBox | A separate secure element | Its own processor, built to resist tampering | Highly resistant to remote and direct hardware attacks |
The TEE
Google's own TEE, Trusty, "runs on the same processor as the Android OS, but Trusty is isolated from the rest of the system by both hardware and software." On Arm chips it uses TrustZone, an Arm processor feature, to wall itself off.
The TEE isn't an extra on current phones. The Android 16 Compatibility Definition Document, the rules a phone must meet to count as Android compatible, says handheld devices "MUST back up the keystore implementation with an isolated execution environment," with exemptions for some phones that launched on older versions.
StrongBox
StrongBox moves the key off the main processor entirely. Google's developer guide says phones running Android 9 or later can include it, and that it denotes "embedded SEs or integrated Secure Enclaves (iSE), providing stronger isolation and tamper resistance compared to the TEE." An SE, or secure element, is a small security chip of the kind used in SIM and payment cards.
The Android 16 rules spell out what that means. A StrongBox must have "a discrete CPU that shares no cache, DRAM, coprocessors" with the main processor, resistance to physical penetration and glitching (deliberately disturbing the chip's power or clock to make it misbehave), side-channel resistance against leaks through power use or timing, and hardware certified against the Secure IC Protection Profile, a Common Criteria standard for security chips. StrongBox is not yet required: the same document says devices "are STRONGLY RECOMMENDED to support StrongBox" and that it "will likely become a requirement in a future release."
The trade-off is speed. Google's guide warns that StrongBox "is slower, more resource-constrained, and supports fewer concurrent operations," and that "for most apps, StrongBox is not necessary." It supports a short list of algorithms: RSA 2048, AES 128 and 256, ECDSA and ECDH on P-256, Triple DES, and HMAC-SHA256 with keys from 8 to 64 bytes.
Secure hardware you can name: Titan M2 and Knox Vault
- Pixel: Titan M2. From the Pixel 6 on, Pixels carry a separate security chip called Titan M2. Google's Pixel 6 security post says "Titan M2 supports Android Strongbox, which securely generates and stores keys used to protect your PINs and password," and that it was tested against AVA_VAN.5, which Google calls "the most rigorous standard for vulnerability assessment," by an independent lab. Google's Pixel certifications page lists the chip for the Pixel 10 series with a Common Criteria certificate.
- Samsung: Knox Vault. Samsung's Knox Vault, in select Galaxy devices starting from the Galaxy S21, has its own processor and memory chip, separate from the main processor, and wipes that memory if its sensors detect a physical attack. Android's StrongBox runs on the Knox Vault processor, and Samsung says the design "protects sensitive data even if the primary processor itself is completely compromised."
To check your own phone, turn on USB debugging, connect it to a computer and run:
adb shell pm list features | grep keystore
According to Android's PackageManager reference, android.hardware.hardware_keystore means the keystore is backed by an isolated environment such as a TEE, and android.hardware.strongbox_keystore means the phone also has StrongBox. Phones that launched before Android 12 may not list the first feature even when they have a TEE. If adb is new to you, checking an app's permissions with adb walks through the setup.
How an app finds out where its key lives
Three tools cover asking, reading and proving.
- Ask for StrongBox. An app requests it when it creates a key, with
setIsStrongBoxBacked(true). If StrongBox can't hold that kind of key, Android throwsStrongBoxUnavailableException, and the app tries again without the request, which usually lands the key in the TEE. - Read the level. On Android 12 and later, KeyInfo has
getSecurityLevel(), which returns software, trusted environment or StrongBox, or one of two "unknown" values. On older versions,isInsideSecureHardware()answers only yes or no. - Prove it to someone else. Key attestation gives a key pair a certificate chain signed inside the secure hardware and anchored in Google's attestation root. A server can check the chain, the revocation list and the recorded security level.
A minimal Kotlin sketch of the first two steps, as a general example:
val spec = KeyGenParameterSpec.Builder("pepper", KeyProperties.PURPOSE_SIGN)
.setIsStrongBoxBacked(true)
.build()
val key = KeyGenerator.getInstance(KeyProperties.KEY_ALGORITHM_HMAC_SHA256, "AndroidKeyStore")
.apply { init(spec) }
.generateKey() // StrongBoxUnavailableException here means: retry without StrongBox
val info = SecretKeyFactory.getInstance(key.algorithm, "AndroidKeyStore")
.getKeySpec(key, KeyInfo::class.java) as KeyInfo
val level = info.securityLevel // Android 12 and later
Attestation is built for key pairs: Google's platform documentation describes it as a way "to strongly determine if an asymmetric key pair is hardware-backed." For a symmetric key, such as an AES or HMAC key, KeyInfo is the answer: a report from the phone's own Keystore, useful on your own phone but not a signed proof. That is also why Google's attestation guide tells developers not to validate attestations on the same device: "If the Android system on that device is compromised, that could cause the validation process to trust something that is untrustworthy."
How Cachette uses it: a pepper, not the root of trust
A pepper is a secret key mixed into password hashing and stored away from the hashes. The NIST guidelines for password storage recommend "an additional iteration of a keyed hashing or encryption operation using a secret key known only to the verifier," stored separately and ideally "within a hardware-protected area." The OWASP password storage guide adds that peppers "should be stored in 'secrets vaults' or HSMs" (hardware security modules, dedicated key-holding devices), and describes the post-hashing version, where the password hash "is then hashed again using an HMAC."
Cachette follows the post-hashing version on the phone. Your pattern goes through Argon2id, a deliberately slow and memory-hungry hashing function, with 128 MiB of memory, 3 passes and 4 lanes. The result then goes through HMAC-SHA256 with a pepper key held in the hardware keystore: in StrongBox where the phone has one, otherwise in the TEE.
The output is the vault key. Each file is encrypted with AES-256-GCM, which also detects tampering, under its own random key, and that key is sealed under the vault key.
The pepper is not the root of trust, and that is deliberate.
- The secret is your pattern. The pepper can't open anything on its own. It adds a second ingredient that never leaves the phone, so a copy of the vault's files from the phone can't be attacked on another computer: every guess has to run on the phone and costs a full Argon2id. Backups work differently, as covered below.
- The hardware decides where guessing happens, not whether a pattern is right. There is no stored pattern to compare against and no "wrong pattern" answer. An unused pattern opens an empty vault.
- The design degrades instead of collapsing. On a phone with neither StrongBox nor a TEE, the pepper lives in software. There, someone who breaks into Android or reads its storage may be able to take the pepper, as could anyone in the unlikely event that secure hardware ever gave up a key. Each guess would still cost a full Argon2id, but it could then run off the phone. The
pm list featurescheck above shows which hardware your phone has, and Cachette uses the strongest of it.
HMAC-SHA256 is on StrongBox's short list, and its slower speed matters little here, because the pepper is used once per unlock attempt.
Non-exportable also shapes backups. A key that can never leave the phone can't be part of a backup, and a Cachette backup does not depend on the old phone's hardware. Each backup is one encrypted file holding the vault that was open when you made it, with its own new 24-word recovery phrase, and it restores on a new phone with that file, its 24 words and that vault's pattern.
So that it can restore on another phone, a backup carries an Argon2id check of the pattern, with the same settings but without the pepper. That check is sealed by the backup's 24 words along with its contents, so the file alone gives nobody anything to test guesses against. The words are what protect a backup, so keep them on paper, apart from the file.
The full key chain is in inside Cachette's encryption and on the security page.
Android and Apple's Secure Enclave, compared fairly
Apple's answer to the same problem is the Secure Enclave. Apple describes it as "a dedicated secure subsystem" integrated into its chips and "isolated from the main processor," with its own processor, AES engine, true random number generator and secure storage, on all iPhone models starting with iPhone 5s.
For the phone's own passcode, both platforms tie guessing to the device. Apple's passcode design entangles the passcode with a unique key built into the chip, so "brute-force attempts need to be performed on the device under attack," and the Secure Enclave enforces growing delays after failures. On Android, the compatibility rules require that the keys for your data storage be "cryptographically bound to a hardware-backed Keystore" and to your lock screen credential, and that the lock screen check runs in the isolated environment.
For apps, the toolkits differ:
| Apple Secure Enclave | Android Keystore | |
|---|---|---|
| Hardware | A Secure Enclave on every iPhone since the 5s | A TEE on current phones, plus StrongBox on many |
| Isolation | Its own processor inside Apple's chip | TEE: same processor. StrongBox: its own processor |
| App keys | P-256 elliptic-curve keys for signatures and key agreement | AES, HMAC, RSA and EC keys, depending on the hardware |
| Checking the level | Rarely needed: every iPhone has one | KeyInfo on the phone, attestation for servers |
Apple's developer documentation says the Secure Enclave "works only with NIST P-256 elliptic curve keys," which must be created inside it. Android's PackageManager reference lists "AES, HMAC, ECDSA and RSA support where the secret or private key never leaves secure hardware."
The fair summary: Apple's strength is uniformity. Every iPhone has the same kind of hardware, so nobody has to check. Android's strength is reach and openness: secure hardware across a wide range of phones, and an app can ask where a key lives, and prove it for key pairs. The cost is variation between phones, which is why checking matters.
Architecturally, the Secure Enclave sits closer to StrongBox than to a TEE; Android's own guide counts "integrated Secure Enclaves" as one form of StrongBox.
What secure hardware can't do
- It doesn't stop guessing on the phone itself. Google's guide is frank that an attacker who compromises Android may still be able to use an app's keys on the device. For the vault's files, the pepper decides where guessing happens and Argon2id how much each guess costs. Someone holding a backup file together with its 24 words could also test guesses anywhere, so the pattern you choose still matters. How to choose a pattern covers that.
- It doesn't fix a compromised phone. A rooted or infected phone can watch the screen while you use any app, Cachette included.
- It needs updates. Security chips run firmware, and firmware gets fixed. Keeping the phone updated is the first item on the Android hardening checklist.
- Non-exportable cuts both ways. A key that can't leave the phone leaves with the phone, which is why backups must not depend on it.
Used this way, secure hardware does one job very well: it makes a copy of the vault's files from the phone far less useful than the phone itself. Backups are built to leave the phone, so they rely on their 24 words, your pattern and where you keep them.