tuf

package
v0.9.4 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: BSD-3-Clause-Clear Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AtsKey

type AtsKey struct {
	KeyType  string    `json:"keytype"`
	KeyValue AtsKeyVal `json:"keyval"`
}

AtsKey is the ota-tuf representation of a key.

type AtsKeyVal

type AtsKeyVal struct {
	Public  string `json:"public,omitempty"`
	Private string `json:"private,omitempty"`
}

AtsKeyVal holds the (hex encoded) public and/or private key material.

type AtsTufRoot

type AtsTufRoot struct {
	Signatures []Signature `json:"signatures"`
	Signed     RootMeta    `json:"signed"`
}

AtsTufRoot is a full root.json file.

type AtsTufSnapshot

type AtsTufSnapshot struct {
	Signatures []Signature  `json:"signatures"`
	Signed     SnapshotMeta `json:"signed"`
}

AtsTufSnapshot is a full snapshot.json file.

type AtsTufTargets

type AtsTufTargets struct {
	Signatures []Signature `json:"signatures"`
	Signed     TargetsMeta `json:"signed"`
}

AtsTufTargets is a full targets.json file.

func (AtsTufTargets) GetLatestTargetVersion

func (t AtsTufTargets) GetLatestTargetVersion() int

type AtsTufTimestamp

type AtsTufTimestamp struct {
	Signatures []Signature   `json:"signatures"`
	Signed     TimestampMeta `json:"signed"`
}

AtsTufTimestamp is a full timestamp.json file.

type Hashes

type Hashes map[string]HexBytes

Hashes maps a hash algorithm name (e.g. "sha256") to a hex encoded digest.

type HexBytes

type HexBytes []byte

HexBytes is a byte slice that is hex encoded in JSON. TUF hashes use this representation (unlike signatures, which are base64 encoded).

func (HexBytes) MarshalJSON

func (b HexBytes) MarshalJSON() ([]byte, error)

func (*HexBytes) UnmarshalJSON

func (b *HexBytes) UnmarshalJSON(data []byte) error

type ImportSigner

type ImportSigner struct {
	Id string
	// contains filtered or unexported fields
}

ImportSigner wraps an offline private key (RSA or ed25519) imported from an external tool such as fioctl/garage-sign. It is used to co-sign a newly generated root metadata during migration so that the new root chains from the previously trusted (imported) root.

func ImportSignerFromAtsKey

func ImportSignerFromAtsKey(key AtsKey) (*ImportSigner, error)

ImportSignerFromAtsKey builds an ImportSigner from a private AtsKey. Both the ota-tuf RSA (PEM PKCS#1) and ed25519 (hex) private key representations are supported.

func (*ImportSigner) Sign

func (s *ImportSigner) Sign(signed any) (Signature, error)

Sign signs the canonical JSON of signed with the imported key and returns a SignedMeta carrying the signature along with the sha256 hash and length of the signed bytes.

type MetaItem

type MetaItem struct {
	Version int    `json:"version"`
	Length  int64  `json:"length"`
	Hashes  Hashes `json:"hashes"`
}

MetaItem references a version of another metadata file. The ota-tuf format for snapshot and timestamp metadata only records the version.

type RoleName

type RoleName string

RoleName is the canonical (lower-case) name of a TUF role.

const (
	RoleRoot      RoleName = "root"
	RoleTargets   RoleName = "targets"
	RoleSnapshot  RoleName = "snapshot"
	RoleTimestamp RoleName = "timestamp"
)

func (RoleName) TufType

func (r RoleName) TufType() string

tufType returns the "_type" value used in signed metadata for the role.

type RootMeta

type RootMeta struct {
	SignedCommon
	ConsistentSnapshot bool                  `json:"consistent_snapshot"`
	Keys               map[string]AtsKey     `json:"keys"`
	Roles              map[RoleName]RootRole `json:"roles"`
}

RootMeta is the "signed" component of a root.json file.

type RootRole

type RootRole struct {
	KeyIDs    []string `json:"keyids"`
	Threshold int      `json:"threshold"`
}

RootRole describes the keys and threshold for a role within root metadata.

type SigAlgorithm

type SigAlgorithm string

SigAlgorithm is the signing method recorded in a Signature.

const (
	SigEd25519      SigAlgorithm = "ed25519"
	SigRsaPssSha256 SigAlgorithm = "rsassa-pss-sha256"
)

type Signature

type Signature struct {
	KeyID     string       `json:"keyid"`
	Method    SigAlgorithm `json:"method"`
	Signature []byte       `json:"sig"`
}

Signature is a signature over the canonical JSON of a metadata's "signed" component. The raw signature bytes are base64 encoded in JSON.

type SignedCommon

type SignedCommon struct {
	Type    string    `json:"_type"`
	Expires time.Time `json:"expires"`
	Version int       `json:"version"`
}

SignedCommon contains the fields common to the "signed" component of all TUF metadata files.

type Signer

type Signer struct {
	Id string
	// contains filtered or unexported fields
}

tufSigner holds a loaded private key along with its TUF key id. The server uses online ed25519 keys for all roles.

func NewSigner

func NewSigner() (*Signer, error)

NewSigner generates a fresh ed25519 signer.

func SignerFromAtsKey

func SignerFromAtsKey(key AtsKey) (*Signer, error)

SignerFromAtsKey reconstructs a signer from a stored AtsKey (private key).

func (*Signer) PrivateAtsKey

func (s *Signer) PrivateAtsKey() AtsKey

privateAtsKey returns the AtsKey representation of the signer including the private key material (hex encoded seed).

func (*Signer) PublicAtsKey

func (s *Signer) PublicAtsKey() AtsKey

publicAtsKey returns the AtsKey representation of the signer with only the public key material, as embedded in root metadata.

func (*Signer) Sign

func (s *Signer) Sign(signed any) (Signature, error)

Sign signs the canonical JSON of signed and returns the signature.

type SnapshotMeta

type SnapshotMeta struct {
	SignedCommon
	Meta map[string]MetaItem `json:"meta"`
}

SnapshotMeta is the "signed" component of a snapshot.json file.

type TargetFileMeta

type TargetFileMeta struct {
	Length int64           `json:"length"`
	Hashes Hashes          `json:"hashes"`
	Custom json.RawMessage `json:"custom,omitempty"`
}

TargetFileMeta describes a single target file in targets metadata.

type TargetFiles

type TargetFiles map[string]TargetFileMeta

TargetFiles maps a target name to its metadata.

type TargetsMeta

type TargetsMeta struct {
	SignedCommon
	Targets TargetFiles `json:"targets"`
}

TargetsMeta is the "signed" component of a targets.json file.

type TimestampMeta

type TimestampMeta struct {
	SignedCommon
	Meta map[string]MetaItem `json:"meta"`
}

TimestampMeta is the "signed" component of a timestamp.json file.

Jump to

Keyboard shortcuts

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