blob: 81c24579ed02b5c2c84fb47af9001e162a9ed1f2 [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 JWK RSA-OAEP public key with SHA-1 and then export it in SPKI format");
jsTestIsAsync = true;
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
key_ops: ["encrypt", "wrapKey"],
ext: true,
n: "p55Xl-DyqKL06TE8GCuXd_e-ruTqVB19iDH6DwTIknTyM0fl8EY6qsyOBNTxjpLDsOldEJ8QblG78WY7xYTZtNn-fimz5eG80bwSZ6FUO10z3ikeKzPPC7K4AA196rMoiEu2G4mSfqeg5zz6_iqHf8u_md_n8yk_iPaXJ9RVT-W4zEQQ6WSlsOtYa7blSSAlq0JYDJciNeE0RGqUU-UjcxUWIEnT2ODHGRzSfKHgc8O3fGt4dpVm0op1yItBcSAY-0_f1p_YrVDo8bsyq2uodyDGYhcuQgYJ0NjMgT_rb8rUPpR3bUitd-IZJd_NO9i_NmvbnQfgl6kfnxe_2kM4Tw",
e: "AQAB"
};
var expectedSpkiKey = "30820122300d06092a864886f70d01010105000382010f003082010a0282010100a79e5797e0f2a8a2f4e9313c182b9777f7beaee4ea541d7d8831fa0f04c89274f23347e5f0463aaacc8e04d4f18e92c3b0e95d109f106e51bbf1663bc584d9b4d9fe7e29b3e5e1bcd1bc1267a1543b5d33de291e2b33cf0bb2b8000d7deab328884bb61b89927ea7a0e73cfafe2a877fcbbf99dfe7f3293f88f69727d4554fe5b8cc4410e964a5b0eb586bb6e5492025ab42580c972235e134446a9453e5237315162049d3d8e0c7191cd27ca1e073c3b77c6b78769566d28a75c88b41712018fb4fdfd69fd8ad50e8f1bb32ab6ba87720c662172e420609d0d8cc813feb6fcad43e94776d48ad77e21925dfcd3bd8bf366bdb9d07e097a91f9f17bfda43384f0203010001";
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["encrypt", "wrapKey"]).then(function(cryptoKey) {
debug("Exporting a key...");
return crypto.subtle.exportKey("spki", cryptoKey);
}).then(function(result) {
spkiKey = result;
shouldBe("bytesToHexString(spkiKey)", "expectedSpkiKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>