Documentation
¶
Overview ¶
Package vault seals data with a password, for the backups that take SSHYard's data, secrets included, out of the keychain: the data is encrypted under a random vault key (XChaCha20-Poly1305), and the vault key is wrapped under a key derived from the password (Argon2id). The password itself is never stored.
A sealed file is JSON: a plaintext header (the format, its version, when it was made and the wrapped keys) and the encrypted body, whose authentication covers the header too, so neither can be changed alone.
Index ¶
- Constants
- Variables
- func Check(b []byte) error
- func Created(b []byte) (time.Time, error)
- func Open(b, password []byte) ([]byte, error)
- func OpenWith(ctx context.Context, b, password []byte, costly bool) ([]byte, error)
- func Seal(data, password []byte, p Params) ([]byte, error)
- type Cost
- type CostError
- type Key
- type Params
Constants ¶
const Format = "sshyard-vault"
Format names a sealed file in its header.
const Version = 1
Version is the version of the format this package writes and reads.
Variables ¶
var ( // ErrFormat reports data that is not a sealed file. ErrFormat = errors.New("vault: not an SSHYard backup") // ErrVersion reports a file of a newer format than this app reads. ErrVersion = errors.New("vault: made by a newer version of SSHYard") // ErrPassword reports a password that does not open the file (or a // file whose wrapped key was damaged; the two can not be told apart). ErrPassword = errors.New("vault: wrong password") // ErrCorrupt reports a file whose body was damaged or changed. ErrCorrupt = errors.New("vault: the file is damaged") // ErrCostly reports a file whose password derivation costs more than // usual, though within the limits: Open declines it, OpenWith opens it // once allowed. The error is a *CostError, which says how much. ErrCostly = errors.New("vault: the file's password derivation costs more than usual") // ErrTooCostly reports a file whose password derivation costs more // than this package ever derives: too many wraps, or passes, memory // or work past the limits. Nothing was derived. ErrTooCostly = errors.New("vault: the file's password derivation costs more than SSHYard allows") )
var DefaultParams = Params{Time: 3, Memory: 64 << 10, Threads: 4}
DefaultParams are what Seal uses in the app: 3 passes over 64 MiB on 4 lanes: well under a second on a current machine, and costly to guess against.
Functions ¶
func Check ¶
Check reports whether b is a sealed file this package can open, without the password: ErrFormat, ErrVersion, ErrTooCostly or nil. It derives nothing.
func Open ¶
Open decrypts a file Seal made, with its password. A file whose derivation costs more than usual is a *CostError (ErrCostly), with nothing derived: OpenWith opens it.
func OpenWith ¶ added in v1.1.1
OpenWith is Open, which with costly also opens a file whose derivation costs more than usual, never past the limits (ErrTooCostly). Once ctx is done it stops with ctx's error before the next wrap: one derivation under way can not be interrupted and runs to its end, so cancelling only keeps the wraps after it from being derived.
Types ¶
type Cost ¶ added in v1.1.1
Cost is what opening a sealed file derives: the password wraps tried, their passes in all, the most memory one takes and the work of them all (passes × memory), in KiB.
type CostError ¶ added in v1.1.1
type CostError struct{ Cost Cost }
CostError is a file whose derivation costs more than usual: ErrCostly, with what it costs.
type Key ¶ added in v0.0.7
Key is what a password derives to, with a salt of its own, and how: kept in the local encrypted store, it seals files for automatic backups without the password, and those files still open with the password.