blob: 16613309695a3a011fa8dc13a97f0c5180e7adad [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 P-384 PKCS8 ECDH key and exporting it in PKCS8 format");
jsTestIsAsync = true;
var pkcs8KeyHex = "3081b6020100301006072a8648ce3d020106052b8104002204819e30819b02010104307fdf264b53c1a5e0c6be32f6736a73591f6a2d536c5ac6906b19ebe371ab71ec84c2b102def67aa0db451382604fb21aa1640362000413dcd0e8352158ca1ee5807c3f91d3b7331942baf7a48b0e3ad28fb6b665b1d8188dc01415058dbdb141f81e7cbf595861b1617b3deb5360b7e3dd0e48b92cdf957117cdefa77bc8f797b5b73a614028a83fc123a48c74eec9ca3c3e89322d57";
var pkcs8Key = hexStringToUint8Array(pkcs8KeyHex);
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("pkcs8", pkcs8Key, {name: "ECDH", namedCurve: "P-384"}, extractable, ["deriveKey", "deriveBits"]).then(function(key) {
return crypto.subtle.exportKey("pkcs8", key);
}).then(function(result) {
privateKey = result;
shouldBe("bytesToHexString(privateKey)", "pkcs8KeyHex");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>