VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Main
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2020-06-22 10:22:36 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2020-06-23 16:48:31 +0200
commit05b3cd5cc1c45df594d59e73cc1b693d9e79abc9 (patch)
tree0f1f2a2d319b25b072f7da9ecae11e4b2289720c /src/Main
parentb4465b80e6039ef3b0bf5e93089fabf3d50f501d (diff)
downloadVeraCrypt-05b3cd5cc1c45df594d59e73cc1b693d9e79abc9.tar.gz
VeraCrypt-05b3cd5cc1c45df594d59e73cc1b693d9e79abc9.zip
Linux/MacOSX: Use also PIM when comparing Outer and Hidden volumes credentials
Diffstat (limited to 'src/Main')
-rw-r--r--src/Main/Forms/VolumeCreationWizard.cpp91
-rw-r--r--src/Main/Forms/VolumeCreationWizard.h1
2 files changed, 64 insertions, 28 deletions
diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp
index 240f08dc..572523e7 100644
--- a/src/Main/Forms/VolumeCreationWizard.cpp
+++ b/src/Main/Forms/VolumeCreationWizard.cpp
@@ -92,6 +92,8 @@ namespace VeraCrypt
VolumeCreationWizard::~VolumeCreationWizard ()
{
+ burn (&Pim, sizeof (Pim));
+ burn (&OuterPim, sizeof (OuterPim));
}
WizardPage *VolumeCreationWizard::GetPage (WizardStep step)
@@ -774,29 +776,6 @@ namespace VeraCrypt
Kdf = page->GetPkcs5Kdf();
Keyfiles = page->GetKeyfiles();
- if (forward && !OuterVolume && SelectedVolumeType == VolumeType::Hidden)
- {
- shared_ptr <VolumePassword> hiddenPassword;
- try
- {
- hiddenPassword = Keyfile::ApplyListToPassword (Keyfiles, Password);
- }
- catch (...)
- {
- hiddenPassword = Password;
- }
-
- // check if Outer and Hidden passwords are the same
- if ( (hiddenPassword && !hiddenPassword->IsEmpty() && OuterPassword && !OuterPassword->IsEmpty() && (*(OuterPassword.get()) == *(hiddenPassword.get())))
- ||
- ((!hiddenPassword || hiddenPassword->IsEmpty()) && (!OuterPassword || OuterPassword->IsEmpty()))
- )
- {
- Gui->ShowError (_("The Hidden volume password can not be identical to the Outer volume password"));
- return GetCurrentStep();
- }
- }
-
if (forward && Password && !Password->IsEmpty())
{
if (Password->Size() < VolumePassword::WarningSizeThreshold)
@@ -815,6 +794,33 @@ namespace VeraCrypt
// Clear PIM
Pim = 0;
+ if (forward && !OuterVolume && SelectedVolumeType == VolumeType::Hidden)
+ {
+ shared_ptr <VolumePassword> hiddenPassword;
+ try
+ {
+ hiddenPassword = Keyfile::ApplyListToPassword (Keyfiles, Password);
+ }
+ catch (...)
+ {
+ hiddenPassword = Password;
+ }
+
+ // check if Outer and Hidden passwords are the same
+ if ( (hiddenPassword && !hiddenPassword->IsEmpty() && OuterPassword && !OuterPassword->IsEmpty() && (*(OuterPassword.get()) == *(hiddenPassword.get())))
+ ||
+ ((!hiddenPassword || hiddenPassword->IsEmpty()) && (!OuterPassword || OuterPassword->IsEmpty()))
+ )
+ {
+ //check if they have also the same PIM
+ if (OuterPim == Pim)
+ {
+ Gui->ShowError (_("The Hidden volume can't have the same password, PIM and keyfiles as the Outer volume"));
+ return GetCurrentStep();
+ }
+ }
+ }
+
// Skip PIM
if (forward && OuterVolume)
{
@@ -841,15 +847,42 @@ namespace VeraCrypt
VolumePimWizardPage *page = dynamic_cast <VolumePimWizardPage *> (GetCurrentPage());
Pim = page->GetVolumePim();
- if (forward && Password && !Password->IsEmpty())
+ if (-1 == Pim)
+ {
+ // PIM invalid: don't go anywhere
+ Gui->ShowError ("PIM_TOO_BIG");
+ return GetCurrentStep();
+ }
+
+ if (forward && !OuterVolume && SelectedVolumeType == VolumeType::Hidden)
{
- if (-1 == Pim)
+ shared_ptr <VolumePassword> hiddenPassword;
+ try
{
- // PIM invalid: don't go anywhere
- Gui->ShowError ("PIM_TOO_BIG");
- return GetCurrentStep();
+ hiddenPassword = Keyfile::ApplyListToPassword (Keyfiles, Password);
+ }
+ catch (...)
+ {
+ hiddenPassword = Password;
+ }
+
+ // check if Outer and Hidden passwords are the same
+ if ( (hiddenPassword && !hiddenPassword->IsEmpty() && OuterPassword && !OuterPassword->IsEmpty() && (*(OuterPassword.get()) == *(hiddenPassword.get())))
+ ||
+ ((!hiddenPassword || hiddenPassword->IsEmpty()) && (!OuterPassword || OuterPassword->IsEmpty()))
+ )
+ {
+ //check if they have also the same PIM
+ if (OuterPim == Pim)
+ {
+ Gui->ShowError (_("The Hidden volume can't have the same password, PIM and keyfiles as the Outer volume"));
+ return GetCurrentStep();
+ }
}
+ }
+ if (forward && Password && !Password->IsEmpty())
+ {
if (Password->Size() < VolumePassword::WarningSizeThreshold)
{
if (Pim > 0 && Pim < 485)
@@ -1112,6 +1145,8 @@ namespace VeraCrypt
{
OuterPassword = Password;
}
+
+ OuterPim = Pim;
}
catch (exception &e)
{
diff --git a/src/Main/Forms/VolumeCreationWizard.h b/src/Main/Forms/VolumeCreationWizard.h
index 5555aaaa..fd4b3e06 100644
--- a/src/Main/Forms/VolumeCreationWizard.h
+++ b/src/Main/Forms/VolumeCreationWizard.h
@@ -84,6 +84,7 @@ namespace VeraCrypt
shared_ptr <VolumePassword> Password;
shared_ptr <VolumePassword> OuterPassword;
int Pim;
+ int OuterPim;
shared_ptr <Pkcs5Kdf> Kdf;
uint32 SectorSize;
shared_ptr <Hash> SelectedHash;