mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-29 15:43:52 +00:00
Salsa20 SSE Windows build fix -- turns out you can't be as loose with SSE intrinsics in Visual Studio
This commit is contained in:
parent
9809511c4c
commit
f2d372545a
@ -144,10 +144,14 @@ void Salsa20::encrypt(const void *in,void *out,unsigned int bytes)
|
||||
}
|
||||
|
||||
#ifdef ZT_SALSA20_SSE
|
||||
__m128i X0 = _state.v[0];
|
||||
__m128i X1 = _state.v[1];
|
||||
__m128i X2 = _state.v[2];
|
||||
__m128i X3 = _state.v[3];
|
||||
__m128i X0 = _mm_load_si128((const __m128i *)&(_state.v[0]));
|
||||
__m128i X1 = _mm_load_si128((const __m128i *)&(_state.v[1]));
|
||||
__m128i X2 = _mm_load_si128((const __m128i *)&(_state.v[2]));
|
||||
__m128i X3 = _mm_load_si128((const __m128i *)&(_state.v[3]));
|
||||
__m128i X0s = X0;
|
||||
__m128i X1s = X1;
|
||||
__m128i X2s = X2;
|
||||
__m128i X3s = X3;
|
||||
|
||||
for (i=0;i<_roundsDiv2;++i) {
|
||||
__m128i T = _mm_add_epi32(X0, X3);
|
||||
@ -185,10 +189,10 @@ void Salsa20::encrypt(const void *in,void *out,unsigned int bytes)
|
||||
X3 = _mm_shuffle_epi32(X3, 0x93);
|
||||
}
|
||||
|
||||
X0 = _mm_add_epi32(_state.v[0],X0);
|
||||
X1 = _mm_add_epi32(_state.v[1],X1);
|
||||
X2 = _mm_add_epi32(_state.v[2],X2);
|
||||
X3 = _mm_add_epi32(_state.v[3],X3);
|
||||
X0 = _mm_add_epi32(X0s,X0);
|
||||
X1 = _mm_add_epi32(X1s,X1);
|
||||
X2 = _mm_add_epi32(X2s,X2);
|
||||
X3 = _mm_add_epi32(X3s,X3);
|
||||
|
||||
{
|
||||
__m128i k02 = _mm_or_si128(_mm_slli_epi64(X0, 32), _mm_srli_epi64(X3, 32));
|
||||
@ -201,10 +205,10 @@ void Salsa20::encrypt(const void *in,void *out,unsigned int bytes)
|
||||
const float *const mv = (const float *)m;
|
||||
float *const cv = (float *)c;
|
||||
|
||||
_mm_storeu_ps(cv,_mm_xor_si128(_mm_unpackhi_epi64(k02,k20),_mm_loadu_ps(mv)));
|
||||
_mm_storeu_ps(cv + 4,_mm_xor_si128(_mm_unpackhi_epi64(k13,k31),_mm_loadu_ps(mv + 4)));
|
||||
_mm_storeu_ps(cv + 8,_mm_xor_si128(_mm_unpacklo_epi64(k20,k02),_mm_loadu_ps(mv + 8)));
|
||||
_mm_storeu_ps(cv + 12,_mm_xor_si128(_mm_unpacklo_epi64(k31,k13),_mm_loadu_ps(mv + 12)));
|
||||
_mm_storeu_ps(cv,_mm_castsi128_ps(_mm_xor_si128(_mm_unpackhi_epi64(k02,k20),_mm_castps_si128(_mm_loadu_ps(mv)))));
|
||||
_mm_storeu_ps(cv + 4,_mm_castsi128_ps(_mm_xor_si128(_mm_unpackhi_epi64(k13,k31),_mm_castps_si128(_mm_loadu_ps(mv + 4)))));
|
||||
_mm_storeu_ps(cv + 8,_mm_castsi128_ps(_mm_xor_si128(_mm_unpacklo_epi64(k20,k02),_mm_castps_si128(_mm_loadu_ps(mv + 8)))));
|
||||
_mm_storeu_ps(cv + 12,_mm_castsi128_ps(_mm_xor_si128(_mm_unpacklo_epi64(k31,k13),_mm_castps_si128(_mm_loadu_ps(mv + 12)))));
|
||||
}
|
||||
|
||||
if (!(++_state.i[8])) {
|
||||
|
@ -40,6 +40,7 @@
|
||||
<ClCompile Include="..\..\node\PacketDecoder.cpp" />
|
||||
<ClCompile Include="..\..\node\Peer.cpp" />
|
||||
<ClCompile Include="..\..\node\Poly1305.cpp" />
|
||||
<ClCompile Include="..\..\node\RoutingTable.cpp" />
|
||||
<ClCompile Include="..\..\node\Salsa20.cpp" />
|
||||
<ClCompile Include="..\..\node\Service.cpp" />
|
||||
<ClCompile Include="..\..\node\SHA512.cpp" />
|
||||
@ -51,7 +52,6 @@
|
||||
<ClCompile Include="..\..\node\Topology.cpp" />
|
||||
<ClCompile Include="..\..\node\UdpSocket.cpp" />
|
||||
<ClCompile Include="..\..\node\Utils.cpp" />
|
||||
<ClCompile Include="..\..\node\WindowsEthernetTap.cpp" />
|
||||
<ClCompile Include="ServiceBase.cpp" />
|
||||
<ClCompile Include="ServiceInstaller.cpp" />
|
||||
<ClCompile Include="ZeroTierOneService.cpp" />
|
||||
@ -93,6 +93,7 @@
|
||||
<ClInclude Include="..\..\node\Path.hpp" />
|
||||
<ClInclude Include="..\..\node\Peer.hpp" />
|
||||
<ClInclude Include="..\..\node\Poly1305.hpp" />
|
||||
<ClInclude Include="..\..\node\RoutingTable.hpp" />
|
||||
<ClInclude Include="..\..\node\RuntimeEnvironment.hpp" />
|
||||
<ClInclude Include="..\..\node\Salsa20.hpp" />
|
||||
<ClInclude Include="..\..\node\Service.hpp" />
|
||||
@ -108,7 +109,6 @@
|
||||
<ClInclude Include="..\..\node\Topology.hpp" />
|
||||
<ClInclude Include="..\..\node\UdpSocket.hpp" />
|
||||
<ClInclude Include="..\..\node\Utils.hpp" />
|
||||
<ClInclude Include="..\..\node\WindowsEthernetTap.hpp" />
|
||||
<ClInclude Include="..\..\version.h" />
|
||||
<ClInclude Include="resource.h" />
|
||||
<ClInclude Include="ServiceBase.h" />
|
||||
@ -221,7 +221,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\ext\bin\libcrypto\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;ZT_SALSA20_SSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NoExtensions</EnableEnhancedInstructionSet>
|
||||
<StringPooling>true</StringPooling>
|
||||
@ -245,7 +245,7 @@
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\ext\bin\libcrypto\include</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>ZT_OFFICIAL_RELEASE;ZT_AUTO_UPDATE;ZT_SALSA20_SSE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
|
||||
<EnableEnhancedInstructionSet>NotSet</EnableEnhancedInstructionSet>
|
||||
<StringPooling>true</StringPooling>
|
||||
|
@ -120,7 +120,7 @@
|
||||
<ClCompile Include="..\..\node\TcpSocket.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\node\WindowsEthernetTap.cpp">
|
||||
<ClCompile Include="..\..\node\RoutingTable.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
@ -287,15 +287,15 @@
|
||||
<ClInclude Include="..\..\node\TcpSocket.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\WindowsEthernetTap.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\AntiRecursion.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\version.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\node\RoutingTable.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ResourceCompile Include="ZeroTierOne.rc">
|
||||
|
Loading…
x
Reference in New Issue
Block a user