1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-11 11:08:02 -06:00

Windows: Avoid temporary caching password when mounting multiple favorites. Add option to activate this if needed.

This commit is contained in:
Mounir IDRASSI
2015-03-04 00:25:39 +01:00
parent 8e6707cc22
commit f80f7d47d5
4 changed files with 34 additions and 17 deletions

View File

@@ -155,6 +155,7 @@
<control lang="en" key="IDC_PREF_MOUNT_READONLY">Mount volumes as read-only</control> <control lang="en" key="IDC_PREF_MOUNT_READONLY">Mount volumes as read-only</control>
<control lang="en" key="IDC_PREF_MOUNT_REMOVABLE">Mount volumes as removable media</control> <control lang="en" key="IDC_PREF_MOUNT_REMOVABLE">Mount volumes as removable media</control>
<control lang="en" key="IDC_PREF_OPEN_EXPLORER">Open Explorer window for successfully mounted volume</control> <control lang="en" key="IDC_PREF_OPEN_EXPLORER">Open Explorer window for successfully mounted volume</control>
<control lang="en" key="IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT">Temporary Cache password during "Mount Favorite Volumes" operations</control>
<control lang="en" key="IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED">Use a different taskbar icon when there are mounted volumes</control> <control lang="en" key="IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED">Use a different taskbar icon when there are mounted volumes</control>
<control lang="en" key="IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT">Wipe cached passwords on auto-dismount</control> <control lang="en" key="IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT">Wipe cached passwords on auto-dismount</control>
<control lang="en" key="IDC_PREF_WIPE_CACHE_ON_EXIT">Wipe cached passwords on exit</control> <control lang="en" key="IDC_PREF_WIPE_CACHE_ON_EXIT">Wipe cached passwords on exit</control>

View File

