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
- Variables
- func Fingerprint(s string) string
- func GenerateKey() (identity, recipient string, err error)
- func IsSealed(s string) bool
- func Open(s, name string, identities ...string) (value string, used int, err error)
- func Parse(s string) (keyVersion int, ciphertext []byte, err error)
- func Recipient(identity string) (string, error)
- func Seal(recipient string, keyVersion int, name, value string) (string, error)
- func ValidRecipient(s string) bool
- type NameMismatchError
Constants ¶
const Prefix = "sealed:v1:"
Prefix starts every sealed value of the current format.
Variables ¶
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 ¶
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 ¶
GenerateKey returns a new key pair: the private identity ("AGE-SECRET-KEY-1…") and its public recipient ("age1…").
func IsSealed ¶
IsSealed reports whether s looks like a sealed value. It does not validate it; use Parse for that.
func Open ¶
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 Seal ¶
Seal encrypts value for the secret name to recipient. keyVersion is recorded as a hint; pass 0 if unknown.
func ValidRecipient ¶
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