seal

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 13 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 seal keeps the secret values of a job from each reader but its target agents. The controller makes a new random 256-bit key for each job, encrypts each value with it (AES-256-GCM), and seals the job key to the P-256 ECDH key of each target agent. Each algorithm is FIPS 140-3 approved, from the Go standard library.

A job has one ephemeral P-256 key, From, that seals its key to each agent. For an agent with the public key R, the key-encryption key is HKDF-SHA256 of the ECDH secret of From and R, with no salt and the info "osapi-seal-v1" || From || R (each the 65 bytes of its uncompressed point). The sealed key is base64url, with no padding, of the 12-byte nonce, the job key encrypted with AES-256-GCM, and its 16-byte tag; the job ID is the additional data. A sealed value is Prefix, then base64url of the nonce, the value encrypted with the job key, and the tag, with the job ID as the additional data. Thus a value or a key that somebody copies to a different job does not open.

Index

Constants

View Source
const Prefix = "sealed:"

Prefix starts each sealed value in the data of a job.

Variables

View Source
var ErrNotSealedToAgent = errors.New("the job was not sealed to this agent")

ErrNotSealedToAgent is the error of a job that has sealed values, but no job key for this agent, such as an agent that joined after the controller queued the job.

Functions

func WithOpener

func WithOpener(
	ctx context.Context,
	o *Opener,
) context.Context

WithOpener is ctx with o, the Opener of the job that the agent runs.

Types

type Opener

type Opener struct {
	// contains filtered or unexported fields
}

Opener opens the sealed values of one job.

func Open

func Open(
	jobID string,
	sealedKey string,
	from string,
	own *ecdh.PrivateKey,
) (*Opener, error)

Open is the Opener of the job jobID: own, the P-256 key of the agent, opens sealedKey, the job key that from sealed to it.

func OpenerFrom

func OpenerFrom(
	ctx context.Context,
) *Opener

OpenerFrom is the Opener that WithOpener put in ctx, or nil when the job has no sealed value.

func (*Opener) Value

func (o *Opener) Value(
	v secret.Value,
) (secret.Value, error)

Value is the value that v, a sealed value, holds.

type Sealer

type Sealer struct {
	// contains filtered or unexported fields
}

Sealer seals the values of one job.

func New

func New(
	jobID string,
) (*Sealer, error)

New is a Sealer for the job jobID, with a new random job key, and a new P-256 key that seals the job key to each agent.

func (*Sealer) From

func (s *Sealer) From() string

From is the public P-256 key that seals the job key, in pki.EncryptionKeyEncoding. The agent needs it to open the job key.

func (*Sealer) KeyFor

func (s *Sealer) KeyFor(
	recipient string,
) (string, error)

KeyFor is the job key sealed to recipient, the public P-256 key of an agent in pki.EncryptionKeyEncoding.

func (*Sealer) Value

func (s *Sealer) Value(
	v secret.Value,
) string

Value is v sealed with the job key: Prefix, then the nonce, the ciphertext and the tag.

Jump to

Keyboard shortcuts

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