JWK: support the registered secp256k1 curve name for EC keys
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 65/100
Rechercherichtung
Start with lib/jwt/jwk/ec.rb, especially to_openssl_curve and keypair_components, then read the existing EC JWK tests and the changelog conventions. Reproduce the reported import and export behavior for secp256k1; done means registered-name JWKS keys work through verification, verify_key, private?, and set export, with the intended export name and compatibility note covered.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Problem
RFC 8812, section 3.1 registers the JWK crv value for the secp256k1 curve as "secp256k1". JWT::JWK::EC only recognises "P-256K", a name from earlier drafts, in lib/jwt/jwk/ec.rb:
to_openssl_curvemaps'P-256K'to'secp256k1'and raisesJWT::JWKError, 'Invalid curve provided'for anything else.keypair_componentsexports secp256k1 keys withcrv: 'P-256K'.
As a result, ES256K tokens can't be verified against a JWKS that uses the registered name, and keys exported by ruby-jwt aren't readable by implementations that only accept "secp256k1".
Reproduction (jwt 3.3.0)
key = OpenSSL::PKey::EC.generate("secp256k1")
jwk = JWT::JWK.new(key)
jwk.export[:crv] # => "P-256K"
token = JWT.encode({ sub: "1" }, key, "ES256K", kid: jwk.kid)
standard = jwk.export.merge(crv: "secp256k1")
JWT.decode(token, nil, true, algorithms: ["ES256K"], jwks: { keys: [standard] })
# => JWT::JWKError: Invalid curve provided
JWT.decode(token, nil, true, algorithms: ["ES256K"], jwks: { keys: [jwk.export] })
# => works with "P-256K"
This also shows up with real JWKS. The Connect2id demo JWKS publishes an EC key with crv: "secp256k1". Importing it works because the key is built lazily, but verify_key, private? and export raise, so JWT::JWK::Set#export fails for the whole set. Looking up other keys by kid isn't affected.
Suggested fix
- Accept both
"secp256k1"and"P-256K"into_openssl_curve. This is backwards compatible and could go into a patch release. - Export secp256k1 keys with
crv: "secp256k1". This changes exported JWKs and their thumbprints for existing secp256k1 keys, so it might fit better in a minor or major release, with a CHANGELOG note.
Posted by Claude on behalf of @anakinj.
- Vorherrschende Sprache
- Ruby
- Sterne
- 3.7k
- Forks
- 381
- Ø Merge
- 14 Std. 13 Min.
- Gemergte PRs (30 T.)
- 13
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus jwt/ruby-jwt
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 15/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 68/100
jwt/ruby-jwt#743 · 1 Kommentar ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
jwt/ruby-jwt#723 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
feature
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
jwt/ruby-jwt#428 · 7 Kommentare · 1 Reaktion ·
Maintainer antworten meist innerhalb von 1 Tag
-
Introduce JWE supportOffenenhancement feature help wanted up for grabs
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 25/100
jwt/ruby-jwt#80 · 11 Kommentare · 8 Reaktionen ·
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
internal product:ai-gateway size: S
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Kong/developer.konghq.com#7931 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 78/100
partiql/partiql-lang#105 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
rails/rails-dom-testing#136 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
nesquena/steward-os#79 ·
Maintainer antworten meist innerhalb von 1 Tag
-
area/tech debt
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag