| OLD | NEW |
| 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 exportKey() given bad inputs."); | 12 description("Tests generateKey() with bad AES-CTR parameters."); |
| 13 | |
| 14 jsTestIsAsync = true; | 13 jsTestIsAsync = true; |
| 15 | 14 |
| 16 // Not keys | 15 extractable = true; |
| 17 shouldThrow("crypto.subtle.exportKey('raw', null)"); | 16 keyUsages = ['encrypt', 'decrypt']; |
| 18 shouldThrow("crypto.subtle.exportKey('raw', 3)"); | |
| 19 | 17 |
| 20 function importAesKey() | 18 Promise.resolve(null).then(function() { |
| 21 { | 19 return crypto.subtle.generateKey({ name: 'aes-ctr' }, extractable, keyUsages
); |
| 22 var keyData = new Uint8Array(16); | |
| 23 var usages = ['encrypt']; | |
| 24 var extractable = true; | |
| 25 var algorithm = {name: 'aes-cbc'}; | |
| 26 | |
| 27 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
| 28 } | |
| 29 | |
| 30 importAesKey().then(function(result) { | |
| 31 key = result; | |
| 32 | |
| 33 // Invalid export format | |
| 34 return crypto.subtle.exportKey(3, key); | |
| 35 }).then(failAndFinishJSTest, function(result) { | 20 }).then(failAndFinishJSTest, function(result) { |
| 36 error = result; | 21 error = result; |
| 37 shouldBeNull("error"); | 22 shouldBeNull("error"); |
| 38 | 23 |
| 39 // Invalid export format | 24 return crypto.subtle.generateKey({ name: 'aes-ctr', length: 70000 }, extract
able, keyUsages); |
| 40 return crypto.subtle.exportKey(null, key); | |
| 41 }).then(failAndFinishJSTest, function(result) { | 25 }).then(failAndFinishJSTest, function(result) { |
| 42 error = result; | 26 error = result; |
| 43 shouldBeNull("error"); | 27 shouldBeNull("error"); |
| 44 | 28 |
| 45 // Invalid export format | 29 return crypto.subtle.generateKey({ name: 'aes-ctr', length: -3 }, extractabl
e, keyUsages); |
| 46 return crypto.subtle.exportKey('invalid', key); | |
| 47 }).then(failAndFinishJSTest, function(result) { | 30 }).then(failAndFinishJSTest, function(result) { |
| 48 error = result; | 31 error = result; |
| 49 shouldBeNull("error"); | 32 shouldBeNull("error"); |
| 33 |
| 34 return crypto.subtle.generateKey({ name: 'aes-ctr', length: -Infinity }, ext
ractable, keyUsages); |
| 35 }).then(failAndFinishJSTest, function(result) { |
| 36 error = result; |
| 37 shouldBeNull("error"); |
| 50 }).then(finishJSTest, failAndFinishJSTest); | 38 }).then(finishJSTest, failAndFinishJSTest); |
| 51 | 39 |
| 52 </script> | 40 </script> |
| 53 | 41 |
| 54 </body> | 42 </body> |
| 55 </html> | 43 </html> |
| OLD | NEW |