data

package
v1.1.0-0.5.2 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyIDLength = sha256.Size * 2

	KeyTypeEd25519 KeyType = "ed25519"
	// From version 1.0.32, the reference implementation defines 'ecdsa',
	// not 'ecdsa-sha2-nistp256' for NIST P-256 curves.
	KeyTypeECDSA_SHA2_P256         KeyType = "ecdsa"
	KeyTypeECDSA_SHA2_P256_OLD_FMT KeyType = "ecdsa-sha2-nistp256"
	KeyTypeRSASSA_PSS_SHA256       KeyType = "rsa"

	KeySchemeEd25519           KeyScheme = "ed25519"
	KeySchemeECDSA_SHA2_P256   KeyScheme = "ecdsa-sha2-nistp256"
	KeySchemeRSASSA_PSS_SHA256 KeyScheme = "rsassa-pss-sha256"

	HashAlgorithmSHA256 HashAlgorithm = "sha256"
	HashAlgorithmSHA512 HashAlgorithm = "sha512"
)

Variables

View Source
var (
	HashAlgorithms           = []HashAlgorithm{HashAlgorithmSHA256, HashAlgorithmSHA512}
	ErrPathsAndPathHashesSet = errors.New("tuf: failed validation of delegated target: paths and path_hash_prefixes are both set")
)

Functions

func DefaultExpires

func DefaultExpires(role string) time.Time

func PathHexDigest

func PathHexDigest(s string) string

4.5. File formats: targets.json and delegated target roles: ...each target path, when hashed with the SHA-256 hash function to produce a 64-byte hexadecimal digest (HEX_DIGEST)...

Types

type DelegatedRole

type DelegatedRole struct {
	Name             string   `json:"name"`
	KeyIDs           []string `json:"keyids"`
	Threshold        int      `json:"threshold"`
	Terminating      bool     `json:"terminating"`
	PathHashPrefixes []string `json:"path_hash_prefixes,omitempty"`
	Paths            []string `json:"paths"`
}

DelegatedRole describes a delegated role, including what paths it is reponsible for. See spec v1.0.19 section 4.5.

func (*DelegatedRole) MarshalJSON

func (d *DelegatedRole) MarshalJSON() ([]byte, error)

MarshalJSON is called when writing the struct to JSON. We validate prior to marshalling to ensure that an invalid delegated role can not be serialized to JSON.

func (*DelegatedRole) MatchesPath

func (d *DelegatedRole) MatchesPath(file string) (bool, error)

MatchesPath evaluates whether the path patterns or path hash prefixes match a given file. This determines whether a delegated role is responsible for signing and verifying the file.

func (*DelegatedRole) UnmarshalJSON

func (d *DelegatedRole) UnmarshalJSON(b []byte) error

UnmarshalJSON is called when reading the struct from JSON. We validate once unmarshalled to ensure that an error is thrown if an invalid delegated role is read.

type Delegations

type Delegations struct {
	Keys  map[string]*PublicKey `json:"keys"`
	Roles []DelegatedRole       `json:"roles"`
}

Delegations represents the edges from a parent Targets role to one or more delegated target roles. See spec v1.0.19 section 4.5.

type FileMeta

type FileMeta struct {
	Length int64  `json:"length"`
	Hashes Hashes `json:"hashes"`
}

type Files

type Files map[string]TargetFileMeta

type HashAlgorithm

type HashAlgorithm string

type Hashes

type Hashes map[string]HexBytes

func (Hashes) HashAlgorithms

func (f Hashes) HashAlgorithms() []string

type HexBytes

type HexBytes []byte

func (HexBytes) MarshalJSON

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

func (HexBytes) String

func (b HexBytes) String() string

func (*HexBytes) UnmarshalJSON

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

type KeyScheme

type KeyScheme string

type KeyType

type KeyType string

type PrivateKey

type PrivateKey struct {
	Type       KeyType         `json:"keytype"`
	Scheme     KeyScheme       `json:"scheme,omitempty"`
	Algorithms []HashAlgorithm `json:"keyid_hash_algorithms,omitempty"`
	Value      json.RawMessage `json:"keyval"`
}

type PublicKey

type PublicKey struct {
	Type       KeyType         `json:"keytype"`
	Scheme     KeyScheme       `json:"scheme"`
	Algorithms []HashAlgorithm `json:"keyid_hash_algorithms,omitempty"`
	Value      json.RawMessage `json:"keyval"`
	// contains filtered or unexported fields
}

func (*PublicKey) ContainsID

func (k *PublicKey) ContainsID(id string) bool

func (*PublicKey) IDs

func (k *PublicKey) IDs() []string

type Role

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

func (*Role) AddKeyIDs

func (r *Role) AddKeyIDs(ids []string) bool

type Root

type Root struct {
	Type        string                `json:"_type"`
	SpecVersion string                `json:"spec_version"`
	Version     int64                 `json:"version"`
	Expires     time.Time             `json:"expires"`
	Keys        map[string]*PublicKey `json:"keys"`
	Roles       map[string]*Role      `json:"roles"`
	Custom      *json.RawMessage      `json:"custom,omitempty"`

	ConsistentSnapshot bool `json:"consistent_snapshot"`
}

func NewRoot

func NewRoot() *Root

func (*Root) AddKey

func (r *Root) AddKey(key *PublicKey) bool

type Signature

type Signature struct {
	KeyID     string   `json:"keyid"`
	Signature HexBytes `json:"sig"`
}

type Signed

type Signed struct {
	Signed     json.RawMessage `json:"signed"`
	Signatures []Signature     `json:"signatures"`
}

type Snapshot

type Snapshot struct {
	Type        string           `json:"_type"`
	SpecVersion string           `json:"spec_version"`
	Version     int64            `json:"version"`
	Expires     time.Time        `json:"expires"`
	Meta        SnapshotFiles    `json:"meta"`
	Custom      *json.RawMessage `json:"custom,omitempty"`
}

func NewSnapshot

func NewSnapshot() *Snapshot

type SnapshotFileMeta

type SnapshotFileMeta metapathFileMeta

SnapshotFileMeta is the meta field of a snapshot Note: Contains a `custom` field

type SnapshotFiles

type SnapshotFiles map[string]SnapshotFileMeta

type TargetFileMeta

type TargetFileMeta struct {
	FileMeta
	Custom *json.RawMessage `json:"custom,omitempty"`
}

func (TargetFileMeta) HashAlgorithms

func (f TargetFileMeta) HashAlgorithms() []string

type TargetFiles

type TargetFiles map[string]TargetFileMeta

type Targets

type Targets struct {
	Type        string           `json:"_type"`
	SpecVersion string           `json:"spec_version"`
	Version     int64            `json:"version"`
	Expires     time.Time        `json:"expires"`
	Targets     TargetFiles      `json:"targets"`
	Delegations *Delegations     `json:"delegations,omitempty"`
	Custom      *json.RawMessage `json:"custom,omitempty"`
}

func NewTargets

func NewTargets() *Targets

type Timestamp

type Timestamp struct {
	Type        string           `json:"_type"`
	SpecVersion string           `json:"spec_version"`
	Version     int64            `json:"version"`
	Expires     time.Time        `json:"expires"`
	Meta        TimestampFiles   `json:"meta"`
	Custom      *json.RawMessage `json:"custom,omitempty"`
}

func NewTimestamp

func NewTimestamp() *Timestamp

type TimestampFileMeta

type TimestampFileMeta metapathFileMeta

type TimestampFiles

type TimestampFiles map[string]TimestampFileMeta

Jump to

Keyboard shortcuts

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