Fix OKP importKey validation for Ed448/Ed25519/X25519/X448#8886
Open
tete17 wants to merge 3 commits intoLadybirdBrowser:masterfrom
Open
Fix OKP importKey validation for Ed448/Ed25519/X25519/X448#8886tete17 wants to merge 3 commits intoLadybirdBrowser:masterfrom
tete17 wants to merge 3 commits intoLadybirdBrowser:masterfrom
Conversation
gmta
reviewed
Apr 13, 2026
b1caed4 to
0cef96b
Compare
Ed448 public keys are 57 bytes (456 bits), not 56 bytes (448 bits). The curve is named "Ed448" after its 448-bit prime field, but per RFC 8032 Section 5.2.5, the parameter b=456 and both private and public keys are 57 bytes. This caused importKey to reject valid raw Ed448 public keys with a DataError. Note: The spec incorrectly says "not 448" for this check. See w3c/webcrypto#425 (comment)
After base64url-decoding the x and d fields during JWK import, verify the decoded byte length matches the expected key size for the curve (32 for Ed25519/X25519, 57 for Ed448, 56 for X448). A truncated value does not "contain the public/private key" as required by RFC 8037 Section 2.
For private key JWK imports, after decoding both d and x, derive the public key from d and verify it matches x. A private key that doesn't correspond to the provided public key doesn't "contain the private key" as required by RFC 8037 Section 2.
0cef96b to
f9ab2a5
Compare
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.
This MR fixes 3 issues with OKP key import in WebCryptoAPI:
This fixes ~230 previously failing WPT subtests across Ed25519, Ed448, X25519, and X448.