[WebIDL] Add support for converting dictionaries to JS
[WebKit-https.git] / LayoutTests / crypto / workers / subtle / resources / rsa-generate-key.js
1 importScripts('../../../../resources/js-test-pre.js');
2 importScripts("../../../resources/common.js");
3
4 description("Test generating a RSA keypair using RSA-OAEP algorithm in workers.");
5 jsTestIsAsync = true;
6
7 var extractable = true;
8 var publicExponent = new Uint8Array([0x01, 0x00, 0x01]);
9
10 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign"])');
11 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])').then(function() {
12     debug("Generating a key...");
13     return crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: 'sha-1'}, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]);
14 }).then(function(result) {
15     keyPair = result;
16     shouldBe("keyPair.toString()", "'[object Object]'");
17     shouldBe("keyPair.publicKey.type", "'public'");
18     shouldBe("keyPair.publicKey.extractable", "true");
19     shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
20     shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
21     shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'010001'");
22     shouldBe("keyPair.publicKey.algorithm.hash.name", "'SHA-1'");
23     shouldBe("keyPair.publicKey.usages", "['encrypt', 'wrapKey']");
24     shouldBe("keyPair.privateKey.type", "'private'");
25     shouldBe("keyPair.privateKey.extractable", "true");
26     shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'");
27     shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048");
28     shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "'010001'");
29     shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'");
30     shouldBe("keyPair.privateKey.usages", "['decrypt', 'unwrapKey']");
31
32     finishJSTest();
33 });