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

Side by Side Diff: LayoutTests/crypto/clone-aesKey.html

Issue 195543002: [webcrypto] Implement structured clone of keys (blink-side). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update serialized-script-value.html for version bump Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/crypto/clone-aesKey-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
(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 AES keys");
13
14 jsTestIsAsync = true;
15
16 // Tests the 48 permutations of keys generated by:
17 // kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossible KeyData
18 //
19 // For practical reasons these tests are not exhaustive.
20
21 var k128BitData = "30112233445566778899aabbccddeeff"
22 var k192BitData = "800102030405060708090a0b0c0d0e0f1011121314151617";
23 var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0 e0f";
24
25 var kPossibleAlgorithms = ['AES-CBC', 'AES-GCM'];
26 var kPossibleExtractable = [true, false];
27 var kPossibleKeyUsages = [[], ['encrypt'], ['decrypt', 'wrapKey'], ['encrypt', ' wrapKey', 'unwrapKey']];
28 var kPossibleKeyData = [k128BitData, k192BitData, k256BitData];
29
30 function runTest(algorithmName, extractable, keyUsages, keyData)
31 {
32 var importData = hexStringToUint8Array(keyData);
33 var importAlgorithm = { name: algorithmName };
34
35 var results = {};
36
37 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab le, keyUsages).then(function(importedKey) {
38 results.importedKey = importedKey;
39 importedKey.extraProperty = 'hi';
40 return cloneKey(importedKey);
41 }).then(function(clonedKey) {
42 results.clonedKey = clonedKey;
43 if (extractable)
44 return crypto.subtle.exportKey('raw', clonedKey);
45 return null;
46 }).then(function(clonedKeyData) {
47 importedKey = results.importedKey;
48 clonedKey = results.clonedKey;
49
50 shouldEvaluateAs("importedKey.extraProperty", "hi");
51 shouldEvaluateAs("importedKey.type", "secret");
52 shouldEvaluateAs("importedKey.extractable", extractable);
53 shouldEvaluateAs("importedKey.algorithm.name", algorithmName);
54 shouldEvaluateAs("importedKey.algorithm.length", importData.length * 8);
55 shouldEvaluateAs("importedKey.usages.join(',')", keyUsages.join(","));
56
57 shouldBeTrue("importedKey != clonedKey");
58
59 shouldBeUndefined("clonedKey.extraProperty");
60 shouldEvaluateAs("clonedKey.type", "secret");
61 shouldEvaluateAs("clonedKey.extractable", extractable);
62 shouldEvaluateAs("clonedKey.algorithm.name", algorithmName);
63 shouldEvaluateAs("clonedKey.algorithm.length", importData.length * 8);
64 shouldEvaluateAs("clonedKey.usages.join(',')", keyUsages.join(","));
65
66 logSerializedKey(importedKey);
67
68 if (extractable)
69 bytesShouldMatchHexString("Cloned key exported data", keyData, clone dKeyData);
70
71 debug("");
72 });
73 }
74
75 var lastPromise = Promise.resolve(null);
76
77 kPossibleAlgorithms.forEach(function(algorithmName) {
78 kPossibleExtractable.forEach(function(extractable) {
79 kPossibleKeyUsages.forEach(function(keyUsages) {
80 kPossibleKeyData.forEach(function(keyData) {
81 lastPromise = lastPromise.then(runTest.bind(null, algorithmName, extractable, keyUsages, keyData));
82 });
83 });
84 });
85 });
86
87 lastPromise.then(finishJSTest, failAndFinishJSTest);
88
89 </script>
90
91 </body>
92 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/crypto/clone-aesKey-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698