RESOLVED FIXED 279963
[WebCrypto] JWK import / export round-trip fails in X25519
https://bugs.webkit.org/show_bug.cgi?id=279963
Summary [WebCrypto] JWK import / export round-trip fails in X25519
Javier Fernandez
Reported 2024-09-19 02:24:01 PDT
STEPS TO REPRODUCE THE PROBLEM 1- Load the importKey.html test case (attached) 2- See the messages in the dev tools console EXPECTED RESULT: The following message should appear: CONSOLE LOG Import Success !! CONSOLE LOG Export Success !! CONSOLE LOG Round trip works ACTUAL RESULT: CONSOLE LOG Import Success !! CONSOLE LOG Export Success !! CONSOLE LOG Round trip failed CONSOLE LOG Expected: { crv: X25519 d: yIOOdtBX37fYyVpp4TgWCt1jc_1xpNJ2u1bjqBtk_2E x: HPKx5gIuxTc3Htf1PlT6EVTYPpjrZOpR-uWzMHz-lwY kty: OKP } CONSOLE LOG Got: { crv: X25519 d: yIOOdtBX37fYyVpp4TgWCt1jc_1xpNJ2u1bjqBtk_2E ext: true key_ops: deriveBits kty: OKP x: hbrW0bCab1ERDBqLWuWTwnQLzwZcuzYSiYsyGkVcT8A }
Attachments
Javier Fernandez
Comment 1 2024-09-19 02:31:29 PDT
The problem seems to be the public key set to the 'x' attribute: < x: HPKx5gIuxTc3Htf1PlT6EVTYPpjrZOpR-uWzMHz-lwY > x: hbrW0bCab1ERDBqLWuWTwnQLzwZcuzYSiYsyGkVcT8A This bug happens only in the Mac port; the Gtk+ port produces a successfully round-trip operation. Looking that the code, the JWK export operation in X25519 calls to generateJwkX() function [1], which generates the public key bytes from the private key material. auto* di = ccsha512_di(); ccec25519pubkey publicKey; cced25519_make_pub(di, publicKey, m_data.data()); The result of this operation is different than the original public key previously imported. [1] https://github.com/WebKit/WebKit/blob/2d09e4618e7a51850fd9095f908b7683d4c9b7d9/Source/WebCore/crypto/cocoa/CryptoKeyOKPCocoa.cpp#L376
Radar WebKit Bug Importer
Comment 2 2024-09-19 03:17:07 PDT
Javier Fernandez
Comment 3 2024-09-19 03:26:57 PDT
Nitin Mahendru
Comment 4 2024-09-27 16:13:37 PDT
EWS
Comment 5 2024-09-30 11:39:13 PDT
Committed 284459@main (34986dbe6f18): <https://commits.webkit.org/284459@main> Reviewed commits have been landed. Closing PR #34393 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.