From cb6dad6bd21d66cd28b3ef47e3540316ee9913c3 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 27 Jul 2014 03:29:45 +0200 Subject: Linux/MacOSX port of manual selection of number of passes for volume header over-write operation. --- src/Core/CoreBase.cpp | 10 +- src/Core/CoreBase.h | 5 +- src/Main/Forms/ChangePasswordDialog.cpp | 2 +- src/Main/Forms/Forms.cpp | 12 ++- src/Main/Forms/Forms.h | 2 + src/Main/Forms/TrueCrypt.fbp | 179 +++++++++++++++++++++++++++++++- src/Main/Forms/VolumePasswordPanel.cpp | 17 +++ src/Main/Forms/VolumePasswordPanel.h | 1 + 8 files changed, 217 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/Core/CoreBase.cpp b/src/Core/CoreBase.cpp index 038640ca..95e5c206 100644 --- a/src/Core/CoreBase.cpp +++ b/src/Core/CoreBase.cpp @@ -23,7 +23,7 @@ namespace VeraCrypt { } - void CoreBase::ChangePassword (shared_ptr openVolume, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf) const + void CoreBase::ChangePassword (shared_ptr openVolume, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf, int wipeCount) const { if ((!newPassword || newPassword->Size() < 1) && (!newKeyfiles || newKeyfiles->empty())) throw PasswordEmpty (SRC_POS); @@ -48,9 +48,9 @@ namespace VeraCrypt bool backupHeader = false; while (true) { - for (int i = 1; i <= SecureWipePassCount; i++) + for (int i = 1; i <= wipeCount; i++) { - if (i == SecureWipePassCount) + if (i == wipeCount) RandomNumberGenerator::GetData (newSalt); else RandomNumberGenerator::GetDataFast (newSalt); @@ -68,10 +68,10 @@ namespace VeraCrypt } } - void CoreBase::ChangePassword (shared_ptr volumePath, bool preserveTimestamps, shared_ptr password, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf) const + void CoreBase::ChangePassword (shared_ptr volumePath, bool preserveTimestamps, shared_ptr password, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf, int wipeCount) const { shared_ptr volume = OpenVolume (volumePath, preserveTimestamps, password, keyfiles); - ChangePassword (volume, newPassword, newKeyfiles, newPkcs5Kdf); + ChangePassword (volume, newPassword, newKeyfiles, newPkcs5Kdf, wipeCount); } void CoreBase::CoalesceSlotNumberAndMountPoint (MountOptions &options) const diff --git a/src/Core/CoreBase.h b/src/Core/CoreBase.h index 90a52dbe..6ebb76b7 100644 --- a/src/Core/CoreBase.h +++ b/src/Core/CoreBase.h @@ -28,8 +28,8 @@ namespace VeraCrypt public: virtual ~CoreBase (); - virtual void ChangePassword (shared_ptr openVolume, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf = shared_ptr ()) const; - virtual void ChangePassword (shared_ptr volumePath, bool preserveTimestamps, shared_ptr password, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf = shared_ptr ()) const; + virtual void ChangePassword (shared_ptr openVolume, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf = shared_ptr (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; + virtual void ChangePassword (shared_ptr volumePath, bool preserveTimestamps, shared_ptr password, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newPkcs5Kdf = shared_ptr (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; virtual void CheckFilesystem (shared_ptr mountedVolume, bool repair = false) const = 0; virtual void CoalesceSlotNumberAndMountPoint (MountOptions &options) const; virtual void CreateKeyfile (const FilePath &keyfilePath) const; @@ -80,7 +80,6 @@ namespace VeraCrypt protected: CoreBase (); - static const int SecureWipePassCount = PRAND_DISK_WIPE_PASSES; bool DeviceChangeInProgress; FilePath ApplicationExecutablePath; diff --git a/src/Main/Forms/ChangePasswordDialog.cpp b/src/Main/Forms/ChangePasswordDialog.cpp index 2a46f1ab..f52e169d 100644 --- a/src/Main/Forms/ChangePasswordDialog.cpp +++ b/src/Main/Forms/ChangePasswordDialog.cpp @@ -124,7 +124,7 @@ namespace VeraCrypt wxBusyCursor busy; Core->ChangePassword (Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps, CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetKeyfiles(), - newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf()); + newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount()); } switch (DialogMode) diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp index e804889b..76080605 100644 --- a/src/Main/Forms/Forms.cpp +++ b/src/Main/Forms/Forms.cpp @@ -3150,10 +3150,20 @@ VolumePasswordPanelBase::VolumePasswordPanelBase( wxWindow* parent, wxWindowID i Pkcs5PrfChoice->SetSelection( 0 ); GridBagSizer->Add( Pkcs5PrfChoice, wxGBPosition( 7, 1 ), wxGBSpan( 1, 2 ), wxALIGN_CENTER_VERTICAL|wxLEFT, 5 ); + HeaderWipeCountText = new wxStaticText( this, wxID_ANY, _("Header Wipe:"), wxDefaultPosition, wxDefaultSize, 0 ); + HeaderWipeCountText->Wrap( -1 ); + GridBagSizer->Add( HeaderWipeCountText, wxGBPosition( 8, 0 ), wxGBSpan( 1, 1 ), wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT, 5 ); + + wxString HeaderWipeCountChoices[] = { _("3-pass"), _("7-pass"), _("35-pass"), _("256-pass"), _("3") }; + int HeaderWipeCountNChoices = sizeof( HeaderWipeCountChoices ) / sizeof( wxString ); + HeaderWipeCount = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, HeaderWipeCountNChoices, HeaderWipeCountChoices, 0 ); + HeaderWipeCount->SetSelection( 0 ); + GridBagSizer->Add( HeaderWipeCount, wxGBPosition( 8, 1 ), wxGBSpan( 1, 1 ), wxALL, 5 ); + PasswordPlaceholderSizer = new wxBoxSizer( wxVERTICAL ); - GridBagSizer->Add( PasswordPlaceholderSizer, wxGBPosition( 8, 1 ), wxGBSpan( 1, 2 ), wxTOP|wxEXPAND, 5 ); + GridBagSizer->Add( PasswordPlaceholderSizer, wxGBPosition( 9, 1 ), wxGBSpan( 1, 2 ), wxTOP|wxEXPAND, 5 ); GridBagSizer->AddGrowableCol( 1 ); diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h index 2ced284c..f20a7628 100644 --- a/src/Main/Forms/Forms.h +++ b/src/Main/Forms/Forms.h @@ -950,6 +950,8 @@ namespace VeraCrypt wxBoxSizer* Pkcs5PrfSizer; wxStaticText* Pkcs5PrfStaticText; wxChoice* Pkcs5PrfChoice; + wxStaticText* HeaderWipeCountText; + wxChoice* HeaderWipeCount; wxBoxSizer* PasswordPlaceholderSizer; // Virtual event handlers, overide them in your derived class diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp index 53dd452f..bc11db47 100644 --- a/src/Main/Forms/TrueCrypt.fbp +++ b/src/Main/Forms/TrueCrypt.fbp @@ -25295,12 +25295,189 @@ + + 5 + 1 + 0 + wxALIGN_CENTER_VERTICAL|wxALIGN_RIGHT|wxRIGHT + 8 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Header Wipe: + + 0 + + + 0 + + 1 + HeaderWipeCountText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + 1 + 1 + wxALL + 8 + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "3-pass" "7-pass" "35-pass" "256-pass" "3" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + HeaderWipeCount + 1 + + + protected + 1 + + Resizable + 0 + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 2 1 wxTOP|wxEXPAND - 8 + 9 1 diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp index 54bef90f..10e56f7a 100644 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -189,6 +189,23 @@ namespace VeraCrypt return shared_ptr (); } } + + int VolumePasswordPanel::GetHeaderWipeCount () const + { + try + { + long wipeCount; + wxString wipeCountStrDesc = HeaderWipeCount->GetStringSelection(); + wxString wipeCountStr = wipeCountStrDesc.BeforeFirst(wxT("-")); + if (!wipeCountStr.ToLong(&wipeCount)) + wipeCount = PRAND_HEADER_WIPE_PASSES; + return (int) wipeCount; + } + catch (ParameterIncorrect&) + { + return PRAND_HEADER_WIPE_PASSES; + } + } void VolumePasswordPanel::OnAddKeyfileDirMenuItemSelected (wxCommandEvent& event) { diff --git a/src/Main/Forms/VolumePasswordPanel.h b/src/Main/Forms/VolumePasswordPanel.h index 3ab7f95a..f7f6e7cb 100644 --- a/src/Main/Forms/VolumePasswordPanel.h +++ b/src/Main/Forms/VolumePasswordPanel.h @@ -25,6 +25,7 @@ namespace VeraCrypt shared_ptr GetKeyfiles () const { return UseKeyfilesCheckBox->IsChecked() ? Keyfiles : shared_ptr (); } shared_ptr GetPassword () const; shared_ptr GetPkcs5Kdf () const; + int GetHeaderWipeCount () const; void SetCacheCheckBoxValidator (const wxGenericValidator &validator) { CacheCheckBox->SetValidator (validator); } void SetFocusToPasswordTextCtrl () { PasswordTextCtrl->SetSelection (-1, -1); PasswordTextCtrl->SetFocus(); } bool PasswordsMatch () const; -- cgit v1.2.3