зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1508825 - Enable ESLint for dom/crypto (manual changes) r=Standard8,Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D13694 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
fbb0aae478
Коммит
92c4139a6d
|
@ -182,7 +182,6 @@ dom/cache/test/mochitest/**
|
|||
dom/cache/test/xpcshell/**
|
||||
dom/canvas/**
|
||||
dom/console/**
|
||||
dom/crypto/**
|
||||
dom/encoding/**
|
||||
dom/events/**
|
||||
dom/fetch/**
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// This file expects utils.js to be included in its scope
|
||||
/* import-globals-from ./util.js */
|
||||
var MOCHITEST = false;
|
||||
|
||||
function Test(name, test) {
|
||||
|
@ -34,7 +36,9 @@ function Test(name, test) {
|
|||
};
|
||||
|
||||
this.complete = function(result) {
|
||||
if (MOCHITEST) { ok(result, this.name); }
|
||||
if (MOCHITEST) {
|
||||
ok(result, this.name);
|
||||
}
|
||||
|
||||
// Note the end time
|
||||
this.endTime = new Date();
|
||||
|
@ -60,28 +64,30 @@ function Test(name, test) {
|
|||
|
||||
// Print the name of the test
|
||||
if (this.name) {
|
||||
this.row[0].innerHTML = this.name;
|
||||
this.row[0].textContent = this.name;
|
||||
var that = this;
|
||||
this.row[0].onclick = function() { that.run(); };
|
||||
this.row[0].onclick = function() {
|
||||
that.run();
|
||||
};
|
||||
} else {
|
||||
this.row[0] = "";
|
||||
}
|
||||
|
||||
// Print the result of the test
|
||||
if (this.result == true) {
|
||||
if (this.result === true) {
|
||||
this.row[1].className = "pass";
|
||||
this.row[1].innerHTML = "PASS";
|
||||
} else if (this.result == false) {
|
||||
} else if (this.result === false) {
|
||||
this.row[1].className = "fail";
|
||||
this.row[1].innerHTML = "FAIL";
|
||||
} else {
|
||||
// this.row[1].innerHTML = "";
|
||||
this.row[1].innerHTML = this.result;
|
||||
this.row[1].textContent = this.result;
|
||||
}
|
||||
|
||||
// Print the elapsed time, if known
|
||||
if (this.startTime && this.endTime) {
|
||||
this.row[2].innerHTML = (this.endTime - this.startTime) + " ms";
|
||||
this.row[2].textContent = (this.endTime - this.startTime) + " ms";
|
||||
} else {
|
||||
this.row[2].innerHTML = "";
|
||||
}
|
||||
|
@ -143,13 +149,13 @@ var TestArray = {
|
|||
updateSummary() {
|
||||
this.pass = this.fail = this.pending = 0;
|
||||
for (var i = 0; i < this.tests.length; ++i) {
|
||||
if (this.tests[i].result == true) this.pass++;
|
||||
if (this.tests[i].result == false) this.fail++;
|
||||
if (this.tests[i].result === true) this.pass++;
|
||||
if (this.tests[i].result === false) this.fail++;
|
||||
if (this.tests[i].result == null) this.pending++;
|
||||
}
|
||||
this.passSpan.innerHTML = this.pass;
|
||||
this.failSpan.innerHTML = this.fail;
|
||||
this.pendingSpan.innerHTML = this.pending;
|
||||
this.passSpan.textContent = this.pass;
|
||||
this.failSpan.textContent = this.fail;
|
||||
this.pendingSpan.textContent = this.pending;
|
||||
},
|
||||
|
||||
load() {
|
||||
|
@ -182,7 +188,9 @@ var TestArray = {
|
|||
this.updateSummary();
|
||||
var i = this.currTest++;
|
||||
if (i >= this.tests.length) {
|
||||
if (MOCHITEST) { SimpleTest.finish(); }
|
||||
if (MOCHITEST) {
|
||||
SimpleTest.finish();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -195,16 +203,20 @@ var TestArray = {
|
|||
};
|
||||
|
||||
if (window.addEventListener) {
|
||||
window.addEventListener("load", function() { TestArray.load(); } );
|
||||
window.addEventListener("load", function() {
|
||||
TestArray.load();
|
||||
});
|
||||
} else {
|
||||
window.attachEvent("onload", function() { TestArray.load(); } );
|
||||
window.attachEvent("onload", function() {
|
||||
TestArray.load();
|
||||
});
|
||||
}
|
||||
|
||||
function start() {
|
||||
TestArray.run();
|
||||
}
|
||||
|
||||
MOCHITEST = ("SimpleTest" in window);
|
||||
MOCHITEST = "SimpleTest" in window;
|
||||
if (MOCHITEST) {
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SimpleTest.requestLongerTimeout(2);
|
||||
|
|
|
@ -2,7 +2,9 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
tv = {
|
||||
// This file expects utils.js to be included in its scope
|
||||
/* import-globals-from ./util.js */
|
||||
let tv = {
|
||||
raw: util.hex2abv("f3095c4fe5e299477643c2310b44f0aa"),
|
||||
|
||||
// this key had an inappropriate length (18 octets)
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
/* eslint-env worker */
|
||||
|
||||
// This file expects utils.js to be included in its scope
|
||||
/* import-globals-from ./util.js */
|
||||
importScripts("util.js");
|
||||
importScripts("test-vectors.js");
|
||||
|
||||
|
@ -34,6 +38,7 @@ function error(test) {
|
|||
}
|
||||
|
||||
onmessage = function(msg) {
|
||||
// eslint-disable-next-line no-eval
|
||||
var test = eval("(" + msg.data + ")");
|
||||
|
||||
try {
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
TestArray.addTest(
|
||||
"Test for presence of WebCrypto API methods",
|
||||
function() {
|
||||
var that = this;
|
||||
this.complete(
|
||||
exists(window.crypto.subtle) &&
|
||||
exists(window.crypto.subtle.encrypt) &&
|
||||
|
@ -630,11 +629,6 @@ TestArray.addTest(
|
|||
x, tv.aes_ctr_dec.data);
|
||||
}
|
||||
|
||||
function decrypt(x) {
|
||||
return decrypt(x, new Uint8Array(15))
|
||||
.catch(function() { return decrypt(x, new Uint8Array(17)); });
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("raw", tv.aes_ctr_dec.key, "AES-CTR", false, ["decrypt"])
|
||||
.then(doDecrypt)
|
||||
.then(
|
||||
|
@ -1004,7 +998,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "RSASSA-PKCS1-v1_5", hash: "SHA-256" };
|
||||
var use = ["sign", "verify"];
|
||||
|
||||
function doVerify(x) {
|
||||
return crypto.subtle.verify(alg.name, x, tv.rsassa.sig_fail, tv.rsassa.data);
|
||||
|
@ -1103,7 +1096,7 @@ TestArray.addTest(
|
|||
error(that)();
|
||||
}
|
||||
|
||||
Promise.all([p1, p2, p3]).then(complete(that, keys => {
|
||||
return Promise.all([p1, p2, p3]).then(complete(that, keys => {
|
||||
return keys.every(key => {
|
||||
if (key instanceof CryptoKey) {
|
||||
return checkPrototypes(key, "CryptoKey");
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
<script>/* <![CDATA[*/
|
||||
"use strict";
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
TestArray.addTest(
|
||||
"Generate a DH key",
|
||||
|
@ -68,11 +67,7 @@ TestArray.addTest(
|
|||
};
|
||||
|
||||
function doDerive(x) {
|
||||
var alg = {
|
||||
name: "DH",
|
||||
public: x.publicKey,
|
||||
};
|
||||
return crypto.subtle.deriveBits(alg, x.privateKey, 128);
|
||||
return crypto.subtle.deriveBits({ name: "DH", public: x.publicKey }, x.privateKey, 128);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["deriveBits"])
|
||||
|
@ -218,8 +213,7 @@ TestArray.addTest(
|
|||
}
|
||||
|
||||
function doDerive(pubKey) {
|
||||
var alg = {name: "DH", public: pubKey};
|
||||
return crypto.subtle.deriveBits(alg, privKey, 128);
|
||||
return crypto.subtle.deriveBits({name: "DH", public: pubKey}, privKey, 128);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["deriveBits"])
|
||||
|
|
|
@ -62,8 +62,7 @@ TestArray.addTest(
|
|||
|
||||
function doDerive(n) {
|
||||
return function(x) {
|
||||
var alg = { name: "ECDH", public: pair.publicKey };
|
||||
return crypto.subtle.deriveBits(alg, pair.privateKey, n * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pair.publicKey }, pair.privateKey, n * 8);
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -165,8 +164,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveBits(alg, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pubKey }, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
|
@ -191,8 +189,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveBits(alg, privKey, tv.ecdh_p384.secret.byteLength * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pubKey }, privKey, tv.ecdh_p384.secret.byteLength * 8);
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
|
@ -217,8 +214,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveBits(alg, privKey, tv.ecdh_p521.secret.byteLength * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pubKey }, privKey, tv.ecdh_p521.secret.byteLength * 8);
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
|
@ -342,8 +338,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveKey(alg, privKey, algDerived, false, ["sign", "verify"])
|
||||
return crypto.subtle.deriveKey({ name: "ECDH", public: pubKey }, privKey, algDerived, false, ["sign", "verify"])
|
||||
.then(function(x) {
|
||||
if (!hasKeyFields(x)) {
|
||||
throw "Invalid key; missing field(s)";
|
||||
|
@ -406,6 +401,7 @@ TestArray.addTest(
|
|||
if (keys.length) {
|
||||
return nextKey();
|
||||
}
|
||||
return Promise.resolve();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -425,8 +421,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveBits(alg, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pubKey }, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
|
@ -462,7 +457,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||
var tvs = tv.ecdh_p256_negative.raw_bad;
|
||||
|
||||
crypto.subtle.importKey("raw", tv, alg, false, ["deriveBits"])
|
||||
.then(error(that), complete(that));
|
||||
|
@ -475,7 +469,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||
var tvs = tv.ecdh_p256.raw;
|
||||
|
||||
crypto.subtle.importKey("unknown", tv, alg, false, ["deriveBits"])
|
||||
.then(error(that), complete(that));
|
||||
|
@ -488,7 +481,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||
var tvs = tv.ecdh_p256_negative.raw_short;
|
||||
|
||||
crypto.subtle.importKey("raw", tv, alg, false, ["deriveBits"])
|
||||
.then(error(that), complete(that));
|
||||
|
@ -501,7 +493,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||
var tvs = tv.ecdh_p256_negative.raw_long;
|
||||
|
||||
crypto.subtle.importKey("raw", tv, alg, false, ["deriveBits"])
|
||||
.then(error(that), complete(that));
|
||||
|
@ -514,7 +505,6 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var alg = { name: "ECDH", namedCurve: "P-256" };
|
||||
var tvs = tv.ecdh_p256_negative.raw_compressed;
|
||||
|
||||
crypto.subtle.importKey("raw", tv, alg, false, ["deriveBits"])
|
||||
.then(error(that), complete(that));
|
||||
|
@ -533,8 +523,7 @@ TestArray.addTest(
|
|||
function setPriv(x) { privKey = x; }
|
||||
|
||||
function doDerive() {
|
||||
var alg = { name: "ECDH", public: pubKey };
|
||||
return crypto.subtle.deriveBits(alg, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
return crypto.subtle.deriveBits({ name: "ECDH", public: pubKey }, privKey, tv.ecdh_p256.secret.byteLength * 8);
|
||||
}
|
||||
|
||||
Promise.all([
|
||||
|
|
|
@ -135,10 +135,6 @@ TestArray.addTest(
|
|||
var that = this;
|
||||
var alg = { name: "ECDSA", namedCurve: "P-256", hash: "SHA-256" };
|
||||
|
||||
function doVerify(x) {
|
||||
return crypto.subtle.verify(alg, x, tv.ecdsa_verify.sig, tv.ecdsa_verify.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("jwk", tv.ecdsa_bad.pub_jwk, alg, true, ["verify"])
|
||||
.then(error(that), complete(that));
|
||||
}
|
||||
|
|
|
@ -146,23 +146,27 @@ TestArray.addTest(
|
|||
function() {
|
||||
var that = this;
|
||||
var tests = tv.hkdf.slice();
|
||||
if (!tests.length) {
|
||||
error(that)("No tests found");
|
||||
return;
|
||||
}
|
||||
|
||||
function next() {
|
||||
if (!tests.length) {
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
var test = tests.shift();
|
||||
var {key, data} = test;
|
||||
var {key} = test;
|
||||
|
||||
return crypto.subtle.importKey("raw", key, "HKDF", false, ["deriveBits"])
|
||||
.then(function(key) {
|
||||
.then(function(baseKey) {
|
||||
return crypto.subtle.deriveBits({
|
||||
name: "HKDF",
|
||||
hash: test.prf,
|
||||
salt: test.salt,
|
||||
info: test.info,
|
||||
}, key, test.data.byteLength * 8);
|
||||
}, baseKey, test.data.byteLength * 8);
|
||||
})
|
||||
.then(function(data) {
|
||||
if (!util.memcmp(data, test.data)) {
|
||||
|
|
|
@ -29,23 +29,21 @@ TestArray.addTest(
|
|||
var alg = { name: "hmac", hash: {name: "sHa-256"} };
|
||||
|
||||
function doGenerateAesKey() {
|
||||
var alg = { name: "AES-gcm", length: 192 };
|
||||
return crypto.subtle.generateKey(alg, false, ["encrypt"]);
|
||||
return crypto.subtle.generateKey({ name: "AES-gcm", length: 192 }, false, ["encrypt"]);
|
||||
}
|
||||
|
||||
function doGenerateRsaOaepKey() {
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "rsa-OAEP",
|
||||
hash: "sha-1",
|
||||
modulusLength: 2048,
|
||||
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
||||
};
|
||||
return crypto.subtle.generateKey(alg, false, ["encrypt", "decrypt"]);
|
||||
return crypto.subtle.generateKey(algo, false, ["encrypt", "decrypt"]);
|
||||
}
|
||||
|
||||
function doGenerateRsaSsaPkcs1Key() {
|
||||
var alg = { name: "RSASSA-pkcs1-V1_5", hash: "SHA-1" };
|
||||
return crypto.subtle.importKey("pkcs8", tv.pkcs8, alg, true, ["sign"]);
|
||||
return crypto.subtle.importKey("pkcs8", tv.pkcs8, { name: "RSASSA-pkcs1-V1_5", hash: "SHA-1" }, true, ["sign"]);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["sign"])
|
||||
|
|
|
@ -76,13 +76,13 @@ TestArray.addTest(
|
|||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "PBKDF2",
|
||||
hash: "SHA-1",
|
||||
salt: tv.pbkdf2_sha1.salt,
|
||||
iterations: tv.pbkdf2_sha1.iterations,
|
||||
};
|
||||
return crypto.subtle.deriveBits(alg, x, tv.pbkdf2_sha1.length);
|
||||
return crypto.subtle.deriveBits(algo, x, tv.pbkdf2_sha1.length);
|
||||
}
|
||||
function fail(x) { console.log("failing"); error(that)(x); }
|
||||
|
||||
|
@ -104,13 +104,13 @@ TestArray.addTest(
|
|||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "PBKDF2",
|
||||
hash: "SHA-1",
|
||||
salt: tv.pbkdf2_sha1.salt,
|
||||
iterations: tv.pbkdf2_sha1.iterations,
|
||||
};
|
||||
return crypto.subtle.deriveBits(alg, x, tv.pbkdf2_sha1.length);
|
||||
return crypto.subtle.deriveBits(algo, x, tv.pbkdf2_sha1.length);
|
||||
}
|
||||
function fail(x) { console.log("failing"); error(that)(x); }
|
||||
|
||||
|
@ -133,7 +133,7 @@ TestArray.addTest(
|
|||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "PBKDF2",
|
||||
hash: "SHA-1",
|
||||
salt: tv.pbkdf2_sha1.salt,
|
||||
|
@ -145,17 +145,17 @@ TestArray.addTest(
|
|||
hash: {name: "SHA-1"},
|
||||
};
|
||||
|
||||
return crypto.subtle.deriveKey(alg, x, algDerived, false, ["sign", "verify"])
|
||||
.then(function(x) {
|
||||
if (!hasKeyFields(x)) {
|
||||
return crypto.subtle.deriveKey(algo, x, algDerived, false, ["sign", "verify"])
|
||||
.then(function(y) {
|
||||
if (!hasKeyFields(y)) {
|
||||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
if (x.algorithm.length != 512) {
|
||||
if (y.algorithm.length != 512) {
|
||||
throw "Invalid key; incorrect length";
|
||||
}
|
||||
|
||||
return x;
|
||||
return y;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -217,13 +217,13 @@ TestArray.addTest(
|
|||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "PBKDF2",
|
||||
hash: "SHA-256",
|
||||
salt: tv.pbkdf2_sha256.salt,
|
||||
iterations: tv.pbkdf2_sha256.iterations,
|
||||
};
|
||||
return crypto.subtle.deriveBits(alg, x, tv.pbkdf2_sha256.length);
|
||||
return crypto.subtle.deriveBits(algo, x, tv.pbkdf2_sha256.length);
|
||||
}
|
||||
function fail(x) { console.log("failing"); error(that)(x); }
|
||||
|
||||
|
@ -246,13 +246,13 @@ TestArray.addTest(
|
|||
throw "Invalid key; missing field(s)";
|
||||
}
|
||||
|
||||
var alg = {
|
||||
var algo = {
|
||||
name: "PBKDF2",
|
||||
hash: "SHA-256",
|
||||
salt: tv.pbkdf2_sha256_no_pwd.salt,
|
||||
iterations: tv.pbkdf2_sha256_no_pwd.iterations,
|
||||
};
|
||||
return crypto.subtle.deriveBits(alg, x, tv.pbkdf2_sha256_no_pwd.length);
|
||||
return crypto.subtle.deriveBits(algo, x, tv.pbkdf2_sha256_no_pwd.length);
|
||||
}
|
||||
function fail(x) { console.log("failing"); error(that)(x); }
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ TestArray.addTest(
|
|||
var privKey, pubKey;
|
||||
var alg = {name: "RSA-OAEP", hash: "SHA-1"};
|
||||
|
||||
var privKey, pubKey;
|
||||
function setPriv(x) { privKey = x; }
|
||||
function setPub(x) { pubKey = x; }
|
||||
function doEncrypt() {
|
||||
|
@ -112,7 +111,7 @@ TestArray.addTest(
|
|||
"RSA-OAEP input data length checks (2048-bit key)",
|
||||
function() {
|
||||
var that = this;
|
||||
var privKey, pubKey;
|
||||
var pubKey;
|
||||
var alg = {
|
||||
name: "RSA-OAEP",
|
||||
hash: "SHA-1",
|
||||
|
@ -120,8 +119,7 @@ TestArray.addTest(
|
|||
publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
|
||||
};
|
||||
|
||||
var privKey, pubKey;
|
||||
function setKey(x) { pubKey = x.publicKey; privKey = x.privateKey; }
|
||||
function setKey(x) { pubKey = x.publicKey; }
|
||||
function doEncrypt(n) {
|
||||
console.log("entered encrypt(" + n + ")");
|
||||
return function() {
|
||||
|
|
|
@ -58,12 +58,10 @@ TestArray.addTest(
|
|||
var data = crypto.getRandomValues(new Uint8Array(128));
|
||||
function setKey(x) { pubKey = x.publicKey; privKey = x.privateKey; }
|
||||
function doSign() {
|
||||
var alg = {name: "RSA-PSS", saltLength: 32};
|
||||
return crypto.subtle.sign(alg, privKey, data);
|
||||
return crypto.subtle.sign({name: "RSA-PSS", saltLength: 32}, privKey, data);
|
||||
}
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: 32};
|
||||
return crypto.subtle.verify(alg, pubKey, x, data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: 32}, pubKey, x, data);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["sign", "verify"])
|
||||
|
@ -83,8 +81,7 @@ TestArray.addTest(
|
|||
var vec = tv.rsapss;
|
||||
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: vec.saltLength};
|
||||
return crypto.subtle.verify(alg, x, vec.sig, vec.data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: vec.saltLength}, x, vec.sig, vec.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("spki", vec.spki, alg, false, ["verify"])
|
||||
|
@ -102,17 +99,17 @@ TestArray.addTest(
|
|||
var vec = tv.rsapss;
|
||||
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: vec.saltLength};
|
||||
var algo = {name: "RSA-PSS", saltLength: vec.saltLength};
|
||||
var clone1 = new Uint8Array(vec.data);
|
||||
var clone2 = new Uint8Array(vec.data);
|
||||
clone1[clone1.byteLength - 1] ^= 1;
|
||||
clone2[0] ^= 1;
|
||||
|
||||
return Promise.all([
|
||||
crypto.subtle.verify(alg, x, vec.sig, clone1),
|
||||
crypto.subtle.verify(alg, x, vec.sig, clone2),
|
||||
crypto.subtle.verify(alg, x, vec.sig, vec.data.slice(1)),
|
||||
crypto.subtle.verify(alg, x, vec.sig, vec.data.slice(0, vec.data.byteLength - 1)),
|
||||
crypto.subtle.verify(algo, x, vec.sig, clone1),
|
||||
crypto.subtle.verify(algo, x, vec.sig, clone2),
|
||||
crypto.subtle.verify(algo, x, vec.sig, vec.data.slice(1)),
|
||||
crypto.subtle.verify(algo, x, vec.sig, vec.data.slice(0, vec.data.byteLength - 1)),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -131,8 +128,7 @@ TestArray.addTest(
|
|||
var alg = {name: "RSA-PSS", hash: "SHA-1"};
|
||||
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: tv.rsapss.saltLength};
|
||||
return crypto.subtle.verify(alg, x, tv.rsapss.sig, tv.rsapss.data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: tv.rsapss.saltLength}, x, tv.rsapss.sig, tv.rsapss.data);
|
||||
}
|
||||
|
||||
crypto.subtle.importKey("jwk", tv.rsapss.jwk_pub, alg, false, ["verify"])
|
||||
|
@ -172,12 +168,10 @@ TestArray.addTest(
|
|||
var privKey, pubKey;
|
||||
function setKeys([pub, priv]) { pubKey = pub; privKey = priv; }
|
||||
function doSign() {
|
||||
var alg = {name: "RSA-PSS", saltLength: tv.rsapss.saltLength};
|
||||
return crypto.subtle.sign(alg, privKey, tv.rsapss.data);
|
||||
return crypto.subtle.sign({name: "RSA-PSS", saltLength: tv.rsapss.saltLength}, privKey, tv.rsapss.data);
|
||||
}
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: tv.rsapss.saltLength};
|
||||
return crypto.subtle.verify(alg, pubKey, x, tv.rsapss.data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: tv.rsapss.saltLength}, pubKey, x, tv.rsapss.data);
|
||||
}
|
||||
|
||||
var spki =
|
||||
|
@ -203,12 +197,10 @@ TestArray.addTest(
|
|||
var privKey, pubKey;
|
||||
function setKeys([pub, priv]) { pubKey = pub; privKey = priv; }
|
||||
function doSign() {
|
||||
var alg = {name: "RSA-PSS", saltLength: tv.rsapss.saltLength};
|
||||
return crypto.subtle.sign(alg, privKey, tv.rsapss.data);
|
||||
return crypto.subtle.sign({name: "RSA-PSS", saltLength: tv.rsapss.saltLength}, privKey, tv.rsapss.data);
|
||||
}
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: tv.rsapss.saltLength};
|
||||
return crypto.subtle.verify(alg, pubKey, x, tv.rsapss.data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: tv.rsapss.saltLength}, pubKey, x, tv.rsapss.data);
|
||||
}
|
||||
|
||||
var spki =
|
||||
|
@ -341,16 +333,14 @@ TestArray.addTest(
|
|||
function setKey(x) { pubKey = x.publicKey; privKey = x.privateKey; }
|
||||
|
||||
function doSignTwice() {
|
||||
var alg = {name: "RSA-PSS", saltLength: 0};
|
||||
return Promise.all([
|
||||
crypto.subtle.sign(alg, privKey, data),
|
||||
crypto.subtle.sign(alg, privKey, data),
|
||||
crypto.subtle.sign({name: "RSA-PSS", saltLength: 0}, privKey, data),
|
||||
crypto.subtle.sign({name: "RSA-PSS", saltLength: 0}, privKey, data),
|
||||
]);
|
||||
}
|
||||
|
||||
function doVerify(x) {
|
||||
var alg = {name: "RSA-PSS", saltLength: 0};
|
||||
return crypto.subtle.verify(alg, pubKey, x, data);
|
||||
return crypto.subtle.verify({name: "RSA-PSS", saltLength: 0}, pubKey, x, data);
|
||||
}
|
||||
|
||||
crypto.subtle.generateKey(alg, false, ["sign", "verify"])
|
||||
|
|
|
@ -42,8 +42,7 @@ TestArray.addTest(
|
|||
crypto.subtle.generateKey(alg, false, ["encrypt", "decrypt"]).then(key => {
|
||||
// Wait for ciphertext, check and decrypt.
|
||||
worker.addEventListener("message", ({data: ciphertext}) => {
|
||||
var alg = { name: "AES-GCM", iv: nonce };
|
||||
crypto.subtle.decrypt(alg, key, ciphertext)
|
||||
crypto.subtle.decrypt({ name: "AES-GCM", iv: nonce }, key, ciphertext)
|
||||
.then(memcmp_complete(that, data), error(that));
|
||||
});
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ TestArray.addTest(
|
|||
iv: tv.key_wrap_known_answer.wrapping_iv,
|
||||
tagLength: 128,
|
||||
};
|
||||
var key, wrappingKey;
|
||||
var wrappingKey;
|
||||
|
||||
function doUnwrap(k) {
|
||||
wrappingKey = k;
|
||||
|
|
|
@ -39,9 +39,9 @@
|
|||
frame.remove();
|
||||
|
||||
// Load the test app again to retrieve stored keys.
|
||||
createMozBrowserFrame((frame, result) => {
|
||||
is(result, "ok", "retrieved keys successfully");
|
||||
frame.remove();
|
||||
createMozBrowserFrame((recFrame, recResult) => {
|
||||
is(recResult, "ok", "retrieved keys successfully");
|
||||
recFrame.remove();
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -105,7 +105,7 @@ function shallowArrayEquals(x, y) {
|
|||
return false;
|
||||
}
|
||||
|
||||
for (i in x) {
|
||||
for (let i in x) {
|
||||
if (x[i] != y[i]) {
|
||||
return false;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче