secrets

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 14 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 secrets encrypts values at rest with the controller's master key (AES-256-GCM, §14). The key file is protected by permissions; a copy wrapped by the recovery key goes into backups (§5.0.1).

Index

Constants

This section is empty.

Variables

View Source
var ErrWrongRecoveryKey = errors.New("the recovery key does not match this backup")

ErrWrongRecoveryKey means the key does not unwrap this master key.

Functions

func NewRecoveryKey

func NewRecoveryKey() string

NewRecoveryKey returns a 200-bit key like SYNRK-ABCDE-FGHIJ-… (8 groups).

func RecoveryKeySuffix

func RecoveryKeySuffix(k string) string

RecoveryKeySuffix is what the setup wizard asks the user to type back: the key's last 6 characters, dashes and spaces not counted. Applied to the user's answer too, so "2-IRWKX", "2IRWKX" or the whole key all match.

func Restore

func Restore(dataDir string, master, wrapped []byte) error

Restore writes a master key (unwrapped from a backup) and its wrapped copy into dataDir.

func Unwrap

func Unwrap(wrapped []byte, recoveryKey string) ([]byte, error)

Unwrap recovers the master key.

func Wrap

func Wrap(master []byte, recoveryKey string) ([]byte, error)

Wrap encrypts master with the recovery key.

Types

type Box

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

func LoadOrCreate

func LoadOrCreate(dataDir string) (box *Box, recoveryKey string, err error)

LoadOrCreate reads <dataDir>/master.key, creating it (0600) on first start, and makes sure a wrapped copy exists. When it creates a new recovery key (first start, or an install from before recovery keys), it returns it so the caller can show it once; otherwise recoveryKey is "".

func New

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

func (*Box) Open

func (b *Box) Open(ciphertext, aad []byte) ([]byte, error)

func (*Box) Rewrap added in v0.2.0

func (b *Box) Rewrap(recoveryKey string) error

Rewrap wraps the master key with recoveryKey and makes it the copy that is stored and put into backups (recovery key rotation, Phase 19b). The master key, and so everything sealed with it, is unchanged.

func (*Box) Seal

func (b *Box) Seal(plaintext, aad []byte) []byte

Seal encrypts plaintext. aad binds the ciphertext to its context (e.g. the row ID) so it can't be copied to another row.

func (*Box) Verify added in v0.2.0

func (b *Box) Verify(recoveryKey string) error

Verify reports whether recoveryKey unwraps this master key.

func (*Box) Wrapped

func (b *Box) Wrapped() []byte

Wrapped returns the master key wrapped by the recovery key (safe to back up).

Jump to

Keyboard shortcuts

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