Upstream version 9.38.198.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / crypto / aes-cbc-unwrap-rsa.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <p id="description"></p>
9 <div id="console"></div>
10
11 <script>
12 description("Test unwrapping an RSA key with AES-CBC.");
13
14 jsTestIsAsync = true;
15
16 var nonExtractable = false;
17
18 var publicKeyJSON = {
19     kty: "RSA",
20     alg: "RS256",
21     n: "rcCUCv7Oc1HVam1DIhCzqknThWawOp8QLk8Ziy2p10ByjQFCajoFiyuAWl-R1WXZaf4xitLRracT9agpzIzc-MbLSHIGgWQGO21lGiImy5ftZ-D8bHAqRz2y15pzD4c4CEou7XSSLDoRnR0QG5MsDhD6s2gV9mwHkrtkCxtMWdBi-77as8wGmlNRldcOSgZDLK8UnCSgA1OguZ989bFyc8tOOEIb0xUSfPSz3LPSCnyYz68aDjmKVeNH-ig857OScyWbGyEy3Biw64qun3juUlNWsJ3zngkOdteYWytx5Qr4XKNs6R-Myyq72KUp02mJDZiiyiglxML_i3-_CeecCw",
22     e: "AQAB",
23     ext: false,
24     use: "sig"
25 };
26
27 var unwrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1");
28 var wrappedKey = hexStringToUint8Array("3511f6028db04ea97e7cfad3c4cc60837bceff25cb6c88292fbcb4547570afdc32e4003fe4d65f1e7df60dc1fdb3df36c3f58ab228e33aa31005852d46d0c2ad1318435a071bbb5bbb05650ea63d551698b0c040dd95ed0d379b5e2eccb545ae5620acb8051174cd2ad647328ad99dcd462fec40748724eb1e68f209f779faa2c35b4d4d1b6604a74e62a1846249ea6192954a5af10c71ebfea79948142441ed307e9f52e797a51a8007a6f87b57c51f9e7eef54b7e4a1f818ba6ac25ee5935c23b3253d6d9d222262c79ccdb7147d9c07527c22fe7a4ab91af20479edf5930b3c053c0a0b27092cfb53203633d01dcf6e333b5be7c1933c321c953f962b934ebefd9df8cca6c0a25fcd5fb96105435c42d9902406f82bc8daa8ec12fa85d9afa65adbfe3f60828ef64adaf43ad8e3b0af104cbfafd994323732bba08f84d5cac1d157b276233dffecafe47942b83c85ead6d5886c6badf534d4a32d3f545e8032dd5e419d7bff3acde2c37a96fc34fda8747d89500bf9f7ef45873c6b3b2741aaf74ff96a2f950028f38eb62f1be936fe0a994ebfa928021c0c96172d84584e");
29
30 debug("Importing an unwrapping key...");
31 crypto.subtle.importKey("raw", unwrappingKeyOctets, {name:"AES-CBC"}, nonExtractable, ["unwrapKey"]).then(function(result) {
32     unwrappingKey = result;
33     shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
34     var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
35     debug("Unwrapping a key...");
36     var importAlgorithm = {name: 'RSASSA-PKCS1-v1_5', hash: {name: 'sha-256'} };
37     return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, importAlgorithm, nonExtractable, ["verify"]);
38 }).then(function(result) {
39     unwrappedKey = result;
40
41     shouldBe("unwrappedKey.toString()", "'[object CryptoKey]'");
42     shouldBe("unwrappedKey.type", "'public'");
43     shouldBe("unwrappedKey.usages", "['verify']");
44     shouldBe("unwrappedKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
45     shouldBe("unwrappedKey.algorithm.modulusLength", "2048");
46     shouldBe("Base64URL.stringify(unwrappedKey.algorithm.publicExponent)", "publicKeyJSON.e");
47     shouldBe("unwrappedKey.algorithm.hash.name", "'SHA-256'");
48     shouldBe("unwrappedKey.extractable", "false");
49 }).then(finishJSTest, failAndFinishJSTest);
50
51 </script>
52
53 </body>
54 </html>