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

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

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

Powered by Google App Engine
This is Rietveld 408576698