VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/VolumePasswordPanel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Main/Forms/VolumePasswordPanel.cpp')
-rw-r--r--src/Main/Forms/VolumePasswordPanel.cpp69
1 files changed, 14 insertions, 55 deletions
diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp
index 3525abf5..56804a49 100644
--- a/src/Main/Forms/VolumePasswordPanel.cpp
+++ b/src/Main/Forms/VolumePasswordPanel.cpp
@@ -18,7 +18,7 @@
namespace VeraCrypt
{
- VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, MountOptions* options, shared_ptr <VolumePassword> password, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel)
+ VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, MountOptions* options, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel)
: VolumePasswordPanelBase (parent), TopOwnerParent(NULL), Keyfiles (new KeyfileList), EnablePimEntry (true)
{
size_t maxPasswordLength = CmdLine->ArgUseLegacyPassword? VolumePassword::MaxLegacySize : VolumePassword::MaxSize;
@@ -78,22 +78,9 @@ namespace VeraCrypt
Pkcs5PrfStaticText->Show (enablePkcs5Prf);
Pkcs5PrfChoice->Show (enablePkcs5Prf);
- TrueCryptModeCheckBox->Show (!disableTruecryptMode);
HeaderWipeCountText->Show (enablePkcs5Prf && !isMountPassword);
HeaderWipeCount->Show (enablePkcs5Prf && !isMountPassword);
- if (options && !disableTruecryptMode)
- {
- TrueCryptModeCheckBox->SetValue (options->TrueCryptMode);
- if (options->TrueCryptMode)
- {
- PimCheckBox->Enable (false);
- VolumePimStaticText->Enable (false);
- VolumePimTextCtrl->Enable (false);
- VolumePimHelpStaticText->Enable (false);
- }
- }
-
if (EnablePimEntry && options && options->Pim > 0)
{
PimCheckBox->SetValue (true);
@@ -113,7 +100,7 @@ namespace VeraCrypt
Pkcs5PrfChoice->Delete (0);
Pkcs5PrfChoice->Append (LangString["AUTODETECTION"]);
}
- foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms(false))
+ foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms())
{
if (!kdf.IsDeprecated() || isMountPassword)
{
@@ -185,9 +172,7 @@ namespace VeraCrypt
void VolumePasswordPanel::SetPimValidator ()
{
- wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc.
- const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" };
- validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr));
+ wxTextValidator validator (wxFILTER_DIGITS);
VolumePimTextCtrl->SetValidator (validator);
}
@@ -204,7 +189,7 @@ namespace VeraCrypt
newTextCtrl->SetMinSize ((*textCtrl)->GetSize());
GridBagSizer->Detach ((*textCtrl));
- GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, colspan), wxEXPAND|wxBOTTOM|wxALIGN_CENTER_VERTICAL, 5);
+ GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, colspan), wxEXPAND|wxBOTTOM, 5);
(*textCtrl)->Show (false);
WipeTextCtrl (*textCtrl);
@@ -221,7 +206,7 @@ namespace VeraCrypt
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (bool bForceLegacyPassword) const
{
- return GetPassword (PasswordTextCtrl, bForceLegacyPassword || GetTrueCryptMode());
+ return GetPassword (PasswordTextCtrl, bForceLegacyPassword);
}
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (wxTextCtrl *textCtrl, bool bLegacyPassword) const
@@ -246,14 +231,8 @@ namespace VeraCrypt
return password;
}
- shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf (bool &bUnsupportedKdf) const
+ shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf () const
{
- return GetPkcs5Kdf (GetTrueCryptMode(), bUnsupportedKdf);
- }
-
- shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf (bool bTrueCryptMode, bool &bUnsupportedKdf) const
- {
- bUnsupportedKdf = false;
try
{
int index = Pkcs5PrfChoice->GetSelection ();
@@ -263,11 +242,10 @@ namespace VeraCrypt
return shared_ptr <Pkcs5Kdf> ();
}
else
- return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()), bTrueCryptMode);
+ return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection()));
}
catch (ParameterIncorrect&)
{
- bUnsupportedKdf = true;
return shared_ptr <Pkcs5Kdf> ();
}
}
@@ -303,21 +281,6 @@ namespace VeraCrypt
}
}
- bool VolumePasswordPanel::GetTrueCryptMode () const
- {
- return TrueCryptModeCheckBox->GetValue ();
- }
-
- void VolumePasswordPanel::SetTrueCryptMode (bool trueCryptMode)
- {
- bool bEnablePIM = !trueCryptMode;
- TrueCryptModeCheckBox->SetValue (trueCryptMode);
- PimCheckBox->Enable (bEnablePIM);
- VolumePimStaticText->Enable (bEnablePIM);
- VolumePimTextCtrl->Enable (bEnablePIM);
- VolumePimHelpStaticText->Enable (bEnablePIM);
- }
-
int VolumePasswordPanel::GetHeaderWipeCount () const
{
try
@@ -383,7 +346,7 @@ namespace VeraCrypt
SecurityTokenKeyfilesDialog dialog (this);
if (dialog.ShowModal() == wxID_OK)
{
- foreach (const SecurityTokenKeyfilePath &path, dialog.GetSelectedSecurityTokenKeyfilePaths())
+ foreach (const TokenKeyfilePath &path, dialog.GetSelectedSecurityTokenKeyfilePaths())
{
Keyfiles->push_back (make_shared <Keyfile> (wstring (path)));
}
@@ -459,7 +422,11 @@ namespace VeraCrypt
void VolumePasswordPanel::WipeTextCtrl (wxTextCtrl *textCtrl)
{
- textCtrl->SetValue (wxString (L'X', textCtrl->GetLineLength(0)));
+ int txtLen = textCtrl->GetLineLength(0);
+ if (txtLen > 0)
+ {
+ textCtrl->SetValue (wxString (L'X', txtLen));
+ }
GetPassword (textCtrl);
}
@@ -498,6 +465,7 @@ namespace VeraCrypt
VolumePimStaticText->Show (true);
VolumePimTextCtrl->Show (true);
VolumePimHelpStaticText->Show (true);
+ VolumePimTextCtrl->SetFocus();
if (DisplayPasswordCheckBox->IsChecked ())
DisplayPassword (true, &VolumePimTextCtrl, 3);
@@ -511,13 +479,4 @@ namespace VeraCrypt
layoutParent->Fit();
}
}
-
- void VolumePasswordPanel::OnTrueCryptModeChecked( wxCommandEvent& event )
- {
- bool bEnablePIM = !GetTrueCryptMode ();
- PimCheckBox->Enable (bEnablePIM);
- VolumePimStaticText->Enable (bEnablePIM);
- VolumePimTextCtrl->Enable (bEnablePIM);
- VolumePimHelpStaticText->Enable (bEnablePIM);
- }
}