aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/contrib/examples/keygen-html/src/glue.js
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2017-12-12 01:08:18 +0100
committerJason A. Donenfeld <Jason@zx2c4.com>2017-12-12 01:18:30 +0100
commit037c389f2f09f721ecc84105b0d5d0ca8824c070 (patch)
treea9e2aabd9a92235ca438f18bac5633ea20094c04 /contrib/examples/keygen-html/src/glue.js
parentversion: bump snapshot (diff)
downloadwireguard-monolithic-historical-037c389f2f09f721ecc84105b0d5d0ca8824c070.tar.xz
wireguard-monolithic-historical-037c389f2f09f721ecc84105b0d5d0ca8824c070.zip
keygen-html: remove prebuilt file
We also reduce the optimization level, just in case, but add closure compiler into the mix. Suggested-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
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..f79c383
--- /dev/null
+++ b/contrib/examples/keygen-html/src/glue.js
@@ -0,0 +1,25 @@
+/*! SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright (C) 2015-2017 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;
+ }
+};