blob: f4a14e62bf1d8053dbb39a822a9242d92ecf7d8c [file] [log] [blame]
jiewen_tan@apple.com83b63012016-11-18 21:31:42 +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-CBC with an imported 128bit key");
13
14jsTestIsAsync = true;
15
16var extractable = false;
17var plainText = asciiToUint8Array("Hello, World!");
18var aesCbcParams = {
19 name: "aes-cbc",
20 iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
21}
22var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
23var expectedCipherText = "2ffa4618784dfd414b22c40c6330d022";
24
25crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]).then(function(key) {
26 return crypto.subtle.encrypt(aesCbcParams, key, plainText);
27}).then(function(result) {
28 cipherText = result;
29
30 shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
31
32 finishJSTest();
33});
34
35</script>
36
37<script src="../../resources/js-test-post.js"></script>
38</body>
39</html>