VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Mount.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-10-07 04:06:50 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-10-07 12:55:58 +0200
commitf3c91cb05c9a3ba2651438f576d707f7a48d507b (patch)
tree6e7f4b7ae134247357109a86f6540b3a4bca523e /src/Mount/Mount.c
parent13058fd638eaddf4ecdd52e902f3bf7254b5c45c (diff)
downloadVeraCrypt-f3c91cb05c9a3ba2651438f576d707f7a48d507b.tar.gz
VeraCrypt-f3c91cb05c9a3ba2651438f576d707f7a48d507b.zip
Windows: Don’t try to mount using empty password when default keyfile configured or keyfile specified in command line. Add option in default keyfiles dialog to restore the old behavior.
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r--src/Mount/Mount.c70
1 files changed, 52 insertions, 18 deletions
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 09552c0a..ddf03faf 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -86,6 +86,9 @@ BOOL bCacheInDriver = FALSE; /* Cache any passwords we see */
BOOL bCacheInDriverDefault = FALSE;
BOOL bCacheDuringMultipleMount = FALSE;
BOOL bCmdCacheDuringMultipleMount = FALSE;
+BOOL bTryEmptyPasswordWhenKeyfileUsed = FALSE;
+BOOL bCmdTryEmptyPasswordWhenKeyfileUsed = FALSE;
+BOOL bCmdTryEmptyPasswordWhenKeyfileUsedValid = FALSE;
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
BOOL bUseDifferentTrayIconIfVolMounted = TRUE;
BOOL bCloseDismountedWindows=TRUE; /* Close all open explorer windows of dismounted volume */
@@ -680,6 +683,8 @@ void LoadSettingsAndCheckModified (HWND hwndDlg, BOOL bOnlyCheckModified, BOOL*
ConfigReadCompareInt ("WipePasswordCacheOnExit", FALSE, &bWipeCacheOnExit, bOnlyCheckModified, pbSettingsModified);
ConfigReadCompareInt ("WipeCacheOnAutoDismount", TRUE, &bWipeCacheOnAutoDismount, bOnlyCheckModified, pbSettingsModified);
+ ConfigReadCompareInt ("TryEmptyPasswordWhenKeyfileUsed",FALSE, &bTryEmptyPasswordWhenKeyfileUsed, bOnlyCheckModified, pbSettingsModified);
+
ConfigReadCompareInt ("StartOnLogon", FALSE, &bStartOnLogon, bOnlyCheckModified, pbSettingsModified);
ConfigReadCompareInt ("MountDevicesOnLogon", FALSE, &bMountDevicesOnLogon, bOnlyCheckModified, pbSettingsModified);
ConfigReadCompareInt ("MountFavoritesOnLogon", FALSE, &bMountFavoritesOnLogon, bOnlyCheckModified, pbSettingsModified);
@@ -835,6 +840,8 @@ void SaveSettings (HWND hwndDlg)
ConfigWriteInt ("WipePasswordCacheOnExit", bWipeCacheOnExit);
ConfigWriteInt ("WipeCacheOnAutoDismount", bWipeCacheOnAutoDismount);
+ ConfigWriteInt ("TryEmptyPasswordWhenKeyfileUsed", bTryEmptyPasswordWhenKeyfileUsed);
+
ConfigWriteInt ("StartOnLogon", bStartOnLogon);
ConfigWriteInt ("MountDevicesOnLogon", bMountDevicesOnLogon);
ConfigWriteInt ("MountFavoritesOnLogon", bMountFavoritesOnLogon);
@@ -4353,6 +4360,8 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
BOOL EffectiveVolumeTrueCryptMode = CmdVolumeTrueCryptMode;
int EffectiveVolumePim = (pim < 0)? CmdVolumePim : pim;
BOOL bEffectiveCacheDuringMultipleMount = bCmdCacheDuringMultipleMount? TRUE: bCacheDuringMultipleMount;
+ BOOL bEffectiveTryEmptyPasswordWhenKeyfileUsed = bCmdTryEmptyPasswordWhenKeyfileUsedValid? bCmdTryEmptyPasswordWhenKeyfileUsed : bTryEmptyPasswordWhenKeyfileUsed;
+ BOOL bUseCmdVolumePassword = CmdVolumePasswordValid && ((CmdVolumePassword.Length > 0) || (KeyFilesEnable && FirstKeyFile));
/* Priority is given to command line parameters
* Default values used only when nothing specified in command line
@@ -4405,29 +4414,32 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
ResetWrongPwdRetryCount ();
- // First try cached passwords and if they fail ask user for a new one
WaitCursor ();
- // try TrueCrypt mode first since it is quick, only if pim = 0
- if (EffectiveVolumePim == 0)
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
- if (!mounted)
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
-
- // If keyfiles are enabled, test empty password first
- if (!mounted && KeyFilesEnable && FirstKeyFile)
+ if (!bUseCmdVolumePassword)
{
- Password emptyPassword;
- emptyPassword.Length = 0;
-
- KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName);
+ // First try cached passwords and if they fail ask user for a new one
// try TrueCrypt mode first since it is quick, only if pim = 0
if (EffectiveVolumePim == 0)
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
if (!mounted)
- mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
- burn (&emptyPassword, sizeof (emptyPassword));
+ // If keyfiles are enabled, test empty password first
+ if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed)
+ {
+ Password emptyPassword;
+ emptyPassword.Length = 0;
+
+ KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName);
+ // try TrueCrypt mode first since it is quick, only if pim = 0
+ if (EffectiveVolumePim == 0)
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
+ if (!mounted)
+ mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
+
+ burn (&emptyPassword, sizeof (emptyPassword));
+ }
}
// Test password and/or keyfiles used for the previous volume
@@ -4452,7 +4464,7 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName, int pim)
while (mounted == 0)
{
- if (CmdVolumePassword.Length > 0)
+ if (bUseCmdVolumePassword)
{
VolumePassword = CmdVolumePassword;
VolumePkcs5 = EffectiveVolumePkcs5;
@@ -6251,6 +6263,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
BOOL mounted = FALSE;
int EffectiveVolumePkcs5 = CmdVolumePkcs5;
BOOL EffectiveVolumeTrueCryptMode = CmdVolumeTrueCryptMode;
+ BOOL bEffectiveTryEmptyPasswordWhenKeyfileUsed = bCmdTryEmptyPasswordWhenKeyfileUsedValid? bCmdTryEmptyPasswordWhenKeyfileUsed : bTryEmptyPasswordWhenKeyfileUsed;
if (!VolumePathExists (szFileName))
{
@@ -6270,7 +6283,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
mounted = MountVolume (hwndDlg, szDriveLetter[0] - 'A', szFileName, NULL, EffectiveVolumePkcs5, CmdVolumePim, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
// Command line password or keyfiles
- if (!mounted && (CmdVolumePassword.Length != 0 || FirstCmdKeyFile))
+ if (!mounted && (CmdVolumePassword.Length != 0 || (FirstCmdKeyFile && (CmdVolumePasswordValid || bEffectiveTryEmptyPasswordWhenKeyfileUsed))))
{
BOOL reportBadPasswd = CmdVolumePassword.Length > 0;
@@ -8086,6 +8099,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
OptionPkcs5,
OptionTrueCryptMode,
OptionPim,
+ OptionTryEmptyPassword,
};
argument args[]=
@@ -8110,6 +8124,7 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
{ OptionTrueCryptMode, "/truecrypt", "/tc", FALSE },
{ OptionVolume, "/volume", "/v", FALSE },
{ CommandWipeCache, "/wipecache", "/w", FALSE },
+ { OptionTryEmptyPassword, "/tryemptypass", NULL, FALSE },
};
argumentspec as;
@@ -8143,6 +8158,25 @@ void ExtractCommandLine (HWND hwndDlg, char *lpszCommandLine)
bBeep = TRUE;
break;
+ case OptionTryEmptyPassword:
+ {
+ char szTmp[16] = {0};
+ bCmdTryEmptyPasswordWhenKeyfileUsed = TRUE;
+ bCmdTryEmptyPasswordWhenKeyfileUsedValid = TRUE;
+
+ if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs,
+ szTmp, sizeof (szTmp)))
+ {
+ if (!_stricmp(szTmp,"n") || !_stricmp(szTmp,"no"))
+ bCmdTryEmptyPasswordWhenKeyfileUsed = FALSE;
+ else if (!_stricmp(szTmp,"y") || !_stricmp(szTmp,"yes"))
+ bCmdTryEmptyPasswordWhenKeyfileUsed = TRUE;
+ else
+ AbortProcess ("COMMAND_LINE_ERROR");
+ }
+ }
+ break;
+
case OptionCache:
{
char szTmp[16] = {0};