VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Cipher.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2016-11-28 00:29:36 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2016-12-07 12:36:04 +0100
commit263abeee3a8c97e98fec49ee0ce628d6c5c5df50 (patch)
treec6a326a7c90280cb3926c58275f361b999bd2ba3 /src/Volume/Cipher.cpp
parent68fababbe88cf213b3f2f3a71d66c2b05196aaed (diff)
downloadVeraCrypt-263abeee3a8c97e98fec49ee0ce628d6c5c5df50.tar.gz
VeraCrypt-263abeee3a8c97e98fec49ee0ce628d6c5c5df50.zip
Crypto: Add optimized Twofish assembly implementation for x86_64.
Diffstat (limited to 'src/Volume/Cipher.cpp')
-rw-r--r--src/Volume/Cipher.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp
index 09c821bb..be8cc3eb 100644
--- a/src/Volume/Cipher.cpp
+++ b/src/Volume/Cipher.cpp
@@ -296,6 +296,39 @@ namespace VeraCrypt
twofish_set_key ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *) key);
}
+ void CipherTwofish::EncryptBlocks (byte *data, size_t blockCount) const
+ {
+ if (!Initialized)
+ throw NotInitialized (SRC_POS);
+
+#if CRYPTOPP_BOOL_X64
+ twofish_encrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount);
+#else
+ Cipher::EncryptBlocks (data, blockCount);
+#endif
+ }
+
+ void CipherTwofish::DecryptBlocks (byte *data, size_t blockCount) const
+ {
+ if (!Initialized)
+ throw NotInitialized (SRC_POS);
+
+#if CRYPTOPP_BOOL_X64
+ twofish_decrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount);
+#else
+ Cipher::DecryptBlocks (data, blockCount);
+#endif
+ }
+
+ bool CipherTwofish::IsHwSupportAvailable () const
+ {
+#if CRYPTOPP_BOOL_X64
+ return true;
+#else
+ return false;
+#endif
+ }
+
// Camellia
void CipherCamellia::Decrypt (byte *data) const
{