blob: f7fcf4fe9c4e4eb0d05ab190809a7faacb09d649 [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 unwrapping an RSA key with AES-CBC.");
jsTestIsAsync = true;
var extractable = true;
var nonExtractable = false;
var unwrappingKeyOctets = hexStringToUint8Array("2a00e0e776e94e4dc89bf947cebdebe1");
var wrappedKey = hexStringToUint8Array("b490dedb3abc3fd545e146538e6cc3ca"); // An empty encrypted JSON.
debug("Importing an unwrapping key...");
crypto.subtle.importKey("raw", unwrappingKeyOctets, "AES-CBC", nonExtractable, ["unwrapKey"]).then(function(result) {
unwrappingKey = result;
shouldBe("unwrappingKey.algorithm.name", "'AES-CBC'");
var unwrapAlgorithm = {name: "AES-CBC", iv: hexStringToUint8Array("000102030405060708090a0b0c0d0e0f")};
debug("Unwrapping a key...");
return crypto.subtle.unwrapKey("jwk", wrappedKey, unwrappingKey, unwrapAlgorithm, null, extractable, ["sign", "verify", "encrypt", "decrypt", "wrap", "unwrap"]);
}).then(undefined, function(result) {
testPassed("Promise rejected");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>