Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(298)

Side by Side Diff: LayoutTests/crypto/rsa-oaep-key-manipulation.html

Issue 333063004: Speed up slow tests by reducing RSA modulus size (from 2048 --> 512). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add more tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../resources/js-test.js"></script> 4 <script src="../resources/js-test.js"></script>
5 <script src="resources/common.js"></script> 5 <script src="resources/common.js"></script>
6 </head> 6 </head>
7 <body> 7 <body>
8 <p id="description"></p> 8 <p id="description"></p>
9 <div id="console"></div> 9 <div id="console"></div>
10 10
11 <script> 11 <script>
12 description("Test generating, importing and exporting RSA keys for RSA-OAEP. Tes t that they can't be used with another algorithm."); 12 description("Test generating, importing and exporting RSA keys for RSA-OAEP. Tes t that they can't be used with another algorithm.");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 var algorithmKeyGen = { 16 var algorithmKeyGen = {
17 name: "RSA-OAEP", 17 name: "RSA-OAEP",
18 hash: {name: "sha-1"}, 18 hash: {name: "sha-1"},
19 // RsaKeyGenParams 19 // RsaKeyGenParams
20 modulusLength: 2048, 20 modulusLength: 512,
21 publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537 21 publicExponent: new Uint8Array([0x01, 0x00, 0x01]), // Equivalent to 65537
22 }; 22 };
23 var extractable = true; 23 var extractable = true;
24 24
25 debug("Generating a key pair..."); 25 debug("Generating a key pair...");
26 crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", " wrapKey", "unwrapKey"]).then(function(result) { 26 crypto.subtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", " wrapKey", "unwrapKey"]).then(function(result) {
27 keyPair = result; 27 keyPair = result;
28 shouldBe("keyPair.toString()", "'[object KeyPair]'"); 28 shouldBe("keyPair.toString()", "'[object KeyPair]'");
29 shouldBe("keyPair.publicKey.type", "'public'"); 29 shouldBe("keyPair.publicKey.type", "'public'");
30 shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'"); 30 shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
31 shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048"); 31 shouldBe("keyPair.publicKey.algorithm.modulusLength", "512");
32 shouldBe("keyPair.publicKey.usages", '["encrypt", "wrapKey"]'); 32 shouldBe("keyPair.publicKey.usages", '["encrypt", "wrapKey"]');
33 shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'0 10001'"); 33 shouldBe("bytesToHexString(keyPair.publicKey.algorithm.publicExponent)", "'0 10001'");
34 shouldBe("keyPair.publicKey.algorithm.hash.name", "'SHA-1'"); 34 shouldBe("keyPair.publicKey.algorithm.hash.name", "'SHA-1'");
35 shouldBe("keyPair.privateKey.type", "'private'"); 35 shouldBe("keyPair.privateKey.type", "'private'");
36 shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'"); 36 shouldBe("keyPair.privateKey.algorithm.name", "'RSA-OAEP'");
37 shouldBe("keyPair.privateKey.algorithm.modulusLength", "2048"); 37 shouldBe("keyPair.privateKey.algorithm.modulusLength", "512");
38 shouldBe("keyPair.privateKey.usages", '["decrypt", "unwrapKey"]'); 38 shouldBe("keyPair.privateKey.usages", '["decrypt", "unwrapKey"]');
39 shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "' 010001'"); 39 shouldBe("bytesToHexString(keyPair.privateKey.algorithm.publicExponent)", "' 010001'");
40 shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'"); 40 shouldBe("keyPair.privateKey.algorithm.hash.name", "'SHA-1'");
41 41
42 debug("\nTesting that the keys can't be used with different algorithms..."); 42 debug("\nTesting that the keys can't be used with different algorithms...");
43 iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f"); 43 iv = hexStringToUint8Array("000102030405060708090a0b0c0d0e0f");
44 44
45 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey, hexStringToUint8Array("00")); 45 return crypto.subtle.encrypt({name: "aes-cbc", iv: iv}, keyPair.privateKey, hexStringToUint8Array("00"));
46 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) { 46 }, failAndFinishJSTest).then(failAndFinishJSTest, function(result) {
47 logError(result); 47 logError(result);
(...skipping 21 matching lines...) Expand all
69 shouldBe("jwkPublicKey.use", "undefined"); 69 shouldBe("jwkPublicKey.use", "undefined");
70 shouldBe("jwkPublicKey.kty", "'RSA'"); 70 shouldBe("jwkPublicKey.kty", "'RSA'");
71 shouldBe("bytesToHexString(Base64URL.parse(jwkPublicKey.e))", "'010001'"); 71 shouldBe("bytesToHexString(Base64URL.parse(jwkPublicKey.e))", "'010001'");
72 72
73 debug("\nImporting it back..."); 73 debug("\nImporting it back...");
74 return crypto.subtle.importKey("jwk", jwkPublicKeyArray, { name: "RSA-OAEP", hash: {name: "sha-1"} }, extractable, ["encrypt", "wrapKey"]); 74 return crypto.subtle.importKey("jwk", jwkPublicKeyArray, { name: "RSA-OAEP", hash: {name: "sha-1"} }, extractable, ["encrypt", "wrapKey"]);
75 }).then(function(result) { 75 }).then(function(result) {
76 exportedPublicKey = result; 76 exportedPublicKey = result;
77 shouldBe("exportedPublicKey.type", "'public'"); 77 shouldBe("exportedPublicKey.type", "'public'");
78 shouldBe("exportedPublicKey.algorithm.name", "'RSA-OAEP'"); 78 shouldBe("exportedPublicKey.algorithm.name", "'RSA-OAEP'");
79 shouldBe("exportedPublicKey.algorithm.modulusLength", "2048"); 79 shouldBe("exportedPublicKey.algorithm.modulusLength", "512");
80 shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'0 10001'"); 80 shouldBe("bytesToHexString(exportedPublicKey.algorithm.publicExponent)", "'0 10001'");
81 shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'"); 81 shouldBe("exportedPublicKey.algorithm.hash.name", "'SHA-1'");
82 shouldBe("exportedPublicKey.extractable", "true"); 82 shouldBe("exportedPublicKey.extractable", "true");
83 shouldBe("exportedPublicKey.usages", "['encrypt','wrapKey']"); 83 shouldBe("exportedPublicKey.usages", "['encrypt','wrapKey']");
84 84
85 }).then(finishJSTest, failAndFinishJSTest); 85 }).then(finishJSTest, failAndFinishJSTest);
86 86
87 </script> 87 </script>
88 88
89 </body> 89 </body>
90 </html> 90 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698