blob: 7b87c1e94d0cf3bcb2cee83c65c90f0d7e5cc2c2 [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 signing with HMAC SHA-256 using an imported key");
jsTestIsAsync = true;
var extractable = false;
var text = asciiToUint8Array("Hello, World!");
var hmacImportParams = {
name: "hmac",
hash: "sha-256",
}
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var expectedSignature = "d6b92f34723a8de7ba53dceea8c821f5d21757ddb478c27d564b356c38f583db";
crypto.subtle.importKey("raw", rawKey, hmacImportParams, extractable, ["sign", "verify"]).then(function(key) {
return crypto.subtle.sign("hmac", key, text);
}).then(function(result) {
signature = result;
shouldBe("bytesToHexString(signature)", "expectedSignature");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>