| 1 | // Copyright The gittuf Authors |
| 2 | // SPDX-License-Identifier: Apache-2.0 |
| 3 | |
| 4 | package v01scip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/ |
| 5 | |
| 6 | // This package defines gittuf's take on TUF metadata. There are some minor |
| 7 | // changes, such as the addition of `custom` to delegation entries. Some of it, |
| 8 | // however, is inspired by or cloned from the go-tuf implementation. |
| 9 | |
| 10 | import ( |
| 11 | "errorsscip-go gomod github.com/golang/go/src go1.26.0 errors/" |
| 12 | |
| 13 | "github.com/gittuf/gittuf/internal/common/setscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/common/set`/" |
| 14 | "github.com/secure-systems-lab/go-securesystemslib/signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/" |
| 15 | ) |
| 16 | |
| 17 | var ErrTargetsNotEmptyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/ErrTargetsNotEmpty. = errorsscip-go gomod github.com/golang/go/src go1.26.0 errors/.Newscip-go gomod github.com/golang/go/src go1.26.0 errors/New().("`targets` field in gittuf Targets metadata must be empty") |
| 18 | |
| 19 | // Key defines the structure for how public keys are stored in TUF metadata. It |
| 20 | // implements the tuf.Principal and is used for backwards compatibility where a |
| 21 | // Principal is always represented directly by a signing key or identity. |
| 22 | type Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key# signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/.SSLibKeyscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey# |
| 23 | |
| 24 | // NewKeyFromSSLibKey converts the signerverifier.SSLibKey into a Key object. |
| 25 | func NewKeyFromSSLibKeyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/NewKeyFromSSLibKey().(key *signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/.SSLibKeyscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey#) *Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key# { |
| 26 | k := Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#(*key) |
| 27 | return &k |
| 28 | } |
| 29 | |
| 30 | // ID implements the key's identifier. It implements the Principal interface. |
| 31 | func (k *Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#) IDscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#ID().() string { |
| 32 | return k.KeyIDscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey#KeyID. |
| 33 | } |
| 34 | |
| 35 | // Keys returns the set of keys (using the signerverifier.SSLibKey definition) |
| 36 | // associated with the principal. |
| 37 | func (k *Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#) Keysscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#Keys().() []*signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/.SSLibKeyscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey# { |
| 38 | key := signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/.SSLibKeyscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey#(*k) |
| 39 | return []*signerverifierscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/.SSLibKeyscip-go gomod github.com/secure-systems-lab/go-securesystemslib v0.11.0 `github.com/secure-systems-lab/go-securesystemslib/signerverifier`/SSLibKey#{&key} |
| 40 | } |
| 41 | |
| 42 | func (k *Keyscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#) CustomMetadatascip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Key#CustomMetadata().() map[string]string { |
| 43 | // Key does not support custom metadata |
| 44 | return nil |
| 45 | } |
| 46 | |
| 47 | // Role records common characteristics recorded in a role entry in Root metadata |
| 48 | // and in a delegation entry. |
| 49 | type Rolescip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Role# struct { |
| 50 | KeyIDsscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Role#KeyIDs. *setscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/common/set`/.Setscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/common/set`/Set#[string] `json:"keyids"` |
| 51 | Thresholdscip-go gomod github.com/gittuf/gittuf . `github.com/gittuf/gittuf/internal/tuf/v01`/Role#Threshold. int `json:"threshold"` |
| 52 | } |