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 decrypting using AES-GCM with malformed parameters"); |
| 13 | |
| 14 | jsTestIsAsync = true; |
| 15 | |
| 16 | var extractable = false; |
| 17 | var smallCipherText = hexStringToUint8Array("f9"); |
| 18 | var corruptedCipherText = hexStringToUint8Array("f9ba1161a16c9fcc726a4531c1b520925e4ba35f8b534c62f34e1f3ba0"); |
| 19 | var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr"); |
| 20 | |
| 21 | crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["decrypt"]).then(function(result) { |
| 22 | key = result; |
| 23 | |
| 24 | // Small cipher text |
| 25 | shouldReject('crypto.subtle.decrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, smallCipherText)'); |
| 26 | |
| 27 | // Corrupted cipher text |
| 28 | return shouldReject('crypto.subtle.decrypt({name: "aes-gcm", iv: asciiToUint8Array("jnOw99oOZFLIEPMrd")}, key, corruptedCipherText)'); |
| 29 | }).then(finishJSTest); |
| 30 | |
| 31 | </script> |
| 32 | |
| 33 | <script src="../../resources/js-test-post.js"></script> |
| 34 | </body> |
| 35 | </html> |