mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-11 11:08:02 -06:00
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
This commit is contained in:
@@ -1436,7 +1436,7 @@ KeyfileGeneratorDialogBase::KeyfileGeneratorDialogBase( wxWindow* parent, wxWind
|
|||||||
bSizer162->Add( fgSizer8, 1, wxEXPAND, 5 );
|
bSizer162->Add( fgSizer8, 1, wxEXPAND, 5 );
|
||||||
|
|
||||||
|
|
||||||
bSizer144->Add( bSizer162, 1, wxALL|wxEXPAND, 5 );
|
bSizer144->Add( bSizer162, 0, wxALL|wxEXPAND, 5 );
|
||||||
|
|
||||||
wxBoxSizer* bSizer146;
|
wxBoxSizer* bSizer146;
|
||||||
bSizer146 = new wxBoxSizer( wxHORIZONTAL );
|
bSizer146 = new wxBoxSizer( wxHORIZONTAL );
|
||||||
@@ -2885,7 +2885,6 @@ VolumeCreationProgressWizardPageBase::VolumeCreationProgressWizardPageBase( wxWi
|
|||||||
bSizer126->Add( RandomPoolSampleStaticText, 0, wxEXPAND|wxTOP|wxRIGHT|wxALIGN_BOTTOM, 7 );
|
bSizer126->Add( RandomPoolSampleStaticText, 0, wxEXPAND|wxTOP|wxRIGHT|wxALIGN_BOTTOM, 7 );
|
||||||
|
|
||||||
DisplayKeysCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
|
DisplayKeysCheckBox = new wxCheckBox( this, wxID_ANY, _("Show"), wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
DisplayKeysCheckBox->SetValue(true);
|
|
||||||
bSizer126->Add( DisplayKeysCheckBox, 0, wxEXPAND|wxRIGHT, 5 );
|
bSizer126->Add( DisplayKeysCheckBox, 0, wxEXPAND|wxRIGHT, 5 );
|
||||||
|
|
||||||
|
|
||||||
@@ -2919,6 +2918,16 @@ VolumeCreationProgressWizardPageBase::VolumeCreationProgressWizardPageBase( wxWi
|
|||||||
|
|
||||||
bSizer105->Add( sbSizer31, 0, wxALL|wxEXPAND, 5 );
|
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;
|
wxStaticBoxSizer* sbSizer32;
|
||||||
sbSizer32 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, wxEmptyString ), wxVERTICAL );
|
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( 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 = new wxStaticText( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
|
||||||
InfoStaticText->Wrap( -1 );
|
InfoStaticText->Wrap( -1 );
|
||||||
bSizer105->Add( InfoStaticText, 0, wxALL, 5 );
|
bSizer105->Add( InfoStaticText, 0, wxBOTTOM|wxLEFT|wxRIGHT, 5 );
|
||||||
|
|
||||||
|
|
||||||
bSizer104->Add( bSizer105, 1, wxEXPAND, 5 );
|
bSizer104->Add( bSizer105, 1, wxEXPAND, 5 );
|
||||||
|
|||||||
@@ -871,6 +871,7 @@ namespace VeraCrypt
|
|||||||
wxCheckBox* DisplayKeysCheckBox;
|
wxCheckBox* DisplayKeysCheckBox;
|
||||||
wxStaticText* HeaderKeySampleStaticText;
|
wxStaticText* HeaderKeySampleStaticText;
|
||||||
wxStaticText* MasterKeySampleStaticText;
|
wxStaticText* MasterKeySampleStaticText;
|
||||||
|
wxGauge* CollectedEntropy;
|
||||||
wxGauge* ProgressGauge;
|
wxGauge* ProgressGauge;
|
||||||
wxButton* AbortButton;
|
wxButton* AbortButton;
|
||||||
wxStaticText* m_staticText31;
|
wxStaticText* m_staticText31;
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ namespace VeraCrypt
|
|||||||
HideBytes (RandomPoolStaticText, 24);
|
HideBytes (RandomPoolStaticText, 24);
|
||||||
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
|
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
|
||||||
|
|
||||||
|
CollectedEntropy->SetRange (RNG_POOL_SIZE * 8);
|
||||||
|
|
||||||
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
|
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
@@ -177,7 +179,8 @@ namespace VeraCrypt
|
|||||||
/* conservative estimate: 1 mouse move event brings 1 bit of entropy
|
/* 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
|
* 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);
|
CollectedEntropy->SetValue (++MouseEventsCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
HashList Hashes;
|
HashList Hashes;
|
||||||
int MouseEventsCounter;
|
int MouseEventsCounter;
|
||||||
|
Mutex AccessMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,6 +36,8 @@ namespace VeraCrypt
|
|||||||
HideBytes (RandomPoolStaticText, 24);
|
HideBytes (RandomPoolStaticText, 24);
|
||||||
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
|
MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70);
|
||||||
|
|
||||||
|
CollectedEntropy->SetRange (RNG_POOL_SIZE * 8);
|
||||||
|
|
||||||
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
|
MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24));
|
||||||
|
|
||||||
Layout();
|
Layout();
|
||||||
@@ -76,7 +78,8 @@ namespace VeraCrypt
|
|||||||
/* conservative estimate: 1 mouse move event brings 1 bit of entropy
|
/* 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
|
* 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);
|
CollectedEntropy->SetValue (++MouseEventsCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ namespace VeraCrypt
|
|||||||
|
|
||||||
HashList Hashes;
|
HashList Hashes;
|
||||||
int MouseEventsCounter;
|
int MouseEventsCounter;
|
||||||
|
Mutex AccessMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23462,6 +23462,107 @@
|
|||||||
</object>
|
</object>
|
||||||
</object>
|
</object>
|
||||||
</object>
|
</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">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
|
||||||
@@ -24467,17 +24568,7 @@
|
|||||||
</object>
|
</object>
|
||||||
<object class="sizeritem" expanded="1">
|
<object class="sizeritem" expanded="1">
|
||||||
<property name="border">5</property>
|
<property name="border">5</property>
|
||||||
<property name="flag">wxTOP|wxBOTTOM</property>
|
<property name="flag">wxBOTTOM|wxLEFT|wxRIGHT</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="proportion">0</property>
|
<property name="proportion">0</property>
|
||||||
<object class="wxStaticText" expanded="1">
|
<object class="wxStaticText" expanded="1">
|
||||||
<property name="BottomDockable">1</property>
|
<property name="BottomDockable">1</property>
|
||||||
|
|||||||
@@ -21,7 +21,8 @@ namespace VeraCrypt
|
|||||||
PreviousGaugeValue (0),
|
PreviousGaugeValue (0),
|
||||||
ProgressBarRange (1),
|
ProgressBarRange (1),
|
||||||
RealProgressBarRange (1),
|
RealProgressBarRange (1),
|
||||||
VolumeCreatorRunning (false)
|
VolumeCreatorRunning (false),
|
||||||
|
MouseEventsCounter (0)
|
||||||
{
|
{
|
||||||
DisplayKeysCheckBox->SetValue (displayKeyInfo);
|
DisplayKeysCheckBox->SetValue (displayKeyInfo);
|
||||||
#ifdef TC_WINDOWS
|
#ifdef TC_WINDOWS
|
||||||
@@ -35,6 +36,8 @@ namespace VeraCrypt
|
|||||||
ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2));
|
ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
CollectedEntropy->SetRange (RNG_POOL_SIZE * 8);
|
||||||
|
|
||||||
if (DisplayKeysCheckBox->IsChecked())
|
if (DisplayKeysCheckBox->IsChecked())
|
||||||
ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true);
|
ShowBytes (RandomPoolSampleStaticText, RandomNumberGenerator::PeekPool(), true);
|
||||||
else
|
else
|
||||||
@@ -184,4 +187,11 @@ namespace VeraCrypt
|
|||||||
RealProgressBarRange = ProgressGauge->GetSize().GetWidth();
|
RealProgressBarRange = ProgressGauge->GetSize().GetWidth();
|
||||||
ProgressGauge->SetRange (RealProgressBarRange);
|
ProgressGauge->SetRange (RealProgressBarRange);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VolumeCreationProgressWizardPage::IncrementEntropyProgress ()
|
||||||
|
{
|
||||||
|
ScopeLock lock (AccessMutex);
|
||||||
|
if (MouseEventsCounter < (RNG_POOL_SIZE * 8))
|
||||||
|
CollectedEntropy->SetValue (++MouseEventsCounter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ namespace VeraCrypt
|
|||||||
void SetProgressRange (uint64 progressBarRange);
|
void SetProgressRange (uint64 progressBarRange);
|
||||||
void SetProgressValue (uint64 value);
|
void SetProgressValue (uint64 value);
|
||||||
void SetProgressState (bool volumeCreatorRunning);
|
void SetProgressState (bool volumeCreatorRunning);
|
||||||
|
void IncrementEntropyProgress ();
|
||||||
|
|
||||||
Event AbortEvent;
|
Event AbortEvent;
|
||||||
|
|
||||||
@@ -51,6 +52,8 @@ namespace VeraCrypt
|
|||||||
int RealProgressBarRange;
|
int RealProgressBarRange;
|
||||||
wxLongLong StartTime;
|
wxLongLong StartTime;
|
||||||
bool VolumeCreatorRunning;
|
bool VolumeCreatorRunning;
|
||||||
|
int MouseEventsCounter;
|
||||||
|
Mutex AccessMutex;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace VeraCrypt
|
|||||||
VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent)
|
VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent)
|
||||||
: WizardFrame (parent),
|
: WizardFrame (parent),
|
||||||
CrossPlatformSupport (true),
|
CrossPlatformSupport (true),
|
||||||
DisplayKeyInfo (true),
|
DisplayKeyInfo (false),
|
||||||
LargeFilesSupport (false),
|
LargeFilesSupport (false),
|
||||||
QuickFormatEnabled (false),
|
QuickFormatEnabled (false),
|
||||||
SelectedFilesystemClusterSize (0),
|
SelectedFilesystemClusterSize (0),
|
||||||
@@ -378,6 +378,12 @@ namespace VeraCrypt
|
|||||||
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
|
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
|
||||||
coord = event.GetY();
|
coord = event.GetY();
|
||||||
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
|
RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord)));
|
||||||
|
|
||||||
|
VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage());
|
||||||
|
if (page)
|
||||||
|
{
|
||||||
|
page->IncrementEntropyProgress ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user