diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-03-03 00:18:48 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2019-03-03 00:20:49 +0100 |
commit | 453ef927ef734320a715de12ec8536e3a642bc26 (patch) | |
tree | 7491ef15d8b5e9b86e776b5f6b4af9689220a0f3 /src/Common | |
parent | ea88c6175c19bbc2c063be63f64705733112ff0d (diff) | |
download | VeraCrypt-453ef927ef734320a715de12ec8536e3a642bc26.tar.gz VeraCrypt-453ef927ef734320a715de12ec8536e3a642bc26.zip |
Windows: Add option to use legacy maximum password length (64 characters) instead of new maximum length (128) in UI and command line. This will users who were relying on the UI truncating the passwords to the first 64 characters in the previous versions of VeraCrypt.
Diffstat (limited to 'src/Common')
-rw-r--r-- | src/Common/Dlgcode.c | 14 | ||||
-rw-r--r-- | src/Common/Dlgcode.h | 1 | ||||
-rw-r--r-- | src/Common/Language.xml | 1 | ||||
-rw-r--r-- | src/Common/Password.c | 2 |
4 files changed, 12 insertions, 6 deletions
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 27779f53..8ff2d944 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -146,6 +146,7 @@ BOOL bHideWaitingDialog = FALSE; BOOL bCmdHideWaitingDialog = FALSE; BOOL bCmdHideWaitingDialogValid = FALSE; BOOL bUseSecureDesktop = FALSE; +BOOL bUseLegacyMaxPasswordLength = FALSE; BOOL bCmdUseSecureDesktop = FALSE; BOOL bCmdUseSecureDesktopValid = FALSE; BOOL bStartOnLogon = FALSE; @@ -1232,6 +1233,7 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar { wchar_t *pchData = (wchar_t*)GlobalLock(h); int txtlen = 0; + int dwMaxPassLen = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD; while (*pchData) { if (*pchData == '\r' || *pchData == '\n') @@ -1246,7 +1248,7 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar if (txtlen) { int curLen = GetWindowTextLength (hwnd); - if (curLen == MAX_PASSWORD) + if (curLen == dwMaxPassLen) { EDITBALLOONTIP ebt; @@ -1261,7 +1263,7 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar bBlock = true; } - else if ((txtlen + curLen) > MAX_PASSWORD) + else if ((txtlen + curLen) > dwMaxPassLen) { EDITBALLOONTIP ebt; @@ -1293,6 +1295,7 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar BYTE vkCode = LOBYTE (vk); BYTE vkState = HIBYTE (vk); bool ctrlPressed = (vkState & 2) && !(vkState & 4); + int dwMaxPassLen = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD; // check if there is a selected text SendMessage (hwnd, EM_GETSEL, (WPARAM) &dwStartPos, (LPARAM) &dwEndPos); @@ -1300,7 +1303,7 @@ static LRESULT CALLBACK NormalPwdFieldProc (HWND hwnd, UINT message, WPARAM wPar if ((dwStartPos == dwEndPos) && (vkCode != VK_DELETE) && (vkCode != VK_BACK) && !ctrlPressed - && (GetWindowTextLength (hwnd) == MAX_PASSWORD)) + && (GetWindowTextLength (hwnd) == dwMaxPassLen)) { EDITBALLOONTIP ebt; @@ -1326,8 +1329,9 @@ void ToNormalPwdField (HWND hwndDlg, UINT ctrlId) { HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId); WNDPROC originalwp = (WNDPROC) GetWindowLongPtrW (hwndCtrl, GWLP_USERDATA); + DWORD dwMaxPassLen = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD; - SendMessage (hwndCtrl, EM_LIMITTEXT, MAX_PASSWORD, 0); + SendMessage (hwndCtrl, EM_LIMITTEXT, dwMaxPassLen, 0); // only change WNDPROC if not changed already if (!originalwp) { @@ -13077,7 +13081,7 @@ BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL BOOL bRet = FALSE; GetWindowText (GetDlgItem (hwndDlg, ctrlID), tmp, ARRAYSIZE (tmp)); - if (bLegacyPassword && (lstrlen (tmp) > MAX_LEGACY_PASSWORD)) + if ((bLegacyPassword || bUseLegacyMaxPasswordLength) && (lstrlen (tmp) > MAX_LEGACY_PASSWORD)) wmemset (&tmp[MAX_LEGACY_PASSWORD], 0, MAX_PASSWORD + 1 - MAX_LEGACY_PASSWORD); utf8Len = WideCharToMultiByte (CP_UTF8, 0, tmp, -1, passValue, bufSize, NULL, NULL); burn (tmp, sizeof (tmp)); diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index eccb8e87..54475cb7 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -124,6 +124,7 @@ extern BOOL bHideWaitingDialog; extern BOOL bCmdHideWaitingDialog; extern BOOL bCmdHideWaitingDialogValid; extern BOOL bUseSecureDesktop; +extern BOOL bUseLegacyMaxPasswordLength; extern BOOL bCmdUseSecureDesktop; extern BOOL bCmdUseSecureDesktopValid; extern BOOL bStartOnLogon; diff --git a/src/Common/Language.xml b/src/Common/Language.xml index f62421de..8d96572c 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -1433,6 +1433,7 @@ <entry lang="en" key="CLEAR_KEYS_ON_DEVICE_INSERTION_WARNING">IMPORTANT NOTES:\n - Please keep in mind that this option will not persist after a shutdown/reboot so you will need to select it again next time the machine is started.\n\n - With this option enabled and after a new device is connected, the machine will freeze and it will eventually crash with a BSOD since Windows can not access the encrypted disk after its keys are cleared from memory.\n</entry> <entry lang="en" key="STARTING">Starting</entry> <entry lang="en" key="IDC_ENABLE_CPU_RNG">Use CPU hardware random generator as an additional source of entropy</entry> + <entry lang="en" key="IDC_USE_LEGACY_MAX_PASSWORD_LENGTH">Use legacy maximum password length (64 characters)</entry> </localization> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="VeraCrypt"> diff --git a/src/Common/Password.c b/src/Common/Password.c index a5050d75..ca0dd468 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -112,7 +112,7 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw) wchar_t s[MAX_PASSWORD + 1]; len = GetWindowTextLength (hPassword); - if (len > MAX_PASSWORD) + if (len > (bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD: MAX_PASSWORD)) return FALSE; GetWindowTextW (hPassword, s, sizeof (s) / sizeof (wchar_t)); |