blob: 784201b0573b6db330e47afb6861cb4fb39f21b2 [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 importing a SPKI RSA-OAEP public key and then export it in JWK format");
jsTestIsAsync = true;
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
key_ops: ["encrypt", "wrapKey"],
ext: true,
n: "1hBRxJINTHwEozvquyQSvtxBc_2-gsfbgPAFLQCr0y4BZW0hBavvT6VBe7hou3d4DAjSDP6eLXZ-6VKXCUE5j4vqWalmdysdifGWk8__X6uiK6Oe95gqxGJXGA1VfTy_P35l3YNdHTUeZ5qEG5BKPPJKAyOqwLuJcFd3UHx29XZjtthG6ZWmMFfOtIBT3fkoKjZtbcbL3OsuvLOzdMfcSdoWDLqKNlYhG4WXo575uMxE0MVzX4cGef_LHLkyG7-8MHhE0xdO9dwUSpUQcTQPTRVr6tIf09m9RkGvpYUVEiZLTu0ii11jJN5CiwDLuJoaiMsTjVneC0rXXyGW4Oe6iQ",
e: "AQAB"
};
var spkiKey = hexStringToUint8Array("30820122300d06092a864886f70d01010105000382010f003082010a0282010100d61051c4920d4c7c04a33beabb2412bedc4173fdbe82c7db80f0052d00abd32e01656d2105abef4fa5417bb868bb77780c08d20cfe9e2d767ee952970941398f8bea59a966772b1d89f19693cfff5faba22ba39ef7982ac46257180d557d3cbf3f7e65dd835d1d351e679a841b904a3cf24a0323aac0bb89705777507c76f57663b6d846e995a63057ceb48053ddf9282a366d6dc6cbdceb2ebcb3b374c7dc49da160cba8a3656211b8597a39ef9b8cc44d0c5735f870679ffcb1cb9321bbfbc307844d3174ef5dc144a951071340f4d156bead21fd3d9bd4641afa5851512264b4eed228b5d6324de428b00cbb89a1a88cb138d59de0b4ad75f2196e0e7ba890203010001");
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("spki", spkiKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]).then(function(cryptoKey) {
debug("Exporting a key...");
return crypto.subtle.exportKey("jwk", cryptoKey);
}).then(function(result) {
exportedJwkKey = result;
shouldBe("exportedJwkKey.kty", "jwkKey.kty");
shouldBe("exportedJwkKey.alg", "jwkKey.alg");
shouldBe("exportedJwkKey.key_ops", "jwkKey.key_ops");
shouldBe("exportedJwkKey.ext", "jwkKey.ext");
shouldBe("exportedJwkKey.n", "jwkKey.n");
shouldBe("exportedJwkKey.e", "jwkKey.e");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>