From 439e0a9588f83e93b609563bcef0a03b13928534 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Sun, 28 Jun 2015 20:19:19 +0200 Subject: Linux/MacOSX: Add dedicated PIM page in the volume creation wizard. Correct PIM value check logic. --- src/Main/Forms/Forms.cpp | 53 ++++ src/Main/Forms/Forms.h | 26 ++ src/Main/Forms/TrueCrypt.fbp | 432 ++++++++++++++++++++++++++++++++ src/Main/Forms/VolumeCreationWizard.cpp | 45 +++- src/Main/Forms/VolumeCreationWizard.h | 1 + src/Main/Forms/VolumePasswordPanel.cpp | 5 +- src/Main/Forms/VolumePasswordPanel.h | 0 src/Main/Forms/VolumePimWizardPage.cpp | 67 +++++ src/Main/Forms/VolumePimWizardPage.h | 40 +++ src/Main/Main.make | 1 + src/Main/TextUserInterface.cpp | 0 11 files changed, 660 insertions(+), 10 deletions(-) mode change 100755 => 100644 src/Main/Forms/Forms.cpp mode change 100755 => 100644 src/Main/Forms/Forms.h mode change 100755 => 100644 src/Main/Forms/TrueCrypt.fbp mode change 100755 => 100644 src/Main/Forms/VolumePasswordPanel.cpp mode change 100755 => 100644 src/Main/Forms/VolumePasswordPanel.h create mode 100644 src/Main/Forms/VolumePimWizardPage.cpp create mode 100644 src/Main/Forms/VolumePimWizardPage.h mode change 100755 => 100644 src/Main/TextUserInterface.cpp (limited to 'src') diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp old mode 100755 new mode 100644 index 20f2bfdd..76013e1a --- a/src/Main/Forms/Forms.cpp +++ b/src/Main/Forms/Forms.cpp @@ -3329,6 +3329,59 @@ VolumePasswordWizardPageBase::~VolumePasswordWizardPageBase() { } +VolumePimWizardPageBase::VolumePimWizardPageBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : WizardPage( parent, id, pos, size, style ) +{ + wxBoxSizer* bSizer101; + bSizer101 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer102; + bSizer102 = new wxBoxSizer( wxVERTICAL ); + + PimPanelSizer = new wxBoxSizer( wxVERTICAL ); + + PimSizer = new wxBoxSizer( wxHORIZONTAL ); + + VolumePimStaticText = new wxStaticText( this, wxID_ANY, _("Volume PIM:"), wxDefaultPosition, wxDefaultSize, 0 ); + VolumePimStaticText->Wrap( -1 ); + PimSizer->Add( VolumePimStaticText, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + VolumePimTextCtrl = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + VolumePimTextCtrl->SetMaxLength( 10 ); + PimSizer->Add( VolumePimTextCtrl, 0, wxALL, 5 ); + + VolumePinHelpStaticText = new wxStaticText( this, wxID_ANY, _("(Empty or 0 for default iterations)"), wxDefaultPosition, wxDefaultSize, 0 ); + VolumePinHelpStaticText->Wrap( -1 ); + PimSizer->Add( VolumePinHelpStaticText, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 ); + + + PimPanelSizer->Add( PimSizer, 1, wxEXPAND, 5 ); + + + bSizer102->Add( PimPanelSizer, 0, wxEXPAND, 5 ); + + InfoStaticText = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + InfoStaticText->Wrap( -1 ); + bSizer102->Add( InfoStaticText, 0, wxALL|wxEXPAND, 5 ); + + + bSizer101->Add( bSizer102, 1, wxEXPAND, 5 ); + + + this->SetSizer( bSizer101 ); + this->Layout(); + bSizer101->Fit( this ); + + // Connect Events + VolumePimTextCtrl->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( VolumePimWizardPageBase::OnPimChanged ), NULL, this ); +} + +VolumePimWizardPageBase::~VolumePimWizardPageBase() +{ + // Disconnect Events + VolumePimTextCtrl->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( VolumePimWizardPageBase::OnPimChanged ), NULL, this ); + +} + VolumeSizeWizardPageBase::VolumeSizeWizardPageBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style ) : WizardPage( parent, id, pos, size, style ) { wxBoxSizer* bSizer98; diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h old mode 100755 new mode 100644 index 358e937a..143e5c8d --- a/src/Main/Forms/Forms.h +++ b/src/Main/Forms/Forms.h @@ -1011,6 +1011,32 @@ namespace VeraCrypt }; + /////////////////////////////////////////////////////////////////////////////// + /// Class VolumePimWizardPageBase + /////////////////////////////////////////////////////////////////////////////// + class VolumePimWizardPageBase : public WizardPage + { + private: + + protected: + wxBoxSizer* PimPanelSizer; + wxBoxSizer* PimSizer; + wxStaticText* VolumePimStaticText; + wxTextCtrl* VolumePimTextCtrl; + wxStaticText* VolumePinHelpStaticText; + wxStaticText* InfoStaticText; + + // Virtual event handlers, overide them in your derived class + virtual void OnPimChanged( wxCommandEvent& event ) { event.Skip(); } + + + public: + + VolumePimWizardPageBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxTAB_TRAVERSAL ); + ~VolumePimWizardPageBase(); + + }; + /////////////////////////////////////////////////////////////////////////////// /// Class VolumeSizeWizardPageBase /////////////////////////////////////////////////////////////////////////////// diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp old mode 100755 new mode 100644 index 8a7705da..10472f11 --- a/src/Main/Forms/TrueCrypt.fbp +++ b/src/Main/Forms/TrueCrypt.fbp @@ -27104,6 +27104,438 @@ + + 0 + wxAUI_MGR_DEFAULT + + + 1 + 1 + impl_virtual + + + 0 + wxID_ANY + + + VolumePimWizardPageBase + + -1,-1 + WizardPage; WizardPage.h + + + + wxTAB_TRAVERSAL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer101 + wxVERTICAL + none + + 5 + wxEXPAND + 1 + + + bSizer102 + wxVERTICAL + none + + 5 + wxEXPAND + 0 + + + PimPanelSizer + wxVERTICAL + protected + + 5 + wxEXPAND + 1 + + + PimSizer + wxHORIZONTAL + protected + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Volume PIM: + + 0 + + + 0 + + 1 + VolumePimStaticText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + 10 + + 0 + + 1 + VolumePimTextCtrl + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NUMERIC + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + OnPimChanged + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + (Empty or 0 for default iterations) + + 0 + + + 0 + + 1 + VolumePinHelpStaticText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + InfoStaticText + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 0 wxAUI_MGR_DEFAULT diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp index e7f3fb46..8382127a 100644 --- a/src/Main/Forms/VolumeCreationWizard.cpp +++ b/src/Main/Forms/VolumeCreationWizard.cpp @@ -26,6 +26,7 @@ #include "VolumeFormatOptionsWizardPage.h" #include "VolumeLocationWizardPage.h" #include "VolumePasswordWizardPage.h" +#include "VolumePimWizardPage.h" #include "VolumeSizeWizardPage.h" #include "WaitDialog.h" @@ -196,6 +197,21 @@ namespace VeraCrypt page->SetPageText (LangString[OuterVolume ? "PASSWORD_HIDDENVOL_HOST_HELP" : "PASSWORD_HELP"]); return page; } + + case Step::VolumePim: + { + VolumePimWizardPage *page = new VolumePimWizardPage (GetPageParent()); + + if (OuterVolume) + page->SetPageTitle (LangString["PIM_HIDVOL_HOST_TITLE"]); + else if (SelectedVolumeType == VolumeType::Hidden) + page->SetPageTitle (LangString["PIM_HIDVOL_TITLE"]); + else + page->SetPageTitle (LangString["PIM_TITLE"]); + + page->SetPageText (LangString["PIM_HELP"]); + return page; + } case Step::LargeFilesSupport: { @@ -708,7 +724,6 @@ namespace VeraCrypt { VolumePasswordWizardPage *page = dynamic_cast (GetCurrentPage()); Password = page->GetPassword(); - Pim = page->GetVolumePim(); Kdf = page->GetPkcs5Kdf(); Keyfiles = page->GetKeyfiles(); @@ -726,18 +741,32 @@ namespace VeraCrypt if (Password->Size() < VolumePassword::WarningSizeThreshold) { - if (Pim < 485) - { - Gui->ShowError ("PIM_REQUIRE_LONG_PASSWORD"); - return GetCurrentStep(); - } - if (!Gui->AskYesNo (LangString["PASSWORD_LENGTH_WARNING"], false, true)) { return GetCurrentStep(); } } - else if (Pim < 485) + } + + return Step::VolumePim; + } + + case Step::VolumePim: + { + VolumePimWizardPage *page = dynamic_cast (GetCurrentPage()); + Pim = page->GetVolumePim(); + + if (forward && Password && !Password->IsEmpty()) + { + if (Password->Size() < VolumePassword::WarningSizeThreshold) + { + if (Pim > 0 && Pim < 485) + { + Gui->ShowError ("PIM_REQUIRE_LONG_PASSWORD"); + return GetCurrentStep(); + } + } + else if (Pim > 0 && Pim < 485) { if (!Gui->AskYesNo (LangString["PIM_SMALL_WARNING"], false, true)) { diff --git a/src/Main/Forms/VolumeCreationWizard.h b/src/Main/Forms/VolumeCreationWizard.h index 839a9993..105a2c59 100644 --- a/src/Main/Forms/VolumeCreationWizard.h +++ b/src/Main/Forms/VolumeCreationWizard.h @@ -31,6 +31,7 @@ namespace VeraCrypt EncryptionOptions, VolumeSize, VolumePassword, + VolumePim, LargeFilesSupport, FormatOptions, CrossPlatformSupport, diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp old mode 100755 new mode 100644 index 5385d6c8..8c0133eb --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -55,8 +55,9 @@ namespace VeraCrypt PasswordTextCtrl->Show (enablePassword); DisplayPasswordCheckBox->Show (enablePassword); - VolumePimTextCtrl->Show (enablePassword); - VolumePinHelpStaticText->Show (enablePassword); + VolumePimStaticText->Show (enablePassword && (!enableConfirmation || (enablePkcs5Prf && !isMountPassword))); + VolumePimTextCtrl->Show (enablePassword && (!enableConfirmation || (enablePkcs5Prf && !isMountPassword))); + VolumePinHelpStaticText->Show (enablePassword && (!enableConfirmation || (enablePkcs5Prf && !isMountPassword))); ConfirmPasswordStaticText->Show (enableConfirmation); ConfirmPasswordTextCtrl->Show (enableConfirmation); diff --git a/src/Main/Forms/VolumePasswordPanel.h b/src/Main/Forms/VolumePasswordPanel.h old mode 100755 new mode 100644 diff --git a/src/Main/Forms/VolumePimWizardPage.cpp b/src/Main/Forms/VolumePimWizardPage.cpp new file mode 100644 index 00000000..d7176bb2 --- /dev/null +++ b/src/Main/Forms/VolumePimWizardPage.cpp @@ -0,0 +1,67 @@ +/* + Copyright (c) 2015 Mounir IDRASSI for the VeraCrypt project. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "System.h" +#include "Main/GraphicUserInterface.h" +#include "VolumePimWizardPage.h" + +namespace VeraCrypt +{ + VolumePimWizardPage::VolumePimWizardPage (wxPanel* parent) + : VolumePimWizardPageBase (parent) + { + } + + VolumePimWizardPage::~VolumePimWizardPage () + { + } + + int VolumePimWizardPage::GetVolumePim () const + { + if (VolumePimTextCtrl->IsEnabled ()) + { + wxString pinStr (VolumePimTextCtrl->GetValue()); + long pin = 0; + if (pinStr.IsEmpty()) + return 0; + if (pinStr.ToLong (&pin)) + return (int) pin; + else + return -1; + } + else + return 0; + } + + bool VolumePimWizardPage::IsValid () + { + return true; + } + + void VolumePimWizardPage::OnPimChanged (wxCommandEvent& event) + { + if (GetVolumePim() != 0) + { + VolumePinHelpStaticText->SetForegroundColour(*wxRED); + VolumePinHelpStaticText->SetLabel(LangString["PIM_CHANGE_WARNING"]); + } + else + { + VolumePinHelpStaticText->SetForegroundColour(*wxBLACK); + VolumePinHelpStaticText->SetLabel(LangString["IDC_PIM_HELP"]); + } + } +} diff --git a/src/Main/Forms/VolumePimWizardPage.h b/src/Main/Forms/VolumePimWizardPage.h new file mode 100644 index 00000000..eff35e1e --- /dev/null +++ b/src/Main/Forms/VolumePimWizardPage.h @@ -0,0 +1,40 @@ +/* + Copyright (c) 2015 Mounir IDRASSI for the VeraCrypt project. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef VC_HEADER_Main_Forms_VolumePimWizardPage +#define VC_HEADER_Main_Forms_VolumePimWizardPage + +#include "Forms.h" + +namespace VeraCrypt +{ + class VolumePimWizardPage : public VolumePimWizardPageBase + { + public: + VolumePimWizardPage (wxPanel* parent); + ~VolumePimWizardPage (); + + int GetVolumePim () const; + bool IsValid (); + void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); } + void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); } + + protected: + void OnPimChanged (wxCommandEvent& event); + }; +} + +#endif // VC_HEADER_Main_Forms_VolumePimWizardPage diff --git a/src/Main/Main.make b/src/Main/Main.make index 7461f821..26d3bb31 100644 --- a/src/Main/Main.make +++ b/src/Main/Main.make @@ -51,6 +51,7 @@ OBJS += Forms/VolumeCreationWizard.o OBJS += Forms/VolumeFormatOptionsWizardPage.o OBJS += Forms/VolumeLocationWizardPage.o OBJS += Forms/VolumePasswordWizardPage.o +OBJS += Forms/VolumePimWizardPage.o OBJS += Forms/VolumeSizeWizardPage.o OBJS += Forms/WaitDialog.o OBJS += Forms/WizardFrame.o diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp old mode 100755 new mode 100644 -- cgit v1.2.3