sealed

package
v1.10.21 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: AGPL-3.0, Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package sealed implements sealed secret values: a secret encrypted to a workspace's public sealing key so it can be committed to git and only Miabi can open it.

A sealed value reads "sealed:v1:<keyVersion>:<base64(age ciphertext)>". The ciphertext is an age (X25519) file whose plaintext names the secret it was sealed for, so a value copied into another Secret refuses to open. Each workspace has its own key pair, which binds the value to the workspace as well. keyVersion is a hint for picking the private key; 0 means unknown and every retained key is tried.

Index

Constants

View Source
const Prefix = "sealed:v1:"

Prefix starts every sealed value of the current format.

Variables

View Source
var (
	// ErrFormat means the string is not a sealed value of a known format.
	ErrFormat = errors.New("not a sealed value (expected sealed:v1:<version>:<data>)")
	// ErrNoKey means none of the given private keys opens the value: it was sealed for another workspace, or
	// with a sealing key that no longer exists.
	ErrNoKey = errors.New("sealed value does not open with this workspace's sealing keys")
)

Functions

func Fingerprint

func Fingerprint(s string) string

Fingerprint identifies a sealed value without revealing anything about the plaintext. Every seal draws a fresh ephemeral key, so re-sealing the same value yields a different fingerprint.

func GenerateKey

func GenerateKey() (identity, recipient string, err error)

GenerateKey returns a new key pair: the private identity ("AGE-SECRET-KEY-1…") and its public recipient ("age1…").

func IsSealed

func IsSealed(s string) bool

IsSealed reports whether s looks like a sealed value. It does not validate it; use Parse for that.

func Open

func Open(s, name string, identities ...string) (value string, used int, err error)

Open decrypts a sealed value declared on the secret name, trying each private identity in order, and returns the plaintext and the index of the identity that opened it.

func Parse

func Parse(s string) (keyVersion int, ciphertext []byte, err error)

Parse splits a sealed value into its key-version hint and ciphertext.

func Recipient

func Recipient(identity string) (string, error)

Recipient derives the public recipient of a private identity.

func Seal

func Seal(recipient string, keyVersion int, name, value string) (string, error)

Seal encrypts value for the secret name to recipient. keyVersion is recorded as a hint; pass 0 if unknown.

func ValidRecipient

func ValidRecipient(s string) bool

ValidRecipient reports whether s parses as a public sealing key.

Types

type NameMismatchError

type NameMismatchError struct {
	SealedFor, DeclaredAs string
}

NameMismatchError reports a value sealed for a different secret than the one it is declared on.

func (*NameMismatchError) Error

func (e *NameMismatchError) Error() string

Jump to

Keyboard shortcuts

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