1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Crypto: Use SIMD optimized Serpent implementation from Botan. 2.5x speed gain factor. Update credits and copyrights notice.

This commit is contained in:
Mounir IDRASSI
2016-10-04 13:21:48 +02:00
parent 7ff3c5d108
commit e5a9e9239b
21 changed files with 285 additions and 26 deletions

View File

@@ -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