diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index fdbd8022783a22..c65cb15fffacf6 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/42e47329fd/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/c9e955840a/WebCryptoAPI - webidl: https://github.com/web-platform-tests/wpt/tree/63ca529a02/webidl - 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 diff --git a/test/fixtures/wpt/WebCryptoAPI/normalize-algorithm-name.https.any.js b/test/fixtures/wpt/WebCryptoAPI/normalize-algorithm-name.https.any.js new file mode 100644 index 00000000000000..5f9779c9dba168 --- /dev/null +++ b/test/fixtures/wpt/WebCryptoAPI/normalize-algorithm-name.https.any.js @@ -0,0 +1,52 @@ +// META: title=WebCryptoAPI: Algorithm normalization matches names ASCII case-insensitively +// U+212A is the Kelvin Sign + +function makeSalt() { + return crypto.getRandomValues(new Uint8Array(32)); +} + +async function makeKey(algorithm) { + const keyData = new Uint8Array([]); + return crypto.subtle.importKey("raw", keyData, algorithm, false, ["deriveBits"]); +} + +promise_test(async (t) => { + const algorithm = { + name: "H\u212ADF", + hash: "SHA-256", + salt: makeSalt(), + info: new TextEncoder().encode(''), + }; + const key = await makeKey("HKDF"); + const p = crypto.subtle.deriveBits(algorithm, key, 256); + return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name); +}, `"HDF" does not match "HKDF"`); + +promise_test(async (t) => { + const algorithm = { + name: "PB\u212ADF2", + hash: "SHA-256", + iterations: 1, + salt: makeSalt(), + }; + const key = await makeKey("PBKDF2"); + const p = crypto.subtle.deriveBits(algorithm, key, 256); + return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name); +}, `"PBDF2" does not match "PBKDF2"`); + +promise_test(async (t) => { + const algorithm = {name: "AES-\u212AW", length: 256}; + const p = crypto.subtle.generateKey(algorithm, false, ["wrapKey"]); + return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name); +}, `"AES-W" does not match "AES-KW"`); + +promise_test(async (t) => { + const algorithm = { + name: "RSASSA-P\u212ACS1-V1_5", + modulusLength: 2048, + publicExponent: new Uint8Array([3]), + hash: "SHA-256", + }; + const p = crypto.subtle.generateKey(algorithm, false, ["sign"]); + return promise_rejects_dom(t, "NotSupportedError", p, algorithm.name); +}, `"RSASSA-PCS1-V1_5" does not match "RSASSA-PKCS1-V1_5"`); diff --git a/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js b/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js index 9dd837b3bf60a9..e40b4b6d35f794 100644 --- a/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey.https.any.js @@ -40,6 +40,11 @@ name: "AES-KW", importParameters: {name: "AES-KW", length: 128}, wrapParameters: {name: "AES-KW"} + }, + { + name: 'ChaCha20-Poly1305', + importParameters: {name: "ChaCha20-Poly1305"}, + wrapParameters: {name: "ChaCha20-Poly1305", iv: new Uint8Array(12), additionalData: new Uint8Array(16)} } ]; @@ -57,7 +62,8 @@ {algorithm: {name: "AES-CBC", length: 128}, usages: ["encrypt", "decrypt"]}, {algorithm: {name: "AES-GCM", length: 128}, usages: ["encrypt", "decrypt"]}, {algorithm: {name: "AES-KW", length: 128}, usages: ["wrapKey", "unwrapKey"]}, - {algorithm: {name: "HMAC", length: 128, hash: "SHA-256"}, usages: ["sign", "verify"]} + {algorithm: {name: "HMAC", length: 128, hash: "SHA-256"}, usages: ["sign", "verify"]}, + {algorithm: {name: "ChaCha20-Poly1305"}, usages: ['encrypt', 'decrypt']} ]; // Import all the keys needed, then iterate over all combinations @@ -106,9 +112,15 @@ .then(function(key) { wrappers["RSA-OAEP"].unwrappingKey = key; })); + } else if (params.name === "ChaCha20-Poly1305") { + var algorithm = {name: params.name}; + promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC256"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) + .then(function(key) { + wrappers[params.name] = {wrappingKey: key, unwrappingKey: key, parameters: params}; + })); } else { var algorithm = {name: params.name}; - promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) + promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC128"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) .then(function(key) { wrappers[params.name] = {wrappingKey: key, unwrappingKey: key, parameters: params}; })); @@ -151,9 +163,12 @@ var keyData = toWrapKeyDataFromAlg(params.algorithm.name); promises.push(importAndExport("spki", keyData.spki, params.algorithm, params.publicUsages, "public key ")); promises.push(importAndExport("pkcs8", keyData.pkcs8, params.algorithm, params.privateUsages, "private key ")); + } else if (params.algorithm.name === "ChaCha20-Poly1305") { + keys[params.algorithm.name] = {}; + promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC256"].raw, params.algorithm, params.usages, "")); } else { keys[params.algorithm.name] = {}; - promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC"].raw, params.algorithm, params.usages, "")); + promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC128"].raw, params.algorithm, params.usages, "")); } }); // Using allSettled to skip unsupported test cases. @@ -432,6 +447,9 @@ case "ECDH" : deriveParams = {name: "ECDH"}; break; + case "ChaCha20-Poly1305": + cryptParams = {name: "ChaCha20-Poly1305", iv: new Uint8Array(12)}; + break; default: throw new Error("Unsupported algorithm for key comparison"); } diff --git a/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js b/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js index 0c29a7df88b15e..cf799a8a8ce3ea 100644 --- a/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js +++ b/test/fixtures/wpt/WebCryptoAPI/wrapKey_unwrapKey/wrapKey_unwrapKey_vectors.js @@ -14,8 +14,11 @@ let wrappingKeyData = { qi: "JHmVKb1zwW5iRR6RCeexYnh2fmY-3DrPSdM8Dxhr0F8dayi-tlRqEdnG0hvp45n8gLUskWWcB9EXlUJObZGKDfGuxgMa3g_xeLA2vmFQ12MxPsyH4iCNZvsgmGxx7TuOHrnDh5EBVnM4_de63crEJON2sYI8Ozi-xp2OEmAr2seWKq4sxkFni6exLhqb-NE4m9HMKlng1EtQh2rLBFG1VYD3SYYpMLc5fxzqGvSxn3Fa-Xgg-IZPY3ubrcm52KYgmLUGmnYStfVqGSWSdhDXHlNgI5pdAA0FzpyBk3ZX-JsxhwcnneKrYBBweq06kRMGWgvdbdAQ-7wSeGqqj5VPwA" }, }, - "SYMMETRIC": { + "SYMMETRIC128": { raw: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), + }, + "SYMMETRIC256": { + raw: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]), } } @@ -86,8 +89,11 @@ let toWrapKeyData = { kty: "OKP" } }, - "SYMMETRIC": { + "SYMMETRIC128": { raw: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16]), + }, + "SYMMETRIC256": { + raw: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]), } } diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index 0717125cb0a4b0..bf77f405074d91 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -96,7 +96,7 @@ "path": "web-locks" }, "WebCryptoAPI": { - "commit": "42e47329fdc92c80d58c2816eb66cb2cf2b32a89", + "commit": "c9e955840a21be6e492225a4a53fc4828d8933b9", "path": "WebCryptoAPI" }, "webidl": {