From 8699d1f56532dc7653abef53e4b72bf87b095280 Mon Sep 17 00:00:00 2001 From: Ethan Lowman Date: Fri, 10 Dec 2021 17:33:49 -0500 Subject: [PATCH] [Delegations prereq] Support delegated targets in DefaultExpires and fix GenKey expiration Splitting up https://github.com/theupdateframework/go-tuf/pull/175 --- data/types.go | 5 +++-- repo.go | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/types.go b/data/types.go index 125590c1..db60c16f 100644 --- a/data/types.go +++ b/data/types.go @@ -82,12 +82,13 @@ func DefaultExpires(role string) time.Time { switch role { case "root": t = time.Now().AddDate(1, 0, 0) - case "targets": - t = time.Now().AddDate(0, 3, 0) case "snapshot": t = time.Now().AddDate(0, 0, 7) case "timestamp": t = time.Now().AddDate(0, 0, 1) + default: + // targets and delegated targets + t = time.Now().AddDate(0, 3, 0) } return t.UTC().Round(time.Second) } diff --git a/repo.go b/repo.go index 3f29b3ac..aef90da4 100644 --- a/repo.go +++ b/repo.go @@ -332,7 +332,7 @@ func (r *Repo) ChangePassphrase(keyRole string) error { } func (r *Repo) GenKey(role string) ([]string, error) { - return r.GenKeyWithExpires(role, data.DefaultExpires("root")) + return r.GenKeyWithExpires(role, data.DefaultExpires(role)) } func (r *Repo) GenKeyWithExpires(keyRole string, expires time.Time) (keyids []string, err error) {