Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(487)

Side by Side Diff: third_party/WebKit/LayoutTests/external/wpt/WebCryptoAPI/derive_bits_keys/pbkdf2.js

Issue 2838603002: Added [SecureContext] to the subtle attribute (Closed)
Patch Set: Magic test starts doing differnt things out of the blue. Need to handle this properly. Avada Kedavr… Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 1 function run_test(testPasswordSize, testSaltSize) {
2 function run_test() {
3 // May want to test prefixed implementations. 2 // May want to test prefixed implementations.
4 var subtle = self.crypto.subtle; 3 var subtle = self.crypto.subtle;
5 4
6 // pbkdf2_vectors sets up test data with the correct derivations for each 5 // pbkdf2_vectors sets up test data with the correct derivations for each
7 // test case. 6 // test case.
8 var testData = getTestData(); 7 var testData = getTestData();
9 var passwords = testData.passwords; 8 var passwords = testData.passwords;
10 var salts = testData.salts; 9 var salts = testData.salts;
11 var derivations = testData.derivations; 10 var derivations = testData.derivations;
12 11
13 // What kinds of keys can be created with deriveKey? The following: 12 // What kinds of keys can be created with deriveKey? The following:
14 var derivedKeyTypes = testData.derivedKeyTypes; 13 var derivedKeyTypes = testData.derivedKeyTypes;
15 14
16 setUpBaseKeys(passwords) 15 setUpBaseKeys(passwords)
17 .then(function(allKeys) { 16 .then(function(allKeys) {
18 // We get several kinds of base keys. Normal ones that can be used for 17 // We get several kinds of base keys. Normal ones that can be used for
19 // derivation operations, ones that lack the deriveBits usage, ones 18 // derivation operations, ones that lack the deriveBits usage, ones
20 // that lack the deriveKeys usage, and one key that is for the wrong 19 // that lack the deriveKeys usage, and one key that is for the wrong
21 // algorithm (not PBKDF2 in this case). 20 // algorithm (not PBKDF2 in this case).
22 var baseKeys = allKeys.baseKeys; 21 var baseKeys = allKeys.baseKeys;
23 var noBits = allKeys.noBits; 22 var noBits = allKeys.noBits;
24 var noKey = allKeys.noKey; 23 var noKey = allKeys.noKey;
25 var wrongKey = allKeys.wrongKey; 24 var wrongKey = allKeys.wrongKey;
26 25
27 // Test each combination of password size, salt size, hash function, 26 // Test each combination of password size, salt size, hash function,
28 // and number of iterations. The derivations object is structured in 27 // and number of iterations. The derivations object is structured in
29 // that way, so navigate it to run tests and compare with correct result s. 28 // that way, so navigate it to run tests and compare with correct result s.
30 Object.keys(derivations).forEach(function(passwordSize) { 29 Object.keys(derivations).forEach(function(passwordSize) {
30 if (typeof testPasswordSize != 'undefined' && testPasswordSize != pa sswordSize) return;
31 Object.keys(derivations[passwordSize]).forEach(function(saltSize) { 31 Object.keys(derivations[passwordSize]).forEach(function(saltSize) {
32 if (typeof testSaltSize != 'undefined' && testSaltSize != saltSi ze) return;
32 Object.keys(derivations[passwordSize][saltSize]).forEach(functio n(hashName) { 33 Object.keys(derivations[passwordSize][saltSize]).forEach(functio n(hashName) {
33 Object.keys(derivations[passwordSize][saltSize][hashName]).f orEach(function(iterations) { 34 Object.keys(derivations[passwordSize][saltSize][hashName]).f orEach(function(iterations) {
34 var testName = passwordSize + " password, " + saltSize + " salt, " + hashName + ", with " + iterations + " iterations"; 35 var testName = passwordSize + " password, " + saltSize + " salt, " + hashName + ", with " + iterations + " iterations";
35 36
36 // Check for correct deriveBits result 37 // Check for correct deriveBits result
37 promise_test(function(test) { 38 promise_test(function(test) {
38 return subtle.deriveBits({name: "PBKDF2", salt: salt s[saltSize], hash: hashName, iterations: parseInt(iterations)}, baseKeys[passwor dSize], 256) 39 return subtle.deriveBits({name: "PBKDF2", salt: salt s[saltSize], hash: hashName, iterations: parseInt(iterations)}, baseKeys[passwor dSize], 256)
39 .then(function(derivation) { 40 .then(function(derivation) {
40 assert_true(equalBuffers(derivation, derivations [passwordSize][saltSize][hashName][iterations]), "Derived correct key"); 41 assert_true(equalBuffers(derivation, derivations [passwordSize][saltSize][hashName][iterations]), "Derived correct key");
41 }, function(err) { 42 }, function(err) {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 for (var i=0; i<a.byteLength; i++) { 302 for (var i=0; i<a.byteLength; i++) {
302 if (aBytes[i] !== bBytes[i]) { 303 if (aBytes[i] !== bBytes[i]) {
303 return false; 304 return false;
304 } 305 }
305 } 306 }
306 307
307 return true; 308 return true;
308 } 309 }
309 310
310 } 311 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698