blob: e6fa930e2913a409f62a7ed2c38e5f0d8ccad58c [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test importing a raw HMAC key with SHA-1 and then export it in JWK format");
jsTestIsAsync = true;
var rawKey = hexStringToUint8Array("192ff1e96a1399322db620760a738793ab6dfaf26bd2b3889bd81fc9d82ea25d11bb1b4763c0a9259512298e162dab2e6f505c9fc376fda1179a2a4055dd67f6");
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("raw", rawKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(cryptoKey) {
debug("Exporting a key...");
return crypto.subtle.exportKey("jwk", cryptoKey);
}).then(function(result) {
exportedJwkKey = result;
shouldBe("Base64URL.parse(exportedJwkKey.k)", "rawKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>