46 lines
1.2 KiB
HTML
46 lines
1.2 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 importing a JWK AES-CBC key with legnth 128 and then export it in JWK format");
|
|
|
|
jsTestIsAsync = true;
|
|
|
|
var jwkKey = {
|
|
kty: "oct",
|
|
k: "KbXExKw7lIKkvDHi4ud3lg",
|
|
alg: "A128CBC",
|
|
key_ops: ["decrypt", "encrypt", "unwrapKey", "wrapKey"],
|
|
ext: true,
|
|
};
|
|
var extractable = true;
|
|
|
|
debug("Importing a key...");
|
|
crypto.subtle.importKey("jwk", jwkKey, "aes-cbc", extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(cryptoKey) {
|
|
debug("Exporting a key...");
|
|
return crypto.subtle.exportKey("jwk", cryptoKey);
|
|
}).then(function(result) {
|
|
exportedJwkKey = result;
|
|
|
|
shouldBe("exportedJwkKey.kty", "jwkKey.kty");
|
|
shouldBe("exportedJwkKey.k", "jwkKey.k");
|
|
shouldBe("exportedJwkKey.alg", "jwkKey.alg");
|
|
shouldBe("exportedJwkKey.key_ops", "jwkKey.key_ops");
|
|
shouldBe("exportedJwkKey.ext", "jwkKey.ext");
|
|
|
|
finishJSTest();
|
|
});
|
|
|
|
</script>
|
|
|
|
<script src="../../resources/js-test-post.js"></script>
|
|
</body>
|
|
</html>
|