blob: 9db45bc92bb9c8ca28e63ec230c14817d08e4528 [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-256 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-256" }, 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", "64");
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>