data

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: BSD-3-Clause Imports: 11 Imported by: 29

Documentation

Index

Constants

View Source
const (
	KeyIDLength                = sha256.Size * 2
	KeyTypeEd25519             = "ed25519"
	KeyTypeECDSA_SHA2_P256     = "ecdsa-sha2-nistp256"
	KeySchemeEd25519           = "ed25519"
	KeySchemeECDSA_SHA2_P256   = "ecdsa-sha2-nistp256"
	KeyTypeRSASSA_PSS_SHA256   = "rsa"
	KeySchemeRSASSA_PSS_SHA256 = "rsassa-pss-sha256"
)

Variables

View Source
var (
	HashAlgorithms           = []string{"sha256", "sha512"}
	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 Hashes

type Hashes map[string]HexBytes

func (Hashes) HashAlgorithms added in v0.3.2

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 PrivateKey

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

type PublicKey

type PublicKey struct {
	Type       string          `json:"keytype"`
	Scheme     string          `json:"scheme"`
	Algorithms []string        `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

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