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

elliptic-curve: JwkEcKey is too strict in what it accepts #1016

Open
Erik1000 opened this issue May 26, 2022 · 0 comments
Open

elliptic-curve: JwkEcKey is too strict in what it accepts #1016

Erik1000 opened this issue May 26, 2022 · 0 comments

Comments

@Erik1000
Copy link

As per RFC7517 section 4 (fourth paragraph)

Additional members can be present in the JWK; if not understood by
implementations encountering them, they MUST be ignored.

But currently, if you try to parse this key for example (using the p256 crate; key created by step-cli):

{
  "use": "enc",
  "kty": "EC",
  "kid": "UYa89vgc4u_lpcbbmDQfYJQRAUD4AED8H8FUNjk5KyQ",
  "crv": "P-256",
  "alg": "ECDH-ES",
  "x": "hFc6OfbgRsYFOWyhGbWH0sS5DZBjJLGABJvPttVZfA4",
  "y": "tnXB8ks0-AZJKOgbMWJrE5Jm3nTFy0UiqQugmx9jku4"
}

It will fail, because it does not recognize the use parameter (it doesn't recognize some other parameters either, but that is the first parameter it sees).
In fact, you have to reduce it to the following parameters (so only the ones from Field are present)

{
  "kty": "EC",
  "crv": "P-256",
  "x": "hFc6OfbgRsYFOWyhGbWH0sS5DZBjJLGABJvPttVZfA4",
  "y": "tnXB8ks0-AZJKOgbMWJrE5Jm3nTFy0UiqQugmx9jku4"
}

There's a registry for all key parameters at IANA but note that this list 1) may grow with new entries and 2) implementations are allowed to define custom parameters not in the registry.

My proposed solution would be to ignore unknown parameters just like the spec dictates it.

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

3 participants
@newpavlov @Erik1000 and others