Update SubtleCrypto::generateKey to match the latest spec
[WebKit-https.git] / LayoutTests / crypto / subtle / rsa-generate-key-malformed-parameters.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 with malformed-paramters.");
13
14 jsTestIsAsync = true;
15
16 var extractable = true;
17 var publicExponent = new Uint8Array([0x01, 0x00, 0x01]);
18
19 // Malformed AlgorithmIdentifiers
20 shouldReject('crypto.subtle.generateKey("RSAES-PKCS1-v1_5", extractable, ["encrypt", "decrypt"])');
21 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5"}, extractable, ["encrypt", "decrypt"])');
22 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: undefined, publicExponent: publicExponent}, extractable, ["encrypt", "decrypt"])');
23 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: Symbol(), publicExponent: publicExponent}, extractable, ["encrypt", "decrypt"])');
24 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: 1}, extractable, ["encrypt", "decrypt"])');
25 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: true}, extractable, ["encrypt", "decrypt"])');
26 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: null}, extractable, ["encrypt", "decrypt"])');
27 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: undefined}, extractable, ["encrypt", "decrypt"])');
28 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: { }}, extractable, ["encrypt", "decrypt"])');
29 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: Symbol()}, extractable, ["encrypt", "decrypt"])');
30 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: "foo"}, extractable, ["encrypt", "decrypt"])');
31 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: [ ]}, extractable, ["encrypt", "decrypt"])');
32 // Missing hash
33 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["sign", "verify"])');
34 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["decrypt", "encrypt"])');
35 // Wrong usages
36 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["sign"])');
37 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["verify"])');
38 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["deriveKey"])');
39 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["deriveBits"])');
40 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["wrapKey"])');
41 shouldReject('crypto.subtle.generateKey({name: "RSAES-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent}, extractable, ["unwrapKey"])');
42 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["encrypt"])');
43 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["decrypt"])');
44 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveKey"])');
45 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveBits"])');
46 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["wrapKey"])');
47 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["unwrapKey"])');
48 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign"])');
49 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["verify"])');
50 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveKey"])');
51 shouldReject('crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["deriveBits"])');
52 // modulusLength = 0
53 shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"])', finishJSTest);
54 </script>
55
56 <script src="../../resources/js-test-post.js"></script>
57 </body>
58 </html>