blob: f4a212cd92e603bb1340eb199dec8a174f4b035f [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-CTR using an imported key");
jsTestIsAsync = true;
var extractable = true;
var rawKey = asciiToUint8Array("jnOw99oOZFLIEPMr");
var aesCtrParams = {
name: "aes-ctr",
counter: asciiToUint8Array("jnOw99oOZFLIEPMr"),
length: 8,
}
var expectWrappedKey = "96be4de93c08cec8b53046ba31deedd35ab9dead0c86fe41b66cca58a6ba2ced4a55915a1991450dcffd50a533b041cf2b981a53c4136682a0f809e801af10a5bd54cac4e3bb7b345405b73e0bfe51141b23f33d714f81ed7067af";
crypto.subtle.importKey("raw", rawKey, "aes-ctr", 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, aesCtrParams);
}).then(function(result) {
wrappedKey = result;
shouldBe("bytesToHexString(wrappedKey)", "expectWrappedKey");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>