blob: 235f58b88ebb32398c1cfa7c15a93363dd1f5bc6 [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 exporting a SHA-224 RSA-OAEP key pair with JWK format.");
jsTestIsAsync = true;
var algorithmKeyGen = {
name: "RSA-OAEP",
// RsaKeyGenParams
modulusLength: 2048,
publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
hash: "sha-224"
};
var extractable = true;
var keyPair;
debug("Generating a key pair...");
crypto.subtle.generateKey(algorithmKeyGen, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]).then(function(result) {
keyPair = result;
debug("Exporting the public key...");
return crypto.subtle.exportKey("jwk", keyPair.publicKey);
}).then(function(result) {
publicKey = result;
shouldBe("publicKey.kty", "'RSA'");
shouldBe("publicKey.key_ops", "['encrypt', 'wrapKey']");
shouldBe("publicKey.alg", "'RSA-OAEP-224'");
shouldBe("publicKey.ext", "true");
shouldBe("Base64URL.parse(publicKey.n).byteLength", "256");
shouldBe("bytesToHexString(Base64URL.parse(publicKey.e))", "'010001'");
debug("Exporting the private key...");
return crypto.subtle.exportKey("jwk", keyPair.privateKey);
}).then(function(result) {
privateKey = result;
shouldBe("privateKey.kty", "'RSA'");
shouldBe("privateKey.key_ops", "['decrypt', 'unwrapKey']");
shouldBe("privateKey.alg", "'RSA-OAEP-224'");
shouldBe("privateKey.ext", "true");
shouldBe("Base64URL.parse(privateKey.n).byteLength", "256");
shouldBe("bytesToHexString(Base64URL.parse(privateKey.e))", "'010001'");
shouldBeUndefined("privateKey.oth");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>