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

[RFC] Change jws.Sign, remove jws.SignMulti #579

Closed
Tracked by #388
lestrrat opened this issue Feb 22, 2022 · 1 comment
Closed
Tracked by #388

[RFC] Change jws.Sign, remove jws.SignMulti #579

lestrrat opened this issue Feb 22, 2022 · 1 comment
Assignees

Comments

@lestrrat
Copy link
Collaborator

lestrrat commented Feb 22, 2022

Allow jws.Sign() to sign using multiple keys

change the function signature

jws.Sign([]byte, SignOption...) ([]byte, error)
  • jws.Sign() accepts a jws.WithCompact() or jws.WithJSON() option to determine serialization format. If neither is provided, jws.WithCompact() is assumed.
  • jws.Sign() with a single key produces a JWS in compact serialization format.
  • jws.Sign() with multiple keys produces a JWS in JSON serialization format.
  • It is an error to use jws.WithCompact() and provide multiple keys.

There will not be any jws.WithKeySet() for jws.Sign(). The reason is that each generated signature could potentially have specific headers associated with them, and there needs to be a way to specify them.

changes in jws.WithKey

jws.WithKey() was originally introduced in #577 to specify a single key for verification, but we'll overload this option to also work for signing.

// simple case
jws.Sign(payload, jws.WithKey(alg, key))
// more complicated case... actually, this is an error, as compact serialization form does not allow public headers :)
jws.Sign(payload, jws.WithKey(alg, key, jws.WithProtected(hdr1), jws.WithPublic(hdr2)))

changes in jws.KeySink

Not decided here yet, but there may need to be a jws.SigningKeySink and jws.VerifyingKeySink because different arguments are expected.

Updates

  • No changes are required to the signer, deleted
@lestrrat
Copy link
Collaborator Author

implemented via #581

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant