vault

package
v0.2.0-dev.14 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: AGPL-3.0 Imports: 11 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 encrypts secrets at rest (XChaCha20-Poly1305, AAD = record id) and provides a string type that never prints its value.

Index

Constants

KeySize is the master key length in bytes.

Variables

This section is empty.

Functions

func LoadKey

func LoadKey(dataDir string, create bool) ([]byte, error)

LoadKey reads the master key: $CREDENTIALS_DIRECTORY/master.key (systemd LoadCredential) if present, else <dataDir>/master.key. With create set, a missing key file in dataDir is generated (mode 0600); otherwise a missing key is an error.

Types

type Redacted

type Redacted string

Redacted is a secret string: every formatting path prints [REDACTED]. Use Reveal at the single place the value is really needed.

func (Redacted) Format

func (Redacted) Format(f fmt.State, _ rune)

func (Redacted) GoString

func (Redacted) GoString() string

func (Redacted) LogValue

func (Redacted) LogValue() slog.Value

func (Redacted) MarshalJSON

func (Redacted) MarshalJSON() ([]byte, error)

func (Redacted) MarshalText

func (Redacted) MarshalText() ([]byte, error)

func (Redacted) Reveal

func (r Redacted) Reveal() string

func (Redacted) String

func (Redacted) String() string

type Vault

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

Vault seals and opens secrets with the master key.

func New

func New(key []byte) (*Vault, error)

New builds a Vault from a 32-byte master key.

func (*Vault) Derive

func (v *Vault) Derive(label string) []byte

Derive is a key of KeySize bytes for one purpose (HKDF-SHA256 of the master key, the label as context): the same master key and label always give the same key, and keys of different labels reveal nothing about each other or about the master key. For values that must be recomputable without storing anything (page passwords).

func (*Vault) Open

func (v *Vault) Open(blob []byte, recordID string) ([]byte, error)

Open reverses Seal. It fails if the blob was tampered with or recordID differs.

func (*Vault) Seal

func (v *Vault) Seal(plaintext []byte, recordID string) []byte

Seal encrypts plaintext bound to recordID (the AAD): a blob sealed for one record cannot be opened as another. The random nonce is prepended to the result.

Jump to

Keyboard shortcuts

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