VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Volume/Volume.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 17:01:49 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2014-12-30 17:06:20 +0100
commitc178e325b807258199ae45b2c50c265b4d7ce7af (patch)
tree905297a12e86b71d4611ff13d1df7e99c1e20b61 /src/Volume/Volume.cpp
parent8d787dcd7128fce554f473da62e20162b0b6c9c4 (diff)
downloadVeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.tar.gz
VeraCrypt-c178e325b807258199ae45b2c50c265b4d7ce7af.zip
Linux/MacOSX: Implement TrueCrypt conversion and loading support. Correct many GTK issues linked to multi-threaded origine of events by implementing an automatic mechanism for handling such requests in the main thread.
Diffstat (limited to 'src/Volume/Volume.cpp')
-rwxr-xr-xsrc/Volume/Volume.cpp30
1 files changed, 20 insertions, 10 deletions
diff --git a/src/Volume/Volume.cpp b/src/Volume/Volume.cpp
index 362b342c..f1f248ba 100755
--- a/src/Volume/Volume.cpp
+++ b/src/Volume/Volume.cpp
@@ -23,7 +23,8 @@ namespace VeraCrypt
VolumeDataSize (0),
TopWriteOffset (0),
TotalDataRead (0),
- TotalDataWritten (0)
+ TotalDataWritten (0),
+ TrueCryptMode (false)
{
}
@@ -62,7 +63,7 @@ namespace VeraCrypt
return EA->GetMode();
}
- void Volume::Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr <Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
+ void Volume::Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr <Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
{
make_shared_auto (File, file);
@@ -93,14 +94,21 @@ namespace VeraCrypt
throw;
}
- return Open (file, password, kdf, keyfiles, protection, protectionPassword, protectionKdf,protectionKeyfiles, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
+ return Open (file, password, kdf, truecryptMode, keyfiles, protection, protectionPassword, protectionKdf,protectionKeyfiles, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
}
- void Volume::Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr <Pkcs5Kdf> protectionKdf,shared_ptr <KeyfileList> protectionKeyfiles, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
+ void Volume::Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr <Pkcs5Kdf> protectionKdf,shared_ptr <KeyfileList> protectionKeyfiles, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope)
{
if (!volumeFile)
throw ParameterIncorrect (SRC_POS);
+ // TrueCrypt doesn't support SHA-256
+ if (kdf && truecryptMode && (kdf->GetName() == L"HMAC-SHA-256"))
+ throw UnsupportedAlgoInTrueCryptMode (SRC_POS);
+
+ if (truecryptMode && partitionInSystemEncryptionScope)
+ throw ParameterIncorrect (SRC_POS);
+
Protection = protection;
VolumeFile = volumeFile;
SystemEncryption = partitionInSystemEncryptionScope;
@@ -182,11 +190,11 @@ namespace VeraCrypt
shared_ptr <VolumeHeader> header = layout->GetHeader();
- if (header->Decrypt (headerBuffer, *passwordKey, kdf, layout->GetSupportedKeyDerivationFunctions(), layoutEncryptionAlgorithms, layoutEncryptionModes))
+ if (header->Decrypt (headerBuffer, *passwordKey, kdf, truecryptMode, layout->GetSupportedKeyDerivationFunctions(truecryptMode), layoutEncryptionAlgorithms, layoutEncryptionModes))
{
// Header decrypted
- if (typeid (*layout) == typeid (VolumeLayoutV2Normal) && header->GetRequiredMinProgramVersion() < 0x10b)
+ if (!truecryptMode && typeid (*layout) == typeid (VolumeLayoutV2Normal) && header->GetRequiredMinProgramVersion() < 0x10b)
{
// VolumeLayoutV1Normal has been opened as VolumeLayoutV2Normal
layout.reset (new VolumeLayoutV1Normal);
@@ -194,6 +202,7 @@ namespace VeraCrypt
layout->SetHeader (header);
}
+ TrueCryptMode = truecryptMode;
Type = layout->GetType();
SectorSize = header->GetSectorSize();
@@ -231,7 +240,7 @@ namespace VeraCrypt
Volume protectedVolume;
protectedVolume.Open (VolumeFile,
- protectionPassword, protectionKdf, protectionKeyfiles,
+ protectionPassword, protectionKdf, truecryptMode, protectionKeyfiles,
VolumeProtection::ReadOnly,
shared_ptr <VolumePassword> (), shared_ptr <Pkcs5Kdf> (),shared_ptr <KeyfileList> (),
VolumeType::Hidden,
@@ -269,11 +278,12 @@ namespace VeraCrypt
Buffer mbr (VolumeFile->GetDeviceSectorSize());
driveDevice.ReadAt (mbr, 0);
- // Search for the string "VeraCrypt"
- size_t nameLen = strlen (TC_APP_NAME);
+ // Search for the string "VeraCrypt" or "TrueCrypt"
+ const char* bootSignature = truecryptMode? "TrueCrypt" : TC_APP_NAME;
+ size_t nameLen = strlen (bootSignature);
for (size_t i = 0; i < mbr.Size() - nameLen; ++i)
{
- if (memcmp (mbr.Ptr() + i, TC_APP_NAME, nameLen) == 0)
+ if (memcmp (mbr.Ptr() + i, bootSignature, nameLen) == 0)
throw PasswordOrMountOptionsIncorrect (SRC_POS);
}
}