sealbox

package
v1.0.310 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2026 License: MIT Imports: 6 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 sealbox is the recipient-public-key sealing leaf for support-bundle export (M4 E2E). It wraps NaCl anonymous sealed boxes (X25519 key agreement + XSalsa20-Poly1305 AEAD via golang.org/x/crypto/nacl/box) in a fixed, versioned envelope so a bundle can be sealed to a recipient's PUBLIC key on the appliance and opened ONLY by the holder of the matching private key. The appliance never holds a decryption capability — true end-to-end confidentiality to (e.g.) TAC.

On-disk format:

offset  size  field       notes
------  ----  ----------  ---------------------------------
  0       8   magic       "CVRTSB01" (ASCII)
  8       1   version     0x01
  9      ..   sealed box  box.SealAnonymous output (ephemeral pub || ciphertext || tag)

The magic distinguishes a sealed export from the passphrase envelope ("CVRTBK01") and from a plain gzip tar, so a recipient tool can sniff the first bytes. Anonymous boxes carry no sender identity by design (the operator chooses the recipient key out-of-band); integrity/authenticity of the CONTENTS still comes from the bundle manifest's own hashes.

Index

Constants

View Source
const (
	// Magic is the 8-byte ASCII envelope magic.
	Magic = "CVRTSB01"
	// MagicLen is the prefix length a reader peeks to classify a blob.
	MagicLen = 8
	// Version is the current envelope version byte.
	Version = byte(0x01)
	// KeyLen is the X25519 public/private key length.
	KeyLen = 32
)

Variables

View Source
var ErrLowOrderKey = errors.New("sealbox: low-order recipient public key")

ErrLowOrderKey is returned for a recipient public key that is a low-order Curve25519 point. Sealing to such a key would derive an all-zero shared secret, so the resulting box could be opened WITHOUT the recipient's private key — silently breaking the end-to-end confidentiality guarantee. We reject these before ever sealing.

View Source
var ErrOpenFailed = errors.New("sealed bundle open failed (wrong key or tampered)")

ErrOpenFailed is the single opaque error for a decrypt/auth failure (wrong key or tampered ciphertext) — it never distinguishes the two, so a caller gets no oracle. Header-level problems (bad magic/version/length) report specifically because they leak no key information.

Functions

func GenerateKey

func GenerateKey() (pub, priv *[KeyLen]byte, err error)

GenerateKey returns a fresh X25519 key pair (public, private). Recipients use it to publish a public key and keep the private key; tests use it end-to-end.

func IsSealed

func IsSealed(prefix []byte) bool

IsSealed reports whether prefix begins with the sealbox magic.

func Open

func Open(blob []byte, recipientPub, recipientPriv *[KeyLen]byte) ([]byte, error)

Open reverses Seal using the recipient's key pair. It validates the header, then opens the anonymous box; any auth/key failure returns ErrOpenFailed.

func Seal

func Seal(plaintext []byte, recipientPub *[KeyLen]byte, randSource io.Reader) ([]byte, error)

Seal wraps plaintext for recipientPub. randSource defaults to crypto/rand when nil (tests may inject a deterministic reader).

func ValidateRecipientPublicKey

func ValidateRecipientPublicKey(pub *[KeyLen]byte) error

ValidateRecipientPublicKey rejects a nil or low-order X25519 public key. A low-order point drives box.SealAnonymous to an all-zero shared key, which would let anyone (not just the private-key holder) open the sealed bundle; guarding here keeps that class of key from ever producing a "sealed" blob.

Types

This section is empty.

Jump to

Keyboard shortcuts

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