| <!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-256 SPKI ECDH key and exporting it in SPKI format"); |
| |
| jsTestIsAsync = true; |
| |
| var spkiKeyHex = "3059301306072a8648ce3d020106082a8648ce3d03010703420004c3ee3a2c3380072b9b2a59fed2cada65121806e22c4f4f8a25e740fc3e54d75d86c200298e6dfc1611d185eedbdb3c2661b0eb0441f7fd57c90d08112e9ae71c"; |
| var spkiKey = hexStringToUint8Array(spkiKeyHex); |
| 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("spki", key); |
| }).then(function(result) { |
| publicKey = result; |
| |
| shouldBe("bytesToHexString(publicKey)", "spkiKeyHex"); |
| |
| finishJSTest(); |
| }); |
| |
| </script> |
| |
| <script src="../../resources/js-test-post.js"></script> |
| </body> |
| </html> |