secret

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.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 secret seals secrets at rest with the server key (VX_SECRET_KEY): AES-256-GCM with a random nonce. Every database column ending in _enc holds a sealed value, never plaintext.

A sealed value is: version byte (1), 12-byte nonce, ciphertext and tag. The caller passes associated data naming what the value is (for example "github_app.private_key"), so a value copied into another column does not open.

Index

Constants

View Source
const KeySize = 32

KeySize is the size of the server key in bytes.

Variables

View Source
var ErrNoKey = errors.New("VX_SECRET_KEY is not set: the server needs a 32-byte key (64 hex characters or base64) to store secrets; generate one with `openssl rand -hex 32`")

ErrNoKey is returned when sealing or opening without a server key.

View Source
var ErrOpen = errors.New("a stored secret does not open with VX_SECRET_KEY: the key changed or the value is damaged")

ErrOpen is returned when a sealed value does not open: it was sealed with another key, for another purpose, or it was changed.

Functions

func Open

func Open(key []byte, purpose string, sealed []byte) ([]byte, error)

Open decrypts a value from Seal with the same key and purpose.

func OpenString

func OpenString(key []byte, purpose string, sealed []byte) (string, error)

func ParseKey

func ParseKey(s string) ([]byte, error)

ParseKey reads a server key: 64 hex characters, or base64 (standard or URL alphabet, padded or not) of 32 bytes. Surrounding space is ignored.

func Seal

func Seal(key []byte, purpose string, plaintext []byte) ([]byte, error)

Seal encrypts plaintext with key; purpose is bound as associated data.

func SealString

func SealString(key []byte, purpose, plaintext string) ([]byte, error)

SealString and OpenString are Seal and Open for strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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