data

package
v0.0.0-...-69a7a08 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2015 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TUFTypes = map[string]string{
	"targets":   "Targets",
	"root":      "Root",
	"snapshot":  "Snapshot",
	"timestamp": "Timestamp",
}
View Source
var ValidRoles = map[string]string{
	"root":      "root",
	"targets":   "targets",
	"snapshot":  "snapshot",
	"timestamp": "timestamp",
}

Functions

func DefaultExpires

func DefaultExpires(role string) time.Time

func RoleName

func RoleName(role string) string

func SetDefaultExpiryTimes

func SetDefaultExpiryTimes(times map[string]time.Time)

SetDefaultExpiryTimes allows one to change the default expiries.

func SetTUFTypes

func SetTUFTypes(ts map[string]string)

SetTUFTypes allows one to override some or all of the default type names in TUF.

func SetValidRoles

func SetValidRoles(rs map[string]string)

func ValidRole

func ValidRole(name string) bool

ValidRole only determines the name is semantically correct. For target delegated roles, it does NOT check the the appropriate parent roles exist.

func ValidTUFType

func ValidTUFType(t string) bool

Checks if type is correct.

Types

type Delegations

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

func NewDelegations

func NewDelegations() *Delegations

type FileMeta

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

func NewFileMeta

func NewFileMeta(r io.Reader, hashAlgorithms ...string) (FileMeta, error)

type Files

type Files map[string]FileMeta

type Hashes

type Hashes map[string]HexBytes

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 Key

type Key interface {
	ID() string
	Cipher() string
	Public() string
	Private() string
}

type KeyPair

type KeyPair struct {
	Public  []byte `json:"public"`
	Private []byte `json:"private"`
}

type PrivateKey

type PrivateKey struct {
	TUFKey
}

func NewPrivateKey

func NewPrivateKey(cipher, public, private string) *PrivateKey

func (PrivateKey) Private

func (k PrivateKey) Private() string

type PublicKey

type PublicKey struct {
	TUFKey
}

func NewPublicKey

func NewPublicKey(cipher, public string) *PublicKey

func PublicKeyFromPrivate

func PublicKeyFromPrivate(pk PrivateKey) *PublicKey

func (PublicKey) Private

func (k PublicKey) Private() string

type Role

type Role struct {
	RootRole
	Name             string   `json:"name"`
	Paths            []string `json:"paths,omitempty"`
	PathHashPrefixes []string `json:"path_hash_prefixes,omitempty"`
}

func NewRole

func NewRole(name string, threshold int, keyIDs, paths, pathHashPrefixes []string) (*Role, error)

func (Role) CheckPaths

func (r Role) CheckPaths(path string) bool

func (Role) CheckPrefixes

func (r Role) CheckPrefixes(hash string) bool

func (Role) IsDelegation

func (r Role) IsDelegation() bool

func (Role) IsValid

func (r Role) IsValid() bool

func (Role) ValidKey

func (r Role) ValidKey(id string) bool

type Root

type Root struct {
	Type               string                `json:"_type"`
	Version            int                   `json:"version"`
	Expires            string                `json:"expires"`
	Keys               map[string]*PublicKey `json:"keys"`
	Roles              map[string]*RootRole  `json:"roles"`
	ConsistentSnapshot bool                  `json:"consistent_snapshot"`
}

type RootRole

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

type Signature

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

type Signed

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

type SignedRoot

type SignedRoot struct {
	Signatures []Signature
	Signed     Root
	Dirty      bool
}

func NewRoot

func NewRoot(keys map[string]*PublicKey, roles map[string]*RootRole, consistent bool) (*SignedRoot, error)

func RootFromSigned

func RootFromSigned(s *Signed) (*SignedRoot, error)

func (SignedRoot) ToSigned

func (r SignedRoot) ToSigned() (*Signed, error)

type SignedSnapshot

type SignedSnapshot struct {
	Signatures []Signature
	Signed     Snapshot
	Dirty      bool
}

func NewSnapshot

func NewSnapshot(root *Signed, targets *Signed) (*SignedSnapshot, error)

func SnapshotFromSigned

func SnapshotFromSigned(s *Signed) (*SignedSnapshot, error)

func (*SignedSnapshot) AddMeta

func (sp *SignedSnapshot) AddMeta(role string, meta FileMeta)

func (SignedSnapshot) ToSigned

func (sp SignedSnapshot) ToSigned() (*Signed, error)

type SignedTargets

type SignedTargets struct {
	Signatures []Signature
	Signed     Targets
	Dirty      bool
}

func NewTargets

func NewTargets() *SignedTargets

func TargetsFromSigned

func TargetsFromSigned(s *Signed) (*SignedTargets, error)

func (*SignedTargets) AddDelegation

func (t *SignedTargets) AddDelegation(role *Role, keys []*PublicKey) error

func (*SignedTargets) AddTarget

func (t *SignedTargets) AddTarget(path string, meta FileMeta)

func (SignedTargets) GetDelegations

func (t SignedTargets) GetDelegations(path string) []*Role

GetDelegations filters the roles and associated keys that may be the signers for the given target path. If no appropriate roles can be found, it will simply return nil for the return values. The returned slice of Role will have order maintained relative to the role slice on Delegations per TUF spec proposal on using order to determine priority.

func (SignedTargets) GetMeta

func (t SignedTargets) GetMeta(path string) *FileMeta

GetMeta attempts to find the targets entry for the path. It will return nil in the case of the target not being found.

func (SignedTargets) ToSigned

func (t SignedTargets) ToSigned() (*Signed, error)

type SignedTimestamp

type SignedTimestamp struct {
	Signatures []Signature
	Signed     Timestamp
	Dirty      bool
}

func NewTimestamp

func NewTimestamp(snapshot *Signed) (*SignedTimestamp, error)

func TimestampFromSigned

func TimestampFromSigned(s *Signed) (*SignedTimestamp, error)

func (SignedTimestamp) ToSigned

func (ts SignedTimestamp) ToSigned() (*Signed, error)

type Snapshot

type Snapshot struct {
	Type    string `json:"_type"`
	Version int    `json:"version"`
	Expires string `json:"expires"`
	Meta    Files  `json:"meta"`
}

type TUFKey

type TUFKey struct {
	Type  string  `json:"keytype"`
	Value KeyPair `json:"keyval"`
	// contains filtered or unexported fields
}

func NewTUFKey

func NewTUFKey(cipher, public, private string) *TUFKey

func (TUFKey) Cipher

func (k TUFKey) Cipher() string

func (*TUFKey) ID

func (k *TUFKey) ID() string

func (TUFKey) Public

func (k TUFKey) Public() string

type Targets

type Targets struct {
	Type        string      `json:"_type"`
	Version     int         `json:"version"`
	Expires     string      `json:"expires"`
	Targets     Files       `json:"targets"`
	Delegations Delegations `json:"delegations,omitempty"`
}

type Timestamp

type Timestamp struct {
	Type    string `json:"_type"`
	Version int    `json:"version"`
	Expires string `json:"expires"`
	Meta    Files  `json:"meta"`
}

Jump to

Keyboard shortcuts

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