From 2c674a03e742fed1a83afb2b26e0df2d7200c781 Mon Sep 17 00:00:00 2001 From: "Node.js GitHub Bot" Date: Tue, 10 Mar 2026 15:23:07 +0000 Subject: [PATCH] test: update WPT for WebCryptoAPI to 6a1c545d77 --- test/fixtures/wpt/README.md | 2 +- .../digest/cshake.tentative.https.any.js | 41 +++- .../WebCryptoAPI/digest/digest.https.any.js | 24 +++ .../digest/sha3.tentative.https.any.js | 38 +++- .../wpt/WebCryptoAPI/encrypt_decrypt/aes.js | 126 +++++++++++ .../wpt/WebCryptoAPI/encrypt_decrypt/rsa.js | 179 ++++++++++++++-- .../wpt/WebCryptoAPI/sign_verify/ecdsa.js | 142 +++++++++++-- .../wpt/WebCryptoAPI/sign_verify/eddsa.js | 92 +++++++- .../wpt/WebCryptoAPI/sign_verify/hmac.js | 134 ++++++++++-- .../wpt/WebCryptoAPI/sign_verify/kmac.js | 148 ++++++++++++- .../wpt/WebCryptoAPI/sign_verify/mldsa.js | 200 ++++++++++++++++++ .../wpt/WebCryptoAPI/sign_verify/rsa.js | 134 ++++++++++-- .../wrapKey_unwrapKey.https.any.js | 6 +- test/fixtures/wpt/versions.json | 2 +- 14 files changed, 1187 insertions(+), 81 deletions(-) diff --git a/test/fixtures/wpt/README.md b/test/fixtures/wpt/README.md index 34dadc7a702755..89f0cefdb6363e 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/c9e955840a/WebCryptoAPI +- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/6a1c545d77/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/digest/cshake.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/digest/cshake.tentative.https.any.js index d5f790e42b4982..d0c23c09ada4a9 100644 --- a/test/fixtures/wpt/WebCryptoAPI/digest/cshake.tentative.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/digest/cshake.tentative.https.any.js @@ -195,17 +195,52 @@ Object.keys(digestedData).forEach(function (alg) { promise_test(function (test) { var buffer = new Uint8Array(sourceData[size]); - return crypto.subtle + var promise = crypto.subtle .digest({ name: alg, length: length }, buffer) .then(function (result) { - // Alter the buffer after calling digest - buffer[0] = ~buffer[0]; assert_true( equalBuffers(result, digestedData[alg][length][size]), 'digest matches expected' ); }); + // Alter the buffer after calling digest + buffer[0] = ~buffer[0]; + return promise; }, alg + ' with ' + length + ' bit output and ' + size + ' source data and altered buffer after call'); + + promise_test(function (test) { + var buffer = new Uint8Array(sourceData[size]); + return crypto.subtle + .digest({ + get name() { + // Transfer the buffer while calling digest + buffer.buffer.transfer(); + return alg; + }, + length + }, buffer) + .then(function (result) { + assert_true( + equalBuffers(result, digestedData[alg][length].empty), + 'digest on transferred buffer should match result for empty buffer' + ); + }); + }, alg + ' with ' + length + ' bit output and ' + size + ' source data and transferred buffer during call'); + + promise_test(function (test) { + var buffer = new Uint8Array(sourceData[size]); + var promise = crypto.subtle + .digest({ name: alg, length: length }, buffer) + .then(function (result) { + assert_true( + equalBuffers(result, digestedData[alg][length][size]), + 'digest matches expected' + ); + }); + // Transfer the buffer after calling digest + buffer.buffer.transfer(); + return promise; + }, alg + ' with ' + length + ' bit output and ' + size + ' source data and transferred buffer after call'); } }); }); diff --git a/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js b/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js index e0c85f8f6b30e4..47bc220d44fb70 100644 --- a/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/digest/digest.https.any.js @@ -113,6 +113,30 @@ copiedBuffer[0] = 255 - copiedBuffer[0]; return promise; }, upCase + " with " + size + " source data and altered buffer after call"); + + promise_test(function(test) { + var copiedBuffer = copyBuffer(sourceData[size]); + copiedBuffer.buffer.transfer(); + return subtle.digest({name: upCase}, copiedBuffer) + .then(function(result) { + assert_true(equalBuffers(result, digestedData[alg].empty), "digest() on transferred buffer should yield result for empty buffer for " + alg + ":" + size); + }, function(err) { + assert_unreached("digest() threw an error for transferred buffer for " + alg + ":" + size + ": " + err.message); + }); + }, upCase + " with " + size + " source data and transferred buffer during call"); + + promise_test(function(test) { + var copiedBuffer = copyBuffer(sourceData[size]); + var promise = subtle.digest({name: upCase}, copiedBuffer) + .then(function(result) { + assert_true(equalBuffers(result, digestedData[alg][size]), "digest() yielded expected result for " + alg + ":" + size); + }, function(err) { + assert_unreached("digest() threw an error for " + alg + ":" + size + " - " + err.message); + }); + + copiedBuffer.buffer.transfer(); + return promise; + }, upCase + " with " + size + " source data and transferred buffer after call"); } }); }); diff --git a/test/fixtures/wpt/WebCryptoAPI/digest/sha3.tentative.https.any.js b/test/fixtures/wpt/WebCryptoAPI/digest/sha3.tentative.https.any.js index fc33608e07ab14..4ae99791b8c95f 100644 --- a/test/fixtures/wpt/WebCryptoAPI/digest/sha3.tentative.https.any.js +++ b/test/fixtures/wpt/WebCryptoAPI/digest/sha3.tentative.https.any.js @@ -132,15 +132,47 @@ Object.keys(sourceData).forEach(function (size) { promise_test(function (test) { var buffer = new Uint8Array(sourceData[size]); - return crypto.subtle.digest(alg, buffer).then(function (result) { - // Alter the buffer after calling digest - buffer[0] = ~buffer[0]; + var promise = crypto.subtle.digest(alg, buffer).then(function (result) { assert_true( equalBuffers(result, digestedData[alg][size]), 'digest matches expected' ); }); + // Alter the buffer after calling digest + buffer[0] = ~buffer[0]; + return promise; }, alg + ' with ' + size + ' source data and altered buffer after call'); + + promise_test(function (test) { + var buffer = new Uint8Array(sourceData[size]); + return crypto.subtle + .digest({ + get name() { + // Transfer the buffer while calling digest + buffer.buffer.transfer(); + return alg; + } + }, buffer) + .then(function (result) { + assert_true( + equalBuffers(result, digestedData[alg].empty), + 'digest on transferred buffer should match result for empty buffer' + ); + }); + }, alg + ' with ' + size + ' source data and transferred buffer during call'); + + promise_test(function (test) { + var buffer = new Uint8Array(sourceData[size]); + var promise = crypto.subtle.digest(alg, buffer).then(function (result) { + assert_true( + equalBuffers(result, digestedData[alg][size]), + 'digest matches expected' + ); + }); + // Transfer the buffer after calling digest + buffer.buffer.transfer(); + return promise; + }, alg + ' with ' + size + ' source data and transferred buffer after call'); } }); }); diff --git a/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/aes.js b/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/aes.js index b157a94a0dc4fb..456f66423419c8 100644 --- a/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/aes.js +++ b/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/aes.js @@ -93,6 +93,67 @@ function run_test() { all_promises.push(promise); }); + // Check for encryption of an empty value if the buffer is transferred while calling encrypt. + passingVectors.forEach(function(vector) { + var plaintext = copyBuffer(vector.plaintext); + var promise = importVectorKey(vector, ["encrypt", "decrypt"]) + .then(function(vector) { + promise_test(function(test) { + var operation = subtle.encrypt({ + ...vector.algorithm, + get name() { + plaintext.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.key, plaintext) + .then(function(result) { + var expectedLength = + ["AES-GCM", "AES-OCB"].includes(vector.algorithm.name) ? vector.algorithm.tagLength / 8 : + vector.algorithm.name === "AES-CBC" ? 16 : + 0; + assert_equals(result.byteLength, expectedLength, "Transferred plaintext yields an empty ciphertext"); + }, function(err) { + assert_unreached("encrypt error for test " + vector.name + ": " + err.message); + }); + return operation; + }, vector.name + " with transferred plaintext during call"); + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importKey failed for " + vector.name); + }, "importKey step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful encryption even if the buffer is transferred after calling encrypt. + passingVectors.forEach(function(vector) { + var plaintext = copyBuffer(vector.plaintext); + var promise = importVectorKey(vector, ["encrypt", "decrypt"]) + .then(function(vector) { + promise_test(function(test) { + var operation = subtle.encrypt(vector.algorithm, vector.key, plaintext) + .then(function(result) { + assert_true(equalBuffers(result, vector.result), "Should return expected result"); + }, function(err) { + assert_unreached("encrypt error for test " + vector.name + ": " + err.message); + }); + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importKey failed for " + vector.name); + }, "importKey step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for successful decryption. passingVectors.forEach(function(vector) { var promise = importVectorKey(vector, ["encrypt", "decrypt"]) @@ -174,6 +235,71 @@ function run_test() { all_promises.push(promise); }); + // Check for decryption when ciphertext is transferred while calling decrypt. + passingVectors.forEach(function(vector) { + var ciphertext = copyBuffer(vector.result); + var promise = importVectorKey(vector, ["encrypt", "decrypt"]) + .then(function(vector) { + promise_test(function(test) { + var operation = subtle.decrypt({ + ...vector.algorithm, + get name() { + ciphertext.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.key, ciphertext) + .then(function(result) { + if (vector.algorithm.name === "AES-CTR") { + assert_equals(result.byteLength, 0, "Transferred ciphertext yields empty plaintext"); + } else { + assert_unreached("decrypt should not have succeeded for " + vector.name); + } + }, function(err) { + if (vector.algorithm.name === "AES-CTR") { + assert_unreached("decrypt error for test " + vector.name + ": " + err.message); + } else { + assert_equals(err.name, "OperationError", "Should throw an OperationError instead of " + err.message); + } + }); + return operation; + }, vector.name + " decryption with transferred ciphertext during call"); + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importKey failed for " + vector.name); + }, "importKey step for decryption: " + vector.name + " with transferred ciphertext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful decryption even if ciphertext is transferred after calling encrypt. + passingVectors.forEach(function(vector) { + var ciphertext = copyBuffer(vector.result); + var promise = importVectorKey(vector, ["encrypt", "decrypt"]) + .then(function(vector) { + promise_test(function(test) { + var operation = subtle.decrypt(vector.algorithm, vector.key, ciphertext) + .then(function(result) { + assert_true(equalBuffers(result, vector.plaintext), "Should return expected result"); + }, function(err) { + assert_unreached("decrypt error for test " + vector.name + ": " + err.message); + }); + ciphertext.buffer.transfer(); + return operation; + }, vector.name + " decryption with transferred ciphertext after call"); + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importKey failed for " + vector.name); + }, "importKey step for decryption: " + vector.name + " with transferred ciphertext after call"); + }); + + all_promises.push(promise); + }); + // Everything that succeeded should fail if no "encrypt" usage. passingVectors.forEach(function(vector) { // Don't want to overwrite key being used for success tests! diff --git a/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/rsa.js b/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/rsa.js index 76c90809783205..6f585cbe1ffcef 100644 --- a/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/rsa.js +++ b/test/fixtures/wpt/WebCryptoAPI/encrypt_decrypt/rsa.js @@ -25,7 +25,7 @@ function run_test() { .then(function(plaintext) { assert_true(equalBuffers(plaintext, vector.plaintext, "Decryption works")); }, function(err) { - assert_unreached("Decryption should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Decryption should not throw error " + vector.name + ": '" + err.message + "'"); }); }, vector.name + " decryption"); @@ -62,7 +62,7 @@ function run_test() { .then(function(plaintext) { assert_true(equalBuffers(plaintext, vector.plaintext, "Decryption works")); }, function(err) { - assert_unreached("Decryption should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Decryption should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; }, vector.name + " decryption with altered ciphertext during call"); @@ -78,7 +78,7 @@ function run_test() { all_promises.push(promise); }); - // Test decryption with an altered buffer + // Test decryption with an altered buffer after call passingVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) .then(function(vectors) { @@ -93,7 +93,7 @@ function run_test() { .then(function(plaintext) { assert_true(equalBuffers(plaintext, vector.plaintext, "Decryption works")); }, function(err) { - assert_unreached("Decryption should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Decryption should not throw error " + vector.name + ": '" + err.message + "'"); }); ciphertext[0] = 255 - ciphertext[0]; return operation; @@ -110,6 +110,75 @@ function run_test() { all_promises.push(promise); }); + // Test decryption with a transferred buffer during call + passingVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) + .then(function(vectors) { + // Get a one byte longer plaintext to encrypt + if (!("ciphertext" in vector)) { + return; + } + + promise_test(function(test) { + var ciphertext = copyBuffer(vector.ciphertext); + var operation = subtle.decrypt({ + ...vector.algorithm, + get name() { + ciphertext.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.privateKey, ciphertext) + .then(function(plaintext) { + assert_unreached("Decryption should not have succeeded for " + vector.name); + }, function(err) { + assert_equals(err.name, "OperationError", "Should throw OperationError instead of " + err.message); + }); + return operation; + }, vector.name + " decryption with transferred ciphertext during call"); + + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " decryption with transferred ciphertext during call"); + }); + + all_promises.push(promise); + }); + + // Test decryption with a transferred buffer after call + passingVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) + .then(function(vectors) { + // Get a one byte longer plaintext to encrypt + if (!("ciphertext" in vector)) { + return; + } + + promise_test(function(test) { + var ciphertext = copyBuffer(vector.ciphertext); + var operation = subtle.decrypt(vector.algorithm, vector.privateKey, ciphertext) + .then(function(plaintext) { + assert_true(equalBuffers(plaintext, vector.plaintext, "Decryption works")); + }, function(err) { + assert_unreached("Decryption should not throw error " + vector.name + ": '" + err.message + "'"); + }); + ciphertext.buffer.transfer(); + return operation; + }, vector.name + " decryption with transferred ciphertext after call"); + + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " decryption with transferred ciphertext after call"); + }); + + all_promises.push(promise); + }); + // Check for failures due to using publicKey to decrypt. passingVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) @@ -117,7 +186,7 @@ function run_test() { promise_test(function(test) { return subtle.decrypt(vector.algorithm, vector.publicKey, vector.ciphertext) .then(function(plaintext) { - assert_unreached("Should have thrown error for using publicKey to decrypt in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using publicKey to decrypt in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of " + err.message); }); @@ -145,7 +214,7 @@ function run_test() { promise_test(function(test) { return subtle.decrypt(vector.algorithm, vector.publicKey, vector.ciphertext) .then(function(plaintext) { - assert_unreached("Should have thrown error for no decrypt usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no decrypt usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of " + err.message); }); @@ -185,7 +254,7 @@ function run_test() { assert_true(equalBuffers(result, vector.plaintext), "Round trip returns original plaintext"); return ciphertext; }, function(err) { - assert_unreached("decrypt error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); }); }) .then(function(priorCiphertext) { @@ -229,7 +298,7 @@ function run_test() { assert_true(equalBuffers(result, vector.plaintext), "Round trip returns original plaintext"); return ciphertext; }, function(err) { - assert_unreached("decrypt error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); }); }) .then(function(priorCiphertext) { @@ -259,6 +328,92 @@ function run_test() { all_promises.push(promise); }); + // Check for encryption of an empty value if plaintext is transferred during call. + passingVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) + .then(function(vectors) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.encrypt({ + ...vector.algorithm, + get name() { + plaintext.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.publicKey, plaintext) + .then(function(ciphertext) { + assert_equals(ciphertext.byteLength * 8, vector.privateKey.algorithm.modulusLength, "Ciphertext length matches modulus length"); + // Do we get an empty plaintext back via decrypt? + return subtle.decrypt(vector.algorithm, vector.privateKey, ciphertext) + .then(function(result) { + assert_equals(result.byteLength, 0, "Decryption returns empty plaintext"); + return ciphertext; + }, function(err) { + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); + }); + }, function(err) { + assert_unreached("encrypt error for test " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " with transferred plaintext during call"); + + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful encryption even if plaintext is transferred after call. + passingVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) + .then(function(vectors) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.encrypt(vector.algorithm, vector.publicKey, plaintext) + .then(function(ciphertext) { + assert_equals(ciphertext.byteLength * 8, vector.privateKey.algorithm.modulusLength, "Ciphertext length matches modulus length"); + // Can we get the original plaintext back via decrypt? + return subtle.decrypt(vector.algorithm, vector.privateKey, ciphertext) + .then(function(result) { + assert_true(equalBuffers(result, vector.plaintext), "Round trip returns original plaintext"); + return ciphertext; + }, function(err) { + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); + }); + }) + .then(function(priorCiphertext) { + // Will a second encrypt give us different ciphertext, as it should? + return subtle.encrypt(vector.algorithm, vector.publicKey, vector.plaintext) + .then(function(ciphertext) { + assert_false(equalBuffers(priorCiphertext, ciphertext), "Two encrypts give different results") + }, function(err) { + assert_unreached("second time encrypt error for test " + vector.name + ": '" + err.message + "'"); + }); + }, function(err) { + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); + }); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + + }, function(err) { + // We need a failed test if the importVectorKey operation fails, so + // we know we never tested encryption + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for successful encryption. passingVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["encrypt"], ["decrypt"]) @@ -274,7 +429,7 @@ function run_test() { assert_true(equalBuffers(result, vector.plaintext), "Round trip returns original plaintext"); return ciphertext; }, function(err) { - assert_unreached("decrypt error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("decrypt error for test " + vector.name + ": '" + err.message + "'"); }); }) .then(function(priorCiphertext) { @@ -312,7 +467,7 @@ function run_test() { promise_test(function(test) { return subtle.encrypt(vector.algorithm, vector.publicKey, plaintext) .then(function(ciphertext) { - assert_unreached("Should have thrown error for too long plaintext in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for too long plaintext in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "OperationError", "Should throw OperationError instead of " + err.message); }); @@ -337,7 +492,7 @@ function run_test() { promise_test(function(test) { return subtle.encrypt(vector.algorithm, vector.privateKey, vector.plaintext) .then(function(ciphertext) { - assert_unreached("Should have thrown error for using privateKey to encrypt in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using privateKey to encrypt in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of " + err.message); }); @@ -365,7 +520,7 @@ function run_test() { promise_test(function(test) { return subtle.encrypt(vector.algorithm, vector.publicKey, vector.plaintext) .then(function(ciphertext) { - assert_unreached("Should have thrown error for no encrypt usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no encrypt usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of " + err.message); }); diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/ecdsa.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/ecdsa.js index 9b47868fe32bfb..b2e0bf606b5fee 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/ecdsa.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/ecdsa.js @@ -22,7 +22,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -57,7 +57,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -82,7 +82,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); signature[0] = 255 - signature[0]; @@ -97,6 +97,63 @@ function run_test() { all_promises.push(promise); }); + // Test verification with a transferred buffer during call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var algorithm = { + get name() { + signature.buffer.transfer(); + return vector.algorithmName; + }, + hash: vector.hashName + }; + var operation = subtle.verify(algorithm, vector.publicKey, signature, vector.plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " verification with transferred signature during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature during call"); + }); + + all_promises.push(promise); + }); + + // Test verification with a transferred buffer after call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + var algorithm = {name: vector.algorithmName, hash: vector.hashName}; + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var operation = subtle.verify(algorithm, vector.publicKey, signature, vector.plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + signature.buffer.transfer(); + return operation; + }, vector.name + " verification with transferred signature after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature after call"); + }); + + all_promises.push(promise); + }); + // Check for successful verification even if plaintext is altered during call. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify"], ["sign"]) @@ -115,7 +172,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -140,7 +197,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); plaintext[0] = 255 - plaintext[0]; @@ -155,6 +212,63 @@ function run_test() { all_promises.push(promise); }); + // Check for failed verification if plaintext is transferred during call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var algorithm = { + get name() { + plaintext.buffer.transfer(); + return vector.algorithmName; + }, + hash: vector.hashName + }; + var operation = subtle.verify(algorithm, vector.publicKey, vector.signature, plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " with transferred plaintext during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful verification even if plaintext is transferred after call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + var algorithm = {name: vector.algorithmName, hash: vector.hashName}; + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.verify(algorithm, vector.publicKey, vector.signature, plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for failures due to using privateKey to verify. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify"], ["sign"]) @@ -163,7 +277,7 @@ function run_test() { promise_test(function(test) { return subtle.verify(algorithm, vector.privateKey, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for using privateKey to verify in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using privateKey to verify in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -186,7 +300,7 @@ function run_test() { promise_test(function(test) { return subtle.sign(algorithm, vector.publicKey, vector.plaintext) .then(function(signature) { - assert_unreached("Should have thrown error for using publicKey to sign in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using publicKey to sign in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -210,7 +324,7 @@ function run_test() { promise_test(function(test) { return subtle.verify(algorithm, vector.publicKey, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -238,7 +352,7 @@ function run_test() { assert_true(is_verified, "Round trip verification works"); return signature; }, function(err) { - assert_unreached("verify error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("verify error for test " + vector.name + ": '" + err.message + "'"); }); }, function(err) { assert_unreached("sign error for test " + vector.name + ": '" + err.message + "'"); @@ -338,7 +452,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -369,7 +483,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -426,7 +540,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -455,7 +569,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -482,7 +596,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature unexpectedly verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/eddsa.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/eddsa.js index 4bf1887b2ae9bb..5ff6f21150c272 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/eddsa.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/eddsa.js @@ -18,7 +18,7 @@ function run_test(algorithmName) { isVerified = await subtle.verify(algorithm, key, vector.signature, vector.data) } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Signature verified"); }, vector.name + " verification"); @@ -39,7 +39,7 @@ function run_test(algorithmName) { }, key, signature, vector.data); } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Signature verified"); }, vector.name + " verification with altered signature during call"); @@ -57,11 +57,48 @@ function run_test(algorithmName) { ]); } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Signature verified"); }, vector.name + " verification with altered signature after call"); + // Test verification with a transferred buffer during call + promise_test(async() => { + let isVerified = false; + let key; + try { + key = await subtle.importKey("spki", vector.publicKeyBuffer, algorithm, false, ["verify"]); + var signature = copyBuffer(vector.signature); + isVerified = await subtle.verify({ + get name() { + signature.buffer.transfer(); + return vector.algorithmName; + } + }, key, signature, vector.data); + } catch (err) { + assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }; + assert_false(isVerified, "Signature is NOT verified"); + }, vector.name + " verification with transferred signature during call"); + + // Test verification with a transferred buffer after call + promise_test(async() => { + let isVerified = false; + let key; + try { + key = await subtle.importKey("spki", vector.publicKeyBuffer, algorithm, false, ["verify"]); + var signature = copyBuffer(vector.signature); + var operation = subtle.verify(algorithm, key, signature, vector.data); + signature.buffer.transfer(); + isVerified = await operation; + } catch (err) { + assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }; + assert_true(isVerified, "Signature verified"); + }, vector.name + " verification with transferred signature after call"); + // Check for successful verification even if data is altered during call. promise_test(async() => { let isVerified = false; @@ -78,7 +115,7 @@ function run_test(algorithmName) { }, key, vector.signature, data); } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Signature verified"); }, vector.name + " with altered data during call"); @@ -96,11 +133,48 @@ function run_test(algorithmName) { ]); } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Signature verified"); }, vector.name + " with altered data after call"); + // Check for failed verification if data is transferred during call. + promise_test(async() => { + let isVerified = false; + let key; + try { + key = await subtle.importKey("spki", vector.publicKeyBuffer, algorithm, false, ["verify"]); + var data = copyBuffer(vector.data); + isVerified = await subtle.verify({ + get name() { + data.buffer.transfer(); + return vector.algorithmName; + } + }, key, vector.signature, data); + } catch (err) { + assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }; + assert_false(isVerified, "Signature is NOT verified"); + }, vector.name + " with transferred data during call"); + + // Check for successful verification even if data is transferred after call. + promise_test(async() => { + let isVerified = false; + let key; + try { + key = await subtle.importKey("spki", vector.publicKeyBuffer, algorithm, false, ["verify"]); + var data = copyBuffer(vector.data); + var operation = subtle.verify(algorithm, key, vector.signature, data); + data.buffer.transfer(); + isVerified = await operation; + } catch (err) { + assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }; + assert_true(isVerified, "Signature verified"); + }, vector.name + " with transferred data after call"); + // Check for failures due to using privateKey to verify. promise_test(async() => { let isVerified = false; @@ -165,7 +239,7 @@ function run_test(algorithmName) { } catch (err) { assert_false(publicKey === undefined || privateKey === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); assert_false(signature === undefined, "sign error for test " + vector.name + ": '" + err.message + "'"); - assert_unreached("verify error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("verify error for test " + vector.name + ": '" + err.message + "'"); }; assert_true(isVerified, "Round trip verification works"); }, vector.name + " round trip"); @@ -214,7 +288,7 @@ function run_test(algorithmName) { isVerified = await subtle.verify(algorithm, key, signature, vector.data) } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_false(isVerified, "Signature verified"); }, vector.name + " verification failure due to altered signature"); @@ -229,7 +303,7 @@ function run_test(algorithmName) { isVerified = await subtle.verify(algorithm, key, signature, vector.data) } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_false(isVerified, "Signature verified"); }, vector.name + " verification failure due to shortened signature"); @@ -245,7 +319,7 @@ function run_test(algorithmName) { isVerified = await subtle.verify(algorithm, key, vector.signature, data) } catch (err) { assert_false(key === undefined, "importKey failed for " + vector.name + ". Message: ''" + err.message + "''"); - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }; assert_false(isVerified, "Signature verified"); }, vector.name + " verification failure due to altered data"); diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.js index dff8c994d83de0..8a099f4ce9377a 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/hmac.js @@ -20,7 +20,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -45,16 +45,16 @@ function run_test() { var signature = copyBuffer(vector.signature); signature[0] = 255 - signature[0]; var operation = subtle.verify({ - hash: vector.hash, get name() { signature[0] = vector.signature[0]; return "HMAC"; - } + }, + hash: vector.hash }, vector.key, signature, vector.plaintext) .then(function(is_verified) { assert_true(is_verified, "Signature is not verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -78,7 +78,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature is not verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); signature[0] = 255 - signature[0]; @@ -93,6 +93,61 @@ function run_test() { all_promises.push(promise); }); + // Test verification with a transferred buffer during call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var operation = subtle.verify({ + get name() { + signature.buffer.transfer(); + return "HMAC"; + }, + hash: vector.hash + }, vector.key, signature, vector.plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " verification with transferred signature during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature during call"); + }); + + all_promises.push(promise); + }); + + // Test verification with a transferred buffer after call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var operation = subtle.verify({name: "HMAC", hash: vector.hash}, vector.key, signature, vector.plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature is not verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + signature.buffer.transfer(); + return operation; + }, vector.name + " verification with transferred signature after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature after call"); + }); + + all_promises.push(promise); + }); + // Check for successful verification even if plaintext is altered during call. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify", "sign"]) @@ -110,7 +165,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -134,7 +189,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); plaintext[0] = 255 - plaintext[0]; @@ -149,6 +204,61 @@ function run_test() { all_promises.push(promise); }); + // Check for failed verification if plaintext is transferred during call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.verify({ + get name() { + plaintext.buffer.transfer(); + return "HMAC"; + }, + hash: vector.hash + }, vector.key, vector.signature, plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " with transferred plaintext during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful verification even if plaintext is transferred after call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.verify({name: "HMAC", hash: vector.hash}, vector.key, vector.signature, plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for failures due to no "verify" usage. testVectors.forEach(function(originalVector) { var vector = Object.assign({}, originalVector); @@ -158,7 +268,7 @@ function run_test() { promise_test(function(test) { return subtle.verify({name: "HMAC", hash: vector.hash}, vector.key, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -186,7 +296,7 @@ function run_test() { assert_true(is_verified, "Round trip verifies"); return signature; }, function(err) { - assert_unreached("verify error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("verify error for test " + vector.name + ": '" + err.message + "'"); }); }); }, vector.name + " round trip"); @@ -281,7 +391,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -309,7 +419,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -336,7 +446,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/kmac.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/kmac.js index 57c9dc6f34790a..f3cc9b4cd1dbfd 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/kmac.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/kmac.js @@ -23,7 +23,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -61,7 +61,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature is not verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -89,7 +89,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature is not verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); signature[0] = 255 - signature[0]; @@ -104,6 +104,69 @@ function run_test() { all_promises.push(promise); }); + // Test verification with a transferred buffer during call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var algorithmParams = { + get name() { + signature.buffer.transfer(); + return vector.algorithm; + }, + length: vector.length + }; + if (vector.customization !== undefined) { + algorithmParams.customization = vector.customization; + } + var operation = subtle.verify(algorithmParams, vector.key, signature, vector.plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " verification with transferred signature during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature during call"); + }); + + all_promises.push(promise); + }); + + // Test verification with a transferred buffer after call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var algorithmParams = {name: vector.algorithm, length: vector.length}; + if (vector.customization !== undefined) { + algorithmParams.customization = vector.customization; + } + var operation = subtle.verify(algorithmParams, vector.key, signature, vector.plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature is not verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + signature.buffer.transfer(); + return operation; + }, vector.name + " verification with transferred signature after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature after call"); + }); + + all_promises.push(promise); + }); + // Check for successful verification even if plaintext is altered during call. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify", "sign"]) @@ -125,7 +188,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -153,7 +216,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); plaintext[0] = 255 - plaintext[0]; @@ -168,6 +231,69 @@ function run_test() { all_promises.push(promise); }); + // Check for failed verification if plaintext is transferred during call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var algorithmParams = { + get name() { + plaintext.buffer.transfer(); + return vector.algorithm; + }, + length: vector.length + }; + if (vector.customization !== undefined) { + algorithmParams.customization = vector.customization; + } + var operation = subtle.verify(algorithmParams, vector.key, vector.signature, plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " with transferred plaintext during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful verification even if plaintext is transferred after call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify", "sign"]) + .then(function(vector) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var algorithmParams = {name: vector.algorithm, length: vector.length}; + if (vector.customization !== undefined) { + algorithmParams.customization = vector.customization; + } + var operation = subtle.verify(algorithmParams, vector.key, vector.signature, plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for failures due to no "verify" usage. testVectors.forEach(function(originalVector) { var vector = Object.assign({}, originalVector); @@ -181,7 +307,7 @@ function run_test() { } return subtle.verify(algorithmParams, vector.key, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -213,7 +339,7 @@ function run_test() { assert_true(is_verified, "Round trip verifies"); return signature; }, function(err) { - assert_unreached("verify error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("verify error for test " + vector.name + ": '" + err.message + "'"); }); }); }, vector.name + " round trip"); @@ -320,7 +446,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -352,7 +478,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -383,7 +509,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -414,7 +540,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature is NOT verified with wrong length"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/mldsa.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/mldsa.js index 88143a33879ed7..9c654685c74f31 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/mldsa.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/mldsa.js @@ -156,6 +156,106 @@ function run_test() { all_promises.push(promise); }); + // Test verification with a transferred buffer during call + testVectors.forEach(function (vector) { + var promise = importVectorKeys(vector, ['verify'], ['sign']).then( + function (vectors) { + promise_test(function (test) { + var signature = copyBuffer(vector.signature); + var operation = subtle + .verify( + { + get name() { + signature.buffer.transfer(); + return vector.algorithmName; + }, + }, + vector.publicKey, + signature, + vector.data + ) + .then( + function (is_verified) { + assert_false(is_verified, 'Signature is NOT verified'); + }, + function (err) { + assert_unreached( + 'Verification should not throw error ' + + vector.name + + ': ' + + err.message + + "'" + ); + } + ); + + return operation; + }, vector.name + ' verification with transferred signature during call'); + }, + function (err) { + promise_test(function (test) { + assert_unreached( + 'importVectorKeys failed for ' + + vector.name + + ". Message: ''" + + err.message + + "''" + ); + }, 'importVectorKeys step: ' + + vector.name + + ' verification with transferred signature during call'); + } + ); + + all_promises.push(promise); + }); + + // Test verification with a transferred buffer after call + testVectors.forEach(function (vector) { + var promise = importVectorKeys(vector, ['verify'], ['sign']).then( + function (vectors) { + var algorithm = vector.algorithmName; + promise_test(function (test) { + var signature = copyBuffer(vector.signature); + var operation = subtle + .verify(algorithm, vector.publicKey, signature, vector.data) + .then( + function (is_verified) { + assert_true(is_verified, 'Signature verified'); + }, + function (err) { + assert_unreached( + 'Verification should not throw error ' + + vector.name + + ': ' + + err.message + + "'" + ); + } + ); + + signature.buffer.transfer(); + return operation; + }, vector.name + ' verification with transferred signature after call'); + }, + function (err) { + promise_test(function (test) { + assert_unreached( + 'importVectorKeys failed for ' + + vector.name + + ". Message: ''" + + err.message + + "''" + ); + }, 'importVectorKeys step: ' + + vector.name + + ' verification with transferred signature after call'); + } + ); + + all_promises.push(promise); + }); + // Check for successful verification even if plaintext is altered during call. testVectors.forEach(function (vector) { var promise = importVectorKeys(vector, ['verify'], ['sign']).then( @@ -257,6 +357,106 @@ function run_test() { all_promises.push(promise); }); + // Check for failed verification if plaintext is transferred during call. + testVectors.forEach(function (vector) { + var promise = importVectorKeys(vector, ['verify'], ['sign']).then( + function (vectors) { + promise_test(function (test) { + var plaintext = copyBuffer(vector.data); + var operation = subtle + .verify( + { + get name() { + plaintext.buffer.transfer(); + return vector.algorithmName; + }, + }, + vector.publicKey, + vector.signature, + plaintext + ) + .then( + function (is_verified) { + assert_false(is_verified, 'Signature is NOT verified'); + }, + function (err) { + assert_unreached( + 'Verification should not throw error ' + + vector.name + + ': ' + + err.message + + "'" + ); + } + ); + + return operation; + }, vector.name + ' with transferred plaintext during call'); + }, + function (err) { + promise_test(function (test) { + assert_unreached( + 'importVectorKeys failed for ' + + vector.name + + ". Message: ''" + + err.message + + "''" + ); + }, 'importVectorKeys step: ' + + vector.name + + ' with transferred plaintext during call'); + } + ); + + all_promises.push(promise); + }); + + // Check for successful verification even if plaintext is transferred after call. + testVectors.forEach(function (vector) { + var promise = importVectorKeys(vector, ['verify'], ['sign']).then( + function (vectors) { + var algorithm = vector.algorithmName; + promise_test(function (test) { + var plaintext = copyBuffer(vector.data); + var operation = subtle + .verify(algorithm, vector.publicKey, vector.signature, plaintext) + .then( + function (is_verified) { + assert_true(is_verified, 'Signature verified'); + }, + function (err) { + assert_unreached( + 'Verification should not throw error ' + + vector.name + + ': ' + + err.message + + "'" + ); + } + ); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + ' with transferred plaintext after call'); + }, + function (err) { + promise_test(function (test) { + assert_unreached( + 'importVectorKeys failed for ' + + vector.name + + ". Message: ''" + + err.message + + "''" + ); + }, 'importVectorKeys step: ' + + vector.name + + ' with transferred plaintext after call'); + } + ); + + all_promises.push(promise); + }); + // Check for failures due to using privateKey to verify. testVectors.forEach(function (vector) { var promise = importVectorKeys(vector, ['verify'], ['sign']).then( diff --git a/test/fixtures/wpt/WebCryptoAPI/sign_verify/rsa.js b/test/fixtures/wpt/WebCryptoAPI/sign_verify/rsa.js index f808714cfb11d4..09c7ceb7675107 100644 --- a/test/fixtures/wpt/WebCryptoAPI/sign_verify/rsa.js +++ b/test/fixtures/wpt/WebCryptoAPI/sign_verify/rsa.js @@ -20,7 +20,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -54,7 +54,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -78,7 +78,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); signature[0] = 255 - signature[0]; @@ -93,6 +93,61 @@ function run_test() { all_promises.push(promise); }); + // Test verification with a transferred buffer during call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var operation = subtle.verify({ + ...vector.algorithm, + get name() { + signature.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.publicKey, signature, vector.plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " verification with transferred signature during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature during call"); + }); + + all_promises.push(promise); + }); + + // Test verification with a transferred buffer after call + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var signature = copyBuffer(vector.signature); + var operation = subtle.verify(vector.algorithm, vector.publicKey, signature, vector.plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + signature.buffer.transfer(); + return operation; + }, vector.name + " verification with transferred signature after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " verification with transferred signature after call"); + }); + + all_promises.push(promise); + }); + // Check for successful verification even if plaintext is altered during call. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify"], ["sign"]) @@ -110,7 +165,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -134,7 +189,7 @@ function run_test() { .then(function(is_verified) { assert_true(is_verified, "Signature verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); plaintext[0] = 255 - plaintext[0]; @@ -149,6 +204,61 @@ function run_test() { all_promises.push(promise); }); + // Check for failed verification if plaintext is transferred during call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.verify({ + ...vector.algorithm, + get name() { + plaintext.buffer.transfer(); + return vector.algorithm.name; + } + }, vector.publicKey, vector.signature, plaintext) + .then(function(is_verified) { + assert_false(is_verified, "Signature is NOT verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + return operation; + }, vector.name + " with transferred plaintext during call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext during call"); + }); + + all_promises.push(promise); + }); + + // Check for successful verification even if plaintext is transferred after call. + testVectors.forEach(function(vector) { + var promise = importVectorKeys(vector, ["verify"], ["sign"]) + .then(function(vectors) { + promise_test(function(test) { + var plaintext = copyBuffer(vector.plaintext); + var operation = subtle.verify(vector.algorithm, vector.publicKey, vector.signature, plaintext) + .then(function(is_verified) { + assert_true(is_verified, "Signature verified"); + }, function(err) { + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); + }); + + plaintext.buffer.transfer(); + return operation; + }, vector.name + " with transferred plaintext after call"); + }, function(err) { + promise_test(function(test) { + assert_unreached("importVectorKeys failed for " + vector.name + ". Message: ''" + err.message + "''"); + }, "importVectorKeys step: " + vector.name + " with transferred plaintext after call"); + }); + + all_promises.push(promise); + }); + // Check for failures due to using privateKey to verify. testVectors.forEach(function(vector) { var promise = importVectorKeys(vector, ["verify"], ["sign"]) @@ -156,7 +266,7 @@ function run_test() { promise_test(function(test) { return subtle.verify(vector.algorithm, vector.privateKey, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for using privateKey to verify in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using privateKey to verify in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -178,7 +288,7 @@ function run_test() { promise_test(function(test) { return subtle.sign(vector.algorithm, vector.publicKey, vector.plaintext) .then(function(signature) { - assert_unreached("Should have thrown error for using publicKey to sign in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for using publicKey to sign in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -201,7 +311,7 @@ function run_test() { promise_test(function(test) { return subtle.verify(vector.algorithm, vector.publicKey, vector.signature, vector.plaintext) .then(function(plaintext) { - assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": " + err.message + "'"); + assert_unreached("Should have thrown error for no verify usage in " + vector.name + ": '" + err.message + "'"); }, function(err) { assert_equals(err.name, "InvalidAccessError", "Should throw InvalidAccessError instead of '" + err.message + "'"); }); @@ -234,7 +344,7 @@ function run_test() { assert_true(is_verified, "Round trip verifies"); return signature; }, function(err) { - assert_unreached("verify error for test " + vector.name + ": " + err.message + "'"); + assert_unreached("verify error for test " + vector.name + ": '" + err.message + "'"); }); }) .then(function(priorSignature) { @@ -351,7 +461,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -379,7 +489,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; @@ -408,7 +518,7 @@ function run_test() { .then(function(is_verified) { assert_false(is_verified, "Signature NOT verified"); }, function(err) { - assert_unreached("Verification should not throw error " + vector.name + ": " + err.message + "'"); + assert_unreached("Verification should not throw error " + vector.name + ": '" + err.message + "'"); }); return operation; 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 e40b4b6d35f794..880f7d650964ae 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 @@ -75,7 +75,7 @@ var wrapper = wrappers[wrapperParam.name]; keysToWrapParameters.filter((param) => Object.keys(keys).includes(param.algorithm.name)).forEach(function(toWrapParam) { var keyData = keys[toWrapParam.algorithm.name]; - ["raw", "spki", "pkcs8"].filter((fmt) => Object.keys(keyData).includes(fmt)).forEach(function(keyDataFormat) { + ["raw", "raw-secret", "spki", "pkcs8"].filter((fmt) => Object.keys(keyData).includes(fmt)).forEach(function(keyDataFormat) { var toWrap = keyData[keyDataFormat]; [keyDataFormat, "jwk"].forEach(function(format) { if (wrappingIsPossible(toWrap.originalExport[format], wrapper.parameters.name)) { @@ -114,7 +114,7 @@ })); } else if (params.name === "ChaCha20-Poly1305") { var algorithm = {name: params.name}; - promises.push(subtle.importKey("raw", wrappingKeyData["SYMMETRIC256"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) + promises.push(subtle.importKey("raw-secret", wrappingKeyData["SYMMETRIC256"].raw, algorithm, true, ["wrapKey", "unwrapKey"]) .then(function(key) { wrappers[params.name] = {wrappingKey: key, unwrappingKey: key, parameters: params}; })); @@ -165,7 +165,7 @@ 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, "")); + promises.push(importAndExport("raw-secret", toWrapKeyData["SYMMETRIC256"].raw, params.algorithm, params.usages, "")); } else { keys[params.algorithm.name] = {}; promises.push(importAndExport("raw", toWrapKeyData["SYMMETRIC128"].raw, params.algorithm, params.usages, "")); diff --git a/test/fixtures/wpt/versions.json b/test/fixtures/wpt/versions.json index a3b6c290982f88..ba7488a89a20b9 100644 --- a/test/fixtures/wpt/versions.json +++ b/test/fixtures/wpt/versions.json @@ -96,7 +96,7 @@ "path": "web-locks" }, "WebCryptoAPI": { - "commit": "c9e955840a21be6e492225a4a53fc4828d8933b9", + "commit": "6a1c545d778f115c84a1c27c25484afd442b89d8", "path": "WebCryptoAPI" }, "webidl": {