VeraCrypt
aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMounir IDRASSI <mounir.idrassi@idrix.fr>2015-06-14 18:06:41 +0200
committerMounir IDRASSI <mounir.idrassi@idrix.fr>2015-06-19 18:31:59 +0200
commitd31466ae7a55668a6b9a3b1eda82abcbfc58e9c6 (patch)
tree0a1197ee42f2ffb49faa2c29c5aea5b0d42b791e
parent7d55b028f277fb5598da40e7ae8167ba0a4218a7 (diff)
downloadVeraCrypt-d31466ae7a55668a6b9a3b1eda82abcbfc58e9c6.tar.gz
VeraCrypt-d31466ae7a55668a6b9a3b1eda82abcbfc58e9c6.zip
Windows: If PIM of a volume is changed and if it is a favorite or system favorite, automatically update favorite or system favorite XML file with the new value.
-rw-r--r--src/Common/Language.xml3
-rw-r--r--src/Mount/Favorites.cpp2
-rw-r--r--src/Mount/Favorites.h3
-rw-r--r--src/Mount/Mount.c56
4 files changed, 58 insertions, 6 deletions
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 8de941b7..95446ded 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -587,7 +587,8 @@
<string lang="en" key="IDD_PCDM_CHANGE_PKCS5_PRF">Set Header Key Derivation Algorithm</string>
<string lang="en" key="IDD_PCDM_ADD_REMOVE_VOL_KEYFILES">Add/Remove Keyfiles to/from Volume</string>
<string lang="en" key="IDD_PCDM_REMOVE_ALL_KEYFILES_FROM_VOL">Remove All Keyfiles from Volume</string>
- <string lang="en" key="PASSWORD_CHANGED">Password and/or keyfile(s) successfully changed.\n\nIMPORTANT: Please make sure you have read the section 'Changing Passwords and Keyfiles' in the chapter 'Security Requirements and Precautions' in the VeraCrypt User Guide.</string>
+ <string lang="en" key="PASSWORD_CHANGED">Password, PIM and/or keyfile(s) successfully changed.\n\nIMPORTANT: Please make sure you have read the section 'Changing Passwords and Keyfiles' in the chapter 'Security Requirements and Precautions' in the VeraCrypt User Guide.</string>
+ <string lang="en" key="FAVORITE_PIM_CHANGED">This volume is registered as a System Favorite and its PIM was changed.\nDo you want VeraCrypt to automatically update the System Favorite configuration (administrator privileges required)?\n\nPlease note that if you answer no, you'll have to update the System Favorite manually.</string>
<string lang="en" key="SYS_PASSWORD_CHANGED_ASK_RESCUE_DISK">IMPORTANT: If you did not destroy your VeraCrypt Rescue Disk, your system partition/drive can still be decrypted using the old password (by booting the VeraCrypt Rescue Disk and entering the old password). You should create a new VeraCrypt Rescue Disk and then destroy the old one.\n\nDo you want to create a new VeraCrypt Rescue Disk?</string>
<string lang="en" key="SYS_HKD_ALGO_CHANGED_ASK_RESCUE_DISK">Note that your VeraCrypt Rescue Disk still uses the previous algorithm. If you consider the previous algorithm insecure, you should create a new VeraCrypt Rescue Disk and then destroy the old one.\n\nDo you want to create a new VeraCrypt Rescue Disk?</string>
<string lang="en" key="KEYFILES_NOTE">Any kind of file (for example, .mp3, .jpg, .zip, .avi) may be used as a VeraCrypt keyfile. Note that VeraCrypt never modifies the keyfile contents. You can select more than one keyfile (the order does not matter). If you add a folder, all non-hidden files found in it will be used as keyfiles. Click 'Add Token Files' to select keyfiles stored on security tokens or smart cards (or to import keyfiles to security tokens or smart cards).</string>
diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp
index 382b238d..50842a35 100644
--- a/src/Mount/Favorites.cpp
+++ b/src/Mount/Favorites.cpp
@@ -659,7 +659,7 @@ namespace VeraCrypt
}
- static bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites)
+ bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites)
{
FILE *f;
int cnt = 0;
diff --git a/src/Mount/Favorites.h b/src/Mount/Favorites.h
index 3a0a771b..5d823ccd 100644
--- a/src/Mount/Favorites.h
+++ b/src/Mount/Favorites.h
@@ -53,6 +53,7 @@ namespace VeraCrypt
};
extern vector <FavoriteVolume> FavoriteVolumes;
+ extern vector <FavoriteVolume> SystemFavoriteVolumes;
extern list <FavoriteVolume> FavoritesOnArrivalMountRequired;
extern list <FavoriteVolume> FavoritesMountedOnArrivalStillConnected;
extern HMENU FavoriteVolumesMenu;
@@ -67,7 +68,7 @@ namespace VeraCrypt
void LoadFavoriteVolumes (vector <FavoriteVolume> &favorites, bool systemFavorites, bool noUacElevation = false);
static void OnFavoriteVolumesUpdated ();
BOOL OrganizeFavoriteVolumes (HWND hwndDlg, bool systemFavorites, const FavoriteVolume &newFavorite = FavoriteVolume());
- static bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites);
+ bool SaveFavoriteVolumes (HWND hwndDlg, const vector <FavoriteVolume> &favorites, bool systemFavorites);
static void SetControls (HWND hwndDlg, const FavoriteVolume &favorite, bool systemFavoritesMode, bool enable = true);
static void SetFavoriteVolume (HWND hwndDlg, FavoriteVolume &favorite, bool systemFavoritesMode);
void UpdateDeviceHostedFavoriteVolumes ();
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c
index 88dbfa5d..d5521725 100644
--- a/src/Mount/Mount.c
+++ b/src/Mount/Mount.c
@@ -1787,6 +1787,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
{
static KeyFilesDlgParam newKeyFilesParam;
static BOOL PinValueChangedWarning = FALSE;
+ static int* NewPimValuePtr = NULL;
WORD lw = LOWORD (wParam);
WORD hw = HIWORD (wParam);
@@ -1800,6 +1801,8 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
int i;
WipeAlgorithmId headerWipeMode = TC_WIPE_3_DOD_5220;
+ NewPimValuePtr = (int*) lParam;
+
PinValueChangedWarning = FALSE;
ZeroMemory (&newKeyFilesParam, sizeof (newKeyFilesParam));
@@ -2337,6 +2340,15 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR
ShowWaitDialog(hwndDlg, TRUE, ChangePwdWaitThreadProc, &changePwdParam);
err:
+ // notify the caller in case the PIM has changed
+ if (NewPimValuePtr)
+ {
+ if (pin != old_pin)
+ *NewPimValuePtr = pin;
+ else
+ *NewPimValuePtr = -1;
+ }
+
burn (&oldPassword, sizeof (oldPassword));
burn (&newPassword, sizeof (newPassword));
burn (&old_pin, sizeof(old_pin));
@@ -4691,6 +4703,7 @@ static BOOL MountAllDevices (HWND hwndDlg, BOOL bPasswordPrompt)
static void ChangePassword (HWND hwndDlg)
{
INT_PTR result;
+ int newPimValue = -1;
GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, sizeof (szFileName));
if (IsMountedVolume (szFileName))
@@ -4707,8 +4720,8 @@ static void ChangePassword (HWND hwndDlg)
bSysEncPwdChangeDlgMode = FALSE;
- result = DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_PASSWORDCHANGE_DLG), hwndDlg,
- (DLGPROC) PasswordChangeDlgProc);
+ result = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_PASSWORDCHANGE_DLG), hwndDlg,
+ (DLGPROC) PasswordChangeDlgProc, (LPARAM) &newPimValue);
if (result == IDOK)
{
@@ -4725,7 +4738,44 @@ static void ChangePassword (HWND hwndDlg)
case PCDM_CHANGE_PASSWORD:
default:
- Info ("PASSWORD_CHANGED", hwndDlg);
+ {
+ Info ("PASSWORD_CHANGED", hwndDlg);
+ if (newPimValue != -1)
+ {
+ // update the encoded volue in favorite XML if found
+ bool bFavoriteFound = false;
+ for (vector <FavoriteVolume>::iterator favorite = FavoriteVolumes.begin();
+ favorite != FavoriteVolumes.end(); favorite++)
+ {
+ if (favorite->Path == szFileName)
+ {
+ bFavoriteFound = true;
+ favorite->Pin = newPimValue;
+ SaveFavoriteVolumes (hwndDlg, FavoriteVolumes, false);
+ break;
+ }
+ }
+
+ if (!bFavoriteFound)
+ {
+ for (vector <FavoriteVolume>::iterator favorite = SystemFavoriteVolumes.begin();
+ favorite != SystemFavoriteVolumes.end(); favorite++)
+ {
+ if (favorite->Path == szFileName)
+ {
+ bFavoriteFound = true;
+ favorite->Pin = newPimValue;
+
+ if (AskYesNo("FAVORITE_PIM_CHANGED", hwndDlg) == IDYES)
+ {
+ SaveFavoriteVolumes (hwndDlg, SystemFavoriteVolumes, true);
+ }
+ break;
+ }
+ }
+ }
+ }
+ }
}
}
}