[WebIDL] Add support for converting dictionaries to JS
[WebKit-https.git] / LayoutTests / crypto / subtle / rsaes-pkcs1-v1_5-generate-key-extractable.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test-pre.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 generating an RSA key using RSAES-PKCS1-v1_5 algorithm.");
13
14 jsTestIsAsync = true;
15
16 var algorithmKeyGen = {
17     name: "RSAES-PKCS1-v1_5",
18     // RsaKeyGenParams
19     modulusLength: 2048,
20     publicExponent: new Uint8Array([0x01, 0x00, 0x01]),  // Equivalent to 65537
21 };
22 var extractable = true;
23
24 debug("Generating a key pair...");
25 crypto.subtle.generateKey(algorithmKeyGen, extractable, ["decrypt", "encrypt"]).then(function(result) {
26     keyPair = result;
27     shouldBe("keyPair.toString()", "'[object Object]'");
28     shouldBe("keyPair.publicKey.type", "'public'");
29     shouldBe("keyPair.publicKey.extractable", "true");
30     shouldBe("keyPair.publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
31     shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
32     shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'010001'");
33     shouldBeUndefined("keyPair.publicKey.algorithm.hash");
34     shouldBe("keyPair.publicKey.usages", "['encrypt']");
35     shouldBe("keyPair.privateKey.type", "'private'");
36     shouldBe("keyPair.privateKey.extractable", "true");
37     shouldBe("keyPair.privateKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
38     shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048");
39     shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'010001'");
40     shouldBeUndefined("keyPair.privateKey.algorithm.hash");
41     shouldBe("keyPair.privateKey.usages", "['decrypt']");
42
43     finishJSTest();
44 });
45 </script>
46
47 <script src="../../resources/js-test-post.js"></script>
48 </body>
49 </html>