| <!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 wrapping a JWK RSA private key with AES-CBC using an imported key"); |
| |
| jsTestIsAsync = true; |
| |
| var extractable = true; |
| var jwkKey = { |
| kty: "RSA", |
| alg: "RSA-OAEP", |
| use: "enc", |
| key_ops: ["decrypt", "unwrapKey"], |
| ext: true, |
| n: "lxHN0N9VRZ0_pl0xv3-NXx70WnjkODSkQ5LjHXTFy3DOQsvkagFzD9HqYQezCmcewLjdK5PLwSesDoMdfL6tusBHcvyit1kvydYFQ3NLbENNkYsiBG5_nW4IQGL6JKbZ5iGdUop98QHKm6YZR1u4zrAtxM6bVEo05VvhjRS0M8yWoZVi-7Vdsc0LqI0Qdq_NoctX5Fu-AqiBN7Uo1HkYGcP2oC82J_J5cjw98BQiP5kDWThq9RK-X6S-EUALx_m4iG6iOYKTA3SQyf1xBqFaXXoEJjcckbOqkegecz5b-YWUh8iZPvhwnt-RZwpIbLJgKwz19ndkn9KvoEEw7YbEow", |
| e: "AQAB", |
| d: "cj5DkDakjM2bKduGWJREO-_zyEtuA1dD9doqKMd7IRuA0CDS7puEAS20-oXRDwfmyMXEdEUDrGGtCxh6fzDPvs_T-JA3GUK4EgHo3xZcrlXDXlKCeil6Fnr0gISZOIh5dkBrcdVL4quBJe4ZZc5mVuAC7Ld13et0TxMJ4iALGrPuqPVUOGSYIcZ9idx5zKKBWhY3tPggEdKpnHBmPfTRO4yZaf0Nw1QXrgSMZY9ejeuaurAh4Q8o4-6-r8O2LUe7ufMh_ccKkXISEh4KdOnT17EM9BQTn9UNS9GoK2ZZU0U3io5DSu_kpasr4uOVWcGlE2wczOv2nkGwG39F3sFF0Q", |
| p: "x5vnco5j-TD6hTOzyN4DhkZ44m05NycxT6SUE2qTurT3-uze_L7TYutLRIRkovRMhTHZAr2pziRlasEs13PEz9Zvx1I_T68srsonrdbak-SFMecM7EjHc5C-J13gXhw9HIW28_Sx9rQ-JkGwEwE9PEdIUfuvdqpgh3SmXwPJrEs", |
| q: "wb9vllg_2n-kNge0bThg_7xu1UwTzipM8vxSUkkV2IipJKIAekkU3aAB8LoPhUI0-17pSGw3ETOO27t163TI9qIPpzLbhTH9aUi7qLGbKlzPlgnqP43Z0LHxc3xKDgit-Ar29QLaX2uoJBX6VVWvhmh7BIPDHNVM5GZjwWORYgk", |
| dp: "C2c8sa6wx2uk5Dcv7inAycr83PKgciYrCwG78-AC0IfGIu-lTYsZSG1ov2FQ3n5WYMWYQC_Vo5EwugiPJz_V3onBmQF53HOFefbSjXvYwNotQcyRUG5X9qIuOtGCH949H4QED6vK_u0NH-JgzLUlamwoFYbrXzwch6CCYKs2ukE", |
| dq: "hbtRloDLclHwUqr2yvzDV0IFbozYjtF706x-VfXEcnXB6ls34TBYirFLJZIH7H9KeseEVkz7pY_k5555QlCV9kbebxYXl9RtiiJ-BW6yH4d4caPeYIfU9MweUQxVQWKUUkWfOHcDrCFvKZlR9Vzzjt7HKtKX9mr0bCKQcIf9baE", |
| qi: "a-7hUTTnclUPKOfSgH8zEKGJ-AvdFEzxvZ5sq46Qf2MbORxVjN4dJamVvM-FoqcwN-9cuUlyr9bSFTwUBW4vXa8Xj9a8JfViuMCqzR-mL1rGIUQ5ARGhNcSsRlyKTqz5BlWlVKmXIx_p-DeVwPWiJJy4k_FqyBxrnxkzomHfrxk", |
| }; |
| var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr"); |
| var aesCbcParams = { |
| name: "aes-cbc", |
| iv: asciiToUint8Array("jnOw99oOZFLIEPMr"), |
| } |
| var expectWrappedKey = "995a93379575a0c677a7d48dbe7d496f64a53769eafae1e6a1d0f6a57d2c7f69748cdaeeff1fe7e13eb9c6d4597458ed22d369d5c6043b6ab30c79f1e7082cb3a57e19e53e607a0b26090317f45b24266c662923bb3b8c0fd7447860c52b3052da1bddda729a8bc19c447e4acd2b7da6b13fad0c4e022f7d76cb804c8aaebaed4566e2e14b02e81689f47314bf49c599c9b3700f2e23df498816bbe3ffe139cc0ed0500e762b4f3341b159950abd362ada4158e21b8ba0ed0f01a441d6a730e6a5717fd939b2e8b418d86f632ed2f3c7fea57d1ad67914afc41e4153c5b799f91c49f4db257d06477c748f7405c1394fbc8523c0a6fd31bf8368573defb47353d55c3bd5a7adfa5d9a54412823a5cfed93e632af8bdb929f0113d5ff021c0cf40d98e0f8dbaadf2c8c3878196a616e607fb5f7db4420a587cac87771c2ee6028d7f5036e1ffcb88b7f4c72a155890e8bb99c74a02aa80d4ed22ad27d4a60e9d532ab4c461a776a16e6b88ae8365b3987eab6fd2d02f9de9febc28d6f4a5467a3ef8e92c36d4e971d8c0801526393260f11eed75b6fb70ed3822c60bf7dcc6c8d4ef21ce74449365019033dfb9b8f9793198d68d406ca5dce366fb7b515c85c4ff47f6b5b3692397632d22eb6026f05a9e39f2be3be75d8aa1876aa4bac108d3ce67914c95cba31c5c072d9ddcbbbb90e34bc16c60ce812bfbb34cb76e4e7f68c0e5d6eb7647853731cab8ef4b8e3a557c84ca2b6aae9eec06bef30edf1280ef534c8698baa265d08b75ca3a29a4fbed50afdaa48e8cfebff211e9d64e63c0e3ba077f9a9c6f77a5b865a25850334d42df4f55cb7d0e1fb59590fea96d757eac310be056427b55b10342a3dd522a712d86e589183fa278dbc3c6654c12d777e9fa2a030aba5747aa345a46e7754bda59f530e5e8dfdedfc343bb789fdfc138210d5ab587f581c006760ba3d6b5875e2a34ae16f9cbded2882f5e6ffd9904518b789123ca6d19eeda979dab4ba8437b8d660354a28dac7e917cdf061cd7748d624e0af4ab9c2a5c18389e71accc495945dc83e7ea7c7724434ab375551c6fd2b0070229ec791aa680be539799aa168cf5a955721d249e676ee434141f93d1977fd8d635e387496cac6c3509a71df4fac016ca7885ae7fa7fe601c6ed62a83d0313b7d07476501e5e8b3821a1fedfa91e842cffa3cc255db1a50091aa6b391d1014cc1e59c3f36425102a03acabf06525f44c87422a889ed78c1e78a2a4d9ab244a30155005e954111d4c3384f63153adc276861021a76289f266fb7d6eda300d39102bee7d7047e32b0ced7a90e0b27f201ad8960ecb83a8003ef1e3de97b2ddf00f5b8344f1f103c6b0c5a90804201f9ac26c544e7f3cca7d4d10a7388b2460a83dfbc9c7544b9e7ce2488907f2da06b48ec209c8e9a4688261c1a1b63c940b07c2053b60b06b20421810ffbef6a4d482d7ba7d80cb6ea04222797e4ee40564612bfb15b57b34afcab259efb03e2f7a7a1622b06df5825d6cf2fd0bf63749e2c6e89b358cfe0167f0577c571953dba4b4bb3591c922b2605ccc4ccb5a3ba1a38a8983d885d867713be90d2e796fd7cb8d465925927feaeae45ef931dc7806a6ecc94810a7a39a87c6158e85866a8c2bdd3b88522c23fc4a969f60994e3cfb1be584c3f418b1e19009ac53b38d9d015af213acd5f0e9d65ee78d59c10e94973eb08b79403483591662cc9b45ac13360e262c77bb3f71f32f0f3fa35ce75daf7ca39c4c81abbabc478d6c51ffdadee0787bc98617e3ef85d87a2447103e43f910019ee95d829a4dda87339fb1437aabf4bdc884ac470853622835e825229299b838ed75024ed28050ac858aa5ba9df18ff072e878c7f1fb2da444a8eb92de07e77fd1cf7c19e589646cdbce436de837b44b78420ee9ed1bc74b5b49d98758b1b80bf17f1a2836a2a9958990a6205bd20e969c91ed56b196b0dd64fc3545e5d9278a75f0368bd4ec1a88f396e374d19a3e622f65709a522b2b1ffc70aac843f879e4507cc675a513eb868e1116fa2c8e0215afa1ddaaa99d2698879944180a4da38873c512998a7a0c51b44c8655302b703a9251a9f3acd9465d9f3eab1b7555317fdd97ccf0305a56e32a34daa62a8a4d16f280db7fd54bff1ed916d04c3e346b5de79b833d9ba42789be91a42fdad20c239eaa51f411fde79f0d6274a055fa98fabbc583714ed4baa168660493a55a7fdf5b66dc4d6afb05224da3b3f81ca8274b1be0d31da40b80ee9f0a56448bcbc6f8142aea8ab0169764dac201c7c8733e3f9b7212be22a39c12e30cde9ed5fe3042db4a51a1b85e0d23fc7b237224473be41ef6a8db014cda53969b1acdd0b732a5"; |
| |
| crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey"]).then(function(result) { |
| wrappingKey = result; |
| return crypto.subtle.importKey("jwk", jwkKey, { name: "rsa-oaep", hash: "sha-1" }, extractable, ["decrypt"]); |
| }).then(function(result) { |
| key = result; |
| return crypto.subtle.wrapKey("jwk", key, wrappingKey, aesCbcParams); |
| }).then(function(result) { |
| wrappedKey = result; |
| |
| shouldBe("bytesToHexString(wrappedKey)", "expectWrappedKey"); |
| |
| finishJSTest(); |
| }); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |