diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-10-04 13:21:48 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-10-17 18:40:23 +0200 |
commit | e5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f (patch) | |
tree | 5656a151e5f777d834924a3784432c5bd928ed03 | |
parent | 7ff3c5d1080482c55a5c5f4720d22d212a8d7373 (diff) | |
download | VeraCrypt-e5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f.tar.gz VeraCrypt-e5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f.zip |
Crypto: Use SIMD optimized Serpent implementation from Botan. 2.5x speed gain factor. Update credits and copyrights notice.
-rw-r--r-- | src/Common/Crypto.c | 38 | ||||
-rw-r--r-- | src/Common/Crypto.h | 6 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 7 | ||||
-rw-r--r-- | src/Common/Xts.c | 4 | ||||
-rw-r--r-- | src/Crypto/Crypto.vcxproj | 6 | ||||
-rw-r--r-- | src/Crypto/Crypto.vcxproj.filters | 18 | ||||
-rw-r--r-- | src/Crypto/Sources | 3 | ||||
-rw-r--r-- | src/Crypto/cpu.h | 38 | ||||
-rw-r--r-- | src/Crypto/misc.h | 8 | ||||
-rw-r--r-- | src/Driver/Driver.vcxproj | 3 | ||||
-rw-r--r-- | src/Driver/Driver.vcxproj.filters | 9 | ||||
-rw-r--r-- | src/License.html | 14 | ||||
-rw-r--r-- | src/License.txt | 28 | ||||
-rw-r--r-- | src/Main/Forms/AboutDialog.cpp | 9 | ||||
-rw-r--r-- | src/Readme.txt | 1 | ||||
-rw-r--r-- | src/Release/Setup Files/License.txt | 28 | ||||
-rw-r--r-- | src/Release/Setup Files/NOTICE | 27 | ||||
-rw-r--r-- | src/Resources/Texts/License.rtf | 6 | ||||
-rw-r--r-- | src/Volume/Cipher.cpp | 53 | ||||
-rw-r--r-- | src/Volume/Cipher.h | 2 | ||||
-rw-r--r-- | src/Volume/Volume.make | 3 |
21 files changed, 285 insertions, 26 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index cae705b6..49ccbde5 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -232,6 +232,21 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) KeRestoreFloatingPointState (&floatingPointState); #endif } +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + else if (cipher == SERPENT + && (blockCount >= 4) + && HasSSE2() +#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) + && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) +#endif + ) + { + serpent_encrypt_blocks (data, data, blockCount, ks); +#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) + KeRestoreFloatingPointState (&floatingPointState); +#endif + } +#endif else if (cipher == GOST89) { gost_encrypt(data, data, ks, (int)blockCount); } @@ -312,6 +327,21 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) KeRestoreFloatingPointState (&floatingPointState); #endif } +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + else if (cipher == SERPENT + && (blockCount >= 4) + && HasSSE2() +#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) + && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) +#endif + ) + { + serpent_decrypt_blocks (data, data, blockCount, ks); +#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) + KeRestoreFloatingPointState (&floatingPointState); +#endif + } +#endif else if (cipher == GOST89) { gost_decrypt(data, data, ks, (int)blockCount); } @@ -383,8 +413,12 @@ int CipherGetKeyScheduleSize (int cipherId) BOOL CipherSupportsIntraDataUnitParallelization (int cipher) { - return cipher == AES && IsAesHwCpuSupported() || - cipher == GOST89; + return (cipher == AES && IsAesHwCpuSupported()) + || (cipher == GOST89) +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + || (cipher == SERPENT && HasSSE2()) +#endif + ; } #endif diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 6a943edf..d654b0c4 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -193,7 +193,11 @@ typedef struct #endif #include "Aes_hw_cpu.h" -#include "Serpent.h" +#if !defined (TC_WINDOWS_BOOT) +# include "SerpentFast.h" +#else +# include "Serpent.h" +#endif #include "Twofish.h" #include "Rmd160.h" diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 810b6e8a..ae6fcd2d 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -1214,10 +1214,11 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\r\n" L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\r\n" L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\r\n" - L"Copyright \xA9 2002-2004 Mark Adler. All Rights Reserved.\r\n" + L"Copyright \xA9 1995-2013 Jean-loup Gailly and Mark Adler.\r\n" L"Copyright \xA9 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov.\r\n" - L"Copyright \xA9 1990-2002 Info-ZIP. All rights reserved.\r\n" - L"Copyright \xA9 2013, Alexey Degtyarev. All rights reserved.\r\n\r\n" + L"Copyright \xA9 Dieter Baron and Thomas Klausner.\r\n" + L"Copyright \xA9 2013, Alexey Degtyarev. All rights reserved.\r\n" + L"Copyright \xA9 1999-2013,2014,2015,2016 Jack Lloyd. All rights reserved.\r\n\r\n" L"This software as a whole:\r\n" L"Copyright \xA9 2013-2016 IDRIX. All rights reserved.\r\n\r\n" diff --git a/src/Common/Xts.c b/src/Common/Xts.c index 02977887..87c9de00 100644 --- a/src/Common/Xts.c +++ b/src/Common/Xts.c @@ -68,7 +68,7 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, { unsigned __int8 finalCarry; unsigned __int8 whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; - unsigned __int8 whiteningValue [BYTES_PER_XTS_BLOCK]; + CRYPTOPP_ALIGN_DATA(16) unsigned __int8 whiteningValue [BYTES_PER_XTS_BLOCK]; unsigned __int8 byteBufUnitNo [BYTES_PER_XTS_BLOCK]; unsigned __int64 *whiteningValuesPtr64 = (unsigned __int64 *) whiteningValues; unsigned __int64 *whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; @@ -208,7 +208,7 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, int cipher) { unsigned __int8 finalCarry; - unsigned __int8 whiteningValue [BYTES_PER_XTS_BLOCK]; + CRYPTOPP_ALIGN_DATA(16) unsigned __int8 whiteningValue [BYTES_PER_XTS_BLOCK]; unsigned __int8 byteBufUnitNo [BYTES_PER_XTS_BLOCK]; unsigned __int64 *whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; unsigned __int64 *bufPtr = (unsigned __int64 *) buffer; diff --git a/src/Crypto/Crypto.vcxproj b/src/Crypto/Crypto.vcxproj index 3db1e789..7573f1ec 100644 --- a/src/Crypto/Crypto.vcxproj +++ b/src/Crypto/Crypto.vcxproj @@ -221,7 +221,8 @@ <ClCompile Include="GostCipher.c" /> <ClCompile Include="kuznyechik.c" /> <ClCompile Include="Rmd160.c" /> - <ClCompile Include="Serpent.c" /> + <ClCompile Include="SerpentFast.c" /> + <ClCompile Include="SerpentFast_simd.cpp" /> <ClCompile Include="Sha2.c" /> <ClCompile Include="Streebog.c" /> <ClCompile Include="Twofish.c" /> @@ -239,7 +240,8 @@ <ClInclude Include="kuznyechik.h" /> <ClInclude Include="misc.h" /> <ClInclude Include="Rmd160.h" /> - <ClInclude Include="Serpent.h" /> + <ClInclude Include="SerpentFast.h" /> + <ClInclude Include="SerpentFast_sbox.h" /> <ClInclude Include="Sha2.h" /> <ClInclude Include="Streebog.h" /> <ClInclude Include="Twofish.h" /> diff --git a/src/Crypto/Crypto.vcxproj.filters b/src/Crypto/Crypto.vcxproj.filters index 91e83c60..ad933b0a 100644 --- a/src/Crypto/Crypto.vcxproj.filters +++ b/src/Crypto/Crypto.vcxproj.filters @@ -30,9 +30,6 @@ <ClCompile Include="Rmd160.c"> <Filter>Source Files</Filter> </ClCompile> - <ClCompile Include="Serpent.c"> - <Filter>Source Files</Filter> - </ClCompile> <ClCompile Include="Sha2.c"> <Filter>Source Files</Filter> </ClCompile> @@ -51,6 +48,12 @@ <ClCompile Include="Streebog.c"> <Filter>Source Files</Filter> </ClCompile> + <ClCompile Include="SerpentFast.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="SerpentFast_simd.cpp"> + <Filter>Source Files</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="Aes.h"> @@ -80,9 +83,6 @@ <ClInclude Include="Rmd160.h"> <Filter>Header Files</Filter> </ClInclude> - <ClInclude Include="Serpent.h"> - <Filter>Header Files</Filter> - </ClInclude> <ClInclude Include="Sha2.h"> <Filter>Header Files</Filter> </ClInclude> @@ -101,6 +101,12 @@ <ClInclude Include="Streebog.h"> <Filter>Header Files</Filter> </ClInclude> + <ClInclude Include="SerpentFast.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="SerpentFast_sbox.h"> + <Filter>Header Files</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <CustomBuild Include="Aes_hw_cpu.asm"> diff --git a/src/Crypto/Sources b/src/Crypto/Sources index c7601a02..07e66b71 100644 --- a/src/Crypto/Sources +++ b/src/Crypto/Sources @@ -16,7 +16,8 @@ SOURCES = \ Aestab.c \ cpu.c \ Rmd160.c \ - Serpent.c \ + SerpentFast.c \ + SerpentFast_simd.cpp \ Sha2.c \ Twofish.c \ GostCipher.c \ diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h index 2d26e927..1057a373 100644 --- a/src/Crypto/cpu.h +++ b/src/Crypto/cpu.h @@ -69,8 +69,29 @@ extern void _mm_store_si128(__m128i *_P, __m128i _B); extern __m64 _m_pxor(__m64 _MM1, __m64 _MM2); extern __m128i _mm_set_epi64(__m64 _Q1, __m64 _Q0); extern __m128i _mm_setr_epi32(int _I0, int _I1, int _I2, int _I3); +extern __m128i _mm_loadu_si128(__m128i const*_P); +extern __m128i _mm_set_epi32(int _I3, int _I2, int _I1, int _I0); +extern __m128i _mm_set1_epi32(int _I); +extern void _mm_storeu_si128(__m128i *_P, __m128i _B); +extern __m128i _mm_or_si128(__m128i _A, __m128i _B); +extern __m128i _mm_slli_epi32(__m128i _A, int _Count); +extern __m128i _mm_srli_epi32(__m128i _A, int _Count); +extern __m128i _mm_add_epi32(__m128i _A, __m128i _B); +extern __m128i _mm_sub_epi32(__m128i _A, __m128i _B); +extern __m128i _mm_or_si128(__m128i _A, __m128i _B); +extern __m128i _mm_and_si128(__m128i _A, __m128i _B); +extern __m128i _mm_andnot_si128(__m128i _A, __m128i _B); +extern __m128i _mm_shufflehi_epi16(__m128i _A, int _Imm); +extern __m128i _mm_shufflelo_epi16(__m128i _A, int _Imm); +extern __m128i _mm_unpacklo_epi32(__m128i _A, __m128i _B); +extern __m128i _mm_unpackhi_epi32(__m128i _A, __m128i _B); +extern __m128i _mm_unpackhi_epi64(__m128i _A, __m128i _B); +extern __m128i _mm_srli_epi16(__m128i _A, int _Count); +extern __m128i _mm_slli_epi16(__m128i _A, int _Count); #define _mm_xor_si64 _m_pxor #define _mm_empty _m_empty +#define _MM_SHUFFLE(fp3,fp2,fp1,fp0) (((fp3) << 6) | ((fp2) << 4) | \ + ((fp1) << 2) | ((fp0))) #if defined(__cplusplus) } #endif @@ -396,4 +417,21 @@ extern int g_hasMMX; AS2( add outputPtr, increment*16) +#if defined(TC_WINDOWS_DRIVER) || defined (_UEFI) +#ifdef __cplusplus +extern "C" { +#endif +extern unsigned __int64 __cdecl _rotl64(unsigned __int64,int); +extern unsigned __int64 __cdecl _rotr64(unsigned __int64,int); +extern unsigned int __cdecl _rotl(unsigned int,int); +extern unsigned int __cdecl _rotr(unsigned int,int); +extern unsigned char _rotr8(unsigned char value, unsigned char shift); +extern unsigned short _rotr16(unsigned short value, unsigned char shift); +extern unsigned char _rotl8(unsigned char value, unsigned char shift); +extern unsigned short _rotl16(unsigned short value, unsigned char shift); +#ifdef __cplusplus +} +#endif +#endif + #endif diff --git a/src/Crypto/misc.h b/src/Crypto/misc.h index 31fa1187..47d0288a 100644 --- a/src/Crypto/misc.h +++ b/src/Crypto/misc.h @@ -12,6 +12,10 @@ #include "Tcdefs.h" #endif // !defined(_UEFI) +#ifdef __cplusplus +extern "C" { +#endif + #if defined(_MSC_VER) && !defined(_UEFI) #if _MSC_VER >= 1400 #if !defined(TC_WINDOWS_DRIVER) && !defined(_UEFI) @@ -175,4 +179,8 @@ VC_INLINE void CorrectEndianess(uint64 *out, const uint64 *in, size_t byteCount) #define IsAligned16(p) IsAlignedOn(p, GetAlignmentOf(uint64)) +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/Driver/Driver.vcxproj b/src/Driver/Driver.vcxproj index bc95ffe1..f534a0ee 100644 --- a/src/Driver/Driver.vcxproj +++ b/src/Driver/Driver.vcxproj @@ -193,6 +193,8 @@ BuildDriver.cmd -rebuild -debug -x64 "$(SolutionDir)\Common" "$(SolutionDir)\Cry </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\Crypto\Camellia.c" /> + <ClCompile Include="..\Crypto\SerpentFast.c" /> + <ClCompile Include="..\Crypto\SerpentFast_simd.cpp" /> <ClCompile Include="DriveFilter.c" /> <ClCompile Include="DumpFilter.c" /> <ClCompile Include="EncryptedIoQueue.c" /> @@ -213,7 +215,6 @@ BuildDriver.cmd -rebuild -debug -x64 "$(SolutionDir)\Common" "$(SolutionDir)\Cry <ClCompile Include="..\Crypto\Aeskey.c" /> <ClCompile Include="..\Crypto\Aestab.c" /> <ClCompile Include="..\Crypto\Rmd160.c" /> - <ClCompile Include="..\Crypto\Serpent.c" /> <ClCompile Include="..\Crypto\Sha2.c" /> <ClCompile Include="..\Crypto\Twofish.c" /> <ClCompile Include="..\Crypto\Whirlpool.c" /> diff --git a/src/Driver/Driver.vcxproj.filters b/src/Driver/Driver.vcxproj.filters index 73f45952..dfb7edac 100644 --- a/src/Driver/Driver.vcxproj.filters +++ b/src/Driver/Driver.vcxproj.filters @@ -90,9 +90,6 @@ <ClCompile Include="..\Crypto\Rmd160.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> - <ClCompile Include="..\Crypto\Serpent.c"> - <Filter>Source Files\Crypto</Filter> - </ClCompile> <ClCompile Include="..\Crypto\Sha2.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> @@ -105,6 +102,12 @@ <ClCompile Include="..\Crypto\Camellia.c"> <Filter>Source Files\Crypto</Filter> </ClCompile> + <ClCompile Include="..\Crypto\SerpentFast.c"> + <Filter>Source Files\Crypto</Filter> + </ClCompile> + <ClCompile Include="..\Crypto\SerpentFast_simd.cpp"> + <Filter>Source Files\Crypto</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <None Include="..\Crypto\Aes_hw_cpu.asm"> diff --git a/src/License.html b/src/License.html index d24beae5..333aa218 100644 --- a/src/License.html +++ b/src/License.html @@ -202,5 +202,19 @@ ________________________________________________________<br> <br> The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0<br> ____________________________________________________________<br> +<br> + Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. <br> + <br> + All rights reserved.<br> + <br> +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<br> + <br> +<ol> + <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li> + <li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li> +</ol> +<br> +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br> +____________________________________________________________<br> </body> </html> diff --git a/src/License.txt b/src/License.txt index 675207ec..5a638acf 100644 --- a/src/License.txt +++ b/src/License.txt @@ -742,3 +742,31 @@ version 3.0 (LGPL-3.0). The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0 ____________________________________________________________ +Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +____________________________________________________________ diff --git a/src/Main/Forms/AboutDialog.cpp b/src/Main/Forms/AboutDialog.cpp index 8949673c..214dd27d 100644 --- a/src/Main/Forms/AboutDialog.cpp +++ b/src/Main/Forms/AboutDialog.cpp @@ -51,14 +51,21 @@ namespace VeraCrypt L"Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, Niels Ferguson, " L"Lars Knudsen, Ross Anderson, Eli Biham, " L"Joan Daemen, Vincent Rijmen, " + L"Jean-loup Gailly, Mark Adler, " L"Phillip Rogaway, " - L"Hans Dobbertin, Antoon Bosselaers, Bart Preneel, " + L"Hans Dobbertin, Antoon Bosselaers, Bart Preneel, Jack Lloyd" L"Paulo Barreto, Brian Gladman, Wei Dai, Peter Gutmann, and many others.\n\n" L"Portions of this software:\n" + L"Copyright \xA9 2013-2016 IDRIX. All rights reserved.\n" L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\n" L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\n" L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\n" + L"Copyright \xA9 1995-2013 Jean-loup Gailly and Mark Adler.\n" + L"Copyright \xA9 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov.\n" + L"Copyright \xA9 Dieter Baron and Thomas Klausner.\n" + L"Copyright \xA9 2013, Alexey Degtyarev. All rights reserved.\n" + L"Copyright \xA9 1999-2013,2014,2015,2016 Jack Lloyd. All rights reserved.\n\n" L"\nThis software as a whole:\n" L"Copyright \xA9 2013-2016 IDRIX. All rights reserved.\n\n" diff --git a/src/Readme.txt b/src/Readme.txt index 41eabe9a..5280ac30 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -249,6 +249,7 @@ Copyright (c) 1995-2013 Jean-loup Gailly and Mark Adler. Copyright (c) 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov Copyright (c) Dieter Baron and Thomas Klausner. Copyright (c) 2013, Alexey Degtyarev. All rights reserved. +Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. All rights reserved. For more information, please see the legal notices attached to parts of the source code. diff --git a/src/Release/Setup Files/License.txt b/src/Release/Setup Files/License.txt index 675207ec..5a638acf 100644 --- a/src/Release/Setup Files/License.txt +++ b/src/Release/Setup Files/License.txt @@ -742,3 +742,31 @@ version 3.0 (LGPL-3.0). The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0 ____________________________________________________________ +Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +____________________________________________________________ diff --git a/src/Release/Setup Files/NOTICE b/src/Release/Setup Files/NOTICE index a87a4d33..7ded056f 100644 --- a/src/Release/Setup Files/NOTICE +++ b/src/Release/Setup Files/NOTICE @@ -174,4 +174,31 @@ version 3.0 (LGPL-3.0). The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0 ____________________________________________________________ +Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS +OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER +IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR +OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN +IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +____________________________________________________________ diff --git a/src/Resources/Texts/License.rtf b/src/Resources/Texts/License.rtf index cccbb15d..1af5c90f 100644 --- a/src/Resources/Texts/License.rtf +++ b/src/Resources/Texts/License.rtf @@ -57,5 +57,11 @@ Copyright (c) 2013, Alexey Degtyarev. All rights reserved.\par ____________________________________________________________\par
Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov\par
This program and the accompanying materials are licensed and made available under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).\line\line The full text of the license may be found at {\field{\*\fldinst{HYPERLINK "https://opensource.org/licenses/LGPL-3.0"}}{\fldrslt{\ul\cf1 https://opensource.org/licenses/LGPL-3.0}}}\f0\fs16\par
+____________________________________________________________\f2\par
+Copyright (c) 1999-2013,2014,2015,2016 Jack Lloyd. All rights reserved.\par
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\par
+1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\par
+2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\par
+THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\f0\par
}
diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp index 3363f640..09c821bb 100644 --- a/src/Volume/Cipher.cpp +++ b/src/Volume/Cipher.cpp @@ -13,7 +13,7 @@ #include "Platform/Platform.h" #include "Cipher.h" #include "Crypto/Aes.h" -#include "Crypto/Serpent.h" +#include "Crypto/SerpentFast.h" #include "Crypto/Twofish.h" #include "Crypto/Camellia.h" #include "Crypto/GostCipher.h" @@ -21,8 +21,8 @@ #ifdef TC_AES_HW_CPU # include "Crypto/Aes_hw_cpu.h" -# include "Crypto/cpu.h" #endif +#include "Crypto/cpu.h" namespace VeraCrypt { @@ -224,6 +224,55 @@ namespace VeraCrypt { serpent_set_key (key, ScheduledKey); } + + void CipherSerpent::EncryptBlocks (byte *data, size_t blockCount) const + { + if (!Initialized) + throw NotInitialized (SRC_POS); + +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + if ((blockCount >= 4) + && IsHwSupportAvailable()) + { + serpent_encrypt_blocks (data, data, blockCount, ScheduledKey.Ptr()); + } + else +#endif + Cipher::EncryptBlocks (data, blockCount); + } + + void CipherSerpent::DecryptBlocks (byte *data, size_t blockCount) const + { + if (!Initialized) + throw NotInitialized (SRC_POS); + +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + if ((blockCount >= 4) + && IsHwSupportAvailable()) + { + serpent_decrypt_blocks (data, data, blockCount, ScheduledKey.Ptr()); + } + else +#endif + Cipher::DecryptBlocks (data, blockCount); + } + + bool CipherSerpent::IsHwSupportAvailable () const + { +#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE + static bool state = false; + static bool stateValid = false; + + if (!stateValid) + { + state = HasSSE2() ? true : false; + stateValid = true; + } + return state; +#else + return false; +#endif + } // Twofish diff --git a/src/Volume/Cipher.h b/src/Volume/Cipher.h index 1805229e..7aefbfc6 100644 --- a/src/Volume/Cipher.h +++ b/src/Volume/Cipher.h @@ -100,11 +100,11 @@ namespace VeraCrypt virtual bool IsHwSupportAvailable () const; TC_CIPHER (AES, 16, 32); + TC_CIPHER (Serpent, 16, 32); #undef TC_CIPHER_ADD_METHODS #define TC_CIPHER_ADD_METHODS - TC_CIPHER (Serpent, 16, 32); TC_CIPHER (Twofish, 16, 32); TC_CIPHER (Camellia, 16, 32); TC_CIPHER (Gost89, 16, 32); diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make index 855e5f60..fa3a4207 100644 --- a/src/Volume/Volume.make +++ b/src/Volume/Volume.make @@ -47,7 +47,8 @@ OBJS += ../Crypto/Aeskey.o OBJS += ../Crypto/Aestab.o OBJS += ../Crypto/cpu.o OBJS += ../Crypto/Rmd160.o -OBJS += ../Crypto/Serpent.o +OBJS += ../Crypto/SerpentFast.o +OBJS += ../Crypto/SerpentFast_simd.o OBJS += ../Crypto/Sha2.o OBJS += ../Crypto/Twofish.o OBJS += ../Crypto/Whirlpool.o |