Windows: replicate old behavior when handling passwords in UI when legacy password maximum length option selected
This commit is contained in:
parent
453ef927ef
commit
d92e045b8d
|
@ -285,6 +285,7 @@ void LoadSettings (HWND hwndDlg)
|
||||||
bShowDisconnectedNetworkDrives = ConfigReadInt ("ShowDisconnectedNetworkDrives", FALSE);
|
bShowDisconnectedNetworkDrives = ConfigReadInt ("ShowDisconnectedNetworkDrives", FALSE);
|
||||||
bHideWaitingDialog = ConfigReadInt ("HideWaitingDialog", FALSE);
|
bHideWaitingDialog = ConfigReadInt ("HideWaitingDialog", FALSE);
|
||||||
bUseSecureDesktop = ConfigReadInt ("UseSecureDesktop", FALSE);
|
bUseSecureDesktop = ConfigReadInt ("UseSecureDesktop", FALSE);
|
||||||
|
bUseLegacyMaxPasswordLength = ConfigReadInt ("UseLegacyMaxPasswordLength", FALSE);
|
||||||
defaultMountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
|
defaultMountOptions.Removable = ConfigReadInt ("MountVolumesRemovable", FALSE);
|
||||||
defaultMountOptions.ReadOnly = ConfigReadInt ("MountVolumesReadOnly", FALSE);
|
defaultMountOptions.ReadOnly = ConfigReadInt ("MountVolumesReadOnly", FALSE);
|
||||||
defaultMountOptions.ProtectHiddenVolume = FALSE;
|
defaultMountOptions.ProtectHiddenVolume = FALSE;
|
||||||
|
@ -674,10 +675,11 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA
|
||||||
if (lw == IDOK)
|
if (lw == IDOK)
|
||||||
{
|
{
|
||||||
BOOL bTrueCryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
|
BOOL bTrueCryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
|
||||||
|
int iMaxPasswordLength = (bUseLegacyMaxPasswordLength || bTrueCryptMode)? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
|
||||||
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
|
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
|
||||||
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
|
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, PasswordDlgVolume);
|
||||||
|
|
||||||
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, bTrueCryptMode, TRUE))
|
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, iMaxPasswordLength + 1, bTrueCryptMode, TRUE))
|
||||||
szXPwd->Length = (unsigned __int32) (strlen ((char *) szXPwd->Text));
|
szXPwd->Length = (unsigned __int32) (strlen ((char *) szXPwd->Text));
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -886,6 +888,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
bShowDisconnectedNetworkDrives = FALSE;
|
bShowDisconnectedNetworkDrives = FALSE;
|
||||||
bHideWaitingDialog = FALSE;
|
bHideWaitingDialog = FALSE;
|
||||||
bUseSecureDesktop = FALSE;
|
bUseSecureDesktop = FALSE;
|
||||||
|
bUseLegacyMaxPasswordLength = FALSE;
|
||||||
|
|
||||||
if (UsePreferences)
|
if (UsePreferences)
|
||||||
{
|
{
|
||||||
|
|
|
@ -295,6 +295,8 @@ BOOL bIsSparseFilesSupportedByHost = FALSE;
|
||||||
|
|
||||||
vector <HostDevice> DeferredNonSysInPlaceEncDevices;
|
vector <HostDevice> DeferredNonSysInPlaceEncDevices;
|
||||||
|
|
||||||
|
int iMaxPasswordLength = MAX_PASSWORD;
|
||||||
|
|
||||||
// specific definitions and implementation for support of resume operation
|
// specific definitions and implementation for support of resume operation
|
||||||
// in wait dialog mechanism
|
// in wait dialog mechanism
|
||||||
|
|
||||||
|
@ -5757,7 +5759,7 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
{
|
{
|
||||||
if (hw == EN_CHANGE)
|
if (hw == EN_CHANGE)
|
||||||
{
|
{
|
||||||
GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, MAX_PASSWORD + 1, FALSE, FALSE);
|
GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, iMaxPasswordLength + 1, FALSE, FALSE);
|
||||||
volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
|
volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -6081,6 +6083,12 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
|
|
||||||
LoadSettings (hwndDlg);
|
LoadSettings (hwndDlg);
|
||||||
|
|
||||||
|
// set the maximum password length based on configuration setting
|
||||||
|
if (bUseLegacyMaxPasswordLength)
|
||||||
|
iMaxPasswordLength = MAX_LEGACY_PASSWORD;
|
||||||
|
else
|
||||||
|
iMaxPasswordLength = MAX_PASSWORD;
|
||||||
|
|
||||||
// Save language to XML configuration file if it has been selected in the setup
|
// Save language to XML configuration file if it has been selected in the setup
|
||||||
// so that other VeraCrypt programs will pick it up
|
// so that other VeraCrypt programs will pick it up
|
||||||
if (bLanguageSetInSetup)
|
if (bLanguageSetInSetup)
|
||||||
|
@ -7577,7 +7585,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store the password in case we need to restore it after keyfile is applied to it
|
// Store the password in case we need to restore it after keyfile is applied to it
|
||||||
if (!GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, sizeof (szRawPassword), FALSE, TRUE))
|
if (!GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, iMaxPasswordLength + 1, FALSE, TRUE))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
if (!SysEncInEffect ())
|
if (!SysEncInEffect ())
|
||||||
|
@ -7686,7 +7694,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
{
|
{
|
||||||
WaitCursor ();
|
WaitCursor ();
|
||||||
|
|
||||||
if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, MAX_PASSWORD + 1, FALSE, TRUE))
|
if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, (char*) volumePassword.Text, iMaxPasswordLength + 1, FALSE, TRUE))
|
||||||
{
|
{
|
||||||
NormalCursor ();
|
NormalCursor ();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -7698,7 +7706,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||||
volumePim = GetPim (hCurPage, IDC_PIM, 0);
|
volumePim = GetPim (hCurPage, IDC_PIM, 0);
|
||||||
|
|
||||||
// Store the password in case we need to restore it after keyfile is applied to it
|
// Store the password in case we need to restore it after keyfile is applied to it
|
||||||
if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, sizeof (szRawPassword), FALSE, TRUE))
|
if (!GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, iMaxPasswordLength + 1, FALSE, TRUE))
|
||||||
{
|
{
|
||||||
NormalCursor ();
|
NormalCursor ();
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -8793,7 +8801,7 @@ ovf_end:
|
||||||
else if (nCurPageNo == PASSWORD_PAGE)
|
else if (nCurPageNo == PASSWORD_PAGE)
|
||||||
{
|
{
|
||||||
// Store the password in case we need to restore it after keyfile is applied to it
|
// Store the password in case we need to restore it after keyfile is applied to it
|
||||||
GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, sizeof (szRawPassword), FALSE, FALSE);
|
GetPassword (hCurPage, IDC_PASSWORD, szRawPassword, iMaxPasswordLength + 1, FALSE, FALSE);
|
||||||
|
|
||||||
VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT),
|
VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT),
|
||||||
GetDlgItem (hCurPage, IDC_PASSWORD),
|
GetDlgItem (hCurPage, IDC_PASSWORD),
|
||||||
|
@ -8835,9 +8843,9 @@ ovf_end:
|
||||||
|| nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
|
|| nCurPageNo == NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE)
|
||||||
{
|
{
|
||||||
// Store the password in case we need to restore it after keyfile is applied to it
|
// Store the password in case we need to restore it after keyfile is applied to it
|
||||||
GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, MAX_PASSWORD + 1, FALSE, FALSE);
|
GetPassword (hCurPage, IDC_PASSWORD_DIRECT, szRawPassword, iMaxPasswordLength + 1, FALSE, FALSE);
|
||||||
|
|
||||||
memcpy (volumePassword.Text, szRawPassword, MAX_PASSWORD + 1);
|
memcpy (volumePassword.Text, szRawPassword, iMaxPasswordLength + 1);
|
||||||
volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
|
volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text);
|
||||||
|
|
||||||
if (!bInPlaceEncNonSys)
|
if (!bInPlaceEncNonSys)
|
||||||
|
@ -9082,8 +9090,7 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine)
|
||||||
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
|
||||||
szTmp, ARRAYSIZE (szTmp)))
|
szTmp, ARRAYSIZE (szTmp)))
|
||||||
{
|
{
|
||||||
int iMaxPassLen = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
|
int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (LPSTR) CmdVolumePassword.Text, iMaxPasswordLength + 1, NULL, NULL);
|
||||||
int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (LPSTR) CmdVolumePassword.Text, iMaxPassLen + 1, NULL, NULL);
|
|
||||||
burn (szTmp, sizeof (szTmp));
|
burn (szTmp, sizeof (szTmp));
|
||||||
if (iLen > 0)
|
if (iLen > 0)
|
||||||
CmdVolumePassword.Length = (unsigned __int32) (iLen - 1);
|
CmdVolumePassword.Length = (unsigned __int32) (iLen - 1);
|
||||||
|
|
|
@ -2687,6 +2687,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
|
||||||
|
|
||||||
int old_pim = GetPim (hwndDlg, IDC_OLD_PIM, 0);
|
int old_pim = GetPim (hwndDlg, IDC_OLD_PIM, 0);
|
||||||
int pim = GetPim (hwndDlg, IDC_PIM, 0);
|
int pim = GetPim (hwndDlg, IDC_PIM, 0);
|
||||||
|
int iMaxPasswordLength = (bUseLegacyMaxPasswordLength || truecryptMode)? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
|
||||||
|
|
||||||
if (truecryptMode && !is_pkcs5_prf_supported (old_pkcs5, TRUE, PRF_BOOT_NO))
|
if (truecryptMode && !is_pkcs5_prf_supported (old_pkcs5, TRUE, PRF_BOOT_NO))
|
||||||
{
|
{
|
||||||
|
@ -2744,7 +2745,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
|
||||||
|
|
||||||
GetVolumePath (hParent, szFileName, ARRAYSIZE (szFileName));
|
GetVolumePath (hParent, szFileName, ARRAYSIZE (szFileName));
|
||||||
|
|
||||||
if (GetPassword (hwndDlg, IDC_OLD_PASSWORD, (LPSTR) oldPassword.Text, sizeof (oldPassword.Text), truecryptMode, TRUE))
|
if (GetPassword (hwndDlg, IDC_OLD_PASSWORD, (LPSTR) oldPassword.Text, iMaxPasswordLength + 1, truecryptMode, TRUE))
|
||||||
oldPassword.Length = (unsigned __int32) strlen ((char *) oldPassword.Text);
|
oldPassword.Length = (unsigned __int32) strlen ((char *) oldPassword.Text);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -2762,7 +2763,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) newPassword.Text, sizeof (newPassword.Text), FALSE, TRUE))
|
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) newPassword.Text, iMaxPasswordLength + 1, FALSE, TRUE))
|
||||||
newPassword.Length = (unsigned __int32) strlen ((char *) newPassword.Text);
|
newPassword.Length = (unsigned __int32) strlen ((char *) newPassword.Text);
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3167,10 +3168,11 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
|
||||||
if (lw == IDOK)
|
if (lw == IDOK)
|
||||||
{
|
{
|
||||||
BOOL bTrueCryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
|
BOOL bTrueCryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE);
|
||||||
|
int iMaxPasswordLength = (bUseLegacyMaxPasswordLength || bTrueCryptMode)? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
|
||||||
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
|
if (mountOptions.ProtectHiddenVolume && hidVolProtKeyFilesParam.EnableKeyFiles)
|
||||||
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, wcslen (PasswordDlgVolume) > 0 ? PasswordDlgVolume : NULL);
|
KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, wcslen (PasswordDlgVolume) > 0 ? PasswordDlgVolume : NULL);
|
||||||
|
|
||||||
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, MAX_PASSWORD + 1, bTrueCryptMode, TRUE))
|
if (GetPassword (hwndDlg, IDC_PASSWORD, (LPSTR) szXPwd->Text, iMaxPasswordLength + 1, bTrueCryptMode, TRUE))
|
||||||
szXPwd->Length = (unsigned __int32) strlen ((char *) szXPwd->Text);
|
szXPwd->Length = (unsigned __int32) strlen ((char *) szXPwd->Text);
|
||||||
else
|
else
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -3731,8 +3733,9 @@ BOOL CALLBACK MountOptionsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
|
||||||
|
|
||||||
if (mountOptions->ProtectHiddenVolume)
|
if (mountOptions->ProtectHiddenVolume)
|
||||||
{
|
{
|
||||||
|
int iMaxPasswordLength = bUseLegacyMaxPasswordLength? MAX_LEGACY_PASSWORD : MAX_PASSWORD;
|
||||||
GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL,
|
GetPassword (hwndDlg, IDC_PASSWORD_PROT_HIDVOL,
|
||||||
(LPSTR) mountOptions->ProtectedHidVolPassword.Text, MAX_PASSWORD + 1,
|
(LPSTR) mountOptions->ProtectedHidVolPassword.Text, iMaxPasswordLength + 1,
|
||||||
FALSE, FALSE);
|
FALSE, FALSE);
|
||||||
|
|
||||||
mountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) mountOptions->ProtectedHidVolPassword.Text);
|
mountOptions->ProtectedHidVolPassword.Length = (unsigned __int32) strlen ((char *) mountOptions->ProtectedHidVolPassword.Text);
|
||||||
|
|
Loading…
Reference in New Issue