VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-07-20 12:30:58 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-11-08 23:21:35 +0100
commita5c1978eefe2fd0dbf1ab6b7cdcb019a9b913a40 (patch)
treebb48f3b5544dc218228d368a7e893a83f0c0b059 /src
parent75f780871949e5bacca4718507e66c8d28d72e69 (diff)
downloadVeraCrypt-a5c1978eefe2fd0dbf1ab6b7cdcb019a9b913a40.tar.gz
VeraCrypt-a5c1978eefe2fd0dbf1ab6b7cdcb019a9b913a40.zip
Remove remaining legacy cryptographic algorithms that are never used by VeraCrypt.
Diffstat (limited to 'src')
-rw-r--r--src/Common/Crypto.h3
-rw-r--r--src/Common/Dlgcode.c10
-rw-r--r--src/Common/Pkcs5.h3
-rw-r--r--src/Common/Tests.h1
-rw-r--r--src/Core/Unix/Linux/CoreLinux.cpp7
-rw-r--r--src/Crypto/Crypto.vcproj16
-rw-r--r--src/Crypto/Sources4
-rw-r--r--src/Main/GraphicUserInterface.cpp1
-rw-r--r--src/Main/TextUserInterface.cpp1
-rw-r--r--src/Volume/Cipher.cpp73
-rw-r--r--src/Volume/Cipher.h3
-rw-r--r--src/Volume/EncryptionAlgorithm.cpp76
-rw-r--r--src/Volume/EncryptionAlgorithm.h5
-rw-r--r--src/Volume/EncryptionMode.cpp4
-rw-r--r--src/Volume/EncryptionModeCBC.cpp335
-rw-r--r--src/Volume/EncryptionModeCBC.h47
-rw-r--r--src/Volume/EncryptionModeLRW.cpp195
-rw-r--r--src/Volume/EncryptionModeLRW.h50
-rw-r--r--src/Volume/EncryptionTest.cpp81
-rw-r--r--src/Volume/Hash.cpp27
-rw-r--r--src/Volume/Hash.h22
-rw-r--r--src/Volume/Pkcs5Kdf.cpp7
-rw-r--r--src/Volume/Pkcs5Kdf.h15
-rw-r--r--src/Volume/Volume.cpp5
-rw-r--r--src/Volume/Volume.make4
-rw-r--r--src/Volume/VolumeLayout.cpp18
26 files changed, 1 insertions, 1012 deletions
diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h
index f183a436..e66ac18c 100644
--- a/src/Common/Crypto.h
+++ b/src/Common/Crypto.h
@@ -45,43 +45,40 @@ extern "C" {
// The first PRF to try when mounting
#define FIRST_PRF_ID 1
// Hash algorithms (pseudorandom functions).
enum
{
RIPEMD160 = FIRST_PRF_ID,
#ifndef TC_WINDOWS_BOOT
SHA512,
WHIRLPOOL,
#endif
HASH_ENUM_END_ID
};
// The last PRF to try when mounting and also the number of implemented PRFs
#define LAST_PRF_ID (HASH_ENUM_END_ID - 1)
#define RIPEMD160_BLOCKSIZE 64
#define RIPEMD160_DIGESTSIZE 20
-#define SHA1_BLOCKSIZE 64
-#define SHA1_DIGESTSIZE 20
-
#define SHA512_BLOCKSIZE 128
#define SHA512_DIGESTSIZE 64
#define WHIRLPOOL_BLOCKSIZE 64
#define WHIRLPOOL_DIGESTSIZE 64
#define MAX_DIGESTSIZE WHIRLPOOL_DIGESTSIZE
#define DEFAULT_HASH_ALGORITHM FIRST_PRF_ID
#define DEFAULT_HASH_ALGORITHM_BOOT RIPEMD160
// The mode of operation used for newly created volumes and first to try when mounting
#define FIRST_MODE_OF_OPERATION_ID 1
// Modes of operation
enum
{
/* If you add/remove a mode, update the following: GetMaxPkcs5OutSize(), EAInitMode() */
XTS = FIRST_MODE_OF_OPERATION_ID,
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index b40a41cd..092c8c6f 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -4336,56 +4336,50 @@ static BOOL PerformBenchmark(HWND hwndDlg)
{
EncryptDataUnits (lpTestBuffer, &startDataUnitNo, (TC_LARGEST_COMPILER_UINT) benchmarkBufferSize / ENCRYPTION_DATA_UNIT_SIZE, ci);
DecryptDataUnits (lpTestBuffer, &startDataUnitNo, (TC_LARGEST_COMPILER_UINT) benchmarkBufferSize / ENCRYPTION_DATA_UNIT_SIZE, ci);
}
}
}
#endif
#if HASH_FNC_BENCHMARKS
/* Measures the speed at which each of the hash algorithms processes the message to produce
a single digest.
The hash algorithm benchmarks are included here for development purposes only. Do not enable
them when building a public release (the benchmark GUI strings wouldn't make sense). */
{
BYTE *digest [MAX_DIGESTSIZE];
WHIRLPOOL_CTX wctx;
RMD160_CTX rctx;
- sha1_ctx sctx;
sha512_ctx s2ctx;
int hid;
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
if (QueryPerformanceCounter (&performanceCountStart) == 0)
goto counter_error;
switch (hid)
{
- case SHA1:
- sha1_begin (&sctx);
- sha1_hash (lpTestBuffer, benchmarkBufferSize, &sctx);
- sha1_end ((unsigned char *) digest, &sctx);
- break;
case SHA512:
sha512_begin (&s2ctx);
sha512_hash (lpTestBuffer, benchmarkBufferSize, &s2ctx);
sha512_end ((unsigned char *) digest, &s2ctx);
break;
case RIPEMD160:
RMD160Init(&rctx);
RMD160Update(&rctx, lpTestBuffer, benchmarkBufferSize);
RMD160Final((unsigned char *) digest, &rctx);
break;
case WHIRLPOOL:
WHIRLPOOL_init (&wctx);
WHIRLPOOL_add (lpTestBuffer, benchmarkBufferSize * 8, &wctx);
WHIRLPOOL_finalize (&wctx, (unsigned char *) digest);
break;
}
@@ -4407,44 +4401,40 @@ static BOOL PerformBenchmark(HWND hwndDlg)
/* Measures the time that it takes for the PKCS-5 routine to derive a header key using
each of the implemented PRF algorithms.
The PKCS-5 benchmarks are included here for development purposes only. Do not enable
them when building a public release (the benchmark GUI strings wouldn't make sense). */
{
int thid, i;
char dk[MASTER_KEYDATA_SIZE];
char *tmp_salt = {"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"};
for (thid = FIRST_PRF_ID; thid <= LAST_PRF_ID; thid++)
{
if (QueryPerformanceCounter (&performanceCountStart) == 0)
goto counter_error;
for (i = 1; i <= 5; i++)
{
switch (thid)
{
- case SHA1:
- /* PKCS-5 test with HMAC-SHA-1 used as the PRF */
- derive_key_sha1 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE), dk, MASTER_KEYDATA_SIZE);
- break;
case SHA512:
/* PKCS-5 test with HMAC-SHA-512 used as the PRF */
derive_key_sha512 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE), dk, MASTER_KEYDATA_SIZE);
break;
case RIPEMD160:
/* PKCS-5 test with HMAC-RIPEMD-160 used as the PRF */
derive_key_ripemd160 (FALSE, "passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE), dk, MASTER_KEYDATA_SIZE);
break;
case WHIRLPOOL:
/* PKCS-5 test with HMAC-Whirlpool used as the PRF */
derive_key_whirlpool ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE), dk, MASTER_KEYDATA_SIZE);
break;
}
}
if (QueryPerformanceCounter (&performanceCountEnd) == 0)
goto counter_error;
diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h
index 5a286fb5..148a3e2d 100644
--- a/src/Common/Pkcs5.h
+++ b/src/Common/Pkcs5.h
@@ -5,37 +5,34 @@
Agreement for Encryption for the Masses'. Modifications and additions to
the original source code (contained in this file) and all other portions
of this file are Copyright (c) 2003-2008 TrueCrypt Developers Association
and are governed by the TrueCrypt License 3.0 the full text of which is
contained in the file License.txt included in TrueCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_PKCS5
#define TC_HEADER_PKCS5
#include "Tcdefs.h"
#if defined(__cplusplus)
extern "C"
{
#endif
void hmac_sha512 (char *k, int lk, char *d, int ld, char *out, int t);
void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
-void hmac_sha1 (char *k, int lk, char *d, int ld, char *out, int t);
-void derive_u_sha1 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
-void derive_key_sha1 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
void hmac_ripemd160 (char *key, int keylen, char *input, int len, char *digest);
void derive_u_ripemd160 (BOOL bNotTest, char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
void derive_key_ripemd160 (BOOL bNotTest, char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
void hmac_whirlpool (char *k, int lk, char *d, int ld, char *out, int t);
void derive_u_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
int get_pkcs5_iteration_count (int pkcs5_prf_id, BOOL bBoot);
char *get_pkcs5_prf_name (int pkcs5_prf_id);
#if defined(__cplusplus)
}
#endif
#endif // TC_HEADER_PKCS5
diff --git a/src/Common/Tests.h b/src/Common/Tests.h
index cd8aaf4c..e98ae884 100644
--- a/src/Common/Tests.h
+++ b/src/Common/Tests.h
@@ -1,30 +1,29 @@
/*
Legal Notice: Some portions of the source code contained in this file were
derived from the source code of Encryption for the Masses 2.02a, which is
Copyright (c) 1998-2000 Paul Le Roux and which is governed by the 'License
Agreement for Encryption for the Masses'. Modifications and additions to
the original source code (contained in this file) and all other portions
of this file are Copyright (c) 2003-2008 TrueCrypt Developers Association
and are governed by the TrueCrypt License 3.0 the full text of which is
contained in the file License.txt included in TrueCrypt binary and source
code distribution packages. */
#ifdef __cplusplus
extern "C" {
#endif
extern unsigned char ks_tmp[MAX_EXPANDED_KEY];
void CipherInit2(int cipher, void* key, void* ks, int key_len);
BOOL test_hmac_sha512 (void);
-BOOL test_hmac_sha1 (void);
BOOL test_hmac_ripemd160 (void);
BOOL test_hmac_whirlpool (void);
BOOL test_pkcs5 (void);
BOOL TestSectorBufEncryption ();
BOOL TestLegacySectorBufEncryption ();
BOOL AutoTestAlgorithms (void);
#ifdef __cplusplus
}
#endif
diff --git a/src/Core/Unix/Linux/CoreLinux.cpp b/src/Core/Unix/Linux/CoreLinux.cpp
index 4170cdfe..83c91dd2 100644
--- a/src/Core/Unix/Linux/CoreLinux.cpp
+++ b/src/Core/Unix/Linux/CoreLinux.cpp
@@ -1,40 +1,39 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include <fstream>
#include <iomanip>
#include <mntent.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/mount.h>
#include <sys/wait.h>
#include "CoreLinux.h"
#include "Platform/SystemInfo.h"
#include "Platform/TextReader.h"
-#include "Volume/EncryptionModeLRW.h"
#include "Volume/EncryptionModeXTS.h"
#include "Driver/Fuse/FuseService.h"
#include "Core/Unix/CoreServiceProxy.h"
namespace VeraCrypt
{
CoreLinux::CoreLinux ()
{
}
CoreLinux::~CoreLinux ()
{
}
DevicePath CoreLinux::AttachFileToLoopDevice (const FilePath &filePath, bool readOnly) const
{
list <string> loopPaths;
loopPaths.push_back ("/dev/loop");
loopPaths.push_back ("/dev/loop/");
loopPaths.push_back ("/dev/.static/dev/loop");
@@ -273,44 +272,43 @@ namespace VeraCrypt
try
{
if (!FilesystemSupportsUnixPermissions (devicePath))
{
stringstream userMountOptions;
userMountOptions << "uid=" << GetRealUserId() << ",gid=" << GetRealGroupId() << ",umask=077" << (!systemMountOptions.empty() ? "," : "");
CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, userMountOptions.str() + systemMountOptions);
fsMounted = true;
}
}
catch (...) { }
if (!fsMounted)
CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, systemMountOptions);
}
void CoreLinux::MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const
{
bool xts = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeXTS));
- bool lrw = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeLRW));
if (options.NoKernelCrypto
- || (!xts && (!lrw || volume->GetEncryptionAlgorithm()->GetCiphers().size() > 1 || volume->GetEncryptionAlgorithm()->GetMinBlockSize() != 16))
+ || !xts
|| volume->GetProtectionType() == VolumeProtection::HiddenVolumeReadOnly)
{
throw NotApplicable (SRC_POS);
}
if (!SystemInfo::IsVersionAtLeast (2, 6, xts ? 24 : 20))
throw NotApplicable (SRC_POS);
// Load device mapper kernel module
list <string> execArgs;
foreach (const string &dmModule, StringConverter::Split ("dm_mod dm-mod dm"))
{
execArgs.clear();
execArgs.push_back (dmModule);
try
{
Process::Execute ("modprobe", execArgs);
break;
}
@@ -355,43 +353,40 @@ namespace VeraCrypt
dmCreateArgs << ' ' << (xts ? startSector + volume->GetEncryptionMode()->GetSectorOffset() : 0) << ' ';
if (nativeDevCount == 0)
dmCreateArgs << string (volumePath) << ' ' << startSector;
else
dmCreateArgs << nativeDevPath << " 0";
SecureBuffer dmCreateArgsBuf (dmCreateArgs.str().size());
dmCreateArgsBuf.CopyFrom (ConstBufferPtr ((byte *) dmCreateArgs.str().c_str(), dmCreateArgs.str().size()));
// Keys
const SecureBuffer &cipherKey = cipher.GetKey();
secondaryKeyOffset -= cipherKey.Size();
ConstBufferPtr secondaryKey = volume->GetEncryptionMode()->GetKey().GetRange (xts ? secondaryKeyOffset : 0, xts ? cipherKey.Size() : 16);
SecureBuffer hexStr (3);
for (size_t i = 0; i < cipherKey.Size(); ++i)
{
sprintf ((char *) hexStr.Ptr(), "%02x", (int) cipherKey[i]);
dmCreateArgsBuf.GetRange (keyArgOffset + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2));
- if (lrw && i >= 16)
- continue;
-
sprintf ((char *) hexStr.Ptr(), "%02x", (int) secondaryKey[i]);
dmCreateArgsBuf.GetRange (keyArgOffset + cipherKey.Size() * 2 + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2));
}
stringstream nativeDevName;
nativeDevName << "veracrypt" << options.SlotNumber;
if (nativeDevCount != cipherCount - 1)
nativeDevName << "_" << cipherCount - nativeDevCount - 2;
nativeDevPath = "/dev/mapper/" + nativeDevName.str();
execArgs.clear();
execArgs.push_back ("create");
execArgs.push_back (nativeDevName.str());
Process::Execute ("dmsetup", execArgs, -1, nullptr, &dmCreateArgsBuf);
// Wait for the device to be created
for (int t = 0; true; t++)
diff --git a/src/Crypto/Crypto.vcproj b/src/Crypto/Crypto.vcproj
index 72e6f645..b28feb1e 100644
--- a/src/Crypto/Crypto.vcproj
+++ b/src/Crypto/Crypto.vcproj
@@ -237,64 +237,48 @@
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\Aes.h"
>
</File>
<File
RelativePath=".\Aes_hw_cpu.h"
>
</File>
<File
RelativePath=".\Aesopt.h"
>
</File>
<File
RelativePath=".\Aestab.h"
>
</File>
<File
- RelativePath=".\Blowfish.h"
- >
- </File>
- <File
- RelativePath=".\Cast.h"
- >
- </File>
- <File
- RelativePath=".\Des.h"
- >
- </File>
- <File
RelativePath=".\Rmd160.h"
>
</File>
<File
RelativePath=".\Serpent.h"
>
</File>
<File
- RelativePath=".\Sha1.h"
- >
- </File>
- <File
RelativePath=".\Sha2.h"
>
</File>
<File
RelativePath=".\Twofish.h"
>
</File>
<File
RelativePath=".\Whirlpool.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
diff --git a/src/Crypto/Sources b/src/Crypto/Sources
index f38c268e..417f0e04 100644
--- a/src/Crypto/Sources
+++ b/src/Crypto/Sources
@@ -1,23 +1,19 @@
TARGETNAME=Crypto
TARGETTYPE=DRIVER_LIBRARY
INCLUDES = ..
NTTARGETFILES = \
"$(OBJ_PATH)\$(O)\Aes_$(TC_ARCH).obj" \
"$(OBJ_PATH)\$(O)\Aes_hw_cpu.obj"
SOURCES = \
Aes_$(TC_ARCH).asm \
Aes_hw_cpu.asm \
Aeskey.c \
Aestab.c \
- Blowfish.c \
- Cast.c \
- Des.c \
Rmd160.c \
Serpent.c \
- Sha1.c \
Sha2.c \
Twofish.c \
Whirlpool.c
diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp
index 642a572c..e225726a 100644
--- a/src/Main/GraphicUserInterface.cpp
+++ b/src/Main/GraphicUserInterface.cpp
@@ -726,41 +726,40 @@ namespace VeraCrypt
ShowWarning (e);
}
}
else
ShowWarning (e);
}
catch (PasswordException &e)
{
ShowWarning (e);
}
}
}
catch (exception &e)
{
ShowError (e);
}
#ifdef TC_LINUX
if (volume && !Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning
&& volume->EncryptionModeName != L"XTS"
- && (volume->EncryptionModeName != L"LRW" || volume->EncryptionAlgorithmMinBlockSize != 16 || volume->EncryptionAlgorithmKeySize != 32)
&& !AskYesNo (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"] + _("\n\nDo you want to show this message next time you mount such a volume?"), true, true))
{
UserPreferences prefs = GetPreferences();
prefs.DisableKernelEncryptionModeWarning = true;
Gui->SetPreferences (prefs);
}
#endif
return volume;
}
void GraphicUserInterface::OnAutoDismountAllEvent ()
{
VolumeInfoList mountedVolumes = Core->GetMountedVolumes();
if (!mountedVolumes.empty())
{
wxBusyCursor busy;
AutoDismountVolumes (mountedVolumes);
}
}
diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp
index d4189a43..12647707 100644
--- a/src/Main/TextUserInterface.cpp
+++ b/src/Main/TextUserInterface.cpp
@@ -1167,41 +1167,40 @@ namespace VeraCrypt
}
}
else
{
ShowInfo (e);
options.Password.reset();
}
ShowString (L"\n");
}
catch (PasswordException &e)
{
ShowInfo (e);
options.Password.reset();
}
}
#ifdef TC_LINUX
if (!Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning
&& volume->EncryptionModeName != L"XTS"
- && (volume->EncryptionModeName != L"LRW" || volume->EncryptionAlgorithmMinBlockSize != 16 || volume->EncryptionAlgorithmKeySize != 32))
{
ShowWarning (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"]);
}
#endif
return volume;
}
bool TextUserInterface::OnInit ()
{
try
{
DefaultMessageOutput = new wxMessageOutputStderr;
wxMessageOutput::Set (DefaultMessageOutput);
InterfaceType = UserInterfaceType::Text;
Init();
}
catch (exception &e)
{
diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp
index a69f15d9..5708e6e0 100644
--- a/src/Volume/Cipher.cpp
+++ b/src/Volume/Cipher.cpp
@@ -1,34 +1,31 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "Platform/Platform.h"
#include "Cipher.h"
#include "Crypto/Aes.h"
-#include "Crypto/Blowfish.h"
-#include "Crypto/Des.h"
-#include "Crypto/Cast.h"
#include "Crypto/Serpent.h"
#include "Crypto/Twofish.h"
#ifdef TC_AES_HW_CPU
# include "Crypto/Aes_hw_cpu.h"
#endif
namespace VeraCrypt
{
Cipher::Cipher () : Initialized (false)
{
}
Cipher::~Cipher ()
{
}
void Cipher::DecryptBlock (byte *data) const
{
if (!Initialized)
@@ -59,43 +56,40 @@ namespace VeraCrypt
void Cipher::EncryptBlocks (byte *data, size_t blockCount) const
{
if (!Initialized)
throw NotInitialized (SRC_POS);
while (blockCount-- > 0)
{
Encrypt (data);
data += GetBlockSize();
}
}
CipherList Cipher::GetAvailableCiphers ()
{
CipherList l;
l.push_back (shared_ptr <Cipher> (new CipherAES ()));
l.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
l.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
- l.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
- l.push_back (shared_ptr <Cipher> (new CipherCast5 ()));
- l.push_back (shared_ptr <Cipher> (new CipherTripleDES ()));
return l;
}
void Cipher::SetKey (const ConstBufferPtr &key)
{
if (key.Size() != GetKeySize ())
throw ParameterIncorrect (SRC_POS);
if (!Initialized)
ScheduledKey.Allocate (GetScheduledKeySize ());
SetCipherKey (key);
Key.CopyFrom (key);
Initialized = true;
}
#define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE)
#undef TC_EXCEPTION_NODECL
#define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE)
@@ -182,129 +176,62 @@ namespace VeraCrypt
if (!stateValid)
{
state = is_aes_hw_cpu_supported() ? true : false;
stateValid = true;
}
return state && HwSupportEnabled;
#else
return false;
#endif
}
void CipherAES::SetCipherKey (const byte *key)
{
if (aes_encrypt_key256 (key, (aes_encrypt_ctx *) ScheduledKey.Ptr()) != EXIT_SUCCESS)
throw CipherInitError (SRC_POS);
if (aes_decrypt_key256 (key, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))) != EXIT_SUCCESS)
throw CipherInitError (SRC_POS);
}
-
- // Blowfish
- void CipherBlowfish::Decrypt (byte *data) const
- {
- BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 0);
- }
-
- void CipherBlowfish::Encrypt (byte *data) const
- {
- BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 1);
- }
-
- size_t CipherBlowfish::GetScheduledKeySize () const
- {
- return sizeof (BF_KEY);
- }
-
- void CipherBlowfish::SetCipherKey (const byte *key)
- {
- BlowfishSetKey ((BF_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key);
- }
-
-
- // CAST5
- void CipherCast5::Decrypt (byte *data) const
- {
- Cast5Decrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr());
- }
-
- void CipherCast5::Encrypt (byte *data) const
- {
- Cast5Encrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr());
- }
-
- size_t CipherCast5::GetScheduledKeySize () const
- {
- return sizeof (CAST_KEY);
- }
-
- void CipherCast5::SetCipherKey (const byte *key)
- {
- Cast5SetKey ((CAST_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key);
- }
-
-
// Serpent
void CipherSerpent::Decrypt (byte *data) const
{
serpent_decrypt (data, data, ScheduledKey);
}
void CipherSerpent::Encrypt (byte *data) const
{
serpent_encrypt (data, data, ScheduledKey);
}
size_t CipherSerpent::GetScheduledKeySize () const
{
return 140*4;
}
void CipherSerpent::SetCipherKey (const byte *key)
{
serpent_set_key (key, static_cast<int> (GetKeySize ()), ScheduledKey);
}
- // Triple-DES
- void CipherTripleDES::Decrypt (byte *data) const
- {
- TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 0);
- }
-
- void CipherTripleDES::Encrypt (byte *data) const
- {
- TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 1);
- }
-
- size_t CipherTripleDES::GetScheduledKeySize () const
- {
- return sizeof (TDES_KEY);
- }
-
- void CipherTripleDES::SetCipherKey (const byte *key)
- {
- TripleDesSetKey (key, GetKeySize(), (TDES_KEY *) ScheduledKey.Ptr());
- }
-
-
// Twofish
void CipherTwofish::Decrypt (byte *data) const
{
twofish_decrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data);
}
void CipherTwofish::Encrypt (byte *data) const
{
twofish_encrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data);
}
size_t CipherTwofish::GetScheduledKeySize () const
{
return TWOFISH_KS;
}
void CipherTwofish::SetCipherKey (const byte *key)
{
twofish_set_key ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *) key, static_cast<int> (GetKeySize ()) * 8);
}
diff --git a/src/Volume/Cipher.h b/src/Volume/Cipher.h
index 90a9a215..4dbead51 100644
--- a/src/Volume/Cipher.h
+++ b/src/Volume/Cipher.h
@@ -83,44 +83,41 @@ namespace VeraCrypt
virtual void Decrypt (byte *data) const; \
virtual void Encrypt (byte *data) const; \
virtual size_t GetScheduledKeySize () const; \
virtual void SetCipherKey (const byte *key); \
\
private: \
TC_JOIN (Cipher,NAME) (const TC_JOIN (Cipher,NAME) &); \
TC_JOIN (Cipher,NAME) &operator= (const TC_JOIN (Cipher,NAME) &); \
}
#define TC_CIPHER_ADD_METHODS \
virtual void DecryptBlocks (byte *data, size_t blockCount) const; \
virtual void EncryptBlocks (byte *data, size_t blockCount) const; \
virtual bool IsHwSupportAvailable () const;
TC_CIPHER (AES, 16, 32);
#undef TC_CIPHER_ADD_METHODS
#define TC_CIPHER_ADD_METHODS
- TC_CIPHER (Blowfish, 8, 56);
- TC_CIPHER (Cast5, 8, 16);
TC_CIPHER (Serpent, 16, 32);
- TC_CIPHER (TripleDES, 8, 24);
TC_CIPHER (Twofish, 16, 32);
#undef TC_CIPHER
#define TC_EXCEPTION(NAME) TC_EXCEPTION_DECL(NAME,CipherException)
#undef TC_EXCEPTION_SET
#define TC_EXCEPTION_SET \
TC_EXCEPTION (CipherInitError); \
TC_EXCEPTION (WeakKeyDetected);
TC_EXCEPTION_SET;
#undef TC_EXCEPTION
#if (defined (TC_ARCH_X86) || defined (TC_ARCH_X64)) && !defined (__ppc__)
# define TC_AES_HW_CPU
#endif
diff --git a/src/Volume/EncryptionAlgorithm.cpp b/src/Volume/EncryptionAlgorithm.cpp
index ce76e71f..3d854ae5 100644
--- a/src/Volume/EncryptionAlgorithm.cpp
+++ b/src/Volume/EncryptionAlgorithm.cpp
@@ -1,31 +1,29 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "EncryptionAlgorithm.h"
-#include "EncryptionModeCBC.h"
-#include "EncryptionModeLRW.h"
#include "EncryptionModeXTS.h"
namespace VeraCrypt
{
EncryptionAlgorithm::EncryptionAlgorithm () : Deprecated (false)
{
}
EncryptionAlgorithm::~EncryptionAlgorithm ()
{
}
void EncryptionAlgorithm::Decrypt (byte *data, uint64 length) const
{
if_debug (ValidateState ());
Mode->Decrypt (data, length);
}
void EncryptionAlgorithm::Decrypt (const BufferPtr &data) const
{
@@ -51,45 +49,40 @@ namespace VeraCrypt
void EncryptionAlgorithm::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
{
if_debug (ValidateState ());
Mode->EncryptSectors (data, sectorIndex, sectorCount, sectorSize);
}
EncryptionAlgorithmList EncryptionAlgorithm::GetAvailableAlgorithms ()
{
EncryptionAlgorithmList l;
l.push_back (shared_ptr <EncryptionAlgorithm> (new AES ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
- l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
- l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
- l.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
- l.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
- l.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
return l;
}
size_t EncryptionAlgorithm::GetLargestKeySize (const EncryptionAlgorithmList &algorithms)
{
size_t largestKeySize = 0;
foreach_ref (const EncryptionAlgorithm &ea, algorithms)
{
if (ea.GetKeySize() > largestKeySize)
largestKeySize = ea.GetKeySize();
}
return largestKeySize;
}
size_t EncryptionAlgorithm::GetKeySize () const
{
if (Ciphers.size() < 1)
throw NotInitialized (SRC_POS);
@@ -192,154 +185,85 @@ namespace VeraCrypt
size_t keyOffset = 0;
foreach_ref (Cipher &c, Ciphers)
{
c.SetKey (key.GetRange (keyOffset, c.GetKeySize()));
keyOffset += c.GetKeySize();
}
}
void EncryptionAlgorithm::ValidateState () const
{
if (Ciphers.size() < 1 || Mode.get() == nullptr)
throw NotInitialized (SRC_POS);
}
// AES
AES::AES ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherAES()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
- }
-
- // AES-Blowfish
- AESBlowfish::AESBlowfish ()
- {
- Deprecated = true;
-
- Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
- Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
-
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
- }
-
- // AES-Blowfish-Serpent
- AESBlowfishSerpent::AESBlowfishSerpent ()
- {
- Deprecated = true;
-
- Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
- Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
- Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
-
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// AES-Twofish
AESTwofish::AESTwofish ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// AES-Twofish-Serpent
AESTwofishSerpent::AESTwofishSerpent ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
- }
-
- // Blowfish
- Blowfish::Blowfish ()
- {
- Deprecated = true;
- Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish()));
-
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
- }
-
- // CAST5
- Cast5::Cast5 ()
- {
- Deprecated = true;
- Ciphers.push_back (shared_ptr <Cipher> (new CipherCast5()));
-
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// Serpent
Serpent::Serpent ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// Serpent-AES
SerpentAES::SerpentAES ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
- }
-
- // Triple-DES
- TripleDES::TripleDES ()
- {
- Deprecated = true;
- Ciphers.push_back (shared_ptr <Cipher> (new CipherTripleDES()));
-
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// Twofish
Twofish::Twofish ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// Twofish-Serpent
TwofishSerpent::TwofishSerpent ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
// Serpent-Twofish-AES
SerpentTwofishAES::SerpentTwofishAES ()
{
Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
}
diff --git a/src/Volume/EncryptionAlgorithm.h b/src/Volume/EncryptionAlgorithm.h
index 7fbee6ae..5a5666fe 100644
--- a/src/Volume/EncryptionAlgorithm.h
+++ b/src/Volume/EncryptionAlgorithm.h
@@ -57,37 +57,32 @@ namespace VeraCrypt
private:
EncryptionAlgorithm (const EncryptionAlgorithm &);
EncryptionAlgorithm &operator= (const EncryptionAlgorithm &);
};
#define TC_ENCRYPTION_ALGORITHM(NAME) \
class NAME : public EncryptionAlgorithm \
{ \
public: \
NAME (); \
virtual ~NAME () { } \
\
virtual shared_ptr <EncryptionAlgorithm> GetNew () const { return shared_ptr <EncryptionAlgorithm> (new NAME()); } \
\
private: \
NAME (const NAME &); \
NAME &operator= (const NAME &); \
}
TC_ENCRYPTION_ALGORITHM (AES);
- TC_ENCRYPTION_ALGORITHM (AESBlowfish);
- TC_ENCRYPTION_ALGORITHM (AESBlowfishSerpent);
TC_ENCRYPTION_ALGORITHM (AESTwofish);
TC_ENCRYPTION_ALGORITHM (AESTwofishSerpent);
- TC_ENCRYPTION_ALGORITHM (Blowfish);
- TC_ENCRYPTION_ALGORITHM (Cast5);
TC_ENCRYPTION_ALGORITHM (Serpent);
TC_ENCRYPTION_ALGORITHM (SerpentAES);
- TC_ENCRYPTION_ALGORITHM (TripleDES);
TC_ENCRYPTION_ALGORITHM (Twofish);
TC_ENCRYPTION_ALGORITHM (TwofishSerpent);
TC_ENCRYPTION_ALGORITHM (SerpentTwofishAES);
#undef TC_ENCRYPTION_ALGORITHM
}
#endif // TC_HEADER_Encryption_EncryptionAlgorithm
diff --git a/src/Volume/EncryptionMode.cpp b/src/Volume/EncryptionMode.cpp
index 0a7ac546..14642b80 100644
--- a/src/Volume/EncryptionMode.cpp
+++ b/src/Volume/EncryptionMode.cpp
@@ -1,61 +1,57 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "EncryptionMode.h"
-#include "EncryptionModeCBC.h"
-#include "EncryptionModeLRW.h"
#include "EncryptionModeXTS.h"
#include "EncryptionThreadPool.h"
namespace VeraCrypt
{
EncryptionMode::EncryptionMode () : KeySet (false), SectorOffset (0)
{
}
EncryptionMode::~EncryptionMode ()
{
}
void EncryptionMode::DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
{
EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::DecryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize);
}
void EncryptionMode::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
{
EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::EncryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize);
}
EncryptionModeList EncryptionMode::GetAvailableModes ()
{
EncryptionModeList l;
l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
return l;
}
void EncryptionMode::ValidateState () const
{
if (!KeySet || Ciphers.size() < 1)
throw NotInitialized (SRC_POS);
}
void EncryptionMode::ValidateParameters (byte *data, uint64 length) const
{
if ((Ciphers.size() > 0 && (length % Ciphers.front()->GetBlockSize()) != 0))
throw ParameterIncorrect (SRC_POS);
}
void EncryptionMode::ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const
{
if (sectorCount == 0 || sectorSize == 0 || (sectorSize % EncryptionDataUnitSize) != 0)
throw ParameterIncorrect (SRC_POS);
diff --git a/src/Volume/EncryptionModeCBC.cpp b/src/Volume/EncryptionModeCBC.cpp
deleted file mode 100644
index 2892986b..00000000
--- a/src/Volume/EncryptionModeCBC.cpp
+++ /dev/null
@@ -1,335 +0,0 @@
-/*
- Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
-
- Governed by the TrueCrypt License 3.0 the full text of which is contained in
- the file License.txt included in TrueCrypt binary and source code distribution
- packages.
-*/
-
-#include "Platform/Memory.h"
-#include "Common/Crc.h"
-#include "Common/Endian.h"
-#include "EncryptionModeCBC.h"
-
-namespace VeraCrypt
-{
- void EncryptionModeCBC::Decrypt (byte *data, uint64 length) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, length));
-
- if (IsOuterCBC (Ciphers))
- {
- DecryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
- }
- else
- {
- for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
- iCipherList != Ciphers.rend();
- ++iCipherList)
- {
- CipherList cl;
- cl.push_back (*iCipherList);
-
- DecryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
- }
- }
- }
-
- void EncryptionModeCBC::DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const
- {
- size_t blockSize = ciphers.front()->GetBlockSize();
- if (blockSize != 8 && blockSize != 16)
- throw ParameterIncorrect (SRC_POS);
-
- uint32 *data32 = (uint32 *) data;
- uint32 bufIV[4];
- uint32 ct[4];
- uint64 i;
-
- bufIV[0] = iv[0];
- bufIV[1] = iv[1];
- if (blockSize == 16)
- {
- bufIV[2] = iv[2];
- bufIV[3] = iv[3];
- }
-
- for (i = 0; i < length / blockSize; i++)
- {
- // Dewhitening
- data32[0] ^= whitening[0];
- data32[1] ^= whitening[1];
- if (blockSize == 16)
- {
- data32[2] ^= whitening[0];
- data32[3] ^= whitening[1];
- }
-
- // CBC
- ct[0] = data32[0];
- ct[1] = data32[1];
- if (blockSize == 16)
- {
- ct[2] = data32[2];
- ct[3] = data32[3];
- }
-
- for (CipherList::const_reverse_iterator iCipherList = ciphers.rbegin();
- iCipherList != ciphers.rend();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
-
- if (c.GetBlockSize () != blockSize)
- throw ParameterIncorrect (SRC_POS);
-
- c.DecryptBlock ((byte *) data32);
- }
-
- // CBC
- data32[0] ^= bufIV[0];
- data32[1] ^= bufIV[1];
- bufIV[0] = ct[0];
- bufIV[1] = ct[1];
- if (blockSize == 16)
- {
- data32[2] ^= bufIV[2];
- data32[3] ^= bufIV[3];
- bufIV[2] = ct[2];
- bufIV[3] = ct[3];
- }
-
- data32 += blockSize / sizeof(*data32);
- }
-
- Memory::Erase (bufIV, sizeof (bufIV));
- Memory::Erase (ct, sizeof (ct));
- }
-
- void EncryptionModeCBC::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, sectorCount, sectorSize));
-
- uint32 sectorIV[4];
- uint32 sectorWhitening[2];
-
- while (sectorCount--)
- {
- if (IsOuterCBC (Ciphers))
- {
- InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
- DecryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening);
- }
- else
- {
- for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
- iCipherList != Ciphers.rend();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
- CipherList cl;
- cl.push_back (*iCipherList);
-
- InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
- DecryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening);
- }
- }
-
- data += sectorSize;
- sectorIndex++;
- }
-
- Memory::Erase (sectorIV, sizeof (sectorIV));
- Memory::Erase (sectorWhitening, sizeof (sectorWhitening));
- }
-
- void EncryptionModeCBC::Encrypt (byte *data, uint64 length) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, length));
-
- if (IsOuterCBC (Ciphers))
- {
- EncryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
- }
- else
- {
- for (CipherList::const_iterator iCipherList = Ciphers.begin();
- iCipherList != Ciphers.end();
- ++iCipherList)
- {
- CipherList cl;
- cl.push_back (*iCipherList);
-
- EncryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
- }
- }
- }
-
- void EncryptionModeCBC::EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const
- {
- size_t blockSize = ciphers.front()->GetBlockSize();
- if (blockSize != 8 && blockSize != 16)
- throw ParameterIncorrect (SRC_POS);
-
- uint32 *data32 = (uint32 *) data;
- uint32 bufIV[4];
- uint64 i;
-
- bufIV[0] = iv[0];
- bufIV[1] = iv[1];
- if (blockSize == 16)
- {
- bufIV[2] = iv[2];
- bufIV[3] = iv[3];
- }
-
- for (i = 0; i < length / blockSize; i++)
- {
- data32[0] ^= bufIV[0];
- data32[1] ^= bufIV[1];
- if (blockSize == 16)
- {
- data32[2] ^= bufIV[2];
- data32[3] ^= bufIV[3];
- }
-
- for (CipherList::const_iterator iCipherList = ciphers.begin();
- iCipherList != ciphers.end();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
-
- if (c.GetBlockSize () != blockSize)
- throw ParameterIncorrect (SRC_POS);
-
- c.EncryptBlock ((byte *) data32);
- }
-
- bufIV[0] = data32[0];
- bufIV[1] = data32[1];
- if (blockSize == 16)
- {
- bufIV[2] = data32[2];
- bufIV[3] = data32[3];
- }
-
- data32[0] ^= whitening[0];
- data32[1] ^= whitening[1];
- if (blockSize == 16)
- {
- data32[2] ^= whitening[0];
- data32[3] ^= whitening[1];
- }
-
- data32 += blockSize / sizeof(*data32);
- }
-
- Memory::Erase (bufIV, sizeof (bufIV));
- }
-
- void EncryptionModeCBC::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, sectorCount, sectorSize));
-
- uint32 sectorIV[4];
- uint32 sectorWhitening[2];
-
- while (sectorCount--)
- {
- if (IsOuterCBC (Ciphers))
- {
- InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
- EncryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening);
- }
- else
- {
- for (CipherList::const_iterator iCipherList = Ciphers.begin();
- iCipherList != Ciphers.end();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
- CipherList cl;
- cl.push_back (*iCipherList);
-
- InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
- EncryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening);
- }
- }
-
- data += sectorSize;
- sectorIndex++;
- }
-
- Memory::Erase (sectorIV, sizeof (sectorIV));
- Memory::Erase (sectorWhitening, sizeof (sectorWhitening));
- }
-
- void EncryptionModeCBC::InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const
- {
- if (blockSize != 8 && blockSize != 16)
- throw ParameterIncorrect (SRC_POS);
-
- uint64 iv64[4];
- uint32 *iv32 = (uint32 *) iv64;
-
- iv64[0] = ivSeed[0] ^ Endian::Little (sectorIndex);
- iv64[1] = ivSeed[1] ^ Endian::Little (sectorIndex);
- iv64[2] = ivSeed[2] ^ Endian::Little (sectorIndex);
- if (blockSize == 16)
- {
- iv64[3] = ivSeed[3] ^ Endian::Little (sectorIndex);
- }
-
- iv[0] = iv32[0];
- iv[1] = iv32[1];
-
- if (blockSize == 8)
- {
- whitening[0] = Endian::Little ( crc32int ( &iv32[2] ) ^ crc32int ( &iv32[5] ) );
- whitening[1] = Endian::Little ( crc32int ( &iv32[3] ) ^ crc32int ( &iv32[4] ) );
- }
- else
- {
- iv[2] = iv32[2];
- iv[3] = iv32[3];
-
- whitening[0] = Endian::Little ( crc32int ( &iv32[4] ) ^ crc32int ( &iv32[7] ) );
- whitening[1] = Endian::Little ( crc32int ( &iv32[5] ) ^ crc32int ( &iv32[6] ) );
- }
- }
-
- bool EncryptionModeCBC::IsOuterCBC (const CipherList &ciphers) const
- {
- if (ciphers.size() < 2)
- return false;
-
- size_t blockSize = ciphers.front()->GetBlockSize();
-
- for (CipherList::const_iterator iCipherList = ciphers.begin();
- iCipherList != ciphers.end();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
- if (c.GetBlockSize() != blockSize)
- return false;
- }
-
- return true;
- }
-
- void EncryptionModeCBC::SetKey (const ConstBufferPtr &key)
- {
- if (key.Size() != GetKeySize ())
- throw ParameterIncorrect (SRC_POS);
-
- if (!KeySet)
- IV.Allocate (GetKeySize ());
-
- IV.CopyFrom (key);
- KeySet = true;
- }
-}
diff --git a/src/Volume/EncryptionModeCBC.h b/src/Volume/EncryptionModeCBC.h
deleted file mode 100644
index 187432ea..00000000
--- a/src/Volume/EncryptionModeCBC.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
-
- Governed by the TrueCrypt License 3.0 the full text of which is contained in
- the file License.txt included in TrueCrypt binary and source code distribution
- packages.
-*/
-
-#ifndef TC_HEADER_Encryption_EncryptionModeCBC
-#define TC_HEADER_Encryption_EncryptionModeCBC
-
-#include "Platform/Platform.h"
-#include "EncryptionMode.h"
-
-namespace VeraCrypt
-{
- class EncryptionModeCBC : public EncryptionMode
- {
- public:
- EncryptionModeCBC () { }
- virtual ~EncryptionModeCBC () { }
-
- virtual void Decrypt (byte *data, uint64 length) const;
- virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
- virtual void Encrypt (byte *data, uint64 length) const;
- virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
- virtual size_t GetKeySize () const { return 32; };
- virtual wstring GetName () const { return L"CBC"; };
- virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeCBC); }
- virtual void SetKey (const ConstBufferPtr &key);
-
- protected:
- void DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
- void EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
- void InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const;
- bool IsOuterCBC (const CipherList &ciphers) const;
-
- SecureBuffer IV;
- static const int WhiteningIVOffset = 8;
-
- private:
- EncryptionModeCBC (const EncryptionModeCBC &);
- EncryptionModeCBC &operator= (const EncryptionModeCBC &);
- };
-}
-
-#endif // TC_HEADER_Encryption_EncryptionModeCBC
diff --git a/src/Volume/EncryptionModeLRW.cpp b/src/Volume/EncryptionModeLRW.cpp
deleted file mode 100644
index 115b0fc5..00000000
--- a/src/Volume/EncryptionModeLRW.cpp
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
-
- Governed by the TrueCrypt License 3.0 the full text of which is contained in
- the file License.txt included in TrueCrypt binary and source code distribution
- packages.
-*/
-
-#include "EncryptionModeLRW.h"
-#include "Common/GfMul.h"
-
-namespace VeraCrypt
-{
- void EncryptionModeLRW::Decrypt (byte *data, uint64 length) const
- {
- if_debug (ValidateState ());
- DecryptBuffer (data, length, 1);
- }
-
- void EncryptionModeLRW::DecryptBuffer (byte *data, uint64 length, uint64 blockIndex) const
- {
- size_t blockSize = Ciphers.front()->GetBlockSize();
- if (blockSize != 8 && blockSize != 16)
- throw ParameterIncorrect (SRC_POS);
-
- byte i[8];
- *(uint64 *)i = Endian::Big (blockIndex);
-
- byte t[Cipher::MaxBlockSize];
-
- for (unsigned int b = 0; b < length / blockSize; b++)
- {
- if (blockSize == 8)
- {
- Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr()));
- Xor64 ((uint64 *)data, (uint64 *)t);
- }
- else
- {
- Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr()));
- Xor128 ((uint64 *)data, (uint64 *)t);
- }
-
- for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
- iCipherList != Ciphers.rend();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
-
- if (c.GetBlockSize () != blockSize)
- throw ParameterIncorrect (SRC_POS);
-
- c.DecryptBlock (data);
- }
-
- if (blockSize == 8)
- Xor64 ((uint64 *)data, (uint64 *)t);
- else
- Xor128 ((uint64 *)data, (uint64 *)t);
-
- data += blockSize;
- IncrementBlockIndex (i);
- }
-
- Memory::Erase (t, sizeof (t));
- }
-
- void EncryptionModeLRW::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, sectorCount, sectorSize));
-
- DecryptBuffer (data,
- sectorCount * sectorSize,
- SectorToBlockIndex (sectorIndex));
- }
-
- void EncryptionModeLRW::Encrypt (byte *data, uint64 length) const
- {
- ValidateState ();
- EncryptBuffer (data, length, 1);
- }
-
- void EncryptionModeLRW::EncryptBuffer (byte *data, uint64 length, uint64 blockIndex) const
- {
- size_t blockSize = Ciphers.front()->GetBlockSize();
- if (blockSize != 8 && blockSize != 16)
- throw ParameterIncorrect (SRC_POS);
-
- byte i[8];
- *(uint64 *)i = Endian::Big (blockIndex);
-
- byte t[Cipher::MaxBlockSize];
-
- for (unsigned int b = 0; b < length / blockSize; b++)
- {
- if (blockSize == 8)
- {
- Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr()));
- Xor64 ((uint64 *)data, (uint64 *)t);
- }
- else
- {
- Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr()));
- Xor128 ((uint64 *)data, (uint64 *)t);
- }
-
- for (CipherList::const_iterator iCipherList = Ciphers.begin();
- iCipherList != Ciphers.end();
- ++iCipherList)
- {
- const Cipher &c = **iCipherList;
-
- if (c.GetBlockSize () != blockSize)
- throw ParameterIncorrect (SRC_POS);
-
- c.EncryptBlock (data);
- }
-
- if (blockSize == 8)
- Xor64 ((uint64 *)data, (uint64 *)t);
- else
- Xor128 ((uint64 *)data, (uint64 *)t);
-
- data += blockSize;
- IncrementBlockIndex (i);
- }
-
- Memory::Erase (t, sizeof (t));
- }
-
- void EncryptionModeLRW::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
- {
- if_debug (ValidateState ());
- if_debug (ValidateParameters (data, sectorCount, sectorSize));
-
- EncryptBuffer (data,
- sectorCount * sectorSize,
- SectorToBlockIndex (sectorIndex));
- }
-
- void EncryptionModeLRW::IncrementBlockIndex (byte *index) const
- {
- if (index[7] != 0xff)
- index[7]++;
- else
- *(uint64 *)index = Endian::Big ( Endian::Big (*(uint64 *)index) + 1 );
- }
-
- uint64 EncryptionModeLRW::SectorToBlockIndex (uint64 sectorIndex) const
- {
- sectorIndex -= SectorOffset;
-
- switch (Ciphers.front()->GetBlockSize())
- {
- case 8:
- return (sectorIndex << 6) | 1;
-
- case 16:
- return (sectorIndex << 5) | 1;
-
- default:
- throw ParameterIncorrect (SRC_POS);
- }
- }
-
- void EncryptionModeLRW::SetKey (const ConstBufferPtr &key)
- {
- if (key.Size() != 16)
- throw ParameterIncorrect (SRC_POS);
-
- if (!KeySet)
- GfContext.Allocate (sizeof (GfCtx));
-
- if (!Gf64TabInit ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
- throw bad_alloc();
-
- if (!Gf128Tab64Init ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
- throw bad_alloc();
-
- Key.CopyFrom (key);
- KeySet = true;
- }
-
- void EncryptionModeLRW::Xor64 (uint64 *a, const uint64 *b) const
- {
- *a ^= *b;
- }
-
- void EncryptionModeLRW::Xor128 (uint64 *a, const uint64 *b) const
- {
- *a++ ^= *b++;
- *a ^= *b;
- }
-}
diff --git a/src/Volume/EncryptionModeLRW.h b/src/Volume/EncryptionModeLRW.h
deleted file mode 100644
index 0cfcd50c..00000000
--- a/src/Volume/EncryptionModeLRW.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
-
- Governed by the TrueCrypt License 3.0 the full text of which is contained in
- the file License.txt included in TrueCrypt binary and source code distribution
- packages.
-*/
-
-#ifndef TC_HEADER_Encryption_EncryptionModeLRW
-#define TC_HEADER_Encryption_EncryptionModeLRW
-
-#include "Platform/Platform.h"
-#include "EncryptionMode.h"
-
-namespace VeraCrypt
-{
- class EncryptionModeLRW : public EncryptionMode
- {
- public:
- EncryptionModeLRW () { }
- virtual ~EncryptionModeLRW () { }
-
- virtual void Decrypt (byte *data, uint64 length) const;
- virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
- virtual void Encrypt (byte *data, uint64 length) const;
- virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
- virtual const SecureBuffer &GetKey () const { return Key; }
- virtual size_t GetKeySize () const { return 16; };
- virtual wstring GetName () const { return L"LRW"; };
- virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeLRW); }
- virtual void SetKey (const ConstBufferPtr &key);
-
- protected:
- void DecryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const;
- void EncryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const;
- void IncrementBlockIndex (byte *index) const;
- uint64 SectorToBlockIndex (uint64 sectorIndex) const;
- void Xor64 (uint64 *a, const uint64 *b) const;
- void Xor128 (uint64 *a, const uint64 *b) const;
-
- SecureBuffer GfContext;
- SecureBuffer Key;
-
- private:
- EncryptionModeLRW (const EncryptionModeLRW &);
- EncryptionModeLRW &operator= (const EncryptionModeLRW &);
- };
-}
-
-#endif // TC_HEADER_Encryption_EncryptionModeLRW
diff --git a/src/Volume/EncryptionTest.cpp b/src/Volume/EncryptionTest.cpp
index 71f55f07..ffe998b0 100644
--- a/src/Volume/EncryptionTest.cpp
+++ b/src/Volume/EncryptionTest.cpp
@@ -1,134 +1,58 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "Cipher.h"
#include "Common/Crc.h"
#include "Crc32.h"
#include "EncryptionAlgorithm.h"
#include "EncryptionMode.h"
-#include "EncryptionModeCBC.h"
-#include "EncryptionModeLRW.h"
#include "EncryptionModeXTS.h"
#include "EncryptionTest.h"
#include "Pkcs5Kdf.h"
namespace VeraCrypt
{
void EncryptionTest::TestAll ()
{
TestAll (false);
TestAll (true);
}
void EncryptionTest::TestAll (bool enableCpuEncryptionSupport)
{
bool hwSupportEnabled = Cipher::IsHwSupportEnabled();
finally_do_arg (bool, hwSupportEnabled, { Cipher::EnableHwSupport (finally_arg); });
Cipher::EnableHwSupport (enableCpuEncryptionSupport);
TestCiphers();
TestXtsAES();
TestXts();
- TestLegacyModes();
TestPkcs5();
}
- void EncryptionTest::TestLegacyModes ()
- {
- byte buf[ENCRYPTION_DATA_UNIT_SIZE * 2];
- byte iv[32];
- unsigned int i;
- uint32 crc;
- uint64 secNo = 0x0234567890ABCDEFull;
-
- for (i = 0; i < sizeof (buf); i++)
- buf[i] = (byte) i;
-
- for (i = 0; i < sizeof (iv); i++)
- iv[i] = (byte) i;
-
- EncryptionModeList encModes = EncryptionMode::GetAvailableModes ();
-
- foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms())
- {
- foreach (shared_ptr <EncryptionMode> mode, encModes)
- {
- if (typeid (*mode) == typeid (EncryptionModeXTS))
- continue;
-
- if (!mode->IsKeySet())
- {
- mode->SetKey (ConstBufferPtr (iv, mode->GetKeySize()));
- mode->SetSectorOffset (1);
- }
-
- if (ea.IsModeSupported (mode))
- {
- ea.SetMode (mode);
- ea.SetKey (ConstBufferPtr (buf, ea.GetKeySize()));
-
- ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
- ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
- ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
-
- crc = ::GetCrc32 (buf, sizeof (buf));
-
- if (typeid (*mode) == typeid (EncryptionModeLRW))
- {
- if (typeid (ea) == typeid (AES) && crc != 0x5237acf9) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESTwofish) && crc != 0x4ed0fd80) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0xea04b3cf) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Blowfish) && crc != 0xf94d5300) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Cast5) && crc != 0x33971e82) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Serpent) && crc != 0x7fb86805) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (TripleDES) && crc != 0x2b20bb84) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Twofish) && crc != 0xa9de0f0b) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xca65c5cd) throw TestFailed (SRC_POS);
- }
-
- if (typeid (*mode) == typeid (EncryptionModeCBC))
- {
- if (typeid (ea) == typeid (AES) && crc != 0x2274f53d) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESBlowfish) && crc != 0xa7a80c84) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESBlowfishSerpent) && crc != 0xa0584562) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESTwofish) && crc != 0x3c226444) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0x5e5e77fd) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Blowfish) && crc != 0x033899a1) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Cast5) && crc != 0x331cecc7) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (Serpent) && crc != 0x42dff3d4) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (TripleDES) && crc != 0xfe497d0c) throw TestFailed (SRC_POS);
- if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xa7b659f3) throw TestFailed (SRC_POS);
- }
-
- ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
- }
- }
- }
- }
-
struct CipherTestVector
{
byte Key[32];
byte Plaintext[16];
byte Ciphertext[16];
};
static const CipherTestVector AESTestVectors[] =
{
{
{
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
},
{
0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff
},
{
0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89
@@ -855,36 +779,31 @@ namespace VeraCrypt
nTestsPerformed++;
}
if (nTestsPerformed != 80)
throw TestFailed (SRC_POS);
}
void EncryptionTest::TestPkcs5 ()
{
VolumePassword password ("password", 8);
static const byte saltData[] = { 0x12, 0x34, 0x56, 0x78 };
ConstBufferPtr salt (saltData, sizeof (saltData));
Buffer derivedKey (4);
Pkcs5HmacRipemd160 pkcs5HmacRipemd160;
pkcs5HmacRipemd160.DeriveKey (derivedKey, password, salt, 5, FALSE);
if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0)
throw TestFailed (SRC_POS);
- Pkcs5HmacSha1 pkcs5HmacSha1;
- pkcs5HmacSha1.DeriveKey (derivedKey, password, salt, 5, FALSE);
- if (memcmp (derivedKey.Ptr(), "\x5c\x75\xce\xf0", 4) != 0)
- throw TestFailed (SRC_POS);
-
Pkcs5HmacSha512 pkcs5HmacSha512;
pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE);
if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0)
throw TestFailed (SRC_POS);
Pkcs5HmacWhirlpool pkcs5HmacWhirlpool;
pkcs5HmacWhirlpool.DeriveKey (derivedKey, password, salt, 5, FALSE);
if (memcmp (derivedKey.Ptr(), "\x50\x7c\x36\x6f", 4) != 0)
throw TestFailed (SRC_POS);
}
}
diff --git a/src/Volume/Hash.cpp b/src/Volume/Hash.cpp
index ddae669a..b917a8e5 100644
--- a/src/Volume/Hash.cpp
+++ b/src/Volume/Hash.cpp
@@ -1,109 +1,82 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "Hash.h"
#include "Crypto/Rmd160.h"
-#include "Crypto/Sha1.h"
#include "Crypto/Sha2.h"
#include "Crypto/Whirlpool.h"
namespace VeraCrypt
{
HashList Hash::GetAvailableAlgorithms ()
{
HashList l;
l.push_back (shared_ptr <Hash> (new Ripemd160 ()));
l.push_back (shared_ptr <Hash> (new Sha512 ()));
l.push_back (shared_ptr <Hash> (new Whirlpool ()));
- l.push_back (shared_ptr <Hash> (new Sha1 ()));
return l;
}
void Hash::ValidateDataParameters (const ConstBufferPtr &data) const
{
if (data.Size() < 1)
throw ParameterIncorrect (SRC_POS);
}
void Hash::ValidateDigestParameters (const BufferPtr &buffer) const
{
if (buffer.Size() != GetDigestSize ())
throw ParameterIncorrect (SRC_POS);
}
// RIPEMD-160
Ripemd160::Ripemd160 ()
{
Context.Allocate (sizeof (RMD160_CTX));
Init();
}
void Ripemd160::GetDigest (const BufferPtr &buffer)
{
if_debug (ValidateDigestParameters (buffer));
RMD160Final (buffer, (RMD160_CTX *) Context.Ptr());
}
void Ripemd160::Init ()
{
RMD160Init ((RMD160_CTX *) Context.Ptr());
}
void Ripemd160::ProcessData (const ConstBufferPtr &data)
{
if_debug (ValidateDataParameters (data));
RMD160Update ((RMD160_CTX *) Context.Ptr(), data.Get(), (int) data.Size());
}
-
- // SHA-1
- Sha1::Sha1 ()
- {
- Deprecated = true;
- Context.Allocate (sizeof (sha1_ctx));
- Init();
- }
-
- void Sha1::GetDigest (const BufferPtr &buffer)
- {
- if_debug (ValidateDigestParameters (buffer));
- sha1_end (buffer, (sha1_ctx *) Context.Ptr());
- }
-
- void Sha1::Init ()
- {
- sha1_begin ((sha1_ctx *) Context.Ptr());
- }
-
- void Sha1::ProcessData (const ConstBufferPtr &data)
- {
- if_debug (ValidateDataParameters (data));
- sha1_hash (data.Get(), (int) data.Size(), (sha1_ctx *) Context.Ptr());
- }
// SHA-512
Sha512::Sha512 ()
{
Context.Allocate (sizeof (sha512_ctx));
Init();
}
void Sha512::GetDigest (const BufferPtr &buffer)
{
if_debug (ValidateDigestParameters (buffer));
sha512_end (buffer, (sha512_ctx *) Context.Ptr());
}
void Sha512::Init ()
{
sha512_begin ((sha512_ctx *) Context.Ptr());
}
void Sha512::ProcessData (const ConstBufferPtr &data)
diff --git a/src/Volume/Hash.h b/src/Volume/Hash.h
index befdd631..70872d54 100644
--- a/src/Volume/Hash.h
+++ b/src/Volume/Hash.h
@@ -48,62 +48,40 @@ namespace VeraCrypt
{
public:
Ripemd160 ();
virtual ~Ripemd160 () { }
virtual void GetDigest (const BufferPtr &buffer);
virtual size_t GetBlockSize () const { return 64; }
virtual size_t GetDigestSize () const { return 160 / 8; }
virtual wstring GetName () const { return L"RIPEMD-160"; }
virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Ripemd160); }
virtual void Init ();
virtual void ProcessData (const ConstBufferPtr &data);
protected:
private:
Ripemd160 (const Ripemd160 &);
Ripemd160 &operator= (const Ripemd160 &);
};
- // SHA-1
- class Sha1 : public Hash
- {
- public:
- Sha1 ();
- virtual ~Sha1 () { }
-
- virtual void GetDigest (const BufferPtr &buffer);
- virtual size_t GetBlockSize () const { return 64; }
- virtual size_t GetDigestSize () const { return 160 / 8; }
- virtual wstring GetName () const { return L"SHA-1"; }
- virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha1); }
- virtual void Init ();
- virtual void ProcessData (const ConstBufferPtr &data);
-
- protected:
-
- private:
- Sha1 (const Sha1 &);
- Sha1 &operator= (const Sha1 &);
- };
-
// SHA-512
class Sha512 : public Hash
{
public:
Sha512 ();
virtual ~Sha512 () { }
virtual void GetDigest (const BufferPtr &buffer);
virtual size_t GetBlockSize () const { return 128; }
virtual size_t GetDigestSize () const { return 512 / 8; }
virtual wstring GetName () const { return L"SHA-512"; }
virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha512); }
virtual void Init ();
virtual void ProcessData (const ConstBufferPtr &data);
protected:
private:
Sha512 (const Sha512 &);
Sha512 &operator= (const Sha512 &);
diff --git a/src/Volume/Pkcs5Kdf.cpp b/src/Volume/Pkcs5Kdf.cpp
index f3724b3a..6521e71a 100644
--- a/src/Volume/Pkcs5Kdf.cpp
+++ b/src/Volume/Pkcs5Kdf.cpp
@@ -36,61 +36,54 @@ namespace VeraCrypt
}
shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const Hash &hash)
{
foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms())
{
if (typeid (*kdf->GetHash()) == typeid (hash))
return kdf;
}
throw ParameterIncorrect (SRC_POS);
}
Pkcs5KdfList Pkcs5Kdf::GetAvailableAlgorithms ()
{
Pkcs5KdfList l;
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacRipemd160 ()));
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ()));
l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ()));
- l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha1 ()));
return l;
}
void Pkcs5Kdf::ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const
{
if (key.Size() < 1 || password.Size() < 1 || salt.Size() < 1 || iterationCount < 1)
throw ParameterIncorrect (SRC_POS);
}
void Pkcs5HmacRipemd160::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
{
ValidateParameters (key, password, salt, iterationCount);
derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
}
void Pkcs5HmacRipemd160_1000::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
{
ValidateParameters (key, password, salt, iterationCount);
derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
}
- void Pkcs5HmacSha1::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
- {
- ValidateParameters (key, password, salt, iterationCount);
- derive_key_sha1 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
- }
-
void Pkcs5HmacSha512::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
{
ValidateParameters (key, password, salt, iterationCount);
derive_key_sha512 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
}
void Pkcs5HmacWhirlpool::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
{
ValidateParameters (key, password, salt, iterationCount);
derive_key_whirlpool ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
}
}
diff --git a/src/Volume/Pkcs5Kdf.h b/src/Volume/Pkcs5Kdf.h
index 35e7dc15..00e7a0a9 100644
--- a/src/Volume/Pkcs5Kdf.h
+++ b/src/Volume/Pkcs5Kdf.h
@@ -58,55 +58,40 @@ namespace VeraCrypt
Pkcs5HmacRipemd160 (const Pkcs5HmacRipemd160 &);
Pkcs5HmacRipemd160 &operator= (const Pkcs5HmacRipemd160 &);
};
class Pkcs5HmacRipemd160_1000 : public Pkcs5Kdf
{
public:
Pkcs5HmacRipemd160_1000 () { }
virtual ~Pkcs5HmacRipemd160_1000 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Ripemd160); }
virtual int GetIterationCount () const { return 16384; }
virtual wstring GetName () const { return L"HMAC-RIPEMD-160"; }
private:
Pkcs5HmacRipemd160_1000 (const Pkcs5HmacRipemd160_1000 &);
Pkcs5HmacRipemd160_1000 &operator= (const Pkcs5HmacRipemd160_1000 &);
};
- class Pkcs5HmacSha1 : public Pkcs5Kdf
- {
- public:
- Pkcs5HmacSha1 () { }
- virtual ~Pkcs5HmacSha1 () { }
-
- virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const;
- virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha1); }
- virtual int GetIterationCount () const { return 500000; }
- virtual wstring GetName () const { return L"HMAC-SHA-1"; }
-
- private:
- Pkcs5HmacSha1 (const Pkcs5HmacSha1 &);
- Pkcs5HmacSha1 &operator= (const Pkcs5HmacSha1 &);
- };
class Pkcs5HmacSha512 : public Pkcs5Kdf
{
public:
Pkcs5HmacSha512 () { }
virtual ~Pkcs5HmacSha512 () { }
virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const;
virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha512); }
virtual int GetIterationCount () const { return 500000; }
virtual wstring GetName () const { return L"HMAC-SHA-512"; }
private:
Pkcs5HmacSha512 (const Pkcs5HmacSha512 &);
Pkcs5HmacSha512 &operator= (const Pkcs5HmacSha512 &);
};
class Pkcs5HmacWhirlpool : public Pkcs5Kdf
{
public:
diff --git a/src/Volume/Volume.cpp b/src/Volume/Volume.cpp
index aeec78e2..2c319ad9 100644
--- a/src/Volume/Volume.cpp
+++ b/src/Volume/Volume.cpp
@@ -1,32 +1,31 @@
/*
Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#ifndef TC_WINDOWS
#include <errno.h>
#endif
-#include "EncryptionModeLRW.h"
#include "EncryptionModeXTS.h"
#include "Volume.h"
#include "VolumeHeader.h"
#include "VolumeLayout.h"
#include "Common/Crypto.h"
namespace VeraCrypt
{
Volume::Volume ()
: HiddenVolumeProtectionTriggered (false),
SystemEncryption (false),
VolumeDataSize (0),
TopWriteOffset (0),
TotalDataRead (0),
TotalDataWritten (0)
{
}
Volume::~Volume ()
{
@@ -209,44 +208,40 @@ namespace VeraCrypt
VolumeDataSize = layout->GetDataSize (VolumeHostSize);
Header = header;
Layout = layout;
EA = header->GetEncryptionAlgorithm();
EncryptionMode &mode = *EA->GetMode();
if (layout->HasDriveHeader())
{
if (header->GetEncryptedAreaLength() != header->GetVolumeDataSize())
throw VolumeEncryptionNotCompleted (SRC_POS);
uint64 partitionStartOffset = VolumeFile->GetPartitionDeviceStartOffset();
if (partitionStartOffset < header->GetEncryptedAreaStart()
|| partitionStartOffset >= header->GetEncryptedAreaStart() + header->GetEncryptedAreaLength())
throw PasswordIncorrect (SRC_POS);
mode.SetSectorOffset (partitionStartOffset / ENCRYPTION_DATA_UNIT_SIZE);
}
- else if (typeid (mode) == typeid (EncryptionModeLRW))
- {
- mode.SetSectorOffset (VolumeDataOffset / SectorSize);
- }
// Volume protection
if (Protection == VolumeProtection::HiddenVolumeReadOnly)
{
if (Type == VolumeType::Hidden)
throw PasswordIncorrect (SRC_POS);
else
{
try
{
Volume protectedVolume;
protectedVolume.Open (VolumeFile,
protectionPassword, protectionKeyfiles,
VolumeProtection::ReadOnly,
shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> (),
VolumeType::Hidden,
useBackupHeaders);
if (protectedVolume.GetType() != VolumeType::Hidden)
diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make
index 29412a9f..528e8876 100644
--- a/src/Volume/Volume.make
+++ b/src/Volume/Volume.make
@@ -24,39 +24,35 @@ OBJS += VolumeHeader.o
OBJS += VolumeInfo.o
OBJS += VolumeLayout.o
OBJS += VolumePassword.o
OBJS += VolumePasswordCache.o
ifeq "$(CPU_ARCH)" "x86"
OBJS += ../Crypto/Aes_x86.o
OBJS += ../Crypto/Aes_hw_cpu.o
ifeq "$(PLATFORM)" "MacOSX"
OBJS += ../Crypto/Aescrypt.o
endif
else ifeq "$(CPU_ARCH)" "x64"
OBJS += ../Crypto/Aes_x64.o
OBJS += ../Crypto/Aes_hw_cpu.o
else
OBJS += ../Crypto/Aescrypt.o
endif
OBJS += ../Crypto/Aeskey.o
OBJS += ../Crypto/Aestab.o
-OBJS += ../Crypto/Blowfish.o
-OBJS += ../Crypto/Cast.o
-OBJS += ../Crypto/Des.o
OBJS += ../Crypto/Rmd160.o
OBJS += ../Crypto/Serpent.o
-OBJS += ../Crypto/Sha1.o
OBJS += ../Crypto/Sha2.o
OBJS += ../Crypto/Twofish.o
OBJS += ../Crypto/Whirlpool.o
OBJS += ../Common/Crc.o
OBJS += ../Common/Endian.o
OBJS += ../Common/GfMul.o
OBJS += ../Common/Pkcs5.o
OBJS += ../Common/SecurityToken.o
VolumeLibrary: Volume.a
include $(BUILD_INC)/Makefile.inc
diff --git a/src/Volume/VolumeLayout.cpp b/src/Volume/VolumeLayout.cpp
index aeade493..a3ecab02 100644
--- a/src/Volume/VolumeLayout.cpp
+++ b/src/Volume/VolumeLayout.cpp
@@ -1,31 +1,29 @@
/*
Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
Governed by the TrueCrypt License 3.0 the full text of which is contained in
the file License.txt included in TrueCrypt binary and source code distribution
packages.
*/
#include "Volume/EncryptionMode.h"
-#include "Volume/EncryptionModeCBC.h"
-#include "Volume/EncryptionModeLRW.h"
#include "Volume/EncryptionModeXTS.h"
#include "VolumeLayout.h"
#include "Boot/Windows/BootCommon.h"
namespace VeraCrypt
{
VolumeLayout::VolumeLayout ()
{
}
VolumeLayout::~VolumeLayout ()
{
}
VolumeLayoutList VolumeLayout::GetAvailableLayouts (VolumeType::Enum type)
{
VolumeLayoutList layouts;
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Normal ()));
layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Normal ()));
@@ -56,86 +54,70 @@ namespace VeraCrypt
return Header;
}
VolumeLayoutV1Normal::VolumeLayoutV1Normal ()
{
Type = VolumeType::Normal;
HeaderOffset = TC_VOLUME_HEADER_OFFSET;
HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY;
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
-
SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const
{
return HeaderSize;
}
uint64 VolumeLayoutV1Normal::GetDataSize (uint64 volumeHostSize) const
{
return volumeHostSize - GetHeaderSize();
}
VolumeLayoutV1Hidden::VolumeLayoutV1Hidden ()
{
Type = VolumeType::Hidden;
HeaderOffset = -TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY;
HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY;
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
- SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
-
SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
- SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
- SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
}
uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const
{
return volumeHostSize - GetDataSize (volumeHostSize) + HeaderOffset;
}
uint64 VolumeLayoutV1Hidden::GetDataSize (uint64 volumeHostSize) const
{
return Header->GetHiddenVolumeDataSize ();
}
VolumeLayoutV2Normal::VolumeLayoutV2Normal ()
{
Type = VolumeType::Normal;
HeaderOffset = TC_VOLUME_HEADER_OFFSET;
HeaderSize = TC_VOLUME_HEADER_SIZE;
BackupHeaderOffset = -TC_VOLUME_HEADER_GROUP_SIZE;