50 lines
1.7 KiB
HTML
50 lines
1.7 KiB
HTML
<!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 generating an RSA key using RSAES-PKCS1-v1_5 algorithm.");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var algorithmKeyGen = {
|
|
name: "RSAES-PKCS1-v1_5",
|
|
// RsaKeyGenParams
|
|
modulusLength: 2048,
|
|
publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
|
|
};
|
|
var nonExtractable = false;
|
|
|
|
debug("Generating a key pair...");
|
|
crypto.subtle.generateKey(algorithmKeyGen, nonExtractable, ["decrypt", "encrypt"]).then(function(result) {
|
|
keyPair = result;
|
|
shouldBe("keyPair.toString()", "'[object Object]'");
|
|
shouldBe("keyPair.publicKey.type", "'public'");
|
|
shouldBe("keyPair.publicKey.extractable", "true");
|
|
shouldBe("keyPair.publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
|
|
shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
|
|
shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'010001'");
|
|
shouldBeUndefined("keyPair.publicKey.algorithm.hash");
|
|
shouldBe("keyPair.publicKey.usages", "['encrypt']");
|
|
shouldBe("keyPair.privateKey.type", "'private'");
|
|
shouldBe("keyPair.privateKey.extractable", "false");
|
|
shouldBe("keyPair.privateKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
|
|
shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048");
|
|
shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'010001'");
|
|
shouldBeUndefined("keyPair.privateKey.algorithm.hash");
|
|
shouldBe("keyPair.privateKey.usages", "['decrypt']");
|
|
|
|
finishJSTest();
|
|
});
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|