VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Core
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/Core
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/Core')
-rw-r--r--src/Core/Core.h19
-rw-r--r--[-rwxr-xr-x]src/Core/CoreBase.cpp18
-rw-r--r--[-rwxr-xr-x]src/Core/CoreBase.h4
-rw-r--r--[-rwxr-xr-x]src/Core/MountOptions.cpp57
-rw-r--r--[-rwxr-xr-x]src/Core/MountOptions.h4
-rwxr-xr-xsrc/Core/Unix/CoreUnix.cpp1
6 files changed, 63 insertions, 40 deletions
diff --git a/src/Core/Core.h b/src/Core/Core.h
index 1a7a1611..4ff85139 100644
--- a/src/Core/Core.h
+++ b/src/Core/Core.h
@@ -70,14 +70,15 @@ namespace VeraCrypt
bool m_preserveTimestamps;
shared_ptr <VolumePassword> m_password;
shared_ptr <Pkcs5Kdf> m_kdf;
+ bool m_truecryptMode;
shared_ptr <KeyfileList> m_keyfiles;
shared_ptr <VolumePassword> m_newPassword;
shared_ptr <KeyfileList> m_newKeyfiles;
shared_ptr <Pkcs5Kdf> m_newPkcs5Kdf;
int m_wipeCount;
- ChangePasswordThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) : m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_kdf(kdf), m_keyfiles(keyfiles), m_newPassword(newPassword), m_newKeyfiles(newKeyfiles), m_newPkcs5Kdf(newPkcs5Kdf), m_wipeCount(wipeCount) {}
+ ChangePasswordThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) : m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_kdf(kdf), m_truecryptMode(truecryptMode), m_keyfiles(keyfiles), m_newPassword(newPassword), m_newKeyfiles(newKeyfiles), m_newPkcs5Kdf(newPkcs5Kdf), m_wipeCount(wipeCount) {}
virtual ~ChangePasswordThreadRoutine() { }
- virtual void ExecutionCode(void) { Core->ChangePassword(m_volumePath, m_preserveTimestamps, m_password, m_kdf, m_keyfiles, m_newPassword, m_newKeyfiles, m_newPkcs5Kdf, m_wipeCount); }
+ virtual void ExecutionCode(void) { Core->ChangePassword(m_volumePath, m_preserveTimestamps, m_password, m_kdf, m_truecryptMode, m_keyfiles, m_newPassword, m_newKeyfiles, m_newPkcs5Kdf, m_wipeCount); }
};
class OpenVolumeThreadRoutine : public WaitThreadRoutine
@@ -87,6 +88,7 @@ namespace VeraCrypt
bool m_preserveTimestamps;
shared_ptr <VolumePassword> m_password;
shared_ptr<Pkcs5Kdf> m_Kdf;
+ bool m_truecryptMode;
shared_ptr <KeyfileList> m_keyfiles;
VolumeProtection::Enum m_protection;
shared_ptr <VolumePassword> m_protectionPassword;
@@ -98,14 +100,14 @@ namespace VeraCrypt
bool m_partitionInSystemEncryptionScope;
shared_ptr <Volume> m_pVolume;
- OpenVolumeThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> Kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false):
- m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_Kdf(Kdf), m_keyfiles(keyfiles),
+ OpenVolumeThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> Kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false):
+ m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_Kdf(Kdf), m_truecryptMode(truecryptMode), m_keyfiles(keyfiles),
m_protection(protection), m_protectionPassword(protectionPassword), m_protectionKdf(protectionKdf), m_protectionKeyfiles(protectionKeyfiles), m_sharedAccessAllowed(sharedAccessAllowed), m_volumeType(volumeType),m_useBackupHeaders(useBackupHeaders),
m_partitionInSystemEncryptionScope(partitionInSystemEncryptionScope) {}
~OpenVolumeThreadRoutine() {}
- virtual void ExecutionCode(void) { m_pVolume = Core->OpenVolume(m_volumePath,m_preserveTimestamps,m_password,m_Kdf,m_keyfiles, m_protection,m_protectionPassword,m_protectionKdf, m_protectionKeyfiles,m_sharedAccessAllowed,m_volumeType,m_useBackupHeaders, m_partitionInSystemEncryptionScope); }
+ virtual void ExecutionCode(void) { m_pVolume = Core->OpenVolume(m_volumePath,m_preserveTimestamps,m_password,m_Kdf,m_truecryptMode,m_keyfiles, m_protection,m_protectionPassword,m_protectionKdf, m_protectionKeyfiles,m_sharedAccessAllowed,m_volumeType,m_useBackupHeaders, m_partitionInSystemEncryptionScope); }
};
@@ -129,14 +131,15 @@ namespace VeraCrypt
const ConstBufferPtr &m_encryptedData;
const VolumePassword &m_password;
shared_ptr <Pkcs5Kdf> m_kdf;
+ bool m_truecryptMode;
const Pkcs5KdfList &m_keyDerivationFunctions;
const EncryptionAlgorithmList &m_encryptionAlgorithms;
const EncryptionModeList &m_encryptionModes;
bool m_bResult;
- DecryptThreadRoutine(shared_ptr <VolumeHeader> header, const ConstBufferPtr &encryptedData, const VolumePassword &password, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
- : m_pHeader(header), m_encryptedData(encryptedData), m_password(password), m_kdf(kdf), m_keyDerivationFunctions(keyDerivationFunctions), m_encryptionAlgorithms(encryptionAlgorithms), m_encryptionModes(encryptionModes), m_bResult(false){}
+ DecryptThreadRoutine(shared_ptr <VolumeHeader> header, const ConstBufferPtr &encryptedData, const VolumePassword &password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes)
+ : m_pHeader(header), m_encryptedData(encryptedData), m_password(password), m_kdf(kdf), m_truecryptMode(truecryptMode), m_keyDerivationFunctions(keyDerivationFunctions), m_encryptionAlgorithms(encryptionAlgorithms), m_encryptionModes(encryptionModes), m_bResult(false){}
virtual ~DecryptThreadRoutine() { }
- virtual void ExecutionCode(void) { m_bResult = m_pHeader->Decrypt(m_encryptedData, m_password, m_kdf, m_keyDerivationFunctions, m_encryptionAlgorithms, m_encryptionModes); }
+ virtual void ExecutionCode(void) { m_bResult = m_pHeader->Decrypt(m_encryptedData, m_password, m_kdf, m_truecryptMode, m_keyDerivationFunctions, m_encryptionAlgorithms, m_encryptionModes); }
};
class WaitThreadUI
diff --git a/src/Core/CoreBase.cpp b/src/Core/CoreBase.cpp
index 0137e204..8dcee144 100755..100644
--- a/src/Core/CoreBase.cpp
+++ b/src/Core/CoreBase.cpp
@@ -29,7 +29,15 @@ namespace VeraCrypt
throw PasswordEmpty (SRC_POS);
if (!newPkcs5Kdf)
- newPkcs5Kdf = openVolume->GetPkcs5Kdf();
+ {
+ if (openVolume->GetPkcs5Kdf()->GetTrueCryptMode ())
+ {
+ newPkcs5Kdf.reset (openVolume->GetPkcs5Kdf()->Clone());
+ newPkcs5Kdf->SetTrueCryptMode (false);
+ }
+ else
+ newPkcs5Kdf = openVolume->GetPkcs5Kdf();
+ }
if ((openVolume->GetHeader()->GetFlags() & TC_HEADER_FLAG_ENCRYPTED_SYSTEM) != 0
&& openVolume->GetType() == VolumeType::Hidden
@@ -68,9 +76,9 @@ namespace VeraCrypt
}
}
- void CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const
+ void CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const
{
- shared_ptr <Volume> volume = OpenVolume (volumePath, preserveTimestamps, password, kdf, keyfiles);
+ shared_ptr <Volume> volume = OpenVolume (volumePath, preserveTimestamps, password, kdf, truecryptMode, keyfiles);
ChangePassword (volume, newPassword, newKeyfiles, newPkcs5Kdf, wipeCount);
}
@@ -242,10 +250,10 @@ namespace VeraCrypt
return GetMountedVolume (volumePath);
}
- shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <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) const
+ shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <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) const
{
make_shared_auto (Volume, volume);
- volume->Open (*volumePath, preserveTimestamps, password, kdf, keyfiles, protection, protectionPassword, protectionKdf, protectionKeyfiles, sharedAccessAllowed, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
+ volume->Open (*volumePath, preserveTimestamps, password, kdf, truecryptMode, keyfiles, protection, protectionPassword, protectionKdf, protectionKeyfiles, sharedAccessAllowed, volumeType, useBackupHeaders, partitionInSystemEncryptionScope);
return volume;
}
diff --git a/src/Core/CoreBase.h b/src/Core/CoreBase.h
index d7dbcd0e..9f704369 100755..100644
--- a/src/Core/CoreBase.h
+++ b/src/Core/CoreBase.h
@@ -30,7 +30,7 @@ namespace VeraCrypt
virtual ~CoreBase ();
virtual void ChangePassword (shared_ptr <Volume> openVolume, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const;
- virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const;
+ virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const;
virtual void CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair = false) const = 0;
virtual void CoalesceSlotNumberAndMountPoint (MountOptions &options) const;
virtual void CreateKeyfile (const FilePath &keyfilePath) const;
@@ -65,7 +65,7 @@ namespace VeraCrypt
virtual bool IsVolumeMounted (const VolumePath &volumePath) const;
virtual VolumeSlotNumber MountPointToSlotNumber (const DirectoryPath &mountPoint) const = 0;
virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) = 0;
- virtual shared_ptr <Volume> OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> Kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false) const;
+ virtual shared_ptr <Volume> OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> Kdf, bool truecryptMode, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false) const;
virtual void RandomizeEncryptionAlgorithmKey (shared_ptr <EncryptionAlgorithm> encryptionAlgorithm) const;
virtual void ReEncryptVolumeHeaderWithNewSalt (const BufferPtr &newHeaderBuffer, shared_ptr <VolumeHeader> header, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles) const;
virtual void SetAdminPasswordCallback (shared_ptr <GetStringFunctor> functor) { }
diff --git a/src/Core/MountOptions.cpp b/src/Core/MountOptions.cpp
index fb813bf0..844d72b4 100755..100644
--- a/src/Core/MountOptions.cpp
+++ b/src/Core/MountOptions.cpp
@@ -46,6 +46,7 @@ namespace VeraCrypt
TC_CLONE (SharedAccessAllowed);
TC_CLONE (SlotNumber);
TC_CLONE (UseBackupHeaders);
+ TC_CLONE (TrueCryptMode);
}
void MountOptions::Deserialize (shared_ptr <Stream> stream)
@@ -72,14 +73,6 @@ namespace VeraCrypt
Password = Serializable::DeserializeNew <VolumePassword> (stream);
else
Password.reset();
-
- if (!sr.DeserializeBool ("KdfNull"))
- {
- sr.Deserialize ("Kdf", nameValue);
- Kdf = Pkcs5Kdf::GetAlgorithm (nameValue);
- }
- else
- Kdf.reset();
if (!sr.DeserializeBool ("PathNull"))
Path.reset (new VolumePath (sr.DeserializeWString ("Path")));
@@ -96,19 +89,33 @@ namespace VeraCrypt
else
ProtectionPassword.reset();
- if (!sr.DeserializeBool ("ProtectionKdfNull"))
- {
- sr.Deserialize ("ProtectionKdf", nameValue);
- ProtectionKdf = Pkcs5Kdf::GetAlgorithm (nameValue);
- }
- else
- ProtectionKdf.reset();
-
ProtectionKeyfiles = Keyfile::DeserializeList (stream, "ProtectionKeyfiles");
sr.Deserialize ("Removable", Removable);
sr.Deserialize ("SharedAccessAllowed", SharedAccessAllowed);
sr.Deserialize ("SlotNumber", SlotNumber);
sr.Deserialize ("UseBackupHeaders", UseBackupHeaders);
+
+ sr.Deserialize ("TrueCryptMode", TrueCryptMode);
+
+ try
+ {
+ if (!sr.DeserializeBool ("KdfNull"))
+ {
+ sr.Deserialize ("Kdf", nameValue);
+ Kdf = Pkcs5Kdf::GetAlgorithm (nameValue, TrueCryptMode);
+ }
+ }
+ catch(...) {}
+
+ try
+ {
+ if (!sr.DeserializeBool ("ProtectionKdfNull"))
+ {
+ sr.Deserialize ("ProtectionKdf", nameValue);
+ ProtectionKdf = Pkcs5Kdf::GetAlgorithm (nameValue, TrueCryptMode);
+ }
+ }
+ catch(...) {}
}
void MountOptions::Serialize (shared_ptr <Stream> stream) const
@@ -133,10 +140,6 @@ namespace VeraCrypt
if (Password)
Password->Serialize (stream);
- sr.Serialize ("KdfNull", Kdf == nullptr);
- if (Kdf)
- sr.Serialize ("Kdf", Kdf->GetName());
-
sr.Serialize ("PathNull", Path == nullptr);
if (Path)
sr.Serialize ("Path", wstring (*Path));
@@ -149,15 +152,21 @@ namespace VeraCrypt
if (ProtectionPassword)
ProtectionPassword->Serialize (stream);
- sr.Serialize ("ProtectionKdfNull", ProtectionKdf == nullptr);
- if (ProtectionKdf)
- sr.Serialize ("ProtectionKdf", ProtectionKdf->GetName());
-
Keyfile::SerializeList (stream, "ProtectionKeyfiles", ProtectionKeyfiles);
sr.Serialize ("Removable", Removable);
sr.Serialize ("SharedAccessAllowed", SharedAccessAllowed);
sr.Serialize ("SlotNumber", SlotNumber);
sr.Serialize ("UseBackupHeaders", UseBackupHeaders);
+
+ sr.Serialize ("TrueCryptMode", TrueCryptMode);
+
+ sr.Serialize ("KdfNull", Kdf == nullptr);
+ if (Kdf)
+ sr.Serialize ("Kdf", Kdf->GetName());
+
+ sr.Serialize ("ProtectionKdfNull", ProtectionKdf == nullptr);
+ if (ProtectionKdf)
+ sr.Serialize ("ProtectionKdf", ProtectionKdf->GetName());
}
TC_SERIALIZER_FACTORY_ADD_CLASS (MountOptions);
diff --git a/src/Core/MountOptions.h b/src/Core/MountOptions.h
index 6cb2c549..8ccbffa0 100755..100644
--- a/src/Core/MountOptions.h
+++ b/src/Core/MountOptions.h
@@ -31,7 +31,8 @@ namespace VeraCrypt
Removable (false),
SharedAccessAllowed (false),
SlotNumber (0),
- UseBackupHeaders (false)
+ UseBackupHeaders (false),
+ TrueCryptMode (false)
{
}
@@ -63,6 +64,7 @@ namespace VeraCrypt
bool SharedAccessAllowed;
VolumeSlotNumber SlotNumber;
bool UseBackupHeaders;
+ bool TrueCryptMode;
protected:
void CopyFrom (const MountOptions &other);
diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp
index d33e4b73..0625ed6b 100755
--- a/src/Core/Unix/CoreUnix.cpp
+++ b/src/Core/Unix/CoreUnix.cpp
@@ -410,6 +410,7 @@ namespace VeraCrypt
options.PreserveTimestamps,
options.Password,
options.Kdf,
+ options.TrueCryptMode,
options.Keyfiles,
options.Protection,
options.ProtectionPassword,