@@ -82,6 +82,7 @@ char szDriveLetter[3]; /* Drive Letter to mount */
char commandLineDrive = 0; char commandLineDrive = 0;
BOOL bCacheInDriver = FALSE; /* Cache any passwords we see */ BOOL bCacheInDriver = FALSE; /* Cache any passwords we see */
BOOL bCacheInDriverDefault = FALSE; BOOL bCacheInDriverDefault = FALSE;
BOOL bCacheDuringMultipleMount = FALSE;
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */ BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
BOOL bUseDifferentTrayIconIfVolMounted = TRUE; BOOL bUseDifferentTrayIconIfVolMounted = TRUE;
BOOL bCloseDismountedWindows=TRUE; /* Close all open explorer windows of dismounted volume */ BOOL bCloseDismountedWindows=TRUE; /* Close all open explorer windows of dismounted volume */
@@ -478,6 +479,7 @@ void LoadSettings (HWND hwndDlg)
bHistory = ConfigReadInt ("SaveVolumeHistory", FALSE); bHistory = ConfigReadInt ("SaveVolumeHistory", FALSE);
bCacheInDriverDefault = bCacheInDriver = ConfigReadInt ("CachePasswords", FALSE); bCacheInDriverDefault = bCacheInDriver = ConfigReadInt ("CachePasswords", FALSE);
bCacheDuringMultipleMount = ConfigReadInt ("CachePasswordDuringMultipleMount", FALSE);
bWipeCacheOnExit = ConfigReadInt ("WipePasswordCacheOnExit", FALSE); bWipeCacheOnExit = ConfigReadInt ("WipePasswordCacheOnExit", FALSE);
bWipeCacheOnAutoDismount = ConfigReadInt ("WipeCacheOnAutoDismount", TRUE); bWipeCacheOnAutoDismount = ConfigReadInt ("WipeCacheOnAutoDismount", TRUE);
@@ -579,6 +581,7 @@ void SaveSettings (HWND hwndDlg)
ConfigWriteInt ("SaveVolumeHistory", !IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY))); ConfigWriteInt ("SaveVolumeHistory", !IsButtonChecked (GetDlgItem (hwndDlg, IDC_NO_HISTORY)));
ConfigWriteInt ("CachePasswords", bCacheInDriverDefault); ConfigWriteInt ("CachePasswords", bCacheInDriverDefault);
ConfigWriteInt ("CachePasswordDuringMultipleMount", bCacheDuringMultipleMount);
ConfigWriteInt ("WipePasswordCacheOnExit", bWipeCacheOnExit); ConfigWriteInt ("WipePasswordCacheOnExit", bWipeCacheOnExit);
ConfigWriteInt ("WipeCacheOnAutoDismount", bWipeCacheOnAutoDismount); ConfigWriteInt ("WipeCacheOnAutoDismount", bWipeCacheOnAutoDismount);
@@ -2538,6 +2541,9 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
SendMessage (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS), BM_SETCHECK, SendMessage (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS), BM_SETCHECK,
defaultMountOptions.PreserveTimestamp ? BST_CHECKED:BST_UNCHECKED, 0); defaultMountOptions.PreserveTimestamp ? BST_CHECKED:BST_UNCHECKED, 0);
SendMessage (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT), BM_SETCHECK,
bCacheDuringMultipleMount ? BST_CHECKED:BST_UNCHECKED, 0);
SendMessage (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT), BM_SETCHECK, SendMessage (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT), BM_SETCHECK,
bWipeCacheOnExit ? BST_CHECKED:BST_UNCHECKED, 0); bWipeCacheOnExit ? BST_CHECKED:BST_UNCHECKED, 0);
@@ -2645,6 +2651,7 @@ BOOL CALLBACK PreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_OPEN_EXPLORER)); bExplore = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_OPEN_EXPLORER));
bUseDifferentTrayIconIfVolMounted = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED)); bUseDifferentTrayIconIfVolMounted = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED));
bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS)); bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PRESERVE_TIMESTAMPS));
bCacheDuringMultipleMount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT));
bWipeCacheOnExit = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT)); bWipeCacheOnExit = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_EXIT));
bWipeCacheOnAutoDismount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT)); bWipeCacheOnAutoDismount = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT));
bCacheInDriverDefault = bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PASSWORDS)); bCacheInDriverDefault = bCacheInDriver = IsButtonChecked (GetDlgItem (hwndDlg, IDC_PREF_CACHE_PASSWORDS));
@@ -3777,7 +3784,10 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName)
// First try cached passwords and if they fail ask user for a new one // First try cached passwords and if they fail ask user for a new one
WaitCursor (); WaitCursor ();
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE); // try TrueCrypt mode first since it is quick
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
if (!mounted)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
// If keyfiles are enabled, test empty password first // If keyfiles are enabled, test empty password first
if (!mounted && KeyFilesEnable && FirstKeyFile) if (!mounted && KeyFilesEnable && FirstKeyFile)
@@ -3786,19 +3796,22 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, char *szFileName)
emptyPassword.Length = 0; emptyPassword.Length = 0;
KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile); KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile);
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE); // try TrueCrypt mode first since it is quick
if (mounted) mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
{ if (!mounted)
VolumePkcs5 = EffectiveVolumePkcs5; mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
VolumeTrueCryptMode = EffectiveVolumeTrueCryptMode;
}
burn (&emptyPassword, sizeof (emptyPassword)); burn (&emptyPassword, sizeof (emptyPassword));
} }
// Test password and/or keyfiles used for the previous volume // Test password and/or keyfiles used for the previous volume
if (!mounted && MultipleMountOperationInProgress && VolumePassword.Length != 0) if (!mounted && bCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, VolumePkcs5, VolumeTrueCryptMode, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE); {
// try TrueCrypt mode first as it is quick
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, 0, TRUE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
if (!mounted)
mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, 0, FALSE, bCacheInDriver, bForceMount, &mountOptions, Silent, FALSE);
}
NormalCursor (); NormalCursor ();

View File

