VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume
diff options
context:
space:
mode:
Diffstat (limited to 'src/Volume')
-rw-r--r--src/Volume/Cipher.cpp50
-rw-r--r--src/Volume/Cipher.h2
-rw-r--r--src/Volume/Volume.make10
3 files changed, 61 insertions, 1 deletions
diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp
index be8cc3eb..1b5df79f 100644
--- a/src/Volume/Cipher.cpp
+++ b/src/Volume/Cipher.cpp
@@ -24,6 +24,23 @@
#endif
#include "Crypto/cpu.h"
+extern "C" int IsAesHwCpuSupported ()
+{
+#ifdef TC_AES_HW_CPU
+ static bool state = false;
+ static bool stateValid = false;
+
+ if (!stateValid)
+ {
+ state = g_hasAESNI ? true : false;
+ stateValid = true;
+ }
+ return state && Cipher::IsHwSupportEnabled();
+#else
+ return false;
+#endif
+}
+
namespace VeraCrypt
{
Cipher::Cipher () : Initialized (false)
@@ -349,6 +366,39 @@ namespace VeraCrypt
{
camellia_set_key (key, ScheduledKey.Ptr());
}
+
+ void CipherCamellia::EncryptBlocks (byte *data, size_t blockCount) const
+ {
+ if (!Initialized)
+ throw NotInitialized (SRC_POS);
+
+#if CRYPTOPP_BOOL_X64
+ camellia_encrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount);
+#else
+ Cipher::EncryptBlocks (data, blockCount);
+#endif
+ }
+
+ void CipherCamellia::DecryptBlocks (byte *data, size_t blockCount) const
+ {
+ if (!Initialized)
+ throw NotInitialized (SRC_POS);
+
+#if CRYPTOPP_BOOL_X64
+ camellia_decrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount);
+#else
+ Cipher::DecryptBlocks (data, blockCount);
+#endif
+ }
+
+ bool CipherCamellia::IsHwSupportAvailable () const
+ {
+#if CRYPTOPP_BOOL_X64
+ return true;
+#else
+ return false;
+#endif
+ }
// GOST89
void CipherGost89::Decrypt (byte *data) const
diff --git a/src/Volume/Cipher.h b/src/Volume/Cipher.h
index 5ebdde19..25410891 100644
--- a/src/Volume/Cipher.h
+++ b/src/Volume/Cipher.h
@@ -103,11 +103,11 @@ namespace VeraCrypt
TC_CIPHER (AES, 16, 32);
TC_CIPHER (Serpent, 16, 32);
TC_CIPHER (Twofish, 16, 32);
+ TC_CIPHER (Camellia, 16, 32);
#undef TC_CIPHER_ADD_METHODS
#define TC_CIPHER_ADD_METHODS
- TC_CIPHER (Camellia, 16, 32);
TC_CIPHER (Gost89, 16, 32);
TC_CIPHER (Gost89StaticSBOX, 16, 32);
TC_CIPHER (Kuznyechik, 16, 32);
diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make
index 40f1281d..0ecc7f42 100644
--- a/src/Volume/Volume.make
+++ b/src/Volume/Volume.make
@@ -34,6 +34,8 @@ ifeq "$(PLATFORM)" "MacOSX"
OBJS += ../Crypto/Aes_hw_cpu.o
OBJS += ../Crypto/Aescrypt.o
OBJSEX += ../Crypto/Twofish_asm.oo
+ OBJSEX += ../Crypto/Camellia_asm.oo
+ OBJSEX += ../Crypto/Camellia_aesni_asm.oo
else ifeq "$(CPU_ARCH)" "x86"
OBJS += ../Crypto/Aes_x86.o
OBJS += ../Crypto/Aes_hw_cpu.o
@@ -41,6 +43,8 @@ else ifeq "$(CPU_ARCH)" "x64"
OBJS += ../Crypto/Aes_x64.o
OBJS += ../Crypto/Aes_hw_cpu.o
OBJS += ../Crypto/Twofish_x64.o
+ OBJS += ../Crypto/Camellia_x64.o
+ OBJS += ../Crypto/Camellia_aesni_x64.o
else
OBJS += ../Crypto/Aescrypt.o
endif
@@ -77,6 +81,12 @@ ifeq "$(PLATFORM)" "MacOSX"
../Crypto/Twofish_asm.oo: ../Crypto/Twofish_x64.S
@echo Assembling $(<F)
$(YASM) -p gas -f macho64 -o ../Crypto/Twofish_asm.oo ../Crypto/Twofish_x64.S
+../Crypto/Camellia_asm.oo: ../Crypto/Camellia_x64.S
+ @echo Assembling $(<F)
+ $(YASM) -p gas -f macho64 -o ../Crypto/Camellia_asm.oo ../Crypto/Camellia_x64.S
+../Crypto/Camellia_aesni_asm.oo: ../Crypto/Camellia_aesni_x64.S
+ @echo Assembling $(<F)
+ $(YASM) -p gas -f macho64 -o ../Crypto/Camellia_aesni_asm.oo ../Crypto/Camellia_aesni_x64.S
endif
include $(BUILD_INC)/Makefile.inc