From 07156b6c09165cf61a6bd499d26151d1f32bf3a9 Mon Sep 17 00:00:00 2001 From: Mounir IDRASSI Date: Fri, 19 Dec 2014 18:18:23 +0100 Subject: Linux/MacOSX: Enhance performance by implementing the possibility to choose the correct hash algorithm of volumes during various operations (mount, change password...), both using the GUI and the command line. --- src/Main/CommandLineInterface.cpp | 32 +++++++++++++++++++++++++++++ src/Main/CommandLineInterface.h | 1 + src/Main/Forms/ChangePasswordDialog.cpp | 4 ++-- src/Main/Forms/MountOptionsDialog.cpp | 6 ++++-- src/Main/Forms/VolumeCreationWizard.cpp | 3 ++- src/Main/Forms/VolumeCreationWizard.h | 1 + src/Main/Forms/VolumePasswordPanel.cpp | 14 +++++++++---- src/Main/Forms/VolumePasswordPanel.h | 2 +- src/Main/Forms/VolumePasswordWizardPage.cpp | 2 +- src/Main/Forms/VolumePasswordWizardPage.h | 1 + src/Main/GraphicUserInterface.cpp | 6 +++++- src/Main/GraphicUserInterface.h | 2 +- src/Main/TextUserInterface.cpp | 30 +++++++++++++++++++++++---- src/Main/TextUserInterface.h | 2 +- src/Main/UserInterface.cpp | 7 ++++++- src/Main/UserInterface.h | 2 +- 16 files changed, 95 insertions(+), 20 deletions(-) mode change 100644 => 100755 src/Main/Forms/ChangePasswordDialog.cpp mode change 100644 => 100755 src/Main/Forms/MountOptionsDialog.cpp mode change 100644 => 100755 src/Main/Forms/VolumePasswordPanel.cpp mode change 100644 => 100755 src/Main/Forms/VolumePasswordPanel.h mode change 100644 => 100755 src/Main/Forms/VolumePasswordWizardPage.cpp mode change 100644 => 100755 src/Main/GraphicUserInterface.cpp mode change 100644 => 100755 src/Main/GraphicUserInterface.h mode change 100644 => 100755 src/Main/TextUserInterface.cpp mode change 100644 => 100755 src/Main/TextUserInterface.h mode change 100644 => 100755 src/Main/UserInterface.cpp mode change 100644 => 100755 src/Main/UserInterface.h (limited to 'src/Main') diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index eed8cf22..68e644b5 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -36,6 +36,7 @@ namespace VeraCrypt parser.AddSwitch (L"C", L"change", _("Change password or keyfiles")); parser.AddSwitch (L"c", L"create", _("Create new volume")); parser.AddSwitch (L"", L"create-keyfile", _("Create new keyfile")); + parser.AddOption (L"", L"current-hash", _("Current hash algorithm for change password/keyfiles operation")); parser.AddSwitch (L"", L"delete-token-keyfiles", _("Delete security token keyfiles")); parser.AddSwitch (L"d", L"dismount", _("Dismount volume")); parser.AddSwitch (L"", L"display-password", _("Display password while typing")); @@ -61,6 +62,7 @@ namespace VeraCrypt parser.AddSwitch (L"", L"non-interactive", _("Do not interact with user")); parser.AddOption (L"p", L"password", _("Password")); parser.AddOption (L"", L"protect-hidden", _("Protect hidden volume")); + parser.AddOption (L"", L"protection-hash", _("Hash algorithm for protected hidden volume")); parser.AddOption (L"", L"protection-keyfiles", _("Keyfiles for protected hidden volume")); parser.AddOption (L"", L"protection-password", _("Password for protected hidden volume")); parser.AddOption (L"", L"random-source", _("Use file as source of random data")); @@ -306,6 +308,20 @@ namespace VeraCrypt throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); } + if (parser.Found (L"current-hash", &str)) + { + ArgCurrentHash.reset(); + + foreach (shared_ptr hash, Hash::GetAvailableAlgorithms()) + { + if (wxString (hash->GetName()).IsSameAs (str, false)) + ArgCurrentHash = hash; + } + + if (!ArgCurrentHash) + throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); + } + if (parser.Found (L"keyfiles", &str)) ArgKeyfiles = ToKeyfileList (str); @@ -377,6 +393,22 @@ namespace VeraCrypt ArgMountOptions.Protection = VolumeProtection::HiddenVolumeReadOnly; } + if (parser.Found (L"protection-hash", &str)) + { + bool bHashFound = false; + foreach (shared_ptr hash, Hash::GetAvailableAlgorithms()) + { + if (wxString (hash->GetName()).IsSameAs (str, false)) + { + bHashFound = true; + ArgMountOptions.ProtectionKdf = Pkcs5Kdf::GetAlgorithm (*hash); + } + } + + if (!bHashFound) + throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); + } + ArgQuick = parser.Found (L"quick"); if (parser.Found (L"random-source", &str)) diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h index c674597a..d3c2a0b3 100644 --- a/src/Main/CommandLineInterface.h +++ b/src/Main/CommandLineInterface.h @@ -61,6 +61,7 @@ namespace VeraCrypt VolumeCreationOptions::FilesystemType::Enum ArgFilesystem; bool ArgForce; shared_ptr ArgHash; + shared_ptr ArgCurrentHash; shared_ptr ArgKeyfiles; MountOptions ArgMountOptions; shared_ptr ArgMountPoint; diff --git a/src/Main/Forms/ChangePasswordDialog.cpp b/src/Main/Forms/ChangePasswordDialog.cpp old mode 100644 new mode 100755 index 83186c05..e07b7d3b --- a/src/Main/Forms/ChangePasswordDialog.cpp +++ b/src/Main/Forms/ChangePasswordDialog.cpp @@ -47,7 +47,7 @@ namespace VeraCrypt throw ParameterIncorrect (SRC_POS); } - CurrentPasswordPanel = new VolumePasswordPanel (this, password, keyfiles); + CurrentPasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, false, true, true); CurrentPasswordPanel->UpdateEvent.Connect (EventConnector (this, &ChangePasswordDialog::OnPasswordPanelUpdate)); CurrentPasswordPanelSizer->Add (CurrentPasswordPanel, 1, wxALL | wxEXPAND); @@ -125,7 +125,7 @@ namespace VeraCrypt #endif wxBusyCursor busy; Core->ChangePassword (Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps, - CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetKeyfiles(), + CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetKeyfiles(), newPassword, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount()); } diff --git a/src/Main/Forms/MountOptionsDialog.cpp b/src/Main/Forms/MountOptionsDialog.cpp old mode 100644 new mode 100755 index 69d821c2..1ddb7793 --- a/src/Main/Forms/MountOptionsDialog.cpp +++ b/src/Main/Forms/MountOptionsDialog.cpp @@ -30,7 +30,7 @@ namespace VeraCrypt if (disableMountOptions) OptionsButton->Show (false); - PasswordPanel = new VolumePasswordPanel (this, options.Password, options.Keyfiles, !disableMountOptions); + PasswordPanel = new VolumePasswordPanel (this, options.Password, 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, options.ProtectionKeyfiles, false, true, true, false, false, _("P&assword to hidden volume:")); + ProtectionPasswordPanel = new VolumePasswordPanel (OptionsPanel, options.ProtectionPassword, options.ProtectionKeyfiles, false, true, true, false, true, true, _("P&assword to hidden volume:")); ProtectionPasswordSizer->Add (ProtectionPasswordPanel, 1, wxALL | wxEXPAND); UpdateDialog(); @@ -85,6 +85,7 @@ namespace VeraCrypt TransferDataFromWindow(); Options.Password = PasswordPanel->GetPassword(); + Options.Kdf = PasswordPanel->GetPkcs5Kdf(); Options.Keyfiles = PasswordPanel->GetKeyfiles(); if (ReadOnlyCheckBox->IsChecked()) @@ -95,6 +96,7 @@ namespace VeraCrypt { Options.Protection = VolumeProtection::HiddenVolumeReadOnly; Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword(); + Options.ProtectionKdf = ProtectionPasswordPanel->GetPkcs5Kdf(); Options.ProtectionKeyfiles = ProtectionPasswordPanel->GetKeyfiles(); } else diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp index 597d014a..1dac1315 100644 --- a/src/Main/Forms/VolumeCreationWizard.cpp +++ b/src/Main/Forms/VolumeCreationWizard.cpp @@ -699,6 +699,7 @@ namespace VeraCrypt { VolumePasswordWizardPage *page = dynamic_cast (GetCurrentPage()); Password = page->GetPassword(); + Kdf = page->GetPkcs5Kdf(); Keyfiles = page->GetKeyfiles(); if (forward && Password && !Password->IsEmpty()) @@ -937,7 +938,7 @@ namespace VeraCrypt }); #endif - shared_ptr outerVolume = Core->OpenVolume (make_shared (SelectedVolumePath), true, Password, Keyfiles, VolumeProtection::ReadOnly); + shared_ptr outerVolume = Core->OpenVolume (make_shared (SelectedVolumePath), true, Password, Kdf, Keyfiles, VolumeProtection::ReadOnly); MaxHiddenVolumeSize = Core->GetMaxHiddenVolumeSize (outerVolume); // Add a reserve (in case the user mounts the outer volume and creates new files diff --git a/src/Main/Forms/VolumeCreationWizard.h b/src/Main/Forms/VolumeCreationWizard.h index abbf64cb..3a87c4cb 100644 --- a/src/Main/Forms/VolumeCreationWizard.h +++ b/src/Main/Forms/VolumeCreationWizard.h @@ -73,6 +73,7 @@ namespace VeraCrypt VolumeHostType::Enum SelectedVolumeHostType; VolumeType::Enum SelectedVolumeType; shared_ptr Password; + shared_ptr Kdf; uint32 SectorSize; shared_ptr SelectedHash; uint64 VolumeSize; diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp old mode 100644 new mode 100755 index 5b1b9db6..50f3eca2 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -14,7 +14,7 @@ namespace VeraCrypt { - VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, shared_ptr password, shared_ptr keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, const wxString &passwordLabel) + VolumePasswordPanel::VolumePasswordPanel (wxWindow* parent, shared_ptr password, shared_ptr keyfiles, bool enableCache, bool enablePassword, bool enableKeyfiles, bool enableConfirmation, bool enablePkcs5Prf, bool isMountPassword, const wxString &passwordLabel) : VolumePasswordPanelBase (parent), Keyfiles (new KeyfileList) { if (keyfiles) @@ -63,14 +63,20 @@ namespace VeraCrypt Pkcs5PrfStaticText->Show (enablePkcs5Prf); Pkcs5PrfChoice->Show (enablePkcs5Prf); - HeaderWipeCountText->Show (enablePkcs5Prf); - HeaderWipeCount->Show (enablePkcs5Prf); + HeaderWipeCountText->Show (enablePkcs5Prf && !isMountPassword); + HeaderWipeCount->Show (enablePkcs5Prf && !isMountPassword); if (enablePkcs5Prf) { + if (isMountPassword) + { + // case of password for mounting + Pkcs5PrfChoice->Delete (0); + Pkcs5PrfChoice->Append (LangString["AUTODETECTION"]); + } foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms()) { - if (!kdf.IsDeprecated()) + if (!kdf.IsDeprecated() || isMountPassword) Pkcs5PrfChoice->Append (kdf.GetName()); } Pkcs5PrfChoice->Select (0); diff --git a/src/Main/Forms/VolumePasswordPanel.h b/src/Main/Forms/VolumePasswordPanel.h old mode 100644 new mode 100755 index f7f6e7cb..465a430a --- a/src/Main/Forms/VolumePasswordPanel.h +++ b/src/Main/Forms/VolumePasswordPanel.h @@ -18,7 +18,7 @@ namespace VeraCrypt class VolumePasswordPanel : public VolumePasswordPanelBase { public: - VolumePasswordPanel (wxWindow* parent, shared_ptr password, shared_ptr keyfiles, bool enableCache = false, bool enablePassword = true, bool enableKeyfiles = true, bool enableConfirmation = false, bool enablePkcs5Prf = false, const wxString &passwordLabel = wxString()); + VolumePasswordPanel (wxWindow* parent, shared_ptr password, shared_ptr 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); diff --git a/src/Main/Forms/VolumePasswordWizardPage.cpp b/src/Main/Forms/VolumePasswordWizardPage.cpp old mode 100644 new mode 100755 index 1034c220..61ff999f --- a/src/Main/Forms/VolumePasswordWizardPage.cpp +++ b/src/Main/Forms/VolumePasswordWizardPage.cpp @@ -15,7 +15,7 @@ namespace VeraCrypt VolumePasswordWizardPage::VolumePasswordWizardPage (wxPanel* parent, shared_ptr password, shared_ptr keyfiles, bool enableConfirmation) : VolumePasswordWizardPageBase (parent), ConfirmationMode (enableConfirmation) { - PasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, enableConfirmation); + PasswordPanel = new VolumePasswordPanel (this, password, keyfiles, false, true, true, enableConfirmation, !enableConfirmation, !enableConfirmation); PasswordPanel->UpdateEvent.Connect (EventConnector (this, &VolumePasswordWizardPage::OnPasswordPanelUpdate)); PasswordPanelSizer->Add (PasswordPanel, 1, wxALL | wxEXPAND); diff --git a/src/Main/Forms/VolumePasswordWizardPage.h b/src/Main/Forms/VolumePasswordWizardPage.h index 8aaf30d6..13a98c62 100644 --- a/src/Main/Forms/VolumePasswordWizardPage.h +++ b/src/Main/Forms/VolumePasswordWizardPage.h @@ -22,6 +22,7 @@ namespace VeraCrypt shared_ptr GetKeyfiles () const { return PasswordPanel->GetKeyfiles(); } shared_ptr GetPassword () const { return PasswordPanel->GetPassword(); } + shared_ptr GetPkcs5Kdf () const { return PasswordPanel->GetPkcs5Kdf(); } bool IsValid (); void SetMaxStaticTextWidth (int width) { InfoStaticText->Wrap (width); } void SetPageText (const wxString &text) { InfoStaticText->SetLabel (text); } diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp old mode 100644 new mode 100755 index 440125ef..889d49c5 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -177,9 +177,11 @@ namespace VeraCrypt options->Path, options->PreserveTimestamps, options->Password, + options->Kdf, options->Keyfiles, options->Protection, options->ProtectionPassword, + options->ProtectionKdf, options->ProtectionKeyfiles, true, volumeType, @@ -1261,9 +1263,11 @@ namespace VeraCrypt options.Path, options.PreserveTimestamps, options.Password, + options.Kdf, options.Keyfiles, options.Protection, options.ProtectionPassword, + options.ProtectionKdf, options.ProtectionKeyfiles, options.SharedAccessAllowed, VolumeType::Unknown, @@ -1373,7 +1377,7 @@ namespace VeraCrypt // Decrypt header shared_ptr passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password); - if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes())) + if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, options.Kdf, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes())) { decryptedLayout = layout; break; diff --git a/src/Main/GraphicUserInterface.h b/src/Main/GraphicUserInterface.h old mode 100644 new mode 100755 index 6fa51c4d..890ab5d6 --- a/src/Main/GraphicUserInterface.h +++ b/src/Main/GraphicUserInterface.h @@ -29,7 +29,7 @@ namespace VeraCrypt virtual void BackupVolumeHeaders (shared_ptr volumePath) const; virtual void BeginBusyState () const { wxBeginBusyCursor(); } virtual void BeginInteractiveBusyState (wxWindow *window); - virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const { ThrowTextModeRequired(); } + virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr currentHash = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const { ThrowTextModeRequired(); } wxHyperlinkCtrl *CreateHyperlink (wxWindow *parent, const wxString &linkUrl, const wxString &linkText) const; virtual void CreateKeyfile (shared_ptr keyfilePath = shared_ptr ()) const; virtual void CreateVolume (shared_ptr options) const { ThrowTextModeRequired(); } diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp old mode 100644 new mode 100755 index f9693cb1..9cc5232d --- a/src/Main/TextUserInterface.cpp +++ b/src/Main/TextUserInterface.cpp @@ -244,6 +244,12 @@ namespace VeraCrypt #endif ShowInfo ("EXTERNAL_VOL_HEADER_BAK_FIRST_INFO"); + + shared_ptr kdf; + if (CmdLine->ArgHash) + { + kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); + } shared_ptr normalVolume; shared_ptr hiddenVolume; @@ -274,9 +280,11 @@ namespace VeraCrypt options->Path, options->PreserveTimestamps, options->Password, + kdf, options->Keyfiles, options->Protection, options->ProtectionPassword, + options->ProtectionKdf, options->ProtectionKeyfiles, true, volumeType, @@ -359,7 +367,7 @@ namespace VeraCrypt ShowInfo ("VOL_HEADER_BACKED_UP"); } - void TextUserInterface::ChangePassword (shared_ptr volumePath, shared_ptr password, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newHash) const + void TextUserInterface::ChangePassword (shared_ptr volumePath, shared_ptr password, shared_ptr currentHash, shared_ptr keyfiles, shared_ptr newPassword, shared_ptr newKeyfiles, shared_ptr newHash) const { shared_ptr volume; @@ -378,6 +386,12 @@ namespace VeraCrypt bool passwordInteractive = !password.get(); bool keyfilesInteractive = !keyfiles.get(); + shared_ptr kdf; + if (currentHash) + { + kdf = Pkcs5Kdf::GetAlgorithm (*currentHash); + } + while (true) { // Current password @@ -406,7 +420,7 @@ namespace VeraCrypt try { keyfiles.reset (new KeyfileList); - volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, keyfiles); + volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, keyfiles); } catch (PasswordException&) { @@ -416,7 +430,7 @@ namespace VeraCrypt } if (!volume.get()) - volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, keyfiles); + volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, kdf, keyfiles); } catch (PasswordException &e) { @@ -1285,6 +1299,12 @@ namespace VeraCrypt // Ask whether to restore internal or external backup bool restoreInternalBackup; + shared_ptr kdf; + if (CmdLine->ArgHash) + { + kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); + } + ShowInfo (LangString["HEADER_RESTORE_EXTERNAL_INTERNAL"]); ShowInfo (L"\n1) " + LangString["HEADER_RESTORE_INTERNAL"]); ShowInfo (L"2) " + LangString["HEADER_RESTORE_EXTERNAL"] + L"\n"); @@ -1325,9 +1345,11 @@ namespace VeraCrypt options.Path, options.PreserveTimestamps, options.Password, + kdf, options.Keyfiles, options.Protection, options.ProtectionPassword, + options.ProtectionKdf, options.ProtectionKeyfiles, options.SharedAccessAllowed, VolumeType::Unknown, @@ -1432,7 +1454,7 @@ namespace VeraCrypt // Decrypt header shared_ptr passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password); - if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes())) + if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, kdf, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes())) { decryptedLayout = layout; break; diff --git a/src/Main/TextUserInterface.h b/src/Main/TextUserInterface.h old mode 100644 new mode 100755 index 8721395f..c26298e2 --- a/src/Main/TextUserInterface.h +++ b/src/Main/TextUserInterface.h @@ -30,7 +30,7 @@ namespace VeraCrypt virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const; virtual void BackupVolumeHeaders (shared_ptr volumePath) const; virtual void BeginBusyState () const { } - virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const; + virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr currentHash = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const; virtual void CreateKeyfile (shared_ptr keyfilePath = shared_ptr ()) const; virtual void CreateVolume (shared_ptr options) const; virtual void DeleteSecurityTokenKeyfiles () const; diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp old mode 100644 new mode 100755 index f66e28d2..4306dec2 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -883,6 +883,11 @@ namespace VeraCrypt cmdLine.ArgMountOptions.Password = cmdLine.ArgPassword; cmdLine.ArgMountOptions.Keyfiles = cmdLine.ArgKeyfiles; cmdLine.ArgMountOptions.SharedAccessAllowed = cmdLine.ArgForce; + if (cmdLine.ArgHash) + { + cmdLine.ArgMountOptions.Kdf = Pkcs5Kdf::GetAlgorithm (*cmdLine.ArgHash); + } + VolumeInfoList mountedVolumes; switch (cmdLine.ArgCommand) @@ -965,7 +970,7 @@ namespace VeraCrypt return true; case CommandId::ChangePassword: - ChangePassword (cmdLine.ArgVolumePath, cmdLine.ArgPassword, cmdLine.ArgKeyfiles, cmdLine.ArgNewPassword, cmdLine.ArgNewKeyfiles, cmdLine.ArgHash); + ChangePassword (cmdLine.ArgVolumePath, cmdLine.ArgPassword, cmdLine.ArgCurrentHash, cmdLine.ArgKeyfiles, cmdLine.ArgNewPassword, cmdLine.ArgNewKeyfiles, cmdLine.ArgHash); return true; case CommandId::CreateKeyfile: diff --git a/src/Main/UserInterface.h b/src/Main/UserInterface.h old mode 100644 new mode 100755 index f7ebee0d..ae74ae99 --- a/src/Main/UserInterface.h +++ b/src/Main/UserInterface.h @@ -29,7 +29,7 @@ namespace VeraCrypt virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const = 0; virtual void BackupVolumeHeaders (shared_ptr volumePath) const = 0; virtual void BeginBusyState () const = 0; - virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const = 0; + virtual void ChangePassword (shared_ptr volumePath = shared_ptr (), shared_ptr password = shared_ptr (), shared_ptr currentHash = shared_ptr (), shared_ptr keyfiles = shared_ptr (), shared_ptr newPassword = shared_ptr (), shared_ptr newKeyfiles = shared_ptr (), shared_ptr newHash = shared_ptr ()) const = 0; virtual void CheckRequirementsForMountingVolume () const; virtual void CloseExplorerWindows (shared_ptr mountedVolume) const; virtual void CreateKeyfile (shared_ptr keyfilePath = shared_ptr ()) const = 0; -- cgit v1.2.3