@@ -41,7 +41,7 @@ IDR_MOUNT_TLB TYPELIB "Mount.tlb"
// Dialog // Dialog
// //
IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 282 IDD_PREFERENCES_DLG DIALOGEX 0, 0, 336, 291
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "VeraCrypt - Preferences" CAPTION "VeraCrypt - Preferences"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
@@ -78,20 +78,22 @@ BEGIN
CONTROL "Wipe cached passwords on exit",IDC_PREF_WIPE_CACHE_ON_EXIT, CONTROL "Wipe cached passwords on exit",IDC_PREF_WIPE_CACHE_ON_EXIT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,227,165,11 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,162,227,165,11
CONTROL "Wipe cached passwords on auto-dismount",IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT, CONTROL "Wipe cached passwords on auto-dismount",IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,239,296,11 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,254,296,11
PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,262,85,14 PUSHBUTTON "More Settings...",IDC_MORE_SETTINGS,5,275,85,14
DEFPUSHBUTTON "OK",IDOK,225,262,50,14 DEFPUSHBUTTON "OK",IDOK,225,275,50,14
PUSHBUTTON "Cancel",IDCANCEL,281,262,50,14 PUSHBUTTON "Cancel",IDCANCEL,281,275,50,14
GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,52 GROUPBOX "Windows",IDT_WINDOWS_RELATED_SETTING,4,160,328,52
GROUPBOX "Default Mount Options",IDT_DEFAULT_MOUNT_OPTIONS,4,3,328,26 GROUPBOX "Default Mount Options",IDT_DEFAULT_MOUNT_OPTIONS,4,3,328,26
GROUPBOX "VeraCrypt Background Task",IDT_TASKBAR_ICON,4,33,328,26 GROUPBOX "VeraCrypt Background Task",IDT_TASKBAR_ICON,4,33,328,26
GROUPBOX "Auto-Dismount",IDT_AUTO_DISMOUNT,4,94,328,62 GROUPBOX "Auto-Dismount",IDT_AUTO_DISMOUNT,4,94,328,62
LTEXT "minutes",IDT_MINUTES,289,129,39,10 LTEXT "minutes",IDT_MINUTES,289,129,39,10
LTEXT "Dismount all when:",IDT_AUTO_DISMOUNT_ON,9,110,71,17 LTEXT "Dismount all when:",IDT_AUTO_DISMOUNT_ON,9,110,71,17
GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,216,328,39 GROUPBOX "Password Cache",IDT_PW_CACHE_OPTIONS,4,216,328,54
GROUPBOX "Actions to perform upon logon to Windows",IDT_LOGON,4,63,328,28 GROUPBOX "Actions to perform upon logon to Windows",IDT_LOGON,4,63,328,28
CONTROL "User session locked",IDC_PREF_DISMOUNT_SESSION_LOCKED, CONTROL "User session locked",IDC_PREF_DISMOUNT_SESSION_LOCKED,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,105,130,11 "Button",BS_AUTOCHECKBOX | WS_TABSTOP,197,105,130,11
CONTROL "Temporary Cache password during ""Mount Favorite Volumes"" operations",IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,241,294,11
END END
IDD_VOLUME_PROPERTIES DIALOGEX 60, 30, 284, 224 IDD_VOLUME_PROPERTIES DIALOGEX 60, 30, 284, 224
@@ -357,7 +359,7 @@ BEGIN
LEFTMARGIN, 7 LEFTMARGIN, 7
RIGHTMARGIN, 329 RIGHTMARGIN, 329
TOPMARGIN, 7 TOPMARGIN, 7
BOTTOMMARGIN, 280 BOTTOMMARGIN, 289
END END
IDD_VOLUME_PROPERTIES, DIALOG IDD_VOLUME_PROPERTIES, DIALOG

View File

@@ -162,6 +162,7 @@
#define IDT_NEW_PKCS5_PRF 1138 #define IDT_NEW_PKCS5_PRF 1138
#define IDC_PKCS5_OLD_PRF_ID 1139 #define IDC_PKCS5_OLD_PRF_ID 1139
#define IDC_TRUECRYPT_MODE 1140 #define IDC_TRUECRYPT_MODE 1140
#define IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT 1141
#define IDM_HELP 40001 #define IDM_HELP 40001
#define IDM_ABOUT 40002 #define IDM_ABOUT 40002
#define IDM_UNMOUNT_VOLUME 40003 #define IDM_UNMOUNT_VOLUME 40003
@@ -237,7 +238,7 @@
#define _APS_NO_MFC 1 #define _APS_NO_MFC 1
#define _APS_NEXT_RESOURCE_VALUE 119 #define _APS_NEXT_RESOURCE_VALUE 119
#define _APS_NEXT_COMMAND_VALUE 40068 #define _APS_NEXT_COMMAND_VALUE 40068
#define _APS_NEXT_CONTROL_VALUE 1141 #define _APS_NEXT_CONTROL_VALUE 1142
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif