diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-12-18 15:26:35 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-12-26 00:00:04 +0100 |
commit | 1ef6177ae3605b4aa24beb6d9a0da214c15e100e (patch) | |
tree | 91276de7861c42faccce3efecb4e55aa5af8b9a0 /src | |
parent | a8fea1d64358793691418089552b6bb9ab32d189 (diff) | |
download | VeraCrypt-1ef6177ae3605b4aa24beb6d9a0da214c15e100e.tar.gz VeraCrypt-1ef6177ae3605b4aa24beb6d9a0da214c15e100e.zip |
Linux & MacOSX: automatically check TrueCryptMode in password dialog when selecting a container file that has the .tc file extension
Diffstat (limited to 'src')
-rw-r--r-- | src/Main/Forms/ChangePasswordDialog.cpp | 7 | ||||
-rw-r--r-- | src/Main/Forms/MountOptionsDialog.cpp | 6 | ||||
-rw-r--r-- | src/Main/Forms/VolumePasswordPanel.cpp | 10 | ||||
-rw-r--r-- | src/Main/Forms/VolumePasswordPanel.h | 1 | ||||
-rw-r--r-- | src/Volume/Volume.h | 27 |
5 files changed, 51 insertions, 0 deletions
diff --git a/src/Main/Forms/ChangePasswordDialog.cpp b/src/Main/Forms/ChangePasswordDialog.cpp index ac8e8147..5b2fdd04 100644 --- a/src/Main/Forms/ChangePasswordDialog.cpp +++ b/src/Main/Forms/ChangePasswordDialog.cpp @@ -24,6 +24,12 @@ namespace VeraCrypt bool enableNewPassword = false; bool enableNewKeyfiles = false; bool enablePkcs5Prf = false; + bool isTrueCryptFile = false; + + if (volumePath && volumePath->HasTrueCryptExtension ()) + { + isTrueCryptFile = true; + } switch (mode) { @@ -54,6 +60,7 @@ namespace VeraCrypt CurrentPasswordPanel = new VolumePasswordPanel (this, NULL, password, false, keyfiles, false, true, true, false, true, true); CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate)); + CurrentPasswordPanel->SetTrueCryptMode (isTrueCryptFile); CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND); NewPasswordPanel = new VolumePasswordPanel (this, NULL, newPassword, true, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf); diff --git a/src/Main/Forms/MountOptionsDialog.cpp b/src/Main/Forms/MountOptionsDialog.cpp index c6b47fd5..c7a853c2 100644 --- a/src/Main/Forms/MountOptionsDialog.cpp +++ b/src/Main/Forms/MountOptionsDialog.cpp @@ -36,6 +36,12 @@ namespace VeraCrypt PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true); PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword)); + + if (options.Path && options.Path->HasTrueCryptExtension() && !disableMountOptions + && !options.TrueCryptMode && (options.Pim <= 0)) + { + PasswordPanel->SetTrueCryptMode (true); + } PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND); diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp index 920d4f96..3ec6aedb 100644 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -306,6 +306,16 @@ namespace VeraCrypt { return TrueCryptModeCheckBox->GetValue (); } + + void VolumePasswordPanel::SetTrueCryptMode (bool trueCryptMode) + { + bool bEnablePIM = !trueCryptMode; + TrueCryptModeCheckBox->SetValue (trueCryptMode); + PimCheckBox->Enable (bEnablePIM); + VolumePimStaticText->Enable (bEnablePIM); + VolumePimTextCtrl->Enable (bEnablePIM); + VolumePimHelpStaticText->Enable (bEnablePIM); + } int VolumePasswordPanel::GetHeaderWipeCount () const { diff --git a/src/Main/Forms/VolumePasswordPanel.h b/src/Main/Forms/VolumePasswordPanel.h index e692d447..a3ed2a6f 100644 --- a/src/Main/Forms/VolumePasswordPanel.h +++ b/src/Main/Forms/VolumePasswordPanel.h @@ -32,6 +32,7 @@ namespace VeraCrypt shared_ptr <Pkcs5Kdf> GetPkcs5Kdf (bool bTrueCryptMode, bool &bUnsupportedKdf) const; int GetVolumePim () const; bool GetTrueCryptMode () const; + void SetTrueCryptMode (bool trueCryptMode); int GetHeaderWipeCount () const; void SetCacheCheckBoxValidator (const wxGenericValidator &validator) { CacheCheckBox->SetValidator (validator); } void SetFocusToPasswordTextCtrl () { PasswordTextCtrl->SetSelection (-1, -1); PasswordTextCtrl->SetFocus(); } diff --git a/src/Volume/Volume.h b/src/Volume/Volume.h index 30373ca1..620d0077 100644 --- a/src/Volume/Volume.h +++ b/src/Volume/Volume.h @@ -39,6 +39,33 @@ namespace VeraCrypt bool IsDevice () const { return FilesystemPath (Data).IsBlockDevice() || FilesystemPath (Data).IsCharacterDevice(); } bool IsEmpty () const { return Data.empty(); } + + wstring GetExtension () const + { + if (Data.empty() || (Data.size() == 1)) + return L""; + else + { + size_t pos = Data.find_last_of (L'.'); + if (pos == string::npos) + return L""; + return Data.substr (pos + 1); + } + } + + bool HasTrueCryptExtension () const + { + wstring sExt = GetExtension (); + if ((sExt.size () == 2) + && (sExt[0] == L't' || sExt[0] == L'T') + && (sExt[1] == L'c' || sExt[1] == L'C') + ) + { + return true; + } + else + return false; + } protected: wstring Data; |