blob: a271e8fefd94a1af539be3f123496ebe376e5223 [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 type="text/javascript">
description("Test importing a JWK ECDSA private key");
jsTestIsAsync = true;
var jwkKey = {
kty: "EC",
use: "sig",
ext: false,
key_ops: ["sign"],
crv: "P-256",
x: "1FSVWieTvikFkG1NOyhkUCaMbdQhxwH6aCu4Ez-sRtA",
y: "9jmNTLqM4cjBhdAnHcNI9YQV3O8LFmo-EdZWk8ntAaI",
d: "ppxBSov3N8_AUcisAuvmLV4yE8e_L_BLE8bZb9Z1Xjg",
};
var nonExtractable = false;
debug("Importing a key...");
crypto.subtle.importKey("jwk", jwkKey, { name: "ECDSA", namedCurve: "P-256" }, nonExtractable, ["sign"]).then(function(result) {
privateKey = result;
shouldBe("privateKey.toString()", "'[object CryptoKey]'");
shouldBe("privateKey.type", "'private'");
shouldBe("privateKey.extractable", "false");
shouldBe("privateKey.algorithm.name", "'ECDSA'");
shouldBe("privateKey.algorithm.namedCurve", "'P-256'");
shouldBe("privateKey.usages", "['sign']");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>