ebe5a5a
diff -up ./client/cjdroute2.c.sodium ./client/cjdroute2.c
6c40d8f
--- ./client/cjdroute2.c.sodium	2020-09-28 22:33:15.839316844 -0400
6c40d8f
+++ ./client/cjdroute2.c	2020-09-28 22:34:40.219680315 -0400
6c40d8f
@@ -64,6 +64,7 @@
6c40d8f
 #include <string.h>
6c40d8f
 #include <time.h>
6c40d8f
 #include <stdlib.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 #define DEFAULT_TUN_DEV "tun0"
ebe5a5a
 
6c40d8f
@@ -598,6 +599,9 @@ static String* getPipePath(Dict* config,
ebe5a5a
 
ebe5a5a
 int main(int argc, char** argv)
ebe5a5a
 {
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
     #ifdef Log_KEYS
ebe5a5a
         fprintf(stderr, "Log_LEVEL = KEYS, EXPECT TO SEE PRIVATE KEYS IN YOUR LOGS!\n");
ebe5a5a
     #endif
ebe5a5a
diff -up ./contrib/c/makekeys.c.sodium ./contrib/c/makekeys.c
6c40d8f
--- ./contrib/c/makekeys.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./contrib/c/makekeys.c	2020-09-28 22:33:15.853317070 -0400
6c40d8f
@@ -22,9 +22,13 @@
ebe5a5a
 
ebe5a5a
 #include <signal.h>
ebe5a5a
 #include <stdio.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 int main(int argc, char** argv)
ebe5a5a
 {
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
     struct Allocator* alloc = MallocAllocator_new(1<<22);
ebe5a5a
     struct Random* rand = Random_new(alloc, NULL, NULL);
ebe5a5a
 
ebe5a5a
diff -up ./contrib/c/mkpasswd.c.sodium ./contrib/c/mkpasswd.c
6c40d8f
--- ./contrib/c/mkpasswd.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./contrib/c/mkpasswd.c	2020-09-28 22:33:15.853317070 -0400
ebe5a5a
@@ -18,9 +18,13 @@
ebe5a5a
 
ebe5a5a
 #include <stdio.h>
ebe5a5a
 #include <unistd.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 int main()
ebe5a5a
 {
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
     struct Allocator* alloc = MallocAllocator_new(1<<22);
ebe5a5a
     struct Random* rand = Random_new(alloc, NULL, NULL);
ebe5a5a
 
ebe5a5a
diff -up ./contrib/c/privatetopublic.c.sodium ./contrib/c/privatetopublic.c
6c40d8f
--- ./contrib/c/privatetopublic.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./contrib/c/privatetopublic.c	2020-09-28 22:33:15.853317070 -0400
ebe5a5a
@@ -23,6 +23,7 @@
ebe5a5a
 #include <stdio.h>
ebe5a5a
 #include <errno.h>
ebe5a5a
 #include <string.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 static int usage(char* appName)
ebe5a5a
 {
ebe5a5a
@@ -67,6 +68,9 @@ int main(int argc, char** argv)
ebe5a5a
             break;
ebe5a5a
         }
ebe5a5a
     }
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
 
5c914f7
     Hex_decode(privateKey, 32, privateKeyHexIn, 64);
ebe5a5a
     crypto_scalarmult_curve25519_base(address.key, privateKey);
ebe5a5a
diff -up ./contrib/c/publictoip6.c.sodium ./contrib/c/publictoip6.c
6c40d8f
--- ./contrib/c/publictoip6.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./contrib/c/publictoip6.c	2020-09-28 22:33:15.853317070 -0400
ebe5a5a
@@ -16,6 +16,7 @@
ebe5a5a
 #include "util/AddrTools.h"
ebe5a5a
 #include "util/CString.h"
ebe5a5a
 #include <stdio.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 static int usage(char* appName)
ebe5a5a
 {
ebe5a5a
@@ -36,6 +37,9 @@ int main(int argc, char** argv)
ebe5a5a
     uint8_t keyBytes[32];
ebe5a5a
     uint8_t ip6Bytes[16];
ebe5a5a
     String key = { .bytes = argv[1], .len = CString_strlen(argv[1]) };
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
 
ebe5a5a
     int ret = Key_parse(&key, keyBytes, ip6Bytes);
ebe5a5a
     switch (ret) {
ebe5a5a
diff -up ./contrib/c/sybilsim.c.sodium ./contrib/c/sybilsim.c
6c40d8f
--- ./contrib/c/sybilsim.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./contrib/c/sybilsim.c	2020-09-28 22:33:15.853317070 -0400
ebe5a5a
@@ -42,6 +42,7 @@
ebe5a5a
 #include "crypto_scalarmult_curve25519.h"
ebe5a5a
 
ebe5a5a
 #include <unistd.h> // isatty()
ebe5a5a
+#include <sodium.h> // isatty()
ebe5a5a
 
ebe5a5a
 struct NodeContext {
ebe5a5a
     struct Sockaddr* boundAddr;
ebe5a5a
@@ -441,6 +442,9 @@ int main(int argc, char** argv)
ebe5a5a
     if (isatty(STDIN_FILENO)) {
ebe5a5a
         return usage(argv[0]);
ebe5a5a
     }
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
 
ebe5a5a
     struct Allocator* alloc = MallocAllocator_new(1LL<<31);
ebe5a5a
 
ebe5a5a
diff -up ./crypto/random/randombytes.c.sodium ./crypto/random/randombytes.c
6c40d8f
--- ./crypto/random/randombytes.c.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./crypto/random/randombytes.c	2020-09-28 22:33:15.853317070 -0400
ebe5a5a
@@ -17,6 +17,7 @@
ebe5a5a
 #include "memory/MallocAllocator.h"
ebe5a5a
 
ebe5a5a
 #include <unistd.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 int main()
ebe5a5a
 {
ebe5a5a
@@ -29,6 +30,9 @@ int main()
ebe5a5a
     } str;
ebe5a5a
 
ebe5a5a
     size_t out = 0;
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
ebe5a5a
     for (;;) {
ebe5a5a
         Random_bytes(rand, str.buff, 4096);
ebe5a5a
         out = write(STDOUT_FILENO, str.buff, 4096);
dcdbe47
diff -up ./node_build/make.js.sodium ./node_build/make.js
6c40d8f
--- ./node_build/make.js.sodium	2020-09-18 14:24:44.000000000 -0400
6c40d8f
+++ ./node_build/make.js	2020-09-28 22:33:15.853317070 -0400
6c40d8f
@@ -264,48 +264,8 @@ Builder.configure({
e380438
 
e380438
     }).nThen(function (waitFor) {
e380438
 
e380438
-        builder.config.libs.push(dependencyDir + '/cnacl/jsbuild/libnacl.a');
e380438
-        builder.config.includeDirs.push(dependencyDir + '/cnacl/jsbuild/include/');
e380438
-
dcdbe47
-        // needed for Sign.c which pulls in crypto_int32.h
dcdbe47
-        builder.config.includeDirs.push(dependencyDir + '/cnacl/jsbuild/include_internal/');
dcdbe47
-
e380438
-        Fs.exists(dependencyDir + '/cnacl/jsbuild/libnacl.a', waitFor(function (exists) {
e380438
-            if (exists) { return; }
e380438
-
e380438
-            console.log("Build NaCl");
e380438
-            var cwd = process.cwd();
e380438
-            process.chdir(dependencyDir + '/cnacl/');
e380438
-
e380438
-            var NaCl = require(process.cwd() + '/node_build/make.js');
e380438
-            NaCl.build(function (args, callback) {
e380438
-                if (builder.config.systemName !== 'win32') {
e380438
-                    args.unshift('-fPIC');
e380438
-                }
e380438
-
e380438
-                args.unshift(builder.config.optimizeLevel, '-fomit-frame-pointer');
e380438
-
5c914f7
-                if (!/^\-O0$/.test(builder.config.optimizeLevel)) {
5c914f7
-                    args.unshift('-D_FORTIFY_SOURCE=2');
5c914f7
-                }
5c914f7
-
e380438
-                if (CFLAGS) {
e380438
-                    [].push.apply(args, CFLAGS.split(' '));
e380438
-                }
e380438
-
e380438
-                if (!builder.config.crossCompiling) {
5c914f7
-                    if (NO_MARCH_FLAG.indexOf(process.arch) == -1) {
5c914f7
-                        args.unshift('-march=native');
e380438
-                    }
e380438
-                }
e380438
-
e380438
-                builder.cc(args, callback);
e380438
-            },
e380438
-            builder.config,
e380438
-            waitFor(function () {
e380438
-                process.chdir(cwd);
e380438
-            }));
e380438
-        }));
e380438
+        builder.config.libs.push('-lsodium');
e380438
+        builder.config.includeDirs.push('/usr/include/sodium/');
e380438
 
e380438
     }).nThen(function (waitFor) {
e380438
 
6c40d8f
@@ -452,7 +412,7 @@ Builder.configure({
e380438
     builder.buildExecutable('crypto/random/randombytes.c');
e380438
 
e380438
     builder.lintFiles(function (fileName, file, callback) {
6c40d8f
-        if (/dependencies/.test(fileName) || /crypto\/sign/.test(fileName)) {
6c40d8f
+        if (/(dependencies|\/usr\/include)/.test(fileName) || /crypto\/sign/.test(fileName)) {
e380438
             callback('', false);
e380438
             return;
e380438
         }
ebe5a5a
diff -up ./test/testcjdroute.c.sodium ./test/testcjdroute.c
6c40d8f
--- ./test/testcjdroute.c.sodium	2020-09-28 22:33:15.854317087 -0400
6c40d8f
+++ ./test/testcjdroute.c	2020-09-28 22:36:34.386525092 -0400
6c40d8f
@@ -26,6 +26,7 @@
ebe5a5a
 #include <stdio.h>
6c40d8f
 #include <unistd.h>
6c40d8f
 #include <fcntl.h>
ebe5a5a
+#include <sodium.h>
ebe5a5a
 
ebe5a5a
 #ifdef SUBNODE
ebe5a5a
     #define testcjdroute_SUBNODE 1
6c40d8f
@@ -272,6 +273,9 @@ static int main2(int argc, char** argv,
ebe5a5a
 
ebe5a5a
 int main(int argc, char** argv)
ebe5a5a
 {
ebe5a5a
+    if (sodium_init() == -1) {
ebe5a5a
+        return 1;
ebe5a5a
+    }
6c40d8f
     struct Allocator* alloc = MallocAllocator_new(1<<24);
6c40d8f
     struct RandomSeed* rs = DeterminentRandomSeed_new(alloc, RANDOM_SEED);
6c40d8f
     struct Random* detRand = Random_newWithSeed(alloc, NULL, rs, NULL);