diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-02-09 00:49:04 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-02-09 00:52:28 +0100 |
commit | 39fb2edc25f2703744932f25d956bf7af604fc5f (patch) | |
tree | a25f2ab7bd6ee5d55b5e89093b86f6b7f802fa7e | |
parent | 0863924483c09d05948f63d1b1740f107e3e80fe (diff) | |
download | VeraCrypt-39fb2edc25f2703744932f25d956bf7af604fc5f.tar.gz VeraCrypt-39fb2edc25f2703744932f25d956bf7af604fc5f.zip |
Linux/MacOSX: add progress bar for mouse collected entropy in GUI of volume creation wizard. Add mutex protection in event handler for shared counter variable
-rw-r--r-- | src/Main/Forms/Forms.cpp | 18 | ||||
-rw-r--r-- | src/Main/Forms/Forms.h | 1 | ||||
-rw-r--r-- | src/Main/Forms/KeyfileGeneratorDialog.cpp | 5 | ||||
-rw-r--r-- | src/Main/Forms/KeyfileGeneratorDialog.h | 1 | ||||
-rw-r--r-- | src/Main/Forms/RandomPoolEnrichmentDialog.cpp | 5 | ||||
-rw-r--r-- | src/Main/Forms/RandomPoolEnrichmentDialog.h | 1 | ||||
-rw-r--r-- | src/Main/Forms/TrueCrypt.fbp | 113 | ||||
-rw-r--r-- | src/Main/Forms/VolumeCreationProgressWizardPage.cpp | 12 | ||||
-rw-r--r-- | src/Main/Forms/VolumeCreationProgressWizardPage.h | 3 | ||||
-rwxr-xr-x | src/Main/Forms/VolumeCreationWizard.cpp | 8 |
10 files changed, 146 insertions, 21 deletions
diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp index da2a30ba..5fa70e5f 100644 --- a/src/Main/Forms/Forms.cpp +++ b/src/Main/Forms/Forms.cpp @@ -1436,7 +1436,7 @@ KeyfileGeneratorDialogBase::KeyfileGeneratorDialogBase( wxWindow* parent, wxWind bSizer162->Add( fgSizer8, 1, wxEXPAND, 5 );
- bSizer144->Add( bSizer162, 1, wxALL|wxEXPAND, 5 );
+ bSizer144->Add( bSizer162, 0, wxALL|wxEXPAND, 5 );
wxBoxSizer* bSizer146;
bSizer146 = new wxBoxSizer( wxHORIZONTAL );
@@ -2885,7 +2885,6 @@ VolumeCreationProgressWizardPageBase::VolumeCreationProgressWizardPageBase( wxWi bSizer126->Add( RandomPoolSampleStaticText, 0, wxEXPAND|wxTOP|wxRIGHT|wxALIGN_BOTTOM, 7 );
DisplayKeysCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
- DisplayKeysCheckBox->SetValue(true);
bSizer126->Add( DisplayKeysCheckBox, 0, wxEXPAND|wxRIGHT, 5 );
@@ -2919,6 +2918,16 @@ VolumeCreationProgressWizardPageBase::VolumeCreationProgressWizardPageBase( wxWi bSizer105->Add( sbSizer31, 0, wxALL|wxEXPAND, 5 );
+ wxStaticBoxSizer* sbSizer45;
+ sbSizer45 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Randomness Collected From Mouse Movements") ), wxVERTICAL );
+
+ CollectedEntropy = new wxGauge( this, wxID_ANY, 2560, wxDefaultPosition, wxDefaultSize, wxGA_HORIZONTAL|wxGA_SMOOTH );
+ CollectedEntropy->SetValue( 0 );
+ sbSizer45->Add( CollectedEntropy, 0, wxALL|wxEXPAND, 5 );
+
+
+ bSizer105->Add( sbSizer45, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 );
+
wxStaticBoxSizer* sbSizer32;
sbSizer32 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL );
@@ -3015,12 +3024,9 @@ VolumeCreationProgressWizardPageBase::VolumeCreationProgressWizardPageBase( wxWi bSizer105->Add( sbSizer32, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
-
- bSizer105->Add( 0, 0, 0, wxTOP|wxBOTTOM, 5 );
-
InfoStaticText = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
InfoStaticText->Wrap( -1 );
- bSizer105->Add( InfoStaticText, 0, wxALL, 5 );
+ bSizer105->Add( InfoStaticText, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
bSizer104->Add( bSizer105, 1, wxEXPAND, 5 );
diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h index fc3f62d3..5a3e8646 100644 --- a/src/Main/Forms/Forms.h +++ b/src/Main/Forms/Forms.h @@ -871,6 +871,7 @@ namespace VeraCrypt wxCheckBox* DisplayKeysCheckBox;
wxStaticText* HeaderKeySampleStaticText;
wxStaticText* MasterKeySampleStaticText;
+ wxGauge* CollectedEntropy;
wxGauge* ProgressGauge;
wxButton* AbortButton;
wxStaticText* m_staticText31;
diff --git a/src/Main/Forms/KeyfileGeneratorDialog.cpp b/src/Main/Forms/KeyfileGeneratorDialog.cpp index 157f74e5..61f16287 100644 --- a/src/Main/Forms/KeyfileGeneratorDialog.cpp +++ b/src/Main/Forms/KeyfileGeneratorDialog.cpp @@ -33,6 +33,8 @@ namespace VeraCrypt HideBytes (RandomPoolStaticText, 24); MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70); + + CollectedEntropy->SetRange (RNG_POOL_SIZE * 8); MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24)); @@ -177,7 +179,8 @@ namespace VeraCrypt /* conservative estimate: 1 mouse move event brings 1 bit of entropy * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848 */ - if (MouseEventsCounter < 2560) + ScopeLock lock (AccessMutex); + if (MouseEventsCounter < (RNG_POOL_SIZE * 8)) CollectedEntropy->SetValue (++MouseEventsCounter); } diff --git a/src/Main/Forms/KeyfileGeneratorDialog.h b/src/Main/Forms/KeyfileGeneratorDialog.h index 23c66f08..e4fd3633 100644 --- a/src/Main/Forms/KeyfileGeneratorDialog.h +++ b/src/Main/Forms/KeyfileGeneratorDialog.h @@ -35,6 +35,7 @@ namespace VeraCrypt HashList Hashes; int MouseEventsCounter; + Mutex AccessMutex; }; } diff --git a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp index f8b04d24..ecbfe7ac 100644 --- a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp +++ b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp @@ -35,6 +35,8 @@ namespace VeraCrypt HideBytes (RandomPoolStaticText, 24); MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70); + + CollectedEntropy->SetRange (RNG_POOL_SIZE * 8); MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24)); @@ -76,7 +78,8 @@ namespace VeraCrypt /* conservative estimate: 1 mouse move event brings 1 bit of entropy * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848 */ - if (MouseEventsCounter < 2560) + ScopeLock lock (AccessMutex); + if (MouseEventsCounter < (RNG_POOL_SIZE * 8)) CollectedEntropy->SetValue (++MouseEventsCounter); } diff --git a/src/Main/Forms/RandomPoolEnrichmentDialog.h b/src/Main/Forms/RandomPoolEnrichmentDialog.h index 6e113cbe..4135ff28 100644 --- a/src/Main/Forms/RandomPoolEnrichmentDialog.h +++ b/src/Main/Forms/RandomPoolEnrichmentDialog.h @@ -33,6 +33,7 @@ namespace VeraCrypt HashList Hashes; int MouseEventsCounter; + Mutex AccessMutex; }; } diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp index a993f39f..d9b1b1f1 100644 --- a/src/Main/Forms/TrueCrypt.fbp +++ b/src/Main/Forms/TrueCrypt.fbp @@ -23464,6 +23464,107 @@ </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
+ <property name="flag">wxEXPAND|wxLEFT|wxRIGHT</property>
+ <property name="proportion">0</property>
+ <object class="wxStaticBoxSizer" expanded="0">
+ <property name="id">wxID_ANY</property>
+ <property name="label">Randomness Collected From Mouse Movements</property>
+ <property name="minimum_size"></property>
+ <property name="name">sbSizer45</property>
+ <property name="orient">wxVERTICAL</property>
+ <property name="permission">none</property>
+ <event name="OnUpdateUI"></event>
+ <object class="sizeritem" expanded="1">
+ <property name="border">5</property>
+ <property name="flag">wxALL|wxEXPAND</property>
+ <property name="proportion">0</property>
+ <object class="wxGauge" expanded="1">
+ <property name="BottomDockable">1</property>
+ <property name="LeftDockable">1</property>
+ <property name="RightDockable">1</property>
+ <property name="TopDockable">1</property>
+ <property name="aui_layer"></property>
+ <property name="aui_name"></property>
+ <property name="aui_position"></property>
+ <property name="aui_row"></property>
+ <property name="best_size"></property>
+ <property name="bg"></property>
+ <property name="caption"></property>
+ <property name="caption_visible">1</property>
+ <property name="center_pane">0</property>
+ <property name="close_button">1</property>
+ <property name="context_help"></property>
+ <property name="context_menu">1</property>
+ <property name="default_pane">0</property>
+ <property name="dock">Dock</property>
+ <property name="dock_fixed">0</property>
+ <property name="docking">Left</property>
+ <property name="enabled">1</property>
+ <property name="fg"></property>
+ <property name="floatable">1</property>
+ <property name="font"></property>
+ <property name="gripper">0</property>
+ <property name="hidden">0</property>
+ <property name="id">wxID_ANY</property>
+ <property name="max_size"></property>
+ <property name="maximize_button">0</property>
+ <property name="maximum_size"></property>
+ <property name="min_size"></property>
+ <property name="minimize_button">0</property>
+ <property name="minimum_size"></property>
+ <property name="moveable">1</property>
+ <property name="name">CollectedEntropy</property>
+ <property name="pane_border">1</property>
+ <property name="pane_position"></property>
+ <property name="pane_size"></property>
+ <property name="permission">protected</property>
+ <property name="pin_button">1</property>
+ <property name="pos"></property>
+ <property name="range">2560</property>
+ <property name="resize">Resizable</property>
+ <property name="show">1</property>
+ <property name="size"></property>
+ <property name="style">wxGA_HORIZONTAL|wxGA_SMOOTH</property>
+ <property name="subclass"></property>
+ <property name="toolbar_pane">0</property>
+ <property name="tooltip"></property>
+ <property name="validator_data_type"></property>
+ <property name="validator_style">wxFILTER_NONE</property>
+ <property name="validator_type">wxDefaultValidator</property>
+ <property name="validator_variable"></property>
+ <property name="value">0</property>
+ <property name="window_extra_style"></property>
+ <property name="window_name"></property>
+ <property name="window_style"></property>
+ <event name="OnChar"></event>
+ <event name="OnEnterWindow"></event>
+ <event name="OnEraseBackground"></event>
+ <event name="OnKeyDown"></event>
+ <event name="OnKeyUp"></event>
+ <event name="OnKillFocus"></event>
+ <event name="OnLeaveWindow"></event>
+ <event name="OnLeftDClick"></event>
+ <event name="OnLeftDown"></event>
+ <event name="OnLeftUp"></event>
+ <event name="OnMiddleDClick"></event>
+ <event name="OnMiddleDown"></event>
+ <event name="OnMiddleUp"></event>
+ <event name="OnMotion"></event>
+ <event name="OnMouseEvents"></event>
+ <event name="OnMouseWheel"></event>
+ <event name="OnPaint"></event>
+ <event name="OnRightDClick"></event>
+ <event name="OnRightDown"></event>
+ <event name="OnRightUp"></event>
+ <event name="OnSetFocus"></event>
+ <event name="OnSize"></event>
+ <event name="OnUpdateUI"></event>
+ </object>
+ </object>
+ </object>
+ </object>
+ <object class="sizeritem" expanded="1">
+ <property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
@@ -24467,17 +24568,7 @@ </object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
- <property name="flag">wxTOP|wxBOTTOM</property>
- <property name="proportion">0</property>
- <object class="spacer" expanded="1">
- <property name="height">0</property>
- <property name="permission">protected</property>
- <property name="width">0</property>
- </object>
- </object>
- <object class="sizeritem" expanded="1">
- <property name="border">5</property>
- <property name="flag">wxALL</property>
+ <property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
diff --git a/src/Main/Forms/VolumeCreationProgressWizardPage.cpp b/src/Main/Forms/VolumeCreationProgressWizardPage.cpp index a1964958..08986f5e 100644 --- a/src/Main/Forms/VolumeCreationProgressWizardPage.cpp +++ b/src/Main/Forms/VolumeCreationProgressWizardPage.cpp @@ -21,7 +21,8 @@ namespace VeraCrypt PreviousGaugeValue (0), ProgressBarRange (1), RealProgressBarRange (1), - VolumeCreatorRunning (false) + VolumeCreatorRunning (false), + MouseEventsCounter (0) { DisplayKeysCheckBox->SetValue (displayKeyInfo); #ifdef TC_WINDOWS @@ -35,6 +36,8 @@ namespace VeraCrypt ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2)); #endif + CollectedEntropy->SetRange (RNG_POOL_SIZE * 8); + if (DisplayKeysCheckBox->IsChecked()) ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true); else @@ -184,4 +187,11 @@ namespace VeraCrypt RealProgressBarRange = ProgressGauge->GetSize().GetWidth(); ProgressGauge->SetRange (RealProgressBarRange); } + + void VolumeCreationProgressWizardPage::IncrementEntropyProgress () + { + ScopeLock lock (AccessMutex); + if (MouseEventsCounter < (RNG_POOL_SIZE * 8)) + CollectedEntropy->SetValue (++MouseEventsCounter); + } } diff --git a/src/Main/Forms/VolumeCreationProgressWizardPage.h b/src/Main/Forms/VolumeCreationProgressWizardPage.h index 63bd7fa8..417766e4 100644 --- a/src/Main/Forms/VolumeCreationProgressWizardPage.h +++ b/src/Main/Forms/VolumeCreationProgressWizardPage.h @@ -34,6 +34,7 @@ namespace VeraCrypt void SetProgressRange (uint64 progressBarRange); void SetProgressValue (uint64 value); void SetProgressState (bool volumeCreatorRunning); + void IncrementEntropyProgress (); Event AbortEvent; @@ -51,6 +52,8 @@ namespace VeraCrypt int RealProgressBarRange; wxLongLong StartTime; bool VolumeCreatorRunning; + int MouseEventsCounter; + Mutex AccessMutex; }; } diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp index 1e4c2513..e9ceb3a3 100755 --- a/src/Main/Forms/VolumeCreationWizard.cpp +++ b/src/Main/Forms/VolumeCreationWizard.cpp @@ -39,7 +39,7 @@ namespace VeraCrypt VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent) : WizardFrame (parent), CrossPlatformSupport (true), - DisplayKeyInfo (true), + DisplayKeyInfo (false), LargeFilesSupport (false), QuickFormatEnabled (false), SelectedFilesystemClusterSize (0), @@ -378,6 +378,12 @@ namespace VeraCrypt RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); coord = event.GetY(); RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + + VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); + if (page) + { + page->IncrementEntropyProgress (); + } } } |