Documentation
¶
Overview ¶
Package passphrase provides the passphrase-based archive encryption shared by internal/backup and the recovery bundle: a caller-chosen "magic" prefix identifies the archive format and doubles as the AEAD's associated data (so a sealed payload can't be replayed under a different format's magic), and the passphrase itself is stretched with Argon2id before sealing the payload with AES-256-GCM. Without a passphrase, the payload is written plain, behind the same magic+flag framing, so a reader can always tell which case it's looking at from the first few bytes alone.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrBadMagic = errors.New("passphrase: not a recognised archive for this magic")
ErrBadMagic is returned when the leading bytes don't match the caller's expected magic — the file isn't this kind of archive at all.
var ErrPassphraseRequired = errors.New("passphrase: this archive is encrypted; a passphrase is required")
ErrPassphraseRequired is returned when opening an encrypted archive without one (or with the wrong one — the two are indistinguishable by design).
Functions ¶
func OpenFrom ¶
OpenFrom reads salt || nonce || len || sealed from r (immediately after ReadFlag has consumed the magic+flag prefix) and returns the decrypted plaintext.
func ReadFlag ¶
ReadFlag reads and verifies the magic prefix from r and returns whether the payload that follows is encrypted. Callers read this first, then dispatch to either a plain io.Copy of the remainder or OpenFrom.
func SealTo ¶
SealTo writes magic || flagEncrypted || salt || nonce || len || sealed, where sealed is AES-256-GCM(plain) under an Argon2id-derived key, with magic as the AEAD's associated data. The whole plaintext is sealed as one unit — chunking would invite a truncation attack for no benefit here — so plain must fit in memory, same as the encrypted path this replaces in internal/backup.
Types ¶
This section is empty.