From f800d42854936b2b2ef2c4dcbb25fc76013a2f39 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Sun, 20 Jul 2025 00:23:09 +0000 Subject: [PATCH 1/2] test: update WPT for WebCryptoAPI to 19d82c57ab --- test/fixtures/wpt/README.md | 2 +- .../import_export/okp_importKey_failures_fixtures.js | 12 ++++++------ test/fixtures/wpt/WebCryptoAPI/util/helpers.js | 5 +++++ test/fixtures/wpt/versions.json | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 38fa8d9e21e869..3e27f079aa7750 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -34,7 +34,7 @@ Last update: - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi - web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/591c95ce61/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/19d82c57ab/WebCryptoAPI - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/2f96fa1996/webidl/ecmascript-binding/es-exceptions - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel - webstorage: https://github.com/web-platform-tests/wpt/tree/1291340aaa/webstorage diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_fixtures.js b/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_fixtures.js index 9bedddc5c5944a..cac6db1dcac758 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_fixtures.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/okp_importKey_failures_fixtures.js @@ -2,27 +2,27 @@ // helper functions that generate all possible test parameters for // different situations. function getValidKeyData(algorithm) { - return validKeyData[algorithm.name]; + return validKeyData[algorithm.name || algorithm]; } function getBadKeyLengthData(algorithm) { - return badKeyLengthData[algorithm.name]; + return badKeyLengthData[algorithm.name || algorithm]; } function getMissingJWKFieldKeyData(algorithm) { - return missingJWKFieldKeyData[algorithm.name]; + return missingJWKFieldKeyData[algorithm.name || algorithm]; } function getMismatchedJWKKeyData(algorithm) { - return mismatchedJWKKeyData[algorithm.name]; + return mismatchedJWKKeyData[algorithm.name || algorithm]; } function getMismatchedKtyField(algorithm) { - return mismatchedKtyField[algorithm.name]; + return mismatchedKtyField[algorithm.name || algorithm]; } function getMismatchedCrvField(algorithm) { - return mismatchedCrvField[algorithm.name]; + return mismatchedCrvField[algorithm.name || algorithm]; } var validKeyData = { diff --git a/test/fixtures/wpt/WebCryptoAPI/util/helpers.js b/test/fixtures/wpt/WebCryptoAPI/util/helpers.js index c60371dc6adac9..488eadf29c09da 100644 --- a/test/fixtures/wpt/WebCryptoAPI/util/helpers.js +++ b/test/fixtures/wpt/WebCryptoAPI/util/helpers.js @@ -93,6 +93,10 @@ function objectToString(obj) { // Is key a CryptoKey object with correct algorithm, extractable, and usages? // Is it a secret, private, or public kind of key? function assert_goodCryptoKey(key, algorithm, extractable, usages, kind) { + if (typeof algorithm === "string") { + algorithm = { name: algorithm }; + } + var correctUsages = []; var registeredAlgorithmName; @@ -203,6 +207,7 @@ function allAlgorithmSpecifiersFor(algorithmName) { results.push({name: algorithmName, namedCurve: curveName}); }); } else if (algorithmName.toUpperCase().substring(0, 1) === "X" || algorithmName.toUpperCase().substring(0, 2) === "ED") { + results.push(algorithmName); results.push({ name: algorithmName }); } diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 68c2974f33820d..be0e08b04b0f86 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -96,7 +96,7 @@ "path": "web-locks" }, "WebCryptoAPI": { - "commit": "591c95ce6174690b92833cd92859ce2807714591", + "commit": "19d82c57abc7494bdc459a338c5dcfd79e818b4a", "path": "WebCryptoAPI" }, "webidl/ecmascript-binding/es-exceptions": { From a2e44cd54dbff70caae00bbf1ce72208e817c387 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Mon, 21 Jul 2025 12:42:25 +0000 Subject: [PATCH 2/2] test: update WPT for WebCryptoAPI to ab08796857 --- test/fixtures/wpt/README.md | 2 +- .../wpt/WebCryptoAPI/generateKey/successes.js | 11 ++++++++++- .../import_export/ec_importKey_failures_fixtures.js | 4 ++-- .../WebCryptoAPI/import_export/importKey_failures.js | 2 +- test/fixtures/wpt/versions.json | 2 +- 5 files changed, 15 insertions(+), 6 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 3e27f079aa7750..34aed56641dd84 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -34,7 +34,7 @@ Last update: - wasm/jsapi: https://github.com/web-platform-tests/wpt/tree/cde25e7e3c/wasm/jsapi - wasm/webapi: https://github.com/web-platform-tests/wpt/tree/fd1b23eeaa/wasm/webapi - web-locks: https://github.com/web-platform-tests/wpt/tree/10a122a6bc/web-locks -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/19d82c57ab/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/ab08796857/WebCryptoAPI - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/2f96fa1996/webidl/ecmascript-binding/es-exceptions - webmessaging/broadcastchannel: https://github.com/web-platform-tests/wpt/tree/6495c91853/webmessaging/broadcastchannel - webstorage: https://github.com/web-platform-tests/wpt/tree/1291340aaa/webstorage diff --git a/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js b/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js index a9a168e1adbf72..13c96b7c735fcb 100644 --- a/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js +++ b/test/fixtures/wpt/WebCryptoAPI/generateKey/successes.js @@ -75,7 +75,7 @@ function run_test(algorithmNames, slowTest) { }) .then(async function (result) { if (resultType === "CryptoKeyPair") { - await Promise.all([ + const [jwkPub,,, jwkPriv] = await Promise.all([ subtle.exportKey('jwk', result.publicKey), subtle.exportKey('spki', result.publicKey), result.publicKey.algorithm.name.startsWith('RSA') ? undefined : subtle.exportKey('raw', result.publicKey), @@ -84,6 +84,15 @@ function run_test(algorithmNames, slowTest) { subtle.exportKey('pkcs8', result.privateKey), ] : []) ]); + + if (extractable) { + // Test that the JWK public key is a superset of the JWK private key. + for (const [prop, value] of Object.entries(jwkPub)) { + if (prop !== 'key_ops') { + assert_equals(value, jwkPriv[prop], `Property ${prop} is equal in public and private JWK`); + } + } + } } else { if (extractable) { await Promise.all([ diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey_failures_fixtures.js b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey_failures_fixtures.js index a2d25e816cbd73..dc0e11d551a922 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey_failures_fixtures.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/ec_importKey_failures_fixtures.js @@ -20,11 +20,11 @@ function getMismatchedJWKKeyData(algorithm) { } function getMismatchedKtyField(algorithm) { - return mismatchedKtyField[algorithm.name]; + return mismatchedKtyField[algorithm.namedCurve]; } function getMismatchedCrvField(algorithm) { - return mismatchedCrvField[algorithm.name]; + return mismatchedCrvField[algorithm.namedCurve]; } var validKeyData = { diff --git a/test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js b/test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js index 39c70a85470dca..47d12f14500dff 100644 --- a/test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js +++ b/test/fixtures/wpt/WebCryptoAPI/import_export/importKey_failures.js @@ -243,7 +243,7 @@ function run_test(algorithmNames) { allAlgorithmSpecifiersFor(name).forEach(function(algorithm) { getValidKeyData(algorithm).forEach(function(test) { if (test.format === "jwk") { - var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, d: test.data.d}; + var data = {crv: test.data.crv, kty: test.data.kty, d: test.data.d, x: test.data.x, y: test.data.y}; data.use = "invalid"; var usages = validUsages(vector, 'jwk', test.data); if (usages.length !== 0) diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index be0e08b04b0f86..86b594dd5ef9a2 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -96,7 +96,7 @@ "path": "web-locks" }, "WebCryptoAPI": { - "commit": "19d82c57abc7494bdc459a338c5dcfd79e818b4a", + "commit": "ab08796857072c5a93e27e0a25effba2e07dad11", "path": "WebCryptoAPI" }, "webidl/ecmascript-binding/es-exceptions": {