seal

package
v0.1.6 Latest Latest
Warning

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

Go to latest
Published: Nov 13, 2026 License: MIT Imports: 7 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 detects authama's state being moved or edited outside authama.

A seal is an HMAC-SHA256, keyed by a secret the OS keeps for the user (see services/owner), over each state file's name and content and over the binding: who the user is and which machine this is. authama reseals after each operation it performs, so when a file no longer matches its seal, something other than authama changed it; when the binding no longer matches, the home was copied to another account or machine.

This is detection, not prevention. Anyone who can run as the user can read and write the user's files, and can run authama to reseal them. What a seal adds is that a change made behind authama's back - by another program, a sync tool, a restored backup, or a person editing the file - is noticed and named the next time authama runs, instead of being acted on silently.

The package is pure: the caller reads the files and supplies the key.

Index

Constants

View Source
const Version = 1

Version is the seal record format.

Variables

View Source
var ErrNoKey = errors.New("no sealing key")

ErrNoKey is a seal or verify asked for without a key.

Functions

This section is empty.

Types

type Binding

type Binding struct {
	User    string // the OS user name
	UID     string // the numeric id, or the Windows SID
	Machine string // the OS's machine id
}

Binding identifies the account and machine a home belongs to.

func (Binding) ID

func (b Binding) ID() string

ID is the binding as one opaque value: a hash, so the record does not carry the machine id in clear.

type Finding

type Finding struct {
	Name   string
	Status Status
}

Finding is one file whose state is not OK.

type Record

type Record struct {
	Version int               `json:"version"`
	Binding string            `json:"binding"`
	Sealed  time.Time         `json:"sealed"`
	Files   map[string]string `json:"files"` // name -> MAC; "" means the file was absent
	MAC     string            `json:"mac"`
}

Record is what is stored: one MAC per sealed file, and one over the record.

func Make

func Make(key []byte, b Binding, files map[string][]byte, now time.Time) (Record, error)

Make seals files: name -> content, with a nil content for a file that does not exist (so its appearing later is noticed too).

type Report

type Report struct {
	// Authentic is false when the record itself fails its MAC: the seal file
	// was edited, or the key is not the one that made it. Nothing else in the
	// report can be trusted then, and Findings is empty.
	Authentic bool
	// Bound is false when the record was made for another account or machine.
	Bound    bool
	Findings []Finding
}

Report is the outcome of a verification.

func Verify

func Verify(key []byte, b Binding, r Record, files map[string][]byte) Report

Verify checks files against r. A name in files but not in r is Unsealed; a name in r but not in files is not checked (the caller decides the set).

func (Report) Clean

func (r Report) Clean() bool

Clean reports a record that is authentic, bound here, and matches every file.

type Status

type Status string

Status is one file's state against its seal.

const (
	OK       Status = "ok"
	Changed  Status = "changed"  // present before and now, different content
	Missing  Status = "missing"  // present when sealed, gone now
	Appeared Status = "appeared" // absent when sealed, present now
	Unsealed Status = "unsealed" // not in the record at all
)

Jump to

Keyboard shortcuts

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