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/TextUserInterface.cpp | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) mode change 100644 => 100755 src/Main/TextUserInterface.cpp (limited to 'src/Main/TextUserInterface.cpp') 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; -- cgit v1.2.3