mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 03:18:26 -06:00
Automatically truncate passwords for TrueCrypt volumes and System Encryption to the first 64 characters. This fix issues encountered by users of TrueCrypt volumes who were using passwords longer than 64 characters that were truncated in previous version.
This commit is contained in:
@@ -133,7 +133,7 @@ namespace VeraCrypt
|
||||
|
||||
try
|
||||
{
|
||||
Options.Password = PasswordPanel->GetPassword();
|
||||
Options.Password = PasswordPanel->GetPassword(Options.PartitionInSystemEncryptionScope);
|
||||
}
|
||||
catch (PasswordException& e)
|
||||
{
|
||||
@@ -165,7 +165,7 @@ namespace VeraCrypt
|
||||
{
|
||||
try
|
||||
{
|
||||
Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword();
|
||||
Options.ProtectionPassword = ProtectionPasswordPanel->GetPassword(Options.TrueCryptMode);
|
||||
}
|
||||
catch (PasswordException& e)
|
||||
{
|
||||
|
||||
@@ -219,15 +219,16 @@ namespace VeraCrypt
|
||||
SetPimValidator ();
|
||||
}
|
||||
|
||||
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword () const
|
||||
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (bool bForceLegacyPassword) const
|
||||
{
|
||||
return GetPassword (PasswordTextCtrl);
|
||||
return GetPassword (PasswordTextCtrl, bForceLegacyPassword || GetTrueCryptMode());
|
||||
}
|
||||
|
||||
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (wxTextCtrl *textCtrl) const
|
||||
shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (wxTextCtrl *textCtrl, bool bLegacyPassword) const
|
||||
{
|
||||
shared_ptr <VolumePassword> password;
|
||||
wchar_t passwordBuf[VolumePassword::MaxSize + 1];
|
||||
size_t maxPasswordLength = bLegacyPassword? VolumePassword::MaxLegacySize: VolumePassword::MaxSize;
|
||||
finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); });
|
||||
|
||||
#ifdef TC_WINDOWS
|
||||
@@ -235,12 +236,12 @@ namespace VeraCrypt
|
||||
password = ToUTF8Password (passwordBuf, len);
|
||||
#else
|
||||
wxString passwordStr (textCtrl->GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased
|
||||
for (size_t i = 0; i < passwordStr.size() && i < VolumePassword::MaxSize; ++i)
|
||||
for (size_t i = 0; i < passwordStr.size() && i < maxPasswordLength; ++i)
|
||||
{
|
||||
passwordBuf[i] = (wchar_t) passwordStr[i];
|
||||
passwordStr[i] = L'X';
|
||||
}
|
||||
password = ToUTF8Password (passwordBuf, passwordStr.size() <= VolumePassword::MaxSize ? passwordStr.size() : VolumePassword::MaxSize);
|
||||
password = ToUTF8Password (passwordBuf, passwordStr.size() <= maxPasswordLength ? passwordStr.size() : maxPasswordLength);
|
||||
#endif
|
||||
return password;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace VeraCrypt
|
||||
|
||||
void AddKeyfile (shared_ptr <Keyfile> keyfile);
|
||||
shared_ptr <KeyfileList> GetKeyfiles () const { return UseKeyfilesCheckBox->IsChecked() ? Keyfiles : shared_ptr <KeyfileList> (); }
|
||||
shared_ptr <VolumePassword> GetPassword () const;
|
||||
shared_ptr <VolumePassword> GetPassword (bool bForceLegacyPassword = false) const;
|
||||
shared_ptr <Pkcs5Kdf> GetPkcs5Kdf (bool &bUnsupportedKdf) const;
|
||||
shared_ptr <Pkcs5Kdf> GetPkcs5Kdf (bool bTrueCryptMode, bool &bUnsupportedKdf) const;
|
||||
int GetVolumePim () const;
|
||||
@@ -49,7 +49,7 @@ namespace VeraCrypt
|
||||
protected:
|
||||
void SetPimValidator ();
|
||||
void DisplayPassword (bool display, wxTextCtrl **textCtrl, int row);
|
||||
shared_ptr <VolumePassword> GetPassword (wxTextCtrl *textCtrl) const;
|
||||
shared_ptr <VolumePassword> GetPassword (wxTextCtrl *textCtrl, bool bLegacyPassword = false) const;
|
||||
void OnAddKeyfileDirMenuItemSelected (wxCommandEvent& event);
|
||||
void OnAddKeyfilesMenuItemSelected (wxCommandEvent& event);
|
||||
void OnAddSecurityTokenSignatureMenuItemSelected (wxCommandEvent& event);
|
||||
|
||||
Reference in New Issue
Block a user