verify

package
v0.0.0-...-a98aea1 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2017 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingKey       = errors.New("tuf: missing key")
	ErrNoSignatures     = errors.New("tuf: data has no signatures")
	ErrInvalid          = errors.New("tuf: signature verification failed")
	ErrWrongMethod      = errors.New("tuf: invalid signature type")
	ErrUnknownRole      = errors.New("tuf: unknown role")
	ErrRoleThreshold    = errors.New("tuf: valid signatures did not meet threshold")
	ErrWrongMetaType    = errors.New("tuf: meta file has wrong type")
	ErrExists           = errors.New("tuf: key already in db")
	ErrWrongID          = errors.New("tuf: key id mismatch")
	ErrInvalidKey       = errors.New("tuf: invalid key")
	ErrInvalidRole      = errors.New("tuf: invalid role")
	ErrInvalidKeyID     = errors.New("tuf: invalid key id")
	ErrInvalidThreshold = errors.New("tuf: invalid role threshold")
)
View Source
var IsExpired = func(t time.Time) bool {
	return t.Sub(time.Now()) <= 0
}
View Source
var Verifiers = map[string]Verifier{
	data.KeyTypeEd25519:         ed25519Verifier{},
	data.KeyTypeECDSA_SHA2_P256: p256Verifier{},
}

Verifiers is used to map key types to Verifier instances.

Functions

func Unmarshal

func Unmarshal(b []byte, v interface{}, role string, minVersion int, db *DB) error

func UnmarshalTrusted

func UnmarshalTrusted(b []byte, v interface{}, role string, db *DB) error

func ValidRole

func ValidRole(name string) bool

Types

type DB

type DB struct {
	// contains filtered or unexported fields
}

func NewDB

func NewDB() *DB

func (*DB) AddKey

func (db *DB) AddKey(id string, k *data.Key) error

func (*DB) AddRole

func (db *DB) AddRole(name string, r *data.Role) error

func (*DB) GetKey

func (db *DB) GetKey(id string) *data.Key

func (*DB) GetRole

func (db *DB) GetRole(name string) *Role

func (*DB) Verify

func (db *DB) Verify(s *data.Signed, role string, minVersion int) error

func (*DB) VerifySignatures

func (db *DB) VerifySignatures(s *data.Signed, role string) error

type ErrExpired

type ErrExpired struct {
	Expired time.Time
}

func (ErrExpired) Error

func (e ErrExpired) Error() string

type ErrLowVersion

type ErrLowVersion struct {
	Actual  int
	Current int
}

func (ErrLowVersion) Error

func (e ErrLowVersion) Error() string

type Role

type Role struct {
	KeyIDs    map[string]struct{}
	Threshold int
}

func (*Role) ValidKey

func (r *Role) ValidKey(id string) bool

type Verifier

type Verifier interface {
	// Verify takes a key, message and signature, all as byte slices,
	// and determines whether the signature is valid for the given
	// key and message.
	Verify(key, msg, sig []byte) error

	// ValidKey returns true if the provided public key is valid and usable to
	// verify signatures with this verifier.
	ValidKey([]byte) bool
}

A Verifier verifies public key signatures.

Jump to

Keyboard shortcuts

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