VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Mount/Favorites.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Mount/Favorites.cpp')
-rw-r--r--src/Mount/Favorites.cpp84
1 files changed, 84 insertions, 0 deletions
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index c27fed5f..ee34272f 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -21,6 +21,7 @@
#include "Resource.h"
#include "Xml.h"
#include "Favorites.h"
+#include "Pkcs5.h"
using namespace std;
@@ -98,6 +99,8 @@ namespace VeraCrypt
favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false;
favorite.OpenExplorerWindow = (bExplore == TRUE);
favorite.Pim = prop.volumePim;
+ favorite.Pkcs5 = prop.pkcs5;
+ favorite.TrueCryptMode = (prop.pkcs5Iterations == get_pkcs5_iteration_count(prop.pkcs5, 0, TRUE, prop.partitionInInactiveSysEncScope))? 1 : 0;
memcpy (favorite.VolumeID, prop.volumeID, VOLUME_ID_SIZE);
if (favorite.VolumePathId.empty()
@@ -669,6 +672,30 @@ namespace VeraCrypt
favorite.DisconnectedDevice = true;
}
+ XmlGetAttributeText (xml, "TrueCryptMode", boolVal, sizeof (boolVal));
+ if (boolVal[0])
+ favorite.TrueCryptMode = (boolVal[0] == '1')? 1 : 0;
+ else
+ favorite.TrueCryptMode = -1;
+
+ if (favorite.TrueCryptMode)
+ favorite.Pim = 0;
+
+ XmlGetAttributeText (xml, "pkcs5", label, sizeof (label));
+ if (label[0])
+ favorite.Pkcs5 = strtol (label, NULL, 10);
+ else
+ favorite.Pkcs5 = -1;
+ if ( (favorite.Pkcs5 != -1)
+ && ( (favorite.Pkcs5 < FIRST_PRF_ID)
+ || (favorite.Pkcs5 > LAST_PRF_ID)
+ || (favorite.TrueCryptMode == 1 && (0 == get_pkcs5_iteration_count (favorite.Pkcs5, 0, TRUE, favorite.SystemEncryption? TRUE : FALSE)))
+ )
+ )
+ {
+ favorite.Pkcs5 = -1;
+ }
+
favorites.push_back (favorite);
xml++;
}
@@ -762,6 +789,14 @@ namespace VeraCrypt
if (favorite.Pim > 0)
s += L" pim=\"" + IntToWideString(favorite.Pim) + L"\"";
+ if (favorite.Pkcs5 > 0)
+ s += L" pkcs5=\"" + IntToWideString(favorite.Pkcs5) + L"\"";
+
+ if (favorite.TrueCryptMode > 0)
+ s += L" TrueCryptMode=\"1\"";
+ else if (favorite.TrueCryptMode == 0)
+ s += L" TrueCryptMode=\"0\"";
+
if (favorite.ReadOnly)
s += L" readonly=\"1\"";
@@ -871,6 +906,29 @@ namespace VeraCrypt
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly);
SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE, favorite.Removable);
SetCheckBox (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID, favorite.UseVolumeID && bIsDevice);
+ SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, (favorite.TrueCryptMode > 0)? TRUE : FALSE);
+
+ /* Populate the PRF algorithms list */
+ int nIndex, i, nSelected = 0;
+ HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
+ SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
+
+ nIndex = (int) SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
+
+ for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
+ {
+ if (!favorite.SystemEncryption || (favorite.TrueCryptMode != 1) || (i == RIPEMD160))
+ {
+ nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
+ SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
+ if (favorite.Pkcs5 == i)
+ nSelected = nIndex;
+ }
+ }
+
+ if (favorite.Pkcs5 >= 0)
+ SendMessage (hComboBox, CB_SETCURSEL, nSelected, 0);
if (IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)) || !bIsDevice)
{
@@ -898,6 +956,9 @@ namespace VeraCrypt
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_UP), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_DOWN), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_REMOVE), enable);
+ EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), enable && !favorite.SystemEncryption);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), enable && !favorite.SystemEncryption);
+ EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), enable && !favorite.SystemEncryption);
EnableWindow (GetDlgItem (hwndDlg, IDT_PIM), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_PIM), enable);
EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PIM), enable);
@@ -971,6 +1032,29 @@ namespace VeraCrypt
favorite.Pim = GetPim (hwndDlg, IDC_PIM);
favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0);
favorite.UseVolumeID = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID) != 0);
+ int nSelected = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0);
+ if (nSelected != CB_ERR)
+ favorite.Pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, nSelected, 0);
+ else
+ favorite.Pkcs5 = -1;
+ BOOL selectedTrueCryptMode = (IsDlgButtonChecked (hwndDlg, IDC_TRUECRYPT_MODE) != 0)? 1 : 0;
+ if ((favorite.TrueCryptMode >= 0) || selectedTrueCryptMode)
+ favorite.TrueCryptMode = selectedTrueCryptMode;
+
+ if (favorite.TrueCryptMode == 1)
+ {
+ if ((favorite.Pkcs5 > 0) && !is_pkcs5_prf_supported (favorite.Pkcs5, TRUE, favorite.SystemEncryption? PRF_BOOT_MBR : PRF_BOOT_NO))
+ {
+ Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
+ favorite.Pkcs5 = 0;
+ }
+
+ if (favorite.Pim > 0)
+ {
+ Error ("PIM_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg);
+ favorite.Pim = 0;
+ }
+ }
favorite.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0);
favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0);