Commit Graph

352 Commits

Author SHA1 Message Date
Ying Li ab7064ea12 Change minimum required version of metadata to be 1, not 0
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-27 10:58:58 -07:00
Ying Li c9e91446a1 Builder interface cleanup and bugfixes:
- can never set an invalid repo, so we can remove the failed builder state
- once a builder is "finished", it's swapped out with one that has no state and cannot be modified
- add builder tests for the negative path cases where builder should error
- fix bug with GenerateSnapshot where we didn't check for a targets to be loaded when generating for the first time

This also adds some negative path tests (cases in which the builder errors due to invalid input or things not being loaded)

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-27 10:58:58 -07:00
Ying Li 5acab543e4 Update the client to have an old builder and a new builder, and to only use
cached version numbers to check downloaded version numbers of cached data
validates against the old builder.

This also removes the `GetRepo` function of the builder and adds some data
accessors instead that are necessary to do a consistent download and check
versions, that way the downloader doesn't need to fish around in the repo
itself for data in order to figure out what to download.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-27 10:58:58 -07:00
Ying Li 04ec865b31 Update all the server validation and generation code to use the builder.
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>
2016-04-27 10:58:58 -07:00
Ying Li 82c88e95a5 Convert bootstrap repo to use the builder
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-27 10:58:57 -07:00
Ying Li 5f3eaf411b Update the downloading client to use the builder.
Delete the remaining TUF client download tests because they are already covered by
the client update tests.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-27 10:58:57 -07:00
Riyaz Faizullabhoy 1976982685 Use ErrRootRotationFail when checking new root against old keys
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 17:00:12 -07:00
Riyaz Faizullabhoy ed1bf1a0a6 Address review comments
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 17:00:12 -07:00
Riyaz Faizullabhoy ca9fc99ba5 Goodbye Certstore
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 17:00:09 -07:00
Riyaz Faizullabhoy 01bbd532c6 Update update logic to error out on corrupted previous root metadata
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 16:59:22 -07:00
Riyaz Faizullabhoy 5901c87feb Update tests
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 16:59:22 -07:00
Riyaz Faizullabhoy 9da40f07da Foundation for removing certstore
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-26 16:59:22 -07:00
Ying Li 2d72c39e6c Add a few more tests for tuf/store/memorystore.
Also add a few tuf/client/client_test tests back that checks for download failure
if the local timestamp or snapshot is missing in the local TUF repo.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-20 17:00:40 -07:00
Ying Li 283c452737 A lot of tuf/client tests are redundant - move the ones that aren't to client_update_test
and just remove tuf/client/client_test.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-20 16:59:12 -07:00
Ying Li 053c2a5a79 Remove a redundant ErrChecksumMismatch error in tuf/client, since we
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>
2016-04-20 11:08:03 -07:00
Ying Li cc5211cdf6 Fix server validation and client update tests to also test threshold when testing
root rotation with the previous root role.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-19 15:14:14 -07:00
Ying Li 839a1d076f Add support for thresholds, which means signed.VerifyRoot needs to be have just like
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>
2016-04-19 15:14:14 -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
Riyaz Faizullabhoy 378116d37c Add empty hashes check for AddTarget
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-19 13:39:26 -07:00
Riyaz Faizullabhoy 94a2e3a741 Change config to disable_tofu instead of tofu
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-19 11:01:56 -07:00
Riyaz Faizullabhoy bbf51108c0 Rename certs package to trustpinning
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-19 11:01:55 -07:00
Riyaz Faizullabhoy 7d6fdc08cd Update function description for expected behavior, groundwork for config
in validation

Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-04-19 11:01:54 -07:00
Ying Li cea46f7c3e Change root cert rotation to be root key rotation instead
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-13 22:12:53 -07:00
Ying Li 708507adde Require signing with all previous roles, instead of just the immediately previous role
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-13 22:10:58 -07:00
Ying Li 160ea2bc54 Address review comments and improve docstrings
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-13 11:48:36 -07:00
Miloslav Trmač d835fbbca2 Implement root certificate rotation in NotaryRepository
NotaryRepository can now list root certificates, and
generate new versions (as changelists to be applied
on Publish).

This is a pretty mechanical encapsulation of the
root certificate rotation support in Repo.AddBaseKeys
and Repo.RemoveBaseKeys. The only slightly interesting
part is ListRootCert, which requires on-line access
to ensure fresh data, and depends on CertStore doing
some verification for us.

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
Ying Li cf4e726514 "make lint" wasn't actually linting every file in the repo. golint ./...
ignores buildtags, for instance, and somehow didn't pick up some code in
the signer.

This calls golint on every go file in the repo and also fixes some linting
issues, which involves renaming two yubikey functions to avoid stuttering.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-12 22:28:32 -07:00
Miloslav Trmač 14a563bb51 Add a few more descriptive comments
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
2016-04-12 14:33:45 -07:00
Ying Li f8c42e4cbf NotaryRepository.Update now just returns an error, rather than a client
an error, because we don't actually use the client anymore.

Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-06 14:08:08 -07:00
Ying Li 38cfb6f961 Change assert to require in client/changelist package.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-04-05 15:13:29 -07:00
HuKeping 0a60261fab Use constant for root role
Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-29 07:08:23 +08:00
HuKeping ddff581bd8 Use constant for targets role
Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-29 07:08:16 +08:00
HuKeping 67b0ec3771 Use constant for snapshot
Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-28 17:21:24 +08:00
Ying Li 3b80293a0c Add test cases generating a timestamp from previous timestamps
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-23 13:24:52 -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
Riyaz Faizullabhoy 2a37590ea6 update interface and comments
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-18 11:06:37 -07:00
Riyaz Faizullabhoy 95af5d4800 try cleaning up removekey, debugging tests
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-18 11:04:00 -07:00
Riyaz Faizullabhoy 351b247aec add tests for initial keystore state, and after removing and adding
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-18 11:03:11 -07:00
Riyaz Faizullabhoy b65723fce3 Remove mentions of fallback
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-16 15:12:12 -07:00
Riyaz Faizullabhoy 83f7c758ca Remove delegation role fallback when applying targets changes
Signed-off-by: Riyaz Faizullabhoy <riyaz.faizullabhoy@docker.com>
2016-03-16 15:12:11 -07:00
Ying Li 44cccbb4db Make all key rotations publish immediately, not just remote key rotations
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 18:35:30 -07:00
Ying Li fa5edc40af Publish only the key rotation changes after a remote key rotation
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 18:17:27 -07:00
Ying Li b6c4840231 Update comments, and publish in the CLI after remote key rotation
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 18:17:27 -07:00
Ying Li e3716f0be9 Change the CLI for rotate key to require a role type
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 18:17:27 -07:00
Ying Li 07b9f504e4 Update the CLI and client to no longer reject remote timestamp rotations.
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 18:17:27 -07:00
Ying Li 4022e97b08 Use 'require' instead of 'assert' in client and TUF client tests
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-15 13:52:48 -07:00
Ying Li e25746dac3 Use a CacheControlHandler that wraps other handlers instead
Signed-off-by: Ying Li <ying.li@docker.com>
2016-03-14 17:19:13 -07:00
HuKeping 6b96c7e56d [PATCH 3/8] Add sha512 when creating target, snapshot and timestamp
Signed-off-by: Hu Keping <hukeping@huawei.com>
2016-03-11 10:44:42 +08:00