From 4f53d09c7e446e20e0a8da3bdb6bdc5b138cf55c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 16 Sep 2013 14:47:48 -0400 Subject: [PATCH] Build fix for 32-bit Linux and tweaks to address derivation algorithm. --- Makefile.linux | 15 +++++---------- node/Identity.cpp | 31 +++++++++++++++++-------------- node/Multicaster.hpp | 8 +++++--- 3 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Makefile.linux b/Makefile.linux index 0ebc5ae8a..1f27194a5 100644 --- a/Makefile.linux +++ b/Makefile.linux @@ -6,21 +6,16 @@ ARCH=$(shell uname -m) DEFS=-DZT_ARCH="$(ARCH)" -DZT_OSNAME="linux" -DZT_TRACE # Uncomment for a release optimized build -#CFLAGS=-Wall -O3 -fno-unroll-loops -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS) -#STRIP=strip --strip-all +CFLAGS=-Wall -O3 -fno-unroll-loops -fstack-protector -pthread $(INCLUDES) -DNDEBUG $(DEFS) +STRIP=strip --strip-all # Uncomment for a debug build -CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS) -STRIP=echo +#CFLAGS=-Wall -g -pthread $(INCLUDES) -DZT_TRACE $(DEFS) +#STRIP=echo CXXFLAGS=$(CFLAGS) -fno-rtti -# We statically link against libcrypto because RedHat-derived distributions do -# not ship the elliptic curve algorithms. If we didn't we'd have to build -# separate binaries for the RedHat and Debian universes to distribute via -# auto-update. This way we get one Linux binary for all systems of a given -# architecture. -LIBS=ext/bin/libcrypto/linux-$(ARCH)/libcrypto.a -lm -ldl +LIBS=-lm include objects.mk diff --git a/node/Identity.cpp b/node/Identity.cpp index 678922323..298db57b5 100644 --- a/node/Identity.cpp +++ b/node/Identity.cpp @@ -32,6 +32,7 @@ #include "Identity.hpp" #include "SHA512.hpp" +#include "Salsa20.hpp" namespace ZeroTier { @@ -130,8 +131,8 @@ bool Identity::fromString(const char *str) // These are fixed parameters and can't be changed without a new // identity type. -#define ZT_IDENTITY_DERIVEADDRESS_DIGESTS 2048 -#define ZT_IDENTITY_DERIVEADDRESS_ROUNDS 8 +#define ZT_IDENTITY_DERIVEADDRESS_MEMORY 16777216 +#define ZT_IDENTITY_DERIVEADDRESS_ROUNDS 32 Address Identity::deriveAddress(const void *keyBytes,unsigned int keyLen) { @@ -149,24 +150,26 @@ Address Identity::deriveAddress(const void *keyBytes,unsigned int keyLen) * to similar concepts. */ - unsigned char finalDigest[ZT_SHA512_DIGEST_LEN]; - unsigned char *digests = new unsigned char[ZT_SHA512_DIGEST_LEN * ZT_IDENTITY_DERIVEADDRESS_DIGESTS]; + unsigned char *ram = new unsigned char[ZT_IDENTITY_DERIVEADDRESS_MEMORY]; + for(unsigned int i=0;i