aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/examples/keygen-html/src/glue.js
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2018-03-01 02:14:50 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2018-03-02 16:42:29 +0100
commit9d5baf7d1d14ca7eb0852b41566330259229d489 (patch)
tree6a48ccfef59a25d49551ccff71619f807a6548a8 /contrib/examples/keygen-html/src/glue.js
parentcontrib: keygen-html: rewrite in pure javascript (diff)
downloadwireguard-monolithic-historical-9d5baf7d1d14ca7eb0852b41566330259229d489.tar.xz
wireguard-monolithic-historical-9d5baf7d1d14ca7eb0852b41566330259229d489.zip
Revert "contrib: keygen-html: rewrite in pure javascript"
This reverts commit e5203543a674453ce1e0cbbcb234d3308762fe65. As swanky as it is to have a really short file, it's hard to justify and makes me nervous.
Diffstat (limited to '')
-rw-r--r--contrib/examples/keygen-html/src/glue.js25
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/examples/keygen-html/src/glue.js b/contrib/examples/keygen-html/src/glue.js
new file mode 100644
index 0000000..981e533
--- /dev/null
+++ b/contrib/examples/keygen-html/src/glue.js
@@ -0,0 +1,25 @@
+/*! SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2015-2018 Jason A. Donenfeld <Jason@zx2c4.com>. All Rights Reserved.
+ */
+window["WireGuard"] = {
+ "generateKeypair": function() {
+ var privateKey = Module["_malloc"](32);
+ var publicKey = Module["_malloc"](32);
+ Module["_curve25519_generate_private"](privateKey);
+ Module["_curve25519_generate_public"](publicKey, privateKey);
+ var privateBase64 = Module["_malloc"](45);
+ var publicBase64 = Module["_malloc"](45);
+ Module["_key_to_base64"](privateBase64, privateKey);
+ Module["_key_to_base64"](publicBase64, publicKey);
+ Module["_free"](privateKey);
+ Module["_free"](publicKey);
+ var keypair = {
+ publicKey: Module["Pointer_stringify"](publicBase64),
+ privateKey: Module["Pointer_stringify"](privateBase64)
+ };
+ Module["_free"](privateBase64);
+ Module["_free"](publicBase64);
+ return keypair;
+ }
+};