theca

package module
v0.38.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2026 License: BSD-3-Clause Imports: 21 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

theca

Theca is an encrypted container format in pure Go. It has:

  • authenticated sectors: XChaCha20 xor AES-256-CTR, with HMAC-SHA-256;
  • a Merkle tree over the sector tags, and a write-ahead journal;
  • no magic bytes;
  • keyslots opened by a password (Argon2id), a recovery code, or both;
  • an optional hardware rollback counter.

The design, its threat model, the primary sources it rests on and the decisions taken are in docs/DESIGN.md. Hardware keys are covered in docs/HARDWARE-KEYS.md.

Status: v0.1.0 released (CHANGELOG). Below v1 the format can still change: a breaking change bumps the minor version.

Quick start: one command, one touch

Password from your secret manager plus a hardware key, with nothing new stored:

go install github.com/go-theca/theca/cmd/theca@latest

# once: name the container (references only, nothing secret is written)
theca profile add vault ~/vault/vault.theca \
    --password-from 'keepassxc:https://theca.invalid/vault' --device bio

# every day
theca open vault      # asks the manager, waits for one touch, mounts, frees the terminal
theca status          # what is open, where
theca close vault     # unmounts, commits, closes

profile add checks the syntax of the references and never reads a secret. The profile file (containers.toml, mode 0600, in the user's configuration directory) holds the container's path, --password-from / --recovery-from / --pin-from references (keychain:, secretservice:, keepassxc:; file: is refused), --device, --counter tpm with --tpm-device, --tpm-auth-from, --tpm-endorsement-auth-from, --share, --sync and --close-on-lock. A counter whose authValue is derived from the master key (the default since v0.19.0) needs no --tpm-auth-from; --counter tpm stays in the profile, since the header can be read only after the unlock.

Several containers at once. Each profile has its own background process, its own socket, its own loopback port and its own random account, so any number of profiles can be open together; status lists them all and close NAME closes that one only. The share name is the same (theca) for every profile by default, so the system names the volumes /Volumes/theca, /Volumes/theca-1, /Volumes/theca-2 (status says which is which; --share NAME names them yourself). Measured on macOS 27 (Darwin 27.2.0, arm64), theca v0.33.0, three 16 MiB exFAT containers opened at the same moment, each from its own keychain entry, no key: three distinct mount points, each write read back from its own container after a close and reopen, status listing three, closing one leaving the other two mounted and readable, a second open of an open profile refused, and verify clean (ok: 4096 sectors verified) on all three. Reproduce it with THECA_LIVE_MULTIMOUNT=<durable directory> go test ./cmd/theca -run TestLiveSeveralContainersMountedAtOnce -v. Linux and Windows: not measured.

open starts a background process that holds the unlocked container; close and status talk to it over a per-user Unix socket (mode 0600, peer user ID checked). A second open of the same container is refused. With --close-on-lock (the default) the container is closed when the screen locks, the machine sleeps or the session ends: logind over D-Bus on Linux, the screen-lock, will-sleep and session-resign notifications on macOS through go-macos/sessionwatch (delivered before the sleep, no polling; theca open says on standard error whether it listens or, if the notifications cannot be heard, polls every 2 s).

On Windows the same commands work. The channel is a named pipe, \\.\pipe\theca-<user SID>-<name>, whose security descriptor grants access to that SID alone; the daemon also reads the SID of each client's process token (GetNamedPipeClientProcessId) and refuses any other. The container file is locked with LockFileEx (a byte far beyond the end of the file, so reading the container is not blocked), which makes a second open fail before it touches the rollback counter. theca open starts the daemon with your console, so a password or PIN prompt works, and the daemon lets go of the console (FreeConsole) once the container is open and in a process group of its own; it leaves the job of an ssh session when that job allows it, so it survives the logout. Close-on-lock listens through a hidden message-only window on a locked OS thread: WTSRegisterSessionNotification for the lock and the logoff of the daemon's own session, RegisterSuspendResumeNotification for the suspend; if the window cannot be made or registered, open fails like on Linux (--close-on-lock=false opts out). Limits: the daemon's session is the one theca open ran in, so an ssh session (session 0 here) hears nothing of the console's lock and a mounted drive letter belongs to that logon session; Windows has no call that makes a process undumpable (no PR_SET_DUMPABLE, PT_DENY_ATTACH or RLIMIT_CORE equivalent), so theca only sets SetErrorMode (no error-reporting box) and wipes its keys; --mlock is not implemented on Windows yet. The profile file is checked through its DACL (owner, the system and the administrators only) instead of mode bits. On Linux only logind's own signals about this process's own session count (sender org.freedesktop.login1, the session of this process's pid or XDG_SESSION_ID), and a session that is already locked at open closes at once. If the watcher cannot start (no logind, no session), open fails and nothing stays mounted: --close-on-lock=false is the explicit opt-out. Limit: a screen locker that tells logind nothing (a bare i3lock or swaylock that neither calls loginctl lock-session nor sets the session's LockedHint) is not seen; the container then closes on sleep, shutdown or theca close, not on that lock. profile list and profile remove NAME list and delete profiles (the container and the manager's entries stay).

Command line

go install github.com/go-theca/theca/cmd/theca@latest

theca create vault.theca --size 1G            # asks the password twice, prints the recovery code once
theca info   vault.theca                      # unlock and describe
theca verify vault.theca                      # authenticate every sector and tree node
theca import vault.theca --password-from keychain:theca/vault --offset 0 < disk.img
theca export vault.theca --password-from keychain:theca/vault > disk.img
  • Secrets never go in arguments or environment variables. The password is read from the terminal with echo off, or from a secret manager (next item).

  • Secret files are deprecated (v0.21.0). --tpm-auth-file and --tpm-owner-auth-file were removed in v0.33.0 (breaking): see the counter section below for the migration. --password-file, --recovery-file and --pin-file still work (a regular file, mode 0600 or stricter) but are hidden from the help, and each use prints a warning on standard error that names the --X-from replacement. So does a file: reference in --password-from, --recovery-from and --pin-from. --tpm-auth-from refuses file:, like the other TPM flags. A plaintext file beside a container protected by hardware keys defeats them. Scripts keep working; move them to a manager before the files are removed.

  • From a secret manager, so no plaintext file sits on disk. --password-from, --recovery-from and --pin-from (the FIDO2 key's PIN) take a reference: keychain:SERVICE/ACCOUNT (macOS Keychain), secretservice:SERVICE/ACCOUNT or secretservice:KEY=VALUE,... (GNOME Keyring, KWallet, KeePassXC with Secret Service Integration), keepassxc:URL (KeePassXC itself, on macOS and Linux, through its browser-integration socket; the reference is the URL field of the entry: enable it, run secretsource keepassxc associate once and approve it in KeePassXC. Lookups by UUID or path are refused: KeePassXC 2.8.0 crashes on an entry without a URL); systemd-creds:NAME (Linux: a systemd credential, see "From a systemd service" below); file:PATH still works there but is deprecated. A reference holds no secret, and no scheme runs a command. Each excludes the -file flag of the same secret. See go-authn/secretsource.

    security add-generic-password -s theca -a vault -w          # macOS: asks for the password
    theca info vault.theca --password-from keychain:theca/vault
    theca info vault.theca --fido2 --password-from secretservice:theca/vault --pin-from secretservice:fido/yubikey-5c
    theca info vault.theca --fido2 --password-from 'keepassxc:https://theca.invalid/vault' --pin-from 'keepassxc:https://fido.invalid/yubikey-5c'
    
  • From a systemd service (Linux): --password-from systemd-creds:NAME (and --recovery-from, --pin-from) read the credential NAME that systemd delivers in $CREDENTIALS_DIRECTORY, or decrypt it from a credstore.encrypted directory, with go-authn/secretsource v0.8.0. The bytes are taken exactly, with no newline trimming: seal the password with printf %s. Measured on systemd 257 (Debian 13) with --with-key=host, not with a TPM2 key.

    # once, as root: seal the password to this machine (the host key)
    printf %s 'the vault password' | systemd-creds encrypt --with-key=host --name=theca - /etc/credstore.encrypted/theca.cred
    
    # /etc/systemd/system/theca-vault.service
    [Service]
    LoadCredentialEncrypted=theca
    ExecStart=/usr/local/bin/theca serve /srv/vault.theca --password-from systemd-creds:theca
    

    Choose what the credential is sealed to, and plan the way back. --with-key=tpm2 seals to the TPM2 chip and binds to no PCR by default. Adding PCRs makes the credential unreadable whenever they change, and the service then fails closed, with the vault shut: a bare --tpm2-pcrs=7 (Secure Boot state) can lock every credential after a firmware or shim update or a vTPM migration, so do not use it without a recovery path. Better: --with-key=host+tpm2 (TPM2 chip and the host key file /var/lib/systemd/credential.secret; survives firmware updates, lost with either); a signed PCR policy (--tpm2-public-key=PATH, PCR 11 by default, signatures from systemd-measure, no re-sealing for a new boot component); or systemd-pcrlock (unlock-firmware-code before a firmware update, make-policy after). Keep the password where this machine is not needed (a paper copy, a password manager, or the recovery code: --recovery-from takes a credential too) and re-seal with systemd-creds encrypt when decryption fails; the error says so. See the secretsource documentation.

  • create --password-to REF [--generate 24] [--recovery-to REF2] [--replace] stores the new password (typed twice, or drawn) and the recovery code in a secret manager, with no plaintext file and nothing secret printed. The password is stored before the container is created; if storing the recovery code fails, the code is printed after all. For example:

    theca create vault.theca --size 1G --password-to 'keepassxc:https://theca.invalid/vault' --generate 24 \
        --recovery-to 'keepassxc:https://theca.invalid/vault-recovery'
    
  • create prints the recovery code once, on standard output. It is never stored. If you redirect it to a file, that file gets your umask (often 0644): restrict it, or better, write the code down on paper.

  • --policy any (the default): the password alone, or the recovery code alone, opens the container.

  • --policy 2of3: two of the three factors are needed. Password and recovery code from the start; a FIDO2 key (enroll-key) then pairs with each.

  • import reads its data from standard input, so it needs --password-file, --password-from, --recovery-file or --recovery-from. It is not one atomic transaction: on an error, the bytes written before the error are kept.

  • Every command that opens a container states whether it is protected against rollback. Without --counter tpm it is not: an older copy of the container would be accepted (see "Rollback counter" below).

Keyslots
theca slots list   vault.theca --password-file pw --recovery-file rc
theca slots remove vault.theca --password-file pw --recovery-file rc --remove recovery --keep password
  • A keyslot holds nothing that says what opens it, so list shows the recorded slots and which ones the factors you present open.
  • remove takes the slot(s) a factor set opens (password, recovery, password+recovery, password+fido2 or recovery+fido2) and a DIFFERENT set to --keep, which must still open the container: this is checked before anything is written, and a removal that would leave no way in is refused. Both sets are presented with --password-file / --recovery-file (or the terminal).
  • A set with the key touches it ONCE (--device, --pin-file as for --fido2): the slot it opens must exist and must not be among the removed ones, so a key that is not the one enrolled here, or that holds no Theca credential, is refused before any write. To make the key mandatory: theca slots remove vault.theca --password-file pw --remove password --keep password+fido2. A container only the key opens also needs --fido2 to be opened (a second touch).
  • It stops access to this copy only: anyone holding an older copy can still open it with the removed factor (DESIGN §2, R7).
  • Library: Container.RemoveFactors(remove, keep []Factor), RemoveFactorSets(remove, keep [][]Factor), KeyPairs, SlotsOf, Slots, ErrLastWay.
Serving the files inside: SMB on loopback
theca create vault.theca --size 4G --fs exfat      # a container holding an exFAT filesystem
theca serve vault.theca --mount                    # appears in the Finder; Ctrl-C unmounts and stops
# serving smb://127.0.0.1:58738/theca; Ctrl-C to stop
# mounted at /Volumes/theca
theca serve vault.theca --credentials-to keychain:theca/serve   # or: hand the account to another client
  • create --fs exfat formats the volume through the container itself (go-filesystems/exfat FormatImage). No decrypted copy is ever written to disk.
  • serve unlocks the container and serves its exFAT over SMB (2.1 to 3.1.1, signed) using go-filesystems/smb, through go-fileshare/localshare (the generic share: account, address policy, signing, mount, ordered stop; theca keeps the container and lends it as a theca.Device). The server REQUIRES message signing on loopback too (RequireSigning), not only beyond it: a session that does not sign is refused.
    • It listens on a loopback address only by default: the data is decrypted. See "Beyond loopback" below.
    • One random account is drawn per run (a random user name, theca- and 8 characters, as well as a random password), never printed or passed as an argument. The name is random on purpose: macOS replays a stale credential for a fixed name on 127.0.0.1 and fails the next mount.
    • --mount mounts the share in the file manager with no password dialog (go-fileshare/automount): the password goes to the OS mount service as a value. At stop it unmounts first, so the client flushes through the server, then commits and closes the container.
    • --credentials-to REF stores the URL, user and password in the OS secret store, for another client, as ONE entry holding the JSON {"url":…,"user":…,"password":…}, and deletes it when serve stops. REF is keychain:SERVICE/ACCOUNT or secretservice:SERVICE/ACCOUNT (go-authn/secretsource Store and Delete); file:, keepassxc: (a delete there only moves the entry to the Recycle Bin, after a confirmation) and systemd-creds: are refused before anything starts. An entry that already exists is refused and never deleted; a serve that is killed (SIGKILL, power) cannot delete its entry, so the next one reports it. Read it with security find-generic-password -s SERVICE -a ACCOUNT -w (macOS) or secret-tool lookup service SERVICE account ACCOUNT (Linux). One of --mount and --credentials-to is required.
    • --credentials-out FILE (deprecated since v0.34.0, plaintext: mode 0600, created only if absent, removed at exit) still works and warns, naming --credentials-to. It cannot be given with --credentials-to. Its removal is go-theca/theca#90.
    • Writes are committed to the container every --sync (default 5 s) and when the server stops.
  • Measured on macOS 27 (2026-11-16): --mount lands in /Volumes/theca over SMB 3.1.1 signed with AES-128-GMAC, a file written through it survives a stop and a remount, and verify passes. Linux (GNOME Files, through gvfs) and Windows (Explorer, a drive letter through MSFT_SmbMapping) use the same command; neither has been measured with theca yet.
  • A copy of a file written through the share is one transaction per journal budget, not one per file (DESIGN §19 I12). A crash in the middle of a large copy can leave the exFAT metadata of that copy half-written, as on a disk.
  • The journal budget is the batch: every commit costs about four flushes (F_FULLFSYNC on macOS) whatever its size. create sizes the journal at one entry per 16 sectors, from 64 to 4096 (--journal overrides), so a 64 MiB sustained write through the share went from 7.6 to 28.8 MiB/s on macOS (go-theca/theca#73). The size is part of the layout, so it cannot change in place: a container made before v0.26.1 keeps its 64 entries until you copy it with theca journal resize (below).
Resizing the journal of an existing container
theca journal resize vault.theca --out vault-new.theca --password-from keychain:theca/vault --device bio   # the factors that open it

resize writes vault-new.theca, a copy whose journal has the default size for the volume (or --entries N). Keys, slots, the policy, the rollback counter binding and the content are carried over. The copy is created exclusively (an existing --out is refused), synced, reopened, verified sector by sector and compared with the original by the hash of the whole volume; nothing is reported before that passes. vault.theca is never rewritten (opening it is an ordinary mount, and that is all), and nothing is swapped for you: the command prints the two mv lines to run. With a TPM counter, the first real mount of the copy moves the counter past the old file, which is refused as a rollback from then on, so keep it until the copy has been mounted once. Containers have no hidden volume (DESIGN section 8), so there is nothing in the file that the copy leaves behind.

Beyond loopback: --network
theca serve vault.theca --network --addr 0.0.0.0:4455 --mount --credentials-to keychain:theca/serve

A non-loopback --addr is refused unless --network is given (the library: share.Options{Network: true}). It is one switch, not a knob per protection: the server is then started with message signing required, encryption required of every session, and encryption required of the share (go-filesystems/smb v0.15.0 RequireSigning, EncryptData, RequireEncryption), and a client that cannot do both (SMB 2.1, or one that refuses encryption) is refused. That is the only condition under which three independent security reviews found serving beyond loopback acceptable. It does not make it safe for a hostile network: anyone who can reach the address and has the password can read and write the container's files, and the password is in the --credentials-to entry (or was handed to the file manager by --mount); the warning serve prints says which. serve prints a warning on standard error. With --mount and an unspecified address (0.0.0.0, ::), the local mount uses 127.0.0.1 on the same port; another machine uses this machine's address with that port. The server bounds its connections and what an unauthenticated one may hold (smb v0.15.0 defaults). The GUI has no network option: it always serves loopback.

Measured on macOS 27.2.1 (2026-11-16, theca v0.5.0, smb v0.15.0): serve --network --addr 0.0.0.0:4455 --mount --credentials-out f mounted in /Volumes/theca, and smbutil statshares -a reported SMB 3.1.1 with SMB_CURR_ENCRYPT_ALGORITHM AES-128-GCM, SMB_CURR_SIGN_ALGORITHM AES_128_GMAC, ENCRYPTION_REQUIRED TRUE and SIGNING_REQUIRED TRUE. A file written and read back through the mount worked; SIGINT (by PID) left no volume and no credentials file, and verify passed (16384 sectors). Not measured: a client on another machine.

FIDO2 security keys
theca enroll-key vault.theca --recovery-file rc   # pair the key with the password and the recovery code
theca info vault.theca --fido2                    # password + key
theca info vault.theca --recovery-file rc --fido2 # recovery code + key
  • enroll-key makes ONE discoverable credential on the key: relying party theca, credProtect 3, hmac-secret. It pairs that credential with the password, and with the recovery code too when --recovery-file names it. The key is touched twice: to register, then to confirm.

  • --fido2 adds the attached key to an unlock. It pairs with the password or the recovery code. The key is never a factor alone.

  • Pairing only ADDS a way in. Under policy any the password alone (and the recovery code alone) still open the container after enroll-key. It says which still do, and prints the command that removes the password-only slot. enroll-key --require does it in the same run: after pairing the key is touched once more to prove the password with the key opens the container, and only then is the password-only slot removed (nothing is removed if the proof fails; the pairing stays). It does NOT remove the recovery-only slot: that code is the way in if the key is lost, so under policy any it still opens the container alone until you run slots remove --remove recovery --keep password+fido2 (then a lost key means a lost container). A recovery code that was not presented cannot be tested, and the output says so.

  • Naming a key. fido name set "desk key" (go-authn/fido cmd/fido) stores a name ON the key; theca reads it with no touch and no PIN, shows the key by that name, and --device "desk key" finds it wherever it is plugged (exactly; a name on two keys is refused). A key that will not answer that read is chosen by id.

  • Which key. With one key attached, that key is used. With several, theca never takes "the first": --device ID names one (the ids are what fido list from go-authn/fido prints: iokit:<location> on macOS, the USB port on Linux), and without it you touch the key to use (CTAP 2.1 authenticatorSelection) within 30 seconds. Two keys touched together are refused. The key is named on stderr before anything is asked of it, and enroll-key says which key it paired (ok: the key YubiKey Bio (…) is paired with 2 factor(s)). On Windows the system dialog chooses, and --device is refused.

  • Nothing about the key is written into the container but its pairwise slots. The key is asked once per unlock, for all its Theca credentials (one touch).

  • A key with a fingerprint enrolled (CTAP option uv true, e.g. a YubiKey Bio) verifies with it: one fingerprint per unlock, no second touch. A fingerprint that is not recognised is retried while the key has tries left (the count is shown); when it is blocked, exhausted, or none is enrolled, theca says so ("the fingerprint is blocked — using the PIN.") and asks for the PIN instead, if one is set.

  • A key without a fingerprint asks for its PIN. It is read from --pin-file (mode 0600 or stricter) or from the terminal, never from an argument.

  • What each OS does (the transport is chosen by GOOS):

    OS Route PIN and prompts Status
    macOS CTAP over IOKit HID (go-macos/fido) theca asks: --pin-file or the terminal measured on a YubiKey 5, firmware 5.7.4
    Linux CTAP over /dev/hidraw* (go-gnulinux/fido), pure Go theca asks, as on macOS fakes and a kernel-made HID device only; not measured on a real key
    Windows webauthn.dll (go-mswin/webauthn), because Windows 10 1903+ refuses raw HID to a process that is not elevated Windows asks: a Windows Security dialog collects the PIN or fingerprint, so --pin-file does not apply fakes and struct layouts only; not measured on a real key

    On Linux /dev/hidraw* belongs to root on a stock system: install a udev rule giving your user access to FIDO keys (libfido2's 70-u2f.rules); theca then says "a security key is attached but this user cannot open it" instead of "no key". On Windows, hmac-secret needs WebAuthn API version 6 (webauthn.h; Windows 11 reports 9). When several Theca credentials are on the key, Windows has the person pick one, and only that one is tried.

Design and trade-offs: docs/HARDWARE-KEYS.md §9 "H2 revised", and docs/DESIGN.md §19 I21.

Rollback counter: a TPM 2.0 NV counter
theca create vault.theca --size 1G --counter tpm                 # defines an NV counter, binds the container to it
theca info   vault.theca --counter tpm                           # rollback protected: true (TPM NV counter 0x01500000 ...)
theca create v2.theca --size 1G --counter tpm --tpm-owner-auth-from keychain:tpm/owner --tpm-endorsement-auth-from keychain:tpm/endorsement
theca info   vault.theca --counter tpm --accept-rollback          # accept an older copy on purpose (loud); needs the counter
theca counter rebind vault.theca --counter tpm --tpm-owner-auth-from keychain:tpm/owner   # the counter is gone: bind to a new one
  • Asking for the counter means requiring it. A container whose header names no counter (made without one, or an older copy from before counter rebind bound it) is refused under --counter tpm (or a profile's counter = "tpm") with "this container has no rollback counter, but --counter tpm was asked: an older copy may have been restored"; a library caller that passes a counter gets ErrCounterRequired. The TPM cannot judge a copy that never named it.

  • The counter advances once per mount, not per commit. An older copy of the container (any earlier session) is refused with ErrRollback before anything is written; the copy taken during the current session is the window that stays open (DESIGN §5.4).

  • Every command that opens the container needs --counter tpm again (and --tpm-auth-from if an older theca stored one), and opens the file read-write, because a mount rebinds the header. Without the flag, a protected container is refused with a message naming it.

  • --tpm-device: a device path, or unix:SOCKET for a software TPM (swtpm socket --tpm2 --server type=unixio,path=SOCKET ...). The default is /dev/tpmrm0 on Linux, which needs permission to open it (usually the tss group). On Windows the default is TPM Base Services (tbs:, through go-tpm2/devtpm's OpenTBS); name tbs: explicitly on any platform to select it (off Windows it says it is unsupported). Windows is measured only as far as TBS_E_TPM_NOT_FOUND on a Windows 11 VM without a TPM; a counter through a real TPM there has not been run. macOS has no TPM and says so unless a device is named.

  • The counter's authValue is derived from the container (v0.19.0). With no --tpm-auth-* flag, a new counter's authValue is an HKDF of the container's master key: whoever unlocks the container (password plus security key) can use its counter, nobody else, and there is nothing to store. The header records it, so a mount needs only --counter tpm. A counter made by an older theca keeps its stored authValue (--tpm-auth-from REF at every mount); theca counter rebind without that flag moves it to a derived one. Upgrading to v0.33.0 (breaking): --tpm-auth-file is gone. A container whose counter has an authValue stored in a file is refused by the TPM ("the TPM refused the counter's authValue"), and the message names the migration. Run theca counter rebind FILE --counter tpm once, with the factors that open the container, no --tpm-auth-* flag, and --tpm-owner-auth-from REF if the TPM has an owner password: it needs neither the old file nor the old value, derives a new authValue, binds the container to a new counter and deletes the old one (rollback protection restarts from that moment). Or put the old value in a secret manager and give --tpm-auth-from REF.

  • TPM passwords come from a secret manager. --tpm-owner-auth-from REF (create, counter rebind) and --tpm-endorsement-auth-from REF (create, counter rebind and every mount, only on a TPM whose endorsement hierarchy has a password) take keychain:, secretservice: or keepassxc: references; a file: reference is refused (--tpm-auth-from too, since v0.21.0). --tpm-owner-auth-file was removed in v0.33.0 (an empty owner password needs no flag; otherwise use --tpm-owner-auth-from). Never arguments or environment variables. Without --tpm-endorsement-auth-from on such a TPM a pinned container is refused, and the message names the flag. A wrong endorsement password does not count toward the TPM's dictionary-attack lockout (the authValue of a hierarchy other than lockout is not DA protected: TCG TPM 2.0 Part 1 rev 1.59, 19.8.1), so a mistake cannot lock the TPM; for the same reason it is not throttled against guessing, so use a long random one.

  • When the counter is gone (the owner undefined the index, or TPM2_Clear, a BIOS reset or a reinstall removed it; an index with POLICY_DELETE would need platform authorization, so the owner can delete this one) the container cannot be opened, and the message says so and names theca counter rebind FILE --counter tpm --tpm-owner-auth-from REF. That command needs the factors that open the container AND the TPM owner password; it defines a counter (at the recorded handle if free, else the first free one), binds the header to it and increments it. A healthy old counter is deleted first (otherwise a copy made just before the rebind would still open with it). Rollback protection then restarts from that moment: nothing is checked against the old counter. An old copy of the container shows the same refusal as a reset TPM: do not rebind to open one. --accept-rollback is another thing: it needs a counter that exists and is ahead of the container.

  • The TPM is pinned (v0.18.0). create and counter rebind record, in the authenticated header, the identity of the TPM the counter is on: the digest of the Name of its endorsement key (the EK Credential Profile ECC P-256 template, created transiently and flushed, never persistent). Every mount compares it before reading the counter; a counter on another TPM is refused, naming both identities (first 6 bytes in hex) and the recovery: theca counter rebind, only if you really replaced the TPM. info shows counter TPM identity: <hex>. On a TPM with an endorsement password, give --tpm-endorsement-auth-from (above); without it the mount is refused. Containers made before v0.18.0 carry no identity: they open as before, with a warning at every mount, until theca counter rebind pins them (it replaces the counter, so protection restarts from that moment).

  • Threat model, by attacker.

    • Replaces the container file with an older copy (a stolen backup, a sync client): stopped by the counter, as before.
    • Brings another TPM (a fresh software TPM, a replaced TPM, another machine's) and defines the same index on it at the old bound: stopped since v0.18.0, by the pinned identity. Not stopped in a container made before v0.18.0 and not rebound.
    • Controls the TPM in use: the host of a virtual TPM, a program standing between theca and the TPM (a replaced device or socket). Not stopped. The identity names a TPM, it does not prove that the TPM answering is that one: the EK public is not secret and whoever is the TPM can present it.
    • Holds a copy of the TPM's state (a software TPM's state directory, a VM snapshot): it holds the endorsement seed, so it is the same TPM, and it can roll the counter back with the state. Not stopped.
    • Forges the answers on the bus to a discrete TPM: not stopped. TPM2_NV_Certify under an attestation key would authenticate the answers; it was weighed and deferred (DESIGN 5.4.1), because it does not change the outcome against the other attackers.

    The counter index has NO_DA: a wrong authValue file does not count towards the TPM's lockout.

  • Library: go-tpm2/nvcounter (nvcounter.Create, nvcounter.Open, nvcounter.Counter.Identity, a theca.IdentifiedCounter; it was theca's tpmcounter package until v0.30.0), OpenOptions.CounterFor, OpenOptions.RebindFor. Built on go-tpm2/tpm2 v0.11.0 NVDefineCounter, NVIncrementAuth, NVReadCounter, EKIdentity. Counters defined by v0.9.0 (without NO_DA) are still recognized. One counter per container.

Not in this version: slot management for FIDO2 factor sets on the command line (slots handles the password and the recovery code).

Keys in memory (go-theca/theca#68)

While a container is open its keys are in RAM, and for hours in the open daemon. What theca does about it, and what it does not:

  • Wiped after use. The password, the PIN and the recovery code are []byte from the moment they are read (terminal, owner-only file, secret manager) and are cleared once used, and no string copy of any of them is made: the PIN goes to the FIDO2 library through its []byte call (go-authn/fido v0.15.0, PINTokenBytes), and create prints the recovery code it just made from a []byte it then wipes (theca.Create returns it as []byte).
  • Known remaining copies, not wiped. The AES round keys are wiped on Close (ctr.Cipher.Zeroize), but only on the accelerated path (arm64 and amd64 with AES-NI): the crypto/aes fallback, used elsewhere, keeps its key schedule inside the standard library, where it cannot be cleared, and the key expansion's own temporaries are not visible from here (go-encryptions/ctr, go-theca/theca#74). The transient key-encryption keys: where they live in a heap slice or in a field of a value we own they are cleared, but a [32]byte returned by value (kdf.KEK, kdf.Pair) is copied through registers and stack frames, and Go cannot address or clear a stack slot it has already moved or left. (The pads of the HMAC are not in this list: they live in a go-encryptions/hmac MAC, which Close wipes.)
  • Not swapped. The pages that hold the master secret, the slot wrap keys and their cipher caches are mlocked (a per-page count, because munlock of a page undoes every mlock of it). --mlock=auto (the default) tries and says once on stderr if the system refuses (RLIMIT_MEMLOCK); --mlock=required refuses to open instead; --mlock=off does not call mlock. The pinning is go-authn/harden/memlock: mlock on Linux and the BSDs, and, since v0.31.0, VirtualLock on Windows (which counts against the process's minimum working set). The copies listed above (the fallback's round keys, stack KEKs) are not pinned.
  • No core file, no debugger. theca _serve, the daemon, sets RLIMIT_CORE to 0 and, on Linux, PR_SET_DUMPABLE to 0 (no core file whatever the limit; ptrace, /proc/PID/mem and process_vm_readv refused to a process of the same user), on macOS PT_DENY_ATTACH (a later attach fails). A refusal is a warning, not a stop. Windows and the other systems: nothing.

Library

f, _ := os.OpenFile("vault.theca", os.O_RDWR, 0)
c, err := theca.Open(ctx, theca.FileBacking{File: f}, theca.Unlock{Password: pw}, theca.OpenOptions{})
// c is an io.ReaderAt and io.WriterAt over the logical volume; Sync commits.
Sharing the files inside (package share)

What theca serve does, as a library (a GUI imports this, not package main):

s, err := share.Start(ctx, c, share.Options{
	Addr: "127.0.0.1:0", Name: "theca", Sync: 5 * time.Second, Mount: true,
})
if err != nil { // share.ErrNoFilesystem: no exFAT inside
	return err
}
fmt.Println(s.URL(), s.MountPath()) // smb://127.0.0.1:58738/theca /Volumes/theca
// <-s.Done() fires when a commit or the server fails; s.Err() says why.
err = s.Stop() // unmount, close the server, close the filesystem (idempotent)
c.Close()      // the caller closes the container, after Stop

share.Format(c) makes a fresh container shareable: it lays exFAT onto the volume through the container (what create --fs exfat does).

Only a loopback address is served. RevealPassword(func([]byte)) lends the account's password as bytes that are wiped when the callback returns (Password() string was removed in v0.38.0: a Go string cannot be wiped); it is a secret, never to be shown or logged.

License

BSD-3-Clause.

Documentation

Overview

Package theca is an encrypted container format: authenticated sectors (XChaCha20 xor AES-256-CTR, HMAC-SHA-256), a Merkle tree, a write-ahead journal, no magic, and keyslots opened by a password, a recovery code and hardware factors. See docs/DESIGN.md.

This package is a library over a Backing (a file or block device); it does not mount anything.

Index

Constants

View Source
const DefaultCacheBytes = 64 << 20

DefaultCacheBytes is the cache budget when none is given: 64 MiB, which holds 8192 metadata blocks (each covering 64 sectors: 2 GiB of volume) and 8192 tree nodes.

View Source
const DefaultJournalEntries = 64

DefaultJournalEntries is the smallest default journal, used when CreateOptions leaves JournalEntries zero for a small container.

View Source
const IDSize = format.IDSize

IDSize is the size of a TPM identity.

View Source
const MaxDefaultJournalEntries = 4096

MaxDefaultJournalEntries caps the default journal: 4096 entries are 17 MiB on disk and at most 16 MiB of pending sectors in memory.

View Source
const MaxFIDO2Credentials = 128

MaxFIDO2Credentials bounds how many Theca credentials an authenticator may report in one answer (a YubiKey 5.7 holds at most 100 discoverable credentials). A larger answer is refused, not processed.

View Source
const MaxFIDO2Salts = 2

MaxFIDO2Salts is how many salts one hmac-secret request carries (salt1 and salt2, CTAP 2.1 §12.5), hence how many partner factors one key pairs with.

View Source
const SectorSize = ta1.SectorSize

SectorSize is the logical sector size.

Variables

View Source
var (
	// ErrNoMatch is the single answer to "nothing unlocked this": a wrong
	// password, a wrong key, a corrupted slot area and a file that is not a
	// container are indistinguishable (DESIGN 13).
	ErrNoMatch = errors.New("theca: no factor opened a keyslot")
	// ErrCorrupt: the container unlocked but a structure failed to
	// authenticate (both header copies, a tree node, a metadata block).
	ErrCorrupt = errors.New("theca: container is corrupted or was tampered with")
	// ErrSector names a data sector whose tag failed: an I/O error, never
	// silently zero data.
	ErrSector = errors.New("theca: sector failed authentication")
	// ErrRollback: the header is older than the hardware counter allows.
	ErrRollback = errors.New("theca: container is older than the rollback counter (use AcceptRollback to rebind)")
	// ErrCounter: the counter given does not match the one the header names.
	ErrCounter = errors.New("theca: rollback counter missing or not the one recorded in the header")
	// ErrCounterRequired: a counter was asked for (OpenOptions.Counter,
	// CounterFor or CounterDerived) and the header names none: the container
	// was made without one, or an older copy from before `counter rebind` was
	// restored. Asking for a counter means requiring it.
	ErrCounterRequired = errors.New("theca: this container has no rollback counter, but one was asked: an older copy may have been restored")
	ErrRange           = errors.New("theca: offset or length out of range")
	ErrBroken          = errors.New("theca: container failed an earlier write and must be reopened")
	ErrClosed          = errors.New("theca: container is closed")
	ErrNoSlot          = errors.New("theca: no free keyslot")
	ErrOption          = errors.New("theca: invalid option")
	// ErrNoCredential is returned by a FIDO2 provider whose key holds no
	// Theca credential. It is routine during unlock and not an error.
	ErrNoCredential = errors.New("theca: authenticator holds no theca credential")
	// ErrAuthenticator: a FIDO2 provider answered something malformed.
	ErrAuthenticator = errors.New("theca: malformed answer from the authenticator")
)

Errors.

View Source
var ErrCounterIdentity = errors.New("theca: the rollback counter is not on the TPM this container is bound to")

ErrCounterIdentity: the counter is not on the TPM the header pins (DESIGN 5.4.1), or cannot say which TPM it is on.

View Source
var ErrLastWay = errors.New("theca: refusing to remove the last way in: the factors to keep would not open any other slot")

ErrLastWay is returned by RemoveFactors when no factor set the caller presented as the ones to keep would still open the container afterwards.

View Source
var ErrResizeSame = errors.New("theca: the container already has that journal size")

ErrResizeSame: the container already has the journal size asked for.

Functions

func DefaultJournal added in v0.26.1

func DefaultJournal(sectors uint64) uint32

DefaultJournal is the journal size Create uses for a container of that many sectors when JournalEntries is zero: one entry per 16 sectors (6.25 % of the data, clamped to [DefaultJournalEntries, MaxDefaultJournalEntries]).

The journal bounds a transaction, and every transaction costs about four flushes whatever its size (go-theca/theca#73): a bigger journal is fewer flushes per byte written. A 64-entry journal measured 11.7 MiB/s for 64 MiB on macOS (F_FULLFSYNC), a 1024-entry one 94 MiB/s. The size is fixed at creation: an existing container keeps its own.

func Device added in v0.35.0

func Device(c *Container) volume.Borrowed

Device lends c as a volume.Borrowed: the borrower reads and writes the logical volume, Sync commits the container, and nothing it does can close c (a Borrowed has no Close: the lender owns the keys and the wiping). It is how a share serves the filesystem inside c (go-fileshare/localshare).

func KeyPairs added in v0.17.0

func KeyPairs(ctx context.Context, dev FIDO2, partners ...Factor) ([][]Factor, error)

KeyPairs asks the key ONCE (one touch) for the pairs it forms with the partner factors: for every partner and every Theca credential the key holds, the factor set {partner, key}, which is what opens a key slot. They are what RemoveFactorSets and SlotsOf take to remove a key slot, or to prove, before a removal, that the key still opens the container.

The pairs are ordered by credential, then by partner. A key holding no Theca credential is ErrNoCredential: there is nothing to prove with. The caller wipes the pairs with WipeSets (they hold copies of the partners' keys).

func ShortID added in v0.18.0

func ShortID(id []byte) string

ShortID renders an identity for a message: its first 6 bytes in hex.

func WipeSets added in v0.17.0

func WipeSets(sets [][]Factor)

WipeSets zeroes every factor of every set.

Types

type Backing

type Backing interface {
	io.ReaderAt
	io.WriterAt
	Sync() error
	Size() (int64, error)
}

Backing is the storage under a container.

type Container

type Container struct {
	// contains filtered or unexported fields
}

Container is an open container. It is safe for concurrent use.

func Create

func Create(f Backing, o CreateOptions) (c *Container, printed []byte, err error)

Create formats a new container in f. It returns the container and, for both policies, the printed recovery code (shown once, never stored). The code is bytes, not a string, so the caller can wipe it after showing it; it is nil when err is not.

func Open

func Open(ctx context.Context, f Backing, u Unlock, o OpenOptions) (*Container, error)

Open unlocks a container and brings it to its last committed state.

func (*Container) AddSlot

func (c *Container) AddSlot(fs ...Factor) error

AddSlot adds a slot opened by the given one or two factors.

func (*Container) Close

func (c *Container) Close() error

Close commits, wipes the keys and refuses further use. The backing is not closed: it belongs to the caller.

func (*Container) EnrollFIDO2

func (c *Container) EnrollFIDO2(ctx context.Context, dev FIDO2, partners ...Factor) error

EnrollFIDO2 enrols a hardware key paired with each of the given partner factors (one or two: the hmac-secret salts of one request). The key makes a new discoverable credential and answers one output per partner, for the salt derived from that partner (kdf.FIDO2Salt); each output becomes the pairwise slot {partner, key}. Nothing else is stored, and all the slots are recorded by ONE commit. Enrolment needs the master secret, so the container must already be open. The container and its free slots are checked before the key is asked, so a touch is never spent on an enrolment that cannot be stored (review of PR #4, finding 6).

func (*Container) Info

func (c *Container) Info() Info

Info returns a snapshot.

func (*Container) ReadAt

func (c *Container) ReadAt(p []byte, off int64) (int, error)

ReadAt implements io.ReaderAt over the logical volume.

func (*Container) RemoveFactorSets added in v0.17.0

func (c *Container) RemoveFactorSets(remove, keep [][]Factor) (int, error)

RemoveFactorSets is RemoveFactors for a factor set that stands for SEVERAL slots: "the password with the key" is one pair per Theca credential the key holds (KeyPairs). A slot is removed when ANY set in `remove` opens it, and the container must still open under ANY set in `keep` through a slot that is not among those removed, else ErrLastWay. Nothing is written before both are known, and the writes are RemoveFactors's.

func (*Container) RemoveFactors added in v0.6.0

func (c *Container) RemoveFactors(remove, keep []Factor) (int, error)

RemoveFactors removes the slot(s) the factor set `remove` opens ("the recovery code", "this key and this password"), and returns how many it removed. It does not need an index.

`keep` is a DIFFERENT factor set that must still open the container afterwards: a slot holds nothing that says what opens it, so the container cannot count the ways in that would remain, and asks the caller to prove one. The proof is checked before anything is written. With none (no slot opens under `remove`) the answer is ErrNoMatch; with a `keep` that opens no slot outside the ones to remove, ErrLastWay. A power cut keeps RemoveSlot's order (overwrite first, then commit).

Like RemoveSlot it only stops access to the CURRENT container: anyone with an older copy can still open it with the removed factor (DESIGN 2, R7).

func (*Container) RemoveSlot

func (c *Container) RemoveSlot(i int) error

RemoveSlot overwrites slot i with random bytes, then records it as free. Any index 0..15 is accepted, recorded or not, so that a working slot the header does not record (left by a crash in an older version, or written by another tool) can still be destroyed. The overwrite comes first: a crash in between leaves a recorded slot holding random bytes, never a working slot marked free (review of PR #4, finding 3).

It only stops access to the CURRENT container: anyone holding an older copy can still open that copy with the revoked factor, because the master secret does not change (DESIGN 2, review finding R7). Callers must tell the user.

func (*Container) Size

func (c *Container) Size() int64

Size is the logical size in bytes.

func (*Container) Slots added in v0.6.0

func (c *Container) Slots() []int

Slots returns the indexes of the slots the header records, in order. A slot holds nothing that says what opens it, so this is all the container knows; SlotsOf answers "which slots does this factor set open".

func (*Container) SlotsOf added in v0.6.0

func (c *Container) SlotsOf(fs ...Factor) ([]int, error)

SlotsOf returns the indexes of the slots (recorded or not) that the factor set opens: one factor, or two that pair. It trial-opens all 16, as unlock does.

func (*Container) Sync

func (c *Container) Sync() error

Sync commits pending writes.

func (*Container) Verify

func (c *Container) Verify() (uint64, error)

Verify reads every sector, authenticating tags, metadata blocks and the tree. It returns the number of sectors checked and the first failure.

func (*Container) WriteAt

func (c *Container) WriteAt(p []byte, off int64) (int, error)

WriteAt implements io.WriterAt. Writes past the end are refused.

type Counter

type Counter interface {
	Handle() uint32
	Name() []byte
	Read() (uint64, error)
	Increment() error
}

Counter is a hardware monotonic counter (DESIGN 5.4): in practice a TPM NV counter. Handle and Name identify the index; the container pins both.

type CreateOptions

type CreateOptions struct {
	Sectors        uint64
	JournalEntries uint32 // 0: DefaultJournal(Sectors) (raised to the minimum)
	Hint           int    // Argon2id profile (D2)
	Password       []byte
	Policy         Policy
	Counter        Counter // optional hardware counter
	// NewCounter, when Counter is nil, makes the counter AFTER the master secret
	// exists, and is given the authValue derived from it (DESIGN 5.4.2): the
	// container records that the counter's authValue is derived, so a mount asks
	// OpenOptions.CounterDerived, not CounterFor. The slice is wiped when
	// NewCounter returns: copy what is kept.
	NewCounter func(auth []byte) (Counter, error)
	Rand       io.Reader // nil: crypto/rand
	CacheBytes int       // see OpenOptions.CacheBytes
}

CreateOptions configures Create.

type FIDO2

type FIDO2 interface {
	// Enroll creates a new discoverable credential (rk, credProtect 3) and
	// returns its outputs for each salt, in order (one or two salts).
	Enroll(ctx context.Context, salts [][32]byte) ([][]byte, error)
	// Derive asks for the outputs of EVERY Theca credential on the key, for
	// each salt (getAssertion with an empty allowList, then
	// getNextAssertion): result[i][j] is credential i's output for salts[j].
	// It returns ErrNoCredential if the key holds none.
	Derive(ctx context.Context, salts [][32]byte) ([][][]byte, error)
}

FIDO2 is a hmac-secret authenticator holding DISCOVERABLE credentials for the rp id "theca" (decision H2, revised: DESIGN 19, I21). Nothing about the key is stored in the container: the salts are derived from the partner factors (kdf.FIDO2Salt), and the key is asked about all of its Theca credentials at once. Each call is one touch and one user verification. Every output is the raw 32-byte hmac-secret value.

type Factor

type Factor struct {
	Kind string // "pw", "rc", "fido2"
	KEK  [32]byte
}

Factor is one access factor reduced to a key-encryption key.

func FIDO2Factor

func FIDO2Factor(secret []byte) Factor

FIDO2Factor turns an hmac-secret output into a factor.

func PasswordFactor

func PasswordFactor(hint int, password, salt []byte) (Factor, error)

PasswordFactor runs Argon2id (one evaluation, D2) with the hinted profile.

func RecoveryFactor

func RecoveryFactor(code []byte) (Factor, error)

RecoveryFactor parses a printed recovery code. The bytes are the caller's to wipe.

func (*Factor) Zeroize

func (f *Factor) Zeroize()

Zeroize wipes the factor's key.

type FileBacking

type FileBacking struct{ *os.File }

FileBacking adapts an *os.File.

func (FileBacking) Size

func (f FileBacking) Size() (int64, error)

Size implements Backing.

type IdentifiedCounter added in v0.18.0

type IdentifiedCounter interface {
	Counter
	Identity() ([]byte, error)
}

IdentifiedCounter is a Counter that can name the TPM it lives on: a digest of that TPM's endorsement key Name, IDSize bytes. A container made with one records the identity in its authenticated header and refuses, at every mount, a counter that reports another.

The identity names a TPM, it does not prove the TPM answering is that one: whoever controls a software TPM, or the bus to a TPM, can report any identity (DESIGN 5.4.1).

type Info

type Info struct {
	Sectors             uint64
	Size                uint64
	Epoch               uint64
	SlotsUsed           int
	RollbackProtected   bool
	CounterHandle       uint32 // the counter's handle; 0 when RollbackProtected is false
	CounterTPM          []byte // identity of the TPM the counter is pinned to; nil when RollbackProtected is false or the container predates the pin
	CounterDerivedAuth  bool   // the counter's authValue is derived from the master secret (DESIGN 5.4.2); false when RollbackProtected is false
	JournalEntries      uint32
	ReplayedTransaction bool
}

Info describes an open container.

type OpenOptions

type OpenOptions struct {
	Counter Counter
	// CounterFor, when Counter is nil, is asked for the counter once the header
	// has been authenticated and names one (its handle and NV Name are only
	// known then: the header has no plaintext fields). An error it returns
	// refuses the open.
	CounterFor func(handle uint32, name []byte) (Counter, error)
	// CounterDerived is CounterFor for a counter whose authValue is derived from
	// the master secret (the header says so): it is given that authValue, which
	// only someone who unlocked the container has. The slice is wiped when it
	// returns. A container with such a counter and no CounterDerived is refused
	// with ErrCounter.
	CounterDerived func(handle uint32, name, auth []byte) (Counter, error)
	// RebindDerived is RebindFor for a NEW counter with a derived authValue
	// (the migration from a stored one). RebindFor wins if both are set.
	RebindDerived func(handle uint32, name, auth []byte) (Counter, error)
	// RebindFor is the recovery path for a counter that is gone (the index was
	// undefined, the TPM was cleared) or that the container should move away
	// from. It is asked, once the header has authenticated, for a NEW counter:
	// the handle and Name the header records (0 and nil if it records none) are
	// passed so a counter can be made at the same handle. The mount protocol
	// does not run against the old counter: this mount increments the new one,
	// reads its value and binds the header to it. Rollback protection restarts
	// from that moment: nothing is checked against the old counter. Needs the
	// unlocking factors, like any open; the decision to use it is the caller's.
	RebindFor      func(handle uint32, name []byte) (Counter, error)
	AcceptRollback bool
	Rand           io.Reader
	// CacheBytes bounds the memory the container keeps for verified, clean
	// metadata blocks and tree nodes (half each, 4 KiB per entry): 0 is
	// DefaultCacheBytes. Entries that are part of a transaction not yet
	// committed are not counted: the journal budget bounds those. An evicted
	// entry is wiped, and read and authenticated again when it is needed.
	CacheBytes int
}

OpenOptions configures Open.

type Policy

type Policy int

Policy chooses the slots a new container gets.

const (
	// PolicyAny: the password alone, and the recovery code alone, each open
	// the container (1-of-n).
	PolicyAny Policy = iota
	// PolicyTwoOfThree: password + recovery code open it; a hardware factor
	// added later pairs with each of them (DESIGN 6.2, D3).
	PolicyTwoOfThree
)

type ResizeInfo added in v0.27.0

type ResizeInfo struct {
	OldEntries uint32
	Entries    uint32
	Sectors    uint64
	// Epoch is the source's epoch after the unlock, which the copy carries.
	Epoch uint64
	// Size is the size of the new file in bytes.
	Size uint64
	// Hash is the SHA-256 of the whole volume, read through the source and,
	// again, through the reopened copy: Resize reports success only when both
	// agree.
	Hash [32]byte
}

ResizeInfo describes a finished resize.

func Resize added in v0.27.0

func Resize(ctx context.Context, src Backing, u Unlock, o OpenOptions, dst Backing, ro ResizeOptions) (ResizeInfo, error)

Resize writes a copy of the container in src, with a journal of a different size, to the empty backing dst. The journal size is part of the header and the layout is derived from it, so every area after the journal moves; the sectors, the tree and the key slots are copied byte for byte (a sector is sealed under the container id and its INDEX, never its offset), and the header is sealed again under the same master secret.

src is unlocked like any mount: the factors open it, the counter is consulted and advanced, a committed transaction in its journal is replayed. That is the only thing written to it, and the copy is never written to src. dst is synced before the verification. The verification reopens dst with the counter's increments swallowed, checks the journal size, authenticates every sector, and compares the SHA-256 of the volume read through each.

The copy carries the counter binding unchanged (handle, name, TPM identity, derived authValue, bound value, epoch). The first real mount of dst finishes the increment the verification left unfinished and advances the counter, and from then on src is refused as a rollback, like any older copy of the container.

type ResizeOptions added in v0.27.0

type ResizeOptions struct {
	// Entries is the new journal size in entries (the most one commit holds).
	// 0 means DefaultJournal(sectors). A value below what one sector write needs
	// is raised to that minimum, as in Create.
	Entries uint32
}

ResizeOptions chooses the new journal size.

type Unlock

type Unlock struct {
	Hint     int
	Password []byte
	Recovery []byte // the printed code; the caller wipes it after use
	FIDO     FIDO2
}

Unlock carries the factors the user presents.

Directories

Path Synopsis
bench module
cmd
theca command
Command theca creates, inspects and copies data in and out of Theca containers (docs/DESIGN.md).
Command theca creates, inspects and copies data in and out of Theca containers (docs/DESIGN.md).
Package fido2 is Theca's FIDO2 factor on a real authenticator: it implements theca.FIDO2 over go-authn/fido (CTAP 2.1) and, on macOS, the go-macos/fido transport.
Package fido2 is Theca's FIDO2 factor on a real authenticator: it implements theca.FIDO2 over go-authn/fido (CTAP 2.1) and, on macOS, the go-macos/fido transport.
internal
format
Package format holds the on-disk layout of a Theca container: the geometry derived from the authenticated header, the header body, the keyslots and the recovery code (DESIGN 9).
Package format holds the on-disk layout of a Theca container: the geometry derived from the authenticated header, the header body, the keyslots and the recovery code (DESIGN 9).
journal
Package journal is Theca's write-ahead journal (DESIGN 5.3, review finding R1).
Package journal is Theca's write-ahead journal (DESIGN 5.3, review finding R1).
kdf
Package kdf holds Theca's key derivation: Argon2id with parameters from a fixed compiled-in table (DESIGN 6.1, decision D2) and HKDF-SHA-256 at the wrapping layer (DESIGN 2).
Package kdf holds Theca's key derivation: Argon2id with parameters from a fixed compiled-in table (DESIGN 6.1, decision D2) and HKDF-SHA-256 at the wrapping layer (DESIGN 2).
lru
Package lru is a bounded cache keyed by uint64 for the verified clean entries of an open container (go-theca/theca#6).
Package lru is a bounded cache keyed by uint64 for the verified clean entries of an open container (go-theca/theca#6).
merkle
Package merkle implements Theca's integrity tree (DESIGN 5.2).
Package merkle implements Theca's integrity tree (DESIGN 5.2).
pin
Package pin is theca's policy over go-authn/harden/memlock: what a refusal to pin the pages that hold key material means (go-theca/theca#68).
Package pin is theca's policy over go-authn/harden/memlock: what a refusal to pin the pages that hold key material means (go-theca/theca#68).
ta1
Package ta1 implements the Theca-A sector construction and the sealed object format of suite TA1 (docs/DESIGN.md sections 2, 4.3 and 9.3).
Package ta1 implements the Theca-A sector construction and the sealed object format of suite TA1 (docs/DESIGN.md sections 2, 4.3 and 9.3).
tools/covgaps command
Command covgaps reads a Go cover profile and prints every uncovered block.
Command covgaps reads a Go cover profile and prints every uncovered block.
Package profile is the file of named containers: containers.toml, in the per-user configuration directory, mode 0600.
Package profile is the file of named containers: containers.toml, in the per-user configuration directory, mode 0600.
Package session is the conversation between `theca close` / `theca status` (or a GUI) and the background process that holds an unlocked container.
Package session is the conversation between `theca close` / `theca status` (or a GUI) and the background process that holds an unlocked container.
Package share serves the exFAT filesystem inside an unlocked container over SMB on a loopback address, and optionally mounts it in the file manager.
Package share serves the exFAT filesystem inside an unlocked container over SMB on a loopback address, and optionally mounts it in the file manager.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址