Skip to content
anti-ghostsecPublic

About

An encrypted file vault for Android: no ads, no internet permission, no analytics. Duress passwords, decoy vault and encrypted backups.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Enclave

An encrypted file vault for Android. No ads, no internet permission, no analytics.

Features

  • Encrypted vault for any files: folders, move, multi-select, search, sort, a grid or list view with encrypted thumbnails, and a duplicate finder.
  • Files are checked as they go in: each one is read back and decrypted from start to end, and compared with the original, before it's listed; one that fails isn't added, and its original is untouched. If you then let Enclave delete the originals, each file is read back from the vault once more right before its original goes, and an original whose copy doesn't read back is kept.
  • Built-in viewer: swipe through photos, GIFs, videos and audio. It has pinch zoom, a slideshow and a delete button. Videos start muted and loop. Playback reads straight from the encrypted file.
  • Safer sharing: Enclave's own share list shows apps only, never people or recent chats. You can limit it to apps you choose and confirm before anything is sent. Shared links end when the screen turns off, after 30 minutes, or as soon as a different vault is unlocked, and carry no file name (the receiving app asks for it).
  • Other apps can pick from Enclave (opt-in): browsers and chats can attach a vault file directly. In their list it carries the name and icon of the disguise in use.
  • Password plus an optional keyfile, duress passwords (decoy vault or silent wipe), wipe after N wrong attempts, and exponential lock-out. A decoy opened on its own never writes to the containers, so it can't damage the hidden real vault. Changes made in it work normally, with room for as much as the phone has free, but are kept only until it locks. It can't be used to test guesses at the real password either: it checks a new password only against its own. You fill it for real from Settings while the real vault is open. Only the real password clears the count of wrong passwords: a decoy or duress password leaves it as it was, and a decoy can't change the wipe or auto-lock settings (what it sets lasts until it locks). After a wipe for too many wrong passwords the lock screen looks exactly the same, every password is "wrong" and the lock-out keeps growing as it did before. The wipe runs once: each wrong password after it takes as long as the wipe did, and writes no more than any wrong password does. To start again, clear Enclave's storage in Android Settings.
  • Disguise (off by default): a preset name and icon, a working calculator front, or a custom home-screen icon. With the calculator front on, other apps that pick from Enclave get the calculator first too.
  • Locks when the screen turns off or Enclave is left. A system picker Enclave opened gets five minutes; nothing keeps the vault open indefinitely, not even another app opening Enclave's picker over and over. If a delayed lock's time ran out, or the screen went off, while the phone slept, Enclave locks as soon as it's opened again. Screenshots, recent-apps previews and audio capture are blocked, and in recent apps Enclave carries the disguise's name and icon. Messages appear inside Enclave's own window, never as Android toasts (which screenshots catch, and which show the real icon). Autofill services are offered nothing, other apps' overlays are hidden while Enclave is on screen (Android 12 and later), and only accessibility services meant for people with disabilities can read it (Android 14 and later), in its dialogs and menus as well as its screens. Settings needed while locked (disguise, lock-out) are sealed by a hardware key, not kept in plain preferences. Every save of them uses a new key and deletes the one before, so an older copy of that file put back can't be opened. If it's missing while a vault exists, or every key rejects it as sealed by another, and that's still so when Enclave next starts (or two minutes later), Enclave assumes someone is trying to undo the count of wrong passwords: the longest lock-out starts, the third wrong password wipes the vault (the next one, if it happens again before the real password has been typed), and the real vault says so when it's next opened. Until it's confirmed, no password is tried. A keystore that's busy or failing for a while is never taken for this: Enclave waits and reads the file again. The calculator front and its code are also kept in a small record of their own, so the calculator still shows meanwhile and afterwards. The lock-out uses time since boot, so changing the clock doesn't skip it.
  • Encrypted backups (Settings → Backup): one file holding the whole vault, protected only by a password you choose, so it can be restored on another phone. A restore adds everything to the open vault, in a new folder.
  • A built-in folder browser for import, export and keyfiles. It works inside profiles where the system file picker doesn't, such as Motorola Secure Folder, and shows photo and video previews that are made in memory and never saved.

Security model

