diff options
author | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-01-22 11:46:37 +0100 |
---|---|---|
committer | Mounir IDRASSI <mounir.idrassi@idrix.fr> | 2020-01-22 18:20:11 +0100 |
commit | be1aee00340f40f9c81676d8b65f728f4a34cd9b (patch) | |
tree | 8b793876db52e6d4bd5cb8170e8705145acb86a6 /src/ExpandVolume/InitDataArea.c | |
parent | 56775af8d7578bfb5fd5d938def23ba32e4e7bb2 (diff) | |
download | VeraCrypt-be1aee00340f40f9c81676d8b65f728f4a34cd9b.tar.gz VeraCrypt-be1aee00340f40f9c81676d8b65f728f4a34cd9b.zip |
Windows: Fix regression in Expander and Format when RAM encryption is enable that was causing volume headers to be corrupted.
Diffstat (limited to 'src/ExpandVolume/InitDataArea.c')
-rw-r--r-- | src/ExpandVolume/InitDataArea.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/ExpandVolume/InitDataArea.c b/src/ExpandVolume/InitDataArea.c index afca2306..618358d1 100644 --- a/src/ExpandVolume/InitDataArea.c +++ b/src/ExpandVolume/InitDataArea.c @@ -56,6 +56,9 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, LARGE_INTEGER startOffset; LARGE_INTEGER newOffset; +#ifdef _WIN64 + CRYPTO_INFO tmpCI; +#endif // Seek to start sector startOffset.QuadPart = startSector * FormatSectorSize; @@ -74,6 +77,16 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, memset (sector, 0, sizeof (sector)); +#ifdef _WIN64 + if (IsRamEncryptionEnabled ()) + { + VirtualLock (&tmpCI, sizeof (tmpCI)); + memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO)); + VcUnprotectKeys (&tmpCI, VcGetEncryptionID (cryptoInfo)); + cryptoInfo = &tmpCI; + } +#endif + // Remember the original secondary key (XTS mode) before generating a temporary one memcpy (originalK2, cryptoInfo->k2, sizeof (cryptoInfo->k2)); @@ -136,6 +149,13 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, __int64 num_sectors, VirtualUnlock (temporaryKey, sizeof (temporaryKey)); VirtualUnlock (originalK2, sizeof (originalK2)); TCfree (write_buf); +#ifdef _WIN64 + if (IsRamEncryptionEnabled ()) + { + burn (&tmpCI, sizeof (CRYPTO_INFO)); + VirtualUnlock (&tmpCI, sizeof (tmpCI)); + } +#endif return 0; @@ -147,6 +167,13 @@ fail: VirtualUnlock (temporaryKey, sizeof (temporaryKey)); VirtualUnlock (originalK2, sizeof (originalK2)); TCfree (write_buf); +#ifdef _WIN64 + if (IsRamEncryptionEnabled ()) + { + burn (&tmpCI, sizeof (CRYPTO_INFO)); + VirtualUnlock (&tmpCI, sizeof (tmpCI)); + } +#endif SetLastError (err); return (retVal ? retVal : ERR_OS_ERROR); |