blob: acfea2e1547150c39313ec793b463a7b322e6102 [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 JWK HMAC key with SHA-1 and then export it in raw format");
jsTestIsAsync = true;
var jwkKey = {
kty: "oct",
k: "vgJ5AXWT3Fm2w_zZCRF4UVwo53rIhwqLm6b9Tq4m1c53dr94eqPlxt99yb9RCjCFDa2C56K448xe4V964xFucg",
alg: "HS1",
key_ops: ["sign", "verify"],
ext: true,
};
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, {name: "hmac", hash: "sha-1"}, extractable, ["sign", "verify"]).then(function(cryptoKey) {
debug("Exporting a key...");
return crypto.subtle.exportKey("raw", cryptoKey);
}).then(function(result) {
exportedRawKey = new Uint8Array(result);
shouldBe("Base64URL.stringify(exportedRawKey)", "jwkKey.k");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>