repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
partition
stringclasses
1 value
theupdateframework/notary
tuf/tuf.go
InitTargets
func (tr *Repo) InitTargets(role data.RoleName) (*data.SignedTargets, error) { if !data.IsDelegation(role) && role != data.CanonicalTargetsRole { return nil, data.ErrInvalidRole{ Role: role, Reason: fmt.Sprintf("role is not a valid targets role name: %s", role.String()), } } targets := data.NewTargets() ...
go
func (tr *Repo) InitTargets(role data.RoleName) (*data.SignedTargets, error) { if !data.IsDelegation(role) && role != data.CanonicalTargetsRole { return nil, data.ErrInvalidRole{ Role: role, Reason: fmt.Sprintf("role is not a valid targets role name: %s", role.String()), } } targets := data.NewTargets() ...
[ "func", "(", "tr", "*", "Repo", ")", "InitTargets", "(", "role", "data", ".", "RoleName", ")", "(", "*", "data", ".", "SignedTargets", ",", "error", ")", "{", "if", "!", "data", ".", "IsDelegation", "(", "role", ")", "&&", "role", "!=", "data", "."...
// InitTargets initializes an empty targets, and returns the new empty target
[ "InitTargets", "initializes", "an", "empty", "targets", "and", "returns", "the", "new", "empty", "target" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L578-L588
train
theupdateframework/notary
tuf/tuf.go
InitSnapshot
func (tr *Repo) InitSnapshot() error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } root, err := tr.Root.ToSigned() if err != nil { return err } if _, ok := tr.Targets[data.CanonicalTargetsRole]; !ok { return ErrNotLoaded{Role: data.CanonicalTargetsRole} } targets, err := tr.Ta...
go
func (tr *Repo) InitSnapshot() error { if tr.Root == nil { return ErrNotLoaded{Role: data.CanonicalRootRole} } root, err := tr.Root.ToSigned() if err != nil { return err } if _, ok := tr.Targets[data.CanonicalTargetsRole]; !ok { return ErrNotLoaded{Role: data.CanonicalTargetsRole} } targets, err := tr.Ta...
[ "func", "(", "tr", "*", "Repo", ")", "InitSnapshot", "(", ")", "error", "{", "if", "tr", ".", "Root", "==", "nil", "{", "return", "ErrNotLoaded", "{", "Role", ":", "data", ".", "CanonicalRootRole", "}", "\n", "}", "\n", "root", ",", "err", ":=", "t...
// InitSnapshot initializes a snapshot based on the current root and targets
[ "InitSnapshot", "initializes", "a", "snapshot", "based", "on", "the", "current", "root", "and", "targets" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L591-L613
train
theupdateframework/notary
tuf/tuf.go
InitTimestamp
func (tr *Repo) InitTimestamp() error { snap, err := tr.Snapshot.ToSigned() if err != nil { return err } timestamp, err := data.NewTimestamp(snap) if err != nil { return err } tr.Timestamp = timestamp return nil }
go
func (tr *Repo) InitTimestamp() error { snap, err := tr.Snapshot.ToSigned() if err != nil { return err } timestamp, err := data.NewTimestamp(snap) if err != nil { return err } tr.Timestamp = timestamp return nil }
[ "func", "(", "tr", "*", "Repo", ")", "InitTimestamp", "(", ")", "error", "{", "snap", ",", "err", ":=", "tr", ".", "Snapshot", ".", "ToSigned", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "timestamp", ",", "er...
// InitTimestamp initializes a timestamp based on the current snapshot
[ "InitTimestamp", "initializes", "a", "timestamp", "based", "on", "the", "current", "snapshot" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L616-L628
train
theupdateframework/notary
tuf/tuf.go
TargetMeta
func (tr Repo) TargetMeta(role data.RoleName, path string) *data.FileMeta { if t, ok := tr.Targets[role]; ok { if m, ok := t.Signed.Targets[path]; ok { return &m } } return nil }
go
func (tr Repo) TargetMeta(role data.RoleName, path string) *data.FileMeta { if t, ok := tr.Targets[role]; ok { if m, ok := t.Signed.Targets[path]; ok { return &m } } return nil }
[ "func", "(", "tr", "Repo", ")", "TargetMeta", "(", "role", "data", ".", "RoleName", ",", "path", "string", ")", "*", "data", ".", "FileMeta", "{", "if", "t", ",", "ok", ":=", "tr", ".", "Targets", "[", "role", "]", ";", "ok", "{", "if", "m", ",...
// TargetMeta returns the FileMeta entry for the given path in the // targets file associated with the given role. This may be nil if // the target isn't found in the targets file.
[ "TargetMeta", "returns", "the", "FileMeta", "entry", "for", "the", "given", "path", "in", "the", "targets", "file", "associated", "with", "the", "given", "role", ".", "This", "may", "be", "nil", "if", "the", "target", "isn", "t", "found", "in", "the", "t...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L633-L640
train
theupdateframework/notary
tuf/tuf.go
TargetDelegations
func (tr Repo) TargetDelegations(role data.RoleName, path string) []*data.Role { var roles []*data.Role if t, ok := tr.Targets[role]; ok { for _, r := range t.Signed.Delegations.Roles { if r.CheckPaths(path) { roles = append(roles, r) } } } return roles }
go
func (tr Repo) TargetDelegations(role data.RoleName, path string) []*data.Role { var roles []*data.Role if t, ok := tr.Targets[role]; ok { for _, r := range t.Signed.Delegations.Roles { if r.CheckPaths(path) { roles = append(roles, r) } } } return roles }
[ "func", "(", "tr", "Repo", ")", "TargetDelegations", "(", "role", "data", ".", "RoleName", ",", "path", "string", ")", "[", "]", "*", "data", ".", "Role", "{", "var", "roles", "[", "]", "*", "data", ".", "Role", "\n", "if", "t", ",", "ok", ":=", ...
// TargetDelegations returns a slice of Roles that are valid publishers // for the target path provided.
[ "TargetDelegations", "returns", "a", "slice", "of", "Roles", "that", "are", "valid", "publishers", "for", "the", "target", "path", "provided", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L644-L654
train
theupdateframework/notary
tuf/tuf.go
VerifyCanSign
func (tr *Repo) VerifyCanSign(roleName data.RoleName) error { var ( role data.BaseRole err error canonicalKeyIDs []string ) // we only need the BaseRole part of a delegation because we're just // checking KeyIDs if data.IsDelegation(roleName) { r, err := tr.GetDelegationRole(roleName...
go
func (tr *Repo) VerifyCanSign(roleName data.RoleName) error { var ( role data.BaseRole err error canonicalKeyIDs []string ) // we only need the BaseRole part of a delegation because we're just // checking KeyIDs if data.IsDelegation(roleName) { r, err := tr.GetDelegationRole(roleName...
[ "func", "(", "tr", "*", "Repo", ")", "VerifyCanSign", "(", "roleName", "data", ".", "RoleName", ")", "error", "{", "var", "(", "role", "data", ".", "BaseRole", "\n", "err", "error", "\n", "canonicalKeyIDs", "[", "]", "string", "\n", ")", "\n", "// we o...
// VerifyCanSign returns nil if the role exists and we have at least one // signing key for the role, false otherwise. This does not check that we have // enough signing keys to meet the threshold, since we want to support the use // case of multiple signers for a role. It returns an error if the role doesn't // exis...
[ "VerifyCanSign", "returns", "nil", "if", "the", "role", "exists", "and", "we", "have", "at", "least", "one", "signing", "key", "for", "the", "role", "false", "otherwise", ".", "This", "does", "not", "check", "that", "we", "have", "enough", "signing", "keys...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L661-L696
train
theupdateframework/notary
tuf/tuf.go
isValidPath
func isValidPath(candidatePath string, delgRole data.DelegationRole) bool { return candidatePath == "" || delgRole.CheckPaths(candidatePath) }
go
func isValidPath(candidatePath string, delgRole data.DelegationRole) bool { return candidatePath == "" || delgRole.CheckPaths(candidatePath) }
[ "func", "isValidPath", "(", "candidatePath", "string", ",", "delgRole", "data", ".", "DelegationRole", ")", "bool", "{", "return", "candidatePath", "==", "\"", "\"", "||", "delgRole", ".", "CheckPaths", "(", "candidatePath", ")", "\n", "}" ]
// helper function that returns whether the delegation Role is valid against the given path // Will return true if given an empty candidatePath
[ "helper", "function", "that", "returns", "whether", "the", "delegation", "Role", "is", "valid", "against", "the", "given", "path", "Will", "return", "true", "if", "given", "an", "empty", "candidatePath" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L771-L773
train
theupdateframework/notary
tuf/tuf.go
AddTargets
func (tr *Repo) AddTargets(role data.RoleName, targets data.Files) (data.Files, error) { cantSignErr := tr.VerifyCanSign(role) if _, ok := cantSignErr.(data.ErrInvalidRole); ok { return nil, cantSignErr } var needSign bool // check existence of the role's metadata _, ok := tr.Targets[role] if !ok { // the tar...
go
func (tr *Repo) AddTargets(role data.RoleName, targets data.Files) (data.Files, error) { cantSignErr := tr.VerifyCanSign(role) if _, ok := cantSignErr.(data.ErrInvalidRole); ok { return nil, cantSignErr } var needSign bool // check existence of the role's metadata _, ok := tr.Targets[role] if !ok { // the tar...
[ "func", "(", "tr", "*", "Repo", ")", "AddTargets", "(", "role", "data", ".", "RoleName", ",", "targets", "data", ".", "Files", ")", "(", "data", ".", "Files", ",", "error", ")", "{", "cantSignErr", ":=", "tr", ".", "VerifyCanSign", "(", "role", ")", ...
// AddTargets will attempt to add the given targets specifically to // the directed role. If the metadata for the role doesn't exist yet, // AddTargets will create one.
[ "AddTargets", "will", "attempt", "to", "add", "the", "given", "targets", "specifically", "to", "the", "directed", "role", ".", "If", "the", "metadata", "for", "the", "role", "doesn", "t", "exist", "yet", "AddTargets", "will", "create", "one", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L778-L826
train
theupdateframework/notary
tuf/tuf.go
UpdateSnapshot
func (tr *Repo) UpdateSnapshot(role data.RoleName, s *data.Signed) error { jsonData, err := json.Marshal(s) if err != nil { return err } meta, err := data.NewFileMeta(bytes.NewReader(jsonData), data.NotaryDefaultHashes...) if err != nil { return err } tr.Snapshot.Signed.Meta[role.String()] = meta tr.Snapsho...
go
func (tr *Repo) UpdateSnapshot(role data.RoleName, s *data.Signed) error { jsonData, err := json.Marshal(s) if err != nil { return err } meta, err := data.NewFileMeta(bytes.NewReader(jsonData), data.NotaryDefaultHashes...) if err != nil { return err } tr.Snapshot.Signed.Meta[role.String()] = meta tr.Snapsho...
[ "func", "(", "tr", "*", "Repo", ")", "UpdateSnapshot", "(", "role", "data", ".", "RoleName", ",", "s", "*", "data", ".", "Signed", ")", "error", "{", "jsonData", ",", "err", ":=", "json", ".", "Marshal", "(", "s", ")", "\n", "if", "err", "!=", "n...
// UpdateSnapshot updates the FileMeta for the given role based on the Signed object
[ "UpdateSnapshot", "updates", "the", "FileMeta", "for", "the", "given", "role", "based", "on", "the", "Signed", "object" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L863-L875
train
theupdateframework/notary
tuf/tuf.go
UpdateTimestamp
func (tr *Repo) UpdateTimestamp(s *data.Signed) error { jsonData, err := json.Marshal(s) if err != nil { return err } meta, err := data.NewFileMeta(bytes.NewReader(jsonData), data.NotaryDefaultHashes...) if err != nil { return err } tr.Timestamp.Signed.Meta[data.CanonicalSnapshotRole.String()] = meta tr.Tim...
go
func (tr *Repo) UpdateTimestamp(s *data.Signed) error { jsonData, err := json.Marshal(s) if err != nil { return err } meta, err := data.NewFileMeta(bytes.NewReader(jsonData), data.NotaryDefaultHashes...) if err != nil { return err } tr.Timestamp.Signed.Meta[data.CanonicalSnapshotRole.String()] = meta tr.Tim...
[ "func", "(", "tr", "*", "Repo", ")", "UpdateTimestamp", "(", "s", "*", "data", ".", "Signed", ")", "error", "{", "jsonData", ",", "err", ":=", "json", ".", "Marshal", "(", "s", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}",...
// UpdateTimestamp updates the snapshot meta in the timestamp based on the Signed object
[ "UpdateTimestamp", "updates", "the", "snapshot", "meta", "in", "the", "timestamp", "based", "on", "the", "Signed", "object" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L878-L890
train
theupdateframework/notary
tuf/tuf.go
SignTargets
func (tr *Repo) SignTargets(role data.RoleName, expires time.Time) (*data.Signed, error) { logrus.Debugf("sign targets called for role %s", role) if _, ok := tr.Targets[role]; !ok { return nil, data.ErrInvalidRole{ Role: role, Reason: "SignTargets called with non-existent targets role", } } tr.Targets[r...
go
func (tr *Repo) SignTargets(role data.RoleName, expires time.Time) (*data.Signed, error) { logrus.Debugf("sign targets called for role %s", role) if _, ok := tr.Targets[role]; !ok { return nil, data.ErrInvalidRole{ Role: role, Reason: "SignTargets called with non-existent targets role", } } tr.Targets[r...
[ "func", "(", "tr", "*", "Repo", ")", "SignTargets", "(", "role", "data", ".", "RoleName", ",", "expires", "time", ".", "Time", ")", "(", "*", "data", ".", "Signed", ",", "error", ")", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ",", "role", ")...
// SignTargets signs the targets file for the given top level or delegated targets role
[ "SignTargets", "signs", "the", "targets", "file", "for", "the", "given", "top", "level", "or", "delegated", "targets", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L949-L986
train
theupdateframework/notary
tuf/tuf.go
SignSnapshot
func (tr *Repo) SignSnapshot(expires time.Time) (*data.Signed, error) { logrus.Debug("signing snapshot...") signedRoot, err := tr.Root.ToSigned() if err != nil { return nil, err } err = tr.UpdateSnapshot(data.CanonicalRootRole, signedRoot) if err != nil { return nil, err } tr.Root.Dirty = false // root dirt...
go
func (tr *Repo) SignSnapshot(expires time.Time) (*data.Signed, error) { logrus.Debug("signing snapshot...") signedRoot, err := tr.Root.ToSigned() if err != nil { return nil, err } err = tr.UpdateSnapshot(data.CanonicalRootRole, signedRoot) if err != nil { return nil, err } tr.Root.Dirty = false // root dirt...
[ "func", "(", "tr", "*", "Repo", ")", "SignSnapshot", "(", "expires", "time", ".", "Time", ")", "(", "*", "data", ".", "Signed", ",", "error", ")", "{", "logrus", ".", "Debug", "(", "\"", "\"", ")", "\n", "signedRoot", ",", "err", ":=", "tr", ".",...
// SignSnapshot updates the snapshot based on the current targets and root then signs it
[ "SignSnapshot", "updates", "the", "snapshot", "based", "on", "the", "current", "targets", "and", "root", "then", "signs", "it" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L989-L1027
train
theupdateframework/notary
tuf/tuf.go
SignTimestamp
func (tr *Repo) SignTimestamp(expires time.Time) (*data.Signed, error) { logrus.Debug("SignTimestamp") signedSnapshot, err := tr.Snapshot.ToSigned() if err != nil { return nil, err } err = tr.UpdateTimestamp(signedSnapshot) if err != nil { return nil, err } tr.Timestamp.Signed.Expires = expires tr.Timestam...
go
func (tr *Repo) SignTimestamp(expires time.Time) (*data.Signed, error) { logrus.Debug("SignTimestamp") signedSnapshot, err := tr.Snapshot.ToSigned() if err != nil { return nil, err } err = tr.UpdateTimestamp(signedSnapshot) if err != nil { return nil, err } tr.Timestamp.Signed.Expires = expires tr.Timestam...
[ "func", "(", "tr", "*", "Repo", ")", "SignTimestamp", "(", "expires", "time", ".", "Time", ")", "(", "*", "data", ".", "Signed", ",", "error", ")", "{", "logrus", ".", "Debug", "(", "\"", "\"", ")", "\n", "signedSnapshot", ",", "err", ":=", "tr", ...
// SignTimestamp updates the timestamp based on the current snapshot then signs it
[ "SignTimestamp", "updates", "the", "timestamp", "based", "on", "the", "current", "snapshot", "then", "signs", "it" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/tuf.go#L1030-L1057
train
theupdateframework/notary
tuf/data/targets.go
isValidTargetsStructure
func isValidTargetsStructure(t Targets, roleName RoleName) error { if roleName != CanonicalTargetsRole && !IsDelegation(roleName) { return ErrInvalidRole{Role: roleName} } // even if it's a delegated role, the metadata type is "Targets" expectedType := TUFTypes[CanonicalTargetsRole] if t.Type != expectedType { ...
go
func isValidTargetsStructure(t Targets, roleName RoleName) error { if roleName != CanonicalTargetsRole && !IsDelegation(roleName) { return ErrInvalidRole{Role: roleName} } // even if it's a delegated role, the metadata type is "Targets" expectedType := TUFTypes[CanonicalTargetsRole] if t.Type != expectedType { ...
[ "func", "isValidTargetsStructure", "(", "t", "Targets", ",", "roleName", "RoleName", ")", "error", "{", "if", "roleName", "!=", "CanonicalTargetsRole", "&&", "!", "IsDelegation", "(", "roleName", ")", "{", "return", "ErrInvalidRole", "{", "Role", ":", "roleName"...
// isValidTargetsStructure returns an error, or nil, depending on whether the content of the struct // is valid for targets metadata. This does not check signatures or expiry, just that // the metadata content is valid.
[ "isValidTargetsStructure", "returns", "an", "error", "or", "nil", "depending", "on", "whether", "the", "content", "of", "the", "struct", "is", "valid", "for", "targets", "metadata", ".", "This", "does", "not", "check", "signatures", "or", "expiry", "just", "th...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L29-L55
train
theupdateframework/notary
tuf/data/targets.go
NewTargets
func NewTargets() *SignedTargets { return &SignedTargets{ Signatures: make([]Signature, 0), Signed: Targets{ SignedCommon: SignedCommon{ Type: TUFTypes["targets"], Version: 0, Expires: DefaultExpires("targets"), }, Targets: make(Files), Delegations: *NewDelegations(), }, Dirty: t...
go
func NewTargets() *SignedTargets { return &SignedTargets{ Signatures: make([]Signature, 0), Signed: Targets{ SignedCommon: SignedCommon{ Type: TUFTypes["targets"], Version: 0, Expires: DefaultExpires("targets"), }, Targets: make(Files), Delegations: *NewDelegations(), }, Dirty: t...
[ "func", "NewTargets", "(", ")", "*", "SignedTargets", "{", "return", "&", "SignedTargets", "{", "Signatures", ":", "make", "(", "[", "]", "Signature", ",", "0", ")", ",", "Signed", ":", "Targets", "{", "SignedCommon", ":", "SignedCommon", "{", "Type", ":...
// NewTargets initializes a new empty SignedTargets object
[ "NewTargets", "initializes", "a", "new", "empty", "SignedTargets", "object" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L58-L72
train
theupdateframework/notary
tuf/data/targets.go
GetMeta
func (t SignedTargets) GetMeta(path string) *FileMeta { for p, meta := range t.Signed.Targets { if p == path { return &meta } } return nil }
go
func (t SignedTargets) GetMeta(path string) *FileMeta { for p, meta := range t.Signed.Targets { if p == path { return &meta } } return nil }
[ "func", "(", "t", "SignedTargets", ")", "GetMeta", "(", "path", "string", ")", "*", "FileMeta", "{", "for", "p", ",", "meta", ":=", "range", "t", ".", "Signed", ".", "Targets", "{", "if", "p", "==", "path", "{", "return", "&", "meta", "\n", "}", ...
// GetMeta attempts to find the targets entry for the path. It // will return nil in the case of the target not being found.
[ "GetMeta", "attempts", "to", "find", "the", "targets", "entry", "for", "the", "path", ".", "It", "will", "return", "nil", "in", "the", "case", "of", "the", "target", "not", "being", "found", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L76-L83
train
theupdateframework/notary
tuf/data/targets.go
GetValidDelegations
func (t SignedTargets) GetValidDelegations(parent DelegationRole) []DelegationRole { roles := t.buildDelegationRoles() result := []DelegationRole{} for _, r := range roles { validRole, err := parent.Restrict(r) if err != nil { continue } result = append(result, validRole) } return result }
go
func (t SignedTargets) GetValidDelegations(parent DelegationRole) []DelegationRole { roles := t.buildDelegationRoles() result := []DelegationRole{} for _, r := range roles { validRole, err := parent.Restrict(r) if err != nil { continue } result = append(result, validRole) } return result }
[ "func", "(", "t", "SignedTargets", ")", "GetValidDelegations", "(", "parent", "DelegationRole", ")", "[", "]", "DelegationRole", "{", "roles", ":=", "t", ".", "buildDelegationRoles", "(", ")", "\n", "result", ":=", "[", "]", "DelegationRole", "{", "}", "\n",...
// GetValidDelegations filters the delegation roles specified in the signed targets, and // only returns roles that are direct children and restricts their paths
[ "GetValidDelegations", "filters", "the", "delegation", "roles", "specified", "in", "the", "signed", "targets", "and", "only", "returns", "roles", "that", "are", "direct", "children", "and", "restricts", "their", "paths" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L87-L98
train
theupdateframework/notary
tuf/data/targets.go
BuildDelegationRole
func (t *SignedTargets) BuildDelegationRole(roleName RoleName) (DelegationRole, error) { for _, role := range t.Signed.Delegations.Roles { if role.Name == roleName { pubKeys := make(map[string]PublicKey) for _, keyID := range role.KeyIDs { pubKey, ok := t.Signed.Delegations.Keys[keyID] if !ok { //...
go
func (t *SignedTargets) BuildDelegationRole(roleName RoleName) (DelegationRole, error) { for _, role := range t.Signed.Delegations.Roles { if role.Name == roleName { pubKeys := make(map[string]PublicKey) for _, keyID := range role.KeyIDs { pubKey, ok := t.Signed.Delegations.Keys[keyID] if !ok { //...
[ "func", "(", "t", "*", "SignedTargets", ")", "BuildDelegationRole", "(", "roleName", "RoleName", ")", "(", "DelegationRole", ",", "error", ")", "{", "for", "_", ",", "role", ":=", "range", "t", ".", "Signed", ".", "Delegations", ".", "Roles", "{", "if", ...
// BuildDelegationRole returns a copy of a DelegationRole using the information in this SignedTargets for the specified role name. // Will error for invalid role name or key metadata within this SignedTargets. Path data is not validated.
[ "BuildDelegationRole", "returns", "a", "copy", "of", "a", "DelegationRole", "using", "the", "information", "in", "this", "SignedTargets", "for", "the", "specified", "role", "name", ".", "Will", "error", "for", "invalid", "role", "name", "or", "key", "metadata", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L102-L128
train
theupdateframework/notary
tuf/data/targets.go
buildDelegationRoles
func (t SignedTargets) buildDelegationRoles() []DelegationRole { var roles []DelegationRole for _, roleData := range t.Signed.Delegations.Roles { delgRole, err := t.BuildDelegationRole(roleData.Name) if err != nil { continue } roles = append(roles, delgRole) } return roles }
go
func (t SignedTargets) buildDelegationRoles() []DelegationRole { var roles []DelegationRole for _, roleData := range t.Signed.Delegations.Roles { delgRole, err := t.BuildDelegationRole(roleData.Name) if err != nil { continue } roles = append(roles, delgRole) } return roles }
[ "func", "(", "t", "SignedTargets", ")", "buildDelegationRoles", "(", ")", "[", "]", "DelegationRole", "{", "var", "roles", "[", "]", "DelegationRole", "\n", "for", "_", ",", "roleData", ":=", "range", "t", ".", "Signed", ".", "Delegations", ".", "Roles", ...
// helper function to create DelegationRole structures from all delegations in a SignedTargets, // these delegations are read directly from the SignedTargets and not modified or validated
[ "helper", "function", "to", "create", "DelegationRole", "structures", "from", "all", "delegations", "in", "a", "SignedTargets", "these", "delegations", "are", "read", "directly", "from", "the", "SignedTargets", "and", "not", "modified", "or", "validated" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L132-L142
train
theupdateframework/notary
tuf/data/targets.go
AddTarget
func (t *SignedTargets) AddTarget(path string, meta FileMeta) { t.Signed.Targets[path] = meta t.Dirty = true }
go
func (t *SignedTargets) AddTarget(path string, meta FileMeta) { t.Signed.Targets[path] = meta t.Dirty = true }
[ "func", "(", "t", "*", "SignedTargets", ")", "AddTarget", "(", "path", "string", ",", "meta", "FileMeta", ")", "{", "t", ".", "Signed", ".", "Targets", "[", "path", "]", "=", "meta", "\n", "t", ".", "Dirty", "=", "true", "\n", "}" ]
// AddTarget adds or updates the meta for the given path
[ "AddTarget", "adds", "or", "updates", "the", "meta", "for", "the", "given", "path" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L145-L148
train
theupdateframework/notary
tuf/data/targets.go
AddDelegation
func (t *SignedTargets) AddDelegation(role *Role, keys []*PublicKey) error { return errors.New("Not Implemented") }
go
func (t *SignedTargets) AddDelegation(role *Role, keys []*PublicKey) error { return errors.New("Not Implemented") }
[ "func", "(", "t", "*", "SignedTargets", ")", "AddDelegation", "(", "role", "*", "Role", ",", "keys", "[", "]", "*", "PublicKey", ")", "error", "{", "return", "errors", ".", "New", "(", "\"", "\"", ")", "\n", "}" ]
// AddDelegation will add a new delegated role with the given keys, // ensuring the keys either already exist, or are added to the map // of delegation keys
[ "AddDelegation", "will", "add", "a", "new", "delegated", "role", "with", "the", "given", "keys", "ensuring", "the", "keys", "either", "already", "exist", "or", "are", "added", "to", "the", "map", "of", "delegation", "keys" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L153-L155
train
theupdateframework/notary
tuf/data/targets.go
MarshalJSON
func (t *SignedTargets) MarshalJSON() ([]byte, error) { signed, err := t.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
go
func (t *SignedTargets) MarshalJSON() ([]byte, error) { signed, err := t.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
[ "func", "(", "t", "*", "SignedTargets", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "signed", ",", "err", ":=", "t", ".", "ToSigned", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err", "...
// MarshalJSON returns the serialized form of SignedTargets as bytes
[ "MarshalJSON", "returns", "the", "serialized", "form", "of", "SignedTargets", "as", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/targets.go#L177-L183
train
theupdateframework/notary
tuf/builder.go
ChecksumKnown
func (c ConsistentInfo) ChecksumKnown() bool { // empty hash, no size : this is the zero value return len(c.fileMeta.Hashes) > 0 || c.fileMeta.Length != 0 }
go
func (c ConsistentInfo) ChecksumKnown() bool { // empty hash, no size : this is the zero value return len(c.fileMeta.Hashes) > 0 || c.fileMeta.Length != 0 }
[ "func", "(", "c", "ConsistentInfo", ")", "ChecksumKnown", "(", ")", "bool", "{", "// empty hash, no size : this is the zero value", "return", "len", "(", "c", ".", "fileMeta", ".", "Hashes", ")", ">", "0", "||", "c", ".", "fileMeta", ".", "Length", "!=", "0"...
// ChecksumKnown determines whether or not we know enough to provide a size and // consistent name
[ "ChecksumKnown", "determines", "whether", "or", "not", "we", "know", "enough", "to", "provide", "a", "size", "and", "consistent", "name" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L37-L40
train
theupdateframework/notary
tuf/builder.go
NewRepoBuilder
func NewRepoBuilder(gun data.GUN, cs signed.CryptoService, trustpin trustpinning.TrustPinConfig) RepoBuilder { return NewBuilderFromRepo(gun, NewRepo(cs), trustpin) }
go
func NewRepoBuilder(gun data.GUN, cs signed.CryptoService, trustpin trustpinning.TrustPinConfig) RepoBuilder { return NewBuilderFromRepo(gun, NewRepo(cs), trustpin) }
[ "func", "NewRepoBuilder", "(", "gun", "data", ".", "GUN", ",", "cs", "signed", ".", "CryptoService", ",", "trustpin", "trustpinning", ".", "TrustPinConfig", ")", "RepoBuilder", "{", "return", "NewBuilderFromRepo", "(", "gun", ",", "NewRepo", "(", "cs", ")", ...
// NewRepoBuilder is the only way to get a pre-built RepoBuilder
[ "NewRepoBuilder", "is", "the", "only", "way", "to", "get", "a", "pre", "-", "built", "RepoBuilder" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L100-L102
train
theupdateframework/notary
tuf/builder.go
NewBuilderFromRepo
func NewBuilderFromRepo(gun data.GUN, repo *Repo, trustpin trustpinning.TrustPinConfig) RepoBuilder { return &repoBuilderWrapper{ RepoBuilder: &repoBuilder{ repo: repo, invalidRoles: NewRepo(nil), gun: gun, trustpin: trustpin, loadedNotChecksummed: ...
go
func NewBuilderFromRepo(gun data.GUN, repo *Repo, trustpin trustpinning.TrustPinConfig) RepoBuilder { return &repoBuilderWrapper{ RepoBuilder: &repoBuilder{ repo: repo, invalidRoles: NewRepo(nil), gun: gun, trustpin: trustpin, loadedNotChecksummed: ...
[ "func", "NewBuilderFromRepo", "(", "gun", "data", ".", "GUN", ",", "repo", "*", "Repo", ",", "trustpin", "trustpinning", ".", "TrustPinConfig", ")", "RepoBuilder", "{", "return", "&", "repoBuilderWrapper", "{", "RepoBuilder", ":", "&", "repoBuilder", "{", "rep...
// NewBuilderFromRepo allows us to bootstrap a builder given existing repo data. // YOU PROBABLY SHOULDN'T BE USING THIS OUTSIDE OF TESTING CODE!!!
[ "NewBuilderFromRepo", "allows", "us", "to", "bootstrap", "a", "builder", "given", "existing", "repo", "data", ".", "YOU", "PROBABLY", "SHOULDN", "T", "BE", "USING", "THIS", "OUTSIDE", "OF", "TESTING", "CODE!!!" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L106-L116
train
theupdateframework/notary
tuf/builder.go
IsLoaded
func (rb *repoBuilder) IsLoaded(roleName data.RoleName) bool { switch roleName { case data.CanonicalRootRole: return rb.repo.Root != nil case data.CanonicalSnapshotRole: return rb.repo.Snapshot != nil case data.CanonicalTimestampRole: return rb.repo.Timestamp != nil default: return rb.repo.Targets[roleName...
go
func (rb *repoBuilder) IsLoaded(roleName data.RoleName) bool { switch roleName { case data.CanonicalRootRole: return rb.repo.Root != nil case data.CanonicalSnapshotRole: return rb.repo.Snapshot != nil case data.CanonicalTimestampRole: return rb.repo.Timestamp != nil default: return rb.repo.Targets[roleName...
[ "func", "(", "rb", "*", "repoBuilder", ")", "IsLoaded", "(", "roleName", "data", ".", "RoleName", ")", "bool", "{", "switch", "roleName", "{", "case", "data", ".", "CanonicalRootRole", ":", "return", "rb", ".", "repo", ".", "Root", "!=", "nil", "\n", "...
// IsLoaded returns whether a particular role has already been loaded
[ "IsLoaded", "returns", "whether", "a", "particular", "role", "has", "already", "been", "loaded" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L187-L198
train
theupdateframework/notary
tuf/builder.go
LoadRootForUpdate
func (rb *repoBuilder) LoadRootForUpdate(content []byte, minVersion int, isFinal bool) error { if err := rb.loadOptions(data.CanonicalRootRole, content, minVersion, !isFinal, !isFinal, true); err != nil { return err } if !isFinal { rb.prevRoot = rb.repo.Root } return nil }
go
func (rb *repoBuilder) LoadRootForUpdate(content []byte, minVersion int, isFinal bool) error { if err := rb.loadOptions(data.CanonicalRootRole, content, minVersion, !isFinal, !isFinal, true); err != nil { return err } if !isFinal { rb.prevRoot = rb.repo.Root } return nil }
[ "func", "(", "rb", "*", "repoBuilder", ")", "LoadRootForUpdate", "(", "content", "[", "]", "byte", ",", "minVersion", "int", ",", "isFinal", "bool", ")", "error", "{", "if", "err", ":=", "rb", ".", "loadOptions", "(", "data", ".", "CanonicalRootRole", ",...
// LoadRootForUpdate adds additional flags for updating the root.json file
[ "LoadRootForUpdate", "adds", "additional", "flags", "for", "updating", "the", "root", ".", "json", "file" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L253-L261
train
theupdateframework/notary
tuf/builder.go
loadOptions
func (rb *repoBuilder) loadOptions(roleName data.RoleName, content []byte, minVersion int, allowExpired, skipChecksum, allowLoaded bool) error { if !data.ValidRole(roleName) { return ErrInvalidBuilderInput{msg: fmt.Sprintf("%s is an invalid role", roleName)} } if !allowLoaded && rb.IsLoaded(roleName) { return E...
go
func (rb *repoBuilder) loadOptions(roleName data.RoleName, content []byte, minVersion int, allowExpired, skipChecksum, allowLoaded bool) error { if !data.ValidRole(roleName) { return ErrInvalidBuilderInput{msg: fmt.Sprintf("%s is an invalid role", roleName)} } if !allowLoaded && rb.IsLoaded(roleName) { return E...
[ "func", "(", "rb", "*", "repoBuilder", ")", "loadOptions", "(", "roleName", "data", ".", "RoleName", ",", "content", "[", "]", "byte", ",", "minVersion", "int", ",", "allowExpired", ",", "skipChecksum", ",", "allowLoaded", "bool", ")", "error", "{", "if", ...
// loadOptions adds additional flags that should only be used for updating the root.json
[ "loadOptions", "adds", "additional", "flags", "that", "should", "only", "be", "used", "for", "updating", "the", "root", ".", "json" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L264-L298
train
theupdateframework/notary
tuf/builder.go
loadRoot
func (rb *repoBuilder) loadRoot(content []byte, minVersion int, allowExpired, skipChecksum bool) error { roleName := data.CanonicalRootRole signedObj, err := rb.bytesToSigned(content, data.CanonicalRootRole, skipChecksum) if err != nil { return err } // ValidateRoot validates against the previous root's role, a...
go
func (rb *repoBuilder) loadRoot(content []byte, minVersion int, allowExpired, skipChecksum bool) error { roleName := data.CanonicalRootRole signedObj, err := rb.bytesToSigned(content, data.CanonicalRootRole, skipChecksum) if err != nil { return err } // ValidateRoot validates against the previous root's role, a...
[ "func", "(", "rb", "*", "repoBuilder", ")", "loadRoot", "(", "content", "[", "]", "byte", ",", "minVersion", "int", ",", "allowExpired", ",", "skipChecksum", "bool", ")", "error", "{", "roleName", ":=", "data", ".", "CanonicalRootRole", "\n\n", "signedObj", ...
// loadRoot loads a root if one has not been loaded
[ "loadRoot", "loads", "a", "root", "if", "one", "has", "not", "been", "loaded" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/builder.go#L431-L464
train
theupdateframework/notary
server/storage/sql_models.go
CreateTUFTable
func CreateTUFTable(db gorm.DB) error { // TODO: gorm query := db.AutoMigrate(&TUFFile{}) if query.Error != nil { return query.Error } query = db.Model(&TUFFile{}).AddUniqueIndex( "idx_gun", "gun", "role", "version") return query.Error }
go
func CreateTUFTable(db gorm.DB) error { // TODO: gorm query := db.AutoMigrate(&TUFFile{}) if query.Error != nil { return query.Error } query = db.Model(&TUFFile{}).AddUniqueIndex( "idx_gun", "gun", "role", "version") return query.Error }
[ "func", "CreateTUFTable", "(", "db", "gorm", ".", "DB", ")", "error", "{", "// TODO: gorm", "query", ":=", "db", ".", "AutoMigrate", "(", "&", "TUFFile", "{", "}", ")", "\n", "if", "query", ".", "Error", "!=", "nil", "{", "return", "query", ".", "Err...
// CreateTUFTable creates the DB table for TUFFile
[ "CreateTUFTable", "creates", "the", "DB", "table", "for", "TUFFile" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sql_models.go#L51-L60
train
theupdateframework/notary
server/storage/sql_models.go
CreateChangefeedTable
func CreateChangefeedTable(db gorm.DB) error { query := db.AutoMigrate(&SQLChange{}) return query.Error }
go
func CreateChangefeedTable(db gorm.DB) error { query := db.AutoMigrate(&SQLChange{}) return query.Error }
[ "func", "CreateChangefeedTable", "(", "db", "gorm", ".", "DB", ")", "error", "{", "query", ":=", "db", ".", "AutoMigrate", "(", "&", "SQLChange", "{", "}", ")", "\n", "return", "query", ".", "Error", "\n", "}" ]
// CreateChangefeedTable creates the DB table for Changefeed
[ "CreateChangefeedTable", "creates", "the", "DB", "table", "for", "Changefeed" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/sql_models.go#L63-L66
train
theupdateframework/notary
server/server.go
Run
func Run(ctx context.Context, conf Config) error { tcpAddr, err := net.ResolveTCPAddr("tcp", conf.Addr) if err != nil { return err } var lsnr net.Listener lsnr, err = net.ListenTCP("tcp", tcpAddr) if err != nil { return err } if conf.TLSConfig != nil { logrus.Info("Enabling TLS") lsnr = tls.NewListener...
go
func Run(ctx context.Context, conf Config) error { tcpAddr, err := net.ResolveTCPAddr("tcp", conf.Addr) if err != nil { return err } var lsnr net.Listener lsnr, err = net.ListenTCP("tcp", tcpAddr) if err != nil { return err } if conf.TLSConfig != nil { logrus.Info("Enabling TLS") lsnr = tls.NewListener...
[ "func", "Run", "(", "ctx", "context", ".", "Context", ",", "conf", "Config", ")", "error", "{", "tcpAddr", ",", "err", ":=", "net", ".", "ResolveTCPAddr", "(", "\"", "\"", ",", "conf", ".", "Addr", ")", "\n", "if", "err", "!=", "nil", "{", "return"...
// Run sets up and starts a TLS server that can be cancelled using the // given configuration. The context it is passed is the context it should // use directly for the TLS server, and generate children off for requests
[ "Run", "sets", "up", "and", "starts", "a", "TLS", "server", "that", "can", "be", "cancelled", "using", "the", "given", "configuration", ".", "The", "context", "it", "is", "passed", "is", "the", "context", "it", "should", "use", "directly", "for", "the", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/server.go#L51-L92
train
theupdateframework/notary
server/server.go
filterImagePrefixes
func filterImagePrefixes(requiredPrefixes []string, err error, handler http.Handler) http.Handler { if len(requiredPrefixes) == 0 { return handler } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gun := mux.Vars(r)["gun"] if gun == "" { handler.ServeHTTP(w, r) return } for ...
go
func filterImagePrefixes(requiredPrefixes []string, err error, handler http.Handler) http.Handler { if len(requiredPrefixes) == 0 { return handler } return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { gun := mux.Vars(r)["gun"] if gun == "" { handler.ServeHTTP(w, r) return } for ...
[ "func", "filterImagePrefixes", "(", "requiredPrefixes", "[", "]", "string", ",", "err", "error", ",", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "if", "len", "(", "requiredPrefixes", ")", "==", "0", "{", "return", "handler", "\n",...
// assumes that required prefixes is not empty
[ "assumes", "that", "required", "prefixes", "is", "not", "empty" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/server.go#L95-L117
train
theupdateframework/notary
server/server.go
CreateHandler
func CreateHandler(operationName string, serverHandler utils.ContextHandler, errorIfGUNInvalid error, includeCacheHeaders bool, cacheControlConfig utils.CacheControlConfig, permissionsRequired []string, authWrapper utils.AuthWrapper, repoPrefixes []string) http.Handler { var wrapped http.Handler wrapped = authWrapper...
go
func CreateHandler(operationName string, serverHandler utils.ContextHandler, errorIfGUNInvalid error, includeCacheHeaders bool, cacheControlConfig utils.CacheControlConfig, permissionsRequired []string, authWrapper utils.AuthWrapper, repoPrefixes []string) http.Handler { var wrapped http.Handler wrapped = authWrapper...
[ "func", "CreateHandler", "(", "operationName", "string", ",", "serverHandler", "utils", ".", "ContextHandler", ",", "errorIfGUNInvalid", "error", ",", "includeCacheHeaders", "bool", ",", "cacheControlConfig", "utils", ".", "CacheControlConfig", ",", "permissionsRequired",...
// CreateHandler creates a server handler, wrapping with auth, caching, and monitoring
[ "CreateHandler", "creates", "a", "server", "handler", "wrapping", "with", "auth", "caching", "and", "monitoring" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/server.go#L120-L128
train
theupdateframework/notary
cmd/notary/keys.go
keyRemove
func (k *keyCommander) keyRemove(cmd *cobra.Command, args []string) error { if len(args) < 1 { cmd.Usage() return fmt.Errorf("must specify the key ID of the key to remove") } config, err := k.configGetter() if err != nil { return err } ks, err := k.getKeyStores(config, true, false) if err != nil { retur...
go
func (k *keyCommander) keyRemove(cmd *cobra.Command, args []string) error { if len(args) < 1 { cmd.Usage() return fmt.Errorf("must specify the key ID of the key to remove") } config, err := k.configGetter() if err != nil { return err } ks, err := k.getKeyStores(config, true, false) if err != nil { retur...
[ "func", "(", "k", "*", "keyCommander", ")", "keyRemove", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "<", "1", "{", "cmd", ".", "Usage", "(", ")", "\n", "return", ...
// keyRemove deletes a private key based on ID
[ "keyRemove", "deletes", "a", "private", "key", "based", "on", "ID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/keys.go#L415-L439
train
theupdateframework/notary
cmd/notary/keys.go
keyPassphraseChange
func (k *keyCommander) keyPassphraseChange(cmd *cobra.Command, args []string) error { if len(args) < 1 { cmd.Usage() return fmt.Errorf("must specify the key ID of the key to change the passphrase of") } config, err := k.configGetter() if err != nil { return err } ks, err := k.getKeyStores(config, true, fal...
go
func (k *keyCommander) keyPassphraseChange(cmd *cobra.Command, args []string) error { if len(args) < 1 { cmd.Usage() return fmt.Errorf("must specify the key ID of the key to change the passphrase of") } config, err := k.configGetter() if err != nil { return err } ks, err := k.getKeyStores(config, true, fal...
[ "func", "(", "k", "*", "keyCommander", ")", "keyPassphraseChange", "(", "cmd", "*", "cobra", ".", "Command", ",", "args", "[", "]", "string", ")", "error", "{", "if", "len", "(", "args", ")", "<", "1", "{", "cmd", ".", "Usage", "(", ")", "\n", "r...
// keyPassphraseChange changes the passphrase for a private key based on ID
[ "keyPassphraseChange", "changes", "the", "passphrase", "for", "a", "private", "key", "based", "on", "ID" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/keys.go#L442-L503
train
theupdateframework/notary
cmd/notary-signer/main.go
debugServer
func debugServer(addr string) { logrus.Infof("Debug server listening on %s", addr) if err := http.ListenAndServe(addr, nil); err != nil { logrus.Fatalf("error listening on debug interface: %v", err) } }
go
func debugServer(addr string) { logrus.Infof("Debug server listening on %s", addr) if err := http.ListenAndServe(addr, nil); err != nil { logrus.Fatalf("error listening on debug interface: %v", err) } }
[ "func", "debugServer", "(", "addr", "string", ")", "{", "logrus", ".", "Infof", "(", "\"", "\"", ",", "addr", ")", "\n", "if", "err", ":=", "http", ".", "ListenAndServe", "(", "addr", ",", "nil", ")", ";", "err", "!=", "nil", "{", "logrus", ".", ...
// debugServer starts the debug server with pprof, expvar among other // endpoints. The addr should not be exposed externally. For most of these to // work, tls cannot be enabled on the endpoint, so it is generally separate.
[ "debugServer", "starts", "the", "debug", "server", "with", "pprof", "expvar", "among", "other", "endpoints", ".", "The", "addr", "should", "not", "be", "exposed", "externally", ".", "For", "most", "of", "these", "to", "work", "tls", "cannot", "be", "enabled"...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary-signer/main.go#L93-L98
train
theupdateframework/notary
utils/http.go
RootHandlerFactory
func RootHandlerFactory(ctx context.Context, auth auth.AccessController, trust signed.CryptoService) func(ContextHandler, ...string) *rootHandler { return func(handler ContextHandler, actions ...string) *rootHandler { return &rootHandler{ handler: handler, auth: auth, actions: actions, context: ctx, ...
go
func RootHandlerFactory(ctx context.Context, auth auth.AccessController, trust signed.CryptoService) func(ContextHandler, ...string) *rootHandler { return func(handler ContextHandler, actions ...string) *rootHandler { return &rootHandler{ handler: handler, auth: auth, actions: actions, context: ctx, ...
[ "func", "RootHandlerFactory", "(", "ctx", "context", ".", "Context", ",", "auth", "auth", ".", "AccessController", ",", "trust", "signed", ".", "CryptoService", ")", "func", "(", "ContextHandler", ",", "...", "string", ")", "*", "rootHandler", "{", "return", ...
// RootHandlerFactory creates a new rootHandler factory using the given // Context creator and authorizer. The returned factory allows creating // new rootHandlers from the alternate http handler contextHandler and // a scope.
[ "RootHandlerFactory", "creates", "a", "new", "rootHandler", "factory", "using", "the", "given", "Context", "creator", "and", "authorizer", ".", "The", "returned", "factory", "allows", "creating", "new", "rootHandlers", "from", "the", "alternate", "http", "handler", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L39-L49
train
theupdateframework/notary
utils/http.go
ServeHTTP
func (root *rootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var ( err error ctx = ctxu.WithRequest(root.context, r) log = ctxu.GetRequestLogger(ctx) vars = mux.Vars(r) ) ctx, w = ctxu.WithResponseWriter(ctx, w) ctx = ctxu.WithLogger(ctx, log) ctx = context.WithValue(ctx, notary.CtxKeyCr...
go
func (root *rootHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { var ( err error ctx = ctxu.WithRequest(root.context, r) log = ctxu.GetRequestLogger(ctx) vars = mux.Vars(r) ) ctx, w = ctxu.WithResponseWriter(ctx, w) ctx = ctxu.WithLogger(ctx, log) ctx = context.WithValue(ctx, notary.CtxKeyCr...
[ "func", "(", "root", "*", "rootHandler", ")", "ServeHTTP", "(", "w", "http", ".", "ResponseWriter", ",", "r", "*", "http", ".", "Request", ")", "{", "var", "(", "err", "error", "\n", "ctx", "=", "ctxu", ".", "WithRequest", "(", "root", ".", "context"...
// ServeHTTP serves an HTTP request and implements the http.Handler interface.
[ "ServeHTTP", "serves", "an", "HTTP", "request", "and", "implements", "the", "http", ".", "Handler", "interface", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L52-L78
train
theupdateframework/notary
utils/http.go
buildCatalogRecord
func buildCatalogRecord(actions ...string) []auth.Access { requiredAccess := []auth.Access{{ Resource: auth.Resource{ Type: "registry", Name: "catalog", }, Action: "*", }} return requiredAccess }
go
func buildCatalogRecord(actions ...string) []auth.Access { requiredAccess := []auth.Access{{ Resource: auth.Resource{ Type: "registry", Name: "catalog", }, Action: "*", }} return requiredAccess }
[ "func", "buildCatalogRecord", "(", "actions", "...", "string", ")", "[", "]", "auth", ".", "Access", "{", "requiredAccess", ":=", "[", "]", "auth", ".", "Access", "{", "{", "Resource", ":", "auth", ".", "Resource", "{", "Type", ":", "\"", "\"", ",", ...
// buildCatalogRecord returns the only valid format for the catalog // resource. Only admins can get this access level from the token // server.
[ "buildCatalogRecord", "returns", "the", "only", "valid", "format", "for", "the", "catalog", "resource", ".", "Only", "admins", "can", "get", "this", "access", "level", "from", "the", "token", "server", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L143-L153
train
theupdateframework/notary
utils/http.go
NewCacheControlConfig
func NewCacheControlConfig(maxAgeInSeconds int, mustRevalidate bool) CacheControlConfig { if maxAgeInSeconds > 0 { return PublicCacheControl{MustReValidate: mustRevalidate, MaxAgeInSeconds: maxAgeInSeconds} } return NoCacheControl{} }
go
func NewCacheControlConfig(maxAgeInSeconds int, mustRevalidate bool) CacheControlConfig { if maxAgeInSeconds > 0 { return PublicCacheControl{MustReValidate: mustRevalidate, MaxAgeInSeconds: maxAgeInSeconds} } return NoCacheControl{} }
[ "func", "NewCacheControlConfig", "(", "maxAgeInSeconds", "int", ",", "mustRevalidate", "bool", ")", "CacheControlConfig", "{", "if", "maxAgeInSeconds", ">", "0", "{", "return", "PublicCacheControl", "{", "MustReValidate", ":", "mustRevalidate", ",", "MaxAgeInSeconds", ...
// NewCacheControlConfig returns CacheControlConfig interface for either setting // cache control or disabling cache control entirely
[ "NewCacheControlConfig", "returns", "CacheControlConfig", "interface", "for", "either", "setting", "cache", "control", "or", "disabling", "cache", "control", "entirely" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L164-L169
train
theupdateframework/notary
utils/http.go
SetHeaders
func (p PublicCacheControl) SetHeaders(headers http.Header) { cacheControlValue := fmt.Sprintf("public, max-age=%v, s-maxage=%v", p.MaxAgeInSeconds, p.MaxAgeInSeconds) if p.MustReValidate { cacheControlValue = fmt.Sprintf("%s, must-revalidate", cacheControlValue) } headers.Set("Cache-Control", cacheControlValu...
go
func (p PublicCacheControl) SetHeaders(headers http.Header) { cacheControlValue := fmt.Sprintf("public, max-age=%v, s-maxage=%v", p.MaxAgeInSeconds, p.MaxAgeInSeconds) if p.MustReValidate { cacheControlValue = fmt.Sprintf("%s, must-revalidate", cacheControlValue) } headers.Set("Cache-Control", cacheControlValu...
[ "func", "(", "p", "PublicCacheControl", ")", "SetHeaders", "(", "headers", "http", ".", "Header", ")", "{", "cacheControlValue", ":=", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "p", ".", "MaxAgeInSeconds", ",", "p", ".", "MaxAgeInSeconds", ")", "\n\n", ...
// SetHeaders sets the public headers with an optional must-revalidate header
[ "SetHeaders", "sets", "the", "public", "headers", "with", "an", "optional", "must", "-", "revalidate", "header" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L178-L192
train
theupdateframework/notary
utils/http.go
SetHeaders
func (n NoCacheControl) SetHeaders(headers http.Header) { headers.Set("Cache-Control", "max-age=0, no-cache, no-store") headers.Set("Pragma", "no-cache") }
go
func (n NoCacheControl) SetHeaders(headers http.Header) { headers.Set("Cache-Control", "max-age=0, no-cache, no-store") headers.Set("Pragma", "no-cache") }
[ "func", "(", "n", "NoCacheControl", ")", "SetHeaders", "(", "headers", "http", ".", "Header", ")", "{", "headers", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "headers", ".", "Set", "(", "\"", "\"", ",", "\"", "\"", ")", "\n", "}" ]
// SetHeaders sets the public headers cache-control headers and pragma to no-cache
[ "SetHeaders", "sets", "the", "public", "headers", "cache", "-", "control", "headers", "and", "pragma", "to", "no", "-", "cache" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L198-L201
train
theupdateframework/notary
utils/http.go
WriteHeader
func (c *cacheControlResponseWriter) WriteHeader(statusCode int) { c.statusCode = statusCode c.ResponseWriter.WriteHeader(statusCode) }
go
func (c *cacheControlResponseWriter) WriteHeader(statusCode int) { c.statusCode = statusCode c.ResponseWriter.WriteHeader(statusCode) }
[ "func", "(", "c", "*", "cacheControlResponseWriter", ")", "WriteHeader", "(", "statusCode", "int", ")", "{", "c", ".", "statusCode", "=", "statusCode", "\n", "c", ".", "ResponseWriter", ".", "WriteHeader", "(", "statusCode", ")", "\n", "}" ]
// WriteHeader stores the header before writing it, so we can tell if it's been set // to a non-200 status code
[ "WriteHeader", "stores", "the", "header", "before", "writing", "it", "so", "we", "can", "tell", "if", "it", "s", "been", "set", "to", "a", "non", "-", "200", "status", "code" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L213-L216
train
theupdateframework/notary
utils/http.go
Write
func (c *cacheControlResponseWriter) Write(data []byte) (int, error) { if c.statusCode == http.StatusOK || c.statusCode == 0 { headers := c.ResponseWriter.Header() if headers.Get("Cache-Control") == "" { c.config.SetHeaders(headers) } } return c.ResponseWriter.Write(data) }
go
func (c *cacheControlResponseWriter) Write(data []byte) (int, error) { if c.statusCode == http.StatusOK || c.statusCode == 0 { headers := c.ResponseWriter.Header() if headers.Get("Cache-Control") == "" { c.config.SetHeaders(headers) } } return c.ResponseWriter.Write(data) }
[ "func", "(", "c", "*", "cacheControlResponseWriter", ")", "Write", "(", "data", "[", "]", "byte", ")", "(", "int", ",", "error", ")", "{", "if", "c", ".", "statusCode", "==", "http", ".", "StatusOK", "||", "c", ".", "statusCode", "==", "0", "{", "h...
// Write will set the cache headers if they haven't already been set and if the status // code has either not been set or set to 200
[ "Write", "will", "set", "the", "cache", "headers", "if", "they", "haven", "t", "already", "been", "set", "and", "if", "the", "status", "code", "has", "either", "not", "been", "set", "or", "set", "to", "200" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L220-L228
train
theupdateframework/notary
utils/http.go
WrapWithCacheHandler
func WrapWithCacheHandler(ccc CacheControlConfig, handler http.Handler) http.Handler { if ccc != nil { return cacheControlHandler{Handler: handler, config: ccc} } return handler }
go
func WrapWithCacheHandler(ccc CacheControlConfig, handler http.Handler) http.Handler { if ccc != nil { return cacheControlHandler{Handler: handler, config: ccc} } return handler }
[ "func", "WrapWithCacheHandler", "(", "ccc", "CacheControlConfig", ",", "handler", "http", ".", "Handler", ")", "http", ".", "Handler", "{", "if", "ccc", "!=", "nil", "{", "return", "cacheControlHandler", "{", "Handler", ":", "handler", ",", "config", ":", "c...
// WrapWithCacheHandler wraps another handler in one that can add cache control headers // given a 200 response
[ "WrapWithCacheHandler", "wraps", "another", "handler", "in", "one", "that", "can", "add", "cache", "control", "headers", "given", "a", "200", "response" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L241-L246
train
theupdateframework/notary
utils/http.go
SetLastModifiedHeader
func SetLastModifiedHeader(headers http.Header, lmt time.Time) { headers.Set("Last-Modified", lmt.Format(time.RFC1123)) }
go
func SetLastModifiedHeader(headers http.Header, lmt time.Time) { headers.Set("Last-Modified", lmt.Format(time.RFC1123)) }
[ "func", "SetLastModifiedHeader", "(", "headers", "http", ".", "Header", ",", "lmt", "time", ".", "Time", ")", "{", "headers", ".", "Set", "(", "\"", "\"", ",", "lmt", ".", "Format", "(", "time", ".", "RFC1123", ")", ")", "\n", "}" ]
// SetLastModifiedHeader takes a time and uses it to set the LastModified header using // the right date format
[ "SetLastModifiedHeader", "takes", "a", "time", "and", "uses", "it", "to", "set", "the", "LastModified", "header", "using", "the", "right", "date", "format" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/utils/http.go#L250-L252
train
theupdateframework/notary
client/tufclient.go
Update
func (c *tufClient) Update() (*tuf.Repo, *tuf.Repo, error) { // 1. Get timestamp // a. If timestamp error (verification, expired, etc...) download new root and return to 1. // 2. Check if local snapshot is up to date // a. If out of date, get updated snapshot // i. If snapshot error, download new root and ...
go
func (c *tufClient) Update() (*tuf.Repo, *tuf.Repo, error) { // 1. Get timestamp // a. If timestamp error (verification, expired, etc...) download new root and return to 1. // 2. Check if local snapshot is up to date // a. If out of date, get updated snapshot // i. If snapshot error, download new root and ...
[ "func", "(", "c", "*", "tufClient", ")", "Update", "(", ")", "(", "*", "tuf", ".", "Repo", ",", "*", "tuf", ".", "Repo", ",", "error", ")", "{", "// 1. Get timestamp", "// a. If timestamp error (verification, expired, etc...) download new root and return to 1.", "...
// Update performs an update to the TUF repo as defined by the TUF spec
[ "Update", "performs", "an", "update", "to", "the", "TUF", "repo", "as", "defined", "by", "the", "TUF", "spec" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L27-L56
train
theupdateframework/notary
client/tufclient.go
updateRoot
func (c *tufClient) updateRoot() error { // Get current root version currentRootConsistentInfo := c.oldBuilder.GetConsistentInfo(data.CanonicalRootRole) currentVersion := c.oldBuilder.GetLoadedVersion(currentRootConsistentInfo.RoleName) // Get new root version raw, err := c.downloadRoot() switch err.(type) { c...
go
func (c *tufClient) updateRoot() error { // Get current root version currentRootConsistentInfo := c.oldBuilder.GetConsistentInfo(data.CanonicalRootRole) currentVersion := c.oldBuilder.GetLoadedVersion(currentRootConsistentInfo.RoleName) // Get new root version raw, err := c.downloadRoot() switch err.(type) { c...
[ "func", "(", "c", "*", "tufClient", ")", "updateRoot", "(", ")", "error", "{", "// Get current root version", "currentRootConsistentInfo", ":=", "c", ".", "oldBuilder", ".", "GetConsistentInfo", "(", "data", ".", "CanonicalRootRole", ")", "\n", "currentVersion", "...
// updateRoot checks if there is a newer version of the root available, and if so // downloads all intermediate root files to allow proper key rotation.
[ "updateRoot", "checks", "if", "there", "is", "a", "newer", "version", "of", "the", "root", "available", "and", "if", "so", "downloads", "all", "intermediate", "root", "files", "to", "allow", "proper", "key", "rotation", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L77-L138
train
theupdateframework/notary
client/tufclient.go
updateRootVersions
func (c *tufClient) updateRootVersions(fromVersion, toVersion int) error { for v := fromVersion; v <= toVersion; v++ { logrus.Debugf("updating root from version %d to version %d, currently fetching %d", fromVersion, toVersion, v) versionedRole := fmt.Sprintf("%d.%s", v, data.CanonicalRootRole) raw, err := c.re...
go
func (c *tufClient) updateRootVersions(fromVersion, toVersion int) error { for v := fromVersion; v <= toVersion; v++ { logrus.Debugf("updating root from version %d to version %d, currently fetching %d", fromVersion, toVersion, v) versionedRole := fmt.Sprintf("%d.%s", v, data.CanonicalRootRole) raw, err := c.re...
[ "func", "(", "c", "*", "tufClient", ")", "updateRootVersions", "(", "fromVersion", ",", "toVersion", "int", ")", "error", "{", "for", "v", ":=", "fromVersion", ";", "v", "<=", "toVersion", ";", "v", "++", "{", "logrus", ".", "Debugf", "(", "\"", "\"", ...
// updateRootVersions updates the root from it's current version to a target, rotating keys // as they are found
[ "updateRootVersions", "updates", "the", "root", "from", "it", "s", "current", "version", "to", "a", "target", "rotating", "keys", "as", "they", "are", "found" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L142-L160
train
theupdateframework/notary
client/tufclient.go
downloadSnapshot
func (c *tufClient) downloadSnapshot() error { logrus.Debug("Loading snapshot...") role := data.CanonicalSnapshotRole consistentInfo := c.newBuilder.GetConsistentInfo(role) _, err := c.tryLoadCacheThenRemote(consistentInfo) return err }
go
func (c *tufClient) downloadSnapshot() error { logrus.Debug("Loading snapshot...") role := data.CanonicalSnapshotRole consistentInfo := c.newBuilder.GetConsistentInfo(role) _, err := c.tryLoadCacheThenRemote(consistentInfo) return err }
[ "func", "(", "c", "*", "tufClient", ")", "downloadSnapshot", "(", ")", "error", "{", "logrus", ".", "Debug", "(", "\"", "\"", ")", "\n", "role", ":=", "data", ".", "CanonicalSnapshotRole", "\n", "consistentInfo", ":=", "c", ".", "newBuilder", ".", "GetCo...
// downloadSnapshot is responsible for downloading the snapshot.json
[ "downloadSnapshot", "is", "responsible", "for", "downloading", "the", "snapshot", ".", "json" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L201-L208
train
theupdateframework/notary
client/tufclient.go
downloadTargets
func (c *tufClient) downloadTargets() error { toDownload := []data.DelegationRole{{ BaseRole: data.BaseRole{Name: data.CanonicalTargetsRole}, Paths: []string{""}, }} for len(toDownload) > 0 { role := toDownload[0] toDownload = toDownload[1:] consistentInfo := c.newBuilder.GetConsistentInfo(role.Name) ...
go
func (c *tufClient) downloadTargets() error { toDownload := []data.DelegationRole{{ BaseRole: data.BaseRole{Name: data.CanonicalTargetsRole}, Paths: []string{""}, }} for len(toDownload) > 0 { role := toDownload[0] toDownload = toDownload[1:] consistentInfo := c.newBuilder.GetConsistentInfo(role.Name) ...
[ "func", "(", "c", "*", "tufClient", ")", "downloadTargets", "(", ")", "error", "{", "toDownload", ":=", "[", "]", "data", ".", "DelegationRole", "{", "{", "BaseRole", ":", "data", ".", "BaseRole", "{", "Name", ":", "data", ".", "CanonicalTargetsRole", "}...
// downloadTargets downloads all targets and delegated targets for the repository. // It uses a pre-order tree traversal as it's necessary to download parents first // to obtain the keys to validate children.
[ "downloadTargets", "downloads", "all", "targets", "and", "delegated", "targets", "for", "the", "repository", ".", "It", "uses", "a", "pre", "-", "order", "tree", "traversal", "as", "it", "s", "necessary", "to", "download", "parents", "first", "to", "obtain", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L213-L244
train
theupdateframework/notary
client/tufclient.go
downloadRoot
func (c *tufClient) downloadRoot() ([]byte, error) { role := data.CanonicalRootRole consistentInfo := c.newBuilder.GetConsistentInfo(role) // We can't read an exact size for the root metadata without risking getting stuck in the TUF update cycle // since it's possible that downloading timestamp/snapshot metadata m...
go
func (c *tufClient) downloadRoot() ([]byte, error) { role := data.CanonicalRootRole consistentInfo := c.newBuilder.GetConsistentInfo(role) // We can't read an exact size for the root metadata without risking getting stuck in the TUF update cycle // since it's possible that downloading timestamp/snapshot metadata m...
[ "func", "(", "c", "*", "tufClient", ")", "downloadRoot", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "role", ":=", "data", ".", "CanonicalRootRole", "\n", "consistentInfo", ":=", "c", ".", "newBuilder", ".", "GetConsistentInfo", "(", "role",...
// downloadRoot is responsible for downloading the root.json
[ "downloadRoot", "is", "responsible", "for", "downloading", "the", "root", ".", "json" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/tufclient.go#L262-L277
train
theupdateframework/notary
client/changelist/change.go
NewTUFChange
func NewTUFChange(action string, role data.RoleName, changeType, changePath string, content []byte) *TUFChange { return &TUFChange{ Actn: action, Role: role, ChangeType: changeType, ChangePath: changePath, Data: content, } }
go
func NewTUFChange(action string, role data.RoleName, changeType, changePath string, content []byte) *TUFChange { return &TUFChange{ Actn: action, Role: role, ChangeType: changeType, ChangePath: changePath, Data: content, } }
[ "func", "NewTUFChange", "(", "action", "string", ",", "role", "data", ".", "RoleName", ",", "changeType", ",", "changePath", "string", ",", "content", "[", "]", "byte", ")", "*", "TUFChange", "{", "return", "&", "TUFChange", "{", "Actn", ":", "action", "...
// NewTUFChange initializes a TUFChange object
[ "NewTUFChange", "initializes", "a", "TUFChange", "object" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/change.go#L45-L53
train
theupdateframework/notary
client/changelist/change.go
ToNewRole
func (td TUFDelegation) ToNewRole(scope data.RoleName) (*data.Role, error) { name := scope if td.NewName != "" { name = td.NewName } return data.NewRole(name, td.NewThreshold, td.AddKeys.IDs(), td.AddPaths) }
go
func (td TUFDelegation) ToNewRole(scope data.RoleName) (*data.Role, error) { name := scope if td.NewName != "" { name = td.NewName } return data.NewRole(name, td.NewThreshold, td.AddKeys.IDs(), td.AddPaths) }
[ "func", "(", "td", "TUFDelegation", ")", "ToNewRole", "(", "scope", "data", ".", "RoleName", ")", "(", "*", "data", ".", "Role", ",", "error", ")", "{", "name", ":=", "scope", "\n", "if", "td", ".", "NewName", "!=", "\"", "\"", "{", "name", "=", ...
// ToNewRole creates a fresh role object from the TUFDelegation data
[ "ToNewRole", "creates", "a", "fresh", "role", "object", "from", "the", "TUFDelegation", "data" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/client/changelist/change.go#L94-L100
train
theupdateframework/notary
signer/keydbstore/rethink_keydbstore.go
NewRethinkDBKeyStore
func NewRethinkDBKeyStore(dbName, username, password string, passphraseRetriever notary.PassRetriever, defaultPassAlias string, rethinkSession *gorethink.Session) *RethinkDBKeyStore { return &RethinkDBKeyStore{ sess: rethinkSession, defaultPassAlias: defaultPassAlias, dbName: dbName, retr...
go
func NewRethinkDBKeyStore(dbName, username, password string, passphraseRetriever notary.PassRetriever, defaultPassAlias string, rethinkSession *gorethink.Session) *RethinkDBKeyStore { return &RethinkDBKeyStore{ sess: rethinkSession, defaultPassAlias: defaultPassAlias, dbName: dbName, retr...
[ "func", "NewRethinkDBKeyStore", "(", "dbName", ",", "username", ",", "password", "string", ",", "passphraseRetriever", "notary", ".", "PassRetriever", ",", "defaultPassAlias", "string", ",", "rethinkSession", "*", "gorethink", ".", "Session", ")", "*", "RethinkDBKey...
// NewRethinkDBKeyStore returns a new RethinkDBKeyStore backed by a RethinkDB database
[ "NewRethinkDBKeyStore", "returns", "a", "new", "RethinkDBKeyStore", "backed", "by", "a", "RethinkDB", "database" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/rethink_keydbstore.go#L104-L114
train
theupdateframework/notary
signer/keydbstore/rethink_keydbstore.go
getKey
func (rdb *RethinkDBKeyStore) getKey(keyID string) (*RDBPrivateKey, string, error) { // Retrieve the RethinkDB private key from the database dbPrivateKey := RDBPrivateKey{} res, err := gorethink.DB(rdb.dbName).Table(dbPrivateKey.TableName()).Filter(gorethink.Row.Field("key_id").Eq(keyID)).Run(rdb.sess) if err != ni...
go
func (rdb *RethinkDBKeyStore) getKey(keyID string) (*RDBPrivateKey, string, error) { // Retrieve the RethinkDB private key from the database dbPrivateKey := RDBPrivateKey{} res, err := gorethink.DB(rdb.dbName).Table(dbPrivateKey.TableName()).Filter(gorethink.Row.Field("key_id").Eq(keyID)).Run(rdb.sess) if err != ni...
[ "func", "(", "rdb", "*", "RethinkDBKeyStore", ")", "getKey", "(", "keyID", "string", ")", "(", "*", "RDBPrivateKey", ",", "string", ",", "error", ")", "{", "// Retrieve the RethinkDB private key from the database", "dbPrivateKey", ":=", "RDBPrivateKey", "{", "}", ...
// getKeyBytes returns the RDBPrivateKey given a KeyID, as well as the decrypted private bytes
[ "getKeyBytes", "returns", "the", "RDBPrivateKey", "given", "a", "KeyID", "as", "well", "as", "the", "decrypted", "private", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/rethink_keydbstore.go#L161-L188
train
theupdateframework/notary
signer/keydbstore/rethink_keydbstore.go
GetKey
func (rdb *RethinkDBKeyStore) GetKey(keyID string) data.PublicKey { dbPrivateKey, _, err := rdb.getKey(keyID) if err != nil { return nil } return data.NewPublicKey(dbPrivateKey.Algorithm, dbPrivateKey.Public) }
go
func (rdb *RethinkDBKeyStore) GetKey(keyID string) data.PublicKey { dbPrivateKey, _, err := rdb.getKey(keyID) if err != nil { return nil } return data.NewPublicKey(dbPrivateKey.Algorithm, dbPrivateKey.Public) }
[ "func", "(", "rdb", "*", "RethinkDBKeyStore", ")", "GetKey", "(", "keyID", "string", ")", "data", ".", "PublicKey", "{", "dbPrivateKey", ",", "_", ",", "err", ":=", "rdb", ".", "getKey", "(", "keyID", ")", "\n", "if", "err", "!=", "nil", "{", "return...
// GetKey returns the PublicKey given a KeyID, and does not activate the key
[ "GetKey", "returns", "the", "PublicKey", "given", "a", "KeyID", "and", "does", "not", "activate", "the", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/rethink_keydbstore.go#L209-L216
train
theupdateframework/notary
signer/keydbstore/rethink_keydbstore.go
RemoveKey
func (rdb RethinkDBKeyStore) RemoveKey(keyID string) error { // Delete the key from the database dbPrivateKey := RDBPrivateKey{KeyID: keyID} _, err := gorethink.DB(rdb.dbName).Table(dbPrivateKey.TableName()).Filter(gorethink.Row.Field("key_id").Eq(keyID)).Delete().RunWrite(rdb.sess) if err != nil { return fmt.Err...
go
func (rdb RethinkDBKeyStore) RemoveKey(keyID string) error { // Delete the key from the database dbPrivateKey := RDBPrivateKey{KeyID: keyID} _, err := gorethink.DB(rdb.dbName).Table(dbPrivateKey.TableName()).Filter(gorethink.Row.Field("key_id").Eq(keyID)).Delete().RunWrite(rdb.sess) if err != nil { return fmt.Err...
[ "func", "(", "rdb", "RethinkDBKeyStore", ")", "RemoveKey", "(", "keyID", "string", ")", "error", "{", "// Delete the key from the database", "dbPrivateKey", ":=", "RDBPrivateKey", "{", "KeyID", ":", "keyID", "}", "\n", "_", ",", "err", ":=", "gorethink", ".", ...
// RemoveKey removes the key from the table
[ "RemoveKey", "removes", "the", "key", "from", "the", "table" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/rethink_keydbstore.go#L229-L238
train
theupdateframework/notary
signer/keydbstore/rethink_keydbstore.go
Bootstrap
func (rdb RethinkDBKeyStore) Bootstrap() error { if err := rethinkdb.SetupDB(rdb.sess, rdb.dbName, []rethinkdb.Table{ PrivateKeysRethinkTable, }); err != nil { return err } return rethinkdb.CreateAndGrantDBUser(rdb.sess, rdb.dbName, rdb.user, rdb.password) }
go
func (rdb RethinkDBKeyStore) Bootstrap() error { if err := rethinkdb.SetupDB(rdb.sess, rdb.dbName, []rethinkdb.Table{ PrivateKeysRethinkTable, }); err != nil { return err } return rethinkdb.CreateAndGrantDBUser(rdb.sess, rdb.dbName, rdb.user, rdb.password) }
[ "func", "(", "rdb", "RethinkDBKeyStore", ")", "Bootstrap", "(", ")", "error", "{", "if", "err", ":=", "rethinkdb", ".", "SetupDB", "(", "rdb", ".", "sess", ",", "rdb", ".", "dbName", ",", "[", "]", "rethinkdb", ".", "Table", "{", "PrivateKeysRethinkTable...
// Bootstrap sets up the database and tables, also creating the notary signer user with appropriate db permission
[ "Bootstrap", "sets", "up", "the", "database", "and", "tables", "also", "creating", "the", "notary", "signer", "user", "with", "appropriate", "db", "permission" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/rethink_keydbstore.go#L310-L317
train
theupdateframework/notary
tuf/signed/verify.go
VerifyExpiry
func VerifyExpiry(s *data.SignedCommon, role data.RoleName) error { if IsExpired(s.Expires) { logrus.Errorf("Metadata for %s expired", role) return ErrExpired{Role: role, Expired: s.Expires.Format("Mon Jan 2 15:04:05 MST 2006")} } return nil }
go
func VerifyExpiry(s *data.SignedCommon, role data.RoleName) error { if IsExpired(s.Expires) { logrus.Errorf("Metadata for %s expired", role) return ErrExpired{Role: role, Expired: s.Expires.Format("Mon Jan 2 15:04:05 MST 2006")} } return nil }
[ "func", "VerifyExpiry", "(", "s", "*", "data", ".", "SignedCommon", ",", "role", "data", ".", "RoleName", ")", "error", "{", "if", "IsExpired", "(", "s", ".", "Expires", ")", "{", "logrus", ".", "Errorf", "(", "\"", "\"", ",", "role", ")", "\n", "r...
// VerifyExpiry returns ErrExpired if the metadata is expired
[ "VerifyExpiry", "returns", "ErrExpired", "if", "the", "metadata", "is", "expired" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verify.go#L28-L34
train
theupdateframework/notary
tuf/signed/verify.go
VerifyVersion
func VerifyVersion(s *data.SignedCommon, minVersion int) error { if s.Version < minVersion { return ErrLowVersion{Actual: s.Version, Current: minVersion} } return nil }
go
func VerifyVersion(s *data.SignedCommon, minVersion int) error { if s.Version < minVersion { return ErrLowVersion{Actual: s.Version, Current: minVersion} } return nil }
[ "func", "VerifyVersion", "(", "s", "*", "data", ".", "SignedCommon", ",", "minVersion", "int", ")", "error", "{", "if", "s", ".", "Version", "<", "minVersion", "{", "return", "ErrLowVersion", "{", "Actual", ":", "s", ".", "Version", ",", "Current", ":", ...
// VerifyVersion returns ErrLowVersion if the metadata version is lower than the min version
[ "VerifyVersion", "returns", "ErrLowVersion", "if", "the", "metadata", "version", "is", "lower", "than", "the", "min", "version" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verify.go#L37-L42
train
theupdateframework/notary
tuf/signed/verify.go
VerifySignatures
func VerifySignatures(s *data.Signed, roleData data.BaseRole) error { if len(s.Signatures) == 0 { return ErrNoSignatures } if roleData.Threshold < 1 { return ErrRoleThreshold{} } logrus.Debugf("%s role has key IDs: %s", roleData.Name, strings.Join(roleData.ListKeyIDs(), ",")) // remarshal the signed part so...
go
func VerifySignatures(s *data.Signed, roleData data.BaseRole) error { if len(s.Signatures) == 0 { return ErrNoSignatures } if roleData.Threshold < 1 { return ErrRoleThreshold{} } logrus.Debugf("%s role has key IDs: %s", roleData.Name, strings.Join(roleData.ListKeyIDs(), ",")) // remarshal the signed part so...
[ "func", "VerifySignatures", "(", "s", "*", "data", ".", "Signed", ",", "roleData", "data", ".", "BaseRole", ")", "error", "{", "if", "len", "(", "s", ".", "Signatures", ")", "==", "0", "{", "return", "ErrNoSignatures", "\n", "}", "\n\n", "if", "roleDat...
// VerifySignatures checks the we have sufficient valid signatures for the given role
[ "VerifySignatures", "checks", "the", "we", "have", "sufficient", "valid", "signatures", "for", "the", "given", "role" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verify.go#L45-L92
train
theupdateframework/notary
tuf/signed/verify.go
VerifySignature
func VerifySignature(msg []byte, sig *data.Signature, pk data.PublicKey) error { // method lookup is consistent due to Unmarshal JSON doing lower case for us. method := sig.Method verifier, ok := Verifiers[method] if !ok { return fmt.Errorf("signing method is not supported: %s", sig.Method) } if err := verifie...
go
func VerifySignature(msg []byte, sig *data.Signature, pk data.PublicKey) error { // method lookup is consistent due to Unmarshal JSON doing lower case for us. method := sig.Method verifier, ok := Verifiers[method] if !ok { return fmt.Errorf("signing method is not supported: %s", sig.Method) } if err := verifie...
[ "func", "VerifySignature", "(", "msg", "[", "]", "byte", ",", "sig", "*", "data", ".", "Signature", ",", "pk", "data", ".", "PublicKey", ")", "error", "{", "// method lookup is consistent due to Unmarshal JSON doing lower case for us.", "method", ":=", "sig", ".", ...
// VerifySignature checks a single signature and public key against a payload // If the signature is verified, the signature's is valid field will actually // be mutated to be equal to the boolean true
[ "VerifySignature", "checks", "a", "single", "signature", "and", "public", "key", "against", "a", "payload", "If", "the", "signature", "is", "verified", "the", "signature", "s", "is", "valid", "field", "will", "actually", "be", "mutated", "to", "be", "equal", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verify.go#L97-L110
train
theupdateframework/notary
tuf/signed/verify.go
VerifyPublicKeyMatchesPrivateKey
func VerifyPublicKeyMatchesPrivateKey(privKey data.PrivateKey, pubKey data.PublicKey) error { pubKeyID, err := utils.CanonicalKeyID(pubKey) if err != nil { return fmt.Errorf("could not verify key pair: %v", err) } if privKey == nil || pubKeyID != privKey.ID() { return fmt.Errorf("private key is nil or does not ...
go
func VerifyPublicKeyMatchesPrivateKey(privKey data.PrivateKey, pubKey data.PublicKey) error { pubKeyID, err := utils.CanonicalKeyID(pubKey) if err != nil { return fmt.Errorf("could not verify key pair: %v", err) } if privKey == nil || pubKeyID != privKey.ID() { return fmt.Errorf("private key is nil or does not ...
[ "func", "VerifyPublicKeyMatchesPrivateKey", "(", "privKey", "data", ".", "PrivateKey", ",", "pubKey", "data", ".", "PublicKey", ")", "error", "{", "pubKeyID", ",", "err", ":=", "utils", ".", "CanonicalKeyID", "(", "pubKey", ")", "\n", "if", "err", "!=", "nil...
// VerifyPublicKeyMatchesPrivateKey checks if the private key and the public keys forms valid key pairs. // Supports both x509 certificate PublicKeys and non-certificate PublicKeys
[ "VerifyPublicKeyMatchesPrivateKey", "checks", "if", "the", "private", "key", "and", "the", "public", "keys", "forms", "valid", "key", "pairs", ".", "Supports", "both", "x509", "certificate", "PublicKeys", "and", "non", "-", "certificate", "PublicKeys" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verify.go#L114-L123
train
theupdateframework/notary
cmd/notary/repo_factory.go
ConfigureRepo
func ConfigureRepo(v *viper.Viper, retriever notary.PassRetriever, onlineOperation bool, permission httpAccess) RepoFactory { localRepo := func(gun data.GUN) (client.Repository, error) { var rt http.RoundTripper trustPin, err := getTrustPinning(v) if err != nil { return nil, err } if onlineOperation { ...
go
func ConfigureRepo(v *viper.Viper, retriever notary.PassRetriever, onlineOperation bool, permission httpAccess) RepoFactory { localRepo := func(gun data.GUN) (client.Repository, error) { var rt http.RoundTripper trustPin, err := getTrustPinning(v) if err != nil { return nil, err } if onlineOperation { ...
[ "func", "ConfigureRepo", "(", "v", "*", "viper", ".", "Viper", ",", "retriever", "notary", ".", "PassRetriever", ",", "onlineOperation", "bool", ",", "permission", "httpAccess", ")", "RepoFactory", "{", "localRepo", ":=", "func", "(", "gun", "data", ".", "GU...
// ConfigureRepo takes in the configuration parameters and returns a repoFactory that can // initialize new client.Repository objects with the correct upstreams and password // retrieval mechanisms.
[ "ConfigureRepo", "takes", "in", "the", "configuration", "parameters", "and", "returns", "a", "repoFactory", "that", "can", "initialize", "new", "client", ".", "Repository", "objects", "with", "the", "correct", "upstreams", "and", "password", "retrieval", "mechanisms...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/cmd/notary/repo_factory.go#L21-L45
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
SetYubikeyKeyMode
func SetYubikeyKeyMode(keyMode int) error { // technically 7 (1 | 2 | 4) is valid, but KeymodePinOnce + // KeymdoePinAlways don't really make sense together if keyMode < 0 || keyMode > 5 { return errors.New("Invalid key mode") } yubikeyKeymode = keyMode return nil }
go
func SetYubikeyKeyMode(keyMode int) error { // technically 7 (1 | 2 | 4) is valid, but KeymodePinOnce + // KeymdoePinAlways don't really make sense together if keyMode < 0 || keyMode > 5 { return errors.New("Invalid key mode") } yubikeyKeymode = keyMode return nil }
[ "func", "SetYubikeyKeyMode", "(", "keyMode", "int", ")", "error", "{", "// technically 7 (1 | 2 | 4) is valid, but KeymodePinOnce +", "// KeymdoePinAlways don't really make sense together", "if", "keyMode", "<", "0", "||", "keyMode", ">", "5", "{", "return", "errors", ".", ...
// SetYubikeyKeyMode - sets the mode when generating yubikey keys. // This is to be used for testing. It does nothing if not building with tag // pkcs11.
[ "SetYubikeyKeyMode", "-", "sets", "the", "mode", "when", "generating", "yubikey", "keys", ".", "This", "is", "to", "be", "used", "for", "testing", ".", "It", "does", "nothing", "if", "not", "building", "with", "tag", "pkcs11", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L63-L71
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
NewYubiPrivateKey
func NewYubiPrivateKey(slot []byte, pubKey data.ECDSAPublicKey, passRetriever notary.PassRetriever) *YubiPrivateKey { return &YubiPrivateKey{ ECDSAPublicKey: pubKey, passRetriever: passRetriever, slot: slot, libLoader: defaultLoader, } }
go
func NewYubiPrivateKey(slot []byte, pubKey data.ECDSAPublicKey, passRetriever notary.PassRetriever) *YubiPrivateKey { return &YubiPrivateKey{ ECDSAPublicKey: pubKey, passRetriever: passRetriever, slot: slot, libLoader: defaultLoader, } }
[ "func", "NewYubiPrivateKey", "(", "slot", "[", "]", "byte", ",", "pubKey", "data", ".", "ECDSAPublicKey", ",", "passRetriever", "notary", ".", "PassRetriever", ")", "*", "YubiPrivateKey", "{", "return", "&", "YubiPrivateKey", "{", "ECDSAPublicKey", ":", "pubKey"...
// NewYubiPrivateKey returns a YubiPrivateKey, which implements the data.PrivateKey // interface except that the private material is inaccessible
[ "NewYubiPrivateKey", "returns", "a", "YubiPrivateKey", "which", "implements", "the", "data", ".", "PrivateKey", "interface", "except", "that", "the", "private", "material", "is", "inaccessible" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L148-L157
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
Public
func (ys *yubikeySigner) Public() crypto.PublicKey { publicKey, err := x509.ParsePKIXPublicKey(ys.YubiPrivateKey.Public()) if err != nil { return nil } return publicKey }
go
func (ys *yubikeySigner) Public() crypto.PublicKey { publicKey, err := x509.ParsePKIXPublicKey(ys.YubiPrivateKey.Public()) if err != nil { return nil } return publicKey }
[ "func", "(", "ys", "*", "yubikeySigner", ")", "Public", "(", ")", "crypto", ".", "PublicKey", "{", "publicKey", ",", "err", ":=", "x509", ".", "ParsePKIXPublicKey", "(", "ys", ".", "YubiPrivateKey", ".", "Public", "(", ")", ")", "\n", "if", "err", "!="...
// Public is a required method of the crypto.Signer interface
[ "Public", "is", "a", "required", "method", "of", "the", "crypto", ".", "Signer", "interface" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L160-L167
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
Sign
func (y *YubiPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error) { ctx, session, err := SetupHSMEnv(pkcs11Lib, y.libLoader) if err != nil { return nil, err } defer cleanup(ctx, session) v := signed.Verifiers[data.ECDSASignature] for i := 0; i < sigAttempts; i++ { sig, err := ...
go
func (y *YubiPrivateKey) Sign(rand io.Reader, msg []byte, opts crypto.SignerOpts) ([]byte, error) { ctx, session, err := SetupHSMEnv(pkcs11Lib, y.libLoader) if err != nil { return nil, err } defer cleanup(ctx, session) v := signed.Verifiers[data.ECDSASignature] for i := 0; i < sigAttempts; i++ { sig, err := ...
[ "func", "(", "y", "*", "YubiPrivateKey", ")", "Sign", "(", "rand", "io", ".", "Reader", ",", "msg", "[", "]", "byte", ",", "opts", "crypto", ".", "SignerOpts", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "ctx", ",", "session", ",", "err",...
// Sign is a required method of the crypto.Signer interface and the data.PrivateKey // interface
[ "Sign", "is", "a", "required", "method", "of", "the", "crypto", ".", "Signer", "interface", "and", "the", "data", ".", "PrivateKey", "interface" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L194-L212
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
ensurePrivateKeySize
func ensurePrivateKeySize(payload []byte) []byte { final := payload if len(payload) < ecdsaPrivateKeySize { final = make([]byte, ecdsaPrivateKeySize) copy(final[ecdsaPrivateKeySize-len(payload):], payload) } return final }
go
func ensurePrivateKeySize(payload []byte) []byte { final := payload if len(payload) < ecdsaPrivateKeySize { final = make([]byte, ecdsaPrivateKeySize) copy(final[ecdsaPrivateKeySize-len(payload):], payload) } return final }
[ "func", "ensurePrivateKeySize", "(", "payload", "[", "]", "byte", ")", "[", "]", "byte", "{", "final", ":=", "payload", "\n", "if", "len", "(", "payload", ")", "<", "ecdsaPrivateKeySize", "{", "final", "=", "make", "(", "[", "]", "byte", ",", "ecdsaPri...
// If a byte array is less than the number of bytes specified by // ecdsaPrivateKeySize, left-zero-pad the byte array until // it is the required size.
[ "If", "a", "byte", "array", "is", "less", "than", "the", "number", "of", "bytes", "specified", "by", "ecdsaPrivateKeySize", "left", "-", "zero", "-", "pad", "the", "byte", "array", "until", "it", "is", "the", "required", "size", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L217-L224
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
addECDSAKey
func addECDSAKey( ctx IPKCS11Ctx, session pkcs11.SessionHandle, privKey data.PrivateKey, pkcs11KeyID []byte, passRetriever notary.PassRetriever, role data.RoleName, ) error { logrus.Debugf("Attempting to add key to yubikey with ID: %s", privKey.ID()) err := login(ctx, session, passRetriever, pkcs11.CKU_SO, SOU...
go
func addECDSAKey( ctx IPKCS11Ctx, session pkcs11.SessionHandle, privKey data.PrivateKey, pkcs11KeyID []byte, passRetriever notary.PassRetriever, role data.RoleName, ) error { logrus.Debugf("Attempting to add key to yubikey with ID: %s", privKey.ID()) err := login(ctx, session, passRetriever, pkcs11.CKU_SO, SOU...
[ "func", "addECDSAKey", "(", "ctx", "IPKCS11Ctx", ",", "session", "pkcs11", ".", "SessionHandle", ",", "privKey", "data", ".", "PrivateKey", ",", "pkcs11KeyID", "[", "]", "byte", ",", "passRetriever", "notary", ".", "PassRetriever", ",", "role", "data", ".", ...
// addECDSAKey adds a key to the yubikey
[ "addECDSAKey", "adds", "a", "key", "to", "the", "yubikey" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L227-L289
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
sign
func sign(ctx IPKCS11Ctx, session pkcs11.SessionHandle, pkcs11KeyID []byte, passRetriever notary.PassRetriever, payload []byte) ([]byte, error) { err := login(ctx, session, passRetriever, pkcs11.CKU_USER, UserPin) if err != nil { return nil, fmt.Errorf("error logging in: %v", err) } defer ctx.Logout(session) //...
go
func sign(ctx IPKCS11Ctx, session pkcs11.SessionHandle, pkcs11KeyID []byte, passRetriever notary.PassRetriever, payload []byte) ([]byte, error) { err := login(ctx, session, passRetriever, pkcs11.CKU_USER, UserPin) if err != nil { return nil, fmt.Errorf("error logging in: %v", err) } defer ctx.Logout(session) //...
[ "func", "sign", "(", "ctx", "IPKCS11Ctx", ",", "session", "pkcs11", ".", "SessionHandle", ",", "pkcs11KeyID", "[", "]", "byte", ",", "passRetriever", "notary", ".", "PassRetriever", ",", "payload", "[", "]", "byte", ")", "(", "[", "]", "byte", ",", "erro...
// sign returns a signature for a given signature request
[ "sign", "returns", "a", "signature", "for", "a", "given", "signature", "request" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L349-L406
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
ListKeys
func (s *YubiStore) ListKeys() map[string]trustmanager.KeyInfo { if len(s.keys) > 0 { return buildKeyMap(s.keys) } ctx, session, err := SetupHSMEnv(pkcs11Lib, s.libLoader) if err != nil { logrus.Debugf("No yubikey found, using alternative key storage: %s", err.Error()) return nil } defer cleanup(ctx, sessio...
go
func (s *YubiStore) ListKeys() map[string]trustmanager.KeyInfo { if len(s.keys) > 0 { return buildKeyMap(s.keys) } ctx, session, err := SetupHSMEnv(pkcs11Lib, s.libLoader) if err != nil { logrus.Debugf("No yubikey found, using alternative key storage: %s", err.Error()) return nil } defer cleanup(ctx, sessio...
[ "func", "(", "s", "*", "YubiStore", ")", "ListKeys", "(", ")", "map", "[", "string", "]", "trustmanager", ".", "KeyInfo", "{", "if", "len", "(", "s", ".", "keys", ")", ">", "0", "{", "return", "buildKeyMap", "(", "s", ".", "keys", ")", "\n", "}",...
// ListKeys returns a list of keys in the yubikey store
[ "ListKeys", "returns", "a", "list", "of", "keys", "in", "the", "yubikey", "store" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L661-L680
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
AddKey
func (s *YubiStore) AddKey(keyInfo trustmanager.KeyInfo, privKey data.PrivateKey) error { added, err := s.addKey(privKey.ID(), keyInfo.Role, privKey) if err != nil { return err } if added && s.backupStore != nil { err = s.backupStore.AddKey(keyInfo, privKey) if err != nil { defer s.RemoveKey(privKey.ID()) ...
go
func (s *YubiStore) AddKey(keyInfo trustmanager.KeyInfo, privKey data.PrivateKey) error { added, err := s.addKey(privKey.ID(), keyInfo.Role, privKey) if err != nil { return err } if added && s.backupStore != nil { err = s.backupStore.AddKey(keyInfo, privKey) if err != nil { defer s.RemoveKey(privKey.ID()) ...
[ "func", "(", "s", "*", "YubiStore", ")", "AddKey", "(", "keyInfo", "trustmanager", ".", "KeyInfo", ",", "privKey", "data", ".", "PrivateKey", ")", "error", "{", "added", ",", "err", ":=", "s", ".", "addKey", "(", "privKey", ".", "ID", "(", ")", ",", ...
// AddKey puts a key inside the Yubikey, as well as writing it to the backup store
[ "AddKey", "puts", "a", "key", "inside", "the", "Yubikey", "as", "well", "as", "writing", "it", "to", "the", "backup", "store" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L683-L696
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
addKey
func (s *YubiStore) addKey(keyID string, role data.RoleName, privKey data.PrivateKey) ( bool, error) { // We only allow adding root keys for now if role != data.CanonicalRootRole { return false, fmt.Errorf( "yubikey only supports storing root keys, got %s for key: %s", role, keyID) } ctx, session, err := Se...
go
func (s *YubiStore) addKey(keyID string, role data.RoleName, privKey data.PrivateKey) ( bool, error) { // We only allow adding root keys for now if role != data.CanonicalRootRole { return false, fmt.Errorf( "yubikey only supports storing root keys, got %s for key: %s", role, keyID) } ctx, session, err := Se...
[ "func", "(", "s", "*", "YubiStore", ")", "addKey", "(", "keyID", "string", ",", "role", "data", ".", "RoleName", ",", "privKey", "data", ".", "PrivateKey", ")", "(", "bool", ",", "error", ")", "{", "// We only allow adding root keys for now", "if", "role", ...
// Only add if we haven't seen the key already. Return whether the key was // added.
[ "Only", "add", "if", "we", "haven", "t", "seen", "the", "key", "already", ".", "Return", "whether", "the", "key", "was", "added", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L700-L742
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
GetKeyInfo
func (s *YubiStore) GetKeyInfo(keyID string) (trustmanager.KeyInfo, error) { return trustmanager.KeyInfo{}, fmt.Errorf("Not yet implemented") }
go
func (s *YubiStore) GetKeyInfo(keyID string) (trustmanager.KeyInfo, error) { return trustmanager.KeyInfo{}, fmt.Errorf("Not yet implemented") }
[ "func", "(", "s", "*", "YubiStore", ")", "GetKeyInfo", "(", "keyID", "string", ")", "(", "trustmanager", ".", "KeyInfo", ",", "error", ")", "{", "return", "trustmanager", ".", "KeyInfo", "{", "}", ",", "fmt", ".", "Errorf", "(", "\"", "\"", ")", "\n"...
// GetKeyInfo is not yet implemented
[ "GetKeyInfo", "is", "not", "yet", "implemented" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L804-L806
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
SetupHSMEnv
func SetupHSMEnv(libraryPath string, libLoader pkcs11LibLoader) ( IPKCS11Ctx, pkcs11.SessionHandle, error) { if libraryPath == "" { return nil, 0, errHSMNotPresent{err: "no library found"} } p := libLoader(libraryPath) if p == nil { return nil, 0, fmt.Errorf("failed to load library %s", libraryPath) } if ...
go
func SetupHSMEnv(libraryPath string, libLoader pkcs11LibLoader) ( IPKCS11Ctx, pkcs11.SessionHandle, error) { if libraryPath == "" { return nil, 0, errHSMNotPresent{err: "no library found"} } p := libLoader(libraryPath) if p == nil { return nil, 0, fmt.Errorf("failed to load library %s", libraryPath) } if ...
[ "func", "SetupHSMEnv", "(", "libraryPath", "string", ",", "libLoader", "pkcs11LibLoader", ")", "(", "IPKCS11Ctx", ",", "pkcs11", ".", "SessionHandle", ",", "error", ")", "{", "if", "libraryPath", "==", "\"", "\"", "{", "return", "nil", ",", "0", ",", "errH...
// SetupHSMEnv is a method that depends on the existences
[ "SetupHSMEnv", "is", "a", "method", "that", "depends", "on", "the", "existences" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L825-L867
train
theupdateframework/notary
trustmanager/yubikey/yubikeystore.go
IsAccessible
func IsAccessible() bool { if pkcs11Lib == "" { return false } ctx, session, err := SetupHSMEnv(pkcs11Lib, defaultLoader) if err != nil { return false } defer cleanup(ctx, session) return true }
go
func IsAccessible() bool { if pkcs11Lib == "" { return false } ctx, session, err := SetupHSMEnv(pkcs11Lib, defaultLoader) if err != nil { return false } defer cleanup(ctx, session) return true }
[ "func", "IsAccessible", "(", ")", "bool", "{", "if", "pkcs11Lib", "==", "\"", "\"", "{", "return", "false", "\n", "}", "\n", "ctx", ",", "session", ",", "err", ":=", "SetupHSMEnv", "(", "pkcs11Lib", ",", "defaultLoader", ")", "\n", "if", "err", "!=", ...
// IsAccessible returns true if a Yubikey can be accessed
[ "IsAccessible", "returns", "true", "if", "a", "Yubikey", "can", "be", "accessed" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/yubikeystore.go#L870-L880
train
theupdateframework/notary
tuf/signed/verifiers.go
Verify
func (v Ed25519Verifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { if key.Algorithm() != data.ED25519Key { return ErrInvalidKeyType{} } sigBytes := make([]byte, ed25519.SignatureSize) if len(sig) != ed25519.SignatureSize { logrus.Debugf("signature length is incorrect, must be %d, was %d.", ed25...
go
func (v Ed25519Verifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { if key.Algorithm() != data.ED25519Key { return ErrInvalidKeyType{} } sigBytes := make([]byte, ed25519.SignatureSize) if len(sig) != ed25519.SignatureSize { logrus.Debugf("signature length is incorrect, must be %d, was %d.", ed25...
[ "func", "(", "v", "Ed25519Verifier", ")", "Verify", "(", "key", "data", ".", "PublicKey", ",", "sig", "[", "]", "byte", ",", "msg", "[", "]", "byte", ")", "error", "{", "if", "key", ".", "Algorithm", "(", ")", "!=", "data", ".", "ED25519Key", "{", ...
// Verify checks that an ed25519 signature is valid
[ "Verify", "checks", "that", "an", "ed25519", "signature", "is", "valid" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verifiers.go#L38-L66
train
theupdateframework/notary
tuf/signed/verifiers.go
Verify
func (v RSAPKCS1v15Verifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { // will return err if keytype is not a recognized RSA type pubKey, err := getRSAPubKey(key) if err != nil { return err } digest := sha256.Sum256(msg) rsaPub, ok := pubKey.(*rsa.PublicKey) if !ok { logrus.Debugf("value wa...
go
func (v RSAPKCS1v15Verifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { // will return err if keytype is not a recognized RSA type pubKey, err := getRSAPubKey(key) if err != nil { return err } digest := sha256.Sum256(msg) rsaPub, ok := pubKey.(*rsa.PublicKey) if !ok { logrus.Debugf("value wa...
[ "func", "(", "v", "RSAPKCS1v15Verifier", ")", "Verify", "(", "key", "data", ".", "PublicKey", ",", "sig", "[", "]", "byte", ",", "msg", "[", "]", "byte", ")", "error", "{", "// will return err if keytype is not a recognized RSA type", "pubKey", ",", "err", ":=...
// Verify does the actual verification
[ "Verify", "does", "the", "actual", "verification" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verifiers.go#L146-L175
train
theupdateframework/notary
tuf/signed/verifiers.go
Verify
func (v RSAPyCryptoVerifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { digest := sha256.Sum256(msg) if key.Algorithm() != data.RSAKey { return ErrInvalidKeyType{} } k, _ := pem.Decode([]byte(key.Public())) if k == nil { logrus.Debugf("failed to decode PEM-encoded x509 certificate") return E...
go
func (v RSAPyCryptoVerifier) Verify(key data.PublicKey, sig []byte, msg []byte) error { digest := sha256.Sum256(msg) if key.Algorithm() != data.RSAKey { return ErrInvalidKeyType{} } k, _ := pem.Decode([]byte(key.Public())) if k == nil { logrus.Debugf("failed to decode PEM-encoded x509 certificate") return E...
[ "func", "(", "v", "RSAPyCryptoVerifier", ")", "Verify", "(", "key", "data", ".", "PublicKey", ",", "sig", "[", "]", "byte", ",", "msg", "[", "]", "byte", ")", "error", "{", "digest", ":=", "sha256", ".", "Sum256", "(", "msg", ")", "\n", "if", "key"...
// Verify does the actual check. // N.B. We have not been able to make this work in a way that is compatible // with PyCrypto.
[ "Verify", "does", "the", "actual", "check", ".", "N", ".", "B", ".", "We", "have", "not", "been", "able", "to", "make", "this", "work", "in", "a", "way", "that", "is", "compatible", "with", "PyCrypto", "." ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/signed/verifiers.go#L183-L202
train
theupdateframework/notary
signer/keydbstore/keydbstore.go
generatePrivateKey
func generatePrivateKey(algorithm string) (data.PrivateKey, error) { var privKey data.PrivateKey var err error switch algorithm { case data.ECDSAKey: privKey, err = utils.GenerateECDSAKey(rand.Reader) if err != nil { return nil, fmt.Errorf("failed to generate EC key: %v", err) } case data.ED25519Key: pr...
go
func generatePrivateKey(algorithm string) (data.PrivateKey, error) { var privKey data.PrivateKey var err error switch algorithm { case data.ECDSAKey: privKey, err = utils.GenerateECDSAKey(rand.Reader) if err != nil { return nil, fmt.Errorf("failed to generate EC key: %v", err) } case data.ED25519Key: pr...
[ "func", "generatePrivateKey", "(", "algorithm", "string", ")", "(", "data", ".", "PrivateKey", ",", "error", ")", "{", "var", "privKey", "data", ".", "PrivateKey", "\n", "var", "err", "error", "\n", "switch", "algorithm", "{", "case", "data", ".", "ECDSAKe...
// helper function to generate private keys for the signer databases - does not implement RSA since that is not // supported by the signer
[ "helper", "function", "to", "generate", "private", "keys", "for", "the", "signer", "databases", "-", "does", "not", "implement", "RSA", "since", "that", "is", "not", "supported", "by", "the", "signer" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/signer/keydbstore/keydbstore.go#L33-L51
train
theupdateframework/notary
tuf/data/serializer.go
Unmarshal
func (c canonicalJSON) Unmarshal(from []byte, to interface{}) error { return json.Unmarshal(from, to) }
go
func (c canonicalJSON) Unmarshal(from []byte, to interface{}) error { return json.Unmarshal(from, to) }
[ "func", "(", "c", "canonicalJSON", ")", "Unmarshal", "(", "from", "[", "]", "byte", ",", "to", "interface", "{", "}", ")", "error", "{", "return", "json", ".", "Unmarshal", "(", "from", ",", "to", ")", "\n", "}" ]
// Unmarshal unmarshals some JSON bytes
[ "Unmarshal", "unmarshals", "some", "JSON", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/serializer.go#L27-L29
train
theupdateframework/notary
tuf/data/timestamp.go
IsValidTimestampStructure
func IsValidTimestampStructure(t Timestamp) error { expectedType := TUFTypes[CanonicalTimestampRole] if t.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalTimestampRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, t.Type)} } if t.Version < 1 { return ErrInvalidMetadata{ rol...
go
func IsValidTimestampStructure(t Timestamp) error { expectedType := TUFTypes[CanonicalTimestampRole] if t.Type != expectedType { return ErrInvalidMetadata{ role: CanonicalTimestampRole, msg: fmt.Sprintf("expected type %s, not %s", expectedType, t.Type)} } if t.Version < 1 { return ErrInvalidMetadata{ rol...
[ "func", "IsValidTimestampStructure", "(", "t", "Timestamp", ")", "error", "{", "expectedType", ":=", "TUFTypes", "[", "CanonicalTimestampRole", "]", "\n", "if", "t", ".", "Type", "!=", "expectedType", "{", "return", "ErrInvalidMetadata", "{", "role", ":", "Canon...
// IsValidTimestampStructure returns an error, or nil, depending on whether the content of the struct // is valid for timestamp metadata. This does not check signatures or expiry, just that // the metadata content is valid.
[ "IsValidTimestampStructure", "returns", "an", "error", "or", "nil", "depending", "on", "whether", "the", "content", "of", "the", "struct", "is", "valid", "for", "timestamp", "metadata", ".", "This", "does", "not", "check", "signatures", "or", "expiry", "just", ...
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L27-L54
train
theupdateframework/notary
tuf/data/timestamp.go
NewTimestamp
func NewTimestamp(snapshot *Signed) (*SignedTimestamp, error) { snapshotJSON, err := json.Marshal(snapshot) if err != nil { return nil, err } snapshotMeta, err := NewFileMeta(bytes.NewReader(snapshotJSON), NotaryDefaultHashes...) if err != nil { return nil, err } return &SignedTimestamp{ Signatures: make([...
go
func NewTimestamp(snapshot *Signed) (*SignedTimestamp, error) { snapshotJSON, err := json.Marshal(snapshot) if err != nil { return nil, err } snapshotMeta, err := NewFileMeta(bytes.NewReader(snapshotJSON), NotaryDefaultHashes...) if err != nil { return nil, err } return &SignedTimestamp{ Signatures: make([...
[ "func", "NewTimestamp", "(", "snapshot", "*", "Signed", ")", "(", "*", "SignedTimestamp", ",", "error", ")", "{", "snapshotJSON", ",", "err", ":=", "json", ".", "Marshal", "(", "snapshot", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",",...
// NewTimestamp initializes a timestamp with an existing snapshot
[ "NewTimestamp", "initializes", "a", "timestamp", "with", "an", "existing", "snapshot" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L57-L79
train
theupdateframework/notary
tuf/data/timestamp.go
ToSigned
func (ts *SignedTimestamp) ToSigned() (*Signed, error) { s, err := defaultSerializer.MarshalCanonical(ts.Signed) if err != nil { return nil, err } signed := json.RawMessage{} err = signed.UnmarshalJSON(s) if err != nil { return nil, err } sigs := make([]Signature, len(ts.Signatures)) copy(sigs, ts.Signatur...
go
func (ts *SignedTimestamp) ToSigned() (*Signed, error) { s, err := defaultSerializer.MarshalCanonical(ts.Signed) if err != nil { return nil, err } signed := json.RawMessage{} err = signed.UnmarshalJSON(s) if err != nil { return nil, err } sigs := make([]Signature, len(ts.Signatures)) copy(sigs, ts.Signatur...
[ "func", "(", "ts", "*", "SignedTimestamp", ")", "ToSigned", "(", ")", "(", "*", "Signed", ",", "error", ")", "{", "s", ",", "err", ":=", "defaultSerializer", ".", "MarshalCanonical", "(", "ts", ".", "Signed", ")", "\n", "if", "err", "!=", "nil", "{",...
// ToSigned partially serializes a SignedTimestamp such that it can // be signed
[ "ToSigned", "partially", "serializes", "a", "SignedTimestamp", "such", "that", "it", "can", "be", "signed" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L83-L99
train
theupdateframework/notary
tuf/data/timestamp.go
GetSnapshot
func (ts *SignedTimestamp) GetSnapshot() (*FileMeta, error) { snapshotExpected, ok := ts.Signed.Meta[CanonicalSnapshotRole.String()] if !ok { return nil, ErrMissingMeta{Role: CanonicalSnapshotRole.String()} } return &snapshotExpected, nil }
go
func (ts *SignedTimestamp) GetSnapshot() (*FileMeta, error) { snapshotExpected, ok := ts.Signed.Meta[CanonicalSnapshotRole.String()] if !ok { return nil, ErrMissingMeta{Role: CanonicalSnapshotRole.String()} } return &snapshotExpected, nil }
[ "func", "(", "ts", "*", "SignedTimestamp", ")", "GetSnapshot", "(", ")", "(", "*", "FileMeta", ",", "error", ")", "{", "snapshotExpected", ",", "ok", ":=", "ts", ".", "Signed", ".", "Meta", "[", "CanonicalSnapshotRole", ".", "String", "(", ")", "]", "\...
// GetSnapshot gets the expected snapshot metadata hashes in the timestamp metadata, // or nil if it doesn't exist
[ "GetSnapshot", "gets", "the", "expected", "snapshot", "metadata", "hashes", "in", "the", "timestamp", "metadata", "or", "nil", "if", "it", "doesn", "t", "exist" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L103-L109
train
theupdateframework/notary
tuf/data/timestamp.go
MarshalJSON
func (ts *SignedTimestamp) MarshalJSON() ([]byte, error) { signed, err := ts.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
go
func (ts *SignedTimestamp) MarshalJSON() ([]byte, error) { signed, err := ts.ToSigned() if err != nil { return nil, err } return defaultSerializer.Marshal(signed) }
[ "func", "(", "ts", "*", "SignedTimestamp", ")", "MarshalJSON", "(", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "signed", ",", "err", ":=", "ts", ".", "ToSigned", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "err",...
// MarshalJSON returns the serialized form of SignedTimestamp as bytes
[ "MarshalJSON", "returns", "the", "serialized", "form", "of", "SignedTimestamp", "as", "bytes" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L112-L118
train
theupdateframework/notary
tuf/data/timestamp.go
TimestampFromSigned
func TimestampFromSigned(s *Signed) (*SignedTimestamp, error) { ts := Timestamp{} if err := defaultSerializer.Unmarshal(*s.Signed, &ts); err != nil { return nil, err } if err := IsValidTimestampStructure(ts); err != nil { return nil, err } sigs := make([]Signature, len(s.Signatures)) copy(sigs, s.Signatures)...
go
func TimestampFromSigned(s *Signed) (*SignedTimestamp, error) { ts := Timestamp{} if err := defaultSerializer.Unmarshal(*s.Signed, &ts); err != nil { return nil, err } if err := IsValidTimestampStructure(ts); err != nil { return nil, err } sigs := make([]Signature, len(s.Signatures)) copy(sigs, s.Signatures)...
[ "func", "TimestampFromSigned", "(", "s", "*", "Signed", ")", "(", "*", "SignedTimestamp", ",", "error", ")", "{", "ts", ":=", "Timestamp", "{", "}", "\n", "if", "err", ":=", "defaultSerializer", ".", "Unmarshal", "(", "*", "s", ".", "Signed", ",", "&",...
// TimestampFromSigned parsed a Signed object into a fully unpacked // SignedTimestamp
[ "TimestampFromSigned", "parsed", "a", "Signed", "object", "into", "a", "fully", "unpacked", "SignedTimestamp" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/timestamp.go#L122-L136
train
theupdateframework/notary
trustmanager/yubikey/import.go
Set
func (s *YubiImport) Set(name string, bytes []byte) error { block, _ := pem.Decode(bytes) if block == nil { return errors.New("invalid PEM data, could not parse") } role, ok := block.Headers["role"] if !ok { return errors.New("no role found for key") } ki := trustmanager.KeyInfo{ // GUN is ignored by YubiS...
go
func (s *YubiImport) Set(name string, bytes []byte) error { block, _ := pem.Decode(bytes) if block == nil { return errors.New("invalid PEM data, could not parse") } role, ok := block.Headers["role"] if !ok { return errors.New("no role found for key") } ki := trustmanager.KeyInfo{ // GUN is ignored by YubiS...
[ "func", "(", "s", "*", "YubiImport", ")", "Set", "(", "name", "string", ",", "bytes", "[", "]", "byte", ")", "error", "{", "block", ",", "_", ":=", "pem", ".", "Decode", "(", "bytes", ")", "\n", "if", "block", "==", "nil", "{", "return", "errors"...
// Set determines if we are allowed to set the given key on the Yubikey and // calls through to YubiStore.AddKey if it's valid
[ "Set", "determines", "if", "we", "are", "allowed", "to", "set", "the", "given", "key", "on", "the", "Yubikey", "and", "calls", "through", "to", "YubiStore", ".", "AddKey", "if", "it", "s", "valid" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/trustmanager/yubikey/import.go#L33-L59
train
theupdateframework/notary
server/storage/errors.go
Error
func (err ErrKeyExists) Error() string { return fmt.Sprintf("Error, timestamp key already exists for %s:%s", err.gun, err.role) }
go
func (err ErrKeyExists) Error() string { return fmt.Sprintf("Error, timestamp key already exists for %s:%s", err.gun, err.role) }
[ "func", "(", "err", "ErrKeyExists", ")", "Error", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "err", ".", "gun", ",", "err", ".", "role", ")", "\n", "}" ]
// ErrKeyExists is returned when a key already exists
[ "ErrKeyExists", "is", "returned", "when", "a", "key", "already", "exists" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/server/storage/errors.go#L30-L32
train
theupdateframework/notary
tuf/data/keys.go
IDs
func (ks KeyList) IDs() []string { keyIDs := make([]string, 0, len(ks)) for _, k := range ks { keyIDs = append(keyIDs, k.ID()) } return keyIDs }
go
func (ks KeyList) IDs() []string { keyIDs := make([]string, 0, len(ks)) for _, k := range ks { keyIDs = append(keyIDs, k.ID()) } return keyIDs }
[ "func", "(", "ks", "KeyList", ")", "IDs", "(", ")", "[", "]", "string", "{", "keyIDs", ":=", "make", "(", "[", "]", "string", ",", "0", ",", "len", "(", "ks", ")", ")", "\n", "for", "_", ",", "k", ":=", "range", "ks", "{", "keyIDs", "=", "a...
// IDs generates a list of the hex encoded key IDs in the KeyList
[ "IDs", "generates", "a", "list", "of", "the", "hex", "encoded", "key", "IDs", "in", "the", "KeyList" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L81-L87
train
theupdateframework/notary
tuf/data/keys.go
NewPublicKey
func NewPublicKey(alg string, public []byte) PublicKey { tk := TUFKey{ Type: alg, Value: KeyPair{ Public: public, }, } return typedPublicKey(tk) }
go
func NewPublicKey(alg string, public []byte) PublicKey { tk := TUFKey{ Type: alg, Value: KeyPair{ Public: public, }, } return typedPublicKey(tk) }
[ "func", "NewPublicKey", "(", "alg", "string", ",", "public", "[", "]", "byte", ")", "PublicKey", "{", "tk", ":=", "TUFKey", "{", "Type", ":", "alg", ",", "Value", ":", "KeyPair", "{", "Public", ":", "public", ",", "}", ",", "}", "\n", "return", "ty...
// NewPublicKey creates a new, correctly typed PublicKey, using the // UnknownPublicKey catchall for unsupported ciphers
[ "NewPublicKey", "creates", "a", "new", "correctly", "typed", "PublicKey", "using", "the", "UnknownPublicKey", "catchall", "for", "unsupported", "ciphers" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L153-L161
train
theupdateframework/notary
tuf/data/keys.go
NewPrivateKey
func NewPrivateKey(pubKey PublicKey, private []byte) (PrivateKey, error) { tk := TUFKey{ Type: pubKey.Algorithm(), Value: KeyPair{ Public: pubKey.Public(), Private: private, // typedPrivateKey moves this value }, } return typedPrivateKey(tk) }
go
func NewPrivateKey(pubKey PublicKey, private []byte) (PrivateKey, error) { tk := TUFKey{ Type: pubKey.Algorithm(), Value: KeyPair{ Public: pubKey.Public(), Private: private, // typedPrivateKey moves this value }, } return typedPrivateKey(tk) }
[ "func", "NewPrivateKey", "(", "pubKey", "PublicKey", ",", "private", "[", "]", "byte", ")", "(", "PrivateKey", ",", "error", ")", "{", "tk", ":=", "TUFKey", "{", "Type", ":", "pubKey", ".", "Algorithm", "(", ")", ",", "Value", ":", "KeyPair", "{", "P...
// NewPrivateKey creates a new, correctly typed PrivateKey, using the // UnknownPrivateKey catchall for unsupported ciphers
[ "NewPrivateKey", "creates", "a", "new", "correctly", "typed", "PrivateKey", "using", "the", "UnknownPrivateKey", "catchall", "for", "unsupported", "ciphers" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L165-L174
train
theupdateframework/notary
tuf/data/keys.go
UnmarshalPublicKey
func UnmarshalPublicKey(data []byte) (PublicKey, error) { var parsed TUFKey err := json.Unmarshal(data, &parsed) if err != nil { return nil, err } return typedPublicKey(parsed), nil }
go
func UnmarshalPublicKey(data []byte) (PublicKey, error) { var parsed TUFKey err := json.Unmarshal(data, &parsed) if err != nil { return nil, err } return typedPublicKey(parsed), nil }
[ "func", "UnmarshalPublicKey", "(", "data", "[", "]", "byte", ")", "(", "PublicKey", ",", "error", ")", "{", "var", "parsed", "TUFKey", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "parsed", ")", "\n", "if", "err", "!=", "nil", ...
// UnmarshalPublicKey is used to parse individual public keys in JSON
[ "UnmarshalPublicKey", "is", "used", "to", "parse", "individual", "public", "keys", "in", "JSON" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L177-L184
train
theupdateframework/notary
tuf/data/keys.go
UnmarshalPrivateKey
func UnmarshalPrivateKey(data []byte) (PrivateKey, error) { var parsed TUFKey err := json.Unmarshal(data, &parsed) if err != nil { return nil, err } return typedPrivateKey(parsed) }
go
func UnmarshalPrivateKey(data []byte) (PrivateKey, error) { var parsed TUFKey err := json.Unmarshal(data, &parsed) if err != nil { return nil, err } return typedPrivateKey(parsed) }
[ "func", "UnmarshalPrivateKey", "(", "data", "[", "]", "byte", ")", "(", "PrivateKey", ",", "error", ")", "{", "var", "parsed", "TUFKey", "\n", "err", ":=", "json", ".", "Unmarshal", "(", "data", ",", "&", "parsed", ")", "\n", "if", "err", "!=", "nil"...
// UnmarshalPrivateKey is used to parse individual private keys in JSON
[ "UnmarshalPrivateKey", "is", "used", "to", "parse", "individual", "private", "keys", "in", "JSON" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L187-L194
train
theupdateframework/notary
tuf/data/keys.go
ID
func (k *TUFKey) ID() string { if k.id == "" { pubK := TUFKey{ Type: k.Algorithm(), Value: KeyPair{ Public: k.Public(), Private: nil, }, } data, err := json.MarshalCanonical(&pubK) if err != nil { logrus.Error("Error generating key ID:", err) } digest := sha256.Sum256(data) k.id = he...
go
func (k *TUFKey) ID() string { if k.id == "" { pubK := TUFKey{ Type: k.Algorithm(), Value: KeyPair{ Public: k.Public(), Private: nil, }, } data, err := json.MarshalCanonical(&pubK) if err != nil { logrus.Error("Error generating key ID:", err) } digest := sha256.Sum256(data) k.id = he...
[ "func", "(", "k", "*", "TUFKey", ")", "ID", "(", ")", "string", "{", "if", "k", ".", "id", "==", "\"", "\"", "{", "pubK", ":=", "TUFKey", "{", "Type", ":", "k", ".", "Algorithm", "(", ")", ",", "Value", ":", "KeyPair", "{", "Public", ":", "k"...
// ID efficiently generates if necessary, and caches the ID of the key
[ "ID", "efficiently", "generates", "if", "necessary", "and", "caches", "the", "ID", "of", "the", "key" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L213-L230
train
theupdateframework/notary
tuf/data/keys.go
NewECDSAPublicKey
func NewECDSAPublicKey(public []byte) *ECDSAPublicKey { return &ECDSAPublicKey{ TUFKey: TUFKey{ Type: ECDSAKey, Value: KeyPair{ Public: public, Private: nil, }, }, } }
go
func NewECDSAPublicKey(public []byte) *ECDSAPublicKey { return &ECDSAPublicKey{ TUFKey: TUFKey{ Type: ECDSAKey, Value: KeyPair{ Public: public, Private: nil, }, }, } }
[ "func", "NewECDSAPublicKey", "(", "public", "[", "]", "byte", ")", "*", "ECDSAPublicKey", "{", "return", "&", "ECDSAPublicKey", "{", "TUFKey", ":", "TUFKey", "{", "Type", ":", "ECDSAKey", ",", "Value", ":", "KeyPair", "{", "Public", ":", "public", ",", "...
// NewECDSAPublicKey initializes a new public key with the ECDSAKey type
[ "NewECDSAPublicKey", "initializes", "a", "new", "public", "key", "with", "the", "ECDSAKey", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L275-L285
train
theupdateframework/notary
tuf/data/keys.go
NewECDSAx509PublicKey
func NewECDSAx509PublicKey(public []byte) *ECDSAx509PublicKey { return &ECDSAx509PublicKey{ TUFKey: TUFKey{ Type: ECDSAx509Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
go
func NewECDSAx509PublicKey(public []byte) *ECDSAx509PublicKey { return &ECDSAx509PublicKey{ TUFKey: TUFKey{ Type: ECDSAx509Key, Value: KeyPair{ Public: public, Private: nil, }, }, } }
[ "func", "NewECDSAx509PublicKey", "(", "public", "[", "]", "byte", ")", "*", "ECDSAx509PublicKey", "{", "return", "&", "ECDSAx509PublicKey", "{", "TUFKey", ":", "TUFKey", "{", "Type", ":", "ECDSAx509Key", ",", "Value", ":", "KeyPair", "{", "Public", ":", "pub...
// NewECDSAx509PublicKey initializes a new public key with the ECDSAx509Key type
[ "NewECDSAx509PublicKey", "initializes", "a", "new", "public", "key", "with", "the", "ECDSAx509Key", "type" ]
8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5
https://github.com/theupdateframework/notary/blob/8ff3ca06ec48f31e1f1d2685e3e6a9f65b6b92b5/tuf/data/keys.go#L288-L298
train