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.

This commit is contained in:
Mounir IDRASSI
2014-12-19 18:18:23 +01:00
parent 18dc75ee62
commit 07156b6c09
26 changed files with 160 additions and 36 deletions

30
src/Main/TextUserInterface.cpp Normal file → Executable file
View File

@@ -244,6 +244,12 @@ namespace VeraCrypt
#endif
ShowInfo ("EXTERNAL_VOL_HEADER_BAK_FIRST_INFO");
shared_ptr <Pkcs5Kdf> kdf;
if (CmdLine->ArgHash)
{
kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash);
}
shared_ptr <Volume> normalVolume;
shared_ptr <Volume> 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> volumePath, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Hash> newHash) const
void TextUserInterface::ChangePassword (shared_ptr <VolumePath> volumePath, shared_ptr <VolumePassword> password, shared_ptr <Hash> currentHash, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Hash> newHash) const
{
shared_ptr <Volume> volume;
@@ -378,6 +386,12 @@ namespace VeraCrypt
bool passwordInteractive = !password.get();
bool keyfilesInteractive = !keyfiles.get();
shared_ptr<Pkcs5Kdf> 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 <Pkcs5Kdf> 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 <VolumePassword> 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;