42 lines
1.1 KiB
HTML
42 lines
1.1 KiB
HTML
<!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 decrypting using AES-GCM with an imported 128bit key, additional data, and tagLength 32");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var extractable = false;
|
|
var cipherText = hexStringToUint8Array("f9ba1161a16c9fcc726a4531c110d8e4f9");
|
|
var aesGcmParams = {
|
|
name: "aes-gcm",
|
|
iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
|
|
additionalData: asciiToUint8Array("jnOw99oOZFLIEPMr"),
|
|
tagLength: 32
|
|
}
|
|
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
|
|
var expectedPlainText = "Hello, World!";
|
|
|
|
crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["decrypt"]).then(function(key) {
|
|
return crypto.subtle.decrypt(aesGcmParams, key, cipherText);
|
|
}).then(function(result) {
|
|
plainText = result;
|
|
|
|
shouldBe("bytesToASCIIString(plainText)", "expectedPlainText");
|
|
|
|
finishJSTest();
|
|
});
|
|
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|