diff --git a/cjdns.sign.patch b/cjdns.sign.patch
index c4d8f8b..c86619d 100644
--- a/cjdns.sign.patch
+++ b/cjdns.sign.patch
@@ -1,24 +1,51 @@
-diff -up ./crypto/Sign.c.sign ./crypto/Sign.c
---- ./crypto/Sign.c.sign 2016-10-11 17:39:44.000000000 -0400
-+++ ./crypto/Sign.c 2016-10-14 20:59:49.143754098 -0400
-@@ -13,6 +13,7 @@
- * along with this program. If not, see .
- */
+diff -up ./crypto/CryptoAuth.c.sign ./crypto/CryptoAuth.c
+--- ./crypto/CryptoAuth.c.sign 2020-09-18 14:24:44.000000000 -0400
++++ ./crypto/CryptoAuth.c 2020-09-29 10:32:39.040375439 -0400
+@@ -85,8 +85,10 @@ static inline void getSharedSecret(uint8
+ uint8_t passwordHash[32],
+ struct Log* logger)
+ {
++ int keygenfailed;
+ if (passwordHash == NULL) {
+- crypto_box_curve25519xsalsa20poly1305_beforenm(outputSecret, herPublicKey, myPrivateKey);
++ keygenfailed = crypto_box_curve25519xsalsa20poly1305_beforenm(
++ outputSecret, herPublicKey, myPrivateKey);
+ } else {
+ union {
+ struct {
+@@ -96,7 +98,8 @@ static inline void getSharedSecret(uint8
+ uint8_t bytes[64];
+ } buff;
-+#ifdef SUBNODE
- #include "crypto/Sign.h"
+- crypto_scalarmult_curve25519(buff.components.key, myPrivateKey, herPublicKey);
++ keygenfailed = crypto_scalarmult_curve25519(
++ buff.components.key, myPrivateKey, herPublicKey);
+ Bits_memcpy(buff.components.passwd, passwordHash, 32);
+ crypto_hash_sha256(outputSecret, buff.bytes, 64);
+ }
+@@ -114,8 +117,9 @@ static inline void getSharedSecret(uint8
+ " myPublicKey=%s\n"
+ " herPublicKey=%s\n"
+ " passwordHash=%s\n"
+- " outputSecret=%s\n",
+- myPublicKeyHex, herPublicKeyHex, passwordHashHex, outputSecretHex);
++ " outputSecret=%s\n"
++ " keygenfailed=%d\n",
++ myPublicKeyHex, herPublicKeyHex, passwordHashHex, outputSecretHex,keygenfailed);
+ }
+ }
- #include "node_build/dependencies/cnacl/crypto_sign/ed25519/ref10/ge.h"
-@@ -110,3 +111,6 @@ int Sign_publicSigningKeyToCurve25519(ui
+diff -up ./crypto/Sign.c.sign ./crypto/Sign.c
+--- ./crypto/Sign.c.sign 2020-09-18 14:24:44.000000000 -0400
++++ ./crypto/Sign.c 2020-09-29 10:25:02.503986487 -0400
+@@ -210,3 +210,4 @@ int Sign_publicSigningKeyToCurve25519(ui
return 0;
}
-+#else
+#pragma GCC diagnostic ignored "-Wpedantic"
-+#endif // SUBNODE
diff -up ./crypto/test/Sign_test.c.sign ./crypto/test/Sign_test.c
---- ./crypto/test/Sign_test.c.sign 2016-10-11 17:39:44.000000000 -0400
-+++ ./crypto/test/Sign_test.c 2016-10-14 20:57:28.737064976 -0400
+--- ./crypto/test/Sign_test.c.sign 2020-09-18 14:24:44.000000000 -0400
++++ ./crypto/test/Sign_test.c 2020-09-29 10:25:02.503986487 -0400
@@ -23,6 +23,7 @@
int main()
@@ -27,10 +54,10 @@ diff -up ./crypto/test/Sign_test.c.sign ./crypto/test/Sign_test.c
struct Allocator* alloc = MallocAllocator_new(1048576);
struct Log* logger = FileWriterLog_new(stdout, alloc);
struct Random* rand = Random_new(alloc, logger, NULL);
-@@ -42,5 +43,6 @@ int main()
- Assert_true(!Sign_verifyMsg(&signingKeyPair[32], msg));
- Assert_true(!Sign_publicSigningKeyToCurve25519(curve25519publicB, &signingKeyPair[32]));
+@@ -44,5 +45,6 @@ int main()
Assert_true(!Bits_memcmp(curve25519publicB, curve25519public, 32));
+
+ Allocator_free(alloc);
+#endif // SUBNODE
return 0;
}
diff --git a/cjdns.sodium.patch b/cjdns.sodium.patch
index c2e3393..89f60b9 100644
--- a/cjdns.sodium.patch
+++ b/cjdns.sodium.patch
@@ -1,15 +1,15 @@
diff -up ./client/cjdroute2.c.sodium ./client/cjdroute2.c
---- ./client/cjdroute2.c.sodium 2017-05-24 16:30:27.567751409 -0400
-+++ ./client/cjdroute2.c 2017-05-24 16:56:13.496738433 -0400
-@@ -57,6 +57,7 @@
- #include
- #include
- #include
+--- ./client/cjdroute2.c.sodium 2020-09-28 22:33:15.839316844 -0400
++++ ./client/cjdroute2.c 2020-09-28 22:34:40.219680315 -0400
+@@ -64,6 +64,7 @@
+ #include
+ #include
+ #include
+#include
#define DEFAULT_TUN_DEV "tun0"
-@@ -523,6 +524,9 @@ static void onCoreExit(int64_t exit_stat
+@@ -598,6 +599,9 @@ static String* getPipePath(Dict* config,
int main(int argc, char** argv)
{
@@ -20,9 +20,9 @@ diff -up ./client/cjdroute2.c.sodium ./client/cjdroute2.c
fprintf(stderr, "Log_LEVEL = KEYS, EXPECT TO SEE PRIVATE KEYS IN YOUR LOGS!\n");
#endif
diff -up ./contrib/c/makekeys.c.sodium ./contrib/c/makekeys.c
---- ./contrib/c/makekeys.c.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./contrib/c/makekeys.c 2017-05-24 16:52:43.541154825 -0400
-@@ -23,9 +23,13 @@
+--- ./contrib/c/makekeys.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./contrib/c/makekeys.c 2020-09-28 22:33:15.853317070 -0400
+@@ -22,9 +22,13 @@
#include
#include
@@ -37,8 +37,8 @@ diff -up ./contrib/c/makekeys.c.sodium ./contrib/c/makekeys.c
struct Random* rand = Random_new(alloc, NULL, NULL);
diff -up ./contrib/c/mkpasswd.c.sodium ./contrib/c/mkpasswd.c
---- ./contrib/c/mkpasswd.c.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./contrib/c/mkpasswd.c 2017-05-24 16:53:15.323545923 -0400
+--- ./contrib/c/mkpasswd.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./contrib/c/mkpasswd.c 2020-09-28 22:33:15.853317070 -0400
@@ -18,9 +18,13 @@
#include
@@ -54,8 +54,8 @@ diff -up ./contrib/c/mkpasswd.c.sodium ./contrib/c/mkpasswd.c
struct Random* rand = Random_new(alloc, NULL, NULL);
diff -up ./contrib/c/privatetopublic.c.sodium ./contrib/c/privatetopublic.c
---- ./contrib/c/privatetopublic.c.sodium 2017-05-24 16:43:13.814155821 -0400
-+++ ./contrib/c/privatetopublic.c 2017-05-24 16:53:27.460695277 -0400
+--- ./contrib/c/privatetopublic.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./contrib/c/privatetopublic.c 2020-09-28 22:33:15.853317070 -0400
@@ -23,6 +23,7 @@
#include
#include
@@ -75,8 +75,8 @@ diff -up ./contrib/c/privatetopublic.c.sodium ./contrib/c/privatetopublic.c
Hex_decode(privateKey, 32, privateKeyHexIn, 64);
crypto_scalarmult_curve25519_base(address.key, privateKey);
diff -up ./contrib/c/publictoip6.c.sodium ./contrib/c/publictoip6.c
---- ./contrib/c/publictoip6.c.sodium 2017-05-24 16:42:11.085386456 -0400
-+++ ./contrib/c/publictoip6.c 2017-05-24 16:53:33.295767080 -0400
+--- ./contrib/c/publictoip6.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./contrib/c/publictoip6.c 2020-09-28 22:33:15.853317070 -0400
@@ -16,6 +16,7 @@
#include "util/AddrTools.h"
#include "util/CString.h"
@@ -96,8 +96,8 @@ diff -up ./contrib/c/publictoip6.c.sodium ./contrib/c/publictoip6.c
int ret = Key_parse(&key, keyBytes, ip6Bytes);
switch (ret) {
diff -up ./contrib/c/sybilsim.c.sodium ./contrib/c/sybilsim.c
---- ./contrib/c/sybilsim.c.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./contrib/c/sybilsim.c 2017-05-24 16:53:39.030837653 -0400
+--- ./contrib/c/sybilsim.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./contrib/c/sybilsim.c 2020-09-28 22:33:15.853317070 -0400
@@ -42,6 +42,7 @@
#include "crypto_scalarmult_curve25519.h"
@@ -117,8 +117,8 @@ diff -up ./contrib/c/sybilsim.c.sodium ./contrib/c/sybilsim.c
struct Allocator* alloc = MallocAllocator_new(1LL<<31);
diff -up ./crypto/random/randombytes.c.sodium ./crypto/random/randombytes.c
---- ./crypto/random/randombytes.c.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./crypto/random/randombytes.c 2017-05-24 16:54:01.745117164 -0400
+--- ./crypto/random/randombytes.c.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./crypto/random/randombytes.c 2020-09-28 22:33:15.853317070 -0400
@@ -17,6 +17,7 @@
#include "memory/MallocAllocator.h"
@@ -138,9 +138,9 @@ diff -up ./crypto/random/randombytes.c.sodium ./crypto/random/randombytes.c
Random_bytes(rand, str.buff, 4096);
out = write(STDOUT_FILENO, str.buff, 4096);
diff -up ./node_build/make.js.sodium ./node_build/make.js
---- ./node_build/make.js.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./node_build/make.js 2017-05-24 16:39:15.557233617 -0400
-@@ -244,48 +244,8 @@ Builder.configure({
+--- ./node_build/make.js.sodium 2020-09-18 14:24:44.000000000 -0400
++++ ./node_build/make.js 2020-09-28 22:33:15.853317070 -0400
+@@ -264,48 +264,8 @@ Builder.configure({
}).nThen(function (waitFor) {
@@ -191,33 +191,33 @@ diff -up ./node_build/make.js.sodium ./node_build/make.js
}).nThen(function (waitFor) {
-@@ -422,7 +386,7 @@ Builder.configure({
+@@ -452,7 +412,7 @@ Builder.configure({
builder.buildExecutable('crypto/random/randombytes.c');
builder.lintFiles(function (fileName, file, callback) {
-- if (/dependencies/.test(fileName)) {
-+ if (/(dependencies|\/usr\/include)/.test(fileName)) {
+- if (/dependencies/.test(fileName) || /crypto\/sign/.test(fileName)) {
++ if (/(dependencies|\/usr\/include)/.test(fileName) || /crypto\/sign/.test(fileName)) {
callback('', false);
return;
}
diff -up ./test/testcjdroute.c.sodium ./test/testcjdroute.c
---- ./test/testcjdroute.c.sodium 2017-02-21 17:56:22.000000000 -0500
-+++ ./test/testcjdroute.c 2017-05-24 16:57:05.397377097 -0400
-@@ -19,6 +19,7 @@
- #include "memory/MallocAllocator.h"
-
+--- ./test/testcjdroute.c.sodium 2020-09-28 22:33:15.854317087 -0400
++++ ./test/testcjdroute.c 2020-09-28 22:36:34.386525092 -0400
+@@ -26,6 +26,7 @@
#include
+ #include
+ #include
+#include
#ifdef SUBNODE
#define testcjdroute_SUBNODE 1
-@@ -72,6 +73,9 @@ static void usage(char* appName)
+@@ -272,6 +273,9 @@ static int main2(int argc, char** argv,
int main(int argc, char** argv)
{
+ if (sodium_init() == -1) {
+ return 1;
+ }
- struct Allocator* alloc = MallocAllocator_new(4096);
- struct EventBase* base = EventBase_new(alloc);
- uint64_t now = Time_hrtime();
+ struct Allocator* alloc = MallocAllocator_new(1<<24);
+ struct RandomSeed* rs = DeterminentRandomSeed_new(alloc, RANDOM_SEED);
+ struct Random* detRand = Random_newWithSeed(alloc, NULL, rs, NULL);
diff --git a/cjdns.spec b/cjdns.spec
index bc40dd6..52ae0fe 100644
--- a/cjdns.spec
+++ b/cjdns.spec
@@ -6,12 +6,12 @@
%bcond_with subnode
# Option to use the optimized libnacl embedded with cjdns
# Required since v20 due to use of private cnacl APIs
-%bcond_without embedded
+%bcond_with embedded
# Option to enable CPU specific optimization
# Default to generic for distro builds
%bcond_without generic
-# Option to use libsodium instead of nacl (broken since v20)
-%bcond_with libsodium
+# Option to use libsodium instead of nacl (broken since v20, fixed v21)
+%bcond_without libsodium
# Option to disable SECCOMP: confusing backward logic
# Needed to run on openvz and other container systems
%ifarch armv7hl
@@ -84,7 +84,7 @@
Name: cjdns
# major version is cjdns protocol version:
-Version: 20.7
+Version: 21
Release: 2%{?dist}
Summary: The privacy-friendly network without borders
# cjdns is all GPLv3 except libuv which is MIT and BSD and ISC
@@ -312,6 +312,9 @@ elif test -d %{_includedir}/nacl && test -r %{_libdir}/libnacl.a; then
cd -
fi
%patch12 -b .sign
+cd crypto/sign
+sed -i -e'/^#include / s,[<>],",g' crypto*int*.h
+cd -
%endif
%if !0%{?rhel} || 0%{?rhel} > 6
@@ -385,7 +388,7 @@ sed -i -e 's/-march=native/-mtune=native/' node_build/make.js
%else
sed -i -e 's/-march=native/-mtune=generic/' node_build/make.js
%endif
-rm node_build/dependencies/cnacl/node_build/plans/*_AVX_plan.json
+#rm node_build/dependencies/cnacl/node_build/plans/*_AVX_plan.json
# Leaving SSE2 code in since x86 is secondary arch and pretty much everyone
# is going to have SSE2, except things like XO-1 which needs custom build.
#rm node_build/dependencies/cnacl/node_build/plans/x86_SSE2_plan.json
@@ -745,6 +748,12 @@ fi
%{_bindir}/graphStats
%changelog
+* Mon Sep 28 2020 Stuart Gathman - 21-2
+- Enable libsodium
+
+* Sat Sep 26 2020 Stuart Gathman - 21-1
+- New upstream release
+
* Mon Jul 27 2020 Fedora Release Engineering - 20.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild