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

Formulate a consistent canonicalization strategy #261

Closed
znewman01 opened this issue Apr 5, 2022 · 2 comments
Closed

Formulate a consistent canonicalization strategy #261

znewman01 opened this issue Apr 5, 2022 · 2 comments

Comments

@znewman01
Copy link
Contributor

There's been confusion and bugs caused by inconsistent canonicalization (e.g., #214, #247). This issue represents an attempt to catalogue issues and possible solutions. CC @asraa @toby-jn

In the offline signing flow (output something from one TUF repo, copy it to another box, sign it, copy it back, import the signature), when should we canonicalize?

There are two approaches that seem coherent:

  1. Canonicalize at signing time. This allows us to pass around metadata in JSON format, modify it before signing, etc. It has the downside of requiring signing tools to understand canonicalization (though that could be mitigated by adding a tuf canonicalize command).
  2. Canonicalize at output time. This lets users treat the payload as a black box. It means they cannot modify it (unless they convert from canonicalized form back to metadata form).

In the go-tuf library, when should we canonicalize?

  • Should we store metadata on-disk canonicalized?
  • Should we store metadata in-memory canonicalized?
  • Should we have sign.Sign (which signs a payload with a single "Signer") canonicalize?
  • Should we have repo.Sign (which grabs keys associated with a role, grabs metadata for a role, calls sign.Sign, and stores the signed metadata) canonicalize?

I think there's a consensus that clients must canonicalize before verifying signatures, at verification time. There are design decisions to be made there, but let's call them out-of-scope for this issue.

I might be missing something; feel free to add.

@toby-jn
Copy link
Contributor

toby-jn commented Apr 13, 2022

The reason I started looking at the canonicalization originally was due to #246 (also discussed in theupdateframework/specification#92). The result of this is that canonicalization should only be performed when calculating the disgest. Therefore I think repo.Sign and sign.Sign should deal with metadata files, and the specific key implementations should just just receive arbitrary []byte (which would be canonicalized JSON) and sign them.

In order to fit payload and add-signature subcommands into this model, the code perhaps needs some refactoring: currently sign.Sign does the work of canoncalizing and then passing to the signer and then attaches the result to the metadata.. so should be a matter of splitting up this operation into these individual steps and then exposing them separately as subcommands.

@rdimitrov
Copy link
Contributor

Closing since the code base changed and this is no longer relevant.

Thanks for raising this 👍

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

No branches or pull requests

3 participants