blob: 0efed579ec5d9dcbb048017be03ada72280e26e3 [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 sign/verify with RSASSA-PKCS1-v1_5 SHA-1 using a generated key");
jsTestIsAsync = true;
var extractable = false;
var text = asciiToUint8Array("Hello, World!");
var rsatParams = {
name: "RSASSA-PKCS1-v1_5",
hash: "SHA-1",
modulusLength: 2048,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
}
debug("Generating key...");
crypto.subtle.generateKey(rsatParams, extractable, ["sign", "verify"]).then(function(result) {
keyPair = result;
debug("Signing...");
return crypto.subtle.sign("RSASSA-PKCS1-v1_5", keyPair.privateKey, text);
}).then(function(result) {
signature = result;
shouldBe("signature.byteLength", "256");
debug("Verifying...");
return crypto.subtle.verify("RSASSA-PKCS1-v1_5", keyPair.publicKey, signature, text);
}).then(function(result) {
verified = result;
shouldBeTrue("verified");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>