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

Side by Side Diff: LayoutTests/crypto/aes-gcm-parseAlgorithm-failures.html

Issue 790373002: Address a FIXME. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years 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
« no previous file with comments | « no previous file | LayoutTests/crypto/aes-gcm-parseAlgorithm-failures-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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("Tests bad algorithm inputs for AES-GCM"); 12 description("Tests bad algorithm inputs for AES-GCM");
13 13
14 jsTestIsAsync = true; 14 jsTestIsAsync = true;
15 15
16 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c"); 16 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c");
17 var data = asciiToUint8Array("hello"); 17 var data = asciiToUint8Array("hello");
18 var key = null; 18 var key = null;
19 19
20 Promise.resolve(null).then(function(result) { 20 Promise.resolve(null).then(function(result) {
21 var usages = ['encrypt', 'decrypt']; 21 var usages = ['encrypt', 'decrypt'];
22 var extractable = false; 22 var extractable = false;
23 var algorithm = {name: 'aes-gcm'}; 23 var algorithm = {name: 'aes-gcm'};
24 24
25 debug('\nImporting AES-GCM key...');
25 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage s); 26 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage s);
26 }).then(function(result) { 27 }).then(function(result) {
27 key = result; 28 key = result;
28 29
30 debug('\nencrypt() without iv...');
29 return crypto.subtle.encrypt({name: 'AES-gcm'}, key, data); 31 return crypto.subtle.encrypt({name: 'AES-gcm'}, key, data);
30 }).then(failAndFinishJSTest, function(result) { 32 }).then(failAndFinishJSTest, function(result) {
31 logError(result); 33 logError(result);
32 34
35 debug('\nencrypt() with iv that is a number...');
33 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 3}, key, data); 36 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 3}, key, data);
34 }).then(failAndFinishJSTest, function(result) { 37 }).then(failAndFinishJSTest, function(result) {
35 logError(result); 38 logError(result);
36 39
40 debug('\nencrypt() with iv that is a string...');
37 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 'foo'}, key, data); 41 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 'foo'}, key, data);
38 }).then(failAndFinishJSTest, function(result) { 42 }).then(failAndFinishJSTest, function(result) {
39 logError(result); 43 logError(result);
40 44
45 debug('\nencrypt() with additionalData that is a string...');
41 return crypto.subtle.encrypt({name: 'AeS-gcm', iv: new Uint8Array(16), addit ionalData: '5'}, key, data); 46 return crypto.subtle.encrypt({name: 'AeS-gcm', iv: new Uint8Array(16), addit ionalData: '5'}, key, data);
42 }).then(failAndFinishJSTest, function(result) { 47 }).then(failAndFinishJSTest, function(result) {
43 logError(result); 48 logError(result);
44 49
50 debug('\nencrypt() with tagLength that is a string...');
45 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 'foo'}, key, data); 51 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 'foo'}, key, data);
46 }).then(failAndFinishJSTest, function(result) { 52 }).then(failAndFinishJSTest, function(result) {
47 logError(result); 53 logError(result);
48 54
55 debug('\nencrypt() with negative tagLength...');
49 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: -1}, key, data); 56 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: -1}, key, data);
50 }).then(failAndFinishJSTest, function(result) { 57 }).then(failAndFinishJSTest, function(result) {
51 logError(result); 58 logError(result);
52 59
60 debug('\nencrypt() with tagLength larger than an octet...');
53 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 8000}, key, data); 61 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 8000}, key, data);
54 }).then(failAndFinishJSTest, function(result) { 62 }).then(failAndFinishJSTest, function(result) {
55 logError(result); 63 logError(result);
64
65 debug('\nencrypt() with tagLength that is 0...');
66 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 0}, key, data);
67 }).then(failAndFinishJSTest, function(result) {
68 logError(result);
69
70 debug('\nencrypt() with tagLength that is 130...');
jww 2014/12/11 03:42:20 Is it worth throwing in a negative value test, jus
eroman 2014/12/11 03:44:13 There is already a test for -1 on line 55, do you
71 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit ionalData: new Uint8Array(1), tagLength: 130}, key, data);
72 }).then(failAndFinishJSTest, function(result) {
73 logError(result);
56 }).then(finishJSTest, failAndFinishJSTest); 74 }).then(finishJSTest, failAndFinishJSTest);
57 75
58 </script> 76 </script>
59 77
60 </body> 78 </body>
61 </html> 79 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/crypto/aes-gcm-parseAlgorithm-failures-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698