This means that the server cannot accept any roots not signed by an
x509 key whose GUN doesn't match the GUN being updated.
Signed-off-by: Ying Li <ying.li@docker.com>
already have a ErrMismatchedChecksum in tuf/data/errors.
Also, have the CheckHashes function take a role name so that the
ErrMismatchedChecksum error can include the role name.
Signed-off-by: Ying Li <ying.li@docker.com>
signed.VerifySignatures. So remove signed.VerifyRoot and just use signed.VerifySignatures
instead. Also, to fix some tests, add an additional check for version when validating
metadata since versions can't be negative.
Signed-off-by: Ying Li <ying.li@docker.com>
the server validation requirements at all, just the previous root role
(as opposed to a single old key being required)
Signed-off-by: Ying Li <ying.li@docker.com>
Ordinarily we don't want to continue operating on signed data if the
role's threshold of signatures cannot be me and the signature is unsuable.
OTOH we want to keep signing root.json with all older keys if they are
available (to allow migration), but in that case a missing key is not a
fatal error.
So, split the keys passed to signed.Sign into primary and optional,
treating all current uses as primary and enforcing the role's threshold
only on primary keys. Also update the single existing test which uses
a missing/unusable key to use the optionalKeys parameter.
Note that only the _presence_ of optionalKeys is optional; if an
optional key exists but signing using it fails, the function will fail.
This temporarily breaks the second ErrInsufficientSignatures check
(optional keys count against the role threshold), but that will be fixed
soon.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
Tell signed.Sign how many signatures are necessary to sign a role, and
have it fail if it cannot create that many.
For most uses this does not make much of a difference because the
threshold tends to be 1 and signed.Sign was already failing if no key
could be found or if no signature could be created; only >1-threshold
roles now (correctly) fail in additional situations. But the knowledge
of a role’s threshold will be useful in a future commit.
Always use ErrInsufficientSignatures for this failure, whether this is
when loading the keys or actually using them (also fixing
ErrInsufficentSignature documentation to refer to signing and not
verification). ErrNoKeys is no longer returned by signed.Sign.
So, adjust the “snapshot key is not available” logic in
NotaryRepository.Publish accordingly, which also makes it more precise
(actually triggering only when no snapshot key is available).
Now that role's threshold is enforced when signing, update
TestValidateRootInvalidTimestampThreshold to create the second key
necessary to correctly sign the timestamp role.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This is a refactoring with no behavior change, but it will allow adding
more parameters to the function in the future.
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
embedded in Targets. This way we can easily get a SignedCommon object
out after calling RootFromSigned, etc.
Signed-off-by: Ying Li <ying.li@docker.com>
This is in preparation for the server validation automatically generating a snapshot
when an update is applied.
Signed-off-by: Ying Li <ying.li@docker.com>
This is in preparation for the server validation automatically generating a timestamp
when an update is applied.
Signed-off-by: Ying Li <ying.li@docker.com>
Reduce function "snapshotExpired" in a simpler form and replace the
literal string by the constants defined in the data package.
Signed-off-by: Hu Keping <hukeping@huawei.com>