summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@zerotier.com>2017-04-18 12:22:44 -0700
committerAdam Ierymenko <adam.ierymenko@zerotier.com>2017-04-18 12:22:44 -0700
commitaaf597f0205b79c0f1d8523f15c8d8aaecb63f43 (patch)
tree3824dfca12d1dc35530692f6732b47964c6a26cb
parent72bd3064a20aec9b1fcbc86bb590aca87f4eca71 (diff)
downloadinfinitytier-aaf597f0205b79c0f1d8523f15c8d8aaecb63f43.tar.gz
infinitytier-aaf597f0205b79c0f1d8523f15c8d8aaecb63f43.zip
Cleanup, Windows fixes, Self test fix
-rw-r--r--ext/x64-salsa2012-asm/salsa2012.h6
-rw-r--r--node/Dictionary.hpp18
-rw-r--r--one.cpp2
-rw-r--r--selftest.cpp15
-rw-r--r--windows/ZeroTierOne/ZeroTierOne.vcxproj22
-rw-r--r--windows/ZeroTierOne/ZeroTierOne.vcxproj.filters3
6 files changed, 41 insertions, 25 deletions
diff --git a/ext/x64-salsa2012-asm/salsa2012.h b/ext/x64-salsa2012-asm/salsa2012.h
index d47059b4..d8c2e48c 100644
--- a/ext/x64-salsa2012-asm/salsa2012.h
+++ b/ext/x64-salsa2012-asm/salsa2012.h
@@ -2,11 +2,9 @@
extern "C" {
#endif
+// Generates Salsa20/12 key stream
// output, outlen, nonce, key (256-bit / 32-byte)
-extern int zt_salsa2012_amd64_xmm6(unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
-
-// ciphertext, message, mlen, nonce, key
-extern int zt_salsa2012_amd64_xmm6_xor(unsigned char *,const unsigned char *,unsigned long long,const unsigned char *,const unsigned char *);
+extern int zt_salsa2012_amd64_xmm6(unsigned char *, unsigned long long, const unsigned char *, const unsigned char *);
#ifdef __cplusplus
}
diff --git a/node/Dictionary.hpp b/node/Dictionary.hpp
index 440dae7f..0db13b63 100644
--- a/node/Dictionary.hpp
+++ b/node/Dictionary.hpp
@@ -176,12 +176,12 @@ public:
j = 0;
esc = false;
++p;
- while ((*p != 0)&&(*p != '\r')&&(*p != '\n')) {
+ while ((*p != 0)&&(*p != 13)&&(*p != 10)) {
if (esc) {
esc = false;
switch(*p) {
- case 'r': dest[j++] = '\r'; break;
- case 'n': dest[j++] = '\n'; break;
+ case 'r': dest[j++] = 13; break;
+ case 'n': dest[j++] = 10; break;
case '0': dest[j++] = (char)0; break;
case 'e': dest[j++] = '='; break;
default: dest[j++] = *p; break;
@@ -207,7 +207,7 @@ public:
dest[j] = (char)0;
return j;
} else {
- while ((*p)&&(*p != '\r')&&(*p != '\n')) {
+ while ((*p)&&(*p != 13)&&(*p != 10)) {
if (++p == eof) {
dest[0] = (char)0;
return -1;
@@ -299,7 +299,7 @@ public:
unsigned int j = i;
if (j > 0) {
- _d[j++] = '\n';
+ _d[j++] = (char)10;
if (j == C) {
_d[i] = (char)0;
return false;
@@ -326,8 +326,8 @@ public:
while ( ((vlen < 0)&&(*p)) || (k < vlen) ) {
switch(*p) {
case 0:
- case '\r':
- case '\n':
+ case 13:
+ case 10:
case '\\':
case '=':
_d[j++] = '\\';
@@ -337,8 +337,8 @@ public:
}
switch(*p) {
case 0: _d[j++] = '0'; break;
- case '\r': _d[j++] = 'r'; break;
- case '\n': _d[j++] = 'n'; break;
+ case 13: _d[j++] = 'r'; break;
+ case 10: _d[j++] = 'n'; break;
case '\\': _d[j++] = '\\'; break;
case '=': _d[j++] = 'e'; break;
}
diff --git a/one.cpp b/one.cpp
index edefe82e..b40e28fc 100644
--- a/one.cpp
+++ b/one.cpp
@@ -1257,7 +1257,7 @@ public:
};
#ifdef __WINDOWS__
-int _tmain(int argc, _TCHAR* argv[])
+int __cdecl _tmain(int argc, _TCHAR* argv[])
#else
int main(int argc,char **argv)
#endif
diff --git a/selftest.cpp b/selftest.cpp
index 55a469e1..e68cf047 100644
--- a/selftest.cpp
+++ b/selftest.cpp
@@ -212,12 +212,10 @@ static int testCrypto()
std::cout << "[crypto] Benchmarking Salsa20/12 fast x64 ASM... "; std::cout.flush();
{
unsigned char *bb = (unsigned char *)::malloc(1234567);
- for(unsigned int i=0;i<1234567;++i)
- bb[i] = (unsigned char)i;
double bytes = 0.0;
uint64_t start = OSUtils::now();
for(unsigned int i=0;i<200;++i) {
- zt_salsa2012_amd64_xmm6_xor(bb,bb,1234567,s20TV0Iv,s20TV0Key);
+ zt_salsa2012_amd64_xmm6(bb, 1234567, s20TV0Iv, s20TV0Key);
bytes += 1234567.0;
}
uint64_t end = OSUtils::now();
@@ -806,20 +804,19 @@ static int testOther()
memset(key, 0, sizeof(key));
memset(value, 0, sizeof(value));
for(unsigned int q=0;q<32;++q) {
- Utils::snprintf(key[q],16,"%.8lx",(unsigned long)rand());
- int r = (rand() % 127) + 1;
+ Utils::snprintf(key[q],16,"%.8lx",(unsigned long)(rand() % 1000) + (q * 1000));
+ int r = rand() % 128;
for(int x=0;x<r;++x)
value[q][x] = ("0123456789\0\t\r\n= ")[rand() % 16];
value[q][r] = (char)0;
test->add(key[q],value[q],r);
}
for(unsigned int q=0;q<1024;++q) {
- //int r = rand() % 128;
- int r = 31;
+ int r = rand() % 32;
char tmp[128];
if (test->get(key[r],tmp,sizeof(tmp)) >= 0) {
if (strcmp(value[r],tmp)) {
- std::cout << "FAILED (invalid value)!" << std::endl;
+ std::cout << "FAILED (invalid value '" << value[r] << "' != '" << tmp << "')!" << std::endl;
return -1;
}
} else {
@@ -1048,7 +1045,7 @@ static int testHttp()
*/
#ifdef __WINDOWS__
-int _tmain(int argc, _TCHAR* argv[])
+int __cdecl _tmain(int argc, _TCHAR* argv[])
#else
int main(int argc,char **argv)
#endif
diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj b/windows/ZeroTierOne/ZeroTierOne.vcxproj
index 6ed95010..96de5d2b 100644
--- a/windows/ZeroTierOne/ZeroTierOne.vcxproj
+++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj
@@ -72,12 +72,27 @@
<ClCompile Include="..\..\node\Tag.cpp" />
<ClCompile Include="..\..\node\Topology.cpp" />
<ClCompile Include="..\..\node\Utils.cpp" />
- <ClCompile Include="..\..\one.cpp" />
+ <ClCompile Include="..\..\one.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">false</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">false</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="..\..\osdep\Http.cpp" />
<ClCompile Include="..\..\osdep\ManagedRoute.cpp" />
<ClCompile Include="..\..\osdep\OSUtils.cpp" />
<ClCompile Include="..\..\osdep\PortMapper.cpp" />
<ClCompile Include="..\..\osdep\WindowsEthernetTap.cpp" />
+ <ClCompile Include="..\..\selftest.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Profile|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="..\..\service\OneService.cpp" />
<ClCompile Include="..\..\service\SoftwareUpdater.cpp" />
<ClCompile Include="ServiceBase.cpp" />
@@ -363,7 +378,7 @@
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
- <Optimization>Full</Optimization>
+ <Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
@@ -377,6 +392,9 @@
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
<OmitFramePointers>true</OmitFramePointers>
<DisableSpecificWarnings>4996</DisableSpecificWarnings>
+ <ControlFlowGuard>Guard</ControlFlowGuard>
+ <EnableParallelCodeGeneration>false</EnableParallelCodeGeneration>
+ <CallingConvention>VectorCall</CallingConvention>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
diff --git a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
index 01637801..cca10f97 100644
--- a/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
+++ b/windows/ZeroTierOne/ZeroTierOne.vcxproj.filters
@@ -252,6 +252,9 @@
<ClCompile Include="..\..\one.cpp">
<Filter>Source Files</Filter>
</ClCompile>
+ <ClCompile Include="..\..\selftest.cpp">
+ <Filter>Source Files</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource.h">