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