mirror of
https://github.com/veracrypt/VeraCrypt.git
synced 2025-11-12 19:38:26 -06:00
Windows: Enhance performance by implementing the possibility to choose the correct hash algorithm of volumes during various operations (mount, change password...). In case of system encryption, slightly speedup Windows startup time by making the driver pickup the correct hash algorithm used for the encryption.
This commit is contained in:
@@ -548,7 +548,7 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol
|
||||
|
||||
/* Now we will try to decrypt the backup header to verify it has been correctly written. */
|
||||
|
||||
nStatus = OpenBackupHeader (dev, volParams->volumePath, volParams->password, &cryptoInfo2, NULL, deviceSize);
|
||||
nStatus = OpenBackupHeader (dev, volParams->volumePath, volParams->password, volParams->pkcs5,&cryptoInfo2, NULL, deviceSize);
|
||||
|
||||
if (nStatus != ERR_SUCCESS
|
||||
|| cryptoInfo->EncryptedAreaStart.Value != cryptoInfo2->EncryptedAreaStart.Value
|
||||
@@ -663,6 +663,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
||||
DWORD n;
|
||||
char *devicePath = volParams->volumePath;
|
||||
Password *password = volParams->password;
|
||||
int pkcs5_prf = volParams->pkcs5;
|
||||
DISK_GEOMETRY driveGeometry;
|
||||
|
||||
|
||||
@@ -755,7 +756,7 @@ int EncryptPartitionInPlaceResume (HANDLE dev,
|
||||
sectorSize = driveGeometry.BytesPerSector;
|
||||
|
||||
|
||||
nStatus = OpenBackupHeader (dev, devicePath, password, &masterCryptoInfo, headerCryptoInfo, deviceSize);
|
||||
nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, &masterCryptoInfo, headerCryptoInfo, deviceSize);
|
||||
|
||||
if (nStatus != ERR_SUCCESS)
|
||||
goto closing_seq;
|
||||
@@ -1504,7 +1505,7 @@ closing_seq:
|
||||
}
|
||||
|
||||
|
||||
static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
|
||||
static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, int pkcs5, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize)
|
||||
{
|
||||
LARGE_INTEGER offset;
|
||||
DWORD n;
|
||||
@@ -1530,7 +1531,7 @@ static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *passw
|
||||
}
|
||||
|
||||
|
||||
nStatus = ReadVolumeHeader (FALSE, header, password, retMasterCryptoInfo, headerCryptoInfo);
|
||||
nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, retMasterCryptoInfo, headerCryptoInfo);
|
||||
if (nStatus != ERR_SUCCESS)
|
||||
goto closing_seq;
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ static int ConcealNTFS (HANDLE dev);
|
||||
BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId wipeAlgorithm);
|
||||
static void ExportProgressStats (__int64 bytesDone, __int64 totalSize);
|
||||
int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount);
|
||||
static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
|
||||
static int OpenBackupHeader (HANDLE dev, const char *devicePath, Password *password, int pkcs5, PCRYPTO_INFO *retCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize);
|
||||
BOOL MoveClustersBeforeThreshold (HANDLE volumeHandle, PWSTR volumeDevicePath, int64 clusterThreshold);
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "Common/Dictionary.h"
|
||||
#include "Common/Endian.h"
|
||||
#include "Common/resource.h"
|
||||
#include "Common/Pkcs5.h"
|
||||
#include "Platform/Finally.h"
|
||||
#include "Platform/ForEach.h"
|
||||
#include "Random.h"
|
||||
@@ -223,6 +224,8 @@ Password volumePassword; /* User password */
|
||||
char szVerify[MAX_PASSWORD + 1]; /* Tmp password buffer */
|
||||
char szRawPassword[MAX_PASSWORD + 1]; /* Password before keyfile was applied to it */
|
||||
|
||||
int volumePkcs5Prf = 0;
|
||||
|
||||
BOOL bHistoryCmdLine = FALSE; /* History control is always disabled */
|
||||
BOOL ComServerMode = FALSE;
|
||||
|
||||
@@ -2414,7 +2417,7 @@ static void __cdecl volTransformThreadFunction (void *hwndDlgArg)
|
||||
if (bHiddenVolHost && !bVolTransformThreadCancel && nStatus == 0)
|
||||
{
|
||||
/* Auto mount the newly created hidden volume host */
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, FALSE))
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, FALSE))
|
||||
{
|
||||
case ERR_NO_FREE_DRIVES:
|
||||
MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
|
||||
@@ -3861,24 +3864,42 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
|
||||
case HIDDEN_VOL_HOST_PASSWORD_PAGE:
|
||||
case NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE:
|
||||
{
|
||||
/* Populate the PRF algorithms list */
|
||||
int nIndex, i;
|
||||
HWND hComboBox = GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID);
|
||||
SendMessage (hComboBox, CB_RESETCONTENT, 0, 0);
|
||||
|
||||
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), EM_LIMITTEXT, MAX_PASSWORD, 0);
|
||||
nIndex = SendMessageW (hComboBox, CB_ADDSTRING, 0, (LPARAM) GetString ("AUTODETECTION"));
|
||||
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) 0);
|
||||
|
||||
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), szRawPassword);
|
||||
for (i = FIRST_PRF_ID; i <= LAST_PRF_ID; i++)
|
||||
{
|
||||
nIndex = SendMessage (hComboBox, CB_ADDSTRING, 0, (LPARAM) get_pkcs5_prf_name(i));
|
||||
SendMessage (hComboBox, CB_SETITEMDATA, nIndex, (LPARAM) i);
|
||||
}
|
||||
|
||||
SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT));
|
||||
/* make autodetection the default */
|
||||
SendMessage (hComboBox, CB_SETCURSEL, 0, 0);
|
||||
|
||||
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
|
||||
SendMessage (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), EM_LIMITTEXT, MAX_PASSWORD, 0);
|
||||
|
||||
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE_HELP" : "PASSWORD_HIDDENVOL_HOST_DIRECT_HELP"));
|
||||
SetWindowText (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT), szRawPassword);
|
||||
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bInPlaceEncNonSys ? "PASSWORD" : "PASSWORD_HIDVOL_HOST_TITLE"));
|
||||
SetFocus (GetDlgItem (hwndDlg, IDC_PASSWORD_DIRECT));
|
||||
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
|
||||
SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, KeyFilesEnable);
|
||||
|
||||
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bInPlaceEncNonSys);
|
||||
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
|
||||
SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (bInPlaceEncNonSys ? "NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE_HELP" : "PASSWORD_HIDDENVOL_HOST_DIRECT_HELP"));
|
||||
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bInPlaceEncNonSys ? "PASSWORD" : "PASSWORD_HIDVOL_HOST_TITLE"));
|
||||
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT"));
|
||||
SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV"));
|
||||
|
||||
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), !bInPlaceEncNonSys);
|
||||
EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
@@ -6732,6 +6753,8 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
GetWindowText (GetDlgItem (hCurPage, IDC_PASSWORD_DIRECT), (char *) volumePassword.Text, sizeof (volumePassword.Text));
|
||||
volumePassword.Length = strlen ((char *) volumePassword.Text);
|
||||
|
||||
hash_algo = (int) SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hCurPage, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0);
|
||||
|
||||
// Store the password in case we need to restore it after keyfile is applied to it
|
||||
GetWindowText (GetDlgItem (hCurPage, IDC_PASSWORD_DIRECT), szRawPassword, sizeof (szRawPassword));
|
||||
|
||||
@@ -6769,7 +6792,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
|
||||
// Mount the hidden volume host as read-only (to ensure consistent and secure
|
||||
// results of the volume bitmap scanning)
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, TRUE))
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, TRUE))
|
||||
{
|
||||
case ERR_NO_FREE_DRIVES:
|
||||
NormalCursor ();
|
||||
@@ -6878,7 +6901,7 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa
|
||||
{
|
||||
OpenVolumeContext volume;
|
||||
|
||||
if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, FALSE, FALSE, TRUE) == ERR_SUCCESS)
|
||||
if (OpenVolume (&volume, device.Path.c_str(), &volumePassword, volumePkcs5Prf, FALSE, FALSE, TRUE) == ERR_SUCCESS)
|
||||
{
|
||||
if ((volume.CryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) != 0
|
||||
&& volume.CryptoInfo->EncryptedAreaLength.Value != volume.CryptoInfo->VolumeSize.Value)
|
||||
@@ -7446,7 +7469,7 @@ retryCDDriveCheck:
|
||||
{
|
||||
// Remount the hidden volume host as read-only (to ensure consistent and secure
|
||||
// results of the volume bitmap scanning)
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, TRUE))
|
||||
switch (MountHiddenVolHost (hwndDlg, szDiskFile, &hiddenVolHostDriveNo, &volumePassword, hash_algo, TRUE))
|
||||
{
|
||||
case ERR_NO_FREE_DRIVES:
|
||||
MessageBoxW (hwndDlg, GetString ("NO_FREE_DRIVE_FOR_OUTER_VOL"), lpszTitle, ICON_HAND);
|
||||
@@ -8232,7 +8255,7 @@ efsf_error:
|
||||
|
||||
|
||||
// Mounts a volume within which the user intends to create a hidden volume
|
||||
int MountHiddenVolHost (HWND hwndDlg, char *volumePath, int *driveNo, Password *password, BOOL bReadOnly)
|
||||
int MountHiddenVolHost (HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5_prf, BOOL bReadOnly)
|
||||
{
|
||||
MountOptions mountOptions;
|
||||
ZeroMemory (&mountOptions, sizeof (mountOptions));
|
||||
@@ -8252,7 +8275,7 @@ int MountHiddenVolHost (HWND hwndDlg, char *volumePath, int *driveNo, Password *
|
||||
mountOptions.PartitionInInactiveSysEncScope = FALSE;
|
||||
mountOptions.UseBackupHeader = FALSE;
|
||||
|
||||
if (MountVolume (hwndDlg, *driveNo, volumePath, password, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
|
||||
if (MountVolume (hwndDlg, *driveNo, volumePath, password, pkcs5_prf, FALSE, TRUE, &mountOptions, FALSE, TRUE) < 1)
|
||||
{
|
||||
*driveNo = -3;
|
||||
return ERR_VOL_MOUNT_FAILED;
|
||||
|
||||
@@ -67,7 +67,7 @@ static void NonSysInplaceEncPause (void);
|
||||
static void NonSysInplaceEncResume (void);
|
||||
void ShowNonSysInPlaceEncUIStatus (void);
|
||||
void UpdateNonSysInPlaceEncControls (void);
|
||||
int MountHiddenVolHost ( HWND hwndDlg, char *volumePath, int *driveNo, Password *password, BOOL bReadOnly );
|
||||
int MountHiddenVolHost ( HWND hwndDlg, char *volumePath, int *driveNo, Password *password, int pkcs5_prf, BOOL bReadOnly );
|
||||
int AnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *pnbrFreeClusters);
|
||||
int ScanVolClusterBitmap ( HWND hwndDlg, int *driveNo, __int64 nbrClusters, __int64 *nbrFreeClusters);
|
||||
static void WipeStart (void);
|
||||
|
||||
Reference in New Issue
Block a user