|
|
ebe5a5a |
diff -up ./client/cjdroute2.c.sodium ./client/cjdroute2.c
|
|
|
ebe5a5a |
--- ./client/cjdroute2.c.sodium 2017-05-24 16:30:27.567751409 -0400
|
|
|
ebe5a5a |
+++ ./client/cjdroute2.c 2017-05-24 16:56:13.496738433 -0400
|
|
|
ebe5a5a |
@@ -57,6 +57,7 @@
|
|
|
ebe5a5a |
#include <stdint.h>
|
|
|
ebe5a5a |
#include <stdio.h>
|
|
|
ebe5a5a |
#include <unistd.h>
|
|
|
ebe5a5a |
+#include <sodium.h>
|
|
|
ebe5a5a |
|
|
|
ebe5a5a |
#define DEFAULT_TUN_DEV "tun0"
|
|
|
ebe5a5a |
|
|
|
ebe5a5a |
@@ -523,6 +524,9 @@ static void onCoreExit(int64_t exit_stat
|
|
|
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
|
|
|
ebe5a5a |
--- ./contrib/c/makekeys.c.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./contrib/c/makekeys.c 2017-05-24 16:52:43.541154825 -0400
|
|
|
ebe5a5a |
@@ -23,9 +23,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
|
|
|
ebe5a5a |
--- ./contrib/c/mkpasswd.c.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./contrib/c/mkpasswd.c 2017-05-24 16:53:15.323545923 -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
|
|
|
ebe5a5a |
--- ./contrib/c/privatetopublic.c.sodium 2017-05-24 16:43:13.814155821 -0400
|
|
|
ebe5a5a |
+++ ./contrib/c/privatetopublic.c 2017-05-24 16:53:27.460695277 -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 |
|
|
|
ebe5a5a |
Hex_decode(privateKey, 32, privateKeyHexIn, 65);
|
|
|
ebe5a5a |
crypto_scalarmult_curve25519_base(address.key, privateKey);
|
|
|
ebe5a5a |
diff -up ./contrib/c/publictoip6.c.sodium ./contrib/c/publictoip6.c
|
|
|
ebe5a5a |
--- ./contrib/c/publictoip6.c.sodium 2017-05-24 16:42:11.085386456 -0400
|
|
|
ebe5a5a |
+++ ./contrib/c/publictoip6.c 2017-05-24 16:53:33.295767080 -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
|
|
|
ebe5a5a |
--- ./contrib/c/sybilsim.c.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./contrib/c/sybilsim.c 2017-05-24 16:53:39.030837653 -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
|
|
|
ebe5a5a |
--- ./crypto/random/randombytes.c.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./crypto/random/randombytes.c 2017-05-24 16:54:01.745117164 -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
|
|
|
ebe5a5a |
--- ./node_build/make.js.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./node_build/make.js 2017-05-24 16:39:15.557233617 -0400
|
|
|
ebe5a5a |
@@ -244,44 +244,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 |
-
|
|
|
e380438 |
- if (CFLAGS) {
|
|
|
e380438 |
- [].push.apply(args, CFLAGS.split(' '));
|
|
|
e380438 |
- }
|
|
|
e380438 |
-
|
|
|
e380438 |
- if (!builder.config.crossCompiling) {
|
|
|
e380438 |
- if (NO_MARCH_FLAG.indexOf(process.arch) < -1) {
|
|
|
e380438 |
- builder.config.cflags.push('-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 |
|
|
|
ebe5a5a |
@@ -422,7 +386,7 @@ Builder.configure({
|
|
|
e380438 |
builder.buildExecutable('crypto/random/randombytes.c');
|
|
|
e380438 |
|
|
|
e380438 |
builder.lintFiles(function (fileName, file, callback) {
|
|
|
e380438 |
- if (/dependencies/.test(fileName)) {
|
|
|
e380438 |
+ if (/(dependencies|\/usr\/include)/.test(fileName)) {
|
|
|
e380438 |
callback('', false);
|
|
|
e380438 |
return;
|
|
|
e380438 |
}
|
|
|
ebe5a5a |
diff -up ./test/testcjdroute.c.sodium ./test/testcjdroute.c
|
|
|
ebe5a5a |
--- ./test/testcjdroute.c.sodium 2017-02-21 17:56:22.000000000 -0500
|
|
|
ebe5a5a |
+++ ./test/testcjdroute.c 2017-05-24 16:57:05.397377097 -0400
|
|
|
ebe5a5a |
@@ -19,6 +19,7 @@
|
|
|
ebe5a5a |
#include "memory/MallocAllocator.h"
|
|
|
ebe5a5a |
|
|
|
ebe5a5a |
#include <stdio.h>
|
|
|
ebe5a5a |
+#include <sodium.h>
|
|
|
ebe5a5a |
|
|
|
ebe5a5a |
#ifdef SUBNODE
|
|
|
ebe5a5a |
#define testcjdroute_SUBNODE 1
|
|
|
ebe5a5a |
@@ -72,6 +73,9 @@ static void usage(char* appName)
|
|
|
ebe5a5a |
|
|
|
ebe5a5a |
int main(int argc, char** argv)
|
|
|
ebe5a5a |
{
|
|
|
ebe5a5a |
+ if (sodium_init() == -1) {
|
|
|
ebe5a5a |
+ return 1;
|
|
|
ebe5a5a |
+ }
|
|
|
ebe5a5a |
struct Allocator* alloc = MallocAllocator_new(4096);
|
|
|
ebe5a5a |
struct EventBase* base = EventBase_new(alloc);
|
|
|
ebe5a5a |
uint64_t now = Time_hrtime();
|