mirror of
https://github.com/nodejs/node.git
synced 2026-11-30 11:55:44 -05:00
test: update WPT resources, interfaces and WebCryptoAPI
PR-URL: https://github.com/nodejs/node/pull/62389 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
1 parent
d4fa60cf9f
commit
1baafcc882
83 files changed
+2365
-2441
No files matched your search
Vendored
+3
-3
@@ -23,10 +23,10 @@ Last update:
|
||||
- html/webappapis/microtask-queuing: https://github.com/web-platform-tests/wpt/tree/2c5c3c4c27/html/webappapis/microtask-queuing
|
||||
- html/webappapis/structured-clone: https://github.com/web-platform-tests/wpt/tree/47d3fb280c/html/webappapis/structured-clone
|
||||
- html/webappapis/timers: https://github.com/web-platform-tests/wpt/tree/5873f2d8f1/html/webappapis/timers
|
||||
- interfaces: https://github.com/web-platform-tests/wpt/tree/e1b27be06b/interfaces
|
||||
- interfaces: https://github.com/web-platform-tests/wpt/tree/a8392bd021/interfaces
|
||||
- performance-timeline: https://github.com/web-platform-tests/wpt/tree/94caab7038/performance-timeline
|
||||
- resource-timing: https://github.com/web-platform-tests/wpt/tree/22d38586d0/resource-timing
|
||||
- resources: https://github.com/web-platform-tests/wpt/tree/1d2c5fb36a/resources
|
||||
- resources: https://github.com/web-platform-tests/wpt/tree/6a2f322376/resources
|
||||
- streams: https://github.com/web-platform-tests/wpt/tree/bc9dcbbf1a/streams
|
||||
- url: https://github.com/web-platform-tests/wpt/tree/c928b19ab0/url
|
||||
- urlpattern: https://github.com/web-platform-tests/wpt/tree/a2e15ad405/urlpattern
|
||||
@@ -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/0acea989ac/WebCryptoAPI
|
||||
- WebCryptoAPI: https://github.com/web-platform-tests/wpt/tree/caebe89c3b/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
|
||||
|
||||
@@ -51,7 +51,6 @@ function define_tests() {
|
||||
var algorithmName = vector.algorithm;
|
||||
var password = vector.password;
|
||||
|
||||
// Key for normal operations
|
||||
promises.push(
|
||||
subtle
|
||||
.importKey('raw-secret', password, algorithmName, false, [
|
||||
@@ -70,20 +69,3 @@ function define_tests() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aView = new Uint8Array(a);
|
||||
var bView = new Uint8Array(b);
|
||||
|
||||
for (var i = 0; i < aView.length; i++) {
|
||||
if (aView[i] !== bView[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
// META: title=WebCryptoAPI: deriveBits() Using Argon2
|
||||
// META: timeout=long
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=/common/subset-tests.js
|
||||
// META: script=argon2_vectors.js
|
||||
// META: script=argon2.js
|
||||
|
||||
@@ -2,7 +2,6 @@ function getTestData() {
|
||||
// Test vectors from RFC 9106
|
||||
// https://www.rfc-editor.org/rfc/rfc9106
|
||||
|
||||
// Test vectors from RFC 9106
|
||||
var testVectors = [
|
||||
// Argon2d test vector
|
||||
{
|
||||
|
||||
@@ -224,37 +224,4 @@ function define_tests(algorithmName) {
|
||||
.then(function(results) {return {privateKeys: privateKeys, publicKeys: publicKeys, noDeriveBitsKeys: noDeriveBitsKeys, ecdhKeys: ecdhPublicKeys}});
|
||||
}
|
||||
|
||||
// Compares two ArrayBuffer or ArrayBufferView objects. If bitCount is
|
||||
// omitted, the two values must be the same length and have the same contents
|
||||
// in every byte. If bitCount is included, only that leading number of bits
|
||||
// have to match.
|
||||
function equalBuffers(a, b, bitCount) {
|
||||
var remainder;
|
||||
|
||||
if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
var length = a.byteLength;
|
||||
if (typeof bitCount !== "undefined") {
|
||||
length = Math.floor(bitCount / 8);
|
||||
}
|
||||
|
||||
for (var i=0; i<length; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof bitCount !== "undefined") {
|
||||
remainder = bitCount % 8;
|
||||
return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveKey() Using ECDH with CFRG Elliptic Curves
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=cfrg_curves_bits_fixtures.js
|
||||
// META: script=cfrg_curves_bits.js
|
||||
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveKey() Using ECDH with CFRG Elliptic Curves
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=cfrg_curves_bits_fixtures.js
|
||||
// META: script=cfrg_curves_bits.js
|
||||
|
||||
|
||||
@@ -221,37 +221,4 @@ function define_tests(algorithmName) {
|
||||
.then(function(results) {return {privateKeys: privateKeys, publicKeys: publicKeys, noDeriveKeyKeys: noDeriveKeyKeys, ecdhKeys: ecdhPublicKeys}});
|
||||
}
|
||||
|
||||
// Compares two ArrayBuffer or ArrayBufferView objects. If bitCount is
|
||||
// omitted, the two values must be the same length and have the same contents
|
||||
// in every byte. If bitCount is included, only that leading number of bits
|
||||
// have to match.
|
||||
function equalBuffers(a, b, bitCount) {
|
||||
var remainder;
|
||||
|
||||
if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
var length = a.byteLength;
|
||||
if (typeof bitCount !== "undefined") {
|
||||
length = Math.floor(bitCount / 8);
|
||||
}
|
||||
|
||||
for (var i=0; i<length; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof bitCount !== "undefined") {
|
||||
remainder = bitCount % 8;
|
||||
return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveKey() Using ECDH with CFRG Elliptic Curves
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=cfrg_curves_bits_fixtures.js
|
||||
// META: script=cfrg_curves_keys.js
|
||||
|
||||
|
||||
Vendored
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveKey() Using ECDH with CFRG Elliptic Curves
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=cfrg_curves_bits_fixtures.js
|
||||
// META: script=cfrg_curves_keys.js
|
||||
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveBits() tests for the 'length' parameter
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=derived_bits_length.js
|
||||
// META: script=derived_bits_length_vectors.js
|
||||
// META: script=derived_bits_length_testcases.js
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveBits() Using ECDH
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=ecdh_bits.js
|
||||
|
||||
// Define subtests from a `promise_test` to ensure the harness does not
|
||||
|
||||
@@ -230,37 +230,4 @@ function define_tests() {
|
||||
.then(function(results) {return {privateKeys: privateKeys, publicKeys: publicKeys, ecdsaKeyPairs: ecdsaKeyPairs, noDeriveBitsKeys: noDeriveBitsKeys}});
|
||||
}
|
||||
|
||||
// Compares two ArrayBuffer or ArrayBufferView objects. If bitCount is
|
||||
// omitted, the two values must be the same length and have the same contents
|
||||
// in every byte. If bitCount is included, only that leading number of bits
|
||||
// have to match.
|
||||
function equalBuffers(a, b, bitCount) {
|
||||
var remainder;
|
||||
|
||||
if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
var length = a.byteLength;
|
||||
if (typeof bitCount !== "undefined") {
|
||||
length = Math.floor(bitCount / 8);
|
||||
}
|
||||
|
||||
for (var i=0; i<length; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof bitCount !== "undefined") {
|
||||
remainder = bitCount % 8;
|
||||
return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: deriveKey() Using ECDH
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=ecdh_keys.js
|
||||
|
||||
// Define subtests from a `promise_test` to ensure the harness does not
|
||||
|
||||
@@ -209,37 +209,4 @@ function define_tests() {
|
||||
.then(function(results) {return {privateKeys: privateKeys, publicKeys: publicKeys, ecdsaKeyPairs: ecdsaKeyPairs, noDeriveKeyKeys: noDeriveKeyKeys}});
|
||||
}
|
||||
|
||||
// Compares two ArrayBuffer or ArrayBufferView objects. If bitCount is
|
||||
// omitted, the two values must be the same length and have the same contents
|
||||
// in every byte. If bitCount is included, only that leading number of bits
|
||||
// have to match.
|
||||
function equalBuffers(a, b, bitCount) {
|
||||
var remainder;
|
||||
|
||||
if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
var length = a.byteLength;
|
||||
if (typeof bitCount !== "undefined") {
|
||||
length = Math.floor(bitCount / 8);
|
||||
}
|
||||
|
||||
for (var i=0; i<length; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof bitCount !== "undefined") {
|
||||
remainder = bitCount % 8;
|
||||
return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// META: variant=?1001-2000
|
||||
// META: variant=?2001-3000
|
||||
// META: variant=?3001-last
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=/common/subset-tests.js
|
||||
// META: script=hkdf_vectors.js
|
||||
// META: script=hkdf.js
|
||||
|
||||
@@ -275,21 +275,4 @@ function define_tests() {
|
||||
});
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,6 +9,7 @@
|
||||
// META: variant=?6001-7000
|
||||
// META: variant=?7001-8000
|
||||
// META: variant=?8001-last
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=/common/subset-tests.js
|
||||
// META: script=pbkdf2_vectors.js
|
||||
// META: script=pbkdf2.js
|
||||
|
||||
@@ -271,21 +271,4 @@ function define_tests() {
|
||||
});
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: digest() cSHAKE algorithms
|
||||
// META: script=../util/helpers.js
|
||||
// META: timeout=long
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
@@ -245,17 +246,3 @@ Object.keys(digestedData).forEach(function (alg) {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
+1
-30
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: digest()
|
||||
// META: script=../util/helpers.js
|
||||
// META: timeout=long
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
@@ -176,33 +177,3 @@
|
||||
|
||||
|
||||
done();
|
||||
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
// META: title=WebCryptoAPI: digest() KangarooTwelve algorithms
|
||||
// META: script=../util/helpers.js
|
||||
// META: timeout=long
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
|
||||
// Generates a Uint8Array of length n by repeating the pattern 00 01 02 .. F9 FA.
|
||||
function ptn(n) {
|
||||
var buf = new Uint8Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
buf[i] = i % 251;
|
||||
return buf;
|
||||
}
|
||||
|
||||
function hexToBytes(hex) {
|
||||
var bytes = new Uint8Array(hex.length / 2);
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// RFC 9861 Section 5 test vectors
|
||||
// [input, outputLengthBits, expected hex(, customization)]
|
||||
var kt128Vectors = [
|
||||
[new Uint8Array(0), 256,
|
||||
'1ac2d450fc3b4205d19da7bfca1b3751' +
|
||||
'3c0803577ac7167f06fe2ce1f0ef39e5'],
|
||||
[new Uint8Array(0), 512,
|
||||
'1ac2d450fc3b4205d19da7bfca1b3751' +
|
||||
'3c0803577ac7167f06fe2ce1f0ef39e5' +
|
||||
'4269c056b8c82e48276038b6d292966c' +
|
||||
'c07a3d4645272e31ff38508139eb0a71'],
|
||||
[ptn(1), 256,
|
||||
'2bda92450e8b147f8a7cb629e784a058' +
|
||||
'efca7cf7d8218e02d345dfaa65244a1f'],
|
||||
[ptn(17), 256,
|
||||
'6bf75fa2239198db4772e36478f8e19b' +
|
||||
'0f371205f6a9a93a273f51df37122888'],
|
||||
[ptn(Math.pow(17, 2)), 256,
|
||||
'0c315ebcdedbf61426de7dcf8fb725d1' +
|
||||
'e74675d7f5327a5067f367b108ecb67c'],
|
||||
[ptn(Math.pow(17, 3)), 256,
|
||||
'cb552e2ec77d9910701d578b457ddf77' +
|
||||
'2c12e322e4ee7fe417f92c758f0d59d0'],
|
||||
[ptn(Math.pow(17, 4)), 256,
|
||||
'8701045e22205345ff4dda05555cbb5c' +
|
||||
'3af1a771c2b89baef37db43d9998b9fe'],
|
||||
[ptn(Math.pow(17, 5)), 256,
|
||||
'844d610933b1b9963cbdeb5ae3b6b05c' +
|
||||
'c7cbd67ceedf883eb678a0a8e0371682'],
|
||||
[ptn(Math.pow(17, 6)), 256,
|
||||
'3c390782a8a4e89fa6367f72feaaf132' +
|
||||
'55c8d95878481d3cd8ce85f58e880af8'],
|
||||
[new Uint8Array(0), 256,
|
||||
'fab658db63e94a246188bf7af69a1330' +
|
||||
'45f46ee984c56e3c3328caaf1aa1a583', ptn(1)],
|
||||
[new Uint8Array([0xff]), 256,
|
||||
'd848c5068ced736f4462159b9867fd4c' +
|
||||
'20b808acc3d5bc48e0b06ba0a3762ec4', ptn(41)],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 256,
|
||||
'c389e5009ae57120854c2e8c64670ac0' +
|
||||
'1358cf4c1baf89447a724234dc7ced74', ptn(Math.pow(41, 2))],
|
||||
[new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), 256,
|
||||
'75d2f86a2e644566726b4fbcfc5657b9' +
|
||||
'dbcf070c7b0dca06450ab291d7443bcf', ptn(Math.pow(41, 3))],
|
||||
[ptn(8191), 256,
|
||||
'1b577636f723643e990cc7d6a6598374' +
|
||||
'36fd6a103626600eb8301cd1dbe553d6'],
|
||||
[ptn(8192), 256,
|
||||
'48f256f6772f9edfb6a8b661ec92dc93' +
|
||||
'b95ebd05a08a17b39ae3490870c926c3'],
|
||||
[ptn(8192), 256,
|
||||
'3ed12f70fb05ddb58689510ab3e4d23c' +
|
||||
'6c6033849aa01e1d8c220a297fedcd0b', ptn(8189)],
|
||||
[ptn(8192), 256,
|
||||
'6a7c1b6a5cd0d8c9ca943a4a216cc646' +
|
||||
'04559a2ea45f78570a15253d67ba00ae', ptn(8190)],
|
||||
];
|
||||
|
||||
var kt256Vectors = [
|
||||
[new Uint8Array(0), 512,
|
||||
'b23d2e9cea9f4904e02bec06817fc10c' +
|
||||
'e38ce8e93ef4c89e6537076af8646404' +
|
||||
'e3e8b68107b8833a5d30490aa3348235' +
|
||||
'3fd4adc7148ecb782855003aaebde4a9'],
|
||||
[new Uint8Array(0), 1024,
|
||||
'b23d2e9cea9f4904e02bec06817fc10c' +
|
||||
'e38ce8e93ef4c89e6537076af8646404' +
|
||||
'e3e8b68107b8833a5d30490aa3348235' +
|
||||
'3fd4adc7148ecb782855003aaebde4a9' +
|
||||
'b0925319d8ea1e121a609821ec19efea' +
|
||||
'89e6d08daee1662b69c840289f188ba8' +
|
||||
'60f55760b61f82114c030c97e5178449' +
|
||||
'608ccd2cd2d919fc7829ff69931ac4d0'],
|
||||
[ptn(1), 512,
|
||||
'0d005a194085360217128cf17f91e1f7' +
|
||||
'1314efa5564539d444912e3437efa17f' +
|
||||
'82db6f6ffe76e781eaa068bce01f2bbf' +
|
||||
'81eacb983d7230f2fb02834a21b1ddd0'],
|
||||
[ptn(17), 512,
|
||||
'1ba3c02b1fc514474f06c8979978a905' +
|
||||
'6c8483f4a1b63d0dccefe3a28a2f323e' +
|
||||
'1cdcca40ebf006ac76ef039715234683' +
|
||||
'7b1277d3e7faa9c9653b19075098527b'],
|
||||
[ptn(Math.pow(17, 2)), 512,
|
||||
'de8ccbc63e0f133ebb4416814d4c66f6' +
|
||||
'91bbf8b6a61ec0a7700f836b086cb029' +
|
||||
'd54f12ac7159472c72db118c35b4e6aa' +
|
||||
'213c6562caaa9dcc518959e69b10f3ba'],
|
||||
[ptn(Math.pow(17, 3)), 512,
|
||||
'647efb49fe9d717500171b41e7f11bd4' +
|
||||
'91544443209997ce1c2530d15eb1ffbb' +
|
||||
'598935ef954528ffc152b1e4d731ee26' +
|
||||
'83680674365cd191d562bae753b84aa5'],
|
||||
[ptn(Math.pow(17, 4)), 512,
|
||||
'b06275d284cd1cf205bcbe57dccd3ec1' +
|
||||
'ff6686e3ed15776383e1f2fa3c6ac8f0' +
|
||||
'8bf8a162829db1a44b2a43ff83dd89c3' +
|
||||
'cf1ceb61ede659766d5ccf817a62ba8d'],
|
||||
[ptn(Math.pow(17, 5)), 512,
|
||||
'9473831d76a4c7bf77ace45b59f1458b' +
|
||||
'1673d64bcd877a7c66b2664aa6dd149e' +
|
||||
'60eab71b5c2bab858c074ded81ddce2b' +
|
||||
'4022b5215935c0d4d19bf511aeeb0772'],
|
||||
[ptn(Math.pow(17, 6)), 512,
|
||||
'0652b740d78c5e1f7c8dcc1777097382' +
|
||||
'768b7ff38f9a7a20f29f413bb1b3045b' +
|
||||
'31a5578f568f911e09cf44746da84224' +
|
||||
'a5266e96a4a535e871324e4f9c7004da'],
|
||||
[new Uint8Array(0), 512,
|
||||
'9280f5cc39b54a5a594ec63de0bb9937' +
|
||||
'1e4609d44bf845c2f5b8c316d72b1598' +
|
||||
'11f748f23e3fabbe5c3226ec96c62186' +
|
||||
'df2d33e9df74c5069ceecbb4dd10eff6', ptn(1)],
|
||||
[new Uint8Array([0xff]), 512,
|
||||
'47ef96dd616f200937aa7847e34ec2fe' +
|
||||
'ae8087e3761dc0f8c1a154f51dc9ccf8' +
|
||||
'45d7adbce57ff64b639722c6a1672e3b' +
|
||||
'f5372d87e00aff89be97240756998853', ptn(41)],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 512,
|
||||
'3b48667a5051c5966c53c5d42b95de45' +
|
||||
'1e05584e7806e2fb765eda959074172c' +
|
||||
'b438a9e91dde337c98e9c41bed94c4e0' +
|
||||
'aef431d0b64ef2324f7932caa6f54969', ptn(Math.pow(41, 2))],
|
||||
[new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), 512,
|
||||
'e0911cc00025e1540831e266d94add9b' +
|
||||
'98712142b80d2629e643aac4efaf5a3a' +
|
||||
'30a88cbf4ac2a91a2432743054fbcc98' +
|
||||
'97670e86ba8cec2fc2ace9c966369724', ptn(Math.pow(41, 3))],
|
||||
[ptn(8191), 512,
|
||||
'3081434d93a4108d8d8a3305b89682ce' +
|
||||
'bedc7ca4ea8a3ce869fbb73cbe4a58ee' +
|
||||
'f6f24de38ffc170514c70e7ab2d01f03' +
|
||||
'812616e863d769afb3753193ba045b20'],
|
||||
[ptn(8192), 512,
|
||||
'c6ee8e2ad3200c018ac87aaa031cdac2' +
|
||||
'2121b412d07dc6e0dccbb53423747e9a' +
|
||||
'1c18834d99df596cf0cf4b8dfafb7bf0' +
|
||||
'2d139d0c9035725adc1a01b7230a41fa'],
|
||||
[ptn(8192), 512,
|
||||
'74e47879f10a9c5d11bd2da7e194fe57' +
|
||||
'e86378bf3c3f7448eff3c576a0f18c5c' +
|
||||
'aae0999979512090a7f348af4260d4de' +
|
||||
'3c37f1ecaf8d2c2c96c1d16c64b12496', ptn(8189)],
|
||||
[ptn(8192), 512,
|
||||
'f4b5908b929ffe01e0f79ec2f21243d4' +
|
||||
'1a396b2e7303a6af1d6399cd6c7a0a2d' +
|
||||
'd7c4f607e8277f9c9b1cb4ab9ddc59d4' +
|
||||
'b92d1fc7558441f1832c3279a4241b8b', ptn(8190)],
|
||||
];
|
||||
|
||||
// Large output tests: verify last N bytes of extended output
|
||||
var largeOutputTests = [
|
||||
// [algorithm, outputLengthBits, lastNBytes, expectedLastBytes]
|
||||
['KT128', 10032 * 8, 32,
|
||||
'e8dc563642f7228c84684c898405d3a8' +
|
||||
'34799158c079b12880277a1d28e2ff6d'],
|
||||
['KT256', 10064 * 8, 64,
|
||||
'ad4a1d718cf950506709a4c33396139b' +
|
||||
'4449041fc79a05d68da35f1e453522e0' +
|
||||
'56c64fe94958e7085f2964888259b993' +
|
||||
'2752f3ccd855288efee5fcbb8b563069'],
|
||||
];
|
||||
|
||||
largeOutputTests.forEach(function (entry) {
|
||||
var alg = entry[0];
|
||||
var outputLength = entry[1];
|
||||
var lastN = entry[2];
|
||||
var expected = entry[3];
|
||||
|
||||
promise_test(function (test) {
|
||||
return subtle
|
||||
.digest({ name: alg, outputLength: outputLength }, new Uint8Array(0))
|
||||
.then(function (result) {
|
||||
var full = new Uint8Array(result);
|
||||
var last = full.slice(full.length - lastN);
|
||||
assert_true(
|
||||
equalBuffers(last.buffer, hexToBytes(expected)),
|
||||
'last ' + lastN + ' bytes of digest match expected'
|
||||
);
|
||||
});
|
||||
}, alg + ' with ' + outputLength + ' bit output, verify last ' + lastN + ' bytes');
|
||||
});
|
||||
|
||||
function customizationEqual(emptyDataVector, customization) {
|
||||
return equalBuffers(customization ?? new Uint8Array(0), emptyDataVector[3] ?? new Uint8Array(0));
|
||||
}
|
||||
|
||||
function outputLengthLessOrEqual(emptyDataVector, outputLength) {
|
||||
return outputLength <= emptyDataVector[1];
|
||||
}
|
||||
|
||||
var allVectors = {
|
||||
KT128: kt128Vectors,
|
||||
KT256: kt256Vectors,
|
||||
};
|
||||
|
||||
Object.keys(allVectors).forEach(function (alg) {
|
||||
var emptyDataVector = allVectors[alg][0];
|
||||
allVectors[alg].forEach(function (vector, i) {
|
||||
var input = vector[0];
|
||||
var outputLength = vector[1];
|
||||
var expected = vector[2];
|
||||
var customization = vector[3];
|
||||
|
||||
var algorithmParams = { name: alg, outputLength: outputLength };
|
||||
if (customization !== undefined)
|
||||
algorithmParams.customization = customization;
|
||||
|
||||
var label = alg + ' vector #' + (i + 1) +
|
||||
' (' + outputLength + ' bit output, ' + input.length + ' byte input' +
|
||||
(customization !== undefined ? ', C=' + customization.length + ' bytes' : '') + ')';
|
||||
|
||||
promise_test(function (test) {
|
||||
return subtle
|
||||
.digest(algorithmParams, input)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
}, label);
|
||||
|
||||
if (input.length > 0) {
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
// Alter the buffer before calling digest
|
||||
buffer[0] = ~buffer[0];
|
||||
return subtle
|
||||
.digest({
|
||||
get name() {
|
||||
// Alter the buffer back while calling digest
|
||||
buffer[0] = input[0];
|
||||
return alg;
|
||||
},
|
||||
outputLength: outputLength,
|
||||
customization: customization,
|
||||
}, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
}, label + ' and altered buffer during call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
var promise = subtle
|
||||
.digest(algorithmParams, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
// Alter the buffer after calling digest
|
||||
buffer[0] = ~buffer[0];
|
||||
return promise;
|
||||
}, label + ' and altered buffer after call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
return subtle
|
||||
.digest({
|
||||
get name() {
|
||||
// Transfer the buffer while calling digest
|
||||
buffer.buffer.transfer();
|
||||
return alg;
|
||||
},
|
||||
outputLength: outputLength,
|
||||
customization: customization,
|
||||
}, buffer)
|
||||
.then(function (result) {
|
||||
if (customizationEqual(emptyDataVector, customization) && outputLengthLessOrEqual(emptyDataVector, outputLength)) {
|
||||
assert_true(
|
||||
equalBuffers(result, Uint8Array.fromHex(emptyDataVector[2]).subarray(0, outputLength / 8)),
|
||||
'digest on transferred buffer should match result for empty buffer'
|
||||
);
|
||||
} else {
|
||||
assert_equals(result.byteLength, outputLength / 8,
|
||||
'digest on transferred buffer should have correct output length');
|
||||
}
|
||||
});
|
||||
}, label + ' and transferred buffer during call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
var promise = subtle
|
||||
.digest(algorithmParams, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
// Transfer the buffer after calling digest
|
||||
buffer.buffer.transfer();
|
||||
return promise;
|
||||
}, label + ' and transferred buffer after call');
|
||||
}
|
||||
});
|
||||
});
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: digest() SHA-3 algorithms
|
||||
// META: script=../util/helpers.js
|
||||
// META: timeout=long
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
@@ -176,17 +177,3 @@ Object.keys(sourceData).forEach(function (size) {
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
// META: title=WebCryptoAPI: digest() TurboSHAKE algorithms
|
||||
// META: script=../util/helpers.js
|
||||
// META: timeout=long
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
|
||||
// Generates a Uint8Array of length n by repeating the pattern 00 01 02 .. F9 FA.
|
||||
function ptn(n) {
|
||||
var buf = new Uint8Array(n);
|
||||
for (var i = 0; i < n; i++)
|
||||
buf[i] = i % 251;
|
||||
return buf;
|
||||
}
|
||||
|
||||
function hexToBytes(hex) {
|
||||
var bytes = new Uint8Array(hex.length / 2);
|
||||
for (var i = 0; i < hex.length; i += 2)
|
||||
bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
// RFC 9861 Section 5 test vectors
|
||||
// [input, outputLengthBits, expected hex(, domainSeparation)]
|
||||
var turboSHAKE128Vectors = [
|
||||
[new Uint8Array(0), 256,
|
||||
'1e415f1c5983aff2169217277d17bb53' +
|
||||
'8cd945a397ddec541f1ce41af2c1b74c'],
|
||||
[new Uint8Array(0), 512,
|
||||
'1e415f1c5983aff2169217277d17bb53' +
|
||||
'8cd945a397ddec541f1ce41af2c1b74c' +
|
||||
'3e8ccae2a4dae56c84a04c2385c03c15' +
|
||||
'e8193bdf58737363321691c05462c8df'],
|
||||
[ptn(1), 256,
|
||||
'55cedd6f60af7bb29a4042ae832ef3f5' +
|
||||
'8db7299f893ebb9247247d856958daa9'],
|
||||
[ptn(17), 256,
|
||||
'9c97d036a3bac819db70ede0ca554ec6' +
|
||||
'e4c2a1a4ffbfd9ec269ca6a111161233'],
|
||||
[ptn(Math.pow(17, 2)), 256,
|
||||
'96c77c279e0126f7fc07c9b07f5cdae1' +
|
||||
'e0be60bdbe10620040e75d7223a624d2'],
|
||||
[ptn(Math.pow(17, 3)), 256,
|
||||
'd4976eb56bcf118520582b709f73e1d6' +
|
||||
'853e001fdaf80e1b13e0d0599d5fb372'],
|
||||
[ptn(Math.pow(17, 4)), 256,
|
||||
'da67c7039e98bf530cf7a37830c6664e' +
|
||||
'14cbab7f540f58403b1b82951318ee5c'],
|
||||
[ptn(Math.pow(17, 5)), 256,
|
||||
'b97a906fbf83ef7c812517abf3b2d0ae' +
|
||||
'a0c4f60318ce11cf103925127f59eecd'],
|
||||
[ptn(Math.pow(17, 6)), 256,
|
||||
'35cd494adeded2f25239af09a7b8ef0c' +
|
||||
'4d1ca4fe2d1ac370fa63216fe7b4c2b1'],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 256,
|
||||
'bf323f940494e88ee1c540fe660be8a0' +
|
||||
'c93f43d15ec006998462fa994eed5dab', 0x01],
|
||||
[new Uint8Array([0xff]), 256,
|
||||
'8ec9c66465ed0d4a6c35d13506718d68' +
|
||||
'7a25cb05c74cca1e42501abd83874a67', 0x06],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 256,
|
||||
'b658576001cad9b1e5f399a9f77723bb' +
|
||||
'a05458042d68206f7252682dba3663ed', 0x07],
|
||||
[new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), 256,
|
||||
'8deeaa1aec47ccee569f659c21dfa8e1' +
|
||||
'12db3cee37b18178b2acd805b799cc37', 0x0b],
|
||||
[new Uint8Array([0xff]), 256,
|
||||
'553122e2135e363c3292bed2c6421fa2' +
|
||||
'32bab03daa07c7d6636603286506325b', 0x30],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 256,
|
||||
'16274cc656d44cefd422395d0f9053bd' +
|
||||
'a6d28e122aba15c765e5ad0e6eaf26f9', 0x7f],
|
||||
];
|
||||
|
||||
var turboSHAKE256Vectors = [
|
||||
[new Uint8Array(0), 512,
|
||||
'367a329dafea871c7802ec67f905ae13' +
|
||||
'c57695dc2c6663c61035f59a18f8e7db' +
|
||||
'11edc0e12e91ea60eb6b32df06dd7f00' +
|
||||
'2fbafabb6e13ec1cc20d995547600db0'],
|
||||
[ptn(1), 512,
|
||||
'3e1712f928f8eaf1054632b2aa0a246e' +
|
||||
'd8b0c378728f60bc970410155c28820e' +
|
||||
'90cc90d8a3006aa2372c5c5ea176b068' +
|
||||
'2bf22bae7467ac94f74d43d39b0482e2'],
|
||||
[ptn(17), 512,
|
||||
'b3bab0300e6a191fbe61379398359235' +
|
||||
'78794ea54843f5011090fa2f3780a9e5' +
|
||||
'cb22c59d78b40a0fbff9e672c0fbe097' +
|
||||
'0bd2c845091c6044d687054da5d8e9c7'],
|
||||
[ptn(Math.pow(17, 2)), 512,
|
||||
'66b810db8e90780424c0847372fdc957' +
|
||||
'10882fde31c6df75beb9d4cd9305cfca' +
|
||||
'e35e7b83e8b7e6eb4b78605880116316' +
|
||||
'fe2c078a09b94ad7b8213c0a738b65c0'],
|
||||
[ptn(Math.pow(17, 3)), 512,
|
||||
'c74ebc919a5b3b0dd1228185ba02d29e' +
|
||||
'f442d69d3d4276a93efe0bf9a16a7dc0' +
|
||||
'cd4eabadab8cd7a5edd96695f5d360ab' +
|
||||
'e09e2c6511a3ec397da3b76b9e1674fb'],
|
||||
[ptn(Math.pow(17, 4)), 512,
|
||||
'02cc3a8897e6f4f6ccb6fd46631b1f52' +
|
||||
'07b66c6de9c7b55b2d1a23134a170afd' +
|
||||
'ac234eaba9a77cff88c1f020b7372461' +
|
||||
'8c5687b362c430b248cd38647f848a1d'],
|
||||
[ptn(Math.pow(17, 5)), 512,
|
||||
'add53b06543e584b5823f626996aee50' +
|
||||
'fe45ed15f20243a7165485acb4aa76b4' +
|
||||
'ffda75cedf6d8cdc95c332bd56f4b986' +
|
||||
'b58bb17d1778bfc1b1a97545cdf4ec9f'],
|
||||
[ptn(Math.pow(17, 6)), 512,
|
||||
'9e11bc59c24e73993c1484ec66358ef7' +
|
||||
'1db74aefd84e123f7800ba9c4853e02c' +
|
||||
'fe701d9e6bb765a304f0dc34a4ee3ba8' +
|
||||
'2c410f0da70e86bfbd90ea877c2d6104'],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 512,
|
||||
'd21c6fbbf587fa2282f29aea620175fb' +
|
||||
'0257413af78a0b1b2a87419ce031d933' +
|
||||
'ae7a4d383327a8a17641a34f8a1d1003' +
|
||||
'ad7da6b72dba84bb62fef28f62f12424', 0x01],
|
||||
[new Uint8Array([0xff]), 512,
|
||||
'738d7b4e37d18b7f22ad1b5313e357e3' +
|
||||
'dd7d07056a26a303c433fa3533455280' +
|
||||
'f4f5a7d4f700efb437fe6d281405e07b' +
|
||||
'e32a0a972e22e63adc1b090daefe004b', 0x06],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 512,
|
||||
'18b3b5b7061c2e67c1753a00e6ad7ed7' +
|
||||
'ba1c906cf93efb7092eaf27fbeebb755' +
|
||||
'ae6e292493c110e48d260028492b8e09' +
|
||||
'b5500612b8f2578985ded5357d00ec67', 0x07],
|
||||
[new Uint8Array([0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff]), 512,
|
||||
'bb36764951ec97e9d85f7ee9a67a7718' +
|
||||
'fc005cf42556be79ce12c0bde50e5736' +
|
||||
'd6632b0d0dfb202d1bbb8ffe3dd74cb0' +
|
||||
'0834fa756cb03471bab13a1e2c16b3c0', 0x0b],
|
||||
[new Uint8Array([0xff]), 512,
|
||||
'f3fe12873d34bcbb2e608779d6b70e7f' +
|
||||
'86bec7e90bf113cbd4fdd0c4e2f4625e' +
|
||||
'148dd7ee1a52776cf77f240514d9ccfc' +
|
||||
'3b5ddab8ee255e39ee389072962c111a', 0x30],
|
||||
[new Uint8Array([0xff, 0xff, 0xff]), 512,
|
||||
'abe569c1f77ec340f02705e7d37c9ab7' +
|
||||
'e155516e4a6a150021d70b6fac0bb40c' +
|
||||
'069f9a9828a0d575cd99f9bae435ab1a' +
|
||||
'cf7ed9110ba97ce0388d074bac768776', 0x7f],
|
||||
];
|
||||
|
||||
// Large output tests: verify last 32 bytes of extended output
|
||||
var largeOutputTests = [
|
||||
// [algorithm, outputLengthBits, lastNBytes, expectedLastBytes]
|
||||
['TurboSHAKE128', 10032 * 8, 32,
|
||||
'a3b9b0385900ce761f22aed548e754da' +
|
||||
'10a5242d62e8c658e3f3a923a7555607'],
|
||||
['TurboSHAKE256', 10032 * 8, 32,
|
||||
'abefa11630c661269249742685ec082f' +
|
||||
'207265dccf2f43534e9c61ba0c9d1d75'],
|
||||
];
|
||||
|
||||
largeOutputTests.forEach(function (entry) {
|
||||
var alg = entry[0];
|
||||
var outputLength = entry[1];
|
||||
var lastN = entry[2];
|
||||
var expected = entry[3];
|
||||
|
||||
promise_test(function (test) {
|
||||
return subtle
|
||||
.digest({ name: alg, outputLength: outputLength }, new Uint8Array(0))
|
||||
.then(function (result) {
|
||||
var full = new Uint8Array(result);
|
||||
var last = full.slice(full.length - lastN);
|
||||
assert_true(
|
||||
equalBuffers(last.buffer, hexToBytes(expected)),
|
||||
'last ' + lastN + ' bytes of digest match expected'
|
||||
);
|
||||
});
|
||||
}, alg + ' with ' + outputLength + ' bit output, verify last ' + lastN + ' bytes');
|
||||
});
|
||||
|
||||
function domainSeparationEqual(emptyDataVector, domainSeparation) {
|
||||
return (domainSeparation ?? 0x1f) === (emptyDataVector[3] ?? 0x1f);
|
||||
}
|
||||
|
||||
function outputLengthLessOrEqual(emptyDataVector, outputLength) {
|
||||
return outputLength <= emptyDataVector[1];
|
||||
}
|
||||
|
||||
var allVectors = {
|
||||
TurboSHAKE128: turboSHAKE128Vectors,
|
||||
TurboSHAKE256: turboSHAKE256Vectors,
|
||||
};
|
||||
|
||||
Object.keys(allVectors).forEach(function (alg) {
|
||||
var emptyDataVector = allVectors[alg][0];
|
||||
allVectors[alg].forEach(function (vector, i) {
|
||||
var input = vector[0];
|
||||
var outputLength = vector[1];
|
||||
var expected = vector[2];
|
||||
var domainSeparation = vector[3];
|
||||
|
||||
var algorithmParams = { name: alg, outputLength: outputLength };
|
||||
if (domainSeparation !== undefined)
|
||||
algorithmParams.domainSeparation = domainSeparation;
|
||||
|
||||
var label = alg + ' vector #' + (i + 1) +
|
||||
' (' + outputLength + ' bit output, ' + input.length + ' byte input' +
|
||||
(domainSeparation !== undefined ? ', D=0x' + domainSeparation.toString(16) : '') + ')';
|
||||
|
||||
promise_test(function (test) {
|
||||
return subtle
|
||||
.digest(algorithmParams, input)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
}, label);
|
||||
|
||||
if (input.length > 0) {
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
// Alter the buffer before calling digest
|
||||
buffer[0] = ~buffer[0];
|
||||
return subtle
|
||||
.digest({
|
||||
get name() {
|
||||
// Alter the buffer back while calling digest
|
||||
buffer[0] = input[0];
|
||||
return alg;
|
||||
},
|
||||
outputLength: outputLength,
|
||||
domainSeparation: domainSeparation,
|
||||
}, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
}, label + ' and altered buffer during call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
var promise = subtle
|
||||
.digest(algorithmParams, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
// Alter the buffer after calling digest
|
||||
buffer[0] = ~buffer[0];
|
||||
return promise;
|
||||
}, label + ' and altered buffer after call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
return subtle
|
||||
.digest({
|
||||
get name() {
|
||||
// Transfer the buffer while calling digest
|
||||
buffer.buffer.transfer();
|
||||
return alg;
|
||||
},
|
||||
outputLength: outputLength,
|
||||
domainSeparation: domainSeparation,
|
||||
}, buffer)
|
||||
.then(function (result) {
|
||||
if (domainSeparationEqual(emptyDataVector, domainSeparation) && outputLengthLessOrEqual(emptyDataVector, outputLength)) {
|
||||
assert_true(
|
||||
equalBuffers(result, Uint8Array.fromHex(emptyDataVector[2]).subarray(0, outputLength / 8)),
|
||||
'digest on transferred buffer should match result for empty buffer'
|
||||
);
|
||||
} else {
|
||||
assert_equals(result.byteLength, outputLength / 8,
|
||||
'digest on transferred buffer should have correct output length');
|
||||
}
|
||||
});
|
||||
}, label + ' and transferred buffer during call');
|
||||
|
||||
promise_test(function (test) {
|
||||
var buffer = new Uint8Array(input);
|
||||
var promise = subtle
|
||||
.digest(algorithmParams, buffer)
|
||||
.then(function (result) {
|
||||
assert_true(
|
||||
equalBuffers(result, hexToBytes(expected)),
|
||||
'digest matches expected'
|
||||
);
|
||||
});
|
||||
// Transfer the buffer after calling digest
|
||||
buffer.buffer.transfer();
|
||||
return promise;
|
||||
}, label + ' and transferred buffer after call');
|
||||
}
|
||||
});
|
||||
});
|
||||
+1
-40
@@ -73,7 +73,7 @@ function define_bits_tests() {
|
||||
);
|
||||
}, algorithmName + ' encapsulateBits basic functionality');
|
||||
|
||||
// Test decapsulateBits operation
|
||||
// Test encapsulateBits/decapsulateBits round-trip compatibility
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
@@ -109,30 +109,6 @@ function define_bits_tests() {
|
||||
equalBuffers(decapsulatedBits, encapsulatedBits.sharedKey),
|
||||
'Decapsulated shared secret should match original'
|
||||
);
|
||||
}, algorithmName + ' decapsulateBits basic functionality');
|
||||
|
||||
// Test round-trip compatibility
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateBits',
|
||||
'decapsulateBits',
|
||||
]);
|
||||
|
||||
var encapsulatedBits = await subtle.encapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey
|
||||
);
|
||||
|
||||
var decapsulatedBits = await subtle.decapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedBits.ciphertext
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(encapsulatedBits.sharedKey, decapsulatedBits),
|
||||
'Encapsulated and decapsulated shared secrets should match'
|
||||
);
|
||||
}, algorithmName +
|
||||
' encapsulateBits/decapsulateBits round-trip compatibility');
|
||||
|
||||
@@ -175,19 +151,4 @@ function define_bits_tests() {
|
||||
});
|
||||
}
|
||||
|
||||
// Helper function to compare two ArrayBuffers
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
define_bits_tests();
|
||||
+301
-311
@@ -38,313 +38,318 @@ function define_key_tests() {
|
||||
|
||||
variants.forEach(function (algorithmName) {
|
||||
sharedKeyConfigs.forEach(function (config) {
|
||||
// Test encapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
[true, false].forEach(function (extractable) {
|
||||
// Test encapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// Test encapsulateKey
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
// Test encapsulateKey
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
assert_true(
|
||||
encapsulatedKey instanceof Object,
|
||||
'encapsulateKey should return an object'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('sharedKey'),
|
||||
'Result should have sharedKey property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('ciphertext'),
|
||||
'Result should have ciphertext property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.sharedKey instanceof CryptoKey,
|
||||
'sharedKey should be a CryptoKey'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.ciphertext instanceof ArrayBuffer,
|
||||
'ciphertext should be ArrayBuffer'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey instanceof Object,
|
||||
'encapsulateKey should return an object'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('sharedKey'),
|
||||
'Result should have sharedKey property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('ciphertext'),
|
||||
'Result should have ciphertext property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.sharedKey instanceof CryptoKey,
|
||||
'sharedKey should be a CryptoKey'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.ciphertext instanceof ArrayBuffer,
|
||||
'ciphertext should be ArrayBuffer'
|
||||
);
|
||||
|
||||
// Verify the shared key properties
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.type,
|
||||
'secret',
|
||||
'Shared key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Shared key algorithm should match'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.sharedKey.extractable,
|
||||
'Shared key should be extractable as specified'
|
||||
);
|
||||
assert_array_equals(
|
||||
encapsulatedKey.sharedKey.usages,
|
||||
config.usages,
|
||||
'Shared key should have correct usages'
|
||||
);
|
||||
|
||||
// Verify algorithm-specific properties
|
||||
if (config.algorithm.length) {
|
||||
// Verify the shared key properties
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.length,
|
||||
config.algorithm.length,
|
||||
'Key length should be 256'
|
||||
encapsulatedKey.sharedKey.type,
|
||||
'secret',
|
||||
'Shared key should be secret type'
|
||||
);
|
||||
}
|
||||
if (config.algorithm.hash) {
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.hash.name,
|
||||
config.algorithm.hash,
|
||||
'Hash algorithm should match'
|
||||
encapsulatedKey.sharedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Shared key algorithm should match'
|
||||
);
|
||||
}
|
||||
|
||||
// Verify ciphertext length based on algorithm variant
|
||||
var expectedCiphertextLength;
|
||||
switch (algorithmName) {
|
||||
case 'ML-KEM-512':
|
||||
expectedCiphertextLength = 768;
|
||||
break;
|
||||
case 'ML-KEM-768':
|
||||
expectedCiphertextLength = 1088;
|
||||
break;
|
||||
case 'ML-KEM-1024':
|
||||
expectedCiphertextLength = 1568;
|
||||
break;
|
||||
}
|
||||
assert_equals(
|
||||
encapsulatedKey.ciphertext.byteLength,
|
||||
expectedCiphertextLength,
|
||||
'Ciphertext should be ' +
|
||||
expectedCiphertextLength +
|
||||
' bytes for ' +
|
||||
algorithmName
|
||||
);
|
||||
}, algorithmName + ' encapsulateKey with ' + config.description);
|
||||
|
||||
// Test decapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// First encapsulate to get ciphertext
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
|
||||
// Then decapsulate using the private key
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedKey instanceof CryptoKey,
|
||||
'decapsulateKey should return a CryptoKey'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.type,
|
||||
'secret',
|
||||
'Decapsulated key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Decapsulated key algorithm should match'
|
||||
);
|
||||
assert_true(
|
||||
decapsulatedKey.extractable,
|
||||
'Decapsulated key should be extractable as specified'
|
||||
);
|
||||
assert_array_equals(
|
||||
decapsulatedKey.usages,
|
||||
config.usages,
|
||||
'Decapsulated key should have correct usages'
|
||||
);
|
||||
|
||||
// Extract both keys and verify they are identical
|
||||
var originalKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
encapsulatedKey.sharedKey
|
||||
);
|
||||
var decapsulatedKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
decapsulatedKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(originalKeyMaterial, decapsulatedKeyMaterial),
|
||||
'Decapsulated key material should match original'
|
||||
);
|
||||
|
||||
// Verify the key material is 32 bytes (256 bits)
|
||||
assert_equals(
|
||||
originalKeyMaterial.byteLength,
|
||||
32,
|
||||
'Shared key material should be 32 bytes'
|
||||
);
|
||||
}, algorithmName + ' decapsulateKey with ' + config.description);
|
||||
|
||||
// Test round-trip compatibility
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
|
||||
// Verify keys have the same material
|
||||
var originalKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
encapsulatedKey.sharedKey
|
||||
);
|
||||
var decapsulatedKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
decapsulatedKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(originalKeyMaterial, decapsulatedKeyMaterial),
|
||||
'Encapsulated and decapsulated keys should have the same material'
|
||||
);
|
||||
|
||||
// Test that the derived keys can actually be used for their intended purpose
|
||||
if (
|
||||
config.algorithm.name.startsWith('AES') &&
|
||||
config.usages.includes('encrypt')
|
||||
) {
|
||||
await testAESOperation(
|
||||
encapsulatedKey.sharedKey,
|
||||
decapsulatedKey,
|
||||
config.algorithm
|
||||
);
|
||||
} else if (config.algorithm.name === 'HMAC') {
|
||||
await testHMACOperation(encapsulatedKey.sharedKey, decapsulatedKey);
|
||||
}
|
||||
}, algorithmName +
|
||||
' encapsulateKey/decapsulateKey round-trip with ' +
|
||||
config.description);
|
||||
});
|
||||
|
||||
// Test vector-based decapsulation for each shared key config
|
||||
sharedKeyConfigs.forEach(function (config) {
|
||||
promise_test(async function (test) {
|
||||
var vectors = ml_kem_vectors[algorithmName];
|
||||
|
||||
// Import the private key from the vector's privateSeed
|
||||
var privateKey = await subtle.importKey(
|
||||
'raw-seed',
|
||||
vectors.privateSeed,
|
||||
{ name: algorithmName },
|
||||
false,
|
||||
['decapsulateKey']
|
||||
);
|
||||
|
||||
// Decapsulate the sample ciphertext from the vectors to get a shared key
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
privateKey,
|
||||
vectors.sampleCiphertext,
|
||||
config.algorithm,
|
||||
true,
|
||||
config.usages
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedKey instanceof CryptoKey,
|
||||
'decapsulateKey should return a CryptoKey'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.type,
|
||||
'secret',
|
||||
'Decapsulated key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Decapsulated key algorithm should match'
|
||||
);
|
||||
assert_true(
|
||||
decapsulatedKey.extractable,
|
||||
'Decapsulated key should be extractable as specified'
|
||||
);
|
||||
assert_array_equals(
|
||||
decapsulatedKey.usages,
|
||||
config.usages,
|
||||
'Decapsulated key should have correct usages'
|
||||
);
|
||||
|
||||
// Extract the key material and verify it matches the expected shared secret
|
||||
var keyMaterial = await subtle.exportKey('raw', decapsulatedKey);
|
||||
assert_equals(
|
||||
keyMaterial.byteLength,
|
||||
32,
|
||||
'Shared key material should be 32 bytes'
|
||||
);
|
||||
assert_true(
|
||||
equalBuffers(keyMaterial, vectors.expectedSharedSecret),
|
||||
"Decapsulated key material should match vector's expectedSharedSecret"
|
||||
);
|
||||
|
||||
// Verify algorithm-specific properties
|
||||
if (config.algorithm.length) {
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.length,
|
||||
config.algorithm.length,
|
||||
'Key length should be 256'
|
||||
encapsulatedKey.sharedKey.extractable,
|
||||
extractable,
|
||||
'Shared key should have correct extractable property'
|
||||
);
|
||||
}
|
||||
if (config.algorithm.hash) {
|
||||
assert_array_equals(
|
||||
encapsulatedKey.sharedKey.usages,
|
||||
config.usages,
|
||||
'Shared key should have correct usages'
|
||||
);
|
||||
|
||||
// Verify algorithm-specific properties
|
||||
if (config.algorithm.length) {
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.length,
|
||||
config.algorithm.length,
|
||||
'Key length should be 256'
|
||||
);
|
||||
}
|
||||
if (config.algorithm.hash) {
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.hash.name,
|
||||
config.algorithm.hash,
|
||||
'Hash algorithm should match'
|
||||
);
|
||||
}
|
||||
|
||||
// Verify ciphertext length based on algorithm variant
|
||||
var expectedCiphertextLength;
|
||||
switch (algorithmName) {
|
||||
case 'ML-KEM-512':
|
||||
expectedCiphertextLength = 768;
|
||||
break;
|
||||
case 'ML-KEM-768':
|
||||
expectedCiphertextLength = 1088;
|
||||
break;
|
||||
case 'ML-KEM-1024':
|
||||
expectedCiphertextLength = 1568;
|
||||
break;
|
||||
}
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.hash.name,
|
||||
config.algorithm.hash,
|
||||
'Hash algorithm should match'
|
||||
encapsulatedKey.ciphertext.byteLength,
|
||||
expectedCiphertextLength,
|
||||
'Ciphertext should be ' +
|
||||
expectedCiphertextLength +
|
||||
' bytes for ' +
|
||||
algorithmName
|
||||
);
|
||||
}
|
||||
}, algorithmName +
|
||||
' vector-based sampleCiphertext decapsulation with ' +
|
||||
config.description);
|
||||
}, `${algorithmName} encapsulateKey with ${config.description} (extractable=${extractable})`);
|
||||
|
||||
// Test decapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// First encapsulate to get ciphertext
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
// Then decapsulate using the private key
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedKey instanceof CryptoKey,
|
||||
'decapsulateKey should return a CryptoKey'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.type,
|
||||
'secret',
|
||||
'Decapsulated key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Decapsulated key algorithm should match'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.extractable,
|
||||
extractable,
|
||||
'Decapsulated key should have correct extractable property'
|
||||
);
|
||||
assert_array_equals(
|
||||
decapsulatedKey.usages,
|
||||
config.usages,
|
||||
'Decapsulated key should have correct usages'
|
||||
);
|
||||
|
||||
if (extractable) {
|
||||
// Extract both keys and verify they are identical
|
||||
var originalKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
encapsulatedKey.sharedKey
|
||||
);
|
||||
var decapsulatedKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
decapsulatedKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(originalKeyMaterial, decapsulatedKeyMaterial),
|
||||
'Decapsulated key material should match original'
|
||||
);
|
||||
|
||||
// Verify the key material is 32 bytes (256 bits)
|
||||
assert_equals(
|
||||
originalKeyMaterial.byteLength,
|
||||
32,
|
||||
'Shared key material should be 32 bytes'
|
||||
);
|
||||
}
|
||||
}, `${algorithmName} decapsulateKey with ${config.description} (extractable=${extractable})`);
|
||||
|
||||
// Test round-trip compatibility
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
if (extractable) {
|
||||
// Verify keys have the same material
|
||||
var originalKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
encapsulatedKey.sharedKey
|
||||
);
|
||||
var decapsulatedKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
decapsulatedKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(originalKeyMaterial, decapsulatedKeyMaterial),
|
||||
'Encapsulated and decapsulated keys should have the same material'
|
||||
);
|
||||
}
|
||||
|
||||
// Test that the derived keys can actually be used for their intended purpose
|
||||
if (
|
||||
config.algorithm.name.startsWith('AES') &&
|
||||
config.usages.includes('encrypt')
|
||||
) {
|
||||
await testAESOperation(
|
||||
encapsulatedKey.sharedKey,
|
||||
decapsulatedKey,
|
||||
config.algorithm
|
||||
);
|
||||
} else if (config.algorithm.name === 'HMAC') {
|
||||
await testHMACOperation(encapsulatedKey.sharedKey, decapsulatedKey);
|
||||
}
|
||||
}, `${algorithmName} encapsulateKey/decapsulateKey round-trip with ${config.description} (extractable=${extractable})`);
|
||||
|
||||
// Test vector-based decapsulation
|
||||
promise_test(async function (test) {
|
||||
var vectors = ml_kem_vectors[algorithmName];
|
||||
|
||||
// Import the private key from the vector's privateSeed
|
||||
var privateKey = await subtle.importKey(
|
||||
'raw-seed',
|
||||
vectors.privateSeed,
|
||||
{ name: algorithmName },
|
||||
false,
|
||||
['decapsulateKey']
|
||||
);
|
||||
|
||||
// Decapsulate the sample ciphertext from the vectors to get a shared key
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
privateKey,
|
||||
vectors.sampleCiphertext,
|
||||
config.algorithm,
|
||||
extractable,
|
||||
config.usages
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedKey instanceof CryptoKey,
|
||||
'decapsulateKey should return a CryptoKey'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.type,
|
||||
'secret',
|
||||
'Decapsulated key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.name,
|
||||
config.algorithm.name,
|
||||
'Decapsulated key algorithm should match'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.extractable,
|
||||
extractable,
|
||||
'Decapsulated key should have correct extractable property'
|
||||
);
|
||||
assert_array_equals(
|
||||
decapsulatedKey.usages,
|
||||
config.usages,
|
||||
'Decapsulated key should have correct usages'
|
||||
);
|
||||
|
||||
if (extractable) {
|
||||
// Extract the key material and verify it matches the expected shared secret
|
||||
var keyMaterial = await subtle.exportKey('raw', decapsulatedKey);
|
||||
assert_equals(
|
||||
keyMaterial.byteLength,
|
||||
32,
|
||||
'Shared key material should be 32 bytes'
|
||||
);
|
||||
assert_true(
|
||||
equalBuffers(keyMaterial, vectors.expectedSharedSecret),
|
||||
"Decapsulated key material should match vector's expectedSharedSecret"
|
||||
);
|
||||
}
|
||||
|
||||
// Verify algorithm-specific properties
|
||||
if (config.algorithm.length) {
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.length,
|
||||
config.algorithm.length,
|
||||
'Key length should be 256'
|
||||
);
|
||||
}
|
||||
if (config.algorithm.hash) {
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.hash.name,
|
||||
config.algorithm.hash,
|
||||
'Hash algorithm should match'
|
||||
);
|
||||
}
|
||||
}, `${algorithmName} vector-based sampleCiphertext decapsulation with ${config.description} (extractable=${extractable})`);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -430,19 +435,4 @@ async function testHMACOperation(key1, key2) {
|
||||
assert_true(verified2, 'HMAC verification should succeed with key2');
|
||||
}
|
||||
|
||||
// Helper function to compare two ArrayBuffers
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
define_key_tests();
|
||||
@@ -1,410 +0,0 @@
|
||||
// Test implementation for ML-KEM encapsulate and decapsulate operations
|
||||
|
||||
function define_tests() {
|
||||
var subtle = self.crypto.subtle;
|
||||
|
||||
// Test data for all ML-KEM variants
|
||||
var variants = ['ML-KEM-512', 'ML-KEM-768', 'ML-KEM-1024'];
|
||||
|
||||
variants.forEach(function (algorithmName) {
|
||||
var testVector = ml_kem_vectors[algorithmName];
|
||||
|
||||
// Test encapsulateBits operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateBits',
|
||||
'decapsulateBits',
|
||||
]);
|
||||
|
||||
// Test encapsulateBits
|
||||
var encapsulatedBits = await subtle.encapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
encapsulatedBits instanceof Object,
|
||||
'encapsulateBits should return an object'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedBits.hasOwnProperty('sharedKey'),
|
||||
'Result should have sharedKey property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedBits.hasOwnProperty('ciphertext'),
|
||||
'Result should have ciphertext property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedBits.sharedKey instanceof ArrayBuffer,
|
||||
'sharedKey should be ArrayBuffer'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedBits.ciphertext instanceof ArrayBuffer,
|
||||
'ciphertext should be ArrayBuffer'
|
||||
);
|
||||
|
||||
// Verify sharedKey length (should be 32 bytes for all ML-KEM variants)
|
||||
assert_equals(
|
||||
encapsulatedBits.sharedKey.byteLength,
|
||||
32,
|
||||
'Shared key should be 32 bytes'
|
||||
);
|
||||
|
||||
// Verify ciphertext length based on algorithm variant
|
||||
var expectedCiphertextLength;
|
||||
switch (algorithmName) {
|
||||
case 'ML-KEM-512':
|
||||
expectedCiphertextLength = 768;
|
||||
break;
|
||||
case 'ML-KEM-768':
|
||||
expectedCiphertextLength = 1088;
|
||||
break;
|
||||
case 'ML-KEM-1024':
|
||||
expectedCiphertextLength = 1568;
|
||||
break;
|
||||
}
|
||||
assert_equals(
|
||||
encapsulatedBits.ciphertext.byteLength,
|
||||
expectedCiphertextLength,
|
||||
'Ciphertext should be ' +
|
||||
expectedCiphertextLength +
|
||||
' bytes for ' +
|
||||
algorithmName
|
||||
);
|
||||
}, algorithmName + ' encapsulateBits basic functionality');
|
||||
|
||||
// Test decapsulateBits operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateBits',
|
||||
'decapsulateBits',
|
||||
]);
|
||||
|
||||
// First encapsulate to get ciphertext
|
||||
var encapsulatedBits = await subtle.encapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey
|
||||
);
|
||||
|
||||
// Then decapsulate using the private key
|
||||
var decapsulatedBits = await subtle.decapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedBits.ciphertext
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedBits instanceof ArrayBuffer,
|
||||
'decapsulateBits should return ArrayBuffer'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedBits.byteLength,
|
||||
32,
|
||||
'Decapsulated bits should be 32 bytes'
|
||||
);
|
||||
|
||||
// The decapsulated shared secret should match the original
|
||||
assert_true(
|
||||
equalBuffers(decapsulatedBits, encapsulatedBits.sharedKey),
|
||||
'Decapsulated shared secret should match original'
|
||||
);
|
||||
}, algorithmName + ' decapsulateBits basic functionality');
|
||||
|
||||
// Test encapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// Test encapsulateKey with AES-GCM as the shared key algorithm
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
|
||||
assert_true(
|
||||
encapsulatedKey instanceof Object,
|
||||
'encapsulateKey should return an object'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('sharedKey'),
|
||||
'Result should have sharedKey property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.hasOwnProperty('ciphertext'),
|
||||
'Result should have ciphertext property'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.sharedKey instanceof CryptoKey,
|
||||
'sharedKey should be a CryptoKey'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.ciphertext instanceof ArrayBuffer,
|
||||
'ciphertext should be ArrayBuffer'
|
||||
);
|
||||
|
||||
// Verify the shared key properties
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.type,
|
||||
'secret',
|
||||
'Shared key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.name,
|
||||
'AES-GCM',
|
||||
'Shared key algorithm should be AES-GCM'
|
||||
);
|
||||
assert_equals(
|
||||
encapsulatedKey.sharedKey.algorithm.length,
|
||||
256,
|
||||
'Shared key length should be 256'
|
||||
);
|
||||
assert_true(
|
||||
encapsulatedKey.sharedKey.extractable,
|
||||
'Shared key should be extractable as specified'
|
||||
);
|
||||
assert_array_equals(
|
||||
encapsulatedKey.sharedKey.usages,
|
||||
['encrypt', 'decrypt'],
|
||||
'Shared key should have correct usages'
|
||||
);
|
||||
}, algorithmName + ' encapsulateKey basic functionality');
|
||||
|
||||
// Test decapsulateKey operation
|
||||
promise_test(async function (test) {
|
||||
// Generate a key pair for testing
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// First encapsulate to get ciphertext
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
|
||||
// Then decapsulate using the private key
|
||||
var decapsulatedKey = await subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
|
||||
assert_true(
|
||||
decapsulatedKey instanceof CryptoKey,
|
||||
'decapsulateKey should return a CryptoKey'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.type,
|
||||
'secret',
|
||||
'Decapsulated key should be secret type'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.name,
|
||||
'AES-GCM',
|
||||
'Decapsulated key algorithm should be AES-GCM'
|
||||
);
|
||||
assert_equals(
|
||||
decapsulatedKey.algorithm.length,
|
||||
256,
|
||||
'Decapsulated key length should be 256'
|
||||
);
|
||||
assert_true(
|
||||
decapsulatedKey.extractable,
|
||||
'Decapsulated key should be extractable as specified'
|
||||
);
|
||||
assert_array_equals(
|
||||
decapsulatedKey.usages,
|
||||
['encrypt', 'decrypt'],
|
||||
'Decapsulated key should have correct usages'
|
||||
);
|
||||
|
||||
// Extract both keys and verify they are identical
|
||||
var originalKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
encapsulatedKey.sharedKey
|
||||
);
|
||||
var decapsulatedKeyMaterial = await subtle.exportKey(
|
||||
'raw',
|
||||
decapsulatedKey
|
||||
);
|
||||
|
||||
assert_true(
|
||||
equalBuffers(originalKeyMaterial, decapsulatedKeyMaterial),
|
||||
'Decapsulated key material should match original'
|
||||
);
|
||||
}, algorithmName + ' decapsulateKey basic functionality');
|
||||
|
||||
// Test error cases for encapsulateBits
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateBits',
|
||||
'decapsulateBits',
|
||||
]);
|
||||
|
||||
// Test with wrong key type (private key instead of public)
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.encapsulateBits({ name: algorithmName }, keyPair.privateKey),
|
||||
'encapsulateBits should reject private key'
|
||||
);
|
||||
|
||||
// Test with wrong algorithm name
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.encapsulateBits({ name: 'AES-GCM' }, keyPair.publicKey),
|
||||
'encapsulateBits should reject mismatched algorithm'
|
||||
);
|
||||
}, algorithmName + ' encapsulateBits error cases');
|
||||
|
||||
// Test error cases for decapsulateBits
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateBits',
|
||||
'decapsulateBits',
|
||||
]);
|
||||
|
||||
var encapsulatedBits = await subtle.encapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey
|
||||
);
|
||||
|
||||
// Test with wrong key type (public key instead of private)
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.decapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
encapsulatedBits.ciphertext
|
||||
),
|
||||
'decapsulateBits should reject public key'
|
||||
);
|
||||
|
||||
// Test with wrong algorithm name
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.decapsulateBits(
|
||||
{ name: 'AES-GCM' },
|
||||
keyPair.privateKey,
|
||||
encapsulatedBits.ciphertext
|
||||
),
|
||||
'decapsulateBits should reject mismatched algorithm'
|
||||
);
|
||||
|
||||
// Test with invalid ciphertext
|
||||
var invalidCiphertext = new Uint8Array(10); // Wrong size
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'OperationError',
|
||||
subtle.decapsulateBits(
|
||||
{ name: algorithmName },
|
||||
keyPair.privateKey,
|
||||
invalidCiphertext
|
||||
),
|
||||
'decapsulateBits should reject invalid ciphertext'
|
||||
);
|
||||
}, algorithmName + ' decapsulateBits error cases');
|
||||
|
||||
// Test error cases for encapsulateKey
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
// Test with key without encapsulateKey usage
|
||||
var wrongKeyPair = await subtle.generateKey(
|
||||
{ name: algorithmName },
|
||||
false,
|
||||
['decapsulateKey'] // Missing encapsulateKey usage
|
||||
);
|
||||
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
wrongKeyPair.publicKey,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
),
|
||||
'encapsulateKey should reject key without encapsulateKey usage'
|
||||
);
|
||||
}, algorithmName + ' encapsulateKey error cases');
|
||||
|
||||
// Test error cases for decapsulateKey
|
||||
promise_test(async function (test) {
|
||||
var keyPair = await subtle.generateKey({ name: algorithmName }, false, [
|
||||
'encapsulateKey',
|
||||
'decapsulateKey',
|
||||
]);
|
||||
|
||||
var encapsulatedKey = await subtle.encapsulateKey(
|
||||
{ name: algorithmName },
|
||||
keyPair.publicKey,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
);
|
||||
|
||||
// Test with key without decapsulateKey usage
|
||||
var wrongKeyPair = await subtle.generateKey(
|
||||
{ name: algorithmName },
|
||||
false,
|
||||
['encapsulateKey'] // Missing decapsulateKey usage
|
||||
);
|
||||
|
||||
await promise_rejects_dom(
|
||||
test,
|
||||
'InvalidAccessError',
|
||||
subtle.decapsulateKey(
|
||||
{ name: algorithmName },
|
||||
wrongKeyPair.privateKey,
|
||||
encapsulatedKey.ciphertext,
|
||||
{ name: 'AES-GCM', length: 256 },
|
||||
true,
|
||||
['encrypt', 'decrypt']
|
||||
),
|
||||
'decapsulateKey should reject key without decapsulateKey usage'
|
||||
);
|
||||
}, algorithmName + ' decapsulateKey error cases');
|
||||
});
|
||||
}
|
||||
|
||||
// Helper function to compare two ArrayBuffers
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function run_test() {
|
||||
define_tests();
|
||||
}
|
||||
@@ -482,34 +482,5 @@ function run_test() {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using AES-CBC
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=aes_cbc_vectors.js
|
||||
// META: script=aes.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using AES-CTR
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=aes_ctr_vectors.js
|
||||
// META: script=aes.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using AES-GCM w/ 96-bit iv
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=aes_gcm_96_iv_fixtures.js
|
||||
// META: script=aes_gcm_vectors.js
|
||||
// META: script=aes.js
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using AES-GCM w/ 256-bit iv
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=aes_gcm_256_iv_fixtures.js
|
||||
// META: script=aes_gcm_vectors.js
|
||||
// META: script=aes.js
|
||||
|
||||
@@ -59,7 +59,6 @@ function getTestVectors() {
|
||||
// Scenarios that should fail because of a bad tag length, causing an OperationError
|
||||
var failing = [];
|
||||
keyLengths.forEach(function(keyLength) {
|
||||
// First, make some tests for bad tag lengths
|
||||
[24, 48, 72, 95, 129].forEach(function(badTagLength) {
|
||||
failing.push({
|
||||
name: "AES-GCM " + keyLength.toString() + "-bit key, " + (iv.byteLength << 3).toString() + "-bit iv, " + "illegal tag length " + badTagLength.toString() + "-bits",
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using AES-OCB w/ 120-bit iv
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=aes_ocb_fixtures.js
|
||||
// META: script=aes_ocb_vectors.js
|
||||
// META: script=aes.js
|
||||
|
||||
+1
-14
@@ -1,5 +1,6 @@
|
||||
// META: title=WebCryptoAPI: encrypt()/decrypt() ChaCha20-Poly1305
|
||||
// META: timeout=long
|
||||
// META: script=../util/helpers.js
|
||||
|
||||
var subtle = crypto.subtle; // Change to test prefixed implementations
|
||||
|
||||
@@ -120,20 +121,6 @@ var encryptedData = {
|
||||
},
|
||||
};
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// Test ChaCha20-Poly1305 encryption/decryption
|
||||
var algorithmName = 'ChaCha20-Poly1305';
|
||||
|
||||
|
||||
+1
-41
@@ -560,18 +560,7 @@ function run_test() {
|
||||
.then(function(key) {
|
||||
vector.publicKey = key;
|
||||
return vector;
|
||||
}); // Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if (vector.privateKey !== null) {
|
||||
@@ -589,34 +578,5 @@ function run_test() {
|
||||
return Promise.all([publicPromise, privatePromise]);
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: encrypt() Using RSA-OAEP
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=rsa_vectors.js
|
||||
// META: script=rsa.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -155,18 +155,6 @@ promise_test(async function(t) {
|
||||
// Test with empty usages array
|
||||
algorithms.forEach(function(algorithm) {
|
||||
promise_test(async function(t) {
|
||||
// Skip X25519 if not supported
|
||||
if (algorithm.name === "X25519") {
|
||||
try {
|
||||
await crypto.subtle.generateKey(algorithm.generateKeyParams, false, algorithm.usages);
|
||||
} catch (e) {
|
||||
if (e.name === "NotSupportedError") {
|
||||
return;
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
const keyPair = await crypto.subtle.generateKey(
|
||||
algorithm.generateKeyParams,
|
||||
false,
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
// META: script=/resources/WebIDLParser.js
|
||||
// META: script=/resources/idlharness.js
|
||||
// META: timeout=long
|
||||
|
||||
// https://wicg.github.io/webcrypto-secure-curves/
|
||||
// https://wicg.github.io/webcrypto-modern-algos/
|
||||
|
||||
idl_test(
|
||||
['webcrypto', 'webcrypto-secure-curves', 'webcrypto-modern-algos'],
|
||||
['html', 'dom'],
|
||||
idl_array => {
|
||||
idl_array.add_objects({
|
||||
Crypto: ['crypto'],
|
||||
SubtleCrypto: ['crypto.subtle']
|
||||
});
|
||||
}
|
||||
);
|
||||
@@ -106,44 +106,6 @@ function testFormat(format, algorithm, keyData, keySize, usages, extractable) {
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, data, algorithm, extractable, usages) {
|
||||
if ('byteLength' in data) {
|
||||
@@ -166,57 +128,3 @@ function parameterString(format, data, algorithm, extractable, usages) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return (
|
||||
'[' +
|
||||
obj
|
||||
.map(function (elem) {
|
||||
return objectToString(elem);
|
||||
})
|
||||
.join(', ') +
|
||||
']'
|
||||
);
|
||||
} else if (typeof obj === 'object') {
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach(function (keyName) {
|
||||
keyValuePairs.push(keyName + ': ' + objectToString(obj[keyName]));
|
||||
});
|
||||
return '{' + keyValuePairs.join(', ') + '}';
|
||||
} else if (typeof obj === 'undefined') {
|
||||
return 'undefined';
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach(function (keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === 'object') {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === 'array') {
|
||||
value =
|
||||
'[' +
|
||||
value
|
||||
.map(function (elem) {
|
||||
return objectToString(elem);
|
||||
})
|
||||
.join(', ') +
|
||||
']';
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ': ' + value);
|
||||
});
|
||||
|
||||
return '{' + keyValuePairs.join(', ') + '}';
|
||||
}
|
||||
@@ -106,44 +106,6 @@ function testFormat(format, algorithm, keyData, keySize, usages, extractable) {
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for (var i = 0; i < fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, data, algorithm, extractable, usages) {
|
||||
if ('byteLength' in data) {
|
||||
@@ -166,57 +128,3 @@ function parameterString(format, data, algorithm, extractable, usages) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return (
|
||||
'[' +
|
||||
obj
|
||||
.map(function (elem) {
|
||||
return objectToString(elem);
|
||||
})
|
||||
.join(', ') +
|
||||
']'
|
||||
);
|
||||
} else if (typeof obj === 'object') {
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach(function (keyName) {
|
||||
keyValuePairs.push(keyName + ': ' + objectToString(obj[keyName]));
|
||||
});
|
||||
return '{' + keyValuePairs.join(', ') + '}';
|
||||
} else if (typeof obj === 'undefined') {
|
||||
return 'undefined';
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj)
|
||||
.sort()
|
||||
.forEach(function (keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === 'object') {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === 'array') {
|
||||
value =
|
||||
'[' +
|
||||
value
|
||||
.map(function (elem) {
|
||||
return objectToString(elem);
|
||||
})
|
||||
.join(', ') +
|
||||
']';
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ': ' + value);
|
||||
});
|
||||
|
||||
return '{' + keyValuePairs.join(', ') + '}';
|
||||
}
|
||||
@@ -220,44 +220,6 @@
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build minimal Jwk objects from raw key data and algorithm specifications
|
||||
function jwkData(keyData, algorithm) {
|
||||
var result = {
|
||||
@@ -273,17 +235,6 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
// Jwk format wants Base 64 without the typical padding at the end.
|
||||
function byteArrayToUnpaddedBase64(byteArray){
|
||||
var binaryString = "";
|
||||
for (var i=0; i<byteArray.byteLength; i++){
|
||||
binaryString += String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
var base64String = btoa(binaryString);
|
||||
|
||||
return base64String.replace(/=/g, "");
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, compressed, data, algorithm, extractable, usages) {
|
||||
if ("byteLength" in data) {
|
||||
@@ -301,38 +252,3 @@
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return "[" + obj.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else if (typeof obj === "object") {
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
keyValuePairs.push(keyName + ": " + objectToString(obj[keyName]));
|
||||
});
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
} else if (typeof obj === "undefined") {
|
||||
return "undefined";
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
@@ -102,44 +102,6 @@ function testJwkAlgBehaviours(algorithm, keyData, crv, usages) {
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build minimal Jwk objects from raw key data and algorithm specifications
|
||||
function jwkData(keyData, algorithm) {
|
||||
var result = {
|
||||
@@ -155,17 +117,6 @@ function jwkData(keyData, algorithm) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Jwk format wants Base 64 without the typical padding at the end.
|
||||
function byteArrayToUnpaddedBase64(byteArray){
|
||||
var binaryString = "";
|
||||
for (var i=0; i<byteArray.byteLength; i++){
|
||||
binaryString += String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
var base64String = btoa(binaryString);
|
||||
|
||||
return base64String.replace(/=/g, "");
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, data, algorithm, extractable, usages) {
|
||||
if ("byteLength" in data) {
|
||||
@@ -183,38 +134,3 @@ function parameterString(format, data, algorithm, extractable, usages) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return "[" + obj.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else if (typeof obj === "object") {
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
keyValuePairs.push(keyName + ": " + objectToString(obj[keyName]));
|
||||
});
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
} else if (typeof obj === "undefined") {
|
||||
return "undefined";
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
@@ -153,44 +153,6 @@
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build minimal Jwk objects from raw key data and algorithm specifications
|
||||
function jwkData(keyData, algorithm) {
|
||||
var result = {
|
||||
@@ -206,17 +168,6 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
// Jwk format wants Base 64 without the typical padding at the end.
|
||||
function byteArrayToUnpaddedBase64(byteArray){
|
||||
var binaryString = "";
|
||||
for (var i=0; i<byteArray.byteLength; i++){
|
||||
binaryString += String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
var base64String = btoa(binaryString);
|
||||
|
||||
return base64String.replace(/=/g, "");
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, data, algorithm, extractable, usages) {
|
||||
if ("byteLength" in data) {
|
||||
@@ -234,38 +185,3 @@
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return "[" + obj.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else if (typeof obj === "object") {
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
keyValuePairs.push(keyName + ": " + objectToString(obj[keyName]));
|
||||
});
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
} else if (typeof obj === "undefined") {
|
||||
return "undefined";
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
@@ -115,44 +115,6 @@ function runTests(algorithmName) {
|
||||
|
||||
// Helper methods follow:
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (expected[fieldName] !== got[fieldName]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Build minimal Jwk objects from raw key data and algorithm specifications
|
||||
function jwkData(keyData, algorithm) {
|
||||
var result = {
|
||||
@@ -170,17 +132,6 @@ function runTests(algorithmName) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// Jwk format wants Base 64 without the typical padding at the end.
|
||||
function byteArrayToUnpaddedBase64(byteArray){
|
||||
var binaryString = "";
|
||||
for (var i=0; i<byteArray.byteLength; i++){
|
||||
binaryString += String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
var base64String = btoa(binaryString);
|
||||
|
||||
return base64String.replace(/=/g, "");
|
||||
}
|
||||
|
||||
// Convert method parameters to a string to uniquely name each test
|
||||
function parameterString(format, data, algorithm, extractable, usages) {
|
||||
var result = "(" +
|
||||
@@ -193,39 +144,4 @@ function runTests(algorithmName) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return "[" + obj.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else if (typeof obj === "object") {
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
keyValuePairs.push(keyName + ": " + objectToString(obj[keyName]));
|
||||
});
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
} else if (typeof obj === "undefined") {
|
||||
return "undefined";
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using ECDSA
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=ecdsa_vectors.js
|
||||
// META: script=ecdsa.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -654,34 +654,5 @@ function run_test() {
|
||||
return Promise.all([publicPromise, privatePromise]);
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -333,17 +333,5 @@ function run_test(algorithmName) {
|
||||
}, "Sign and verify using generated " + vector.algorithmName + " keys.");
|
||||
});
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using EdDSA
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=eddsa_vectors.js
|
||||
// META: script=eddsa.js
|
||||
// META: timeout=long
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using EdDSA
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=eddsa_vectors.js
|
||||
// META: script=eddsa.js
|
||||
// META: timeout=long
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: verify() Using EdDSA with small-order points
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=eddsa_vectors.js
|
||||
// META: script=eddsa_small_order_points.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using HMAC
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=hmac_vectors.js
|
||||
// META: script=hmac.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -490,34 +490,5 @@ function run_test() {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -582,34 +582,5 @@ function run_test() {
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using KMAC
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=kmac_vectors.js
|
||||
// META: script=kmac.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -1034,34 +1034,5 @@ function run_test() {
|
||||
return Promise.all([publicPromise, privatePromise]);
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength);
|
||||
|
||||
for (var i = 0; i < source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i = 0; i < a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using ML-DSA
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=mldsa_vectors.js
|
||||
// META: script=mldsa.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -577,34 +577,5 @@ function run_test() {
|
||||
return Promise.all([publicPromise, privatePromise]);
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using RSASSA-PKCS1-v1_5
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=rsa_pkcs_vectors.js
|
||||
// META: script=rsa.js
|
||||
// META: timeout=long
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
// META: title=WebCryptoAPI: sign() and verify() Using RSA-PSS
|
||||
// META: script=../util/helpers.js
|
||||
// META: script=rsa_pss_vectors.js
|
||||
// META: script=rsa.js
|
||||
// META: timeout=long
|
||||
|
||||
+76
-17
@@ -84,23 +84,6 @@ function objectToString(obj) {
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
|
||||
// Is key a CryptoKey object with correct algorithm, extractable, and usages?
|
||||
@@ -332,3 +315,79 @@ function hexStringToUint8Array(hexString)
|
||||
|
||||
return arrayBuffer;
|
||||
}
|
||||
|
||||
// Compares two ArrayBuffer or ArrayBufferView objects. If bitCount is
|
||||
// omitted, the two values must be the same length and have the same contents
|
||||
// in every byte. If bitCount is included, only that leading number of bits
|
||||
// have to match.
|
||||
function equalBuffers(a, b, bitCount) {
|
||||
var remainder;
|
||||
|
||||
if (typeof bitCount === "undefined" && a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
var length = a.byteLength;
|
||||
if (typeof bitCount !== "undefined") {
|
||||
length = Math.floor(bitCount / 8);
|
||||
}
|
||||
|
||||
for (var i=0; i<length; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof bitCount !== "undefined") {
|
||||
remainder = bitCount % 8;
|
||||
return aBytes[length] >> (8 - remainder) === bBytes[length] >> (8 - remainder);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns a copy of the sourceBuffer it is sent.
|
||||
function copyBuffer(sourceBuffer) {
|
||||
var source = new Uint8Array(sourceBuffer);
|
||||
var copy = new Uint8Array(sourceBuffer.byteLength)
|
||||
|
||||
for (var i=0; i<source.byteLength; i++) {
|
||||
copy[i] = source[i];
|
||||
}
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (objectToString(expected[fieldName]) !== objectToString(got[fieldName])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Jwk format wants Base 64 without the typical padding at the end.
|
||||
function byteArrayToUnpaddedBase64(byteArray){
|
||||
var binaryString = "";
|
||||
for (var i=0; i<byteArray.byteLength; i++){
|
||||
binaryString += String.fromCharCode(byteArray[i]);
|
||||
}
|
||||
var base64String = btoa(binaryString);
|
||||
|
||||
return base64String.replace(/=/g, "");
|
||||
}
|
||||
-73
@@ -307,79 +307,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Are two array buffers the same?
|
||||
function equalBuffers(a, b) {
|
||||
if (a.byteLength !== b.byteLength) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var aBytes = new Uint8Array(a);
|
||||
var bBytes = new Uint8Array(b);
|
||||
|
||||
for (var i=0; i<a.byteLength; i++) {
|
||||
if (aBytes[i] !== bBytes[i]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Are two Jwk objects "the same"? That is, does the object returned include
|
||||
// matching values for each property that was expected? It's okay if the
|
||||
// returned object has extra methods; they aren't checked.
|
||||
function equalJwk(expected, got) {
|
||||
var fields = Object.keys(expected);
|
||||
var fieldName;
|
||||
|
||||
for(var i=0; i<fields.length; i++) {
|
||||
fieldName = fields[i];
|
||||
if (!(fieldName in got)) {
|
||||
return false;
|
||||
}
|
||||
if (objectToString(expected[fieldName]) !== objectToString(got[fieldName])) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Character representation of any object we may use as a parameter.
|
||||
function objectToString(obj) {
|
||||
var keyValuePairs = [];
|
||||
|
||||
if (Array.isArray(obj)) {
|
||||
return "[" + obj.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else if (typeof obj === "object") {
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
keyValuePairs.push(keyName + ": " + objectToString(obj[keyName]));
|
||||
});
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
} else if (typeof obj === "undefined") {
|
||||
return "undefined";
|
||||
} else {
|
||||
return obj.toString();
|
||||
}
|
||||
|
||||
var keyValuePairs = [];
|
||||
|
||||
Object.keys(obj).sort().forEach(function(keyName) {
|
||||
var value = obj[keyName];
|
||||
if (typeof value === "object") {
|
||||
value = objectToString(value);
|
||||
} else if (typeof value === "array") {
|
||||
value = "[" + value.map(function(elem){return objectToString(elem);}).join(", ") + "]";
|
||||
} else {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
keyValuePairs.push(keyName + ": " + value);
|
||||
});
|
||||
|
||||
return "{" + keyValuePairs.join(", ") + "}";
|
||||
}
|
||||
|
||||
// Can we compare key values by using them
|
||||
function canCompareNonExtractableKeys(key){
|
||||
if (key.usages.indexOf("decrypt") !== -1) {
|
||||
|
||||
Vendored
+5
-5
@@ -313,7 +313,7 @@ interface Document : Node {
|
||||
interface XMLDocument : Document {};
|
||||
|
||||
dictionary ElementCreationOptions {
|
||||
CustomElementRegistry customElementRegistry;
|
||||
CustomElementRegistry? customElementRegistry;
|
||||
DOMString is;
|
||||
};
|
||||
|
||||
@@ -324,7 +324,7 @@ dictionary ImportNodeOptions {
|
||||
|
||||
[Exposed=Window]
|
||||
interface DOMImplementation {
|
||||
[NewObject] DocumentType createDocumentType(DOMString qualifiedName, DOMString publicId, DOMString systemId);
|
||||
[NewObject] DocumentType createDocumentType(DOMString name, DOMString publicId, DOMString systemId);
|
||||
[NewObject] XMLDocument createDocument(DOMString? namespace, [LegacyNullToEmptyString] DOMString qualifiedName, optional DocumentType? doctype = null);
|
||||
[NewObject] Document createHTMLDocument(optional DOMString title);
|
||||
|
||||
@@ -375,8 +375,8 @@ interface Element : Node {
|
||||
sequence<DOMString> getAttributeNames();
|
||||
DOMString? getAttribute(DOMString qualifiedName);
|
||||
DOMString? getAttributeNS(DOMString? namespace, DOMString localName);
|
||||
[CEReactions] undefined setAttribute(DOMString qualifiedName, DOMString value);
|
||||
[CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, DOMString value);
|
||||
[CEReactions] undefined setAttribute(DOMString qualifiedName, (TrustedType or DOMString) value);
|
||||
[CEReactions] undefined setAttributeNS(DOMString? namespace, DOMString qualifiedName, (TrustedType or DOMString) value);
|
||||
[CEReactions] undefined removeAttribute(DOMString qualifiedName);
|
||||
[CEReactions] undefined removeAttributeNS(DOMString? namespace, DOMString localName);
|
||||
[CEReactions] boolean toggleAttribute(DOMString qualifiedName, optional boolean force);
|
||||
@@ -412,7 +412,7 @@ dictionary ShadowRootInit {
|
||||
SlotAssignmentMode slotAssignment = "named";
|
||||
boolean clonable = false;
|
||||
boolean serializable = false;
|
||||
CustomElementRegistry customElementRegistry;
|
||||
CustomElementRegistry? customElementRegistry;
|
||||
};
|
||||
|
||||
[Exposed=Window,
|
||||
|
||||
+380
-337
File diff suppressed because it is too large.
Load diff
+2
-2
@@ -22,8 +22,8 @@ interface PerformanceEntry {
|
||||
};
|
||||
|
||||
callback PerformanceObserverCallback = undefined (PerformanceObserverEntryList entries,
|
||||
PerformanceObserver observer,
|
||||
optional PerformanceObserverCallbackOptions options = {});
|
||||
PerformanceObserver observer,
|
||||
optional PerformanceObserverCallbackOptions options = {});
|
||||
[Exposed=(Window,Worker)]
|
||||
interface PerformanceObserver {
|
||||
constructor(PerformanceObserverCallback callback);
|
||||
|
||||
+6
-2
@@ -22,12 +22,17 @@ interface PerformanceResourceTiming : PerformanceEntry {
|
||||
readonly attribute DOMHighResTimeStamp firstInterimResponseStart;
|
||||
readonly attribute DOMHighResTimeStamp responseStart;
|
||||
readonly attribute DOMHighResTimeStamp responseEnd;
|
||||
readonly attribute DOMHighResTimeStamp workerRouterEvaluationStart;
|
||||
readonly attribute DOMHighResTimeStamp workerCacheLookupStart;
|
||||
readonly attribute DOMString workerMatchedRouterSource;
|
||||
readonly attribute DOMString workerFinalRouterSource;
|
||||
readonly attribute unsigned long long transferSize;
|
||||
readonly attribute unsigned long long encodedBodySize;
|
||||
readonly attribute unsigned long long decodedBodySize;
|
||||
readonly attribute unsigned short responseStatus;
|
||||
readonly attribute RenderBlockingStatusType renderBlockingStatus;
|
||||
readonly attribute DOMString contentType;
|
||||
readonly attribute DOMString contentEncoding;
|
||||
[Default] object toJSON();
|
||||
};
|
||||
|
||||
@@ -36,8 +41,7 @@ enum RenderBlockingStatusType {
|
||||
"non-blocking"
|
||||
};
|
||||
|
||||
partial interface Performance {
|
||||
undefined clearResourceTimings ();
|
||||
partial interface Performance { undefined clearResourceTimings ();
|
||||
undefined setResourceTimingBufferSize (unsigned long maxSize);
|
||||
attribute EventHandler onresourcetimingbufferfull;
|
||||
};
|
||||
+1
-1
@@ -17,7 +17,7 @@ interface ReadableStream {
|
||||
Promise<undefined> pipeTo(WritableStream destination, optional StreamPipeOptions options = {});
|
||||
sequence<ReadableStream> tee();
|
||||
|
||||
async iterable<any>(optional ReadableStreamIteratorOptions options = {});
|
||||
async_iterable<any>(optional ReadableStreamIteratorOptions options = {});
|
||||
};
|
||||
|
||||
typedef (ReadableStreamDefaultReader or ReadableStreamBYOBReader) ReadableStreamReader;
|
||||
|
||||
+7
-2
@@ -1,3 +1,8 @@
|
||||
// GENERATED CONTENT - DO NOT EDIT
|
||||
// Content was automatically extracted by Reffy into webref
|
||||
// (https://github.com/w3c/webref)
|
||||
// Source: Web Locks API (https://w3c.github.io/web-locks/)
|
||||
|
||||
[SecureContext]
|
||||
interface mixin NavigatorLocks {
|
||||
readonly attribute LockManager locks;
|
||||
@@ -5,7 +10,7 @@ interface mixin NavigatorLocks {
|
||||
Navigator includes NavigatorLocks;
|
||||
WorkerNavigator includes NavigatorLocks;
|
||||
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
||||
[SecureContext, Exposed=(Window,Worker,SharedStorageWorklet)]
|
||||
interface LockManager {
|
||||
Promise<any> request(DOMString name,
|
||||
LockGrantedCallback callback);
|
||||
@@ -38,7 +43,7 @@ dictionary LockInfo {
|
||||
DOMString clientId;
|
||||
};
|
||||
|
||||
[SecureContext, Exposed=(Window,Worker)]
|
||||
[SecureContext, Exposed=(Window,Worker,SharedStorageWorklet)]
|
||||
interface Lock {
|
||||
readonly attribute DOMString name;
|
||||
readonly attribute LockMode mode;
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
// GENERATED CONTENT - DO NOT EDIT
|
||||
// Content was automatically extracted by Reffy into webref
|
||||
// (https://github.com/w3c/webref)
|
||||
// Source: Modern Algorithms in the Web Cryptography API (https://wicg.github.io/webcrypto-modern-algos/)
|
||||
|
||||
[SecureContext,Exposed=(Window,Worker)]
|
||||
partial interface SubtleCrypto {
|
||||
Promise<EncapsulatedKey> encapsulateKey(
|
||||
AlgorithmIdentifier encapsulationAlgorithm,
|
||||
CryptoKey encapsulationKey,
|
||||
AlgorithmIdentifier sharedKeyAlgorithm,
|
||||
boolean extractable,
|
||||
sequence<KeyUsage> keyUsages
|
||||
);
|
||||
Promise<EncapsulatedBits> encapsulateBits(
|
||||
AlgorithmIdentifier encapsulationAlgorithm,
|
||||
CryptoKey encapsulationKey
|
||||
);
|
||||
|
||||
Promise<CryptoKey> decapsulateKey(
|
||||
AlgorithmIdentifier decapsulationAlgorithm,
|
||||
CryptoKey decapsulationKey,
|
||||
BufferSource ciphertext,
|
||||
AlgorithmIdentifier sharedKeyAlgorithm,
|
||||
boolean extractable,
|
||||
sequence<KeyUsage> keyUsages
|
||||
);
|
||||
Promise<ArrayBuffer> decapsulateBits(
|
||||
AlgorithmIdentifier decapsulationAlgorithm,
|
||||
CryptoKey decapsulationKey,
|
||||
BufferSource ciphertext
|
||||
);
|
||||
|
||||
Promise<CryptoKey> getPublicKey(
|
||||
CryptoKey key,
|
||||
sequence<KeyUsage> keyUsages
|
||||
);
|
||||
|
||||
static boolean supports(DOMString operation,
|
||||
AlgorithmIdentifier algorithm,
|
||||
optional unsigned long? length = null);
|
||||
static boolean supports(DOMString operation,
|
||||
AlgorithmIdentifier algorithm,
|
||||
AlgorithmIdentifier additionalAlgorithm);
|
||||
};
|
||||
|
||||
enum KeyFormat { "raw-public", "raw-private", "raw-seed", "raw-secret", "raw", "spki", "pkcs8", "jwk" };
|
||||
|
||||
enum KeyUsage { "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", "unwrapKey", "encapsulateKey", "encapsulateBits", "decapsulateKey", "decapsulateBits" };
|
||||
|
||||
dictionary EncapsulatedKey {
|
||||
CryptoKey sharedKey;
|
||||
ArrayBuffer ciphertext;
|
||||
};
|
||||
|
||||
dictionary EncapsulatedBits {
|
||||
ArrayBuffer sharedKey;
|
||||
ArrayBuffer ciphertext;
|
||||
};
|
||||
|
||||
partial dictionary JsonWebKey {
|
||||
// The following fields are defined in draft-ietf-cose-dilithium-08
|
||||
DOMString pub;
|
||||
DOMString priv;
|
||||
};
|
||||
|
||||
dictionary ContextParams : Algorithm {
|
||||
BufferSource context;
|
||||
};
|
||||
|
||||
dictionary AeadParams : Algorithm {
|
||||
required BufferSource iv;
|
||||
BufferSource additionalData;
|
||||
[EnforceRange] octet tagLength;
|
||||
};
|
||||
|
||||
dictionary CShakeParams : Algorithm {
|
||||
required [EnforceRange] unsigned long outputLength;
|
||||
BufferSource functionName;
|
||||
BufferSource customization;
|
||||
};
|
||||
|
||||
dictionary TurboShakeParams : Algorithm {
|
||||
required [EnforceRange] unsigned long outputLength;
|
||||
[EnforceRange] octet domainSeparation;
|
||||
};
|
||||
|
||||
dictionary KangarooTwelveParams : Algorithm {
|
||||
required [EnforceRange] unsigned long outputLength;
|
||||
BufferSource customization;
|
||||
};
|
||||
|
||||
dictionary KmacKeyGenParams : Algorithm {
|
||||
[EnforceRange] unsigned long length;
|
||||
};
|
||||
|
||||
dictionary KmacImportParams : Algorithm {
|
||||
[EnforceRange] unsigned long length;
|
||||
};
|
||||
|
||||
dictionary KmacKeyAlgorithm : KeyAlgorithm {
|
||||
required unsigned long length;
|
||||
};
|
||||
|
||||
dictionary KmacParams : Algorithm {
|
||||
required [EnforceRange] unsigned long outputLength;
|
||||
BufferSource customization;
|
||||
};
|
||||
|
||||
dictionary Argon2Params : Algorithm {
|
||||
required BufferSource nonce;
|
||||
required [EnforceRange] unsigned long parallelism;
|
||||
required [EnforceRange] unsigned long memory;
|
||||
required [EnforceRange] unsigned long passes;
|
||||
[EnforceRange] octet version;
|
||||
BufferSource secretValue;
|
||||
BufferSource associatedData;
|
||||
};
|
||||
@@ -0,0 +1,8 @@
|
||||
// GENERATED CONTENT - DO NOT EDIT
|
||||
// Content was automatically extracted by Reffy into webref
|
||||
// (https://github.com/w3c/webref)
|
||||
// Source: Secure Curves in the Web Cryptography API (https://wicg.github.io/webcrypto-secure-curves/)
|
||||
|
||||
dictionary Ed448Params : Algorithm {
|
||||
BufferSource context;
|
||||
};
|
||||
+1
-5
@@ -1,7 +1,7 @@
|
||||
// GENERATED CONTENT - DO NOT EDIT
|
||||
// Content was automatically extracted by Reffy into webref
|
||||
// (https://github.com/w3c/webref)
|
||||
// Source: Web Cryptography API (https://w3c.github.io/webcrypto/)
|
||||
// Source: Web Cryptography API Level 2 (https://w3c.github.io/webcrypto/)
|
||||
|
||||
partial interface mixin WindowOrWorkerGlobalScope {
|
||||
[SameObject] readonly attribute Crypto crypto;
|
||||
@@ -28,8 +28,6 @@ dictionary KeyAlgorithm {
|
||||
|
||||
enum KeyType { "public", "private", "secret" };
|
||||
|
||||
enum KeyUsage { "encrypt", "decrypt", "sign", "verify", "deriveKey", "deriveBits", "wrapKey", "unwrapKey" };
|
||||
|
||||
[SecureContext,Exposed=(Window,Worker),Serializable]
|
||||
interface CryptoKey {
|
||||
readonly attribute KeyType type;
|
||||
@@ -38,8 +36,6 @@ interface CryptoKey {
|
||||
readonly attribute object usages;
|
||||
};
|
||||
|
||||
enum KeyFormat { "raw", "spki", "pkcs8", "jwk" };
|
||||
|
||||
[SecureContext,Exposed=(Window,Worker)]
|
||||
interface SubtleCrypto {
|
||||
Promise<ArrayBuffer> encrypt(
|
||||
|
||||
+13
@@ -3,6 +3,19 @@
|
||||
// (https://github.com/w3c/webref)
|
||||
// Source: Web IDL Standard (https://webidl.spec.whatwg.org/)
|
||||
|
||||
[Exposed=*, Serializable]
|
||||
interface QuotaExceededError : DOMException {
|
||||
constructor(optional DOMString message = "", optional QuotaExceededErrorOptions options = {});
|
||||
|
||||
readonly attribute double? quota;
|
||||
readonly attribute double? requested;
|
||||
};
|
||||
|
||||
dictionary QuotaExceededErrorOptions {
|
||||
double quota;
|
||||
double requested;
|
||||
};
|
||||
|
||||
typedef (Int8Array or Int16Array or Int32Array or
|
||||
Uint8Array or Uint16Array or Uint32Array or Uint8ClampedArray or
|
||||
BigInt64Array or BigUint64Array or
|
||||
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
%PDF-1.7
|
||||
% ò¤ô
|
||||
1 0 obj <<
|
||||
/Type /Catalog
|
||||
/Pages 2 0 R
|
||||
>>
|
||||
endobj
|
||||
2 0 obj <<
|
||||
/Type /Pages
|
||||
/MediaBox [ 0 0 200 300 ]
|
||||
/Count 1
|
||||
/Kids [ 3 0 R ]
|
||||
>>
|
||||
endobj
|
||||
3 0 obj <<
|
||||
/Type /Page
|
||||
/Parent 2 0 R
|
||||
/Contents 4 0 R
|
||||
>>
|
||||
endobj
|
||||
4 0 obj <<
|
||||
>>
|
||||
stream
|
||||
q
|
||||
0 0 0 rg
|
||||
0 290 10 10 re B*
|
||||
10 150 50 30 re B*
|
||||
0 0 1 rg
|
||||
190 290 10 10 re B*
|
||||
70 232 50 30 re B*
|
||||
0 1 0 rg
|
||||
190 0 10 10 re B*
|
||||
130 150 50 30 re B*
|
||||
1 0 0 rg
|
||||
0 0 10 10 re B*
|
||||
70 67 50 30 re B*
|
||||
Q
|
||||
endstream
|
||||
endobj
|
||||
xref
|
||||
0 5
|
||||
0000000000 65535 f
|
||||
0000000015 00000 n
|
||||
0000000068 00000 n
|
||||
0000000161 00000 n
|
||||
0000000230 00000 n
|
||||
trailer<< /Root 1 0 R /Size 5 >>
|
||||
startxref
|
||||
456
|
||||
%%EOF
|
||||
+1
-1
@@ -1398,7 +1398,7 @@ IdlInterface.prototype.default_to_json_operation = function() {
|
||||
if (I.has_default_to_json_regular_operation()) {
|
||||
isDefault = true;
|
||||
for (const m of I.members) {
|
||||
if (m.special !== "static" && m.type == "attribute" && I.array.is_json_type(m.idlType)) {
|
||||
if (!m.untested && m.special !== "static" && m.type == "attribute" && I.array.is_json_type(m.idlType)) {
|
||||
map.set(m.name, m.idlType);
|
||||
}
|
||||
}
|
||||
|
||||
+11
-3
@@ -252,7 +252,7 @@
|
||||
*/
|
||||
addTick: function(duration) {
|
||||
this.tickIdx += 1;
|
||||
if (duration) {
|
||||
if (duration !== undefined && duration !== null) {
|
||||
this.pause(duration);
|
||||
}
|
||||
return this;
|
||||
@@ -279,6 +279,10 @@
|
||||
/**
|
||||
* Create a keyDown event for the current default key source
|
||||
*
|
||||
* To send special keys, send the respective key's codepoint,
|
||||
* as defined by `WebDriver
|
||||
* <https://w3c.github.io/webdriver/#keyboard-actions>`_.
|
||||
*
|
||||
* @param {String} key - Key to press
|
||||
* @param {String?} sourceName - Named key source to use or null for the default key source
|
||||
* @returns {Actions}
|
||||
@@ -292,6 +296,10 @@
|
||||
/**
|
||||
* Create a keyUp event for the current default key source
|
||||
*
|
||||
* To send special keys, send the respective key's codepoint,
|
||||
* as defined by `WebDriver
|
||||
* <https://w3c.github.io/webdriver/#keyboard-actions>`_.
|
||||
*
|
||||
* @param {String} key - Key to release
|
||||
* @param {String?} sourceName - Named key source to use or null for the default key source
|
||||
* @returns {Actions}
|
||||
@@ -536,7 +544,7 @@
|
||||
tick = actions.addTick().tickIdx;
|
||||
}
|
||||
let moveAction = {type: "pointerMove", x, y, origin};
|
||||
if (duration) {
|
||||
if (duration !== undefined && duration !== null) {
|
||||
moveAction.duration = duration;
|
||||
}
|
||||
let actionProperties = setPointerProperties(moveAction, width, height, pressure,
|
||||
@@ -581,7 +589,7 @@
|
||||
tick = actions.addTick().tickIdx;
|
||||
}
|
||||
this.actions.set(tick, {type: "scroll", x, y, deltaX, deltaY, origin});
|
||||
if (duration) {
|
||||
if (duration !== undefined && duration !== null) {
|
||||
this.actions.get(tick).duration = duration;
|
||||
}
|
||||
},
|
||||
|
||||
+268
-1
@@ -23,6 +23,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
function assertTestIsTentative(){
|
||||
const testPath = location.pathname;
|
||||
const tentative = testPath.includes('.tentative.') || testPath.includes('/tentative/');
|
||||
if (!tentative) {
|
||||
throw new Error("Method in testdriver.js intended for tentative tests used in non-tentative test");
|
||||
}
|
||||
}
|
||||
|
||||
function getInViewCenterPoint(rect) {
|
||||
var left = Math.max(0, rect.left);
|
||||
var right = Math.min(window.innerWidth, rect.right);
|
||||
@@ -769,6 +777,78 @@
|
||||
},
|
||||
}
|
||||
},
|
||||
/**
|
||||
* `speculation <https://wicg.github.io/nav-speculation/prefetch.html>`_ module.
|
||||
*/
|
||||
speculation: {
|
||||
/**
|
||||
* `speculation.PrefetchStatusUpdated <https://wicg.github.io/nav-speculation/prefetch.html#speculation-prefetchstatusupdated-event>`_
|
||||
* event.
|
||||
*/
|
||||
prefetch_status_updated: {
|
||||
/**
|
||||
* @typedef {object} PrefetchStatusUpdated
|
||||
* `speculation.PrefetchStatusUpdatedParameters <https://wicg.github.io/nav-speculation/prefetch.html#cddl-type-speculationprefetchstatusupdatedparameters>`_
|
||||
* event.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Subscribes to the event. Events will be emitted only if
|
||||
* there is a subscription for the event. This method does
|
||||
* not add actual listeners. To listen to the event, use the
|
||||
* `on` or `once` methods. The buffered events will be
|
||||
* emitted before the command promise is resolved.
|
||||
*
|
||||
* @param {object} [params] Parameters for the subscription.
|
||||
* @param {null|Array.<(Context)>} [params.contexts] The
|
||||
* optional contexts parameter specifies which browsing
|
||||
* contexts to subscribe to the event on. It should be
|
||||
* either an array of Context objects, or null. If null, the
|
||||
* event will be subscribed to globally. If omitted, the
|
||||
* event will be subscribed to on the current browsing
|
||||
* context.
|
||||
* @returns {Promise<(function(): Promise<void>)>} Callback
|
||||
* for unsubscribing from the created subscription.
|
||||
*/
|
||||
subscribe: async function(params = {}) {
|
||||
assertBidiIsEnabled();
|
||||
return window.test_driver_internal.bidi.speculation
|
||||
.prefetch_status_updated.subscribe(params);
|
||||
},
|
||||
/**
|
||||
* Adds an event listener for the event.
|
||||
*
|
||||
* @param {function(PrefetchStatusUpdated): void} callback The
|
||||
* callback to be called when the event is emitted. The
|
||||
* callback is called with the event object as a parameter.
|
||||
* @returns {function(): void} A function that removes the
|
||||
* added event listener when called.
|
||||
*/
|
||||
on: function(callback) {
|
||||
assertBidiIsEnabled();
|
||||
return window.test_driver_internal.bidi.speculation
|
||||
.prefetch_status_updated.on(callback);
|
||||
},
|
||||
/**
|
||||
* Adds an event listener for the event that is only called
|
||||
* once and removed afterward.
|
||||
*
|
||||
* @return {Promise<PrefetchStatusUpdated>} The promise which
|
||||
* is resolved with the event object when the event is emitted.
|
||||
*/
|
||||
once: function() {
|
||||
assertBidiIsEnabled();
|
||||
return new Promise(resolve => {
|
||||
const remove_handler =
|
||||
window.test_driver_internal.bidi.speculation
|
||||
.prefetch_status_updated.on(event => {
|
||||
resolve(event);
|
||||
remove_handler();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* `emulation <https://www.w3.org/TR/webdriver-bidi/#module-emulation>`_ module.
|
||||
*/
|
||||
@@ -882,6 +962,61 @@
|
||||
return window.test_driver_internal.bidi.emulation.set_screen_orientation_override(
|
||||
params);
|
||||
},
|
||||
/**
|
||||
* Overrides the touch configuration for the specified browsing
|
||||
* contexts.
|
||||
* Matches the `emulation.setTouchOverride
|
||||
* <https://w3c.github.io/webdriver-bidi/#command-emulation-setTouchOverride>`_
|
||||
* WebDriver BiDi command.
|
||||
*
|
||||
* @example
|
||||
* await test_driver.bidi.emulation.set_touch_override({
|
||||
* maxTouchPoints: 5
|
||||
* });
|
||||
*
|
||||
* @param {object} params - Parameters for the command.
|
||||
* @param {null|number} params.maxTouchPoints - The
|
||||
* maximum number of simultaneous touch points to support.
|
||||
* If null or omitted, the override will be removed.
|
||||
* @param {null|Array.<(Context)>} [params.contexts] The
|
||||
* optional contexts parameter specifies which browsing contexts
|
||||
* to set the touch override on. It should be either an array of
|
||||
* Context objects (window or browsing context id), or null. If
|
||||
* null or omitted, the override will be set on the current
|
||||
* browsing context.
|
||||
* @returns {Promise<void>} Resolves when the touch
|
||||
* override is successfully set.
|
||||
*/
|
||||
set_touch_override: function (params) {
|
||||
assertBidiIsEnabled();
|
||||
return window.test_driver_internal.bidi.emulation.set_touch_override(
|
||||
params);
|
||||
},
|
||||
},
|
||||
/**
|
||||
* `user_agent_client_hints <https://wicg.github.io/ua-client-hints/#automation>`_ module.
|
||||
*/
|
||||
user_agent_client_hints: {
|
||||
/**
|
||||
* Overrides the user agent client hints configuration for the specified browsing
|
||||
* contexts. Matches the `userAgentClientHints.setClientHintsOverride
|
||||
* <https://wicg.github.io/ua-client-hints/#emulation-setclienthintsoverride>`_
|
||||
* WebDriver BiDi command.
|
||||
*
|
||||
* @param {object} params - Parameters for the command.
|
||||
* @param {null|object} params.clientHints - The client hints to override.
|
||||
* Matches the `userAgentClientHints.ClientHints` type.
|
||||
* If null or omitted, the override will be removed.
|
||||
* @param {null|Array.<(Context)>} [params.contexts] The
|
||||
* optional contexts parameter specifies which browsing contexts
|
||||
* to set the override on.
|
||||
* @returns {Promise<void>} Resolves when the override is successfully set.
|
||||
*/
|
||||
set_client_hints_override: function (params) {
|
||||
assertBidiIsEnabled();
|
||||
return window.test_driver_internal.bidi.user_agent_client_hints.set_client_hints_override(
|
||||
params);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* `log <https://www.w3.org/TR/webdriver-bidi/#module-log>`_ module.
|
||||
@@ -973,9 +1108,12 @@
|
||||
* @param {PermissionState} params.state - a `PermissionState
|
||||
* <https://w3c.github.io/permissions/#dom-permissionstate>`_
|
||||
* value.
|
||||
* @param {string} [params.origin] - an optional `origin` string to set the
|
||||
* @param {string} [params.origin] - an optional top-level `origin` string to set the
|
||||
* permission for. If omitted, the permission is set for the
|
||||
* current window's origin.
|
||||
* @param {string} [params.embeddedOrigin] - an optional embedded `origin` string to set the
|
||||
* permission for. If omitted, the top-level `origin` is used as the
|
||||
* embedded origin.
|
||||
* @returns {Promise} fulfilled after the permission is set, or rejected if setting
|
||||
* the permission fails.
|
||||
*/
|
||||
@@ -1191,6 +1329,34 @@
|
||||
return role;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get accessibility properties for a DOM element.
|
||||
*
|
||||
* @param {Element} element
|
||||
* @returns {Promise} fulfilled after the accessibility properties are
|
||||
* returned, or rejected in the cases the WebDriver
|
||||
* command errors
|
||||
*/
|
||||
get_accessibility_properties_for_element: async function(element) {
|
||||
assertTestIsTentative();
|
||||
let acc = await window.test_driver_internal.get_accessibility_properties_for_element(element);
|
||||
return acc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Get properties for an accessibility node.
|
||||
*
|
||||
* @param {String} accId
|
||||
* @returns {Promise} fulfilled after the accessibility properties are
|
||||
* returned, or rejected in the cases the WebDriver
|
||||
* command errors
|
||||
*/
|
||||
get_accessibility_properties_for_accessibility_node: async function(accId) {
|
||||
assertTestIsTentative();
|
||||
let acc = await window.test_driver_internal.get_accessibility_properties_for_accessibility_node(accId);
|
||||
return acc;
|
||||
},
|
||||
|
||||
/**
|
||||
* Send keys to an element.
|
||||
*
|
||||
@@ -2169,6 +2335,69 @@
|
||||
*/
|
||||
clear_display_features: function(context=null) {
|
||||
return window.test_driver_internal.clear_display_features(context);
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current globally-applied privacy control status
|
||||
*
|
||||
* @returns {Promise} Fulfils with an object with boolean property `gpc`
|
||||
* that encodes the current "do not sell or share"
|
||||
* signal the browser is configured to convey.
|
||||
*/
|
||||
get_global_privacy_control: function() {
|
||||
return window.test_driver_internal.get_global_privacy_control();
|
||||
},
|
||||
|
||||
/**
|
||||
* Gets the current globally-applied privacy control status
|
||||
*
|
||||
* @param {bool} newValue - The a boolean that is true if the browers
|
||||
* should convey a "do not sell or share" signal
|
||||
* and false otherwise
|
||||
*
|
||||
* @returns {Promise} Fulfils with an object with boolean property `gpc`
|
||||
* that encodes the new "do not sell or share"
|
||||
* after applying the new value.
|
||||
*/
|
||||
set_global_privacy_control: function(newValue) {
|
||||
return window.test_driver_internal.set_global_privacy_control(newValue);
|
||||
},
|
||||
|
||||
/**
|
||||
* Installs a WebExtension.
|
||||
*
|
||||
* Matches the `Install WebExtension
|
||||
* <https://github.com/w3c/webextensions/blob/main/specification/webdriver-classic.bs>`_
|
||||
* WebDriver command.
|
||||
*
|
||||
* @param {Object} params - Parameters for loading the extension.
|
||||
* @param {String} params.type - A type such as "path", "archivePath", or "base64".
|
||||
*
|
||||
* @param {String} params.path - The path to the extension's resources if type "path" or "archivePath" is specified.
|
||||
*
|
||||
* @param {String} params.value - The base64 encoded value of the extension's resources if type "base64" is specified.
|
||||
*
|
||||
* @returns {Promise} Returns the extension identifier as defined in the spec.
|
||||
* Rejected if the extension fails to load.
|
||||
*/
|
||||
install_web_extension: function(params) {
|
||||
return window.test_driver_internal.install_web_extension(params);
|
||||
},
|
||||
|
||||
/**
|
||||
* Uninstalls a WebExtension.
|
||||
*
|
||||
* Matches the `Uninstall WebExtension
|
||||
* <https://github.com/w3c/webextensions/blob/main/specification/webdriver-classic.bs>`_
|
||||
* WebDriver command.
|
||||
*
|
||||
* @param {String} extension_id - The extension identifier.
|
||||
*
|
||||
* @returns {Promise} Fulfilled after the extension has been removed.
|
||||
* Rejected in case the WebDriver command errors out.
|
||||
*/
|
||||
uninstall_web_extension: function(extension_id) {
|
||||
return window.test_driver_internal.uninstall_web_extension(extension_id);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -2252,6 +2481,16 @@
|
||||
set_screen_orientation_override: function (params) {
|
||||
throw new Error(
|
||||
"bidi.emulation.set_screen_orientation_override is not implemented by testdriver-vendor.js");
|
||||
},
|
||||
set_touch_override: function (params) {
|
||||
throw new Error(
|
||||
"bidi.emulation.set_touch_override is not implemented by testdriver-vendor.js");
|
||||
}
|
||||
},
|
||||
user_agent_client_hints: {
|
||||
set_client_hints_override: function (params) {
|
||||
throw new Error(
|
||||
"bidi.user_agent_client_hints.set_client_hints_override is not implemented by testdriver-vendor.js");
|
||||
}
|
||||
},
|
||||
log: {
|
||||
@@ -2271,6 +2510,18 @@
|
||||
throw new Error(
|
||||
"bidi.permissions.set_permission() is not implemented by testdriver-vendor.js");
|
||||
}
|
||||
},
|
||||
speculation: {
|
||||
prefetch_status_updated: {
|
||||
async subscribe() {
|
||||
throw new Error(
|
||||
'bidi.speculation.prefetch_status_updated.subscribe is not implemented by testdriver-vendor.js');
|
||||
},
|
||||
on() {
|
||||
throw new Error(
|
||||
'bidi.speculation.prefetch_status_updated.on is not implemented by testdriver-vendor.js');
|
||||
}
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2304,6 +2555,14 @@
|
||||
throw new Error("get_computed_name is a testdriver.js function which cannot be run in this context.");
|
||||
},
|
||||
|
||||
async get_accessibility_properties_for_element(element) {
|
||||
throw new Error("get_accessibility_properties_for_element is a testdriver.js function which cannot be run in this context.");
|
||||
},
|
||||
|
||||
async get_accessibility_properties_for_accessibility_node(accId) {
|
||||
throw new Error("get_accessibility_properties_for_accessibility_node is a testdriver.js function which cannot be run in this context.");
|
||||
},
|
||||
|
||||
async send_keys(element, keys) {
|
||||
if (this.in_automation) {
|
||||
throw new Error("send_keys() is not implemented by testdriver-vendor.js");
|
||||
@@ -2486,6 +2745,14 @@
|
||||
|
||||
async clear_display_features(context=null) {
|
||||
throw new Error("clear_display_features() is not implemented by testdriver-vendor.js");
|
||||
},
|
||||
|
||||
async set_global_privacy_control(newValue) {
|
||||
throw new Error("set_global_privacy_control() is not implemented by testdriver-vendor.js");
|
||||
},
|
||||
|
||||
async get_global_privacy_control() {
|
||||
throw new Error("get_global_privacy_control() is not implemented by testdriver-vendor.js");
|
||||
}
|
||||
};
|
||||
})();
|
||||
+1
-1
@@ -5144,7 +5144,7 @@ table#results.assertions > tbody > tr > td:last-child {\
|
||||
width:35%;\
|
||||
}\
|
||||
\
|
||||
table#results > thead > > tr > th {\
|
||||
table#results > thead > tr > th {\
|
||||
padding:0;\
|
||||
padding-bottom:0.5em;\
|
||||
border-bottom:medium solid black;\
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
// testharness file with WebExtensions utilities
|
||||
|
||||
/**
|
||||
* Loads the WebExtension at the path specified and runs the tests defined in the extension's resources.
|
||||
* Listens to messages sent from the user agent and converts the `browser.test` assertions
|
||||
* into testharness.js assertions.
|
||||
*
|
||||
* @param {string} extensionPath - a path to the extension's resources.
|
||||
*/
|
||||
|
||||
setup({ explicit_done: true })
|
||||
globalThis.runTestsWithWebExtension = function(extensionPath) {
|
||||
test_driver.install_web_extension({
|
||||
type: "path",
|
||||
path: extensionPath
|
||||
})
|
||||
.then((result) => {
|
||||
let test;
|
||||
browser.test.onTestStarted.addListener((data) => {
|
||||
test = async_test(data.testName)
|
||||
})
|
||||
|
||||
browser.test.onTestFinished.addListener((data) => {
|
||||
test.step(() => {
|
||||
let description = data.message ? `${data.assertionDescription}. ${data.message}` : data.assertionDescription
|
||||
assert_true(data.result, description)
|
||||
})
|
||||
|
||||
test.done()
|
||||
|
||||
if (!data.result) {
|
||||
test.set_status(test.FAIL)
|
||||
}
|
||||
|
||||
if (!data.remainingTests) {
|
||||
test_driver.uninstall_web_extension(result.extension).then(() => { done() })
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
+1
-1
@@ -1 +1 @@
|
||||
Currently using webidl2.js@6889aee6fc7d65915ab1267825248157dbc50486.
|
||||
Currently using webidl2.js@e6d8ab852ec4e76596f6e308eb7f2efc8b613bfd.
|
||||
+383
-205
File diff suppressed because it is too large.
Load diff
Vendored
+3
-3
@@ -52,7 +52,7 @@
|
||||
"path": "html/webappapis/timers"
|
||||
},
|
||||
"interfaces": {
|
||||
"commit": "e1b27be06b43787a001b7297c4e0fabdd276560f",
|
||||
"commit": "a8392bd0210378dda13278eeccf2c2602278e214",
|
||||
"path": "interfaces"
|
||||
},
|
||||
"performance-timeline": {
|
||||
@@ -64,7 +64,7 @@
|
||||
"path": "resource-timing"
|
||||
},
|
||||
"resources": {
|
||||
"commit": "1d2c5fb36a6e477c8f915bde7eca027be6abe792",
|
||||
"commit": "6a2f32237615d7ea9c1eb1e30453066b5555c603",
|
||||
"path": "resources"
|
||||
},
|
||||
"streams": {
|
||||
@@ -96,7 +96,7 @@
|
||||
"path": "web-locks"
|
||||
},
|
||||
"WebCryptoAPI": {
|
||||
"commit": "0acea989ac21842d6545d16594f1a05491c6076e",
|
||||
"commit": "caebe89c3b243513c4b7e5e8dd2a370e5800bb73",
|
||||
"path": "WebCryptoAPI"
|
||||
},
|
||||
"webidl": {
|
||||
|
||||
@@ -55,6 +55,12 @@ module.exports = {
|
||||
'historical.any.js': {
|
||||
'skip': 'Not relevant in Node.js context',
|
||||
},
|
||||
'digest/turboshake.tentative.https.any.js': {
|
||||
'skip': 'not implemented',
|
||||
},
|
||||
'digest/kangarootwelve.tentative.https.any.js': {
|
||||
'skip': 'not implemented',
|
||||
},
|
||||
'sign_verify/eddsa_small_order_points.https.any.js': {
|
||||
'fail': {
|
||||
'note': 'see https://github.com/nodejs/node/issues/54572',
|
||||
|
||||
@@ -31,7 +31,17 @@
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"firstInterimResponseStart\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"renderBlockingStatus\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"contentType\" with the proper type",
|
||||
"PerformanceResourceTiming interface: default toJSON operation on resource"
|
||||
"PerformanceResourceTiming interface: default toJSON operation on resource",
|
||||
"PerformanceResourceTiming interface: attribute workerRouterEvaluationStart",
|
||||
"PerformanceResourceTiming interface: attribute workerCacheLookupStart",
|
||||
"PerformanceResourceTiming interface: attribute workerMatchedRouterSource",
|
||||
"PerformanceResourceTiming interface: attribute workerFinalRouterSource",
|
||||
"PerformanceResourceTiming interface: attribute contentEncoding",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"workerRouterEvaluationStart\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"workerCacheLookupStart\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"workerMatchedRouterSource\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"workerFinalRouterSource\" with the proper type",
|
||||
"PerformanceResourceTiming interface: resource must inherit property \"contentEncoding\" with the proper type"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user