diff options
Diffstat (limited to 'src/Mount/Mount.c')
-rw-r--r-- | src/Mount/Mount.c | 74 |
1 files changed, 46 insertions, 28 deletions
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); |