blob: 2e079319f8b2742d71fba75d4e71307fd05e04bf [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 type="text/javascript">
description("Test ECDSA signing/verifying operations with generated P-521 keys");
jsTestIsAsync = true;
var extractable = true;
var ecdsaParams = {
name: "ECDSA",
hash: "SHA-256",
}
var data = asciiToUint8Array("Hello, World!");
debug("Generating keys");
crypto.subtle.generateKey({ name: "ECDSA", namedCurve: "P-521" }, extractable, ["sign", "verify"]).then(function(result) {
keyPair = result;
debug("Signing");
return crypto.subtle.sign(ecdsaParams, keyPair.privateKey, data);
}).then(function(result) {
signature = result;
shouldBe("signature.byteLength", "132");
debug("Verifying");
return crypto.subtle.verify(ecdsaParams, keyPair.publicKey, signature, data);
}).then(function(result) {
verified = result;
shouldBeTrue("verified");
finishJSTest();
}, failAndFinishJSTest);
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>