VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-04 13:21:48 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-10-17 18:40:23 +0200
commite5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f (patch)
tree5656a151e5f777d834924a3784432c5bd928ed03 /src/Common
parent7ff3c5d1080482c55a5c5f4720d22d212a8d7373 (diff)
downloadVeraCrypt-e5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f.tar.gz
VeraCrypt-e5a9e9239b0cf1001d9b91497b4ff3ab4a190b1f.zip
Crypto: Use SIMD optimized Serpent implementation from Botan. 2.5x speed gain factor. Update credits and copyrights notice.
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Crypto.c38
-rw-r--r--src/Common/Crypto.h6
-rw-r--r--src/Common/Dlgcode.c7
-rw-r--r--src/Common/Xts.c4
4 files changed, 47 insertions, 8 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;