Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TUF CLI: Improve experience by allowing offline signature generation #205

Closed
asraa opened this issue Jan 10, 2022 · 6 comments · Fixed by #214
Closed

TUF CLI: Improve experience by allowing offline signature generation #205

asraa opened this issue Jan 10, 2022 · 6 comments · Fixed by #214
Assignees

Comments

@asraa
Copy link
Contributor

asraa commented Jan 10, 2022

This would help using the TUF CLI in more tightly controlled key environments, e.g. an air-gapped situation.

I propose two methods:

tuf payload <role> that outputs the canonicalized, signable content of the role's metadata file
tuf add-signature <role> --signature <sig_file> that adds a signature (hex-encoded bytes), generated by an offline tool, to the role. This should verify the signature first.

@haydentherapper

@haydentherapper
Copy link
Contributor

Definitely like this approach! It mirrors what you might do with offline signing of a CSR for X509, where a service generates a CSR and you take just the CSR to an offline key to sign it.

This will also avoid requiring two TUF repos set up, one for online and one for offline.

@asraa
Copy link
Contributor Author

asraa commented Jan 21, 2022

/assign @znewman01

@joshuagl
Copy link
Member

If you comment here @znewman01 we can assign you the issue.

@znewman01
Copy link
Contributor

commenting!

@znewman01
Copy link
Contributor

@asraa I see discussion in #213 about support for key imports etc. Can you clarify for this issue: when you say signed with an "offline tool" what do you mean:

  1. Signed with e.g. the openssl CLI? If so, we need key imports in the CLI (or exports but that feels backwards) so openssl can get the key.

  2. Signed with go-tuf CLI? If so, specifically how (how do we avoid having an offline repo)?

(Hopefully my question makes sense.)

@asraa
Copy link
Contributor Author

asraa commented Jan 28, 2022

Sure! Admittedly I think there's some confusion between the CLI/exposed API...

Signed with e.g. the openssl CLI? If so, we need key imports in the CLI (or exports but that feels backwards) so openssl can get the key.

Yeah, I think we need public key imports via CLI (a method already exists for this in the API -- AddVerificationKey) to make this work. In root-signing none of the private key material is held in the TUF repo. We use the AddVerificationKey method to add the keys to the repo. So in your offline repo you have your private key material, export it and deliver it to the online repo that Adds it to a role, and then you can use the payload generation/add signature flow.

The purpose of the payload command would be to avoid having to manually marshal the metadata into the signable payload (I do this here in root-signing). Right now there's no public API to create and access this, and its caused me a problem with verification before when I've done it incorrectly (sigstore/root-signing@02a7fb4)

znewman01 added a commit to znewman01/go-tuf that referenced this issue Feb 1, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Feb 1, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Feb 1, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Mar 20, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Mar 27, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Mar 31, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Apr 17, 2022
znewman01 added a commit to znewman01/go-tuf that referenced this issue Apr 25, 2022
znewman01 added a commit that referenced this issue May 9, 2022
* feat: Add `payload` and `add-signature` commands.

Fixes #205.

* docs: Clarify `payload` and `add-signature` args.

Specifically, they expect a metadata file name, *not* a role name.

Added a test for each.

* feat: Add `sign-payload` command.

This completes the offline flow:

```shell
tuf payload root.json > /tmp/root.json.payload
tuf sign-payload --role=root /tmp/root.json.payload > /tmp/root.json.sigs
tuf add-signatures --signatures /tmp/root.json.sigs root.json
```

Additional changes:
- rename `add-signature` to `add-signatures`
- `add-signatures` expects JSON (from `sign-payload`) rather than hex bytes

* docs: Beef up documentation for offline signature flow.

- move CLI commands to matching file names
- add examples to README.md
- more details for `repo.SignPayload` docs

* docs: Point out where keys are stored in `sign-payload` docs

* fix: ensure that output is canonicalized

* style: rename ErrInsufficientKeys to ErrNoKeys

* doc: minor `tuf sign-payload` clarifiation

* test: add client test for offline flow

* test: fix tests after rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants