1
0
mirror of https://github.com/veracrypt/VeraCrypt.git synced 2025-11-12 03:18:26 -06:00

Add option in select the number of passes for volume header over-writing. By default, it is set to 3 but it can be increased to 256 passes (which can lead to a delay of many hours for a single password change operation).

This commit is contained in:
Mounir IDRASSI
2014-07-27 02:36:23 +02:00
parent 97154aaf51
commit 1c11ee428d
16 changed files with 67 additions and 35 deletions

View File

@@ -2060,7 +2060,7 @@ namespace VeraCrypt
}
int BootEncryption::ChangePassword (Password *oldPassword, Password *newPassword, int pkcs5)
int BootEncryption::ChangePassword (Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount)
{
BootEncryptionStatus encStatus = GetStatus();
@@ -2125,7 +2125,7 @@ namespace VeraCrypt
UserEnrichRandomPool (ParentWindow);
WaitCursor();
/* The header will be re-encrypted PRAND_DISK_WIPE_PASSES times to prevent adversaries from using
/* The header will be re-encrypted wipePassCount times to prevent adversaries from using
techniques such as magnetic force microscopy or magnetic force scanning tunnelling microscopy
to recover the overwritten header. According to Peter Gutmann, data should be overwritten 22
times (ideally, 35 times) using non-random patterns and pseudorandom data. However, as users might
@@ -2145,7 +2145,7 @@ namespace VeraCrypt
BOOL backupHeader = FALSE;
while (TRUE)
{
for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++)
for (int wipePass = 0; wipePass < wipePassCount; wipePass++)
{
PCRYPTO_INFO tmpCryptoInfo = NULL;
@@ -2164,7 +2164,7 @@ namespace VeraCrypt
cryptoInfo->RequiredProgramVersion,
cryptoInfo->HeaderFlags | TC_HEADER_FLAG_ENCRYPTED_SYSTEM,
cryptoInfo->SectorSize,
wipePass < PRAND_DISK_WIPE_PASSES - 1);
wipePass < wipePassCount - 1);
if (tmpCryptoInfo)
crypto_close (tmpCryptoInfo);

View File

@@ -141,7 +141,7 @@ namespace VeraCrypt
void AbortSetup ();
void AbortSetupWait ();
void CallDriver (DWORD ioctl, void *input = nullptr, DWORD inputSize = 0, void *output = nullptr, DWORD outputSize = 0);
int ChangePassword (Password *oldPassword, Password *newPassword, int pkcs5);
int ChangePassword (Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount);
void CheckDecoyOSWipeResult ();
void CheckEncryptionSetupResult ();
void CheckRequirements ();

View File

@@ -1565,7 +1565,7 @@ SelectAlgo (HWND hComboBox, int *algo_id)
}
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption)
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe)
{
if (bNA)
{
@@ -1573,14 +1573,20 @@ void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption)
}
else
{
if (bInPlaceEncryption)
AddComboPairW (hComboBox, GetString ("WIPE_MODE_NONE"), TC_WIPE_NONE);
else
AddComboPairW (hComboBox, GetString ("WIPE_MODE_1_RAND"), TC_WIPE_1_RAND);
if (!bHeaderWipe)
{
if (bInPlaceEncryption)
AddComboPairW (hComboBox, GetString ("WIPE_MODE_NONE"), TC_WIPE_NONE);
else
AddComboPairW (hComboBox, GetString ("WIPE_MODE_1_RAND"), TC_WIPE_1_RAND);
}
AddComboPairW (hComboBox, GetString ("WIPE_MODE_3_DOD_5220"), TC_WIPE_3_DOD_5220);
AddComboPairW (hComboBox, GetString ("WIPE_MODE_7_DOD_5220"), TC_WIPE_7_DOD_5220);
AddComboPairW (hComboBox, GetString ("WIPE_MODE_35_GUTMANN"), TC_WIPE_35_GUTMANN);
if (bHeaderWipe)
AddComboPairW (hComboBox, GetString ("WIPE_MODE_256"), TC_WIPE_256); // paranoid wipe for volume header
}
}
@@ -1603,6 +1609,9 @@ wchar_t *GetWipeModeName (WipeAlgorithmId modeId)
case TC_WIPE_35_GUTMANN:
return GetString ("WIPE_MODE_35_GUTMANN");
case TC_WIPE_256:
return GetString ("WIPE_MODE_256");
default:
return GetString ("NOT_APPLICABLE_OR_NOT_AVAILABLE");
}

View File

@@ -259,7 +259,7 @@ void HandCursor ();
void AddComboPair (HWND hComboBox, const char *lpszItem, int value);
void AddComboPairW (HWND hComboBox, const wchar_t *lpszItem, int value);
void SelectAlgo ( HWND hComboBox , int *nCipher );
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption);
void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe);
wchar_t *GetWipeModeName (WipeAlgorithmId modeId);
wchar_t *GetPathType (const char *path, BOOL bUpperCase, BOOL *bIsPartition);
LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam );

View File

@@ -119,7 +119,7 @@ BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem)
return TRUE;
}
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg)
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg)
{
int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR;
char szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH];
@@ -323,7 +323,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassw
while (TRUE)
{
/* The header will be re-encrypted PRAND_DISK_WIPE_PASSES times to prevent adversaries from using
/* The header will be re-encrypted wipePassCount times to prevent adversaries from using
techniques such as magnetic force microscopy or magnetic force scanning tunnelling microscopy
to recover the overwritten header. According to Peter Gutmann, data should be overwritten 22
times (ideally, 35 times) using non-random patterns and pseudorandom data. However, as users might
@@ -335,7 +335,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassw
of the header to differ substantially and in a random manner from the versions written during the
other passes. */
for (wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++)
for (wipePass = 0; wipePass < wipePassCount; wipePass++)
{
// Prepare new volume header
nStatus = CreateVolumeHeaderInMemory (FALSE,
@@ -353,7 +353,7 @@ int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassw
cryptoInfo->RequiredProgramVersion,
cryptoInfo->HeaderFlags,
cryptoInfo->SectorSize,
wipePass < PRAND_DISK_WIPE_PASSES - 1);
wipePass < wipePassCount - 1);
if (ci != NULL)
crypto_close (ci);

View File

@@ -35,7 +35,7 @@ typedef struct
void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled );
BOOL CheckPasswordLength (HWND hwndDlg, HWND hwndItem);
BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw);
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, HWND hwndDlg);
int ChangePwd (const char *lpszVolume, Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount, HWND hwndDlg);
#endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER)

View File

@@ -155,6 +155,9 @@ int GetWipePassCount (WipeAlgorithmId algorithm)
case TC_WIPE_35_GUTMANN:
return 35;
case TC_WIPE_256:
return 256;
default:
TC_THROW_FATAL_EXCEPTION;
}
@@ -168,6 +171,7 @@ BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COU
switch (algorithm)
{
case TC_WIPE_1_RAND:
case TC_WIPE_256:
return Wipe1PseudoRandom (pass, buffer, size);
case TC_WIPE_3_DOD_5220:

View File

@@ -24,7 +24,8 @@ typedef enum
TC_WIPE_1_RAND = 100,
TC_WIPE_3_DOD_5220 = 300,
TC_WIPE_7_DOD_5220 = 700,
TC_WIPE_35_GUTMANN = 3500
TC_WIPE_35_GUTMANN = 3500,
TC_WIPE_256 = 25600
} WipeAlgorithmId;