VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common/Crypto.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2017-11-27 09:10:17 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2017-11-27 16:16:35 +0100
commitf53eb8e260d174153bb3fc24ff1fff7966dcfbee (patch)
treeb8e5263c7fc7e90177ca7c296f6bc493fc735877 /src/Common/Crypto.c
parent685fad2d5d56ff1049ba2f5c8b901bca5a4a07bd (diff)
downloadVeraCrypt-f53eb8e260d174153bb3fc24ff1fff7966dcfbee.tar.gz
VeraCrypt-f53eb8e260d174153bb3fc24ff1fff7966dcfbee.zip
SIMD speed optimization for Kuznyechik cipher implementation (up to 2x speedup). Based on https://github.com/aprelev/libgost15.
Diffstat (limited to 'src/Common/Crypto.c')
-rw-r--r--src/Common/Crypto.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index c7b0c73d..3f7e9871 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -255,6 +255,20 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
camellia_encrypt_blocks(ks, data, data, (uint32) blockCount);
}
#endif
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
+ else if (cipher == KUZNYECHIK
+ && HasSSE2()
+#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
+ && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
+#endif
+ )
+ {
+ kuznyechik_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);
}
@@ -358,6 +372,20 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
camellia_decrypt_blocks(ks, data, data, (uint32) blockCount);
}
#endif
+#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
+ else if (cipher == KUZNYECHIK
+ && HasSSE2()
+#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
+ && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
+#endif
+ )
+ {
+ kuznyechik_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);
}
@@ -429,6 +457,7 @@ BOOL CipherSupportsIntraDataUnitParallelization (int cipher)
|| (cipher == GOST89)
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
|| (cipher == SERPENT && HasSSE2())
+ || (cipher == KUZNYECHIK && HasSSE2())
#endif
#if CRYPTOPP_BOOL_X64
|| (cipher == TWOFISH)