Documentation
¶
Index ¶
- Constants
- Variables
- func DefaultExpires(role string) time.Time
- func PathHexDigest(s string) string
- type DelegatedRole
- type Delegations
- type FileMeta
- type Files
- type HashAlgorithm
- type Hashes
- type HexBytes
- type KeyScheme
- type KeyType
- 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 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 ¶
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 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 HashAlgorithm ¶ added in v0.5.0
type HashAlgorithm string
type Hashes ¶
func (Hashes) HashAlgorithms ¶ added in v0.3.2
type HexBytes ¶
type HexBytes []byte
func (*HexBytes) FromString ¶ added in v0.7.0
func (HexBytes) MarshalJSON ¶
func (*HexBytes) UnmarshalJSON ¶
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 ¶
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
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