Update web-platform-tests to revision a46616a5b18e83587ddbbed756c7b96cbb4b015d

This commit is contained in:
Josh Matthews 2017-06-19 19:07:14 -04:00 committed by Ms2ger
parent 3f07cfec7c
commit 578498ba24
4001 changed files with 159517 additions and 30260 deletions

View file

@ -1,5 +1,4 @@
function run_test() {
function run_test(testPasswordSize, testSaltSize) {
// May want to test prefixed implementations.
var subtle = self.crypto.subtle;
@ -28,7 +27,9 @@ function run_test() {
// and number of iterations. The derivations object is structured in
// that way, so navigate it to run tests and compare with correct results.
Object.keys(derivations).forEach(function(passwordSize) {
if (typeof testPasswordSize != 'undefined' && testPasswordSize != passwordSize) return;
Object.keys(derivations[passwordSize]).forEach(function(saltSize) {
if (typeof testSaltSize != 'undefined' && testSaltSize != saltSize) return;
Object.keys(derivations[passwordSize][saltSize]).forEach(function(hashName) {
Object.keys(derivations[passwordSize][saltSize][hashName]).forEach(function(iterations) {
var testName = passwordSize + " password, " + saltSize + " salt, " + hashName + ", with " + iterations + " iterations";

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"empty" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"long" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"empty", //password size
"short" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"long", //password size
"empty" //salt size
);
</script>

View file

@ -15,5 +15,8 @@
<div id="log"></div>
<script>
run_test();
run_test(
"long", //password size
"long" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"long", //password size
"short" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"empty" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"long" //salt size
);
</script>

View file

@ -0,0 +1,22 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: deriveBits() and deriveKey() Using PBKDF2</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveBits">
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#SubtleCrypto-method-deriveKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="pbkdf2_vectors.js"></script>
<script src="pbkdf2.js"></script>
<h1>deriveBits and deriveKey Tests for PBKDF2</h1>
<div id="log"></div>
<script>
run_test(
"short", //password size
"short" //salt size
);
</script>

View file

@ -1,5 +1,5 @@
function run_test(algorithmNames) {
function run_test(algorithmNames, slowTest) {
var subtle = crypto.subtle; // Change to test prefixed implementations
setup({explicit_timeout: true});
@ -74,7 +74,7 @@ function run_test(algorithmNames) {
// Test all valid sets of parameters for successful
// key generation.
testVectors.forEach(function(vector) {
allNameVariants(vector.name).forEach(function(name) {
allNameVariants(vector.name, slowTest).forEach(function(name) {
allAlgorithmSpecifiersFor(name).forEach(function(algorithm) {
allValidUsages(vector.usages, false, vector.mandatoryUsages).forEach(function(usages) {
[false, true].forEach(function(extractable) {

View file

@ -1,23 +0,0 @@
<!DOCTYPE html>
<meta charset=utf-8>
<meta name="timeout" content="long">
<title>WebCryptoAPI: generateKey() Successful Calls</title>
<link rel="author" title="Charles Engelke" href="mailto:w3c@engelke.com">
<link rel="help" href="https://www.w3.org/TR/WebCryptoAPI/#dfn-SubtleCrypto-method-generateKey">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/WebCryptoAPI/util/helpers.js"></script>
<script src="successes.js"></script>
<h1>generateKey Tests for Good Parameters</h1>
<p>
<strong>Warning!</strong> RSA key generation is intrinsically
very slow, so the related tests can take up to
several minutes to complete, depending on browser!
</p>
<div id="log"></div>
<script>
run_test(["RSA-OAEP"]);
</script>

View file

@ -19,5 +19,5 @@
<div id="log"></div>
<script>
run_test();
run_test(["RSA-OAEP"], true);
</script>

View file

@ -0,0 +1,45 @@
<!doctype html>
<html>
<head>
<meta charset=utf-8>
<title>IDL check of WebCrypto</title>
<link rel="help" href="https://w3c.github.io/webcrypto/Overview.html#crypto-interface">
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/WebIDLParser.js></script>
<script src=/resources/idlharness.js></script>
</head>
<body>
<h1 class="instructions">Description</h1>
<p class="instructions">This test verifies that the implementations of the WebCrypto API match with its WebIDL definition.</p>
<div id='log'></div>
<script>
var file_input;
setup(function() {
var idl_array = new IdlArray();
var request = new XMLHttpRequest();
request.open("GET", "WebCryptoAPI.idl");
request.send();
request.onload = function() {
var idls = request.responseText;
idl_array.add_untested_idls("[PrimaryGlobal] interface Window { };");
idl_array.add_untested_idls("interface ArrayBuffer {};");
idl_array.add_untested_idls("interface ArrayBufferView {};");
idl_array.add_idls(idls);
idl_array.add_objects({"Crypto":["crypto"], "SubtleCrypto":["crypto.subtle"]});
idl_array.test();
done();
};
}, {explicit_done: true});
</script>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
assert_true(typeof crypto.subtle === 'undefined');
t.done();
}, "Non-secure context window does not have access to crypto.subtle");
async_test(function(t) {
var w = new Worker('../util/worker-report-crypto-subtle-presence.js');
w.onmessage = t.step_func(function (e) {
if (e.data.msg_type == 'subtle_crypto_found') {
assert_equals(e.data.msg_value, false);
t.done();
}
});
}, "Non-secure context worker does not have access to crypto.subtle");
</script>
</body>
</html>

View file

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<script>
async_test(function(t) {
assert_true(typeof crypto.subtle !== 'undefined');
t.done();
}, "Secure context window has access to crypto.subtle");
async_test(function(t) {
var w = new Worker('../util/worker-report-crypto-subtle-presence.js');
w.onmessage = t.step_func(function (e) {
if (e.data.msg_type == 'subtle_crypto_found') {
assert_equals(e.data.msg_value, true);
t.done();
}
});
}, "Secure context worker has access to crypto.subtle");
</script>
</body>
</html>

View file

@ -219,12 +219,13 @@ function allValidUsages(validUsages, emptyIsValid, mandatoryUsages) {
// Algorithm name specifiers are case-insensitive. Generate several
// case variations of a given name.
function allNameVariants(name) {
function allNameVariants(name, slowTest) {
var upCaseName = name.toUpperCase();
var lowCaseName = name.toLowerCase();
var mixedCaseName = upCaseName.substring(0, 1) + lowCaseName.substring(1);
// for slow tests effectively cut the amount of work in third by only
// returning one variation
if (slowTest) return [mixedCaseName];
return [upCaseName, lowCaseName, mixedCaseName];
}

View file

@ -0,0 +1,3 @@
subtle_crypto_found = true;
if (typeof crypto.subtle === 'undefined') subtle_crypto_found = false;
postMessage({ msg_type: 'subtle_crypto_found', msg_value: subtle_crypto_found });