diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-08-08 00:49:00 +0200 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2016-08-15 01:09:05 +0200 |
commit | 5b381ce7d7ec45e02765b4a180f9aa1ee8aeee40 (patch) | |
tree | 49f9cc8a5cc65386b021566e9b7d7ec631923b79 /src/ExpandVolume/ExpandVolume.c | |
parent | 3fb2eedab8ef586cd2686efba0b668a5070fd0af (diff) | |
download | VeraCrypt-5b381ce7d7ec45e02765b4a180f9aa1ee8aeee40.tar.gz VeraCrypt-5b381ce7d7ec45e02765b4a180f9aa1ee8aeee40.zip |
Windows: Fix vulnerability inherited from TrueCrypt that allows an attacker to detect with high probability if a hidden volume is present. Vulnerability reported by Ivanov Alexey Mikhailovich.
Diffstat (limited to 'src/ExpandVolume/ExpandVolume.c')
-rw-r--r-- | src/ExpandVolume/ExpandVolume.c | 47 |
1 files changed, 44 insertions, 3 deletions
diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index abe09557..82c4207e 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -804,7 +804,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas cryptoInfo->RequiredProgramVersion, cryptoInfo->HeaderFlags, cryptoInfo->SectorSize, - TRUE ); // use slow poll + FALSE ); // use slow poll if (ci != NULL) crypto_close (ci); @@ -818,8 +818,7 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas goto error; } - nStatus = _lwrite ((HFILE) dev, buffer, TC_VOLUME_HEADER_EFFECTIVE_SIZE); - if (nStatus != TC_VOLUME_HEADER_EFFECTIVE_SIZE) + if (!WriteEffectiveVolumeHeader (bDevice, dev, buffer)) { nStatus = ERR_OS_ERROR; goto error; @@ -835,9 +834,51 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas ) { //DebugAddProgressDlgStatus(hwndDlg, L"WriteRandomDataToReservedHeaderAreas() ...\r\n"); + PCRYPTO_INFO dummyInfo = NULL; + LARGE_INTEGER hiddenOffset; + nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, newDataAreaSize, !backupHeader, backupHeader); if (nStatus != ERR_SUCCESS) goto error; + + // write fake hidden volume header to protect against attacks that use statistical entropy + // analysis to detect presence of hidden volumes + hiddenOffset.QuadPart = headerOffset.QuadPart + TC_HIDDEN_VOLUME_HEADER_OFFSET; + + nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, + buffer, + cryptoInfo->ea, + cryptoInfo->mode, + NULL, + 0, + 0, + NULL, + &dummyInfo, + newDataAreaSize, + newDataAreaSize, // hiddenVolumeSize + cryptoInfo->EncryptedAreaStart.Value, + newDataAreaSize, + cryptoInfo->RequiredProgramVersion, + cryptoInfo->HeaderFlags, + cryptoInfo->SectorSize, + FALSE ); // use slow poll + + if (nStatus != ERR_SUCCESS) + goto error; + + crypto_close (dummyInfo); + + if (!SetFilePointerEx ((HANDLE) dev, hiddenOffset, NULL, FILE_BEGIN)) + { + nStatus = ERR_OS_ERROR; + goto error; + } + + if (!WriteEffectiveVolumeHeader (bDevice, dev, buffer)) + { + nStatus = ERR_OS_ERROR; + goto error; + } } FlushFileBuffers (dev); |