blob: 2206b617e99a854158ff872748b39de74a707657 [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 PKCS8 format");
jsTestIsAsync = true;
var jwkKey = {
kty: "RSA",
alg: "RSA-OAEP",
key_ops: ["decrypt", "unwrapKey"],
ext: true,
n: "v_dgJnIz-_l4noBUwEkMAc-TkUXOBXUb4homc5oLYbVKYee51acuc3m26xK-vPD7VMCwEt17ylKW6jiEIEG50cZxzvCnGn2AiaqzVeqmm79htT93aX74yD6lginrtSSky5pasjxLlIzvEEGCC3zuupFyxXmCztY3AXbfcTscgWgSiNrgNzuuxtG6tbigc9gEPQj8XgSecr8XXKTqVbwQwh8rOao2rHfe_IjiXwElsTaL2sl3IHIrHx6NVbj54_0HCuo5AZ4ZyJ_bkLVBFe4gO9pIlhVuAHr6adlM83-moDeowYKqU4me_2GR_JspZ3Kif-WEwSY6jJuIn7qXtD5jUw",
e: "AQAB",
d: "DxvDH4OBf-VkjuT-xpt5LHNP4_Egg-FxrlvshtCq8Ke6EPaR87TSvRfpQ5sYE_rLbSI1OWbhJU1Wv1xvWbKSk2YQ8v6RyE30XeFnd-2d60gmwoMaPN1Xazsy_4mZGYqmxbeCR-Di-fAVqKvfNlRA3cIwzEYB-5F0htL6Rwkl9zE8th1DTuBvqBLoTxYZKLnoCN8YdfTUr-CQOghMafCwi3ltAkZqxNNqP9RRSqfkNCqAKK_23jhXS9yZSes3QEO1LBxDNpdumIk4smpO_iFhxd5I68s8JCDogfNQulmErrYbAk6cAUXNMvpua9ipH-uIw8qgakzKfD6lIQmeFoM7MQ",
p: "7uKCNGo6nH5Kk6zz6H6n3LAkKr45IQb1CfyLi6Po-6lxHt2a5bi5CkRH7PNUz3QRYWAkYmlpfvoAqzXhOYIUewvcbzyzTUxpv-F1Xbw9KV6nc1LFe8W8733AzLtHBgjimwU9VYgsmV7DJDP7djODjskSGPC9O9rcq7jK_1atFy8",
q: "zbhQdf5AX_ssgZALSFhMmvR39c2XJXBLFuAF_c1EBRtch3X-_DgHiZ1srZrdIbnI7yjx7smJPg1Met1pHTgrk9jdlGwkzxFQWgo5XbhergrB7njOtWmkTUlpd01zidk0Nh138KTCchVe7h4JKy7wIomw9256B3ozh0DuP7eIrR0",
dp: "C5HAyJUUfZvINNq9fVcU_iUxuzg3QBg8Kd2nTH4FvJp6Ngp5hAKsQ4kHCrzGML3oUZT8bh-40kN9YM1dORHJuCPc6y4_aND4lihvLLj_JU_GQFmT4uiyu86VVdUEHZC0mNlqHQhZUJw8SzaRSSo5huLKE5clMw7ofRCYFEG4ZFU",
dq: "axFbpx2N6aZzUndit-Nk81z7Nk4rNUwNeLldxOtZVIMaFFKARErw-Vman3wzTQNBpd-ckxgHOul2_ZdQxuleHNPI9x-VxMORG1uo4bM8a76jkncDtn1mCueDYZlI4dzPBL8vlmpZ3UBsKOgvA2-pgYBCP3UbQ9sBCIrttPHTy60",
qi: "o3RcFTK_WfBFceq7ZG3u3imgQkIfRWZorEAKBffBNw0ggh7XjKKNx_dAinTmCE_UlNih-kO9UPTPEI3QyB3i_BIxcm122Ldzot-9Q7H-hsQ6p7AODSlc3xfYNQEG5PjEsDBBG_GlybmDeblhr67s2hDPEmMgAuoXNHxf4QMvmqM",
};
var expectedPkcs8Key = "308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100bff760267233fbf9789e8054c0490c01cf939145ce05751be21a26739a0b61b54a61e7b9d5a72e7379b6eb12bebcf0fb54c0b012dd7bca5296ea38842041b9d1c671cef0a71a7d8089aab355eaa69bbf61b53f77697ef8c83ea58229ebb524a4cb9a5ab23c4b948cef1041820b7ceeba9172c57982ced6370176df713b1c81681288dae0373baec6d1bab5b8a073d8043d08fc5e049e72bf175ca4ea55bc10c21f2b39aa36ac77defc88e25f0125b1368bdac97720722b1f1e8d55b8f9e3fd070aea39019e19c89fdb90b54115ee203bda4896156e007afa69d94cf37fa6a037a8c182aa53899eff6191fc9b296772a27fe584c1263a8c9b889fba97b43e63530203010001028201000f1bc31f83817fe5648ee4fec69b792c734fe3f12083e171ae5bec86d0aaf0a7ba10f691f3b4d2bd17e9439b1813facb6d22353966e1254d56bf5c6f59b292936610f2fe91c84df45de16777ed9deb4826c2831a3cdd576b3b32ff8999198aa6c5b78247e0e2f9f015a8abdf365440ddc230cc4601fb917486d2fa470925f7313cb61d434ee06fa812e84f161928b9e808df1875f4d4afe0903a084c69f0b08b796d02466ac4d36a3fd4514aa7e4342a8028aff6de38574bdc9949eb374043b52c1c4336976e988938b26a4efe2161c5de48ebcb3c2420e881f350ba5984aeb61b024e9c0145cd32fa6e6bd8a91feb88c3caa06a4cca7c3ea521099e16833b3102818100eee282346a3a9c7e4a93acf3e87ea7dcb0242abe392106f509fc8b8ba3e8fba9711edd9ae5b8b90a4447ecf354cf74116160246269697efa00ab35e13982147b0bdc6f3cb34d4c69bfe1755dbc3d295ea77352c57bc5bcef7dc0ccbb470608e29b053d55882c995ec32433fb7633838ec91218f0bd3bdadcabb8caff56ad172f02818100cdb85075fe405ffb2c81900b48584c9af477f5cd9725704b16e005fdcd44051b5c8775fefc3807899d6cad9add21b9c8ef28f1eec9893e0d4c7add691d382b93d8dd946c24cf11505a0a395db85eae0ac1ee78ceb569a44d4969774d7389d934361d77f0a4c272155eee1e092b2ef02289b0f76e7a077a338740ee3fb788ad1d0281800b91c0c895147d9bc834dabd7d5714fe2531bb383740183c29dda74c7e05bc9a7a360a798402ac4389070abcc630bde85194fc6e1fb8d2437d60cd5d3911c9b823dceb2e3f68d0f896286f2cb8ff254fc6405993e2e8b2bbce9555d5041d90b498d96a1d0859509c3c4b3691492a3986e2ca139725330ee87d10981441b864550281806b115ba71d8de9a673527762b7e364f35cfb364e2b354c0d78b95dc4eb5954831a145280444af0f9599a9f7c334d0341a5df9c9318073ae976fd9750c6e95e1cd3c8f71f95c4c3911b5ba8e1b33c6bbea3927703b67d660ae783619948e1dccf04bf2f966a59dd406c28e82f036fa98180423f751b43db01088aedb4f1d3cbad02818100a3745c1532bf59f04571eabb646deede29a042421f456668ac400a05f7c1370d20821ed78ca28dc7f7408a74e6084fd494d8a1fa43bd50f4cf108dd0c81de2fc1231726d76d8b773a2dfbd43b1fe86c43aa7b00e0d295cdf17d8350106e4f8c4b030411bf1a5c9b98379b961afaeecda10cf12632002ea17347c5fe1032f9aa3";
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, {name: "RSA-OAEP", hash: "sha-1"}, extractable, ["decrypt", "unwrapKey"]).then(function(cryptoKey) {
debug("Exporting a key...");
return crypto.subtle.exportKey("pkcs8", cryptoKey);
}).then(function(result) {
pkcs8Key = result;
shouldBe("bytesToHexString(pkcs8Key)", "expectedPkcs8Key");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>