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

Side by Side Diff: LayoutTests/crypto/importKey.html

Issue 206483010: [webcrypto] Refactor some layout tests. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 <script src="resources/keys.js"></script>
6 </head> 7 </head>
7 <body> 8 <body>
8 <p id="description"></p> 9 <p id="description"></p>
9 <div id="console"></div> 10 <div id="console"></div>
10 11
11 <script> 12 <script>
12 description("Tests cypto.subtle.importKey."); 13 description("Tests cypto.subtle.importKey.");
13 14
14 jsTestIsAsync = true; 15 jsTestIsAsync = true;
15 16
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 algorithm = aesCbc; 71 algorithm = aesCbc;
71 extractable = false; 72 extractable = false;
72 keyUsages = []; 73 keyUsages = [];
73 74
74 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages); 75 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages);
75 }).then(undefined, function(result) { 76 }).then(undefined, function(result) {
76 debug("rejected with " + result); 77 debug("rejected with " + result);
77 78
78 // Import an spki formatted public key 79 // Import an spki formatted public key
79 keyFormat = "spki"; 80 keyFormat = "spki";
80 data = hexStringToUint8Array(kPublicKeySpkiDerHex); 81 data = hexStringToUint8Array(kKeyData.rsa1.spki);
81 algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; 82 algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}};
82 extractable = false; 83 extractable = false;
83 keyUsages = []; 84 keyUsages = [];
84 85
85 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages); 86 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages);
86 }).then(function(result) { 87 }).then(function(result) {
87 key = result; 88 key = result;
88 shouldBe("key.type", "'public'"); 89 shouldBe("key.type", "'public'");
89 // FIXME: Enable this once updated. 90 // FIXME: Enable this once updated.
90 //shouldBe("key.extractable", "true"); 91 //shouldBe("key.extractable", "true");
91 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); 92 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
92 shouldBe("key.algorithm.hash.name", '"SHA-1"'); 93 shouldBe("key.algorithm.hash.name", '"SHA-1"');
93 shouldBe("key.algorithm.modulusLength", '1024'); 94 shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthB its);
94 bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo rithm.publicExponent); 95 bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publ icExponent, key.algorithm.publicExponent);
95 shouldBe("key.usages.join(',')", "''"); 96 shouldBe("key.usages.join(',')", "''");
96 97
97 // Import a pkcs8 formatted private key 98 // Import a pkcs8 formatted private key
98 keyFormat = "pkcs8"; 99 keyFormat = "pkcs8";
99 data = hexStringToUint8Array(kPrivateKeyPkcs8DerHex); 100 data = hexStringToUint8Array(kKeyData.rsa1.pkcs8);
100 algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}}; 101 algorithm = {name: 'RsasSA-pKCS1-v1_5', hash: {name: 'sha-1'}};
101 extractable = false; 102 extractable = false;
102 keyUsages = []; 103 keyUsages = [];
103 104
104 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages); 105 return crypto.subtle.importKey(keyFormat, data, algorithm, extractable, keyU sages);
105 }).then(function(result) { 106 }).then(function(result) {
106 key = result; 107 key = result;
107 shouldBe("key.type", "'private'"); 108 shouldBe("key.type", "'private'");
108 shouldBe("key.extractable", "false"); 109 shouldBe("key.extractable", "false");
109 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'"); 110 shouldBe("key.algorithm.name", "'RSASSA-PKCS1-v1_5'");
110 shouldBe("key.algorithm.hash.name", '"SHA-1"'); 111 shouldBe("key.algorithm.hash.name", '"SHA-1"');
111 shouldBe("key.algorithm.modulusLength", '1024'); 112 shouldEvaluateAs("key.algorithm.modulusLength", kKeyData.rsa1.modulusLengthB its);
112 bytesShouldMatchHexString("key.algorithm.publicExponent", "010001", key.algo rithm.publicExponent); 113 bytesShouldMatchHexString("key.algorithm.publicExponent", kKeyData.rsa1.publ icExponent, key.algorithm.publicExponent);
113 shouldBe("key.usages.join(',')", "''") 114 shouldBe("key.usages.join(',')", "''")
114 115
115 keyFormat = "raw"; 116 keyFormat = "raw";
116 data = asciiToUint8Array(""); 117 data = asciiToUint8Array("");
117 algorithm = aesCbc; 118 algorithm = aesCbc;
118 extractable = true; 119 extractable = true;
119 keyUsages = []; 120 keyUsages = [];
120 121
121 // Invalid format. 122 // Invalid format.
122 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data, algorithm, extractable, keyUsages)"); 123 shouldRejectPromiseWithNull("crypto.subtle.importKey('invalid format', data, algorithm, extractable, keyUsages)");
(...skipping 20 matching lines...) Expand all
143 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'hmac'}, extractable, keyUsages)"); 144 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'hmac'}, extractable, keyUsages)");
144 145
145 // SHA-1 doesn't support the importKey operation. 146 // SHA-1 doesn't support the importKey operation.
146 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'sha-1'}, extractable, keyUsages)"); 147 shouldRejectPromiseWithNull("crypto.subtle.importKey(keyFormat, data, {name: 'sha-1'}, extractable, keyUsages)");
147 }).then(finishJSTest, failAndFinishJSTest); 148 }).then(finishJSTest, failAndFinishJSTest);
148 149
149 </script> 150 </script>
150 151
151 </body> 152 </body>
152 </html> 153 </html>
OLDNEW
« no previous file with comments | « LayoutTests/crypto/import-aes-key-bad-length-expected.txt ('k') | LayoutTests/crypto/resources/common.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698