Fix/es256 idtoken eee-p1363 - #30
Open
grahamallen-1 wants to merge 2 commits into
Open
Conversation
Update spruce opencred with latest from stateofca
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix ES256
id_tokensignatures so they're valid JWS. The signer used Node's default ECDSA output (ASN.1/DER); JWS requires the rawR || Sconcatenation (IEEE P1363). As a result, ES256id_tokens are rejected by standards-compliant RPs with a signature-validation error.Fix
Sign with
dsaEncoding: 'ieee-p1363'incommon/oidc.js.dsaEncodingis ignored for RSA keys, so the RS256 path is unaffected.Per RFC 7518 §3.4 (JSON Web Algorithms), the ECDSA JWS Signature is the fixed-length concatenation of R and S — not the DER encoding: https://www.rfc-editor.org/rfc/rfc7518#section-3.4
Tests
Added an
id_tokensigning test intest/unit/60-oidc.test.js: mints a token with an ES256 key, verifies it withjose(a compliant verifier — rejects DER, accepts P1363), and asserts the signature is exactly 64 bytes (P-256 R||S).