Repository navigation
Ignore unknown kty in import_key_set (RFC 7517 §5) - #914
Closed
RalphBragg wants to merge 1 commit into
Closed
RalphBragg wants to merge 1 commit into
RalphBragg wants to merge 1 commit into
Conversation
import_key_set raised KeyError on the first key whose kty was not registered, failing the whole set. Skip a key whose kty is present but unrecognised, per RFC 7517 Section 5, so classical keys published alongside a post-quantum key (ML-DSA, kty AKP) remain usable.
Member
|
Hi, thank you for your contribution, but unfortunately |
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.
What
JsonWebKey.import_key_set()now skips a key whosektyis present but not recognised, instead of raisingKeyErrorand failing the whole set.Why
Today
import_key_setdoes[cls.import_key(k) for k in keys]; the first key with an unregisteredktyraisesKeyError(e.g.KeyError: 'AKP') and the entire set fails to import. RFC 7517 §5 says a processor SHOULD ignore key types it does not understand.This is becoming a live problem as post-quantum keys (ML-DSA,
kty:"AKP", RFC 9964) begin appearing in published JWKS next to RSA/EC keys: a consumer stops verifying every signature from that issuer, including the classical ones, the moment such a key is published. Relates to #913.Change
import_key_setskips only keys whosektyis explicitly present and not inJWK_KEY_CLS; a recognised-but-malformed key still raises as before.test_jwk_import_key_set_ignores_unknown_kty.tests/jose/test_jwk.pypasses (26 passed). I knowauthlib.joseis deprecated in favour of joserfc; happy to also PR joserfc (it has the same behaviour), but sinceauthlib.josestill ships and is widely used pre-2.0, this keeps it safe in the meantime.