Documentation ¶
Index ¶
- Constants
- Variables
- func DefaultExpires(role string) time.Time
- func PathHexDigest(s string) string
- type DelegatedRole
- type Delegations
- type FileMeta
- type Files
- type Hashes
- type HexBytes
- type PrivateKey
- type PublicKey
- type Role
- type Root
- type Signature
- type Signed
- type Snapshot
- type SnapshotFileMeta
- type SnapshotFiles
- type TargetFileMeta
- type TargetFiles
- type Targets
- type Timestamp
- type TimestampFileMeta
- type TimestampFiles
Constants ¶
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 ¶
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 PathHexDigest ¶
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 Files ¶
type Files map[string]TargetFileMeta
type Hashes ¶
func (Hashes) HashAlgorithms ¶ added in v0.3.2
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 ¶
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"` }
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