blob: e6fa930e2913a409f62a7ed2c38e5f0d8ccad58c [file] [log] [blame]
jiewen_tan@apple.com42806462016-11-16 20:18:45 +00001<!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>
12description("Test importing a raw HMAC key with SHA-1 and then export it in JWK format");
13
14jsTestIsAsync = true;
15
16var rawKey = hexStringToUint8Array("192ff1e96a1399322db620760a738793ab6dfaf26bd2b3889bd81fc9d82ea25d11bb1b4763c0a9259512298e162dab2e6f505c9fc376fda1179a2a4055dd67f6");
17var extractable = true;
18
19debug("Importing a key...");
20crypto.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("jwk", cryptoKey);
23}).then(function(result) {
24 exportedJwkKey = result;
25
26 shouldBe("Base64URL.parse(exportedJwkKey.k)", "rawKey");
27
28 finishJSTest();
29});
30
31</script>
32
33<script src="../../resources/js-test-post.js"></script>
34</body>
35</html>