diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-02-08 01:37:02 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-02-08 01:39:50 +0100 |
commit | 0863924483c09d05948f63d1b1740f107e3e80fe (patch) | |
tree | 01edef8d504fa58bda333470e21777728c3da747 /src/Main/Forms/RandomPoolEnrichmentDialog.cpp | |
parent | 8e2793085e380172f412585d56b87c98a272ba82 (diff) | |
download | VeraCrypt-0863924483c09d05948f63d1b1740f107e3e80fe.tar.gz VeraCrypt-0863924483c09d05948f63d1b1740f107e3e80fe.zip |
Linux/MacOSX: add progress bar for mouse collected entropy in GUI for keyfile generator and for random poll enrichment
Diffstat (limited to 'src/Main/Forms/RandomPoolEnrichmentDialog.cpp')
-rw-r--r-- | src/Main/Forms/RandomPoolEnrichmentDialog.cpp | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp index fcfd0767..f8b04d24 100644 --- a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp +++ b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp @@ -33,7 +33,7 @@ namespace VeraCrypt } } - ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); + HideBytes (RandomPoolStaticText, 24); MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70); MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24)); @@ -41,6 +41,8 @@ namespace VeraCrypt Layout(); Fit(); Center(); + + MouseEventsCounter = 0; foreach (wxWindow *c, this->GetChildren()) c->Connect (wxEVT_MOTION, wxMouseEventHandler (RandomPoolEnrichmentDialog::OnMouseMotion), nullptr, this); @@ -68,12 +70,20 @@ namespace VeraCrypt if (ShowRandomPoolCheckBox->IsChecked()) ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); + else + HideBytes (RandomPoolStaticText, 24); + + /* 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) + CollectedEntropy->SetValue (++MouseEventsCounter); } void RandomPoolEnrichmentDialog::OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event) { if (!event.IsChecked()) - RandomPoolStaticText->SetLabel (L""); + HideBytes (RandomPoolStaticText, 24); } void RandomPoolEnrichmentDialog::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer) @@ -94,4 +104,16 @@ namespace VeraCrypt str[i] = L'X'; } } + + void RandomPoolEnrichmentDialog::HideBytes (wxStaticText *textCtrl, size_t len) + { + wxString str; + + for (size_t i = 0; i < len + 1; ++i) + { + str += L"**"; + } + + textCtrl->SetLabel (str.c_str()); + } } |