Add more tests for SubtleCrypto::importKey and SubtleCrypto::exportKey
[WebKit-https.git] / LayoutTests / crypto / subtle / hmac-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 HMAC key with SHA-1 and then export it in raw format");
13
14 jsTestIsAsync = true;
15
16 var rawKey = hexStringToUint8Array("192ff1e96a1399322db620760a738793ab6dfaf26bd2b3889bd81fc9d82ea25d11bb1b4763c0a9259512298e162dab2e6f505c9fc376fda1179a2a4055dd67f6");
17 var extractable = true;
18
19 debug("Importing a key...");
20 crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).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>