1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Linux/MacOSX: use command line values of TrueCryptMode and PRF as defaults for the password dialog

This commit is contained in:
Mounir IDRASSI
2015-01-26 10:14:09 +01:00
parent 3d8d088b06
commit d01fa11983
6 changed files with 33 additions and 9 deletions

View File

@@ -48,11 +48,11 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
}
CurrentPasswordPanel = new VolumePasswordPanel (this, password, false, keyfiles, false, true, true, false, true, true);
CurrentPasswordPanel = new VolumePasswordPanel (this, NULL, password, false, keyfiles, false, true, true, false, true, true);
CurrentPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND);
NewPasswordPanel = new VolumePasswordPanel (this, newPassword, true, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
NewPasswordPanel = new VolumePasswordPanel (this, NULL, newPassword, true, newKeyfiles, false, enableNewPassword, enableNewKeyfiles, enableNewPassword, enablePkcs5Prf);
NewPasswordPanel->UpdateEvent.Connect (EventConnector <ChangePasswordDialog> (this, &ChangePasswordDialog::OnPasswordPanelUpdate));
NewPasswordPanelSizer->Add (NewPasswordPanel, 1, wxALL | wxEXPAND);

View File

@@ -664,6 +664,11 @@ namespace VeraCrypt
MountOptions mountOptions (GetPreferences().DefaultMountOptions);
mountOptions.SlotNumber = SelectedSlotNumber;
mountOptions.Path = GetSelectedVolumePath();
mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode;
if (CmdLine->ArgHash)
{
mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, CmdLine->ArgTrueCryptMode);
}
try
{
@@ -881,6 +886,11 @@ namespace VeraCrypt
SetVolumePath (favorite.Path);
MountOptions mountOptions (GetPreferences().DefaultMountOptions);
mountOptions.TrueCryptMode = CmdLine->ArgTrueCryptMode;
if (CmdLine->ArgHash)
{
mountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash, CmdLine->ArgTrueCryptMode);
}
favorite.ToMountOptions (mountOptions);
shared_ptr <VolumeInfo> volume = Gui->MountVolume (mountOptions);

View File

@@ -30,7 +30,7 @@ namespace VeraCrypt
if (disableMountOptions)
OptionsButton->Show (false);
PasswordPanel = new VolumePasswordPanel (this, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
PasswordPanel = new VolumePasswordPanel (this, &options, options.Password, disableMountOptions, options.Keyfiles, !disableMountOptions, true, true, false, true, true);
PasswordPanel->SetCacheCheckBoxValidator (wxGenericValidator (&Options.CachePassword));
PasswordSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);
@@ -61,7 +61,7 @@ namespace VeraCrypt
OptionsButton->SetLabel (OptionsButtonLabel + L" >");
OptionsPanel->Show (false);
ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, true, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:"));
ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, &options, options.ProtectionPassword, true, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:"));
ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND);
UpdateDialog();

View File

@@ -14,7 +14,7 @@
namespace VeraCrypt
{
VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, 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, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel)
: VolumePasswordPanelBase (parent), Keyfiles (new KeyfileList)
{
if (keyfiles)
@@ -67,8 +67,14 @@ namespace VeraCrypt
HeaderWipeCountText->Show (enablePkcs5Prf && !isMountPassword);
HeaderWipeCount->Show (enablePkcs5Prf && !isMountPassword);
if (options && !disableTruecryptMode)
{
TrueCryptModeCheckBox->SetValue (options->TrueCryptMode);
}
if (enablePkcs5Prf)
{
int index, prfInitialIndex = 0;
if (isMountPassword)
{
// case of password for mounting
@@ -78,9 +84,17 @@ namespace VeraCrypt
foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms(false))
{
if (!kdf.IsDeprecated() || isMountPassword)
Pkcs5PrfChoice->Append (kdf.GetName());
{
index = Pkcs5PrfChoice->Append (kdf.GetName());
if (isMountPassword && options && options->Kdf
&& (options->Kdf->GetName() == kdf.GetName())
)
{
prfInitialIndex = index;
}
}
}
Pkcs5PrfChoice->Select (0);
Pkcs5PrfChoice->Select (prfInitialIndex);
}
if (!enablePkcs5Prf || (!enablePassword && !enableKeyfiles))

View File

@@ -18,7 +18,7 @@ namespace VeraCrypt
class VolumePasswordPanel : public VolumePasswordPanelBase
{
public:
VolumePasswordPanel (wxWindow* parent, shared_ptr <VolumePassword> password, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, bool isMountPassword = false, const wxString &passwordLabel = wxString());
VolumePasswordPanel (wxWindow* parent, MountOptions* options, shared_ptr <VolumePassword> password, bool disableTruecryptMode, shared_ptr <KeyfileList> keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, bool isMountPassword = false, const wxString &passwordLabel = wxString());
virtual ~VolumePasswordPanel ();
void AddKeyfile (shared_ptr <Keyfile> keyfile);

View File

@@ -15,7 +15,7 @@ namespace VeraCrypt
VolumePasswordWizardPage::VolumePasswordWizardPage (wxPanel* parent, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, bool enableConfirmation)
: VolumePasswordWizardPageBase (parent), ConfirmationMode (enableConfirmation)
{
PasswordPanel = new VolumePasswordPanel (this, password, true, keyfiles, false, true, true, enableConfirmation, !enableConfirmation, !enableConfirmation);
PasswordPanel = new VolumePasswordPanel (this, NULL, password, true, keyfiles, false, true, true, enableConfirmation, !enableConfirmation, !enableConfirmation);
PasswordPanel->UpdateEvent.Connect (EventConnector <VolumePasswordWizardPage> (this, &VolumePasswordWizardPage::OnPasswordPanelUpdate));
PasswordPanelSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND);