From 445d117b67cdd06195a3064d2cffa85fada9f0a2 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Sat, 26 Oct 2024 08:41:27 +0100 Subject: [PATCH] test,crypto: update WebCryptoAPI WPT PR-URL: https://github.com/nodejs/node/pull/55512 Reviewed-By: Yagiz Nizipli Reviewed-By: Luigi Pinca --- test/fixtures/wpt/README.md | 2 +- .../derive_bits_keys/derived_bits_length_testcases.js | 8 ++++++++ .../derive_bits_keys/derived_bits_length_vectors.js | 8 ++++++++ test/fixtures/wpt/versions.json | 2 +- test/wpt/status/WebCryptoAPI.cjs | 10 ++++++++++ 5 files changed, 28 insertions(+), 2 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index bf405ad2da4f57..4c8f6e8b0268d6 100644 --- a/test/fixtures/wpt/README.md +++ b/test/fixtures/wpt/README.md @@ -32,7 +32,7 @@ Last update: - user-timing: https://github.com/web-platform-tests/wpt/tree/5ae85bf826/user-timing - 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 -- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/bef6fa3566/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/75db68b054/WebCryptoAPI - webidl/ecmascript-binding/es-exceptions: https://github.com/web-platform-tests/wpt/tree/a370aad338/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/9dafa89214/webstorage diff --git a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_testcases.js b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_testcases.js index 1bd7fbc2c85989..518c781d9f15b4 100644 --- a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_testcases.js +++ b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_testcases.js @@ -1,6 +1,8 @@ var testCases = { "HKDF": [ {length: 256, expected: algorithms["HKDF"].derivation}, + {length: 384, expected: algorithms["HKDF"].derivation384}, + {length: 230, expected: undefined}, // should throw an exception, not multiple of 8 {length: 0, expected: undefined}, // explicitly disallowed, so should throw {length: null, expected: undefined }, // should throw an exception {length: undefined, expected: undefined }, // should throw an exception @@ -8,6 +10,8 @@ var testCases = { ], "PBKDF2": [ {length: 256, expected: algorithms["PBKDF2"].derivation}, + {length: 384, expected: algorithms["PBKDF2"].derivation384}, + {length: 230, expected: undefined}, // should throw an exception, not multiple of 8 {length: 0, expected: undefined}, // explicitly disallowed, so should throw {length: null, expected: undefined }, // should throw an exception {length: undefined, expected: undefined }, // should throw an exception @@ -15,6 +19,8 @@ var testCases = { ], "ECDH": [ {length: 256, expected: algorithms["ECDH"].derivation}, + {length: 384, expected: undefined}, // should throw an exception, bigger than the output size + {length: 230, expected: algorithms["ECDH"].derivation230}, {length: 0, expected: emptyArray}, {length: null, expected: algorithms["ECDH"].derivation}, {length: undefined, expected: algorithms["ECDH"].derivation}, @@ -22,6 +28,8 @@ var testCases = { ], "X25519": [ {length: 256, expected: algorithms["X25519"].derivation}, + {length: 384, expected: undefined}, // should throw an exception, bigger than the output size + {length: 230, expected: algorithms["X25519"].derivation230}, {length: 0, expected: emptyArray}, {length: null, expected: algorithms["X25519"].derivation}, {length: undefined, expected: algorithms["X25519"].derivation}, diff --git a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_vectors.js b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_vectors.js index fa51f7d3f2b195..391f81d1871d76 100644 --- a/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_vectors.js +++ b/test/fixtures/wpt/WebCryptoAPI/derive_bits_keys/derived_bits_length_vectors.js @@ -9,12 +9,16 @@ var algorithms = { privateKey: {format: "raw", data: rawKey}, deriveAlg: {name: "HKDF", salt: salt, hash: "SHA-256", info: info}, derivation: new Uint8Array([49, 183, 214, 133, 48, 168, 99, 231, 23, 192, 129, 202, 105, 23, 182, 134, 80, 179, 221, 154, 41, 243, 6, 6, 226, 202, 209, 153, 190, 193, 77, 19]), + derivation384: new Uint8Array([49, 183, 214, 133, 48, 168, 99, 231, 23, 192, 129, 202, 105, 23, 182, 134, 80, 179, 221, 154, 41, 243, 6, 6, 226, 202, 209, 153, 190, 193, 77, 19, 165, 50, 181, 8, 254, 59, 122, 199, 25, 224,146, 248, 105, 105, 75, 84]), + derivation230: undefined, }, "PBKDF2": { importAlg: {name: "PBKDF2"}, privateKey: {format: "raw", data: rawKey}, deriveAlg: {name: "PBKDF2", salt: salt, hash: "SHA-256", iterations: 100000}, derivation: new Uint8Array([17, 153, 45, 139, 129, 51, 17, 36, 76, 84, 75, 98, 41, 41, 69, 226, 8, 212, 3, 206, 189, 107, 149, 82, 161, 165, 98, 6, 93, 153, 88, 234]), + derivation384: new Uint8Array([17, 153, 45, 139, 129, 51, 17, 36, 76, 84, 75, 98, 41, 41, 69, 226, 8, 212, 3, 206, 189, 107, 149, 82, 161, 165, 98, 6, 93, 153, 88, 234, 39, 104, 8, 112, 222, 57, 166, 47, 102, 146, 195, 59, 219, 239, 238, 47]), + derivation230: undefined, }, "ECDH": { importAlg: {name: "ECDH", namedCurve: "P-256"}, @@ -22,6 +26,8 @@ var algorithms = { publicKey: {format: "spki", data: new Uint8Array([48, 89, 48, 19, 6, 7, 42, 134, 72, 206, 61, 2, 1, 6, 8, 42, 134, 72, 206, 61, 3, 1, 7, 3, 66, 0, 4, 154, 116, 32, 120, 126, 95, 77, 105, 211, 232, 34, 114, 115, 1, 109, 56, 224, 71, 129, 133, 223, 127, 238, 156, 142, 103, 60, 202, 211, 79, 126, 128, 254, 49, 141, 182, 221, 107, 119, 218, 99, 32, 165, 246, 151, 89, 9, 68, 23, 177, 52, 239, 138, 139, 116, 193, 101, 4, 57, 198, 115, 0, 90, 61])}, deriveAlg: {name: "ECDH", public: new Uint8Array ([])}, derivation: new Uint8Array([14, 143, 60, 77, 177, 178, 162, 131, 115, 90, 0, 220, 87, 31, 26, 232, 151, 28, 227, 35, 250, 17, 131, 137, 203, 95, 65, 196, 59, 61, 181, 161]), + derivation384: undefined, + derivation230: new Uint8Array([14, 143, 60, 77, 177, 178, 162, 131, 115, 90, 0, 220, 87, 31, 26, 232, 151, 28, 227, 35, 250, 17, 131, 137, 203, 95, 65, 196, 56]), }, "X25519": { importAlg: {name: "X25519"}, @@ -29,5 +35,7 @@ var algorithms = { publicKey: {format: "spki", data: new Uint8Array([48, 42, 48, 5, 6, 3, 43, 101, 110, 3, 33, 0, 28, 242, 177, 230, 2, 46, 197, 55, 55, 30, 215, 245, 62, 84, 250, 17, 84, 216, 62, 152, 235, 100, 234, 81, 250, 229, 179, 48, 124, 254, 151, 6])}, deriveAlg: {name: "X25519", public: new Uint8Array ([])}, derivation: new Uint8Array([39, 104, 64, 157, 250, 185, 158, 194, 59, 140, 137, 185, 63, 245, 136, 2, 149, 247, 97, 118, 8, 143, 137, 228, 61, 254, 190, 126, 161, 149, 0, 8]), + derivation384: undefined, + derivation230: new Uint8Array([39, 104, 64, 157, 250, 185, 158, 194, 59, 140, 137, 185, 63, 245, 136, 2, 149, 247, 97, 118, 8, 143, 137, 228, 61, 254, 190, 126, 160]), } }; diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 3a01055f5f3c04..d3aef559ecd588 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -88,7 +88,7 @@ "path": "wasm/webapi" }, "WebCryptoAPI": { - "commit": "bef6fa3566074bdde49e7ccc95ea0d76d08ed6ba", + "commit": "75db68b05454e7f3a81e063373defd094c176a16", "path": "WebCryptoAPI" }, "webidl/ecmascript-binding/es-exceptions": { diff --git a/test/wpt/status/WebCryptoAPI.cjs b/test/wpt/status/WebCryptoAPI.cjs index 0057d5f72cc937..d443ae86caaeb7 100644 --- a/test/wpt/status/WebCryptoAPI.cjs +++ b/test/wpt/status/WebCryptoAPI.cjs @@ -8,6 +8,16 @@ module.exports = { 'algorithm-discards-context.https.window.js': { 'skip': 'Not relevant in Node.js context', }, + 'derive_bits_keys/derived_bits_length.https.any.js': { + 'fail': { + // See https://github.com/nodejs/node/pull/55296 + // The fix is pending a decision whether truncation in ECDH/X* will be removed from the spec entirely + 'expected': [ + "ECDH derivation with 230 as 'length' parameter", + "X25519 derivation with 230 as 'length' parameter", + ], + }, + }, 'historical.any.js': { 'skip': 'Not relevant in Node.js context', },