blob: d709e8a231866d18332a4377ffd2c4831d8df0d2 [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 PKCS8 RSA-OAEP public key and then export it in JWK format");
jsTestIsAsync = true;
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
key_ops: ["decrypt", "unwrapKey"],
ext: true,
n: "ym7o7GK2oC4Ye3DBnKFaE8OGpHDuiBbHNAonD5b5BVEfkzYvj3quPmA5Taw0yynqX1QNbvgLHfcVW2ai1tbkQJK8uvv2mwYbP02ScGDIHQ-gfSL0gf9QPAWB_6RE9XNFIE3fCpOiJZecYa65aGVX92MgAuFlQwRSho0BDVBePM_tcxVDKimKm20abt6Y7nRsLIvSL1SVzuVj4tsk8eM9kc7YOvG6rHVNuk3bpDD2zz1Kx-2wv2mJEUCFTocABWp-9tBu1aYFoF507LOyRs6csxCzmwDHB686Y3hi49KRQBPeIS_wmjbbhNmbjWENDP02pEEdvxti4G6_8b7lDwQMpQ",
e: "AQAB",
d: "JHBkgzCduSWzCH1ajKxKv6YBlZYyidK31vlA4MCHYNqieWhWlVg7B0Vg60dlVXDdHH3P0TrbHXC9qm9GPq_99FW1nV7_nBY0T2fSRWJWg0yt0fi51LC1q6g-J1tVgm1WcyMxVAERPf0VjEvcWhtsAz8Xow0Zoj-j705wcwoVfJKLHHhAo0QB0Z2qtSz6m0JMyOEIQlTKWXMEviJUe3Ih6HW_H9yiOGuh6FXV4LyroDN2v9c96FE8B6sOZ8s1VNyMj3pn0jH5mitlOtRx7i-L07j61RsC-AfRMba3GrF-RaX68WHOO5GdlrXnjp5OEgLWOYqVTe9MGYDaH8ww1WFn4Q",
p: "7iS5JmjThGX92aImLmS-VoRr5WHkz7ztyCSWoxkLVJY2kj1hw-Wi1AzG0sRqPomsI-tErEDHdxR-PkmoC9OCuuBuKE8cxVP4nXjwx78g_Toz7lmM4sr2Hj9UV80ij_A_4AnxCVIga_JI4WHReVDGZVr3Wwl7vaG5CQONTXUs0R0",
q: "2Zy2UZWjmfmjrKHvFZNZKZLn2RzAKLcT7FtmG5l2_P_bCG9SPwQmmcuRAyH-e2eifdSnKCLm-7mNAFKAch78MtiJ1DHSc3ySpPNNSIXHqcYkTggaEmSig9B3RLdSpo67b7_zSSoDnj46DMW5RTdYKn0RzGuGeOTDOGcflr4Cmyk",
dp: "oaKnUJyhxCF9tPPLun2CezKSETTqmt1-_vNmkvjyqczy6TtkWhRI-mhZosDR4_SJtC-BgvDM8dQlA532w2AiQTkHS7C2tHCUND3cH5doirewe7yoVV6wwkL1ukpvhQbqM-RLh6oIe3wNX3yHMzJSFoUxksbTCBj2gFm61LINYzk",
dq: "NLO_dALJnIDZIvYU8SS-c1Mg03QjFblBGf0IvaZtKtjMMz7CrIBU2Op0NE4HU9vFfrQBx7asOkq1214fvYPDkIzg1IM8dLu2yDwke2vq7zMNl9heeBXnRgU23W2Ils36lxXl1dJXDfwEExPPyvOcZq3joZ5o8t50aTSQcfGSsAE",
qi: "YKgnH0UWHY7PYsOsXw-oU5tthqNRI6r8w3VB4tXlticVd32w73XzzfZ1Brj8rWuu2GLq-I-h8oD0Jza2mkHqej_qMc5iqgVjyF3x2bArg4OcSrlFPkIMXEAczpefb7e2rBK68ekUBUbu0k6S44O48tN7PkQQhE0jXHF1ES51HuA",
};
var pkcs8Key = hexStringToUint8Array("308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100ca6ee8ec62b6a02e187b70c19ca15a13c386a470ee8816c7340a270f96f905511f93362f8f7aae3e60394dac34cb29ea5f540d6ef80b1df7155b66a2d6d6e44092bcbafbf69b061b3f4d927060c81d0fa07d22f481ff503c0581ffa444f57345204ddf0a93a225979c61aeb9686557f7632002e165430452868d010d505e3ccfed7315432a298a9b6d1a6ede98ee746c2c8bd22f5495cee563e2db24f1e33d91ced83af1baac754dba4ddba430f6cf3d4ac7edb0bf69891140854e8700056a7ef6d06ed5a605a05e74ecb3b246ce9cb310b39b00c707af3a637862e3d2914013de212ff09a36db84d99b8d610d0cfd36a4411dbf1b62e06ebff1bee50f040ca502030100010282010024706483309db925b3087d5a8cac4abfa60195963289d2b7d6f940e0c08760daa279685695583b074560eb47655570dd1c7dcfd13adb1d70bdaa6f463eaffdf455b59d5eff9c16344f67d2456256834cadd1f8b9d4b0b5aba83e275b55826d567323315401113dfd158c4bdc5a1b6c033f17a30d19a23fa3ef4e70730a157c928b1c7840a34401d19daab52cfa9b424cc8e1084254ca597304be22547b7221e875bf1fdca2386ba1e855d5e0bcaba03376bfd73de8513c07ab0e67cb3554dc8c8f7a67d231f99a2b653ad471ee2f8bd3b8fad51b02f807d131b6b71ab17e45a5faf161ce3b919d96b5e78e9e4e1202d6398a954def4c1980da1fcc30d56167e102818100ee24b92668d38465fdd9a2262e64be56846be561e4cfbcedc82496a3190b549636923d61c3e5a2d40cc6d2c46a3e89ac23eb44ac40c777147e3e49a80bd382bae06e284f1cc553f89d78f0c7bf20fd3a33ee598ce2caf61e3f5457cd228ff03fe009f10952206bf248e161d17950c6655af75b097bbda1b909038d4d752cd11d02818100d99cb65195a399f9a3aca1ef1593592992e7d91cc028b713ec5b661b9976fcffdb086f523f042699cb910321fe7b67a27dd4a72822e6fbb98d005280721efc32d889d431d2737c92a4f34d4885c7a9c6244e081a1264a283d07744b752a68ebb6fbff3492a039e3e3a0cc5b94537582a7d11cc6b8678e4c338671f96be029b2902818100a1a2a7509ca1c4217db4f3cbba7d827b32921134ea9add7efef36692f8f2a9ccf2e93b645a1448fa6859a2c0d1e3f489b42f8182f0ccf1d425039df6c360224139074bb0b6b47094343ddc1f97688ab7b07bbca8555eb0c242f5ba4a6f8506ea33e44b87aa087b7c0d5f7c8733325216853192c6d30818f68059bad4b20d633902818034b3bf7402c99c80d922f614f124be735320d3742315b94119fd08bda66d2ad8cc333ec2ac8054d8ea74344e0753dbc57eb401c7b6ac3a4ab5db5e1fbd83c3908ce0d4833c74bbb6c83c247b6beaef330d97d85e7815e7460536dd6d8896cdfa9715e5d5d2570dfc041313cfcaf39c66ade3a19e68f2de7469349071f192b00102818060a8271f45161d8ecf62c3ac5f0fa8539b6d86a35123aafcc37541e2d5e5b62715777db0ef75f3cdf67506b8fcad6baed862eaf88fa1f280f42736b69a41ea7a3fea31ce62aa0563c85df1d9b02b83839c4ab9453e420c5c401cce979f6fb7b6ac12baf1e9140546eed24e92e383b8f2d37b3e4410844d235c7175112e751ee0");
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("pkcs8", pkcs8Key, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"]).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");
shouldBe("exportedJwkKey.d", "jwkKey.d");
shouldBe("exportedJwkKey.p", "jwkKey.p");
shouldBe("exportedJwkKey.q", "jwkKey.q");
shouldBe("exportedJwkKey.dp", "jwkKey.dp");
shouldBe("exportedJwkKey.dq", "jwkKey.dq");
shouldBe("exportedJwkKey.qi", "jwkKey.qi");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>