jiewen_tan@apple.com | cc566de | 2017-03-03 04:24:14 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <script src="../../resources/js-test-pre.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("Test encrypting using AES-GCM with malformed parameters"); |
| 13 | |
| 14 | jsTestIsAsync = true; |
| 15 | |
| 16 | var extractable = false; |
| 17 | var plainText = asciiToUint8Array("Hello, World!"); |
| 18 | var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr"); |
| 19 | |
| 20 | crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["encrypt"]).then(function(result) { |
| 21 | key = result; |
| 22 | |
| 23 | // Wrong tag length |
| 24 | shouldReject('crypto.subtle.encrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd"), tagLength: 0}, key, plainText)'); |
| 25 | shouldReject('crypto.subtle.encrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd"), tagLength: -1}, key, plainText)'); |
| 26 | shouldReject('crypto.subtle.encrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd"), tagLength: 129}, key, plainText)'); |
| 27 | shouldReject('crypto.subtle.encrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd"), tagLength: 70}, key, plainText)'); |
| 28 | |
| 29 | finishJSTest(); |
| 30 | }); |
| 31 | |
| 32 | </script> |
| 33 | |
| 34 | <script src="../../resources/js-test-post.js"></script> |
| 35 | </body> |
| 36 | </html> |