blob: 56b98bd31dbbc04c79f5212bedadd4ea43abe337 [file] [log] [blame]
jiewen_tan@apple.comcc566de2017-03-03 04:24:14 +00001<!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>
12description("Test encrypting using AES-GCM with malformed parameters");
13
14jsTestIsAsync = true;
15
16var extractable = false;
17var plainText = asciiToUint8Array("Hello, World!");
18var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
19
20crypto.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>