Commit Graph

25 Commits

Author SHA1 Message Date
Riyaz Faizullabhoy ed1bf1a0a6 Address review comments
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 17:00:12 -07:00
Ying Li 65851590f6 Add a client update test for root rotations that test that the previous root ROLE is satisfied,
as opposed to just requiring we also sign with whatever key the previous root was signed with.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-19 15:14:14 -07:00
Ying Li 8be82b31f0 Revert "Modify signed.Sign to replace, not add, signatures."
This reverts commit aca1cf6d43ce9aa423a9de21ac5bcdca35cbe811, and modifies a test to expect 2 signatures.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-13 11:48:36 -07:00
Miloslav Trmač 816c1c980c Modify signed.Sign to replace, not add, signatures.
The only thing depending on signed.Sign keeping old signatures was two
tests; all real users were modifying the signed data without clearing
the old signatures, and therefore implicitly relying on signing with
the keys which were used for the old signatures as well.

This broke signing an updated root with a new certificate when the old
certificate was no longer available.

It could have been fixed by keeping signed.Sign as is and adding the
clearing to all users, but noting actually needs the appending
semantics, the appending semantics is surprising, and switching to
replacing signatures is less code.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2016-04-13 11:48:36 -07:00
Miloslav Trmač aa596338a6 Add an optionalKeys parameter to signed.Sign
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>
2016-04-13 11:48:36 -07:00
Miloslav Trmač f23f2093e3 Create enough signatures as role's threshold requires
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>
2016-04-13 11:48:36 -07:00
Miloslav Trmač a5da680e90 Modify signed.Sign to use a slice instead of varargs
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>
2016-04-13 11:48:36 -07:00
David Lawrence bfee37d471 update top level Signed.Signed to be a *json.RawMessage
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2016-03-18 16:18:53 -07:00
Riyaz Faizullabhoy 9ecd899e25 Removing key import and gun from cryptoservice
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-18 11:31:03 -07:00
HuKeping 206d02ab4d [PATCH 4/8] Add sha512 when updating
Actually there are two way to implement this.

One is check the present hash algorithm first and then only update
what we have.

The other is update/add both sha256 and sha512 no matter whether we
have the hash of sha512 or not.

Personally I prefer the latter, for it brings much less change of the
code and will also not affect the validate of the old clients.

Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-11 10:44:46 +08:00
Ying Li 1bfafa0b77 Add test to check that if a key is rotated, but the requisite piece of
metadata hasn't been resigned, that an update fails because the
cached version is no longer valid.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-03 09:22:26 -08:00
Ying Li 8ca8f073fa Have isValidRootRoleStructure take both role names in order to construct an ErrInvalidMetadata
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-22 19:39:54 -08:00
Ying Li 314cfb9a17 Add targets metadata validation to the targets data structure
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-22 19:16:32 -08:00
Ying Li 1e48fd35ff Use ToSigned in the swizzler
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-22 15:27:53 -08:00
Ying Li edb70b5474 Fix test bug where root role mutations weren't being tested
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-17 19:35:03 -08:00
Ying Li f0ddda1602 Add methods for mutating per-metadata data to swizzler
Signed-off-by: Ying Li <ying.li@docker.com>
2016-02-17 19:35:03 -08:00
David Lawrence c07c7b49c2 removing last vestiges of target download code
Signed-off-by: David Lawrence <david.lawrence@docker.com> (github: endophage)
2016-02-02 11:39:17 -08:00
Ying Li 237561a2a9 Fixed timestamp downloading so if verification fails, we fall back to cached.
Signed-off-by: Ying Li <ying.li@docker.com>

Conflicts:
	tuf/client/client.go
2016-01-29 11:05:21 -08:00
Ying Li bb5f9cc170 Update swizzler so that if messing up the root file, we can still get the pub keys and sign.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-01-29 11:01:31 -08:00
Ying Li a969db7a13 Add swizzler method to just change the checksum by adding a space.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-01-29 11:01:31 -08:00
Riyaz Faizullabhoy 41643d4a9c make -1 read up to 100MB of data, use for non-timestamps. Reduce
timestamp to 1MB max

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-01-28 10:17:17 -08:00
Riyaz Faizullabhoy a6159a45d1 ensure filestore GetMeta only returns up to size bytes. Standardize constant for max size
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-01-28 10:16:19 -08:00
Jessica Frazelle a64db12c04
change url from jfrazelle/go to docker/go
Signed-off-by: Jessica Frazelle <acidburn@docker.com>
2016-01-26 08:43:38 -08:00
Ying Li df53f51b0b Refactor swizzler to not produce a repo itself, but to just take some initial metadata.
Updated the testutils/repo.go utility to be able to produce a repository with delegations
and to export metadata from said repo instead.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-01-20 10:02:14 -08:00
Ying Li 4838a90640 Refactor metadata changers into a helper fuzzer object in testutils package.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-01-19 16:27:01 -08:00