diff options
Diffstat (limited to 'src/Volume')
-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 |
17 files changed, 0 insertions, 967 deletions
diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp index a69f15d9..5708e6e0 100644 --- a/src/Volume/Cipher.cpp +++ b/src/Volume/Cipher.cpp @@ -1,34 +1,31 @@ /* Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "Platform/Platform.h" #include "Cipher.h" #include "Crypto/Aes.h" -#include "Crypto/Blowfish.h" -#include "Crypto/Des.h" -#include "Crypto/Cast.h" #include "Crypto/Serpent.h" #include "Crypto/Twofish.h" #ifdef TC_AES_HW_CPU # include "Crypto/Aes_hw_cpu.h" #endif namespace VeraCrypt { Cipher::Cipher () : Initialized (false) { } Cipher::~Cipher () { } void Cipher::DecryptBlock (byte *data) const { if (!Initialized) @@ -59,43 +56,40 @@ namespace VeraCrypt void Cipher::EncryptBlocks (byte *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); while (blockCount-- > 0) { Encrypt (data); data += GetBlockSize(); } } CipherList Cipher::GetAvailableCiphers () { CipherList l; l.push_back (shared_ptr <Cipher> (new CipherAES ())); l.push_back (shared_ptr <Cipher> (new CipherSerpent ())); l.push_back (shared_ptr <Cipher> (new CipherTwofish ())); - l.push_back (shared_ptr <Cipher> (new CipherBlowfish ())); - l.push_back (shared_ptr <Cipher> (new CipherCast5 ())); - l.push_back (shared_ptr <Cipher> (new CipherTripleDES ())); return l; } void Cipher::SetKey (const ConstBufferPtr &key) { if (key.Size() != GetKeySize ()) throw ParameterIncorrect (SRC_POS); if (!Initialized) ScheduledKey.Allocate (GetScheduledKeySize ()); SetCipherKey (key); Key.CopyFrom (key); Initialized = true; } #define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) #undef TC_EXCEPTION_NODECL #define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) @@ -182,129 +176,62 @@ namespace VeraCrypt if (!stateValid) { state = is_aes_hw_cpu_supported() ? true : false; stateValid = true; } return state && HwSupportEnabled; #else return false; #endif } void CipherAES::SetCipherKey (const byte *key) { if (aes_encrypt_key256 (key, (aes_encrypt_ctx *) ScheduledKey.Ptr()) != EXIT_SUCCESS) throw CipherInitError (SRC_POS); if (aes_decrypt_key256 (key, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))) != EXIT_SUCCESS) throw CipherInitError (SRC_POS); } - - // Blowfish - void CipherBlowfish::Decrypt (byte *data) const - { - BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 0); - } - - void CipherBlowfish::Encrypt (byte *data) const - { - BlowfishEncryptLE (data, data, (BF_KEY *) ScheduledKey.Ptr(), 1); - } - - size_t CipherBlowfish::GetScheduledKeySize () const - { - return sizeof (BF_KEY); - } - - void CipherBlowfish::SetCipherKey (const byte *key) - { - BlowfishSetKey ((BF_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key); - } - - - // CAST5 - void CipherCast5::Decrypt (byte *data) const - { - Cast5Decrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr()); - } - - void CipherCast5::Encrypt (byte *data) const - { - Cast5Encrypt (data, data, (CAST_KEY *) ScheduledKey.Ptr()); - } - - size_t CipherCast5::GetScheduledKeySize () const - { - return sizeof (CAST_KEY); - } - - void CipherCast5::SetCipherKey (const byte *key) - { - Cast5SetKey ((CAST_KEY *) ScheduledKey.Ptr(), static_cast<int> (GetKeySize ()), (unsigned char *) key); - } - - // Serpent void CipherSerpent::Decrypt (byte *data) const { serpent_decrypt (data, data, ScheduledKey); } void CipherSerpent::Encrypt (byte *data) const { serpent_encrypt (data, data, ScheduledKey); } size_t CipherSerpent::GetScheduledKeySize () const { return 140*4; } void CipherSerpent::SetCipherKey (const byte *key) { serpent_set_key (key, static_cast<int> (GetKeySize ()), ScheduledKey); } - // Triple-DES - void CipherTripleDES::Decrypt (byte *data) const - { - TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 0); - } - - void CipherTripleDES::Encrypt (byte *data) const - { - TripleDesEncrypt (data, data, (TDES_KEY *) ScheduledKey.Ptr(), 1); - } - - size_t CipherTripleDES::GetScheduledKeySize () const - { - return sizeof (TDES_KEY); - } - - void CipherTripleDES::SetCipherKey (const byte *key) - { - TripleDesSetKey (key, GetKeySize(), (TDES_KEY *) ScheduledKey.Ptr()); - } - - // Twofish void CipherTwofish::Decrypt (byte *data) const { twofish_decrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data); } void CipherTwofish::Encrypt (byte *data) const { twofish_encrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data); } size_t CipherTwofish::GetScheduledKeySize () const { return TWOFISH_KS; } void CipherTwofish::SetCipherKey (const byte *key) { twofish_set_key ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *) key, static_cast<int> (GetKeySize ()) * 8); } diff --git a/src/Volume/Cipher.h b/src/Volume/Cipher.h index 90a9a215..4dbead51 100644 --- a/src/Volume/Cipher.h +++ b/src/Volume/Cipher.h @@ -83,44 +83,41 @@ namespace VeraCrypt virtual void Decrypt (byte *data) const; \ virtual void Encrypt (byte *data) const; \ virtual size_t GetScheduledKeySize () const; \ virtual void SetCipherKey (const byte *key); \ \ private: \ TC_JOIN (Cipher,NAME) (const TC_JOIN (Cipher,NAME) &); \ TC_JOIN (Cipher,NAME) &operator= (const TC_JOIN (Cipher,NAME) &); \ } #define TC_CIPHER_ADD_METHODS \ virtual void DecryptBlocks (byte *data, size_t blockCount) const; \ virtual void EncryptBlocks (byte *data, size_t blockCount) const; \ virtual bool IsHwSupportAvailable () const; TC_CIPHER (AES, 16, 32); #undef TC_CIPHER_ADD_METHODS #define TC_CIPHER_ADD_METHODS - TC_CIPHER (Blowfish, 8, 56); - TC_CIPHER (Cast5, 8, 16); TC_CIPHER (Serpent, 16, 32); - TC_CIPHER (TripleDES, 8, 24); TC_CIPHER (Twofish, 16, 32); #undef TC_CIPHER #define TC_EXCEPTION(NAME) TC_EXCEPTION_DECL(NAME,CipherException) #undef TC_EXCEPTION_SET #define TC_EXCEPTION_SET \ TC_EXCEPTION (CipherInitError); \ TC_EXCEPTION (WeakKeyDetected); TC_EXCEPTION_SET; #undef TC_EXCEPTION #if (defined (TC_ARCH_X86) || defined (TC_ARCH_X64)) && !defined (__ppc__) # define TC_AES_HW_CPU #endif diff --git a/src/Volume/EncryptionAlgorithm.cpp b/src/Volume/EncryptionAlgorithm.cpp index ce76e71f..3d854ae5 100644 --- a/src/Volume/EncryptionAlgorithm.cpp +++ b/src/Volume/EncryptionAlgorithm.cpp @@ -1,31 +1,29 @@ /* Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "EncryptionAlgorithm.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" namespace VeraCrypt { EncryptionAlgorithm::EncryptionAlgorithm () : Deprecated (false) { } EncryptionAlgorithm::~EncryptionAlgorithm () { } void EncryptionAlgorithm::Decrypt (byte *data, uint64 length) const { if_debug (ValidateState ()); Mode->Decrypt (data, length); } void EncryptionAlgorithm::Decrypt (const BufferPtr &data) const { @@ -51,45 +49,40 @@ namespace VeraCrypt void EncryptionAlgorithm::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { if_debug (ValidateState ()); Mode->EncryptSectors (data, sectorIndex, sectorCount, sectorSize); } EncryptionAlgorithmList EncryptionAlgorithm::GetAvailableAlgorithms () { EncryptionAlgorithmList l; l.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ())); - l.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ())); return l; } size_t EncryptionAlgorithm::GetLargestKeySize (const EncryptionAlgorithmList &algorithms) { size_t largestKeySize = 0; foreach_ref (const EncryptionAlgorithm &ea, algorithms) { if (ea.GetKeySize() > largestKeySize) largestKeySize = ea.GetKeySize(); } return largestKeySize; } size_t EncryptionAlgorithm::GetKeySize () const { if (Ciphers.size() < 1) throw NotInitialized (SRC_POS); @@ -192,154 +185,85 @@ namespace VeraCrypt size_t keyOffset = 0; foreach_ref (Cipher &c, Ciphers) { c.SetKey (key.GetRange (keyOffset, c.GetKeySize())); keyOffset += c.GetKeySize(); } } void EncryptionAlgorithm::ValidateState () const { if (Ciphers.size() < 1 || Mode.get() == nullptr) throw NotInitialized (SRC_POS); } // AES AES::AES () { Ciphers.push_back (shared_ptr <Cipher> (new CipherAES())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); - } - - // AES-Blowfish - AESBlowfish::AESBlowfish () - { - Deprecated = true; - - Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ())); - Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); - - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); - } - - // AES-Blowfish-Serpent - AESBlowfishSerpent::AESBlowfishSerpent () - { - Deprecated = true; - - Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); - Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish ())); - Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); - - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // AES-Twofish AESTwofish::AESTwofish () { Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // AES-Twofish-Serpent AESTwofishSerpent::AESTwofishSerpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); - } - - // Blowfish - Blowfish::Blowfish () - { - Deprecated = true; - Ciphers.push_back (shared_ptr <Cipher> (new CipherBlowfish())); - - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); - } - - // CAST5 - Cast5::Cast5 () - { - Deprecated = true; - Ciphers.push_back (shared_ptr <Cipher> (new CipherCast5())); - - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // Serpent Serpent::Serpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // Serpent-AES SerpentAES::SerpentAES () { Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); - } - - // Triple-DES - TripleDES::TripleDES () - { - Deprecated = true; - Ciphers.push_back (shared_ptr <Cipher> (new CipherTripleDES())); - - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // Twofish Twofish::Twofish () { Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // Twofish-Serpent TwofishSerpent::TwofishSerpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } // Serpent-Twofish-AES SerpentTwofishAES::SerpentTwofishAES () { Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } } diff --git a/src/Volume/EncryptionAlgorithm.h b/src/Volume/EncryptionAlgorithm.h index 7fbee6ae..5a5666fe 100644 --- a/src/Volume/EncryptionAlgorithm.h +++ b/src/Volume/EncryptionAlgorithm.h @@ -57,37 +57,32 @@ namespace VeraCrypt private: EncryptionAlgorithm (const EncryptionAlgorithm &); EncryptionAlgorithm &operator= (const EncryptionAlgorithm &); }; #define TC_ENCRYPTION_ALGORITHM(NAME) \ class NAME : public EncryptionAlgorithm \ { \ public: \ NAME (); \ virtual ~NAME () { } \ \ virtual shared_ptr <EncryptionAlgorithm> GetNew () const { return shared_ptr <EncryptionAlgorithm> (new NAME()); } \ \ private: \ NAME (const NAME &); \ NAME &operator= (const NAME &); \ } TC_ENCRYPTION_ALGORITHM (AES); - TC_ENCRYPTION_ALGORITHM (AESBlowfish); - TC_ENCRYPTION_ALGORITHM (AESBlowfishSerpent); TC_ENCRYPTION_ALGORITHM (AESTwofish); TC_ENCRYPTION_ALGORITHM (AESTwofishSerpent); - TC_ENCRYPTION_ALGORITHM (Blowfish); - TC_ENCRYPTION_ALGORITHM (Cast5); TC_ENCRYPTION_ALGORITHM (Serpent); TC_ENCRYPTION_ALGORITHM (SerpentAES); - TC_ENCRYPTION_ALGORITHM (TripleDES); TC_ENCRYPTION_ALGORITHM (Twofish); TC_ENCRYPTION_ALGORITHM (TwofishSerpent); TC_ENCRYPTION_ALGORITHM (SerpentTwofishAES); #undef TC_ENCRYPTION_ALGORITHM } #endif // TC_HEADER_Encryption_EncryptionAlgorithm diff --git a/src/Volume/EncryptionMode.cpp b/src/Volume/EncryptionMode.cpp index 0a7ac546..14642b80 100644 --- a/src/Volume/EncryptionMode.cpp +++ b/src/Volume/EncryptionMode.cpp @@ -1,61 +1,57 @@ /* Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "EncryptionMode.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "EncryptionThreadPool.h" namespace VeraCrypt { EncryptionMode::EncryptionMode () : KeySet (false), SectorOffset (0) { } EncryptionMode::~EncryptionMode () { } void EncryptionMode::DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::DecryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize); } void EncryptionMode::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::EncryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize); } EncryptionModeList EncryptionMode::GetAvailableModes () { EncryptionModeList l; l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); return l; } void EncryptionMode::ValidateState () const { if (!KeySet || Ciphers.size() < 1) throw NotInitialized (SRC_POS); } void EncryptionMode::ValidateParameters (byte *data, uint64 length) const { if ((Ciphers.size() > 0 && (length % Ciphers.front()->GetBlockSize()) != 0)) throw ParameterIncorrect (SRC_POS); } void EncryptionMode::ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const { if (sectorCount == 0 || sectorSize == 0 || (sectorSize % EncryptionDataUnitSize) != 0) throw ParameterIncorrect (SRC_POS); diff --git a/src/Volume/EncryptionModeCBC.cpp b/src/Volume/EncryptionModeCBC.cpp deleted file mode 100644 index 2892986b..00000000 --- a/src/Volume/EncryptionModeCBC.cpp +++ /dev/null @@ -1,335 +0,0 @@ -/* - Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. - - Governed by the TrueCrypt License 3.0 the full text of which is contained in - the file License.txt included in TrueCrypt binary and source code distribution - packages. -*/ - -#include "Platform/Memory.h" -#include "Common/Crc.h" -#include "Common/Endian.h" -#include "EncryptionModeCBC.h" - -namespace VeraCrypt -{ - void EncryptionModeCBC::Decrypt (byte *data, uint64 length) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, length)); - - if (IsOuterCBC (Ciphers)) - { - DecryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset)); - } - else - { - for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin(); - iCipherList != Ciphers.rend(); - ++iCipherList) - { - CipherList cl; - cl.push_back (*iCipherList); - - DecryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset)); - } - } - } - - void EncryptionModeCBC::DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const - { - size_t blockSize = ciphers.front()->GetBlockSize(); - if (blockSize != 8 && blockSize != 16) - throw ParameterIncorrect (SRC_POS); - - uint32 *data32 = (uint32 *) data; - uint32 bufIV[4]; - uint32 ct[4]; - uint64 i; - - bufIV[0] = iv[0]; - bufIV[1] = iv[1]; - if (blockSize == 16) - { - bufIV[2] = iv[2]; - bufIV[3] = iv[3]; - } - - for (i = 0; i < length / blockSize; i++) - { - // Dewhitening - data32[0] ^= whitening[0]; - data32[1] ^= whitening[1]; - if (blockSize == 16) - { - data32[2] ^= whitening[0]; - data32[3] ^= whitening[1]; - } - - // CBC - ct[0] = data32[0]; - ct[1] = data32[1]; - if (blockSize == 16) - { - ct[2] = data32[2]; - ct[3] = data32[3]; - } - - for (CipherList::const_reverse_iterator iCipherList = ciphers.rbegin(); - iCipherList != ciphers.rend(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - - if (c.GetBlockSize () != blockSize) - throw ParameterIncorrect (SRC_POS); - - c.DecryptBlock ((byte *) data32); - } - - // CBC - data32[0] ^= bufIV[0]; - data32[1] ^= bufIV[1]; - bufIV[0] = ct[0]; - bufIV[1] = ct[1]; - if (blockSize == 16) - { - data32[2] ^= bufIV[2]; - data32[3] ^= bufIV[3]; - bufIV[2] = ct[2]; - bufIV[3] = ct[3]; - } - - data32 += blockSize / sizeof(*data32); - } - - Memory::Erase (bufIV, sizeof (bufIV)); - Memory::Erase (ct, sizeof (ct)); - } - - void EncryptionModeCBC::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, sectorCount, sectorSize)); - - uint32 sectorIV[4]; - uint32 sectorWhitening[2]; - - while (sectorCount--) - { - if (IsOuterCBC (Ciphers)) - { - InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening); - DecryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening); - } - else - { - for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin(); - iCipherList != Ciphers.rend(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - CipherList cl; - cl.push_back (*iCipherList); - - InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening); - DecryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening); - } - } - - data += sectorSize; - sectorIndex++; - } - - Memory::Erase (sectorIV, sizeof (sectorIV)); - Memory::Erase (sectorWhitening, sizeof (sectorWhitening)); - } - - void EncryptionModeCBC::Encrypt (byte *data, uint64 length) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, length)); - - if (IsOuterCBC (Ciphers)) - { - EncryptBuffer (data, length, Ciphers, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset)); - } - else - { - for (CipherList::const_iterator iCipherList = Ciphers.begin(); - iCipherList != Ciphers.end(); - ++iCipherList) - { - CipherList cl; - cl.push_back (*iCipherList); - - EncryptBuffer (data, length, cl, (uint32 *) IV.Ptr(), (uint32 *) (IV.Ptr() + WhiteningIVOffset)); - } - } - } - - void EncryptionModeCBC::EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const - { - size_t blockSize = ciphers.front()->GetBlockSize(); - if (blockSize != 8 && blockSize != 16) - throw ParameterIncorrect (SRC_POS); - - uint32 *data32 = (uint32 *) data; - uint32 bufIV[4]; - uint64 i; - - bufIV[0] = iv[0]; - bufIV[1] = iv[1]; - if (blockSize == 16) - { - bufIV[2] = iv[2]; - bufIV[3] = iv[3]; - } - - for (i = 0; i < length / blockSize; i++) - { - data32[0] ^= bufIV[0]; - data32[1] ^= bufIV[1]; - if (blockSize == 16) - { - data32[2] ^= bufIV[2]; - data32[3] ^= bufIV[3]; - } - - for (CipherList::const_iterator iCipherList = ciphers.begin(); - iCipherList != ciphers.end(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - - if (c.GetBlockSize () != blockSize) - throw ParameterIncorrect (SRC_POS); - - c.EncryptBlock ((byte *) data32); - } - - bufIV[0] = data32[0]; - bufIV[1] = data32[1]; - if (blockSize == 16) - { - bufIV[2] = data32[2]; - bufIV[3] = data32[3]; - } - - data32[0] ^= whitening[0]; - data32[1] ^= whitening[1]; - if (blockSize == 16) - { - data32[2] ^= whitening[0]; - data32[3] ^= whitening[1]; - } - - data32 += blockSize / sizeof(*data32); - } - - Memory::Erase (bufIV, sizeof (bufIV)); - } - - void EncryptionModeCBC::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, sectorCount, sectorSize)); - - uint32 sectorIV[4]; - uint32 sectorWhitening[2]; - - while (sectorCount--) - { - if (IsOuterCBC (Ciphers)) - { - InitSectorIVAndWhitening (sectorIndex, Ciphers.front()->GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening); - EncryptBuffer (data, sectorSize, Ciphers, sectorIV, sectorWhitening); - } - else - { - for (CipherList::const_iterator iCipherList = Ciphers.begin(); - iCipherList != Ciphers.end(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - CipherList cl; - cl.push_back (*iCipherList); - - InitSectorIVAndWhitening (sectorIndex, c.GetBlockSize(), (uint64 *) IV.Ptr(), sectorIV, sectorWhitening); - EncryptBuffer (data, sectorSize, cl, sectorIV, sectorWhitening); - } - } - - data += sectorSize; - sectorIndex++; - } - - Memory::Erase (sectorIV, sizeof (sectorIV)); - Memory::Erase (sectorWhitening, sizeof (sectorWhitening)); - } - - void EncryptionModeCBC::InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const - { - if (blockSize != 8 && blockSize != 16) - throw ParameterIncorrect (SRC_POS); - - uint64 iv64[4]; - uint32 *iv32 = (uint32 *) iv64; - - iv64[0] = ivSeed[0] ^ Endian::Little (sectorIndex); - iv64[1] = ivSeed[1] ^ Endian::Little (sectorIndex); - iv64[2] = ivSeed[2] ^ Endian::Little (sectorIndex); - if (blockSize == 16) - { - iv64[3] = ivSeed[3] ^ Endian::Little (sectorIndex); - } - - iv[0] = iv32[0]; - iv[1] = iv32[1]; - - if (blockSize == 8) - { - whitening[0] = Endian::Little ( crc32int ( &iv32[2] ) ^ crc32int ( &iv32[5] ) ); - whitening[1] = Endian::Little ( crc32int ( &iv32[3] ) ^ crc32int ( &iv32[4] ) ); - } - else - { - iv[2] = iv32[2]; - iv[3] = iv32[3]; - - whitening[0] = Endian::Little ( crc32int ( &iv32[4] ) ^ crc32int ( &iv32[7] ) ); - whitening[1] = Endian::Little ( crc32int ( &iv32[5] ) ^ crc32int ( &iv32[6] ) ); - } - } - - bool EncryptionModeCBC::IsOuterCBC (const CipherList &ciphers) const - { - if (ciphers.size() < 2) - return false; - - size_t blockSize = ciphers.front()->GetBlockSize(); - - for (CipherList::const_iterator iCipherList = ciphers.begin(); - iCipherList != ciphers.end(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - if (c.GetBlockSize() != blockSize) - return false; - } - - return true; - } - - void EncryptionModeCBC::SetKey (const ConstBufferPtr &key) - { - if (key.Size() != GetKeySize ()) - throw ParameterIncorrect (SRC_POS); - - if (!KeySet) - IV.Allocate (GetKeySize ()); - - IV.CopyFrom (key); - KeySet = true; - } -} diff --git a/src/Volume/EncryptionModeCBC.h b/src/Volume/EncryptionModeCBC.h deleted file mode 100644 index 187432ea..00000000 --- a/src/Volume/EncryptionModeCBC.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. - - Governed by the TrueCrypt License 3.0 the full text of which is contained in - the file License.txt included in TrueCrypt binary and source code distribution - packages. -*/ - -#ifndef TC_HEADER_Encryption_EncryptionModeCBC -#define TC_HEADER_Encryption_EncryptionModeCBC - -#include "Platform/Platform.h" -#include "EncryptionMode.h" - -namespace VeraCrypt -{ - class EncryptionModeCBC : public EncryptionMode - { - public: - EncryptionModeCBC () { } - virtual ~EncryptionModeCBC () { } - - virtual void Decrypt (byte *data, uint64 length) const; - virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void Encrypt (byte *data, uint64 length) const; - virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual size_t GetKeySize () const { return 32; }; - virtual wstring GetName () const { return L"CBC"; }; - virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeCBC); } - virtual void SetKey (const ConstBufferPtr &key); - - protected: - void DecryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const; - void EncryptBuffer (byte *data, uint64 length, const CipherList &ciphers, const uint32 *iv, const uint32 *whitening) const; - void InitSectorIVAndWhitening (uint64 sectorIndex, size_t blockSize, const uint64 *ivSeed, uint32 *iv, uint32 *whitening) const; - bool IsOuterCBC (const CipherList &ciphers) const; - - SecureBuffer IV; - static const int WhiteningIVOffset = 8; - - private: - EncryptionModeCBC (const EncryptionModeCBC &); - EncryptionModeCBC &operator= (const EncryptionModeCBC &); - }; -} - -#endif // TC_HEADER_Encryption_EncryptionModeCBC diff --git a/src/Volume/EncryptionModeLRW.cpp b/src/Volume/EncryptionModeLRW.cpp deleted file mode 100644 index 115b0fc5..00000000 --- a/src/Volume/EncryptionModeLRW.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. - - Governed by the TrueCrypt License 3.0 the full text of which is contained in - the file License.txt included in TrueCrypt binary and source code distribution - packages. -*/ - -#include "EncryptionModeLRW.h" -#include "Common/GfMul.h" - -namespace VeraCrypt -{ - void EncryptionModeLRW::Decrypt (byte *data, uint64 length) const - { - if_debug (ValidateState ()); - DecryptBuffer (data, length, 1); - } - - void EncryptionModeLRW::DecryptBuffer (byte *data, uint64 length, uint64 blockIndex) const - { - size_t blockSize = Ciphers.front()->GetBlockSize(); - if (blockSize != 8 && blockSize != 16) - throw ParameterIncorrect (SRC_POS); - - byte i[8]; - *(uint64 *)i = Endian::Big (blockIndex); - - byte t[Cipher::MaxBlockSize]; - - for (unsigned int b = 0; b < length / blockSize; b++) - { - if (blockSize == 8) - { - Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr())); - Xor64 ((uint64 *)data, (uint64 *)t); - } - else - { - Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr())); - Xor128 ((uint64 *)data, (uint64 *)t); - } - - for (CipherList::const_reverse_iterator iCipherList = Ciphers.rbegin(); - iCipherList != Ciphers.rend(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - - if (c.GetBlockSize () != blockSize) - throw ParameterIncorrect (SRC_POS); - - c.DecryptBlock (data); - } - - if (blockSize == 8) - Xor64 ((uint64 *)data, (uint64 *)t); - else - Xor128 ((uint64 *)data, (uint64 *)t); - - data += blockSize; - IncrementBlockIndex (i); - } - - Memory::Erase (t, sizeof (t)); - } - - void EncryptionModeLRW::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, sectorCount, sectorSize)); - - DecryptBuffer (data, - sectorCount * sectorSize, - SectorToBlockIndex (sectorIndex)); - } - - void EncryptionModeLRW::Encrypt (byte *data, uint64 length) const - { - ValidateState (); - EncryptBuffer (data, length, 1); - } - - void EncryptionModeLRW::EncryptBuffer (byte *data, uint64 length, uint64 blockIndex) const - { - size_t blockSize = Ciphers.front()->GetBlockSize(); - if (blockSize != 8 && blockSize != 16) - throw ParameterIncorrect (SRC_POS); - - byte i[8]; - *(uint64 *)i = Endian::Big (blockIndex); - - byte t[Cipher::MaxBlockSize]; - - for (unsigned int b = 0; b < length / blockSize; b++) - { - if (blockSize == 8) - { - Gf64MulTab (i, t, (GfCtx *) (GfContext.Ptr())); - Xor64 ((uint64 *)data, (uint64 *)t); - } - else - { - Gf128MulBy64Tab (i, t, (GfCtx *) (GfContext.Ptr())); - Xor128 ((uint64 *)data, (uint64 *)t); - } - - for (CipherList::const_iterator iCipherList = Ciphers.begin(); - iCipherList != Ciphers.end(); - ++iCipherList) - { - const Cipher &c = **iCipherList; - - if (c.GetBlockSize () != blockSize) - throw ParameterIncorrect (SRC_POS); - - c.EncryptBlock (data); - } - - if (blockSize == 8) - Xor64 ((uint64 *)data, (uint64 *)t); - else - Xor128 ((uint64 *)data, (uint64 *)t); - - data += blockSize; - IncrementBlockIndex (i); - } - - Memory::Erase (t, sizeof (t)); - } - - void EncryptionModeLRW::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const - { - if_debug (ValidateState ()); - if_debug (ValidateParameters (data, sectorCount, sectorSize)); - - EncryptBuffer (data, - sectorCount * sectorSize, - SectorToBlockIndex (sectorIndex)); - } - - void EncryptionModeLRW::IncrementBlockIndex (byte *index) const - { - if (index[7] != 0xff) - index[7]++; - else - *(uint64 *)index = Endian::Big ( Endian::Big (*(uint64 *)index) + 1 ); - } - - uint64 EncryptionModeLRW::SectorToBlockIndex (uint64 sectorIndex) const - { - sectorIndex -= SectorOffset; - - switch (Ciphers.front()->GetBlockSize()) - { - case 8: - return (sectorIndex << 6) | 1; - - case 16: - return (sectorIndex << 5) | 1; - - default: - throw ParameterIncorrect (SRC_POS); - } - } - - void EncryptionModeLRW::SetKey (const ConstBufferPtr &key) - { - if (key.Size() != 16) - throw ParameterIncorrect (SRC_POS); - - if (!KeySet) - GfContext.Allocate (sizeof (GfCtx)); - - if (!Gf64TabInit ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr()))) - throw bad_alloc(); - - if (!Gf128Tab64Init ((unsigned char *) key.Get(), (GfCtx *) (GfContext.Ptr()))) - throw bad_alloc(); - - Key.CopyFrom (key); - KeySet = true; - } - - void EncryptionModeLRW::Xor64 (uint64 *a, const uint64 *b) const - { - *a ^= *b; - } - - void EncryptionModeLRW::Xor128 (uint64 *a, const uint64 *b) const - { - *a++ ^= *b++; - *a ^= *b; - } -} diff --git a/src/Volume/EncryptionModeLRW.h b/src/Volume/EncryptionModeLRW.h deleted file mode 100644 index 0cfcd50c..00000000 --- a/src/Volume/EncryptionModeLRW.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. - - Governed by the TrueCrypt License 3.0 the full text of which is contained in - the file License.txt included in TrueCrypt binary and source code distribution - packages. -*/ - -#ifndef TC_HEADER_Encryption_EncryptionModeLRW -#define TC_HEADER_Encryption_EncryptionModeLRW - -#include "Platform/Platform.h" -#include "EncryptionMode.h" - -namespace VeraCrypt -{ - class EncryptionModeLRW : public EncryptionMode - { - public: - EncryptionModeLRW () { } - virtual ~EncryptionModeLRW () { } - - virtual void Decrypt (byte *data, uint64 length) const; - virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void Encrypt (byte *data, uint64 length) const; - virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual const SecureBuffer &GetKey () const { return Key; } - virtual size_t GetKeySize () const { return 16; }; - virtual wstring GetName () const { return L"LRW"; }; - virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeLRW); } - virtual void SetKey (const ConstBufferPtr &key); - - protected: - void DecryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const; - void EncryptBuffer (byte *plainText, uint64 length, uint64 blockIndex) const; - void IncrementBlockIndex (byte *index) const; - uint64 SectorToBlockIndex (uint64 sectorIndex) const; - void Xor64 (uint64 *a, const uint64 *b) const; - void Xor128 (uint64 *a, const uint64 *b) const; - - SecureBuffer GfContext; - SecureBuffer Key; - - private: - EncryptionModeLRW (const EncryptionModeLRW &); - EncryptionModeLRW &operator= (const EncryptionModeLRW &); - }; -} - -#endif // TC_HEADER_Encryption_EncryptionModeLRW diff --git a/src/Volume/EncryptionTest.cpp b/src/Volume/EncryptionTest.cpp index 71f55f07..ffe998b0 100644 --- a/src/Volume/EncryptionTest.cpp +++ b/src/Volume/EncryptionTest.cpp @@ -1,134 +1,58 @@ /* Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "Cipher.h" #include "Common/Crc.h" #include "Crc32.h" #include "EncryptionAlgorithm.h" #include "EncryptionMode.h" -#include "EncryptionModeCBC.h" -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "EncryptionTest.h" #include "Pkcs5Kdf.h" namespace VeraCrypt { void EncryptionTest::TestAll () { TestAll (false); TestAll (true); } void EncryptionTest::TestAll (bool enableCpuEncryptionSupport) { bool hwSupportEnabled = Cipher::IsHwSupportEnabled(); finally_do_arg (bool, hwSupportEnabled, { Cipher::EnableHwSupport (finally_arg); }); Cipher::EnableHwSupport (enableCpuEncryptionSupport); TestCiphers(); TestXtsAES(); TestXts(); - TestLegacyModes(); TestPkcs5(); } - void EncryptionTest::TestLegacyModes () - { - byte buf[ENCRYPTION_DATA_UNIT_SIZE * 2]; - byte iv[32]; - unsigned int i; - uint32 crc; - uint64 secNo = 0x0234567890ABCDEFull; - - for (i = 0; i < sizeof (buf); i++) - buf[i] = (byte) i; - - for (i = 0; i < sizeof (iv); i++) - iv[i] = (byte) i; - - EncryptionModeList encModes = EncryptionMode::GetAvailableModes (); - - foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms()) - { - foreach (shared_ptr <EncryptionMode> mode, encModes) - { - if (typeid (*mode) == typeid (EncryptionModeXTS)) - continue; - - if (!mode->IsKeySet()) - { - mode->SetKey (ConstBufferPtr (iv, mode->GetKeySize())); - mode->SetSectorOffset (1); - } - - if (ea.IsModeSupported (mode)) - { - ea.SetMode (mode); - ea.SetKey (ConstBufferPtr (buf, ea.GetKeySize())); - - ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); - ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); - ea.EncryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); - - crc = ::GetCrc32 (buf, sizeof (buf)); - - if (typeid (*mode) == typeid (EncryptionModeLRW)) - { - if (typeid (ea) == typeid (AES) && crc != 0x5237acf9) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESTwofish) && crc != 0x4ed0fd80) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0xea04b3cf) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Blowfish) && crc != 0xf94d5300) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Cast5) && crc != 0x33971e82) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Serpent) && crc != 0x7fb86805) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (TripleDES) && crc != 0x2b20bb84) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Twofish) && crc != 0xa9de0f0b) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xca65c5cd) throw TestFailed (SRC_POS); - } - - if (typeid (*mode) == typeid (EncryptionModeCBC)) - { - if (typeid (ea) == typeid (AES) && crc != 0x2274f53d) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESBlowfish) && crc != 0xa7a80c84) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESBlowfishSerpent) && crc != 0xa0584562) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESTwofish) && crc != 0x3c226444) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (AESTwofishSerpent) && crc != 0x5e5e77fd) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Blowfish) && crc != 0x033899a1) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Cast5) && crc != 0x331cecc7) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (Serpent) && crc != 0x42dff3d4) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (TripleDES) && crc != 0xfe497d0c) throw TestFailed (SRC_POS); - if (typeid (ea) == typeid (TwofishSerpent) && crc != 0xa7b659f3) throw TestFailed (SRC_POS); - } - - ea.DecryptSectors (buf, secNo, sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); - } - } - } - } - struct CipherTestVector { byte Key[32]; byte Plaintext[16]; byte Ciphertext[16]; }; static const CipherTestVector AESTestVectors[] = { { { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 @@ -855,36 +779,31 @@ namespace VeraCrypt nTestsPerformed++; } if (nTestsPerformed != 80) throw TestFailed (SRC_POS); } void EncryptionTest::TestPkcs5 () { VolumePassword password ("password", 8); static const byte saltData[] = { 0x12, 0x34, 0x56, 0x78 }; ConstBufferPtr salt (saltData, sizeof (saltData)); Buffer derivedKey (4); Pkcs5HmacRipemd160 pkcs5HmacRipemd160; pkcs5HmacRipemd160.DeriveKey (derivedKey, password, salt, 5, FALSE); if (memcmp (derivedKey.Ptr(), "\x7a\x3d\x7c\x03", 4) != 0) throw TestFailed (SRC_POS); - Pkcs5HmacSha1 pkcs5HmacSha1; - pkcs5HmacSha1.DeriveKey (derivedKey, password, salt, 5, FALSE); - if (memcmp (derivedKey.Ptr(), "\x5c\x75\xce\xf0", 4) != 0) - throw TestFailed (SRC_POS); - Pkcs5HmacSha512 pkcs5HmacSha512; pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5, FALSE); if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0) throw TestFailed (SRC_POS); Pkcs5HmacWhirlpool pkcs5HmacWhirlpool; pkcs5HmacWhirlpool.DeriveKey (derivedKey, password, salt, 5, FALSE); if (memcmp (derivedKey.Ptr(), "\x50\x7c\x36\x6f", 4) != 0) throw TestFailed (SRC_POS); } } diff --git a/src/Volume/Hash.cpp b/src/Volume/Hash.cpp index ddae669a..b917a8e5 100644 --- a/src/Volume/Hash.cpp +++ b/src/Volume/Hash.cpp @@ -1,109 +1,82 @@ /* Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "Hash.h" #include "Crypto/Rmd160.h" -#include "Crypto/Sha1.h" #include "Crypto/Sha2.h" #include "Crypto/Whirlpool.h" namespace VeraCrypt { HashList Hash::GetAvailableAlgorithms () { HashList l; l.push_back (shared_ptr <Hash> (new Ripemd160 ())); l.push_back (shared_ptr <Hash> (new Sha512 ())); l.push_back (shared_ptr <Hash> (new Whirlpool ())); - l.push_back (shared_ptr <Hash> (new Sha1 ())); return l; } void Hash::ValidateDataParameters (const ConstBufferPtr &data) const { if (data.Size() < 1) throw ParameterIncorrect (SRC_POS); } void Hash::ValidateDigestParameters (const BufferPtr &buffer) const { if (buffer.Size() != GetDigestSize ()) throw ParameterIncorrect (SRC_POS); } // RIPEMD-160 Ripemd160::Ripemd160 () { Context.Allocate (sizeof (RMD160_CTX)); Init(); } void Ripemd160::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); RMD160Final (buffer, (RMD160_CTX *) Context.Ptr()); } void Ripemd160::Init () { RMD160Init ((RMD160_CTX *) Context.Ptr()); } void Ripemd160::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); RMD160Update ((RMD160_CTX *) Context.Ptr(), data.Get(), (int) data.Size()); } - - // SHA-1 - Sha1::Sha1 () - { - Deprecated = true; - Context.Allocate (sizeof (sha1_ctx)); - Init(); - } - - void Sha1::GetDigest (const BufferPtr &buffer) - { - if_debug (ValidateDigestParameters (buffer)); - sha1_end (buffer, (sha1_ctx *) Context.Ptr()); - } - - void Sha1::Init () - { - sha1_begin ((sha1_ctx *) Context.Ptr()); - } - - void Sha1::ProcessData (const ConstBufferPtr &data) - { - if_debug (ValidateDataParameters (data)); - sha1_hash (data.Get(), (int) data.Size(), (sha1_ctx *) Context.Ptr()); - } // SHA-512 Sha512::Sha512 () { Context.Allocate (sizeof (sha512_ctx)); Init(); } void Sha512::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); sha512_end (buffer, (sha512_ctx *) Context.Ptr()); } void Sha512::Init () { sha512_begin ((sha512_ctx *) Context.Ptr()); } void Sha512::ProcessData (const ConstBufferPtr &data) diff --git a/src/Volume/Hash.h b/src/Volume/Hash.h index befdd631..70872d54 100644 --- a/src/Volume/Hash.h +++ b/src/Volume/Hash.h @@ -48,62 +48,40 @@ namespace VeraCrypt { public: Ripemd160 (); virtual ~Ripemd160 () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 64; } virtual size_t GetDigestSize () const { return 160 / 8; } virtual wstring GetName () const { return L"RIPEMD-160"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Ripemd160); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Ripemd160 (const Ripemd160 &); Ripemd160 &operator= (const Ripemd160 &); }; - // SHA-1 - class Sha1 : public Hash - { - public: - Sha1 (); - virtual ~Sha1 () { } - - virtual void GetDigest (const BufferPtr &buffer); - virtual size_t GetBlockSize () const { return 64; } - virtual size_t GetDigestSize () const { return 160 / 8; } - virtual wstring GetName () const { return L"SHA-1"; } - virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha1); } - virtual void Init (); - virtual void ProcessData (const ConstBufferPtr &data); - - protected: - - private: - Sha1 (const Sha1 &); - Sha1 &operator= (const Sha1 &); - }; - // SHA-512 class Sha512 : public Hash { public: Sha512 (); virtual ~Sha512 () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 128; } virtual size_t GetDigestSize () const { return 512 / 8; } virtual wstring GetName () const { return L"SHA-512"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha512); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Sha512 (const Sha512 &); Sha512 &operator= (const Sha512 &); diff --git a/src/Volume/Pkcs5Kdf.cpp b/src/Volume/Pkcs5Kdf.cpp index f3724b3a..6521e71a 100644 --- a/src/Volume/Pkcs5Kdf.cpp +++ b/src/Volume/Pkcs5Kdf.cpp @@ -36,61 +36,54 @@ namespace VeraCrypt } shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const Hash &hash) { foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms()) { if (typeid (*kdf->GetHash()) == typeid (hash)) return kdf; } throw ParameterIncorrect (SRC_POS); } Pkcs5KdfList Pkcs5Kdf::GetAvailableAlgorithms () { Pkcs5KdfList l; l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacRipemd160 ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ())); - l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha1 ())); return l; } void Pkcs5Kdf::ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { if (key.Size() < 1 || password.Size() < 1 || salt.Size() < 1 || iterationCount < 1) throw ParameterIncorrect (SRC_POS); } void Pkcs5HmacRipemd160::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const { ValidateParameters (key, password, salt, iterationCount); derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacRipemd160_1000::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const { ValidateParameters (key, password, salt, iterationCount); derive_key_ripemd160 (bNotTest, (char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } - void Pkcs5HmacSha1::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const - { - ValidateParameters (key, password, salt, iterationCount); - derive_key_sha1 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); - } - void Pkcs5HmacSha512::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const { ValidateParameters (key, password, salt, iterationCount); derive_key_sha512 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacWhirlpool::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest) const { ValidateParameters (key, password, salt, iterationCount); derive_key_whirlpool ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } } diff --git a/src/Volume/Pkcs5Kdf.h b/src/Volume/Pkcs5Kdf.h index 35e7dc15..00e7a0a9 100644 --- a/src/Volume/Pkcs5Kdf.h +++ b/src/Volume/Pkcs5Kdf.h @@ -58,55 +58,40 @@ namespace VeraCrypt Pkcs5HmacRipemd160 (const Pkcs5HmacRipemd160 &); Pkcs5HmacRipemd160 &operator= (const Pkcs5HmacRipemd160 &); }; class Pkcs5HmacRipemd160_1000 : public Pkcs5Kdf { public: Pkcs5HmacRipemd160_1000 () { } virtual ~Pkcs5HmacRipemd160_1000 () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Ripemd160); } virtual int GetIterationCount () const { return 16384; } virtual wstring GetName () const { return L"HMAC-RIPEMD-160"; } private: Pkcs5HmacRipemd160_1000 (const Pkcs5HmacRipemd160_1000 &); Pkcs5HmacRipemd160_1000 &operator= (const Pkcs5HmacRipemd160_1000 &); }; - class Pkcs5HmacSha1 : public Pkcs5Kdf - { - public: - Pkcs5HmacSha1 () { } - virtual ~Pkcs5HmacSha1 () { } - - virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const; - virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha1); } - virtual int GetIterationCount () const { return 500000; } - virtual wstring GetName () const { return L"HMAC-SHA-1"; } - - private: - Pkcs5HmacSha1 (const Pkcs5HmacSha1 &); - Pkcs5HmacSha1 &operator= (const Pkcs5HmacSha1 &); - }; class Pkcs5HmacSha512 : public Pkcs5Kdf { public: Pkcs5HmacSha512 () { } virtual ~Pkcs5HmacSha512 () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount, BOOL bNotTest = TRUE) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha512); } virtual int GetIterationCount () const { return 500000; } virtual wstring GetName () const { return L"HMAC-SHA-512"; } private: Pkcs5HmacSha512 (const Pkcs5HmacSha512 &); Pkcs5HmacSha512 &operator= (const Pkcs5HmacSha512 &); }; class Pkcs5HmacWhirlpool : public Pkcs5Kdf { public: diff --git a/src/Volume/Volume.cpp b/src/Volume/Volume.cpp index aeec78e2..2c319ad9 100644 --- a/src/Volume/Volume.cpp +++ b/src/Volume/Volume.cpp @@ -1,32 +1,31 @@ /* Copyright (c) 2008-2010 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #ifndef TC_WINDOWS #include <errno.h> #endif -#include "EncryptionModeLRW.h" #include "EncryptionModeXTS.h" #include "Volume.h" #include "VolumeHeader.h" #include "VolumeLayout.h" #include "Common/Crypto.h" namespace VeraCrypt { Volume::Volume () : HiddenVolumeProtectionTriggered (false), SystemEncryption (false), VolumeDataSize (0), TopWriteOffset (0), TotalDataRead (0), TotalDataWritten (0) { } Volume::~Volume () { @@ -209,44 +208,40 @@ namespace VeraCrypt VolumeDataSize = layout->GetDataSize (VolumeHostSize); Header = header; Layout = layout; EA = header->GetEncryptionAlgorithm(); EncryptionMode &mode = *EA->GetMode(); if (layout->HasDriveHeader()) { if (header->GetEncryptedAreaLength() != header->GetVolumeDataSize()) throw VolumeEncryptionNotCompleted (SRC_POS); uint64 partitionStartOffset = VolumeFile->GetPartitionDeviceStartOffset(); if (partitionStartOffset < header->GetEncryptedAreaStart() || partitionStartOffset >= header->GetEncryptedAreaStart() + header->GetEncryptedAreaLength()) throw PasswordIncorrect (SRC_POS); mode.SetSectorOffset (partitionStartOffset / ENCRYPTION_DATA_UNIT_SIZE); } - else if (typeid (mode) == typeid (EncryptionModeLRW)) - { - mode.SetSectorOffset (VolumeDataOffset / SectorSize); - } // Volume protection if (Protection == VolumeProtection::HiddenVolumeReadOnly) { if (Type == VolumeType::Hidden) throw PasswordIncorrect (SRC_POS); else { try { Volume protectedVolume; protectedVolume.Open (VolumeFile, protectionPassword, protectionKeyfiles, VolumeProtection::ReadOnly, shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> (), VolumeType::Hidden, useBackupHeaders); if (protectedVolume.GetType() != VolumeType::Hidden) diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make index 29412a9f..528e8876 100644 --- a/src/Volume/Volume.make +++ b/src/Volume/Volume.make @@ -24,39 +24,35 @@ OBJS += VolumeHeader.o OBJS += VolumeInfo.o OBJS += VolumeLayout.o OBJS += VolumePassword.o OBJS += VolumePasswordCache.o ifeq "$(CPU_ARCH)" "x86" OBJS += ../Crypto/Aes_x86.o OBJS += ../Crypto/Aes_hw_cpu.o ifeq "$(PLATFORM)" "MacOSX" OBJS += ../Crypto/Aescrypt.o endif else ifeq "$(CPU_ARCH)" "x64" OBJS += ../Crypto/Aes_x64.o OBJS += ../Crypto/Aes_hw_cpu.o else OBJS += ../Crypto/Aescrypt.o endif OBJS += ../Crypto/Aeskey.o OBJS += ../Crypto/Aestab.o -OBJS += ../Crypto/Blowfish.o -OBJS += ../Crypto/Cast.o -OBJS += ../Crypto/Des.o OBJS += ../Crypto/Rmd160.o OBJS += ../Crypto/Serpent.o -OBJS += ../Crypto/Sha1.o OBJS += ../Crypto/Sha2.o OBJS += ../Crypto/Twofish.o OBJS += ../Crypto/Whirlpool.o OBJS += ../Common/Crc.o OBJS += ../Common/Endian.o OBJS += ../Common/GfMul.o OBJS += ../Common/Pkcs5.o OBJS += ../Common/SecurityToken.o VolumeLibrary: Volume.a include $(BUILD_INC)/Makefile.inc diff --git a/src/Volume/VolumeLayout.cpp b/src/Volume/VolumeLayout.cpp index aeade493..a3ecab02 100644 --- a/src/Volume/VolumeLayout.cpp +++ b/src/Volume/VolumeLayout.cpp @@ -1,31 +1,29 @@ /* Copyright (c) 2008 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. */ #include "Volume/EncryptionMode.h" -#include "Volume/EncryptionModeCBC.h" -#include "Volume/EncryptionModeLRW.h" #include "Volume/EncryptionModeXTS.h" #include "VolumeLayout.h" #include "Boot/Windows/BootCommon.h" namespace VeraCrypt { VolumeLayout::VolumeLayout () { } VolumeLayout::~VolumeLayout () { } VolumeLayoutList VolumeLayout::GetAvailableLayouts (VolumeType::Enum type) { VolumeLayoutList layouts; layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Normal ())); layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Normal ())); @@ -56,86 +54,70 @@ namespace VeraCrypt return Header; } VolumeLayoutV1Normal::VolumeLayoutV1Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const { return HeaderSize; } uint64 VolumeLayoutV1Normal::GetDataSize (uint64 volumeHostSize) const { return volumeHostSize - GetHeaderSize(); } VolumeLayoutV1Hidden::VolumeLayoutV1Hidden () { Type = VolumeType::Hidden; HeaderOffset = -TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY; HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfish ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESBlowfishSerpent ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Blowfish ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Cast5 ())); - SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TripleDES ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeLRW ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeCBC ())); } uint64 VolumeLayoutV1Hidden::GetDataOffset (uint64 volumeHostSize) const { return volumeHostSize - GetDataSize (volumeHostSize) + HeaderOffset; } uint64 VolumeLayoutV1Hidden::GetDataSize (uint64 volumeHostSize) const { return Header->GetHiddenVolumeDataSize (); } VolumeLayoutV2Normal::VolumeLayoutV2Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE; BackupHeaderOffset = -TC_VOLUME_HEADER_GROUP_SIZE; |