VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main/Forms/VolumePasswordPanel.cpp
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-04 11:37:37 +0100
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2019-02-04 11:39:47 +0100
commit6bb1f24ed571bccd4d1d247dafdc1dda6eaa3d8d (patch)
treecf56d5e0f83ef2fa69580215e60b4106ac888897 /src/Main/Forms/VolumePasswordPanel.cpp
parent5d3278bcf20d7b8039747a430f86b7dd5ef49a04 (diff)
downloadVeraCrypt-6bb1f24ed571bccd4d1d247dafdc1dda6eaa3d8d.tar.gz
VeraCrypt-6bb1f24ed571bccd4d1d247dafdc1dda6eaa3d8d.zip
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.
Diffstat (limited to 'src/Main/Forms/VolumePasswordPanel.cpp')
-rw-r--r--src/Main/Forms/VolumePasswordPanel.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp
index 9bce4c75..2859762c 100644
--- a/src/Main/Forms/VolumePasswordPanel.cpp
+++ b/src/Main/Forms/VolumePasswordPanel.cpp
@@ -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;
}