diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-12-19 18:18:23 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2014-12-19 18:41:41 +0100 |
commit | 07156b6c09165cf61a6bd499d26151d1f32bf3a9 (patch) | |
tree | 165e39c03eaff470c42ef8e3af8f2c3de03b6465 /src/Core | |
parent | 18dc75ee629c5f7af61bf8393dbb693cdd78b235 (diff) | |
download | VeraCrypt-07156b6c09165cf61a6bd499d26151d1f32bf3a9.tar.gz VeraCrypt-07156b6c09165cf61a6bd499d26151d1f32bf3a9.zip |
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.
Diffstat (limited to 'src/Core')
-rwxr-xr-x[-rw-r--r--] | src/Core/CoreBase.cpp | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | src/Core/CoreBase.h | 4 | ||||
-rwxr-xr-x[-rw-r--r--] | src/Core/MountOptions.cpp | 35 | ||||
-rwxr-xr-x[-rw-r--r--] | src/Core/MountOptions.h | 2 | ||||
-rwxr-xr-x[-rw-r--r--] | src/Core/Unix/CoreUnix.cpp | 2 |
5 files changed, 45 insertions, 6 deletions
diff --git a/src/Core/CoreBase.cpp b/src/Core/CoreBase.cpp index 95e5c206..0137e204 100644..100755 --- a/src/Core/CoreBase.cpp +++ b/src/Core/CoreBase.cpp @@ -68,9 +68,9 @@ namespace VeraCrypt } } - void CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const + void CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const { - shared_ptr <Volume> volume = OpenVolume (volumePath, preserveTimestamps, password, keyfiles); + shared_ptr <Volume> volume = OpenVolume (volumePath, preserveTimestamps, password, kdf, keyfiles); ChangePassword (volume, newPassword, newKeyfiles, newPkcs5Kdf, wipeCount); } @@ -242,10 +242,10 @@ namespace VeraCrypt return GetMountedVolume (volumePath); } - shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope) const + shared_ptr <Volume> CoreBase::OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection, shared_ptr <VolumePassword> protectionPassword, shared_ptr<Pkcs5Kdf> protectionKdf, shared_ptr <KeyfileList> protectionKeyfiles, bool sharedAccessAllowed, VolumeType::Enum volumeType, bool useBackupHeaders, bool partitionInSystemEncryptionScope) const { make_shared_auto (Volume, volume); - volume->Open (*volumePath, preserveTimestamps, password, keyfiles, protection, protectionPassword, protectionKeyfiles, sharedAccessAllowed, volumeType, useBackupHeaders, partitionInSystemEncryptionScope); + volume->Open (*volumePath, preserveTimestamps, password, kdf, keyfiles, protection, protectionPassword, protectionKdf, protectionKeyfiles, sharedAccessAllowed, volumeType, useBackupHeaders, partitionInSystemEncryptionScope); return volume; } diff --git a/src/Core/CoreBase.h b/src/Core/CoreBase.h index 6ebb76b7..0d52e5b9 100644..100755 --- a/src/Core/CoreBase.h +++ b/src/Core/CoreBase.h @@ -29,7 +29,7 @@ namespace VeraCrypt virtual ~CoreBase (); virtual void ChangePassword (shared_ptr <Volume> openVolume, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; - virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; + virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; virtual void CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair = false) const = 0; virtual void CoalesceSlotNumberAndMountPoint (MountOptions &options) const; virtual void CreateKeyfile (const FilePath &keyfilePath) const; @@ -64,7 +64,7 @@ namespace VeraCrypt virtual bool IsVolumeMounted (const VolumePath &volumePath) const; virtual VolumeSlotNumber MountPointToSlotNumber (const DirectoryPath &mountPoint) const = 0; virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) = 0; - virtual shared_ptr <Volume> OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false) const; + virtual shared_ptr <Volume> OpenVolume (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, shared_ptr<Pkcs5Kdf> Kdf, shared_ptr <KeyfileList> keyfiles, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false) const; virtual void RandomizeEncryptionAlgorithmKey (shared_ptr <EncryptionAlgorithm> encryptionAlgorithm) const; virtual void ReEncryptVolumeHeaderWithNewSalt (const BufferPtr &newHeaderBuffer, shared_ptr <VolumeHeader> header, shared_ptr <VolumePassword> password, shared_ptr <KeyfileList> keyfiles) const; virtual void SetAdminPasswordCallback (shared_ptr <GetStringFunctor> functor) { } diff --git a/src/Core/MountOptions.cpp b/src/Core/MountOptions.cpp index a09879d8..fb813bf0 100644..100755 --- a/src/Core/MountOptions.cpp +++ b/src/Core/MountOptions.cpp @@ -26,11 +26,21 @@ namespace VeraCrypt TC_CLONE (NoHardwareCrypto); TC_CLONE (NoKernelCrypto); TC_CLONE_SHARED (VolumePassword, Password); + if (other.Kdf) + { + Kdf.reset(other.Kdf->Clone()); + } + else + Kdf.reset(); TC_CLONE_SHARED (VolumePath, Path); TC_CLONE (PartitionInSystemEncryptionScope); TC_CLONE (PreserveTimestamps); TC_CLONE (Protection); TC_CLONE_SHARED (VolumePassword, ProtectionPassword); + if (other.ProtectionKdf) + ProtectionKdf.reset(other.ProtectionKdf->Clone()); + else + ProtectionKdf.reset(); TC_CLONE_SHARED (KeyfileList, ProtectionKeyfiles); TC_CLONE (Removable); TC_CLONE (SharedAccessAllowed); @@ -41,6 +51,7 @@ namespace VeraCrypt void MountOptions::Deserialize (shared_ptr <Stream> stream) { Serializer sr (stream); + wstring nameValue; sr.Deserialize ("CachePassword", CachePassword); sr.Deserialize ("FilesystemOptions", FilesystemOptions); @@ -61,6 +72,14 @@ namespace VeraCrypt Password = Serializable::DeserializeNew <VolumePassword> (stream); else Password.reset(); + + if (!sr.DeserializeBool ("KdfNull")) + { + sr.Deserialize ("Kdf", nameValue); + Kdf = Pkcs5Kdf::GetAlgorithm (nameValue); + } + else + Kdf.reset(); if (!sr.DeserializeBool ("PathNull")) Path.reset (new VolumePath (sr.DeserializeWString ("Path"))); @@ -77,6 +96,14 @@ namespace VeraCrypt else ProtectionPassword.reset(); + if (!sr.DeserializeBool ("ProtectionKdfNull")) + { + sr.Deserialize ("ProtectionKdf", nameValue); + ProtectionKdf = Pkcs5Kdf::GetAlgorithm (nameValue); + } + else + ProtectionKdf.reset(); + ProtectionKeyfiles = Keyfile::DeserializeList (stream, "ProtectionKeyfiles"); sr.Deserialize ("Removable", Removable); sr.Deserialize ("SharedAccessAllowed", SharedAccessAllowed); @@ -106,6 +133,10 @@ namespace VeraCrypt if (Password) Password->Serialize (stream); + sr.Serialize ("KdfNull", Kdf == nullptr); + if (Kdf) + sr.Serialize ("Kdf", Kdf->GetName()); + sr.Serialize ("PathNull", Path == nullptr); if (Path) sr.Serialize ("Path", wstring (*Path)); @@ -118,6 +149,10 @@ namespace VeraCrypt if (ProtectionPassword) ProtectionPassword->Serialize (stream); + sr.Serialize ("ProtectionKdfNull", ProtectionKdf == nullptr); + if (ProtectionKdf) + sr.Serialize ("ProtectionKdf", ProtectionKdf->GetName()); + Keyfile::SerializeList (stream, "ProtectionKeyfiles", ProtectionKeyfiles); sr.Serialize ("Removable", Removable); sr.Serialize ("SharedAccessAllowed", SharedAccessAllowed); diff --git a/src/Core/MountOptions.h b/src/Core/MountOptions.h index 12aa03d5..6cb2c549 100644..100755 --- a/src/Core/MountOptions.h +++ b/src/Core/MountOptions.h @@ -51,11 +51,13 @@ namespace VeraCrypt bool NoHardwareCrypto; bool NoKernelCrypto; shared_ptr <VolumePassword> Password; + shared_ptr <Pkcs5Kdf> Kdf; bool PartitionInSystemEncryptionScope; shared_ptr <VolumePath> Path; bool PreserveTimestamps; VolumeProtection::Enum Protection; shared_ptr <VolumePassword> ProtectionPassword; + shared_ptr <Pkcs5Kdf> ProtectionKdf; shared_ptr <KeyfileList> ProtectionKeyfiles; bool Removable; bool SharedAccessAllowed; diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp index 15a96297..d33e4b73 100644..100755 --- a/src/Core/Unix/CoreUnix.cpp +++ b/src/Core/Unix/CoreUnix.cpp @@ -409,9 +409,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, |