blob: cfa5b68d1e488a7e429a9128862341e59aed01ab [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 wrapping a PKCS8 key with AES-CBC using an imported key");
jsTestIsAsync = true;
var extractable = true;
var pkcs8Key = hexStringToUint8Array("308204bd020100300d06092a864886f70d0101010500048204a7308204a30201000282010100ca6ee8ec62b6a02e187b70c19ca15a13c386a470ee8816c7340a270f96f905511f93362f8f7aae3e60394dac34cb29ea5f540d6ef80b1df7155b66a2d6d6e44092bcbafbf69b061b3f4d927060c81d0fa07d22f481ff503c0581ffa444f57345204ddf0a93a225979c61aeb9686557f7632002e165430452868d010d505e3ccfed7315432a298a9b6d1a6ede98ee746c2c8bd22f5495cee563e2db24f1e33d91ced83af1baac754dba4ddba430f6cf3d4ac7edb0bf69891140854e8700056a7ef6d06ed5a605a05e74ecb3b246ce9cb310b39b00c707af3a637862e3d2914013de212ff09a36db84d99b8d610d0cfd36a4411dbf1b62e06ebff1bee50f040ca502030100010282010024706483309db925b3087d5a8cac4abfa60195963289d2b7d6f940e0c08760daa279685695583b074560eb47655570dd1c7dcfd13adb1d70bdaa6f463eaffdf455b59d5eff9c16344f67d2456256834cadd1f8b9d4b0b5aba83e275b55826d567323315401113dfd158c4bdc5a1b6c033f17a30d19a23fa3ef4e70730a157c928b1c7840a34401d19daab52cfa9b424cc8e1084254ca597304be22547b7221e875bf1fdca2386ba1e855d5e0bcaba03376bfd73de8513c07ab0e67cb3554dc8c8f7a67d231f99a2b653ad471ee2f8bd3b8fad51b02f807d131b6b71ab17e45a5faf161ce3b919d96b5e78e9e4e1202d6398a954def4c1980da1fcc30d56167e102818100ee24b92668d38465fdd9a2262e64be56846be561e4cfbcedc82496a3190b549636923d61c3e5a2d40cc6d2c46a3e89ac23eb44ac40c777147e3e49a80bd382bae06e284f1cc553f89d78f0c7bf20fd3a33ee598ce2caf61e3f5457cd228ff03fe009f10952206bf248e161d17950c6655af75b097bbda1b909038d4d752cd11d02818100d99cb65195a399f9a3aca1ef1593592992e7d91cc028b713ec5b661b9976fcffdb086f523f042699cb910321fe7b67a27dd4a72822e6fbb98d005280721efc32d889d431d2737c92a4f34d4885c7a9c6244e081a1264a283d07744b752a68ebb6fbff3492a039e3e3a0cc5b94537582a7d11cc6b8678e4c338671f96be029b2902818100a1a2a7509ca1c4217db4f3cbba7d827b32921134ea9add7efef36692f8f2a9ccf2e93b645a1448fa6859a2c0d1e3f489b42f8182f0ccf1d425039df6c360224139074bb0b6b47094343ddc1f97688ab7b07bbca8555eb0c242f5ba4a6f8506ea33e44b87aa087b7c0d5f7c8733325216853192c6d30818f68059bad4b20d633902818034b3bf7402c99c80d922f614f124be735320d3742315b94119fd08bda66d2ad8cc333ec2ac8054d8ea74344e0753dbc57eb401c7b6ac3a4ab5db5e1fbd83c3908ce0d4833c74bbb6c83c247b6beaef330d97d85e7815e7460536dd6d8896cdfa9715e5d5d2570dfc041313cfcaf39c66ade3a19e68f2de7469349071f192b00102818060a8271f45161d8ecf62c3ac5f0fa8539b6d86a35123aafcc37541e2d5e5b62715777db0ef75f3cdf67506b8fcad6baed862eaf88fa1f280f42736b69a41ea7a3fea31ce62aa0563c85df1d9b02b83839c4ab9453e420c5c401cce979f6fb7b6ac12baf1e9140546eed24e92e383b8f2d37b3e4410844d235c7175112e751ee0");
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var aesCbcParams = {
name: "aes-cbc",
iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
}
var expectWrappedKey = "7aedac7ca0885c4c8340e7414b45b160a872c38eb56f25fa17eeb885abcbd72ce35fb0d8dcfa023dcb0bf94b0fe2a98a693b30e8a993207d646f2b14f673eddddc53815cb3b63cadf3b275bd0c387276e792fbdfd0bab94951ce109ff42ad4c739e5bd6e3f21140d0de7fbd3b60b8a05b29e1aae6385ced993546140a143db854d5b54e2a5d0be425d2aa8a4eee00b779a7b905c3e7fc4a91c37582871eb0b6daddba5d9497271e82e71589a31058fe0c38a7506f72acbc70f88139654cb1a26580f9c20b228c8f22865233d6a705eb68249a906f7d022ef28c84a5dccba26455391f4ce3572e9cfa50b7b4cefcdadf1eec50afc1df31a43f9dda40cd14524aa075b8f081a8b708ce1214b8ec0bd1c9a9af21596d7520b032a7588edaff8116e8710b47f8cda2caace8386cf176507c664f2757d3d728f6ea3be81abe58f36f751a32833d8689b7008a66b72d325ae729bb1064e88ace17c767c376d5c88eff8e8f1cf377639e66390614af43b4aa171fe144ad69c5a0d4d5d4129461da5250fb389b0eb0d53e65263a4b6265ad3fc0d375d42426f3ca1373c044aa47ec9973c77c46ae34f07ba6cc7d43c56438a9d678bf961f7bd7a4155f7cf813dd7a6fe434f04f052d86f5fc79813e85c0817f952e13e99ddea5d21d92e517a8f269a8da660c1d1432ad2d476bd2d13c1f3207b0a5c3f0f250fc195f406e89c1c107d5733cbaaacefc411ea7377880caa09847560b4dfe86f1ce8a0aac3d142eb9aa315a7e36383b5aa4f027f6ee6603053dd877e57755ae13a0b01453b3806610f98ed85ea574a2c040d0df9e861091f72a285fb563da4ac9d6098a2e4cf232455d8529e80ec8b9334690bca941caa8d8c6c2ebb29c73176c736b2e1cd897aaecdb7d51fbf2eeb5716bb441c0a2646643530f1618a5923b7fe3c6d8fcd55ec18ddbc5053d09af3f3ca058b3471d3cc327cdcdaa8a0dcada0dd3e52365d5ad2d36643769e8f274ef2020ce47975dceefb1fa3a4ff092927ebd2dc9017b4e36ab0591358a65c98d981f1e687e9cde16b3953b0f4b5a8f0b305fdfbbc60d11046d633a8c96e705290300a145a58f61983a3b95dc57615863faa2c217f3656a627b6a3e438ff55cd87c6462699a3db064213f30831e8be8d058ea6313af2d468904dfa544b4caf0598fcb2e59d5a1b4ee022f32e86b4ef0fd2e55ecb38edc114758d97718bc3c43f300614554a19320b7c7687d3d2218bb7fef7a01950c028c14f0bdede849924c0cab8161a7d0600d46f9e37bdbb7f7b2d3ca72e75eb6da10e015c5c2bed171ac50ff94a3291a6fc5b5a093d4c9cfbc269fc4f295c881676706f1fadda515c6f9441f5f05af0a8255706b18f8b76bf4b5f729cddea05b099470f02f71df46a3b0b53ec5429bdfd29c9c50f72c0359bdf4ee7435dcbc415fa5b2633ebdc5d6213fe5eefcfdeda6a14b9f4d9ba837afae59549a31428a9ead0c3e32c66cf93e42d5b0266e0ad7d6ed5027923c6d0eb8191f55d987a2ebf4c87f4d49c1b75c3e938c8c54d502877e54ef1fbae0851e6b55c3fbc443fe6ae1ef97aa4d4c4a0dd7a74191fa72bf1f127b63001f36c9b3d1bb8d9d1fe609cf24423b84cc96afed8e38508efb9bf01638ca75abcc46fc371aac26c493ee9b0a71c95e310eeb30460ef6baf622cbc74c89b01558d0913e4394369a782d3536c8ca0b90aaf087004a7d18836c0b9d45a48fd235a12e687d80c6e";
crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["wrapKey"]).then(function(result) {
wrappingKey = result;
return crypto.subtle.importKey("pkcs8", pkcs8Key, { name: "rsa-oaep", hash: "sha-1" }, extractable, ["decrypt"]);
}).then(function(result) {
key = result;
return crypto.subtle.wrapKey("pkcs8", key, wrappingKey, aesCbcParams);
}).then(function(result) {
wrappedKey = result;
shouldBe("bytesToHexString(wrappedKey)", "expectWrappedKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>