diff options
-rw-r--r-- | src/Common/Crypto.h | 3 | ||||
-rw-r--r-- | src/Common/Dlgcode.c | 10 | ||||
-rw-r--r-- | src/Common/Pkcs5.h | 3 | ||||
-rw-r--r-- | src/Common/Tests.h | 1 | ||||
-rw-r--r-- | src/Core/Unix/Linux/CoreLinux.cpp | 7 | ||||
-rw-r--r-- | src/Crypto/Crypto.vcproj | 16 | ||||
-rw-r--r-- | src/Crypto/Sources | 4 | ||||
-rw-r--r-- | src/Main/GraphicUserInterface.cpp | 1 | ||||
-rw-r--r-- | src/Main/TextUserInterface.cpp | 1 | ||||
-rw-r--r-- | src/Volume/Cipher.cpp | 73 | ||||
-rw-r--r-- | src/Volume/Cipher.h | 3 | ||||
-rw-r--r-- | src/Volume/EncryptionAlgorithm.cpp | 76 | ||||
-rw-r--r-- | src/Volume/EncryptionAlgorithm.h | 5 | ||||
-rw-r--r-- | src/Volume/EncryptionMode.cpp | 4 | ||||
-rw-r--r-- | src/Volume/EncryptionModeCBC.cpp | 335 | ||||
-rw-r--r-- | src/Volume/EncryptionModeCBC.h | 47 | ||||
-rw-r--r-- | src/Volume/EncryptionModeLRW.cpp | 195 | ||||
-rw-r--r-- | src/Volume/EncryptionModeLRW.h | 50 | ||||
-rw-r--r-- | src/Volume/EncryptionTest.cpp | 81 | ||||
-rw-r--r-- | src/Volume/Hash.cpp | 27 | ||||
-rw-r--r-- | src/Volume/Hash.h | 22 | ||||
-rw-r--r-- | src/Volume/Pkcs5Kdf.cpp | 7 | ||||
-rw-r--r-- | src/Volume/Pkcs5Kdf.h | 15 | ||||
-rw-r--r-- | src/Volume/Volume.cpp | 5 | ||||
-rw-r--r-- | src/Volume/Volume.make | 4 | ||||
-rw-r--r-- | src/Volume/VolumeLayout.cpp | 18 |
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 @@ -62,9 +62,6 @@ enum #define RIPEMD160_BLOCKSIZE 64
#define RIPEMD160_DIGESTSIZE 20
-#define SHA1_BLOCKSIZE 64
-#define SHA1_DIGESTSIZE 20
-
#define SHA512_BLOCKSIZE 128
#define SHA512_DIGESTSIZE 64
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 @@ -4353,7 +4353,6 @@ static BOOL PerformBenchmark(HWND hwndDlg) BYTE *digest [MAX_DIGESTSIZE];
WHIRLPOOL_CTX wctx;
RMD160_CTX rctx;
- sha1_ctx sctx;
sha512_ctx s2ctx;
int hid;
@@ -4364,11 +4363,6 @@ static BOOL PerformBenchmark(HWND hwndDlg) switch (hid)
{
- case SHA1:
- sha1_begin (&sctx);
- sha1_hash (lpTestBuffer, benchmarkBufferSize, &sctx);
- sha1_end ((unsigned char *) digest, &sctx);
- break;
case SHA512:
sha512_begin (&s2ctx);
@@ -4424,10 +4418,6 @@ static BOOL PerformBenchmark(HWND hwndDlg) {
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 */
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 @@ -22,9 +22,6 @@ extern "C" 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);
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 @@ -17,7 +17,6 @@ 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);
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 @@ -17,7 +17,6 @@ #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" @@ -290,10 +289,9 @@ namespace VeraCrypt 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); @@ -372,9 +370,6 @@ namespace VeraCrypt 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)); } 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 @@ -254,18 +254,6 @@ >
</File>
<File
- RelativePath=".\Blowfish.h"
- >
- </File>
- <File
- RelativePath=".\Cast.h"
- >
- </File>
- <File
- RelativePath=".\Des.h"
- >
- </File>
- <File
RelativePath=".\Rmd160.h"
>
</File>
@@ -274,10 +262,6 @@ >
</File>
<File
- RelativePath=".\Sha1.h"
- >
- </File>
- <File
RelativePath=".\Sha2.h"
>
</File>
diff --git a/src/Crypto/Sources b/src/Crypto/Sources index f38c268e..417f0e04 100644 --- a/src/Crypto/Sources +++ b/src/Crypto/Sources @@ -12,12 +12,8 @@ SOURCES = \ 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 @@ -743,7 +743,6 @@ namespace VeraCrypt #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(); 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 @@ -1184,7 +1184,6 @@ namespace VeraCrypt #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"]); } 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 @@ -9,9 +9,6 @@ #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" @@ -76,9 +73,6 @@ namespace VeraCrypt 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; } @@ -199,51 +193,6 @@ namespace VeraCrypt 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 { @@ -266,28 +215,6 @@ namespace VeraCrypt } - // 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 { 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 @@ -100,10 +100,7 @@ namespace VeraCrypt #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 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 @@ -7,8 +7,6 @@ */ #include "EncryptionAlgorithm.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" namespace VeraCrypt @@ -68,11 +66,6 @@ namespace VeraCrypt 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; } @@ -209,31 +202,6 @@ namespace VeraCrypt 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 @@ -243,8 +211,6 @@ namespace VeraCrypt 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 @@ -255,28 +221,6 @@ namespace VeraCrypt 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 @@ -285,8 +229,6 @@ namespace VeraCrypt 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 @@ -296,18 +238,6 @@ namespace VeraCrypt 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 @@ -316,8 +246,6 @@ namespace VeraCrypt 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 @@ -327,8 +255,6 @@ namespace VeraCrypt 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 @@ -339,7 +265,5 @@ namespace VeraCrypt 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 @@ -74,15 +74,10 @@ namespace VeraCrypt } 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); 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 @@ -7,8 +7,6 @@ */ #include "EncryptionMode.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "EncryptionThreadPool.h" @@ -37,8 +35,6 @@ namespace VeraCrypt 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; } 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 @@ -11,8 +11,6 @@ #include "Crc32.h" #include "EncryptionAlgorithm.h" #include "EncryptionMode.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "EncryptionTest.h" #include "Pkcs5Kdf.h" @@ -35,83 +33,9 @@ namespace VeraCrypt 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 { @@ -872,11 +796,6 @@ namespace VeraCrypt 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) 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 @@ -9,7 +9,6 @@ #include "Hash.h" #include "Crypto/Rmd160.h" -#include "Crypto/Sha1.h" #include "Crypto/Sha2.h" #include "Crypto/Whirlpool.h" @@ -22,7 +21,6 @@ namespace VeraCrypt 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; } @@ -62,31 +60,6 @@ namespace VeraCrypt 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 () 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 @@ -65,28 +65,6 @@ namespace VeraCrypt 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 { 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 @@ -53,7 +53,6 @@ namespace VeraCrypt 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; } @@ -76,12 +75,6 @@ namespace VeraCrypt 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); 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 @@ -75,21 +75,6 @@ namespace VeraCrypt 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 { 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 @@ -9,7 +9,6 @@ #ifndef TC_WINDOWS #include <errno.h> #endif -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "Volume.h" #include "VolumeHeader.h" @@ -226,10 +225,6 @@ namespace VeraCrypt mode.SetSectorOffset (partitionStartOffset / ENCRYPTION_DATA_UNIT_SIZE); } - else if (typeid (mode) == typeid (EncryptionModeLRW)) - { - mode.SetSectorOffset (VolumeDataOffset / SectorSize); - } // Volume protection if (Protection == VolumeProtection::HiddenVolumeReadOnly) 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 @@ -41,12 +41,8 @@ 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 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 @@ -7,8 +7,6 @@ */ #include "Volume/EncryptionMode.h" -#include "Volume/EncryptionModeCBC.h" -#include "Volume/EncryptionModeLRW.h" #include "Volume/EncryptionModeXTS.h" #include "VolumeLayout.h" #include "Boot/Windows/BootCommon.h" @@ -73,15 +71,7 @@ namespace VeraCrypt 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 @@ -110,15 +100,7 @@ namespace VeraCrypt 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 |