OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <html> |
| 3 <head> |
| 4 <script src="../resources/js-test.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("Tests bad algorithm inputs for AES-CTR"); |
| 13 |
| 14 jsTestIsAsync = true; |
| 15 |
| 16 var keyData = hexStringToUint8Array("2b7e151628aed2a6abf7158809cf4f3c"); |
| 17 var data = asciiToUint8Array("hello"); |
| 18 var key = null; |
| 19 |
| 20 Promise.resolve(null).then(function(result) { |
| 21 var usages = ['encrypt', 'decrypt']; |
| 22 var extractable = false; |
| 23 // FIXME: Should use aes-ctr here. |
| 24 var algorithm = {name: 'aes-cbc'}; |
| 25 |
| 26 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); |
| 27 }).then(function(result) { |
| 28 key = result; |
| 29 |
| 30 return crypto.subtle.encrypt({name: 'AES-CTR', counter: null}, key, data); |
| 31 }).then(failAndFinishJSTest, function(result) { |
| 32 error = result; |
| 33 shouldBeNull("error"); |
| 34 |
| 35 return crypto.subtle.encrypt({name: 'AES-CTR'}, key, data); |
| 36 }).then(failAndFinishJSTest, function(result) { |
| 37 error = result; |
| 38 shouldBeNull("error"); |
| 39 |
| 40 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(0)},
key, data); |
| 41 }).then(failAndFinishJSTest, function(result) { |
| 42 error = result; |
| 43 shouldBeNull("error"); |
| 44 |
| 45 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: 256}, key, data); |
| 46 }).then(failAndFinishJSTest, function(result) { |
| 47 error = result; |
| 48 shouldBeNull("error"); |
| 49 |
| 50 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: -3}, key, data); |
| 51 }).then(failAndFinishJSTest, function(result) { |
| 52 error = result; |
| 53 shouldBeNull("error"); |
| 54 |
| 55 return crypto.subtle.encrypt({name: 'AES-CTR', counter: new Uint8Array(16),
length: Infinity}, key, data); |
| 56 }).then(failAndFinishJSTest, function(result) { |
| 57 error = result; |
| 58 shouldBeNull("error"); |
| 59 }).then(finishJSTest, failAndFinishJSTest); |
| 60 |
| 61 </script> |
| 62 |
| 63 </body> |
| 64 </html> |
OLD | NEW |