Skip to content

Accept JWK alg "Ed25519" when importing an Ed25519 key - #8553

Merged
littledivy merged 2 commits into
mainfrom
littledivy/2026-11-17-wc-ed25519-jwk-import
Nov 18, 2026
Merged

littledivy merged 2 commits into
mainfrom
littledivy/2026-11-17-wc-ed25519-jwk-import

Conversation

@littledivy

Copy link
Copy Markdown
Member

Web Crypto now allows an Ed25519 JWK to carry either "Ed25519" or "EdDSA" as its alg (w3c/webcrypto#401). workerd accepted only "EdDSA", so importing a JWK with alg: "Ed25519" threw a DataError.

In this patch the Ed25519 JWK import accepts both values; any other alg is still rejected. An error turning into a success is additive, so this ships without a compatibility flag. Export still emits "EdDSA", which is why the WPT okp_importKey_Ed25519 alg cases stay expected failures; their comment now says so. The new ed25519JwkImportAlg case in crypto-extras-test fails without the fix.

@littledivy
littledivy requested review from a team as code owners November 17, 2026 17:48

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of ded43784.

This review, of 275a2b78

💬 Approved with comments — The fix is correct, narrowly scoped and has a regression test. The only note is an INFO asking for a clearer WPT expectation comment.

Findings: 1 info (1 is an inline comment on the diff)

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


📋 Code Quality: 💬 1 info

The fix is correct and has a test; the only note is about the wording of the WPT expectation comment.

Recommendation: 💬 Optional Nits

  • [INFO] WPT expectation comment doesn't clearly explain why the alg EdDSA cases also fail (src/wpt/WebCryptoAPI-test.ts:191)
View full review
  • src/workerd/api/crypto/ec.c++:573-580: the looser alg check applies only to NID_ED25519, and any alg other than Ed25519/EdDSA still throws DOMDataError.
  • crypto-extras-test.js: the new test covers both accepted alg values for public and private keys and the rejection case.
  • src/wpt/WebCryptoAPI-test.ts:190-191: the expected-failure list also includes every Good parameters with JWK alg EdDSA case. A reader may wonder why those fail, since export already emits EdDSA. A small wording change would make that clear.

✅ All other checks passed

🔒 Security: ✅ LGTM

Import still rejects any alg other than the two allowed by the spec, and the crv check is unchanged.


📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions.


⚡ Performance: ✅ LGTM

No performance impact.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 275a2b78

Comment thread src/wpt/WebCryptoAPI-test.ts Resolved
@littledivy
littledivy force-pushed the littledivy/2026-11-17-wc-ed25519-jwk-import branch from 275a2b7 to ded4378 Compare November 17, 2026 17:53

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 1d06190b.

This review, of ded43784

✅ Approved — The fix is correct and narrowly scoped, and it has a regression test. The one earlier note, about the WPT expectation comment, is resolved and there are no new findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Import still rejects any alg other than the two the spec allows, and the crv check is unchanged.


📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions, and the commit message records the compatibility decision.


📋 Code Quality: ✅ LGTM

  • src/workerd/api/crypto/ec.c++:573-580: the check only applies to NID_ED25519. It accepts Ed25519 and EdDSA and rejects every other alg with DOMDataError. The crv check is unchanged.
  • src/workerd/api/tests/crypto-extras-test.js: the test covers both accepted alg values for public and private keys and the rejection case.
  • src/wpt/WebCryptoAPI-test.ts:190-191: the comment now explains that the failing cases expect alg: "Ed25519" on export, while workerd exports "EdDSA".

⚡ Performance: ✅ LGTM

No performance impact.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: ded43784

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The generated output of @cloudflare/workers-types matches the snapshot in types/generated-snapshot 🎉

Web Crypto now allows an Ed25519 JWK to carry either "Ed25519" or "EdDSA" as its `alg` (w3c/webcrypto#401). workerd accepted only "EdDSA", so importing a JWK with `alg: "Ed25519"` threw a DataError.

In this patch the Ed25519 JWK import accepts both values; any other `alg` is still rejected. An error turning into a success is additive, so this ships without a compatibility flag. Export still emits "EdDSA", which is why the WPT `okp_importKey_Ed25519` alg cases stay expected failures; their comment now says so. The new `ed25519JwkImportAlg` case in crypto-extras-test fails without the fix.
@littledivy
littledivy force-pushed the littledivy/2026-11-17-wc-ed25519-jwk-import branch from ded4378 to 1d06190 Compare November 17, 2026 21:25

@clanky-the-clanker clanky-the-clanker Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by the review of 94d259a8.

This review, of 1d06190b

✅ Approved — The fix is correct and narrowly scoped, and it has a regression test. The one earlier note, about the WPT expectation comment, is resolved and there are no new findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Import still rejects any alg other than the two the spec allows, and the crv check is unchanged.


📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions, and the commit message records the compatibility decision.


📋 Code Quality: ✅ LGTM

  • src/workerd/api/crypto/ec.c++:573-580: the check only applies to NID_ED25519. It accepts Ed25519 and EdDSA and rejects every other alg with DOMDataError. The crv check is unchanged.
  • src/workerd/api/tests/crypto-extras-test.js: the test covers both accepted alg values for public and private keys and the rejection case.
  • src/wpt/WebCryptoAPI-test.ts:190-191: the comment now explains that the failing cases expect alg: "Ed25519" on export, while workerd exports "EdDSA".

⚡ Performance: ✅ LGTM

No performance impact.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 1d06190b — same changes as ded43784, so this is that commit's review (no new review was run; line numbers are as of ded43784)

@clanky-the-clanker clanky-the-clanker Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — The fix is correct and narrowly scoped, and it has a regression test. The one earlier note, about the WPT expectation comment, is resolved and there are no new findings.

The decision is advisory: this review is a comment and never approves, blocks or requests changes on the pull request.


✅ All checks passed

🔒 Security: ✅ LGTM

Import still rejects any alg other than the two the spec allows, and the crv check is unchanged.


📖 AGENTS.md: ✅ LGTM

The change follows the repository's conventions, and the commit message records the compatibility decision.


📋 Code Quality: ✅ LGTM

  • src/workerd/api/crypto/ec.c++:573-580: the check only applies to NID_ED25519. It accepts Ed25519 and EdDSA and rejects every other alg with DOMDataError. The crv check is unchanged.
  • src/workerd/api/tests/crypto-extras-test.js: the test covers both accepted alg values for public and private keys and the rejection case.
  • src/wpt/WebCryptoAPI-test.ts:190-191: the comment now explains that the failing cases expect alg: "Ed25519" on export, while workerd exports "EdDSA".

⚡ Performance: ✅ LGTM

No performance impact.


📝 Documentation: ✅ LGTM

No documentation issues.


Reviewed commit: 94d259a8 — same changes as ded43784, so this is that commit's review (no new review was run; line numbers are as of ded43784)

@littledivy
littledivy merged commit a034bcb into main Nov 18, 2026
23 of 25 checks passed
@littledivy
littledivy deleted the littledivy/2026-11-17-wc-ed25519-jwk-import branch November 18, 2026 05:22
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.

3 participants