blob: 39de5c5ae0f3bea2e56175756bc172d2792fdfe2 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
<script src="../resources/common.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test encrypting using AES-GCM with an imported 128bit key and additional data");
jsTestIsAsync = true;
var extractable = false;
var plainText = asciiToUint8Array("Hello, World!");
var aesGcmParams = {
name: "aes-gcm",
iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
additionalData: asciiToUint8Array("jnOw99oOZFLIEPMr"),
}
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var expectedCipherText = "f9ba1161a16c9fcc726a4531c110d8e4f966a8cb8291e0c378f99b846d";
crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["encrypt"]).then(function(key) {
return crypto.subtle.encrypt(aesGcmParams, key, plainText);
}).then(function(result) {
cipherText = result;
shouldBe("bytesToHexString(cipherText)", "expectedCipherText");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>