| 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-CBC"); | |
| 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 var algorithm = {name: 'aes-cbc'}; | |
| 24 | |
| 25 debug('\nImporting AES-CBC key...'); | |
| 26 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); | |
| 27 }).then(function(result) { | |
| 28 key = result; | |
| 29 | |
| 30 debug('\nencrypt() with iv that is null...'); | |
| 31 return crypto.subtle.encrypt({name: 'AES-CBC', iv: null}, key, data); | |
| 32 }).then(failAndFinishJSTest, function(result) { | |
| 33 logError(result); | |
| 34 | |
| 35 debug('\nencrypt() without iv...'); | |
| 36 return crypto.subtle.decrypt({name: 'AES-CBC'}, key, data); | |
| 37 }).then(failAndFinishJSTest, function(result) { | |
| 38 logError(result); | |
| 39 | |
| 40 debug('\nencrypt() with iv that is a number...'); | |
| 41 return crypto.subtle.encrypt({name: 'AES-CBC', iv: 3}, key, data); | |
| 42 }).then(failAndFinishJSTest, function(result) { | |
| 43 logError(result); | |
| 44 | |
| 45 debug('\nencrypt() with an iv containing 0 bytes...'); | |
| 46 return crypto.subtle.encrypt({name: 'AES-CBC', iv: new Uint8Array(0)}, key,
data); | |
| 47 }).then(failAndFinishJSTest, function(result) { | |
| 48 logError(result); | |
| 49 | |
| 50 debug('\nencrypt() with an iv containing 17 bytes...'); | |
| 51 return crypto.subtle.encrypt({name: 'AES-CBC', iv: new ArrayBuffer(17)}, key
, data); | |
| 52 }).then(failAndFinishJSTest, function(result) { | |
| 53 logError(result); | |
| 54 }).then(finishJSTest, failAndFinishJSTest); | |
| 55 | |
| 56 </script> | |
| 57 | |
| 58 </body> | |
| 59 </html> | |
| OLD | NEW |