blob: 7da29168203e580d0644889fc0b2e3f8f8e33847 [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 importing a jwk public ECDH key and then export it in jwk format");
jsTestIsAsync = true;
var jwkKey = {
kty: "EC",
use: "enc",
ext: true,
crv: "P-256",
x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
};
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, { name: "ECDH", namedCurve: "P-256" }, extractable, [ ]).then(function(result) {
return crypto.subtle.exportKey("jwk", result);
}).then(function(result) {
publicKey = result;
shouldBe("publicKey.kty", "jwkKey.kty");
shouldBe("publicKey.crv", "jwkKey.crv");
shouldBe("publicKey.x", "jwkKey.x");
shouldBe("publicKey.y", "jwkKey.y");
shouldBe("publicKey.key_ops", "[ ]");
shouldBe("publicKey.ext", "jwkKey.ext");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>