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
- Variables
- func Open(key []byte, purpose string, sealed []byte) ([]byte, error)
- func OpenString(key []byte, purpose string, sealed []byte) (string, error)
- func ParseKey(s string) ([]byte, error)
- func Seal(key []byte, purpose string, plaintext []byte) ([]byte, error)
- func SealString(key []byte, purpose, plaintext string) ([]byte, error)
Constants ¶
const KeySize = 32
KeySize is the size of the server key in bytes.
Variables ¶
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.
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 ParseKey ¶
ParseKey reads a server key: 64 hex characters, or base64 (standard or URL alphabet, padded or not) of 32 bytes. Surrounding space is ignored.
Types ¶
This section is empty.