Layer What it does
Argon2id (64 MiB, 3 passes) Turns the password (plus the SHA-512 of the keyfile, used as Argon2's secret) into a 256-bit key-encryption key.
Header key slots 4 slots, each holding the master key wrapped with AES-256-GCM. Unused slots are random bytes, so the number of passwords, and which one is a duress password, can't be told apart.
Hardware key The header is sealed by a non-exportable AES-256 key in StrongBox or the TEE, so copied app data can't be brute-forced off the device. Deleting this key crypto-shreds the vault.
Files Each file has its own random 256-bit key and is encrypted with chunked AES-256-GCM. The chunk index and a final-chunk flag are in the AAD, which stops chunks being reordered or the file truncated. Names and folders live in an encrypted index.
Deniable containers Everything lives in equal-sized 4 GiB containers of random-looking bytes (native/deniable, a vendored copy of the deniable crate at its v0.3.0, kept byte-identical to that tag). Each vault is volumes inside them, scattered in 4 KiB blocks encrypted with XChaCha20-Poly1305 and opened by a key derived from the vault's master key. Without a key, nothing says how many vaults there are, how many files, how big they are or when they were written. When space runs low, another container is added, so a vault grows without limit and without copying anything.
Crash safety New data only ever goes into space nothing saved still uses. The other containers are flushed first, then the root (index, settings and where every file lives) and the home container, which the crate saves atomically. A power cut leaves the previous state intact. Each time a vault is opened, its list of free space is checked against the root and every file, and anything in use is taken out of it; space that was written just before a crash and never listed is found again.
Backups Argon2id (128 MiB, 4 passes) turns the backup password into a key. The list of files (with each file's own key) and every encrypted file and preview, byte for byte, go into 1 MiB AES-256-GCM chunks (the chunk number and a final-chunk flag are in the AAD), padded with Padmé. The file is a salt and a nonce prefix followed by ciphertext: nothing in it is recognisable without the password. The vault's master key and its settings (which list duress passwords) are left out, so a backup and its password open that backup's files and nothing else. It's written under a temporary name and renamed only once complete.

Quantum resistance: Enclave uses only 256-bit symmetric cryptography (AES-256, SHA-2 and Argon2id), with no RSA or ECC anywhere.

Known limits

  • A backup doesn't need the phone's security chip: whoever has the file can guess passwords offline as fast as their hardware allows. Use a long, unique backup password, and keep the file somewhere safe.
  • Enclave hasn't been audited by an independent security firm. If being found out could put you in danger, don't rely on it alone.
  • A backup of the raw vault only works on the same phone, because it's bound to that phone's hardware key. Uninstalling Enclave or resetting the phone destroys the vault.
  • The containers' total size is visible: it's a rough upper bound on how much is stored.
  • A decoy made before containers keeps its own directory, which shows a second vault exists. Remove it and add a new decoy to move it inside the containers.
  • Someone who has a decoy's password and knows how Enclave works can tell it's a decoy: what they change in it is gone after a lock, and wrong passwords typed before it still count afterwards. A decoy hides the real vault from someone who looks, not from someone who tests.
  • A decoy can't explain more containers than it could have filled. Each is 4 GiB and none is ever removed, so a small decoy next to many containers needs another story ("I deleted a lot").
  • A duress wipe can be seen afterwards in Enclave's private files by someone able to read them: the header and its hardware key are new, while the containers are old. It also takes about twice as long as an ordinary unlock.
  • If the phone's storage is so full that the count of wrong passwords can't be saved, Enclave refuses to try any password, and says so, until there's room. The same goes while its lock settings can't be read: the keystore not answering (as can happen just after the phone starts), or their file missing or rejected and not yet confirmed on a later start.
  • If the real vault's data in the containers is damaged or missing, Enclave shows an empty vault with a message and writes nothing, so whatever is left isn't written over. If it stays that way the data is lost; "Wipe everything now" in Settings starts afresh.
  • The disguise changes the name and icon on the home screen, in recent apps and in other apps' pickers. Android's own Settings, the installer and permission screens still say "Enclave", and any app can list the installed package app.enclave. A link to a shared file names the package too (content://app.enclave.files/...): the receiving app could find that out from any name, so it isn't hidden. A custom home-screen icon opens Enclave through the disguise chosen when it was added; change the disguise and it has to be added again.
  • "Delete originals" deletes the files you imported from, and tells the media index they're gone. Copies elsewhere stay: a cloud backup such as Google Photos, a gallery's trash, and previews a gallery or launcher already made.
  • The folder browser makes its previews by decoding the photos and videos in the folder you're looking at, inside Enclave, while the vault is unlocked. A file that another app put there is decoded without being chosen.
  • The count of wrong passwords can't be rolled back by putting back an older copy of Enclave's files, but someone who can also put back an older copy of the phone's keystore (or run code as Enclave, with root) could still get around it. The strict lock-out applies to any loss of that file, not only to tampering; it also applies once to a vault made by an earlier version that has never been unlocked from the lock screen since, because no count was ever saved for it.
  • On flash storage the controller can keep old copies of blocks that no app can reach.
  • Enclave gives its files a fixed modified time, but an app can't set the time a file's metadata last changed (its ctime), nor a folder's, nor when the keystore made a key. Someone who can read Enclave's private files and the keystore's records (root, or a forensic copy of the phone) can see from these when Enclave last started, when a password was last typed at the lock screen (not whether it was right), and roughly when a vault last saved something. Enclave seals its lock settings again and touches its files at every start, so the newest of these times usually says only that it was started; a password typed or a save made after that still shows.
  • "Open with" and "Share" give the decrypted bytes to the receiving app, which could keep a copy. Exported files are plaintext. Links to shared files survive an automatic lock for up to 30 minutes, so a player or upload can finish. They end on "Lock now", when the screen turns off, or when a different vault (a decoy, say) is unlocked; the same vault unlocked again keeps them. A file over 64 MB is read straight from the open vault, so while another app has one the vault stays unlocked until that link ends (30 minutes at most) instead of locking after the usual delay.
  • Backups made by 0.4.0 also hold the vault's master key and settings. Whoever has one and its password can open a later copy of the same vault, so make a new backup and delete those.
  • With two copies of the phone's storage taken at different times, the containers show that something was written in between. A decoy opened on its own never writes to them, so it can't account for that.
  • A duress password added from inside a decoy, or a new password given to the decoy itself, is forgotten when it locks, like everything else changed there. A decoy never writes a password to the header, so it can't be used to test guesses at the real one.
  • Large files added to a decoy opened on its own are kept, encrypted, in a scratch folder until it locks. The folder is always there, but someone who can read Enclave's private files while it's unlocked would see files in it. That takes root on a running phone, which can read the keys from memory anyway.
  • Restoring a backup made by 0.4.0 shows a reminder to replace it.
  • The hardware key can be used while the phone itself is locked, not only while it's unlocked. Someone with root on a phone that has been unlocked since it started can have the keystore open the header, then guess passwords on their own machines, with no lock-out and no wipe. A long password is the only defence against that, for duress passwords too: one that is guessed shows a duress password was set up. New duress passwords need 8 characters; shorter ones made before 0.6.2 still work and are worth replacing.
  • Photos and videos given to other apps (shared, opened elsewhere, or picked through "Pick from Enclave") lose their GPS position, camera make and model, dates, comments and embedded previews, unless that is turned off in Settings. This covers JPEG, PNG and MP4/MOV. HEIC and WebP photos, raw formats, PDFs, Office documents and audio files are sent as they are, with whatever they say about their author or device, and so is anything a phone adds after the end of a JPEG (the video of a motion photo, for one). The times inside a video's own headers stay. "Export decrypted copy" always writes the file exactly as it was imported.
  • Other apps are told a made-up file name unless Settings says to send real names. An app that opens a PDF or an Office file still keeps it in its own list of recent files, under that made-up name, and may keep a copy.
  • What you type into Enclave goes through the phone's keyboard: file and folder names, searches, duress labels. Enclave asks the keyboard not to learn from it, but a keyboard that sends typing to its maker's servers still can. Use one that works offline. On Android 13 and older, an accessibility service can read the screen too.
  • Only the Calculator disguise has a working front. The other icons (Notes, Weather, Clock, Compass, System Tools) open on the password screen, or on the calculator if the calculator front is on. Disguise names are in English whatever the phone's language.
  • A decoy looks thin to someone who knows what to look for: no folders unless you make them, files all added at about the same time, and previews made again each time it's opened.
  • Photos imported through Android's picker stay in the gallery; only the folder browser can delete the originals. Phone makers' own cloud galleries (Samsung, Xiaomi and others) may have uploaded a photo before it was imported, and Enclave can't reach those copies.
  • The slideshow and a running backup keep the screen on, so the screen-off lock doesn't happen while they run.
  • Another app can bring Enclave's main screen to the front. While a vault is open that counts as coming back, so it can put off the auto-lock; turning the screen off always locks.
  • Builds aren't reproducible, and Gradle's dependencies aren't pinned by checksum. The APK can be checked against the signing certificate (see "Checking the APK"), which shows it came from this project's release key, not that it matches the source.
  • Locking zeroes the keys Enclave holds as bytes: the master key, the index and settings keys, and every file's key. Some secrets also pass through text, which can't be zeroed and stays in memory until it happens to be reused: passwords typed into the UI, the vault's index (which holds every file's key) while it's read or saved, and, while the real vault is unlocked, its settings, which hold each decoy's key. Someone who can read Enclave's memory while it runs (root, or a debugger) could find them.
  • The folder browser needs Android's "All files access" permission.

Checking the APK

Every release is signed with the same key. Its certificate's SHA-256 fingerprint is:

bd2d31089aa7a884ada7736ebcf2ecff5510c8376d8cd9ae08794db53b6f063f

Check a downloaded APK before installing it, with apksigner from the Android SDK build tools:

apksigner verify --print-certs Enclave-x.y.z.apk

The "certificate SHA-256 digest" it prints must be the fingerprint above. Each release's notes also give the SHA-256 of its APK, to compare with sha256sum Enclave-x.y.z.apk. Android itself refuses to install an update signed by a different key over an installed Enclave, so the check matters most the first time. Versions up to 0.4.0 were signed with a different key that no longer exists.

Upgrading from earlier versions

Vaults in the original one-directory format move into the containers on their first unlock after updating. Every encrypted file, preview, the index and the settings are copied byte for byte, nothing is decrypted, and each copy is checked against its original with SHA-256. Only once the move is marked complete is the old directory removed. If it's interrupted, the old vault is untouched and the next unlock carries on.

Versions up to 0.5.1 could damage a file while adding another one after the vault had been locked and unlocked: the newer file was written over the start of the older one, which then wouldn't open. 0.5.2 fixes the cause, repairs the vault's list of free space when it's opened so nothing more is damaged, and changes nothing about how vaults are stored. A file that was already damaged can't be repaired: delete it and add it again from the original.

0.5.3 fixes two problems in the storage code, and changes nothing about how vaults are stored. If unlocking ever failed because a container was full, the next save could overwrite the start of the container and make every vault in it unreadable; a failed unlock now leaves nothing behind. And the random "cover" writes made with each save grew with how much any vault wrote, so someone given a decoy password who copied the phone's storage before and after could see changes the decoy didn't explain grow when the real vault was used. Each save now changes a random number of blocks (between 1 and 2 MiB) chosen without regard to what was written, so saves of the real vault smaller than that look like the decoy's own; a larger save still shows its size.

0.6.0 changes nothing about how vaults are stored, and is mostly about what Enclave gives away. The count of wrong passwords can no longer be undone by putting back an older copy of Enclave's files: every save of the lock settings uses a new hardware key and deletes the one before. If that file goes missing or is replaced while a vault exists, and that's still so on the next start, Enclave puts the strictest lock-out in place (wipe after 20 wrong passwords, with two to spare the first time) and the real vault says so; a passing keystore fault is never taken for this. Settings from before 0.4.0 still move over as before. The wipe for too many wrong passwords runs once. Messages are shown inside Enclave's window instead of as toasts, the disguise's name and icon are used in recent apps, and autofill, other apps' overlays and most accessibility services are kept out of every window, dialogs and menus included. Nothing from one vault (an open folder, a search, a message, a share prompt) is shown after another one unlocks, links handed to other apps carry no file name and end when a different vault is unlocked, and a decoy shows the real wipe setting. File keys are held as bytes and zeroed at the lock. The picker other apps open can no longer keep the vault from locking, and backups get a random file name.

0.6.1 changes nothing about how vaults are stored either. A wipe nobody is meant to notice (a duress password, or too many wrong passwords) no longer leaves a moment with no vault: a header no password opens takes the old one's place in one step, and a wipe that was cut off is finished at the next start, so Enclave never offers to create a vault in its place. The calculator front now comes before that offer too. A duress password can no longer be the same as the vault's own password when that one uses a keyfile, and a new vault password with a keyfile can't be an existing duress password; if a vault already has the two the same, it says so when it's opened.

0.6.2 changes nothing about how vaults are stored. After the calculator code is typed, the password screen no longer stays behind the calculator icon: leaving Enclave with no vault open, or turning the screen off, brings the calculator back and clears a typed password and a chosen keyfile. Photos and videos reach other apps without their position, camera details and comments, and under a made-up file name; both can be changed in Settings. New duress passwords need 8 characters. A wipe now checks that the hardware key is really gone and tries again at the next start if it isn't, and a failed export leaves no half-written file.

Earlier versions also left an empty directory behind for every vault that had been unlocked. They are removed when Enclave starts; a directory that holds an old-format vault is never touched.

Build

Needs the Android NDK (r29) and Rust with the aarch64-linux-android and x86_64-linux-android targets. Gradle builds the Rust code itself.

./gradlew assembleDebug                       # app/build/outputs/apk/debug/app-debug.apk
./gradlew testDebugUnitTest                   # file-format and upgrade tests, run on the PC
./gradlew assembleRelease                     # signed if the properties below are set

Release signing is read from your user-level ~/.gradle/gradle.properties, never from this repository:

ENCLAVE_STORE_FILE=/path/to/release.jks
ENCLAVE_STORE_PASSWORD=...
ENCLAVE_KEY_ALIAS=...
ENCLAVE_KEY_PASSWORD=...

About

An encrypted file vault for Android: no ads, no internet permission, no analytics. Duress passwords, decoy vault and encrypted backups.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages