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-GCM"); |
| 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-gcm'}; |
| 24 |
| 25 return crypto.subtle.importKey('raw', keyData, algorithm, extractable, usage
s); |
| 26 }).then(function(result) { |
| 27 key = result; |
| 28 |
| 29 return crypto.subtle.encrypt({name: 'AES-gcm'}, key, data); |
| 30 }).then(failAndFinishJSTest, function(result) { |
| 31 error = result; |
| 32 shouldBeNull("error"); |
| 33 |
| 34 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 3}, key, data); |
| 35 }).then(failAndFinishJSTest, function(result) { |
| 36 error = result; |
| 37 shouldBeNull("error"); |
| 38 |
| 39 return crypto.subtle.encrypt({name: 'AES-gcm', iv: 'foo'}, key, data); |
| 40 }).then(failAndFinishJSTest, function(result) { |
| 41 error = result; |
| 42 shouldBeNull("error"); |
| 43 |
| 44 return crypto.subtle.encrypt({name: 'AeS-gcm', iv: new Uint8Array(16), addit
ionalData: '5'}, key, data); |
| 45 }).then(failAndFinishJSTest, function(result) { |
| 46 error = result; |
| 47 shouldBeNull("error"); |
| 48 |
| 49 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit
ionalData: new Uint8Array(1), tagLength: 'foo'}, key, data); |
| 50 }).then(failAndFinishJSTest, function(result) { |
| 51 error = result; |
| 52 shouldBeNull("error"); |
| 53 |
| 54 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit
ionalData: new Uint8Array(1), tagLength: -1}, key, data); |
| 55 }).then(failAndFinishJSTest, function(result) { |
| 56 error = result; |
| 57 shouldBeNull("error"); |
| 58 |
| 59 return crypto.subtle.encrypt({name: 'AES-gcm', iv: new Uint8Array(16), addit
ionalData: new Uint8Array(1), tagLength: 8000}, key, data); |
| 60 }).then(failAndFinishJSTest, function(result) { |
| 61 error = result; |
| 62 shouldBeNull("error"); |
| 63 }).then(finishJSTest, failAndFinishJSTest); |
| 64 |
| 65 </script> |
| 66 |
| 67 </body> |
| 68 </html> |
OLD | NEW |