mirror of
https://github.com/veracrypt/VeraCrypt
synced 2024-11-24 12:03:28 +01:00
Crypto: Use SIMD optimized Serpent implementation from Botan. 2.5x speed gain factor. Update credits and copyrights notice.
This commit is contained in:
parent
7ff3c5d108
commit
e5a9e9239b
@ -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
|
||||
|
@ -193,7 +193,11 @@ typedef struct
|
||||
#endif
|
||||
|
||||
#include "Aes_hw_cpu.h"
|
||||
#if !defined (TC_WINDOWS_BOOT)
|
||||
# include "SerpentFast.h"
|
||||
#else
|
||||
# include "Serpent.h"
|
||||
#endif
|
||||
#include "Twofish.h"
|
||||
|
||||
#include "Rmd160.h"
|
||||
|
@ -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"
|
||||
|
@ -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;
|
||||
|
@ -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" />
|
||||
|
@ -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">
|
||||
|
@ -16,7 +16,8 @@ SOURCES = \
|
||||
Aestab.c \
|
||||
cpu.c \
|
||||
Rmd160.c \
|
||||
Serpent.c \
|
||||
SerpentFast.c \
|
||||
SerpentFast_simd.cpp \
|
||||
Sha2.c \
|
||||
Twofish.c \
|
||||
GostCipher.c \
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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" />
|
||||
|
@ -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">
|
||||
|
@ -202,5 +202,19 @@
|
||||
<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>
|
||||
|
@ -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.
|
||||
____________________________________________________________
|
||||
|
@ -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"
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
____________________________________________________________
|
||||
|
@ -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.
|
||||
____________________________________________________________
|
||||
|
Binary file not shown.
@ -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
|
||||
{
|
||||
@ -225,6 +225,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
|
||||
void CipherTwofish::Decrypt (byte *data) const
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user