errors.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. package verify
  2. import (
  3. "errors"
  4. "fmt"
  5. "time"
  6. )
  7. var (
  8. ErrMissingKey = errors.New("tuf: missing key")
  9. ErrNoSignatures = errors.New("tuf: data has no signatures")
  10. ErrInvalid = errors.New("tuf: signature verification failed")
  11. ErrWrongMethod = errors.New("tuf: invalid signature type")
  12. ErrWrongMetaType = errors.New("tuf: meta file has wrong type")
  13. ErrExists = errors.New("tuf: key already in db")
  14. ErrInvalidKey = errors.New("tuf: invalid key")
  15. ErrInvalidRole = errors.New("tuf: invalid role")
  16. ErrInvalidDelegatedRole = errors.New("tuf: invalid delegated role")
  17. ErrInvalidKeyID = errors.New("tuf: invalid key id")
  18. ErrInvalidThreshold = errors.New("tuf: invalid role threshold")
  19. ErrMissingTargetFile = errors.New("tuf: missing previously listed targets metadata file")
  20. )
  21. type ErrWrongID struct{}
  22. func (ErrWrongID) Error() string {
  23. return "tuf: key id mismatch"
  24. }
  25. type ErrUnknownRole struct {
  26. Role string
  27. }
  28. func (e ErrUnknownRole) Error() string {
  29. return fmt.Sprintf("tuf: unknown role %q", e.Role)
  30. }
  31. type ErrExpired struct {
  32. Expired time.Time
  33. }
  34. func (e ErrExpired) Error() string {
  35. return fmt.Sprintf("expired at %s", e.Expired)
  36. }
  37. type ErrLowVersion struct {
  38. Actual int64
  39. Current int64
  40. }
  41. func (e ErrLowVersion) Error() string {
  42. return fmt.Sprintf("version %d is lower than current version %d", e.Actual, e.Current)
  43. }
  44. type ErrWrongVersion struct {
  45. Given int64
  46. Expected int64
  47. }
  48. func (e ErrWrongVersion) Error() string {
  49. return fmt.Sprintf("version %d does not match the expected version %d", e.Given, e.Expected)
  50. }
  51. type ErrRoleThreshold struct {
  52. Expected int
  53. Actual int
  54. }
  55. func (e ErrRoleThreshold) Error() string {
  56. return "tuf: valid signatures did not meet threshold"
  57. }