Documentation ¶
Index ¶
- Variables
- func IsExpired(t time.Time) bool
- func RegisterVerifier(algorithm data.SigAlgorithm, v Verifier)
- func Sign(service CryptoService, s *data.Signed, keys ...data.PublicKey) error
- func Verify(s *data.Signed, role data.BaseRole, minVersion int) error
- func VerifyRoot(s *data.Signed, minVersion int, keys map[string]data.PublicKey) error
- func VerifySignatures(s *data.Signed, roleData data.BaseRole) error
- type CryptoService
- type ECDSAVerifier
- type Ed25519
- func (e *Ed25519) Create(role, algorithm string) (data.PublicKey, error)
- func (e *Ed25519) GetKey(keyID string) data.PublicKey
- func (e *Ed25519) GetPrivateKey(keyID string) (data.PrivateKey, string, error)
- func (e *Ed25519) ImportRootKey(r io.Reader) error
- func (e *Ed25519) ListAllKeys() map[string]string
- func (e *Ed25519) ListKeys(role string) []string
- func (e *Ed25519) PublicKeys(keyIDs ...string) (map[string]data.PublicKey, error)
- func (e *Ed25519) RemoveKey(keyID string) error
- type Ed25519Verifier
- type ErrExpired
- type ErrInsufficientSignatures
- type ErrInvalidKeyLength
- type ErrInvalidKeyType
- type ErrLowVersion
- type ErrNoKeys
- type ErrRoleThreshold
- type KeyService
- type RSAPKCS1v15Verifier
- type RSAPSSVerifier
- type RSAPyCryptoVerifier
- type Verifier
Constants ¶
This section is empty.
Variables ¶
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") ErrWrongType = errors.New("tuf: meta file has wrong type") )
Various basic signing errors
var Verifiers = map[data.SigAlgorithm]Verifier{ data.RSAPSSSignature: RSAPSSVerifier{}, data.RSAPKCS1v15Signature: RSAPKCS1v15Verifier{}, data.PyCryptoSignature: RSAPyCryptoVerifier{}, data.ECDSASignature: ECDSAVerifier{}, data.EDDSASignature: Ed25519Verifier{}, }
Verifiers serves as a map of all verifiers available on the system and can be injected into a verificationService. For testing and configuration purposes, it will not be used by default.
Functions ¶
func RegisterVerifier ¶
func RegisterVerifier(algorithm data.SigAlgorithm, v Verifier)
RegisterVerifier provides a convenience function for init() functions to register additional verifiers or replace existing ones.
func Sign ¶
Sign takes a data.Signed and a key, calculated and adds the signature to the data.Signed
func VerifyRoot ¶
VerifyRoot checks if a given root file is valid against a known set of keys. Threshold is always assumed to be 1
Types ¶
type CryptoService ¶
type CryptoService interface { KeyService }
CryptoService is deprecated and all instances of its use should be replaced with KeyService
type ECDSAVerifier ¶
type ECDSAVerifier struct{}
ECDSAVerifier checks ECDSA signatures, decoding the keyType appropriately
type Ed25519 ¶
type Ed25519 struct {
// contains filtered or unexported fields
}
Ed25519 implements a simple in memory cryptosystem for ED25519 keys
func NewEd25519 ¶
func NewEd25519() *Ed25519
NewEd25519 initializes a new empty Ed25519 CryptoService that operates entirely in memory
func (*Ed25519) GetPrivateKey ¶
GetPrivateKey returns a single private key and role if present, based on the ID
func (*Ed25519) ImportRootKey ¶
ImportRootKey adds an Ed25519 key to the store as a root key
func (*Ed25519) ListAllKeys ¶
ListAllKeys returns the map of keys IDs to role
func (*Ed25519) PublicKeys ¶
PublicKeys returns a map of public keys for the ids provided, when those IDs are found in the store.
type Ed25519Verifier ¶
type Ed25519Verifier struct{}
Ed25519Verifier used to verify Ed25519 signatures
type ErrExpired ¶
ErrExpired indicates a piece of metadata has expired
func (ErrExpired) Error ¶
func (e ErrExpired) Error() string
type ErrInsufficientSignatures ¶
type ErrInsufficientSignatures struct {
Name string
}
ErrInsufficientSignatures - do not have enough signatures on a piece of metadata
func (ErrInsufficientSignatures) Error ¶
func (e ErrInsufficientSignatures) Error() string
type ErrInvalidKeyLength ¶
type ErrInvalidKeyLength struct {
// contains filtered or unexported fields
}
ErrInvalidKeyLength indicates that while we may support the cipher, the provided key length is not specifically supported, i.e. we support RSA, but not 1024 bit keys
func (ErrInvalidKeyLength) Error ¶
func (e ErrInvalidKeyLength) Error() string
type ErrInvalidKeyType ¶
type ErrInvalidKeyType struct{}
ErrInvalidKeyType indicates the types for the key and signature it's associated with are mismatched. Probably a sign of malicious behaviour
func (ErrInvalidKeyType) Error ¶
func (e ErrInvalidKeyType) Error() string
type ErrLowVersion ¶
ErrLowVersion indicates the piece of metadata has a version number lower than a version number we're already seen for this role
func (ErrLowVersion) Error ¶
func (e ErrLowVersion) Error() string
type ErrNoKeys ¶
type ErrNoKeys struct {
KeyIDs []string
}
ErrNoKeys indicates no signing keys were found when trying to sign
type ErrRoleThreshold ¶
type ErrRoleThreshold struct{}
ErrRoleThreshold indicates we did not validate enough signatures to meet the threshold
func (ErrRoleThreshold) Error ¶
func (e ErrRoleThreshold) Error() string
type KeyService ¶
type KeyService interface { // Create issues a new key pair and is responsible for loading // the private key into the appropriate signing service. // The role isn't currently used for anything, but it's here to support // future features Create(role, algorithm string) (data.PublicKey, error) // GetKey retrieves the public key if present, otherwise it returns nil GetKey(keyID string) data.PublicKey // GetPrivateKey retrieves the private key and role if present, otherwise // it returns nil GetPrivateKey(keyID string) (data.PrivateKey, string, error) // RemoveKey deletes the specified key RemoveKey(keyID string) error // ListKeys returns a list of key IDs for the role ListKeys(role string) []string // ListAllKeys returns a map of all available signing key IDs to role ListAllKeys() map[string]string // ImportRootKey imports a root key to the highest priority keystore associated with // the cryptoservice ImportRootKey(source io.Reader) error }
KeyService provides management of keys locally. It will never accept or provide private keys. Communication between the KeyService and a SigningService happen behind the Create function.
type RSAPKCS1v15Verifier ¶
type RSAPKCS1v15Verifier struct{}
RSAPKCS1v15Verifier checks RSA PKCS1v15 signatures
type RSAPyCryptoVerifier ¶
type RSAPyCryptoVerifier struct{}
RSAPyCryptoVerifier checks RSASSA-PSS signatures