VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Common/Language.xml1
-rw-r--r--src/Format/Tcformat.c56
2 files changed, 50 insertions, 7 deletions
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 18dbaf1a..d2114d84 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -1438,6 +1438,7 @@
<entry lang="en" key="IDT_BENCHMARK">Benchmark:</entry>
<entry lang="en" key="IDC_DISABLE_MOUNT_MANAGER">Only create virtual device without mounting on selected drive letter</entry>
<entry lang="en" key="LEGACY_PASSWORD_UTF8_TOO_LONG">The entered password is too long: its UTF-8 representation exceeds 64 bytes.</entry>
+ <entry kang="en" key="HIDDEN_CREDS_SAME_AS_OUTER">The Hidden volume can't have the same password, PIM and keyfiles as the Outer volume</entry>
</localization>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VeraCrypt">
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));