vault

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0 modules, 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.

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

View Source
const Format = "sshyard-vault"

Format names a sealed file in its header.

View Source
const Version = 1

Version is the version of the format this package writes and reads.

Variables

View Source
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")
)
View Source
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

func Check(b []byte) error

Check reports whether b is a sealed file this package can open, without the password: ErrFormat, ErrVersion or nil.

func Created

func Created(b []byte) (time.Time, error)

Created is when the sealed file b was made.

func Open

func Open(b, password []byte) ([]byte, error)

Open decrypts a file Seal made, with its password.

func Seal

func Seal(data, password []byte, p Params) ([]byte, error)

Seal encrypts data under password, deriving with p.

Types

type Key added in v0.0.7

type Key struct {
	Params Params `json:"params"`
	Salt   []byte `json:"salt"`
	KEK    []byte `json:"kek"`
}

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.

func Derive added in v0.0.7

func Derive(password []byte, p Params) (Key, error)

Derive derives a Key from password with p and a new salt.

func (Key) Clear added in v0.0.7

func (k Key) Clear()

Clear zeroes the derived key.

func (Key) Seal added in v0.0.7

func (k Key) Seal(data []byte) ([]byte, error)

Seal encrypts data as Seal does with the password k came from.

func (Key) Valid added in v0.0.7

func (k Key) Valid() bool

Valid reports whether k can seal: a key of the right size and a salt and parameters Open will take.

type Params

type Params struct {
	Time    uint32 `json:"t"`
	Memory  uint32 `json:"m"`
	Threads uint8  `json:"p"`
}

Params are the cost of Argon2id: passes, memory in KiB, and lanes.

Jump to

Keyboard shortcuts

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