blob: 4c317c6a0af7351d493dc5ae5a5626c8b1d7f48f [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 raw ECDH key and then export it in raw format");
jsTestIsAsync = true;
var rawKeyHex = "04dc08d9bf603333eab1ad29cef41a6203ab6ecce03c5a4a9bf5771a3fb9f971d89a09664bfb87c61199b3453220eadec714c49ad1e24bf5d7ec5bddeca6420893";
var rawKey = hexStringToUint8Array(rawKeyHex);
var extractable = true;
debug("Importing a key...");
crypto.subtle.importKey("raw", rawKey, {name: "ECDH", namedCurve: "P-256"}, extractable, [ ]).then(function(publicKey) {
return crypto.subtle.exportKey("raw", publicKey);
}).then(function(result) {
publicKey = result;
shouldBe("bytesToHexString(publicKey)", "rawKeyHex");
finishJSTest();
});
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>