From 64aaea3978533a6643850f6ed05a9afe7f4dc7be Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 6 Oct 2015 18:04:53 -0700 Subject: Cleanup, and add an even faster Poly1305 on systems that support it. --- node/Utils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'node/Utils.cpp') diff --git a/node/Utils.cpp b/node/Utils.cpp index 658c397d..3c6dee32 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -191,7 +191,7 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes) if (devURandomFd <= 0) { devURandomFd = ::open("/dev/urandom",O_RDONLY); if (devURandomFd <= 0) { - fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to open /dev/urandom\r\n"); + fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to open /dev/urandom\n"); exit(1); return; } @@ -200,7 +200,7 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes) for(unsigned int i=0;i= sizeof(randomBuf)) { if ((int)::read(devURandomFd,randomBuf,sizeof(randomBuf)) != (int)sizeof(randomBuf)) { - fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to read from /dev/urandom\r\n"); + fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to read from /dev/urandom\n"); exit(1); return; } -- cgit v1.2.3 From 598a1d8dd7f621bb75a7f0537c5a63ee93e85a4c Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Tue, 6 Oct 2015 18:10:40 -0700 Subject: Try reopening /dev/urandom if there is a problem. --- node/Utils.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'node/Utils.cpp') diff --git a/node/Utils.cpp b/node/Utils.cpp index 3c6dee32..6c5d8c7d 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -181,7 +181,7 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes) #ifdef __UNIX_LIKE__ - static char randomBuf[65536]; + static char randomBuf[131072]; static unsigned int randomPtr = sizeof(randomBuf); static int devURandomFd = -1; static Mutex globalLock; @@ -199,10 +199,16 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes) for(unsigned int i=0;i= sizeof(randomBuf)) { - if ((int)::read(devURandomFd,randomBuf,sizeof(randomBuf)) != (int)sizeof(randomBuf)) { - fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to read from /dev/urandom\n"); - exit(1); - return; + for(;;) { + if ((int)::read(devURandomFd,randomBuf,sizeof(randomBuf)) != (int)sizeof(randomBuf)) { + ::close(devURandomFd); + devURandomFd = ::open("/dev/urandom",O_RDONLY); + if (devURandomFd <= 0) { + fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() unable to open /dev/urandom\n"); + exit(1); + return; + } + } else break; } randomPtr = 0; } -- cgit v1.2.3 From 54f68280bd65589fc858901f1c5c4ed8588862c3 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Thu, 12 Nov 2015 16:48:42 -0800 Subject: Minor Windows build fixes. Builds on VS2012 again. --- node/Hashtable.hpp | 2 +- node/Utils.cpp | 4 ++-- service/OneService.cpp | 2 +- windows/ZeroTierOne/ZeroTierOne.vcxproj | 9 ++++++--- windows/ZeroTierOne/ZeroTierOne.vcxproj.filters | 27 ++++++++++++++++--------- 5 files changed, 28 insertions(+), 16 deletions(-) (limited to 'node/Utils.cpp') diff --git a/node/Hashtable.hpp b/node/Hashtable.hpp index e3512fef..aee24989 100644 --- a/node/Hashtable.hpp +++ b/node/Hashtable.hpp @@ -103,7 +103,7 @@ public: private: unsigned long _idx; Hashtable *_ht; - Hashtable::_Bucket *_b; + _Bucket *_b; }; friend class Hashtable::Iterator; diff --git a/node/Utils.cpp b/node/Utils.cpp index 6c5d8c7d..10146e6c 100644 --- a/node/Utils.cpp +++ b/node/Utils.cpp @@ -168,14 +168,14 @@ void Utils::getSecureRandom(void *buf,unsigned int bytes) fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() CryptGenRandom failed!\r\n"); exit(1); } - s20.init(s20key,256,s20key,8); + s20.init(s20key,256,s20key); } if (!CryptGenRandom(cryptProvider,(DWORD)bytes,(BYTE *)buf)) { fprintf(stderr,"FATAL ERROR: Utils::getSecureRandom() CryptGenRandom failed!\r\n"); exit(1); } - s20.encrypt(buf,buf,bytes); + s20.encrypt12(buf,buf,bytes); #else // not __WINDOWS__ diff --git a/service/OneService.cpp b/service/OneService.cpp index 87f4136c..a912c830 100644 --- a/service/OneService.cpp +++ b/service/OneService.cpp @@ -796,7 +796,7 @@ public: while (ua) { InetAddress ip(ua->Address.lpSockaddr); ip.setPort(_port); - _node->addLocalInterfaceAddress(reinterpret_cast(&ip),0,ZT_LOCAL_INTERFACE_ADDRESS_TRUST_NORMAL); + _node->addLocalInterfaceAddress(reinterpret_cast(&ip)); ua = ua->Next; } } diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj index 0a43a6f6..c3163608 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj @@ -24,7 +24,7 @@ - + @@ -35,6 +35,7 @@ + @@ -87,13 +88,16 @@ + + - + + @@ -111,7 +115,6 @@ - diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters index abaa8547..b9e00b37 100644 --- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters +++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters @@ -105,9 +105,6 @@ Source Files\node - - Source Files\node - Source Files\node @@ -189,6 +186,12 @@ Source Files\osdep + + Source Files\node + + + Source Files\node + @@ -254,9 +257,6 @@ Header Files\node - - Header Files\node - Header Files\node @@ -356,9 +356,6 @@ Header Files\osdep - - Header Files\node - Header Files\osdep @@ -410,6 +407,18 @@ Header Files\ext\bin\miniupnpc\include + + Header Files\node + + + Header Files\node + + + Header Files\node + + + Header Files\node + -- cgit v1.2.3