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

Side by Side Diff: LayoutTests/crypto/subtle/clone-pbkdf2Key.html

Issue 820523003: [webcrypto] Implement PBKDF2 (blink-side) (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: nit Created 5 years, 11 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
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/crypto/subtle/clone-pbkdf2Key-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
11 <script> 11 <script>
12 description("Tests structured cloning of HKDF keys"); 12 description("Tests structured cloning of PBKDF2 keys");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 // Tests the 18 permutations of keys generated by: 16 // Tests the 27 permutations of keys generated by:
17 // kPossibleHashAlgorithms x kPossibleKeyUsages x kPossibleKeyData 17 // kPossibleHashAlgorithms x kPossibleKeyUsages x kPossibleKeyData
18 // 18 //
19 // For practical reasons these tests are not exhaustive. 19 // For practical reasons these tests are not exhaustive.
20 20
21 var k128BitData = "30112233445566778899aabbccddeeff" 21 var k1ByteData = "30"
22 var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0 e0f"; 22 var k8ByteData = "0011223344554677";
23 var k11ByteData = "00112233445546778899aa";
23 24
24 var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512']; 25 var kPossibleHashAlgorithms = ['SHA-1', 'SHA-256', 'SHA-512'];
25 var kPossibleKeyUsages = [['deriveBits'], ['deriveKey'], ['deriveKey', 'deriveBi ts']]; 26 var kPossibleKeyUsages = [['deriveBits'], ['deriveKey'], ['deriveKey', 'deriveBi ts']];
26 var kPossibleKeyData = [ 27 var kPossibleKeyData = [
27 k128BitData, 28 k1ByteData,
28 k256BitData 29 k8ByteData,
30 k11ByteData
29 ]; 31 ];
30 32
31 function runTest(hashName, keyUsages, keyData) 33 function runTest(hashName, keyUsages, keyData)
32 { 34 {
33 var importData = hexStringToUint8Array(keyData); 35 var importData = hexStringToUint8Array(keyData);
34 var importAlgorithm = { name: 'HKDF', hash: {name: hashName } }; 36 var importAlgorithm = { name: 'PBKDF2', hash: {name: hashName } };
37 var extractable = false;
35 38
36 var results = {}; 39 var results = {};
37 40
38 var extractable = false;
39 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab le, keyUsages).then(function(importedKey) { 41 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab le, keyUsages).then(function(importedKey) {
40 results.importedKey = importedKey; 42 results.importedKey = importedKey;
41 importedKey.extraProperty = 'hi'; 43 importedKey.extraProperty = 'hi';
42 return cloneKey(importedKey); 44 return cloneKey(importedKey);
43 }).then(function(result) { 45 }).then(function(result) {
44 results.clonedKey = result; 46 results.clonedKey = result;
45
46 importedKey = results.importedKey; 47 importedKey = results.importedKey;
47 clonedKey = results.clonedKey; 48 clonedKey = results.clonedKey;
48 49
49 shouldEvaluateAs("importedKey.extraProperty", "hi"); 50 shouldEvaluateAs("importedKey.extraProperty", "hi");
50 shouldEvaluateAs("importedKey.type", "secret"); 51 shouldEvaluateAs("importedKey.type", "secret");
51 shouldEvaluateAs("importedKey.extractable", extractable); 52 shouldEvaluateAs("importedKey.extractable", extractable);
52 shouldEvaluateAs("importedKey.algorithm.name", "HKDF"); 53 shouldEvaluateAs("importedKey.algorithm.name", "PBKDF2");
53 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(",")); 54 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
54 55
55 shouldNotBe("importedKey", "clonedKey"); 56 shouldNotBe("importedKey", "clonedKey");
56 57
57 shouldBeUndefined("clonedKey.extraProperty"); 58 shouldBeUndefined("clonedKey.extraProperty");
58 shouldEvaluateAs("clonedKey.type", "secret"); 59 shouldEvaluateAs("clonedKey.type", "secret");
59 shouldEvaluateAs("clonedKey.extractable", extractable); 60 shouldEvaluateAs("clonedKey.extractable", extractable);
60 shouldEvaluateAs("clonedKey.algorithm.name", "HKDF"); 61 shouldEvaluateAs("clonedKey.algorithm.name", "PBKDF2");
61 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(",")); 62 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
62 63
63 logSerializedKey(importedKey); 64 logSerializedKey(importedKey);
64 65
65 debug(""); 66 debug("");
66 }); 67 });
67 } 68 }
68 69
69 var lastPromise = Promise.resolve(null); 70 var lastPromise = Promise.resolve(null);
70 71
71 kPossibleHashAlgorithms.forEach(function(hashName) { 72 kPossibleHashAlgorithms.forEach(function(hashName) {
72 kPossibleKeyUsages.forEach(function(keyUsages) { 73 kPossibleKeyUsages.forEach(function(keyUsages) {
73 kPossibleKeyData.forEach(function(keyData) { 74 kPossibleKeyData.forEach(function(keyData) {
74 lastPromise = lastPromise.then(runTest.bind(null, hashName, keyUsage s, keyData)); 75 lastPromise = lastPromise.then(runTest.bind(null, hashName, keyUsage s, keyData));
75 }); 76 });
76 }); 77 });
77 }); 78 });
78 79
79 lastPromise.then(finishJSTest, failAndFinishJSTest); 80 lastPromise.then(finishJSTest, failAndFinishJSTest);
80 81
81 </script> 82 </script>
82 83
83 </body> 84 </body>
84 </html> 85 </html>
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | LayoutTests/crypto/subtle/clone-pbkdf2Key-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698