diff options
author | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-12-12 01:08:18 +0100 |
---|---|---|
committer | Jason A. Donenfeld <Jason@zx2c4.com> | 2017-12-12 01:18:30 +0100 |
commit | 037c389f2f09f721ecc84105b0d5d0ca8824c070 (patch) | |
tree | a9e2aabd9a92235ca438f18bac5633ea20094c04 /contrib/examples/keygen-html/src/glue.js | |
parent | version: bump snapshot (diff) | |
download | wireguard-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 'contrib/examples/keygen-html/src/glue.js')
-rw-r--r-- | contrib/examples/keygen-html/src/glue.js | 25 |
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; + } +}; |