VeraCrypt
aboutsummaryrefslogtreecommitdiff
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
parent75f780871949e5bacca4718507e66c8d28d72e69 (diff)
downloadVeraCrypt-a5c1978eefe2fd0dbf1ab6b7cdcb019a9b913a40.tar.gz
VeraCrypt-a5c1978eefe2fd0dbf1ab6b7cdcb019a9b913a40.zip
Remove remaining legacy cryptographic algorithms that are never used by VeraCrypt.
-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
@@ -62,9 +62,6 @@ enum
62#define RIPEMD160_BLOCKSIZE 64 62#define RIPEMD160_BLOCKSIZE 64
63#define RIPEMD160_DIGESTSIZE 20 63#define RIPEMD160_DIGESTSIZE 20
64 64
65#define SHA1_BLOCKSIZE 64
66#define SHA1_DIGESTSIZE 20
67
68#define SHA512_BLOCKSIZE 128 65#define SHA512_BLOCKSIZE 128
69#define SHA512_DIGESTSIZE 64 66#define SHA512_DIGESTSIZE 64
70 67
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)
4353 BYTE *digest [MAX_DIGESTSIZE]; 4353 BYTE *digest [MAX_DIGESTSIZE];
4354 WHIRLPOOL_CTX wctx; 4354 WHIRLPOOL_CTX wctx;
4355 RMD160_CTX rctx; 4355 RMD160_CTX rctx;
4356 sha1_ctx sctx;
4357 sha512_ctx s2ctx; 4356 sha512_ctx s2ctx;
4358 int hid; 4357 int hid;
4359 4358
@@ -4364,11 +4363,6 @@ static BOOL PerformBenchmark(HWND hwndDlg)
4364 4363
4365 switch (hid) 4364 switch (hid)
4366 { 4365 {
4367 case SHA1:
4368 sha1_begin (&sctx);
4369 sha1_hash (lpTestBuffer, benchmarkBufferSize, &sctx);
4370 sha1_end ((unsigned char *) digest, &sctx);
4371 break;
4372 4366
4373 case SHA512: 4367 case SHA512:
4374 sha512_begin (&s2ctx); 4368 sha512_begin (&s2ctx);
@@ -4424,10 +4418,6 @@ static BOOL PerformBenchmark(HWND hwndDlg)
4424 { 4418 {
4425 switch (thid) 4419 switch (thid)
4426 { 4420 {
4427 case SHA1:
4428 /* PKCS-5 test with HMAC-SHA-1 used as the PRF */
4429 derive_key_sha1 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, FALSE), dk, MASTER_KEYDATA_SIZE);
4430 break;
4431 4421
4432 case SHA512: 4422 case SHA512:
4433 /* PKCS-5 test with HMAC-SHA-512 used as the PRF */ 4423 /* 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"
22void hmac_sha512 (char *k, int lk, char *d, int ld, char *out, int t); 22void hmac_sha512 (char *k, int lk, char *d, int ld, char *out, int t);
23void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b); 23void derive_u_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
24void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen); 24void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
25void hmac_sha1 (char *k, int lk, char *d, int ld, char *out, int t);
26void derive_u_sha1 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
27void derive_key_sha1 (char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen);
28void hmac_ripemd160 (char *key, int keylen, char *input, int len, char *digest); 25void hmac_ripemd160 (char *key, int keylen, char *input, int len, char *digest);
29void derive_u_ripemd160 (BOOL bNotTest, char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b); 26void derive_u_ripemd160 (BOOL bNotTest, char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *u, int b);
30void derive_key_ripemd160 (BOOL bNotTest, char *pwd, int pwd_len, char *salt, int salt_len, int iterations, char *dk, int dklen); 27void 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];
17 17
18void CipherInit2(int cipher, void* key, void* ks, int key_len); 18void CipherInit2(int cipher, void* key, void* ks, int key_len);
19BOOL test_hmac_sha512 (void); 19BOOL test_hmac_sha512 (void);
20BOOL test_hmac_sha1 (void);
21BOOL test_hmac_ripemd160 (void); 20BOOL test_hmac_ripemd160 (void);
22BOOL test_hmac_whirlpool (void); 21BOOL test_hmac_whirlpool (void);
23BOOL test_pkcs5 (void); 22BOOL 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 @@
17#include "CoreLinux.h" 17#include "CoreLinux.h"
18#include "Platform/SystemInfo.h" 18#include "Platform/SystemInfo.h"
19#include "Platform/TextReader.h" 19#include "Platform/TextReader.h"
20#include "Volume/EncryptionModeLRW.h"
21#include "Volume/EncryptionModeXTS.h" 20#include "Volume/EncryptionModeXTS.h"
22#include "Driver/Fuse/FuseService.h" 21#include "Driver/Fuse/FuseService.h"
23#include "Core/Unix/CoreServiceProxy.h" 22#include "Core/Unix/CoreServiceProxy.h"
@@ -290,10 +289,9 @@ namespace VeraCrypt
290 void CoreLinux::MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const 289 void CoreLinux::MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const
291 { 290 {
292 bool xts = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeXTS)); 291 bool xts = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeXTS));
293 bool lrw = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeLRW));
294 292
295 if (options.NoKernelCrypto 293 if (options.NoKernelCrypto
296 || (!xts && (!lrw || volume->GetEncryptionAlgorithm()->GetCiphers().size() > 1 || volume->GetEncryptionAlgorithm()->GetMinBlockSize() != 16)) 294 || !xts
297 || volume->GetProtectionType() == VolumeProtection::HiddenVolumeReadOnly) 295 || volume->GetProtectionType() == VolumeProtection::HiddenVolumeReadOnly)
298 { 296 {
299 throw NotApplicable (SRC_POS); 297 throw NotApplicable (SRC_POS);
@@ -372,9 +370,6 @@ namespace VeraCrypt
372 sprintf ((char *) hexStr.Ptr(), "%02x", (int) cipherKey[i]); 370 sprintf ((char *) hexStr.Ptr(), "%02x", (int) cipherKey[i]);
373 dmCreateArgsBuf.GetRange (keyArgOffset + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2)); 371 dmCreateArgsBuf.GetRange (keyArgOffset + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2));
374 372
375 if (lrw && i >= 16)
376 continue;
377
378 sprintf ((char *) hexStr.Ptr(), "%02x", (int) secondaryKey[i]); 373 sprintf ((char *) hexStr.Ptr(), "%02x", (int) secondaryKey[i]);
379 dmCreateArgsBuf.GetRange (keyArgOffset + cipherKey.Size() * 2 + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2)); 374 dmCreateArgsBuf.GetRange (keyArgOffset + cipherKey.Size() * 2 + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2));
380 } 375 }
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 @@
254 > 254 >
255 </File> 255 </File>
256 <File 256 <File
257 RelativePath=".\Blowfish.h"
258 >
259 </File>
260 <File
261 RelativePath=".\Cast.h"
262 >
263 </File>
264 <File
265 RelativePath=".\Des.h"
266 >
267 </File>
268 <File
269 RelativePath=".\Rmd160.h" 257 RelativePath=".\Rmd160.h"
270 > 258 >
271 </File> 259 </File>
@@ -274,10 +262,6 @@
274 > 262 >
275 </File> 263 </File>
276 <File 264 <File
277 RelativePath=".\Sha1.h"
278 >
279 </File>
280 <File
281 RelativePath=".\Sha2.h" 265 RelativePath=".\Sha2.h"
282 > 266 >
283 </File> 267 </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 = \
12 Aes_hw_cpu.asm \ 12 Aes_hw_cpu.asm \
13 Aeskey.c \ 13 Aeskey.c \
14 Aestab.c \ 14 Aestab.c \
15 Blowfish.c \
16 Cast.c \
17 Des.c \
18 Rmd160.c \ 15 Rmd160.c \
19 Serpent.c \ 16 Serpent.c \
20 Sha1.c \
21 Sha2.c \ 17 Sha2.c \
22 Twofish.c \ 18 Twofish.c \
23 Whirlpool.c 19 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
743#ifdef TC_LINUX 743#ifdef TC_LINUX
744 if (volume && !Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning 744 if (volume && !Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning
745 && volume->EncryptionModeName != L"XTS" 745 && volume->EncryptionModeName != L"XTS"
746 && (volume->EncryptionModeName != L"LRW" || volume->EncryptionAlgorithmMinBlockSize != 16 || volume->EncryptionAlgorithmKeySize != 32)
747 && !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)) 746 && !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))
748 { 747 {
749 UserPreferences prefs = GetPreferences(); 748 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
1184#ifdef TC_LINUX 1184#ifdef TC_LINUX
1185 if (!Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning 1185 if (!Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning
1186 && volume->EncryptionModeName != L"XTS" 1186 && volume->EncryptionModeName != L"XTS"
1187 && (volume->EncryptionModeName != L"LRW" || volume->EncryptionAlgorithmMinBlockSize != 16 || volume->EncryptionAlgorithmKeySize != 32))
1188 { 1187 {
1189 ShowWarning (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"]); 1188 ShowWarning (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"]);
1190 } 1189 }
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 @@
9#include "Platform/Platform.h" 9#include "Platform/Platform.h"
10#include "Cipher.h" 10#include "Cipher.h"
11#include "Crypto/Aes.h" 11#include "Crypto/Aes.h"
12#include "Crypto/Blowfish.h"
13#include "Crypto/Des.h"
14#include "Crypto/Cast.h"
15#include "Crypto/Serpent.h" 12#include "Crypto/Serpent.h"
16#include "Crypto/Twofish.h" 13#include "Crypto/Twofish.h"
17 14
@@ -76,9 +73,6 @@ namespace VeraCrypt
76 l.push_back (shared_ptr <Cipher> (new CipherAES ())); 73 l.push_back (shared_ptr <Cipher> (new CipherAES ()));
77 l.push_back (shared_ptr <Cipher> (new CipherSerpent ())); 74 l.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
78 l.push_back (shared_ptr <Cipher> (new CipherTwofish ())); 75 l.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
79 l.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
80 l.push_back (shared_ptr <Cipher> (new CipherCast5 ()));
81 l.push_back (shared_ptr <Cipher> (new CipherTripleDES ()));
82 76
83 return l; 77 return l;
84 } 78 }
@@ -199,51 +193,6 @@ namespace VeraCrypt
199 throw CipherInitError (SRC_POS); 193 throw CipherInitError (SRC_POS);
200 } 194 }
201 195
202
203 // Blowfish
204 void CipherBlowfish::Decrypt (byte *data) const
205 {
206 BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 0);
207 }
208
209 void CipherBlowfish::Encrypt (byte *data) const
210 {
211 BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 1);
212 }
213
214 size_t CipherBlowfish::GetScheduledKeySize () const
215 {
216 return sizeof (BF_KEY);
217 }
218
219 void CipherBlowfish::SetCipherKey (const byte *key)
220 {
221 BlowfishSetKey ((BF_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key);
222 }
223
224
225 // CAST5
226 void CipherCast5::Decrypt (byte *data) const
227 {
228 Cast5Decrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr());
229 }
230
231 void CipherCast5::Encrypt (byte *data) const
232 {
233 Cast5Encrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr());
234 }
235
236 size_t CipherCast5::GetScheduledKeySize () const
237 {
238 return sizeof (CAST_KEY);
239 }
240
241 void CipherCast5::SetCipherKey (const byte *key)
242 {
243 Cast5SetKey ((CAST_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key);
244 }
245
246
247 // Serpent 196 // Serpent
248 void CipherSerpent::Decrypt (byte *data) const 197 void CipherSerpent::Decrypt (byte *data) const
249 { 198 {
@@ -266,28 +215,6 @@ namespace VeraCrypt
266 } 215 }
267 216
268 217
269 // Triple-DES
270 void CipherTripleDES::Decrypt (byte *data) const
271 {
272 TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 0);
273 }
274
275 void CipherTripleDES::Encrypt (byte *data) const
276 {
277 TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 1);
278 }
279
280 size_t CipherTripleDES::GetScheduledKeySize () const
281 {
282 return sizeof (TDES_KEY);
283 }
284
285 void CipherTripleDES::SetCipherKey (const byte *key)
286 {
287 TripleDesSetKey (key, GetKeySize(), (TDES_KEY *) ScheduledKey.Ptr());
288 }
289
290
291 // Twofish 218 // Twofish
292 void CipherTwofish::Decrypt (byte *data) const 219 void CipherTwofish::Decrypt (byte *data) const
293 { 220 {
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
100#undef TC_CIPHER_ADD_METHODS 100#undef TC_CIPHER_ADD_METHODS
101#define TC_CIPHER_ADD_METHODS 101#define TC_CIPHER_ADD_METHODS
102 102
103 TC_CIPHER (Blowfish, 8, 56);
104 TC_CIPHER (Cast5, 8, 16);
105 TC_CIPHER (Serpent, 16, 32); 103 TC_CIPHER (Serpent, 16, 32);
106 TC_CIPHER (TripleDES, 8, 24);
107 TC_CIPHER (Twofish, 16, 32); 104 TC_CIPHER (Twofish, 16, 32);
108 105
109#undef TC_CIPHER 106#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 @@
7*/ 7*/
8 8
9#include "EncryptionAlgorithm.h" 9#include "EncryptionAlgorithm.h"
10#include "EncryptionModeCBC.h"
11#include "EncryptionModeLRW.h"
12#include "EncryptionModeXTS.h" 10#include "EncryptionModeXTS.h"
13 11
14namespace VeraCrypt 12namespace VeraCrypt
@@ -68,11 +66,6 @@ namespace VeraCrypt
68 l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); 66 l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
69 l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); 67 l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
70 68
71 l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
72 l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
73 l.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
74 l.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
75 l.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
76 return l; 69 return l;
77 } 70 }
78 71
@@ -209,31 +202,6 @@ namespace VeraCrypt
209 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES())); 202 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES()));
210 203
211 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 204 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
212 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
213 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
214 }
215
216 // AES-Blowfish
217 AESBlowfish::AESBlowfish ()
218 {
219 Deprecated = true;
220
221 Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
222 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
223
224 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
225 }
226
227 // AES-Blowfish-Serpent
228 AESBlowfishSerpent::AESBlowfishSerpent ()
229 {
230 Deprecated = true;
231
232 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
233 Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ()));
234 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
235
236 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
237 } 205 }
238 206
239 // AES-Twofish 207 // AES-Twofish
@@ -243,8 +211,6 @@ namespace VeraCrypt
243 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); 211 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
244 212
245 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 213 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
246 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
247 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
248 } 214 }
249 215
250 // AES-Twofish-Serpent 216 // AES-Twofish-Serpent
@@ -255,28 +221,6 @@ namespace VeraCrypt
255 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); 221 Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ()));
256 222
257 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 223 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
258 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
259 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
260 }
261
262 // Blowfish
263 Blowfish::Blowfish ()
264 {
265 Deprecated = true;
266 Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish()));
267
268 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
269 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
270 }
271
272 // CAST5
273 Cast5::Cast5 ()
274 {
275 Deprecated = true;
276 Ciphers.push_back (shared_ptr <Cipher> (new CipherCast5()));
277
278 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
279 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
280 } 224 }
281 225
282 // Serpent 226 // Serpent
@@ -285,8 +229,6 @@ namespace VeraCrypt
285 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent())); 229 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent()));
286 230
287 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 231 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
288 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
289 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
290 } 232 }
291 233
292 // Serpent-AES 234 // Serpent-AES
@@ -296,18 +238,6 @@ namespace VeraCrypt
296 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); 238 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
297 239
298 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 240 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
299 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
300 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
301 }
302
303 // Triple-DES
304 TripleDES::TripleDES ()
305 {
306 Deprecated = true;
307 Ciphers.push_back (shared_ptr <Cipher> (new CipherTripleDES()));
308
309 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
310 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
311 } 241 }
312 242
313 // Twofish 243 // Twofish
@@ -316,8 +246,6 @@ namespace VeraCrypt
316 Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish())); 246 Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish()));
317 247
318 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 248 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
319 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
320 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
321 } 249 }
322 250
323 // Twofish-Serpent 251 // Twofish-Serpent
@@ -327,8 +255,6 @@ namespace VeraCrypt
327 Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); 255 Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ()));
328 256
329 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 257 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
330 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
331 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
332 } 258 }
333 259
334 // Serpent-Twofish-AES 260 // Serpent-Twofish-AES
@@ -339,7 +265,5 @@ namespace VeraCrypt
339 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); 265 Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ()));
340 266
341 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 267 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
342 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
343 SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
344 } 268 }
345} 269}
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
74 } 74 }
75 75
76 TC_ENCRYPTION_ALGORITHM (AES); 76 TC_ENCRYPTION_ALGORITHM (AES);
77 TC_ENCRYPTION_ALGORITHM (AESBlowfish);
78 TC_ENCRYPTION_ALGORITHM (AESBlowfishSerpent);
79 TC_ENCRYPTION_ALGORITHM (AESTwofish); 77 TC_ENCRYPTION_ALGORITHM (AESTwofish);
80 TC_ENCRYPTION_ALGORITHM (AESTwofishSerpent); 78 TC_ENCRYPTION_ALGORITHM (AESTwofishSerpent);
81 TC_ENCRYPTION_ALGORITHM (Blowfish);
82 TC_ENCRYPTION_ALGORITHM (Cast5);
83 TC_ENCRYPTION_ALGORITHM (Serpent); 79 TC_ENCRYPTION_ALGORITHM (Serpent);
84 TC_ENCRYPTION_ALGORITHM (SerpentAES); 80 TC_ENCRYPTION_ALGORITHM (SerpentAES);
85 TC_ENCRYPTION_ALGORITHM (TripleDES);
86 TC_ENCRYPTION_ALGORITHM (Twofish); 81 TC_ENCRYPTION_ALGORITHM (Twofish);
87 TC_ENCRYPTION_ALGORITHM (TwofishSerpent); 82 TC_ENCRYPTION_ALGORITHM (TwofishSerpent);
88 TC_ENCRYPTION_ALGORITHM (SerpentTwofishAES); 83 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 @@
7*/ 7*/
8 8
9#include "EncryptionMode.h" 9#include "EncryptionMode.h"
10#include "EncryptionModeCBC.h"
11#include "EncryptionModeLRW.h"
12#include "EncryptionModeXTS.h" 10#include "EncryptionModeXTS.h"
13#include "EncryptionThreadPool.h" 11#include "EncryptionThreadPool.h"
14 12
@@ -37,8 +35,6 @@ namespace VeraCrypt
37 EncryptionModeList l; 35 EncryptionModeList l;
38 36
39 l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 37 l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
40 l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
41 l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
42 38
43 return l; 39 return l;
44 } 40 }
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 @@
1/*
2 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4 Governed by the TrueCrypt License 3.0 the full text of which is contained in
5 the file License.txt included in TrueCrypt binary and source code distribution
6 packages.
7*/
8
9#include "Platform/Memory.h"
10#include "Common/Crc.h"
11#include "Common/Endian.h"
12#include "EncryptionModeCBC.h"
13
14namespace VeraCrypt
15{
16 void EncryptionModeCBC::Decrypt (byte *data, uint64 length) const
17 {
18 if_debug (ValidateState ());
19 if_debug (ValidateParameters (data, length));
20
21 if (IsOuterCBC (Ciphers))
22 {
23 DecryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
24 }
25 else
26 {
27 for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
28 iCipherList != Ciphers.rend();
29 ++iCipherList)
30 {
31 CipherList cl;
32 cl.push_back (*iCipherList);
33
34 DecryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
35 }
36 }
37 }
38
39 void EncryptionModeCBC::DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const
40 {
41 size_t blockSize = ciphers.front()->GetBlockSize();
42 if (blockSize != 8 && blockSize != 16)
43 throw ParameterIncorrect (SRC_POS);
44
45 uint32 *data32 = (uint32 *) data;
46 uint32 bufIV[4];
47 uint32 ct[4];
48 uint64 i;
49
50 bufIV[0] = iv[0];
51 bufIV[1] = iv[1];
52 if (blockSize == 16)
53 {
54 bufIV[2] = iv[2];
55 bufIV[3] = iv[3];
56 }
57
58 for (i = 0; i < length / blockSize; i++)
59 {
60 // Dewhitening
61 data32[0] ^= whitening[0];
62 data32[1] ^= whitening[1];
63 if (blockSize == 16)
64 {
65 data32[2] ^= whitening[0];
66 data32[3] ^= whitening[1];
67 }
68
69 // CBC
70 ct[0] = data32[0];
71 ct[1] = data32[1];
72 if (blockSize == 16)
73 {
74 ct[2] = data32[2];
75 ct[3] = data32[3];
76 }
77
78 for (CipherList::const_reverse_iterator iCipherList = ciphers.rbegin();
79 iCipherList != ciphers.rend();
80 ++iCipherList)
81 {
82 const Cipher &c = **iCipherList;
83
84 if (c.GetBlockSize () != blockSize)
85 throw ParameterIncorrect (SRC_POS);
86
87 c.DecryptBlock ((byte *) data32);
88 }
89
90 // CBC
91 data32[0] ^= bufIV[0];
92 data32[1] ^= bufIV[1];
93 bufIV[0] = ct[0];
94 bufIV[1] = ct[1];
95 if (blockSize == 16)
96 {
97 data32[2] ^= bufIV[2];
98 data32[3] ^= bufIV[3];
99 bufIV[2] = ct[2];
100 bufIV[3] = ct[3];
101 }
102
103 data32 += blockSize / sizeof(*data32);
104 }
105
106 Memory::Erase (bufIV, sizeof (bufIV));
107 Memory::Erase (ct, sizeof (ct));
108 }
109
110 void EncryptionModeCBC::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
111 {
112 if_debug (ValidateState ());
113 if_debug (ValidateParameters (data, sectorCount, sectorSize));
114
115 uint32 sectorIV[4];
116 uint32 sectorWhitening[2];
117
118 while (sectorCount--)
119 {
120 if (IsOuterCBC (Ciphers))
121 {
122 InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
123 DecryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening);
124 }
125 else
126 {
127 for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
128 iCipherList != Ciphers.rend();
129 ++iCipherList)
130 {
131 const Cipher &c = **iCipherList;
132 CipherList cl;
133 cl.push_back (*iCipherList);
134
135 InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
136 DecryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening);
137 }
138 }
139
140 data += sectorSize;
141 sectorIndex++;
142 }
143
144 Memory::Erase (sectorIV, sizeof (sectorIV));
145 Memory::Erase (sectorWhitening, sizeof (sectorWhitening));
146 }
147
148 void EncryptionModeCBC::Encrypt (byte *data, uint64 length) const
149 {
150 if_debug (ValidateState ());
151 if_debug (ValidateParameters (data, length));
152
153 if (IsOuterCBC (Ciphers))
154 {
155 EncryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
156 }
157 else
158 {
159 for (CipherList::const_iterator iCipherList = Ciphers.begin();
160 iCipherList != Ciphers.end();
161 ++iCipherList)
162 {
163 CipherList cl;
164 cl.push_back (*iCipherList);
165
166 EncryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset));
167 }
168 }
169 }
170
171 void EncryptionModeCBC::EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const
172 {
173 size_t blockSize = ciphers.front()->GetBlockSize();
174 if (blockSize != 8 && blockSize != 16)
175 throw ParameterIncorrect (SRC_POS);
176
177 uint32 *data32 = (uint32 *) data;
178 uint32 bufIV[4];
179 uint64 i;
180
181 bufIV[0] = iv[0];
182 bufIV[1] = iv[1];
183 if (blockSize == 16)
184 {
185 bufIV[2] = iv[2];
186 bufIV[3] = iv[3];
187 }
188
189 for (i = 0; i < length / blockSize; i++)
190 {
191 data32[0] ^= bufIV[0];
192 data32[1] ^= bufIV[1];
193 if (blockSize == 16)
194 {
195 data32[2] ^= bufIV[2];
196 data32[3] ^= bufIV[3];
197 }
198
199 for (CipherList::const_iterator iCipherList = ciphers.begin();
200 iCipherList != ciphers.end();
201 ++iCipherList)
202 {
203 const Cipher &c = **iCipherList;
204
205 if (c.GetBlockSize () != blockSize)
206 throw ParameterIncorrect (SRC_POS);
207
208 c.EncryptBlock ((byte *) data32);
209 }
210
211 bufIV[0] = data32[0];
212 bufIV[1] = data32[1];
213 if (blockSize == 16)
214 {
215 bufIV[2] = data32[2];
216 bufIV[3] = data32[3];
217 }
218
219 data32[0] ^= whitening[0];
220 data32[1] ^= whitening[1];
221 if (blockSize == 16)
222 {
223 data32[2] ^= whitening[0];
224 data32[3] ^= whitening[1];
225 }
226
227 data32 += blockSize / sizeof(*data32);
228 }
229
230 Memory::Erase (bufIV, sizeof (bufIV));
231 }
232
233 void EncryptionModeCBC::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
234 {
235 if_debug (ValidateState ());
236 if_debug (ValidateParameters (data, sectorCount, sectorSize));
237
238 uint32 sectorIV[4];
239 uint32 sectorWhitening[2];
240
241 while (sectorCount--)
242 {
243 if (IsOuterCBC (Ciphers))
244 {
245 InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
246 EncryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening);
247 }
248 else
249 {
250 for (CipherList::const_iterator iCipherList = Ciphers.begin();
251 iCipherList != Ciphers.end();
252 ++iCipherList)
253 {
254 const Cipher &c = **iCipherList;
255 CipherList cl;
256 cl.push_back (*iCipherList);
257
258 InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening);
259 EncryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening);
260 }
261 }
262
263 data += sectorSize;
264 sectorIndex++;
265 }
266
267 Memory::Erase (sectorIV, sizeof (sectorIV));
268 Memory::Erase (sectorWhitening, sizeof (sectorWhitening));
269 }
270
271 void EncryptionModeCBC::InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const
272 {
273 if (blockSize != 8 && blockSize != 16)
274 throw ParameterIncorrect (SRC_POS);
275
276 uint64 iv64[4];
277 uint32 *iv32 = (uint32 *) iv64;
278
279 iv64[0] = ivSeed[0] ^ Endian::Little (sectorIndex);
280 iv64[1] = ivSeed[1] ^ Endian::Little (sectorIndex);
281 iv64[2] = ivSeed[2] ^ Endian::Little (sectorIndex);
282 if (blockSize == 16)
283 {
284 iv64[3] = ivSeed[3] ^ Endian::Little (sectorIndex);
285 }
286
287 iv[0] = iv32[0];
288 iv[1] = iv32[1];
289
290 if (blockSize == 8)
291 {
292 whitening[0] = Endian::Little ( crc32int ( &iv32[2] ) ^ crc32int ( &iv32[5] ) );
293 whitening[1] = Endian::Little ( crc32int ( &iv32[3] ) ^ crc32int ( &iv32[4] ) );
294 }
295 else
296 {
297 iv[2] = iv32[2];
298 iv[3] = iv32[3];
299
300 whitening[0] = Endian::Little ( crc32int ( &iv32[4] ) ^ crc32int ( &iv32[7] ) );
301 whitening[1] = Endian::Little ( crc32int ( &iv32[5] ) ^ crc32int ( &iv32[6] ) );
302 }
303 }
304
305 bool EncryptionModeCBC::IsOuterCBC (const CipherList &ciphers) const
306 {
307 if (ciphers.size() < 2)
308 return false;
309
310 size_t blockSize = ciphers.front()->GetBlockSize();
311
312 for (CipherList::const_iterator iCipherList = ciphers.begin();
313 iCipherList != ciphers.end();
314 ++iCipherList)
315 {
316 const Cipher &c = **iCipherList;
317 if (c.GetBlockSize() != blockSize)
318 return false;
319 }
320
321 return true;
322 }
323
324 void EncryptionModeCBC::SetKey (const ConstBufferPtr &key)
325 {
326 if (key.Size() != GetKeySize ())
327 throw ParameterIncorrect (SRC_POS);
328
329 if (!KeySet)
330 IV.Allocate (GetKeySize ());
331
332 IV.CopyFrom (key);
333 KeySet = true;
334 }
335}
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 @@
1/*
2 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4 Governed by the TrueCrypt License 3.0 the full text of which is contained in
5 the file License.txt included in TrueCrypt binary and source code distribution
6 packages.
7*/
8
9#ifndef TC_HEADER_Encryption_EncryptionModeCBC
10#define TC_HEADER_Encryption_EncryptionModeCBC
11
12#include "Platform/Platform.h"
13#include "EncryptionMode.h"
14
15namespace VeraCrypt
16{
17 class EncryptionModeCBC : public EncryptionMode
18 {
19 public:
20 EncryptionModeCBC () { }
21 virtual ~EncryptionModeCBC () { }
22
23 virtual void Decrypt (byte *data, uint64 length) const;
24 virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
25 virtual void Encrypt (byte *data, uint64 length) const;
26 virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
27 virtual size_t GetKeySize () const { return 32; };
28 virtual wstring GetName () const { return L"CBC"; };
29 virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeCBC); }
30 virtual void SetKey (const ConstBufferPtr &key);
31
32 protected:
33 void DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
34 void EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const;
35 void InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const;
36 bool IsOuterCBC (const CipherList &ciphers) const;
37
38 SecureBuffer IV;
39 static const int WhiteningIVOffset = 8;
40
41 private:
42 EncryptionModeCBC (const EncryptionModeCBC &);
43 EncryptionModeCBC &operator= (const EncryptionModeCBC &);
44 };
45}
46
47#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 @@
1/*
2 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4 Governed by the TrueCrypt License 3.0 the full text of which is contained in
5 the file License.txt included in TrueCrypt binary and source code distribution
6 packages.
7*/
8
9#include "EncryptionModeLRW.h"
10#include "Common/GfMul.h"
11
12namespace VeraCrypt
13{
14 void EncryptionModeLRW::Decrypt (byte *data, uint64 length) const
15 {
16 if_debug (ValidateState ());
17 DecryptBuffer (data, length, 1);
18 }
19
20 void EncryptionModeLRW::DecryptBuffer (byte *data, uint64 length, uint64 blockIndex) const
21 {
22 size_t blockSize = Ciphers.front()->GetBlockSize();
23 if (blockSize != 8 && blockSize != 16)
24 throw ParameterIncorrect (SRC_POS);
25
26 byte i[8];
27 *(uint64 *)i = Endian::Big (blockIndex);
28
29 byte t[Cipher::MaxBlockSize];
30
31 for (unsigned int b = 0; b < length / blockSize; b++)
32 {
33 if (blockSize == 8)
34 {
35 Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr()));
36 Xor64 ((uint64 *)data, (uint64 *)t);
37 }
38 else
39 {
40 Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr()));
41 Xor128 ((uint64 *)data, (uint64 *)t);
42 }
43
44 for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin();
45 iCipherList != Ciphers.rend();
46 ++iCipherList)
47 {
48 const Cipher &c = **iCipherList;
49
50 if (c.GetBlockSize () != blockSize)
51 throw ParameterIncorrect (SRC_POS);
52
53 c.DecryptBlock (data);
54 }
55
56 if (blockSize == 8)
57 Xor64 ((uint64 *)data, (uint64 *)t);
58 else
59 Xor128 ((uint64 *)data, (uint64 *)t);
60
61 data += blockSize;
62 IncrementBlockIndex (i);
63 }
64
65 Memory::Erase (t, sizeof (t));
66 }
67
68 void EncryptionModeLRW::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
69 {
70 if_debug (ValidateState ());
71 if_debug (ValidateParameters (data, sectorCount, sectorSize));
72
73 DecryptBuffer (data,
74 sectorCount * sectorSize,
75 SectorToBlockIndex (sectorIndex));
76 }
77
78 void EncryptionModeLRW::Encrypt (byte *data, uint64 length) const
79 {
80 ValidateState ();
81 EncryptBuffer (data, length, 1);
82 }
83
84 void EncryptionModeLRW::EncryptBuffer (byte *data, uint64 length, uint64 blockIndex) const
85 {
86 size_t blockSize = Ciphers.front()->GetBlockSize();
87 if (blockSize != 8 && blockSize != 16)
88 throw ParameterIncorrect (SRC_POS);
89
90 byte i[8];
91 *(uint64 *)i = Endian::Big (blockIndex);
92
93 byte t[Cipher::MaxBlockSize];
94
95 for (unsigned int b = 0; b < length / blockSize; b++)
96 {
97 if (blockSize == 8)
98 {
99 Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr()));
100 Xor64 ((uint64 *)data, (uint64 *)t);
101 }
102 else
103 {
104 Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr()));
105 Xor128 ((uint64 *)data, (uint64 *)t);
106 }
107
108 for (CipherList::const_iterator iCipherList = Ciphers.begin();
109 iCipherList != Ciphers.end();
110 ++iCipherList)
111 {
112 const Cipher &c = **iCipherList;
113
114 if (c.GetBlockSize () != blockSize)
115 throw ParameterIncorrect (SRC_POS);
116
117 c.EncryptBlock (data);
118 }
119
120 if (blockSize == 8)
121 Xor64 ((uint64 *)data, (uint64 *)t);
122 else
123 Xor128 ((uint64 *)data, (uint64 *)t);
124
125 data += blockSize;
126 IncrementBlockIndex (i);
127 }
128
129 Memory::Erase (t, sizeof (t));
130 }
131
132 void EncryptionModeLRW::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const
133 {
134 if_debug (ValidateState ());
135 if_debug (ValidateParameters (data, sectorCount, sectorSize));
136
137 EncryptBuffer (data,
138 sectorCount * sectorSize,
139 SectorToBlockIndex (sectorIndex));
140 }
141
142 void EncryptionModeLRW::IncrementBlockIndex (byte *index) const
143 {
144 if (index[7] != 0xff)
145 index[7]++;
146 else
147 *(uint64 *)index = Endian::Big ( Endian::Big (*(uint64 *)index) + 1 );
148 }
149
150 uint64 EncryptionModeLRW::SectorToBlockIndex (uint64 sectorIndex) const
151 {
152 sectorIndex -= SectorOffset;
153
154 switch (Ciphers.front()->GetBlockSize())
155 {
156 case 8:
157 return (sectorIndex << 6) | 1;
158
159 case 16:
160 return (sectorIndex << 5) | 1;
161
162 default:
163 throw ParameterIncorrect (SRC_POS);
164 }
165 }
166
167 void EncryptionModeLRW::SetKey (const ConstBufferPtr &key)
168 {
169 if (key.Size() != 16)
170 throw ParameterIncorrect (SRC_POS);
171
172 if (!KeySet)
173 GfContext.Allocate (sizeof (GfCtx));
174
175 if (!Gf64TabInit ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
176 throw bad_alloc();
177
178 if (!Gf128Tab64Init ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr())))
179 throw bad_alloc();
180
181 Key.CopyFrom (key);
182 KeySet = true;
183 }
184
185 void EncryptionModeLRW::Xor64 (uint64 *a, const uint64 *b) const
186 {
187 *a ^= *b;
188 }
189
190 void EncryptionModeLRW::Xor128 (uint64 *a, const uint64 *b) const
191 {
192 *a++ ^= *b++;
193 *a ^= *b;
194 }
195}
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 @@
1/*
2 Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved.
3
4 Governed by the TrueCrypt License 3.0 the full text of which is contained in
5 the file License.txt included in TrueCrypt binary and source code distribution
6 packages.
7*/
8
9#ifndef TC_HEADER_Encryption_EncryptionModeLRW
10#define TC_HEADER_Encryption_EncryptionModeLRW
11
12#include "Platform/Platform.h"
13#include "EncryptionMode.h"
14
15namespace VeraCrypt
16{
17 class EncryptionModeLRW : public EncryptionMode
18 {
19 public:
20 EncryptionModeLRW () { }
21 virtual ~EncryptionModeLRW () { }
22
23 virtual void Decrypt (byte *data, uint64 length) const;
24 virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
25 virtual void Encrypt (byte *data, uint64 length) const;
26 virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const;
27 virtual const SecureBuffer &GetKey () const { return Key; }
28 virtual size_t GetKeySize () const { return 16; };
29 virtual wstring GetName () const { return L"LRW"; };
30 virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeLRW); }
31 virtual void SetKey (const ConstBufferPtr &key);
32
33 protected:
34 void DecryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const;
35 void EncryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const;
36 void IncrementBlockIndex (byte *index) const;
37 uint64 SectorToBlockIndex (uint64 sectorIndex) const;
38 void Xor64 (uint64 *a, const uint64 *b) const;
39 void Xor128 (uint64 *a, const uint64 *b) const;
40
41 SecureBuffer GfContext;
42 SecureBuffer Key;
43
44 private:
45 EncryptionModeLRW (const EncryptionModeLRW &);
46 EncryptionModeLRW &operator= (const EncryptionModeLRW &);
47 };
48}
49
50#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 @@
11#include "Crc32.h" 11#include "Crc32.h"
12#include "EncryptionAlgorithm.h" 12#include "EncryptionAlgorithm.h"
13#include "EncryptionMode.h" 13#include "EncryptionMode.h"
14#include "EncryptionModeCBC.h"
15#include "EncryptionModeLRW.h"
16#include "EncryptionModeXTS.h" 14#include "EncryptionModeXTS.h"
17#include "EncryptionTest.h" 15#include "EncryptionTest.h"
18#include "Pkcs5Kdf.h" 16#include "Pkcs5Kdf.h"
@@ -35,83 +33,9 @@ namespace VeraCrypt
35 TestCiphers(); 33 TestCiphers();
36 TestXtsAES(); 34 TestXtsAES();
37 TestXts(); 35 TestXts();
38 TestLegacyModes();
39 TestPkcs5(); 36 TestPkcs5();
40 } 37 }
41 38
42 void EncryptionTest::TestLegacyModes ()
43 {
44 byte buf[ENCRYPTION_DATA_UNIT_SIZE * 2];
45 byte iv[32];
46 unsigned int i;
47 uint32 crc;
48 uint64 secNo = 0x0234567890ABCDEFull;
49
50 for (i = 0; i < sizeof (buf); i++)
51 buf[i] = (byte) i;
52
53 for (i = 0; i < sizeof (iv); i++)
54 iv[i] = (byte) i;
55
56 EncryptionModeList encModes = EncryptionMode::GetAvailableModes ();
57
58 foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms())
59 {
60 foreach (shared_ptr <EncryptionMode> mode, encModes)
61 {
62 if (typeid (*mode) == typeid (EncryptionModeXTS))
63 continue;
64
65 if (!mode->IsKeySet())
66 {
67 mode->SetKey (ConstBufferPtr (iv, mode->GetKeySize()));
68 mode->SetSectorOffset (1);
69 }
70
71 if (ea.IsModeSupported (mode))
72 {
73 ea.SetMode (mode);
74 ea.SetKey (ConstBufferPtr (buf, ea.GetKeySize()));
75
76 ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
77 ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
78 ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
79
80 crc = ::GetCrc32 (buf, sizeof (buf));
81
82 if (typeid (*mode) == typeid (EncryptionModeLRW))
83 {
84 if (typeid (ea) == typeid (AES) && crc != 0x5237acf9) throw TestFailed (SRC_POS);
85 if (typeid (ea) == typeid (AESTwofish) && crc != 0x4ed0fd80) throw TestFailed (SRC_POS);
86 if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0xea04b3cf) throw TestFailed (SRC_POS);
87 if (typeid (ea) == typeid (Blowfish) && crc != 0xf94d5300) throw TestFailed (SRC_POS);
88 if (typeid (ea) == typeid (Cast5) && crc != 0x33971e82) throw TestFailed (SRC_POS);
89 if (typeid (ea) == typeid (Serpent) && crc != 0x7fb86805) throw TestFailed (SRC_POS);
90 if (typeid (ea) == typeid (TripleDES) && crc != 0x2b20bb84) throw TestFailed (SRC_POS);
91 if (typeid (ea) == typeid (Twofish) && crc != 0xa9de0f0b) throw TestFailed (SRC_POS);
92 if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xca65c5cd) throw TestFailed (SRC_POS);
93 }
94
95 if (typeid (*mode) == typeid (EncryptionModeCBC))
96 {
97 if (typeid (ea) == typeid (AES) && crc != 0x2274f53d) throw TestFailed (SRC_POS);
98 if (typeid (ea) == typeid (AESBlowfish) && crc != 0xa7a80c84) throw TestFailed (SRC_POS);
99 if (typeid (ea) == typeid (AESBlowfishSerpent) && crc != 0xa0584562) throw TestFailed (SRC_POS);
100 if (typeid (ea) == typeid (AESTwofish) && crc != 0x3c226444) throw TestFailed (SRC_POS);
101 if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0x5e5e77fd) throw TestFailed (SRC_POS);
102 if (typeid (ea) == typeid (Blowfish) && crc != 0x033899a1) throw TestFailed (SRC_POS);
103 if (typeid (ea) == typeid (Cast5) && crc != 0x331cecc7) throw TestFailed (SRC_POS);
104 if (typeid (ea) == typeid (Serpent) && crc != 0x42dff3d4) throw TestFailed (SRC_POS);
105 if (typeid (ea) == typeid (TripleDES) && crc != 0xfe497d0c) throw TestFailed (SRC_POS);
106 if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xa7b659f3) throw TestFailed (SRC_POS);
107 }
108
109 ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE);
110 }
111 }
112 }
113 }
114
115 39
116 struct CipherTestVector 40 struct CipherTestVector
117 { 41 {
@@ -872,11 +796,6 @@ namespace VeraCrypt
872 if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0) 796 if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0)
873 throw TestFailed (SRC_POS); 797 throw TestFailed (SRC_POS);
874 798
875 Pkcs5HmacSha1 pkcs5HmacSha1;
876 pkcs5HmacSha1.DeriveKey (derivedKey, password, salt, 5, FALSE);
877 if (memcmp (derivedKey.Ptr(), "\x5c\x75\xce\xf0", 4) != 0)
878 throw TestFailed (SRC_POS);
879
880 Pkcs5HmacSha512 pkcs5HmacSha512; 799 Pkcs5HmacSha512 pkcs5HmacSha512;
881 pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE); 800 pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE);
882 if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0) 801 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 @@
9#include "Hash.h" 9#include "Hash.h"
10 10
11#include "Crypto/Rmd160.h" 11#include "Crypto/Rmd160.h"
12#include "Crypto/Sha1.h"
13#include "Crypto/Sha2.h" 12#include "Crypto/Sha2.h"
14#include "Crypto/Whirlpool.h" 13#include "Crypto/Whirlpool.h"
15 14
@@ -22,7 +21,6 @@ namespace VeraCrypt
22 l.push_back (shared_ptr <Hash> (new Ripemd160 ())); 21 l.push_back (shared_ptr <Hash> (new Ripemd160 ()));
23 l.push_back (shared_ptr <Hash> (new Sha512 ())); 22 l.push_back (shared_ptr <Hash> (new Sha512 ()));
24 l.push_back (shared_ptr <Hash> (new Whirlpool ())); 23 l.push_back (shared_ptr <Hash> (new Whirlpool ()));
25 l.push_back (shared_ptr <Hash> (new Sha1 ()));
26 24
27 return l; 25 return l;
28 } 26 }
@@ -62,31 +60,6 @@ namespace VeraCrypt
62 if_debug (ValidateDataParameters (data)); 60 if_debug (ValidateDataParameters (data));
63 RMD160Update ((RMD160_CTX *) Context.Ptr(), data.Get(), (int) data.Size()); 61 RMD160Update ((RMD160_CTX *) Context.Ptr(), data.Get(), (int) data.Size());
64 } 62 }
65
66 // SHA-1
67 Sha1::Sha1 ()
68 {
69 Deprecated = true;
70 Context.Allocate (sizeof (sha1_ctx));
71 Init();
72 }
73
74 void Sha1::GetDigest (const BufferPtr &buffer)
75 {
76 if_debug (ValidateDigestParameters (buffer));
77 sha1_end (buffer, (sha1_ctx *) Context.Ptr());
78 }
79
80 void Sha1::Init ()
81 {
82 sha1_begin ((sha1_ctx *) Context.Ptr());
83 }
84
85 void Sha1::ProcessData (const ConstBufferPtr &data)
86 {
87 if_debug (ValidateDataParameters (data));
88 sha1_hash (data.Get(), (int) data.Size(), (sha1_ctx *) Context.Ptr());
89 }
90 63
91 // SHA-512 64 // SHA-512
92 Sha512::Sha512 () 65 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
65 Ripemd160 &operator= (const Ripemd160 &); 65 Ripemd160 &operator= (const Ripemd160 &);
66 }; 66 };
67 67
68 // SHA-1
69 class Sha1 : public Hash
70 {
71 public:
72 Sha1 ();
73 virtual ~Sha1 () { }
74
75 virtual void GetDigest (const BufferPtr &buffer);
76 virtual size_t GetBlockSize () const { return 64; }
77 virtual size_t GetDigestSize () const { return 160 / 8; }
78 virtual wstring GetName () const { return L"SHA-1"; }
79 virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha1); }
80 virtual void Init ();
81 virtual void ProcessData (const ConstBufferPtr &data);
82
83 protected:
84
85 private:
86 Sha1 (const Sha1 &);
87 Sha1 &operator= (const Sha1 &);
88 };
89
90 // SHA-512 68 // SHA-512
91 class Sha512 : public Hash 69 class Sha512 : public Hash
92 { 70 {
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
53 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacRipemd160 ())); 53 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacRipemd160 ()));
54 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ())); 54 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ()));
55 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ())); 55 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ()));
56 l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha1 ()));
57 56
58 return l; 57 return l;
59 } 58 }
@@ -76,12 +75,6 @@ namespace VeraCrypt
76 derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); 75 derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
77 } 76 }
78 77
79 void Pkcs5HmacSha1::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
80 {
81 ValidateParameters (key, password, salt, iterationCount);
82 derive_key_sha1 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size());
83 }
84
85 void Pkcs5HmacSha512::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const 78 void Pkcs5HmacSha512::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const
86 { 79 {
87 ValidateParameters (key, password, salt, iterationCount); 80 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
75 Pkcs5HmacRipemd160_1000 &operator= (const Pkcs5HmacRipemd160_1000 &); 75 Pkcs5HmacRipemd160_1000 &operator= (const Pkcs5HmacRipemd160_1000 &);
76 }; 76 };
77 77
78 class Pkcs5HmacSha1 : public Pkcs5Kdf
79 {
80 public:
81 Pkcs5HmacSha1 () { }
82 virtual ~Pkcs5HmacSha1 () { }
83
84 virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const;
85 virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha1); }
86 virtual int GetIterationCount () const { return 500000; }
87 virtual wstring GetName () const { return L"HMAC-SHA-1"; }
88
89 private:
90 Pkcs5HmacSha1 (const Pkcs5HmacSha1 &);
91 Pkcs5HmacSha1 &operator= (const Pkcs5HmacSha1 &);
92 };
93 78
94 class Pkcs5HmacSha512 : public Pkcs5Kdf 79 class Pkcs5HmacSha512 : public Pkcs5Kdf
95 { 80 {
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 @@
9#ifndef TC_WINDOWS 9#ifndef TC_WINDOWS
10#include <errno.h> 10#include <errno.h>
11#endif 11#endif
12#include "EncryptionModeLRW.h"
13#include "EncryptionModeXTS.h" 12#include "EncryptionModeXTS.h"
14#include "Volume.h" 13#include "Volume.h"
15#include "VolumeHeader.h" 14#include "VolumeHeader.h"
@@ -226,10 +225,6 @@ namespace VeraCrypt
226 225
227 mode.SetSectorOffset (partitionStartOffset / ENCRYPTION_DATA_UNIT_SIZE); 226 mode.SetSectorOffset (partitionStartOffset / ENCRYPTION_DATA_UNIT_SIZE);
228 } 227 }
229 else if (typeid (mode) == typeid (EncryptionModeLRW))
230 {
231 mode.SetSectorOffset (VolumeDataOffset / SectorSize);
232 }
233 228
234 // Volume protection 229 // Volume protection
235 if (Protection == VolumeProtection::HiddenVolumeReadOnly) 230 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
41 41
42OBJS += ../Crypto/Aeskey.o 42OBJS += ../Crypto/Aeskey.o
43OBJS += ../Crypto/Aestab.o 43OBJS += ../Crypto/Aestab.o
44OBJS += ../Crypto/Blowfish.o
45OBJS += ../Crypto/Cast.o
46OBJS += ../Crypto/Des.o
47OBJS += ../Crypto/Rmd160.o 44OBJS += ../Crypto/Rmd160.o
48OBJS += ../Crypto/Serpent.o 45OBJS += ../Crypto/Serpent.o
49OBJS += ../Crypto/Sha1.o
50OBJS += ../Crypto/Sha2.o 46OBJS += ../Crypto/Sha2.o
51OBJS += ../Crypto/Twofish.o 47OBJS += ../Crypto/Twofish.o
52OBJS += ../Crypto/Whirlpool.o 48OBJS += ../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 @@
7*/ 7*/
8 8
9#include "Volume/EncryptionMode.h" 9#include "Volume/EncryptionMode.h"
10#include "Volume/EncryptionModeCBC.h"
11#include "Volume/EncryptionModeLRW.h"
12#include "Volume/EncryptionModeXTS.h" 10#include "Volume/EncryptionModeXTS.h"
13#include "VolumeLayout.h" 11#include "VolumeLayout.h"
14#include "Boot/Windows/BootCommon.h" 12#include "Boot/Windows/BootCommon.h"
@@ -73,15 +71,7 @@ namespace VeraCrypt
73 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); 71 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
74 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); 72 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
75 73
76 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
77 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
78 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
79 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
80 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
81
82 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 74 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
83 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
84 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
85 } 75 }
86 76
87 uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const 77 uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const
@@ -110,15 +100,7 @@ namespace VeraCrypt
110 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); 100 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ()));
111 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); 101 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ()));
112 102
113 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ()));
114 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ()));
115 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ()));
116 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ()));
117 SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ()));
118
119 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); 103 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ()));
120 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ()));
121 SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ()));
122 } 104 }
123 105
124 uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const 106 uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const