Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
[WebKit-https.git] / LayoutTests / crypto / subtle / aes-import-raw-key-export-raw-key.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.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("Test importing a raw AES-CBC key with legnth 128 and then export it in raw format");
13
14 jsTestIsAsync = true;
15
16 var rawKey = hexStringToUint8Array("909152300357f94c2f64321c2d395370");
17 var extractable = true;
18
19 debug("Importing a key...");
20 crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(cryptoKey) {
21     debug("Exporting a key...");
22     return crypto.subtle.exportKey("raw", cryptoKey);
23 }).then(function(result) {
24     exportedRawKey = new Uint8Array(result);
25
26     shouldBe("exportedRawKey", "rawKey");
27
28     finishJSTest();
29 });
30
31 </script>
32
33 <script src="../../resources/js-test-post.js"></script>
34 </body>
35 </html>