diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-12-08 17:06:52 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-12-08 17:53:28 +0100 |
commit | 4262d4feb71aaade721ae5d06eec63ac07144a8f (patch) | |
tree | 2ea6df1dc4f31e7a6c11600b22f8e9a896b71b53 | |
parent | e131d7a6070bbeb6b406fbaa54f8528e0dcace89 (diff) | |
download | VeraCrypt-4262d4feb71aaade721ae5d06eec63ac07144a8f.tar.gz VeraCrypt-4262d4feb71aaade721ae5d06eec63ac07144a8f.zip |
Windows: Enhancement to favorites handling. Add PRF/TrueCryptMode fields in favorites management dialog, and use default mount parameters when mounting multiple favorites at once.
-rw-r--r-- | src/Common/Pkcs5.c | 25 | ||||
-rw-r--r-- | src/Common/Pkcs5.h | 10 | ||||
-rw-r--r-- | src/ExpandVolume/WinMain.cpp | 4 | ||||
-rw-r--r-- | src/Mount/Favorites.cpp | 84 | ||||
-rw-r--r-- | src/Mount/Favorites.h | 4 | ||||
-rw-r--r-- | src/Mount/Mount.c | 74 | ||||
-rw-r--r-- | src/Mount/Mount.rc | 17 |
7 files changed, 181 insertions, 37 deletions
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c index 753c49b4..1da5e237 100644 --- a/src/Common/Pkcs5.c +++ b/src/Common/Pkcs5.c | |||
@@ -1209,4 +1209,29 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BO | |||
1209 | return 0; | 1209 | return 0; |
1210 | } | 1210 | } |
1211 | 1211 | ||
1212 | int is_pkcs5_prf_supported (int pkcs5_prf_id, BOOL truecryptMode, PRF_BOOT_TYPE bootType) | ||
1213 | { | ||
1214 | if (pkcs5_prf_id == 0) // auto-detection always supported | ||
1215 | return 1; | ||
1216 | |||
1217 | if (truecryptMode) | ||
1218 | { | ||
1219 | if ( (bootType == PRF_BOOT_GPT) | ||
1220 | || (bootType == PRF_BOOT_MBR && pkcs5_prf_id != RIPEMD160) | ||
1221 | || (bootType == PRF_BOOT_NO && pkcs5_prf_id != SHA512 && pkcs5_prf_id != WHIRLPOOL && pkcs5_prf_id != RIPEMD160) | ||
1222 | ) | ||
1223 | return 0; | ||
1224 | } | ||
1225 | else | ||
1226 | { | ||
1227 | if ( (bootType == PRF_BOOT_MBR && pkcs5_prf_id != RIPEMD160 && pkcs5_prf_id != SHA256) | ||
1228 | || (bootType != PRF_BOOT_MBR && (pkcs5_prf_id < FIRST_PRF_ID || pkcs5_prf_id > LAST_PRF_ID)) | ||
1229 | ) | ||
1230 | return 0; | ||
1231 | } | ||
1232 | |||
1233 | return 1; | ||
1234 | |||
1235 | } | ||
1236 | |||
1212 | #endif //!TC_WINDOWS_BOOT | 1237 | #endif //!TC_WINDOWS_BOOT |
diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h index 261df85d..2758bdf6 100644 --- a/src/Common/Pkcs5.h +++ b/src/Common/Pkcs5.h | |||
@@ -42,6 +42,16 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint | |||
42 | 42 | ||
43 | int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BOOL bBoot); | 43 | int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BOOL bBoot); |
44 | wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id); | 44 | wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id); |
45 | |||
46 | /* check if given PRF supported.*/ | ||
47 | typedef enum | ||
48 | { | ||
49 | PRF_BOOT_NO = 0, | ||
50 | PRF_BOOT_MBR, | ||
51 | PRF_BOOT_GPT | ||
52 | } PRF_BOOT_TYPE; | ||
53 | |||
54 | int is_pkcs5_prf_supported (int pkcs5_prf_id, BOOL truecryptMode, PRF_BOOT_TYPE bootType); | ||
45 | #endif | 55 | #endif |
46 | 56 | ||
47 | #if defined(__cplusplus) | 57 | #if defined(__cplusplus) |
diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp index 42aa6a70..3172a45f 100644 --- a/src/ExpandVolume/WinMain.cpp +++ b/src/ExpandVolume/WinMain.cpp | |||
@@ -686,9 +686,9 @@ BOOL CALLBACK ExtcvPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARA | |||
686 | 686 | ||
687 | *pim = GetPim (hwndDlg, IDC_PIM); | 687 | *pim = GetPim (hwndDlg, IDC_PIM); |
688 | 688 | ||
689 | /* SHA-256 is not supported by TrueCrypt */ | 689 | /* check that PRF is supported in TrueCrypt Mode */ |
690 | if ( (*truecryptMode) | 690 | if ( (*truecryptMode) |
691 | && ((*pkcs5 == SHA256) || (mountOptions.ProtectHiddenVolume && mountOptions.ProtectedHidVolPkcs5Prf == SHA256)) | 691 | && ((!is_pkcs5_prf_supported(*pkcs5, TRUE, PRF_BOOT_NO)) || (mountOptions.ProtectHiddenVolume && !is_pkcs5_prf_supported(mountOptions.ProtectedHidVolPkcs5Prf, TRUE, PRF_BOOT_NO))) |
692 | ) | 692 | ) |
693 | { | 693 | { |
694 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | 694 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); |
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 @@ | |||
21 | #include "Resource.h" | 21 | #include "Resource.h" |
22 | #include "Xml.h" | 22 | #include "Xml.h" |
23 | #include "Favorites.h" | 23 | #include "Favorites.h" |
24 | #include "Pkcs5.h" | ||
24 | 25 | ||
25 | using namespace std; | 26 | using namespace std; |
26 | 27 | ||
@@ -98,6 +99,8 @@ namespace VeraCrypt | |||
98 | favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false; | 99 | favorite.SystemEncryption = prop.partitionInInactiveSysEncScope ? true : false; |
99 | favorite.OpenExplorerWindow = (bExplore == TRUE); | 100 | favorite.OpenExplorerWindow = (bExplore == TRUE); |
100 | favorite.Pim = prop.volumePim; | 101 | favorite.Pim = prop.volumePim; |
102 | favorite.Pkcs5 = prop.pkcs5; | ||
103 | favorite.TrueCryptMode = (prop.pkcs5Iterations == get_pkcs5_iteration_count(prop.pkcs5, 0, TRUE, prop.partitionInInactiveSysEncScope))? 1 : 0; | ||
101 | memcpy (favorite.VolumeID, prop.volumeID, VOLUME_ID_SIZE); | 104 | memcpy (favorite.VolumeID, prop.volumeID, VOLUME_ID_SIZE); |
102 | 105 | ||
103 | if (favorite.VolumePathId.empty() | 106 | if (favorite.VolumePathId.empty() |
@@ -669,6 +672,30 @@ namespace VeraCrypt | |||
669 | favorite.DisconnectedDevice = true; | 672 | favorite.DisconnectedDevice = true; |
670 | } | 673 | } |
671 | 674 | ||
675 | XmlGetAttributeText (xml, "TrueCryptMode", boolVal, sizeof (boolVal)); | ||
676 | if (boolVal[0]) | ||
677 | favorite.TrueCryptMode = (boolVal[0] == '1')? 1 : 0; | ||
678 | else | ||
679 | favorite.TrueCryptMode = -1; | ||
680 | |||
681 | if (favorite.TrueCryptMode) | ||
682 | favorite.Pim = 0; | ||
683 | |||
684 | XmlGetAttributeText (xml, "pkcs5", label, sizeof (label)); | ||
685 | if (label[0]) | ||
686 | favorite.Pkcs5 = strtol (label, NULL, 10); | ||
687 | else | ||
688 | favorite.Pkcs5 = -1; | ||
689 | if ( (favorite.Pkcs5 != -1) | ||
690 | && ( (favorite.Pkcs5 < FIRST_PRF_ID) | ||
691 | || (favorite.Pkcs5 > LAST_PRF_ID) | ||
692 | || (favorite.TrueCryptMode == 1 && (0 == get_pkcs5_iteration_count (favorite.Pkcs5, 0, TRUE, favorite.SystemEncryption? TRUE : FALSE))) | ||
693 | ) | ||
694 | ) | ||
695 | { | ||
696 | favorite.Pkcs5 = -1; | ||
697 | } | ||
698 | |||
672 | favorites.push_back (favorite); | 699 | favorites.push_back (favorite); |
673 | xml++; | 700 | xml++; |
674 | } | 701 | } |
@@ -762,6 +789,14 @@ namespace VeraCrypt | |||
762 | if (favorite.Pim > 0) | 789 | if (favorite.Pim > 0) |
763 | s += L" pim=\"" + IntToWideString(favorite.Pim) + L"\""; | 790 | s += L" pim=\"" + IntToWideString(favorite.Pim) + L"\""; |
764 | 791 | ||
792 | if (favorite.Pkcs5 > 0) | ||
793 | s += L" pkcs5=\"" + IntToWideString(favorite.Pkcs5) + L"\""; | ||
794 | |||
795 | if (favorite.TrueCryptMode > 0) | ||
796 | s += L" TrueCryptMode=\"1\""; | ||
797 | else if (favorite.TrueCryptMode == 0) | ||
798 | s += L" TrueCryptMode=\"0\""; | ||
799 | |||
765 | if (favorite.ReadOnly) | 800 | if (favorite.ReadOnly) |
766 | s += L" readonly=\"1\""; | 801 | s += L" readonly=\"1\""; |
767 | 802 | ||
@@ -871,6 +906,29 @@ namespace VeraCrypt | |||
871 | SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly); | 906 | SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_READONLY, favorite.ReadOnly); |
872 | SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE, favorite.Removable); | 907 | SetCheckBox (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE, favorite.Removable); |
873 | SetCheckBox (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID, favorite.UseVolumeID && bIsDevice); | 908 | SetCheckBox (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID, favorite.UseVolumeID && bIsDevice); |
909 | SetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE, (favorite.TrueCryptMode > 0)? TRUE : FALSE); | ||
910 | |||
911 | /* Populate the PRF algorithms list */ | ||
912 | int nIndex, i, nSelected = 0; | ||
913 | HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID); | ||
914 | SendMessage (hComboBox, CB_RESETCONTENT, 0, 0); | ||
915 | |||
916 | nIndex = (int) SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION")); | ||
917 | SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0); | ||
918 | |||
919 | for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++) | ||
920 | { | ||
921 | if (!favorite.SystemEncryption || (favorite.TrueCryptMode != 1) || (i == RIPEMD160)) | ||
922 | { | ||
923 | nIndex = (int) SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i)); | ||
924 | SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i); | ||
925 | if (favorite.Pkcs5 == i) | ||
926 | nSelected = nIndex; | ||
927 | } | ||
928 | } | ||
929 | |||
930 | if (favorite.Pkcs5 >= 0) | ||
931 | SendMessage (hComboBox, CB_SETCURSEL, nSelected, 0); | ||
874 | 932 | ||
875 | if (IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)) || !bIsDevice) | 933 | if (IsRepeatedByteArray (0, favorite.VolumeID, sizeof (favorite.VolumeID)) || !bIsDevice) |
876 | { | 934 | { |
@@ -898,6 +956,9 @@ namespace VeraCrypt | |||
898 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_UP), enable); | 956 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_UP), enable); |
899 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_DOWN), enable); | 957 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_MOVE_DOWN), enable); |
900 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_REMOVE), enable); | 958 | EnableWindow (GetDlgItem (hwndDlg, IDC_FAVORITE_REMOVE), enable); |
959 | EnableWindow (GetDlgItem (hwndDlg, IDT_PKCS5_PRF), enable && !favorite.SystemEncryption); | ||
960 | EnableWindow (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), enable && !favorite.SystemEncryption); | ||
961 | EnableWindow (GetDlgItem (hwndDlg, IDC_TRUECRYPT_MODE), enable && !favorite.SystemEncryption); | ||
901 | EnableWindow (GetDlgItem (hwndDlg, IDT_PIM), enable); | 962 | EnableWindow (GetDlgItem (hwndDlg, IDT_PIM), enable); |
902 | EnableWindow (GetDlgItem (hwndDlg, IDC_PIM), enable); | 963 | EnableWindow (GetDlgItem (hwndDlg, IDC_PIM), enable); |
903 | EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PIM), enable); | 964 | EnableWindow (GetDlgItem (hwndDlg, IDC_SHOW_PIM), enable); |
@@ -971,6 +1032,29 @@ namespace VeraCrypt | |||
971 | favorite.Pim = GetPim (hwndDlg, IDC_PIM); | 1032 | favorite.Pim = GetPim (hwndDlg, IDC_PIM); |
972 | favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0); | 1033 | favorite.UseLabelInExplorer = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_LABEL_IN_EXPLORER) != 0); |
973 | favorite.UseVolumeID = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID) != 0); | 1034 | favorite.UseVolumeID = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_USE_VOLUME_ID) != 0); |
1035 | int nSelected = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0); | ||
1036 | if (nSelected != CB_ERR) | ||
1037 | favorite.Pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, nSelected, 0); | ||
1038 | else | ||
1039 | favorite.Pkcs5 = -1; | ||
1040 | BOOL selectedTrueCryptMode = (IsDlgButtonChecked (hwndDlg, IDC_TRUECRYPT_MODE) != 0)? 1 : 0; | ||
1041 | if ((favorite.TrueCryptMode >= 0) || selectedTrueCryptMode) | ||
1042 | favorite.TrueCryptMode = selectedTrueCryptMode; | ||
1043 | |||
1044 | if (favorite.TrueCryptMode == 1) | ||
1045 | { | ||
1046 | if ((favorite.Pkcs5 > 0) && !is_pkcs5_prf_supported (favorite.Pkcs5, TRUE, favorite.SystemEncryption? PRF_BOOT_MBR : PRF_BOOT_NO)) | ||
1047 | { | ||
1048 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | ||
1049 | favorite.Pkcs5 = 0; | ||
1050 | } | ||
1051 | |||
1052 | if (favorite.Pim > 0) | ||
1053 | { | ||
1054 | Error ("PIM_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | ||
1055 | favorite.Pim = 0; | ||
1056 | } | ||
1057 | } | ||
974 | 1058 | ||
975 | favorite.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0); | 1059 | favorite.ReadOnly = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_READONLY) != 0); |
976 | favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0); | 1060 | favorite.Removable = (IsDlgButtonChecked (hwndDlg, IDC_FAVORITE_MOUNT_REMOVABLE) != 0); |
diff --git a/src/Mount/Favorites.h b/src/Mount/Favorites.h index acb9c8d4..6c75590b 100644 --- a/src/Mount/Favorites.h +++ b/src/Mount/Favorites.h | |||
@@ -22,6 +22,8 @@ namespace VeraCrypt | |||
22 | FavoriteVolume() | 22 | FavoriteVolume() |
23 | : | 23 | : |
24 | Pim (0), | 24 | Pim (0), |
25 | Pkcs5 (-1), | ||
26 | TrueCryptMode (-1), | ||
25 | DisableHotkeyMount (false), | 27 | DisableHotkeyMount (false), |
26 | DisconnectedDevice (false), | 28 | DisconnectedDevice (false), |
27 | MountOnLogOn (false), | 29 | MountOnLogOn (false), |
@@ -41,6 +43,8 @@ namespace VeraCrypt | |||
41 | wstring VolumePathId; | 43 | wstring VolumePathId; |
42 | wstring Label; | 44 | wstring Label; |
43 | int Pim; | 45 | int Pim; |
46 | int Pkcs5; | ||
47 | int TrueCryptMode; | ||
44 | BYTE VolumeID[VOLUME_ID_SIZE]; | 48 | BYTE VolumeID[VOLUME_ID_SIZE]; |
45 | 49 | ||
46 | bool DisableHotkeyMount; | 50 | bool DisableHotkeyMount; |
diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index fe4d5605..265f651a 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c | |||
@@ -2506,7 +2506,7 @@ BOOL CALLBACK PasswordChangeDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPAR | |||
2506 | int old_pim = GetPim (hwndDlg, IDC_OLD_PIM); | 2506 | int old_pim = GetPim (hwndDlg, IDC_OLD_PIM); |
2507 | int pim = GetPim (hwndDlg, IDC_PIM); | 2507 | int pim = GetPim (hwndDlg, IDC_PIM); |
2508 | 2508 | ||
2509 | if (truecryptMode && (old_pkcs5 == SHA256)) | 2509 | if (truecryptMode && !is_pkcs5_prf_supported (old_pkcs5, TRUE, PRF_BOOT_NO)) |
2510 | { | 2510 | { |
2511 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | 2511 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); |
2512 | return 1; | 2512 | return 1; |
@@ -2973,9 +2973,9 @@ BOOL CALLBACK PasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa | |||
2973 | 2973 | ||
2974 | *pim = GetPim (hwndDlg, IDC_PIM); | 2974 | *pim = GetPim (hwndDlg, IDC_PIM); |
2975 | 2975 | ||
2976 | /* SHA-256 is not supported by TrueCrypt */ | 2976 | /* check that PRF is supported in TrueCrypt Mode */ |
2977 | if ( (*truecryptMode) | 2977 | if ( (*truecryptMode) |
2978 | && ((*pkcs5 == SHA256) || (mountOptions.ProtectHiddenVolume && mountOptions.ProtectedHidVolPkcs5Prf == SHA256)) | 2978 | && ((!is_pkcs5_prf_supported (*pkcs5, TRUE, PRF_BOOT_NO)) || (mountOptions.ProtectHiddenVolume && !is_pkcs5_prf_supported (mountOptions.ProtectedHidVolPkcs5Prf, TRUE, PRF_BOOT_NO))) |
2979 | ) | 2979 | ) |
2980 | { | 2980 | { |
2981 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | 2981 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); |
@@ -4556,25 +4556,44 @@ static int AskVolumePassword (HWND hwndDlg, Password *password, int *pkcs5, int | |||
4556 | 4556 | ||
4557 | // GUI actions | 4557 | // GUI actions |
4558 | 4558 | ||
4559 | static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim) | 4559 | static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim, int pkcs5, int trueCryptMode) |
4560 | { | 4560 | { |
4561 | BOOL status = FALSE; | 4561 | BOOL status = FALSE; |
4562 | wchar_t fileName[MAX_PATH]; | 4562 | wchar_t fileName[MAX_PATH]; |
4563 | int mounted = 0, EffectiveVolumePkcs5 = CmdVolumePkcs5; | 4563 | int mounted = 0, EffectiveVolumePkcs5 = 0; |
4564 | BOOL EffectiveVolumeTrueCryptMode = CmdVolumeTrueCryptMode; | 4564 | BOOL EffectiveVolumeTrueCryptMode = FALSE; |
4565 | int EffectiveVolumePim = (pim < 0)? CmdVolumePim : pim; | 4565 | int EffectiveVolumePim = (pim < 0)? CmdVolumePim : pim; |
4566 | BOOL bEffectiveCacheDuringMultipleMount = bCmdCacheDuringMultipleMount? TRUE: bCacheDuringMultipleMount; | 4566 | BOOL bEffectiveCacheDuringMultipleMount = bCmdCacheDuringMultipleMount? TRUE: bCacheDuringMultipleMount; |
4567 | BOOL bEffectiveTryEmptyPasswordWhenKeyfileUsed = bCmdTryEmptyPasswordWhenKeyfileUsedValid? bCmdTryEmptyPasswordWhenKeyfileUsed : bTryEmptyPasswordWhenKeyfileUsed; | 4567 | BOOL bEffectiveTryEmptyPasswordWhenKeyfileUsed = bCmdTryEmptyPasswordWhenKeyfileUsedValid? bCmdTryEmptyPasswordWhenKeyfileUsed : bTryEmptyPasswordWhenKeyfileUsed; |
4568 | BOOL bUseCmdVolumePassword = CmdVolumePasswordValid && ((CmdVolumePassword.Length > 0) || (KeyFilesEnable && FirstKeyFile)); | 4568 | BOOL bUseCmdVolumePassword = CmdVolumePasswordValid && ((CmdVolumePassword.Length > 0) || (KeyFilesEnable && FirstKeyFile)); |
4569 | 4569 | ||
4570 | /* Priority is given to command line parameters | 4570 | /* Priority is given to arguments and command line parameters |
4571 | * Default values used only when nothing specified in command line | 4571 | * Default values used only when nothing specified |
4572 | */ | 4572 | */ |
4573 | if (EffectiveVolumePkcs5 == 0) | 4573 | if (pkcs5 > 0) |
4574 | EffectiveVolumePkcs5 = pkcs5; | ||
4575 | else if (CmdVolumePkcs5 > 0) | ||
4576 | EffectiveVolumePkcs5 = CmdVolumePkcs5; | ||
4577 | else | ||
4574 | EffectiveVolumePkcs5 = DefaultVolumePkcs5; | 4578 | EffectiveVolumePkcs5 = DefaultVolumePkcs5; |
4575 | if (!EffectiveVolumeTrueCryptMode) | 4579 | |
4580 | if (trueCryptMode >= 0) | ||
4581 | EffectiveVolumeTrueCryptMode = (trueCryptMode == 0)? FALSE : TRUE; | ||
4582 | else if (CmdVolumeTrueCryptMode) | ||
4583 | EffectiveVolumeTrueCryptMode = TRUE; | ||
4584 | else | ||
4576 | EffectiveVolumeTrueCryptMode = DefaultVolumeTrueCryptMode; | 4585 | EffectiveVolumeTrueCryptMode = DefaultVolumeTrueCryptMode; |
4577 | 4586 | ||
4587 | if (EffectiveVolumeTrueCryptMode) | ||
4588 | { | ||
4589 | /* No PIM Mode if TrueCrypt Mode specified */ | ||
4590 | EffectiveVolumePim = 0; | ||
4591 | |||
4592 | /* valdate the effective PRF is compatible with TrueCrypt Mode */ | ||
4593 | if (!is_pkcs5_prf_supported (EffectiveVolumePkcs5, TRUE, mountOptions.PartitionInInactiveSysEncScope? PRF_BOOT_MBR : PRF_BOOT_NO)) | ||
4594 | EffectiveVolumePkcs5 = 0; | ||
4595 | } | ||
4596 | |||
4578 | bPrebootPasswordDlgMode = mountOptions.PartitionInInactiveSysEncScope; | 4597 | bPrebootPasswordDlgMode = mountOptions.PartitionInInactiveSysEncScope; |
4579 | 4598 | ||
4580 | if (nDosDriveNo == -1) | 4599 | if (nDosDriveNo == -1) |
@@ -4632,11 +4651,10 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim) | |||
4632 | if (!bUseCmdVolumePassword) | 4651 | if (!bUseCmdVolumePassword) |
4633 | { | 4652 | { |
4634 | // First try cached passwords and if they fail ask user for a new one | 4653 | // First try cached passwords and if they fail ask user for a new one |
4635 | // try TrueCrypt mode first since it is quick, only if no custom pim specified | 4654 | if (EffectiveVolumeTrueCryptMode) |
4636 | if (EffectiveVolumePim <= 0) | 4655 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, EffectiveVolumePkcs5, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4637 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | 4656 | else |
4638 | if (!mounted) | 4657 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, EffectiveVolumePkcs5, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4639 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, NULL, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | ||
4640 | 4658 | ||
4641 | // If keyfiles are enabled, test empty password first | 4659 | // If keyfiles are enabled, test empty password first |
4642 | if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed) | 4660 | if (!mounted && KeyFilesEnable && FirstKeyFile && bEffectiveTryEmptyPasswordWhenKeyfileUsed) |
@@ -4644,11 +4662,11 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim) | |||
4644 | Password emptyPassword = {0}; | 4662 | Password emptyPassword = {0}; |
4645 | 4663 | ||
4646 | KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName); | 4664 | KeyFilesApply (hwndDlg, &emptyPassword, FirstKeyFile, szFileName); |
4647 | // try TrueCrypt mode first since it is quick, only if no custom pim specified | 4665 | |
4648 | if (EffectiveVolumePim <= 0) | 4666 | if (EffectiveVolumeTrueCryptMode) |
4649 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | 4667 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, EffectiveVolumePkcs5, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4650 | if (!mounted) | 4668 | else |
4651 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | 4669 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &emptyPassword, EffectiveVolumePkcs5, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4652 | 4670 | ||
4653 | burn (&emptyPassword, sizeof (emptyPassword)); | 4671 | burn (&emptyPassword, sizeof (emptyPassword)); |
4654 | } | 4672 | } |
@@ -4658,10 +4676,10 @@ static BOOL Mount (HWND hwndDlg, int nDosDriveNo, wchar_t *szFileName, int pim) | |||
4658 | if (!mounted && bEffectiveCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0) | 4676 | if (!mounted && bEffectiveCacheDuringMultipleMount && MultipleMountOperationInProgress && VolumePassword.Length != 0) |
4659 | { | 4677 | { |
4660 | // try TrueCrypt mode first as it is quick, only if no custom pim specified | 4678 | // try TrueCrypt mode first as it is quick, only if no custom pim specified |
4661 | if (EffectiveVolumePim <= 0) | 4679 | if (EffectiveVolumeTrueCryptMode) |
4662 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, 0, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | 4680 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, 0, TRUE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4663 | if (!mounted) | 4681 | else |
4664 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, 0, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); | 4682 | mounted = MountVolume (hwndDlg, nDosDriveNo, szFileName, &VolumePassword, EffectiveVolumePkcs5, EffectiveVolumePim, FALSE, bCacheInDriver, bIncludePimInCache, bForceMount, &mountOptions, Silent, FALSE); |
4665 | } | 4683 | } |
4666 | 4684 | ||
4667 | NormalCursor (); | 4685 | NormalCursor (); |
@@ -4811,7 +4829,7 @@ void __cdecl mountThreadFunction (void *hwndDlgArg) | |||
4811 | EnableWindow(hwndDlg, FALSE); | 4829 | EnableWindow(hwndDlg, FALSE); |
4812 | finally_do_arg2 (HWND, hwndDlg, BOOL, bIsForeground, { EnableWindow(finally_arg, TRUE); if (finally_arg2) BringToForeground (finally_arg); bPrebootPasswordDlgMode = FALSE;}); | 4830 | finally_do_arg2 (HWND, hwndDlg, BOOL, bIsForeground, { EnableWindow(finally_arg, TRUE); if (finally_arg2) BringToForeground (finally_arg); bPrebootPasswordDlgMode = FALSE;}); |
4813 | 4831 | ||
4814 | Mount (hwndDlg, -1, 0, -1); | 4832 | Mount (hwndDlg, -1, 0, -1, -1, -1); |
4815 | } | 4833 | } |
4816 | 4834 | ||
4817 | typedef struct | 4835 | typedef struct |
@@ -9283,7 +9301,7 @@ static BOOL MountFavoriteVolumeBase (HWND hwnd, const FavoriteVolume &favorite, | |||
9283 | if (ServiceMode) | 9301 | if (ServiceMode) |
9284 | SystemFavoritesServiceLogInfo (wstring (L"Mounting system favorite \"") + effectiveVolumePath + L"\""); | 9302 | SystemFavoritesServiceLogInfo (wstring (L"Mounting system favorite \"") + effectiveVolumePath + L"\""); |
9285 | 9303 | ||
9286 | status = Mount (hwnd, drive, (wchar_t *) effectiveVolumePath.c_str(), favorite.Pim); | 9304 | status = Mount (hwnd, drive, (wchar_t *) effectiveVolumePath.c_str(), favorite.Pim, favorite.Pkcs5, favorite.TrueCryptMode); |
9287 | 9305 | ||
9288 | if (ServiceMode) | 9306 | if (ServiceMode) |
9289 | { | 9307 | { |
@@ -10785,9 +10803,9 @@ static BOOL CALLBACK DefaultMountParametersDlgProc (HWND hwndDlg, UINT msg, WPAR | |||
10785 | { | 10803 | { |
10786 | int pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0); | 10804 | int pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0); |
10787 | BOOL truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE); | 10805 | BOOL truecryptMode = GetCheckBox (hwndDlg, IDC_TRUECRYPT_MODE); |
10788 | /* SHA-256 is not supported by TrueCrypt */ | 10806 | /* check that PRF is supported in TrueCrypt Mode */ |
10789 | if ( (truecryptMode) | 10807 | if ( (truecryptMode) |
10790 | && (pkcs5 == SHA256) | 10808 | && (!is_pkcs5_prf_supported(pkcs5, TRUE, PRF_BOOT_NO)) |
10791 | ) | 10809 | ) |
10792 | { | 10810 | { |
10793 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); | 10811 | Error ("ALGO_NOT_SUPPORTED_FOR_TRUECRYPT_MODE", hwndDlg); |
diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index 26050225..8a056c0c 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc | |||
@@ -355,16 +355,19 @@ BEGIN | |||
355 | GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,123,366,219 | 355 | GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,123,366,219 |
356 | LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,215,202,8 | 356 | LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,215,202,8 |
357 | GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,300,366,42 | 357 | GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,300,366,42 |
358 | EDITTEXT IDC_PIM,18,183,42,13,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | 358 | EDITTEXT IDC_PIM,87,183,42,13,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER |
359 | LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,64,185,189,8 | 359 | LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,135,186,189,8 |
360 | LTEXT "Volume PIM:",IDT_PIM,18,173,65,8 | 360 | LTEXT "Volume PIM:",IDT_PIM,18,185,65,8 |
361 | CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,199,150,10 | 361 | CONTROL "Display PIM",IDC_SHOW_PIM,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,200,150,10 |
362 | CONTROL "Use favorite label as Explorer drive label",IDC_FAVORITE_USE_LABEL_IN_EXPLORER, | 362 | CONTROL "Use favorite label as Explorer drive label",IDC_FAVORITE_USE_LABEL_IN_EXPLORER, |
363 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,242,349,10 | 363 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,242,349,10 |
364 | LTEXT "Volume ID:",IDT_VOLUME_ID,18,131,57,8 | 364 | LTEXT "Volume ID:",IDT_VOLUME_ID,18,132,62,8 |
365 | EDITTEXT IDC_FAVORITE_VOLUME_ID,18,141,344,14,ES_AUTOHSCROLL | ES_READONLY | 365 | EDITTEXT IDC_FAVORITE_VOLUME_ID,87,130,275,14,ES_AUTOHSCROLL | ES_READONLY |
366 | CONTROL "Use Volume ID to mount favorite",IDC_FAVORITE_USE_VOLUME_ID, | 366 | CONTROL "Use Volume ID to mount favorite",IDC_FAVORITE_USE_VOLUME_ID, |
367 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,159,337,10 | 367 | "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,148,337,10 |
368 | COMBOBOX IDC_PKCS5_PRF_ID,87,166,96,90,CBS_DROPDOWNLIST | WS_TABSTOP | ||
369 | CONTROL "TrueCrypt Mode",IDC_TRUECRYPT_MODE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,189,168,76,10 | ||
370 | LTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,19,168,63,10 | ||
368 | END | 371 | END |
369 | 372 | ||
370 | IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65 | 373 | IDD_DEFAULT_MOUNT_PARAMETERS DIALOGEX 0, 0, 167, 65 |