VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Format/Tcformat.c
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-06-23 13:28:12 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-06-23 16:48:46 +0200
commitcf449a443e629d09b2e0e7a0a271082ffe5a6573 (patch)
tree373c430139b2f02f14454faab450b3e83080a07b /src/Format/Tcformat.c
parent4a5d1f4f461a7f007dd2094a2930d262fb0628e0 (diff)
downloadVeraCrypt-cf449a443e629d09b2e0e7a0a271082ffe5a6573.tar.gz
VeraCrypt-cf449a443e629d09b2e0e7a0a271082ffe5a6573.zip
Windows: Don't allow Hidden volume to have the same password, PIM and keyfiles as Outer volume
Diffstat (limited to 'src/Format/Tcformat.c')
-rw-r--r--src/Format/Tcformat.c56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c
index a8554084..7d9bbb69 100644
--- a/src/Format/Tcformat.c
+++ b/src/Format/Tcformat.c
@@ -233,10 +233,12 @@ BOOL bKeybLayoutAltKeyWarningShown = FALSE; /* TRUE if the user has been informe
BOOL bWarnOuterVolSuitableFileSys = TRUE;
Password volumePassword; /* User password */
+Password outerVolumePassword; /* Outer volume user password */
char szVerify[MAX_PASSWORD + 1]; /* Tmp password buffer */
char szRawPassword[MAX_PASSWORD + 1]; /* Password before keyfile was applied to it */
int volumePim = 0;
+int outerVolumePim = 0;
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
BOOL ComServerMode = FALSE;
@@ -411,7 +413,7 @@ static BOOL ElevateWholeWizardProcess (wstring arguments)
}
}
-static void WipePasswordsAndKeyfiles (void)
+static void WipePasswordsAndKeyfiles (bool bFull)
{
wchar_t tmp[MAX_PASSWORD+1];
@@ -428,6 +430,12 @@ static void WipePasswordsAndKeyfiles (void)
burn (&CmdVolumePassword, sizeof (CmdVolumePassword));
burn (&CmdVolumePim, sizeof (CmdVolumePim));
+ if (bFull)
+ {
+ burn (&outerVolumePassword, sizeof (outerVolumePassword));
+ burn (&outerVolumePim, sizeof (outerVolumePim));
+ }
+
SetWindowText (hPasswordInputField, L"");
SetWindowText (hVerifyPasswordInputField, L"");
@@ -475,7 +483,7 @@ static void localcleanup (void)
WipeAbort();
- WipePasswordsAndKeyfiles ();
+ WipePasswordsAndKeyfiles (true);
RandStop (TRUE);
@@ -709,7 +717,7 @@ static BOOL ChangeWizardMode (int newWizardMode)
// If the previous mode was different, the password may have been typed using a different
// keyboard layout (which might confuse the user and cause other problems if system encryption
// was or will be involved).
- WipePasswordsAndKeyfiles();
+ WipePasswordsAndKeyfiles(true);
}
if (newWizardMode != WIZARD_MODE_NONSYS_DEVICE)
@@ -6619,7 +6627,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
{
// Keyboard layout is not standard US
- WipePasswordsAndKeyfiles ();
+ WipePasswordsAndKeyfiles (true);
SetPassword (hCurPage, IDC_PASSWORD, szRawPassword);
SetPassword (hCurPage, IDC_VERIFY, szVerify);
@@ -7659,6 +7667,18 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
nNewPageNo = PIM_PAGE;
volumePim = 0;
+ if (!CreatingHiddenSysVol() && bHiddenVol && !bHiddenVolHost)
+ {
+ if ( (volumePim == outerVolumePim)
+ && (volumePassword.Length == outerVolumePassword.Length)
+ && (0 == memcmp (volumePassword.Text, outerVolumePassword.Text, volumePassword.Length))
+ )
+ {
+ Warning ("HIDDEN_CREDS_SAME_AS_OUTER", hwndDlg);
+ return 1;
+ }
+ }
+
if (SysEncInEffect ())
{
nNewPageNo = SYSENC_COLLECTING_RANDOM_DATA_PAGE - 1; // Skip irrelevant pages
@@ -7689,6 +7709,18 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
return 1;
}
+ if (!CreatingHiddenSysVol() && bHiddenVol && !bHiddenVolHost)
+ {
+ if ( (volumePim == outerVolumePim)
+ && (volumePassword.Length == outerVolumePassword.Length)
+ && (0 == memcmp (volumePassword.Text, outerVolumePassword.Text, volumePassword.Length))
+ )
+ {
+ Warning ("HIDDEN_CREDS_SAME_AS_OUTER", hwndDlg);
+ return 1;
+ }
+ }
+
if (volumePassword.Length > 0)
{
// Password character encoding
@@ -7856,8 +7888,12 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
bHiddenVolHost = FALSE;
bHiddenVolFinished = FALSE;
+ // save the outer volume password to use it for comparison with hidden volume one
+ memcpy (&outerVolumePassword, &volumePassword, sizeof (volumePassword));
+ outerVolumePim = volumePim;
+
// Clear the outer volume password
- WipePasswordsAndKeyfiles ();
+ WipePasswordsAndKeyfiles (false);
RestoreDefaultKeyFilesParam ();
@@ -8587,7 +8623,7 @@ retryCDDriveCheck:
SetWindowTextW (GetDlgItem (MainDlg, IDCANCEL), GetString ("CANCEL"));
bHiddenVolFinished = FALSE;
- WipePasswordsAndKeyfiles ();
+ WipePasswordsAndKeyfiles (true);
return 1;
}
@@ -8689,8 +8725,12 @@ retryCDDriveCheck:
nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE;
+ // save the outer volume password to use it for comparison with hidden volume one
+ memcpy (&outerVolumePassword, &volumePassword, sizeof (volumePassword));
+ outerVolumePim = volumePim;
+
// Clear the outer volume password
- WipePasswordsAndKeyfiles ();
+ WipePasswordsAndKeyfiles (false);
EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), TRUE);
NormalCursor ();
@@ -10437,9 +10477,11 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz
atexit (localcleanup);
VirtualLock (&volumePassword, sizeof(volumePassword));
+ VirtualLock (&outerVolumePassword, sizeof(outerVolumePassword));
VirtualLock (szVerify, sizeof(szVerify));
VirtualLock (szRawPassword, sizeof(szRawPassword));
VirtualLock (&volumePim, sizeof(volumePim));
+ VirtualLock (&outerVolumePim, sizeof(outerVolumePim));
VirtualLock (&CmdVolumePassword, sizeof (CmdVolumePassword));
VirtualLock (MasterKeyGUIView, sizeof(MasterKeyGUIView));