Skip to content

fix(crypto): throw DataError, not TypeError, for JWK missing kty - #328

Draft
VirtualTim wants to merge 1 commit into
bytecodealliance:mainfrom
VirtualTim:jwk-missing-kty
Draft

VirtualTim wants to merge 1 commit into
bytecodealliance:mainfrom
VirtualTim:jwk-missing-kty

Conversation

@VirtualTim

Copy link
Copy Markdown
Contributor

According to the spec a missing kty should throw a DataError, not TypeError.
Found when looking at the crypto tests post-#326.

From https://w3c.github.io/webcrypto/#concept-parse-a-jwk:

When this specification says to parse a JWK, the user agent must run the following steps:
[...]
6. If the kty field of key is not defined, then throw a DataError.

From https://w3c.github.io/webcrypto/#rsassa-pkcs1-operations-import-key:

  1. If the kty field of jwk is not a case-sensitive string match to "RSA", then throw a DataError.

From https://w3c.github.io/webcrypto/#ecdsa-operations-import-key:

  1. If the kty field of jwk is not "EC", then throw a DataError.

Marking as a draft, as this should be rebased on top of #326, and text expectations should be updated with WPT_FLAGS="--update-expectations".

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant