blob: d0adfd872c7aef1317229b8f599c967c4033c5f6 [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 wrapping a JWK key with AES-GCM using an imported key");
jsTestIsAsync = true;
var extractable = true;
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var aesGcmParams = {
name: "aes-gcm",
iv: asciiToUint8Array("jnOw99oOZFLIEPMr"),
}
var expectWrappedKey = "cafd1c61a96285b95c291b6da304a8be03010b8f96e39fc5076d6c6d8a2a6a669fc76f425ad095b9c18eae86a3f9895998b912807840bcb8bfa9493bed2e27169bd7d61d834e38d0644543195a10c3f9d7e19703244b62e11408663ff142cf2f0c29a6c9df7555f2f77ba0";
crypto.subtle.importKey("raw", rawKey, "aes-gcm", extractable, ["wrapKey"]).then(function(result) {
wrappingKey = result;
return crypto.subtle.importKey("raw", rawKey, "aes-cbc", extractable, ["encrypt"]);
}).then(function(result) {
key = result;
return crypto.subtle.wrapKey("jwk", key, wrappingKey, aesGcmParams);
}).then(function(result) {
wrappedKey = result;
shouldBe("bytesToHexString(wrappedKey)", "expectWrappedKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>