Bug 262613 - Ed25519 JWK import should ignore the "alg" JWK member
Summary: Ed25519 JWK import should ignore the "alg" JWK member
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: Safari 17
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Javier Fernandez
URL:
Keywords: InRadar, WPTImpact
Depends on:
Blocks:
 
Reported: 2023-10-04 06:00 PDT by Filip Skokan
Modified: 2024-10-23 05:43 PDT (History)
8 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Skokan 2023-10-04 06:00:28 PDT
As per https://github.com/WICG/webcrypto-secure-curves/pull/24 the "alg" JWK member is now ignored during JWK import, and missing during JWK export for Ed25519 keys.

Safari correctly handles the latter but not the former, the "alg" JWK member is not ignored during import.

```
const jwk = {
  crv: "Ed25519",
  x: "2OGJY9gJ1IfZVJrMrsZ0Ln7rok2KDTsUt-PK6gaJPcw",
  kty: "OKP",
  alg: "this should now be ignored",
};

crypto.subtle.importKey("jwk", jwk, "Ed25519", true, ["verify"]).then((key) => {
  crypto.subtle.exportKey("jwk", key).then((exportedJwk) => {
    if (exportedJwk.alg) {
      console.log("❌ alg should be missing");
    }
  });
});
```
Comment 1 Filip Skokan 2023-10-04 06:01:20 PDT
WPT update for the draft spec change https://github.com/web-platform-tests/wpt/pull/42333
Comment 2 Radar WebKit Bug Importer 2023-10-11 06:01:15 PDT
<rdar://problem/116806236>
Comment 3 Javier Fernandez 2023-11-27 08:48:50 PST
I'm working on a patch for this bug.
Comment 4 Javier Fernandez 2023-11-28 10:36:41 PST
Pull request: https://github.com/WebKit/WebKit/pull/21006
Comment 5 Javier Fernandez 2024-02-16 02:23:33 PST
It seems Chrome reviewers have doubts regarding the decision to remove the 'alg' field from the JWK import operation's logic. 

I'd rather wait until there is more consensus before merging the patch.
Comment 6 Javier Fernandez 2024-10-23 05:43:47 PDT
It seems that FF implementation ignores the "alg" JWK member, as it passes the related tests [1]. It'd be useful to know WebKit's position on this regard, given than apparently Chrome's concerns are debatable, from what I could extract from the conversation in the mentioned Chrome bug. 

[1] https://wpt.fyi/results/WebCryptoAPI/import_export/okp_importKey_Ed25519.https.any.html?label=experimental&label=master&aligned