OLD | NEW |
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 AES keys"); | 12 description("Tests structured cloning of AES keys"); |
13 | 13 |
14 jsTestIsAsync = true; | 14 jsTestIsAsync = true; |
15 | 15 |
16 // Tests the 32 permutations of keys generated by: | 16 // Tests the 32 permutations of keys generated by: |
17 // kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossible
KeyData | 17 // kPossibleAlgorithms x kPossibleExtractable x kPossibleKeyUsages x kPossible
KeyData |
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 k128BitData = "30112233445566778899aabbccddeeff" |
22 var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0
e0f"; | 22 var k256BitData = "00112233445546778899aabbccddeeff000102030405060708090a0b0c0d0
e0f"; |
23 | 23 |
24 var kPossibleAlgorithms = ['AES-CBC', 'AES-GCM']; | 24 var kPossibleAlgorithms = ['AES-CBC', 'AES-GCM']; |
25 var kPossibleExtractable = [true, false]; | 25 var kPossibleExtractable = [true, false]; |
26 var kPossibleKeyUsages = [[], ['encrypt'], ['decrypt', 'wrapKey'], ['encrypt', '
wrapKey', 'unwrapKey']]; | 26 var kPossibleKeyUsages = [['encrypt'], ['decrypt', 'wrapKey'], ['encrypt', 'wrap
Key', 'unwrapKey']]; |
27 var kPossibleKeyData = [k128BitData, k256BitData]; | 27 var kPossibleKeyData = [k128BitData, k256BitData]; |
28 | 28 |
29 function runTest(algorithmName, extractable, keyUsages, keyData) | 29 function runTest(algorithmName, extractable, keyUsages, keyData) |
30 { | 30 { |
31 var importData = hexStringToUint8Array(keyData); | 31 var importData = hexStringToUint8Array(keyData); |
32 var importAlgorithm = { name: algorithmName }; | 32 var importAlgorithm = { name: algorithmName }; |
33 | 33 |
34 var results = {}; | 34 var results = {}; |
35 | 35 |
36 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab
le, keyUsages).then(function(importedKey) { | 36 return crypto.subtle.importKey('raw', importData, importAlgorithm, extractab
le, keyUsages).then(function(importedKey) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 }); | 82 }); |
83 }); | 83 }); |
84 }); | 84 }); |
85 | 85 |
86 lastPromise.then(finishJSTest, failAndFinishJSTest); | 86 lastPromise.then(finishJSTest, failAndFinishJSTest); |
87 | 87 |
88 </script> | 88 </script> |
89 | 89 |
90 </body> | 90 </body> |
91 </html> | 91 </html> |
OLD | NEW |