diff options
author | David Foerster <david.foerster@informatik.hu-berlin.de> | 2016-05-10 22:16:32 +0200 |
---|---|---|
committer | David Foerster <david.foerster@informatik.hu-berlin.de> | 2016-05-10 22:18:34 +0200 |
commit | 11716ed2dacbb104f8f59867fe66f2c0a6984291 (patch) | |
tree | 28aa448de2e790d0f40dc57799a55a9df12ee6fb /src/Common | |
parent | 191075155835172e5596e191cf0679ff9022f0fd (diff) | |
download | VeraCrypt-11716ed2dacbb104f8f59867fe66f2c0a6984291.tar.gz VeraCrypt-11716ed2dacbb104f8f59867fe66f2c0a6984291.zip |
Remove trailing whitespace
Diffstat (limited to 'src/Common')
61 files changed, 811 insertions, 811 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index 5ea89770..9c16b378 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index f6c55974..5905b6a8 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/BaseCom.h b/src/Common/BaseCom.h index 97009410..a5b27473 100644 --- a/src/Common/BaseCom.h +++ b/src/Common/BaseCom.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -20,11 +20,11 @@ class TrueCryptFactory : public IClassFactory { public: - TrueCryptFactory (DWORD messageThreadId) : + TrueCryptFactory (DWORD messageThreadId) : RefCount (1), ServerLockCount (0), MessageThreadId (messageThreadId) { } ~TrueCryptFactory () { } - + virtual ULONG STDMETHODCALLTYPE AddRef () { return InterlockedIncrement (&RefCount) - 1; @@ -53,7 +53,7 @@ public: AddRef (); return S_OK; } - + virtual HRESULT STDMETHODCALLTYPE CreateInstance (IUnknown *pUnkOuter, REFIID riid, void **ppvObject) { if (pUnkOuter != NULL) diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 73b64458..7148ca24 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -44,7 +44,7 @@ namespace VeraCrypt class Elevator { public: - + static void AddReference () { ++ReferenceCount; @@ -193,7 +193,7 @@ namespace VeraCrypt { result = ERROR_OUTOFMEMORY; } - + if (result != ERROR_SUCCESS) { SetLastError (result); @@ -263,7 +263,7 @@ namespace VeraCrypt ElevatedComInstanceThreadId = GetCurrentThreadId(); } } - + #if defined (TCMOUNT) static ITrueCryptMainCom *ElevatedComInstance; #elif defined (VOLFORMAT) @@ -282,7 +282,7 @@ namespace VeraCrypt int Elevator::ReferenceCount = 0; #else // SETUP - + class Elevator { public: @@ -308,7 +308,7 @@ namespace VeraCrypt { FileOpen = true; } - else + else { LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED && IsUacSupported()) @@ -436,7 +436,7 @@ namespace VeraCrypt { FileOpen = true; } - else + else { LastError = GetLastError (); if (LastError == ERROR_ACCESS_DENIED && IsUacSupported()) @@ -477,7 +477,7 @@ namespace VeraCrypt { if (RescueIsoImage) delete[] RescueIsoImage; - + Elevator::Release(); } @@ -516,7 +516,7 @@ namespace VeraCrypt if (config.SystemPartition.IsGPT) throw ParameterIncorrect (SRC_POS); // It is assumed that CheckRequirements() had been called - // Find the first active partition on the system drive + // Find the first active partition on the system drive foreach (const Partition &partition, config.Partitions) { if (partition.Info.BootIndicator) @@ -558,11 +558,11 @@ namespace VeraCrypt } /* WARNING: Note that the partition number at the end of a device path (\Device\HarddiskY\PartitionX) must - NOT be used to find the first partition physically located behind the active one. The reason is that the - user may have deleted and created partitions during this session and e.g. the second partition could have + NOT be used to find the first partition physically located behind the active one. The reason is that the + user may have deleted and created partitions during this session and e.g. the second partition could have a higer number than the third one. */ - + // Find the first partition physically located behind the active partition if (activePartitionFound) { @@ -692,7 +692,7 @@ namespace VeraCrypt ProbeRealDriveSizeRequest request; StringCchCopyW (request.DeviceName, ARRAYSIZE (request.DeviceName), DriveConfig.DrivePartition.DevicePath.c_str()); - + CallDriver (TC_IOCTL_PROBE_REAL_DRIVE_SIZE, &request, sizeof (request), &request, sizeof (request)); DriveConfig.DrivePartition.Info.PartitionLength = request.RealDriveSize; @@ -787,7 +787,7 @@ namespace VeraCrypt return partList; } - + DISK_GEOMETRY BootEncryption::GetDriveGeometry (int driveNumber) { @@ -799,12 +799,12 @@ namespace VeraCrypt return geometry; } - + wstring BootEncryption::GetWindowsDirectory () { wchar_t buf[MAX_PATH]; throw_sys_if (GetSystemDirectory (buf, ARRAYSIZE (buf)) == 0); - + return wstring (buf); } @@ -827,7 +827,7 @@ namespace VeraCrypt // Note that this does not require admin rights (it just requires the driver to be running) bool BootEncryption::IsBootLoaderOnDrive (wchar_t *devicePath) { - try + try { OPEN_TEST_STRUCT openTestStruct; memset (&openTestStruct, 0, sizeof (openTestStruct)); @@ -871,7 +871,7 @@ namespace VeraCrypt bool BootEncryption::IsHiddenSystemRunning () { int hiddenSystemStatus; - + CallDriver (TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING, nullptr, 0, &hiddenSystemStatus, sizeof (hiddenSystemStatus)); return hiddenSystemStatus != 0; } @@ -1250,7 +1250,7 @@ namespace VeraCrypt if (userConfig) *userConfig = request.UserConfiguration; - + if (customUserMessage) { request.CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH] = 0; @@ -1267,7 +1267,7 @@ namespace VeraCrypt if (userConfig) *userConfig = 0; - + if (customUserMessage) customUserMessage->clear(); @@ -1326,7 +1326,7 @@ namespace VeraCrypt memcpy (mbr + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, customUserMessage.c_str(), customUserMessage.size()); } - + if (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM) { // PIM for pre-boot authentication can be encoded on two bytes since its maximum @@ -1386,7 +1386,7 @@ namespace VeraCrypt ZeroMemory (&request, sizeof (request)); request.WipeAlgorithm = wipeAlgorithm; - + if (Randinit() != ERR_SUCCESS) { if (CryptoAPILastError == ERROR_SUCCESS) @@ -1414,7 +1414,7 @@ namespace VeraCrypt CallDriver (TC_IOCTL_ABORT_DECOY_SYSTEM_WIPE); } - + DecoySystemWipeStatus BootEncryption::GetDecoyOSWipeStatus () { DecoySystemWipeStatus status; @@ -1448,7 +1448,7 @@ namespace VeraCrypt device.SeekAt (0); device.Read (mbr, sizeof (mbr)); - + finally_do_arg (BootEncryption *, this, { try @@ -1594,7 +1594,7 @@ namespace VeraCrypt WCHAR pathBuf[MAX_PATH]; throw_sys_if (!SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, pathBuf))); - + wstring path = wstring (pathBuf) + L"\\" _T(TC_APP_NAME); CreateDirectory (path.c_str(), NULL); @@ -1624,7 +1624,7 @@ namespace VeraCrypt throw ParameterIncorrect (SRC_POS); Buffer imageBuf (RescueIsoImageSize); - + byte *image = imageBuf.Ptr(); memset (image, 0, RescueIsoImageSize); @@ -1721,7 +1721,7 @@ namespace VeraCrypt File sysBakFile (GetSystemLoaderBackupPath(), true); sysBakFile.CheckOpened (SRC_POS); sysBakFile.Read (image + TC_CD_BOOTSECTOR_OFFSET + TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE); - + image[TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER; } catch (Exception &e) @@ -1729,7 +1729,7 @@ namespace VeraCrypt e.Show (ParentWindow); Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK", ParentWindow); } - + // Boot loader backup CreateBootLoaderInMemory (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE, false); @@ -1777,7 +1777,7 @@ namespace VeraCrypt UINT driveType = GetDriveType (rootPath); // check that it is a CD/DVD drive or a removable media in case a bootable // USB key was created from the rescue disk ISO file - if ((DRIVE_CDROM == driveType) || (DRIVE_REMOVABLE == driveType)) + if ((DRIVE_CDROM == driveType) || (DRIVE_REMOVABLE == driveType)) { rootPath[2] = 0; // remove trailing backslash @@ -1813,7 +1813,7 @@ namespace VeraCrypt Buffer buffer ((verifiedSectorCount + 1) * 2048); DWORD bytesRead = isoFile.Read (buffer.Ptr(), (DWORD) buffer.Size()); - if ( (bytesRead == buffer.Size()) + if ( (bytesRead == buffer.Size()) && (memcmp (buffer.Ptr(), RescueIsoImage, buffer.Size()) == 0) ) { @@ -2187,7 +2187,7 @@ namespace VeraCrypt { if (nCurrentOS == WIN_2000) throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_CURRENT_OS", SRC_POS); - + if (CurrentOSMajor == 6 && CurrentOSMinor == 0 && CurrentOSServicePack < 1) throw ErrorException ("SYS_ENCRYPTION_UNSUPPORTED_ON_VISTA_SP0", SRC_POS); @@ -2272,7 +2272,7 @@ namespace VeraCrypt if (!pagingFilesOk) { - if (AskWarnYesNoString ((wchar_t *) (wstring (GetString ("PAGING_FILE_NOT_ON_SYS_PARTITION")) + if (AskWarnYesNoString ((wchar_t *) (wstring (GetString ("PAGING_FILE_NOT_ON_SYS_PARTITION")) + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION") + L"\n\n\n" + GetString ("RESTRICT_PAGING_FILES_TO_SYS_PARTITION") @@ -2283,7 +2283,7 @@ namespace VeraCrypt AbortProcessSilent(); } - throw ErrorException (wstring (GetString ("PAGING_FILE_NOT_ON_SYS_PARTITION")) + throw ErrorException (wstring (GetString ("PAGING_FILE_NOT_ON_SYS_PARTITION")) + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS); } @@ -2291,14 +2291,14 @@ namespace VeraCrypt wchar_t *configPath = GetConfigPath (L"dummy"); if (configPath && towupper (configPath[0]) != windowsDrive) { - throw ErrorException (wstring (GetString ("USER_PROFILE_NOT_ON_SYS_PARTITION")) + throw ErrorException (wstring (GetString ("USER_PROFILE_NOT_ON_SYS_PARTITION")) + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS); } // Temporary files if (towupper (GetTempPathString()[0]) != windowsDrive) { - throw ErrorException (wstring (GetString ("TEMP_NOT_ON_SYS_PARTITION")) + throw ErrorException (wstring (GetString ("TEMP_NOT_ON_SYS_PARTITION")) + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS); } } @@ -2414,7 +2414,7 @@ namespace VeraCrypt device.Read ((byte *) header, sizeof (header)); PCRYPTO_INFO cryptoInfo = NULL; - + int status = ReadVolumeHeader (!encStatus.HiddenSystem, header, oldPassword, old_pkcs5, old_pim, FALSE, &cryptoInfo, NULL); finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); }); @@ -2447,7 +2447,7 @@ namespace VeraCrypt UserEnrichRandomPool (hwndDlg); WaitCursor(); - /* The header will be re-encrypted wipePassCount 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 @@ -2663,7 +2663,7 @@ namespace VeraCrypt SelectedEncryptionAlgorithmId = ea; SelectedPrfAlgorithmId = pkcs5; CreateVolumeHeader (volumeSize, encryptedAreaStart, &password, ea, mode, pkcs5, pim); - + if (!rescueIsoImagePath.empty()) CreateRescueIsoImage (true, rescueIsoImagePath); } @@ -2705,7 +2705,7 @@ namespace VeraCrypt BootEncryptionSetupRequest request; ZeroMemory (&request, sizeof (request)); - + request.SetupMode = SetupDecryption; request.DiscardUnreadableEncryptedSectors = discardUnreadableEncryptedSectors; @@ -2721,7 +2721,7 @@ namespace VeraCrypt BootEncryptionSetupRequest request; ZeroMemory (&request, sizeof (request)); - + request.SetupMode = SetupEncryption; request.WipeAlgorithm = wipeAlgorithm; request.ZeroUnreadableSectors = zeroUnreadableSectors; diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index a89b2ec6..d75b650c 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Cache.c b/src/Common/Cache.c index ba6c6df8..e5b36590 100644 --- a/src/Common/Cache.c +++ b/src/Common/Cache.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Cache.h b/src/Common/Cache.h index c4587d03..1cadf79d 100644 --- a/src/Common/Cache.h +++ b/src/Common/Cache.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -15,7 +15,7 @@ #ifndef CACHE_SIZE /* WARNING: Changing this value might not be safe (some items may be hard coded for 4)! Inspection necessary. */ -#define CACHE_SIZE 4 +#define CACHE_SIZE 4 #endif extern int cacheEmpty; diff --git a/src/Common/Cmdline.c b/src/Common/Cmdline.c index 4a055c16..e5fe5969 100644 --- a/src/Common/Cmdline.c +++ b/src/Common/Cmdline.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -74,7 +74,7 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X"); SetWindowTextW (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), tmp); - + TCfree(tmp); return 1; } diff --git a/src/Common/Cmdline.h b/src/Common/Cmdline.h index 51c173c6..09e59924 100644 --- a/src/Common/Cmdline.h +++ b/src/Common/Cmdline.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Combo.c b/src/Common/Combo.c index fe456853..50e9761c 100644 --- a/src/Common/Combo.c +++ b/src/Common/Combo.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -171,7 +171,7 @@ void LoadCombo (HWND hComboBox, BOOL bEnabled, BOOL bOnlyCheckModified, BOOL *pb { wchar_t szTmp[MAX_PATH] = { 0 }; wchar_t wszVolume[MAX_PATH] = {0}; - + if (i < count) { if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp)) @@ -225,7 +225,7 @@ void DumpCombo (HWND hComboBox, int bClear) for (i = 0; i < SIZEOF_MRU_LIST; i++) { wchar_t szTmp[MAX_PATH] = { 0 }; - + if (SendMessage (hComboBox, CB_GETLBTEXTLEN, nComboIdx[i], 0) < ARRAYSIZE (szTmp)) SendMessage (hComboBox, CB_GETLBTEXT, nComboIdx[i], (LPARAM) & szTmp[0]); diff --git a/src/Common/Combo.h b/src/Common/Combo.h index cacbc413..4f85c6bd 100644 --- a/src/Common/Combo.h +++ b/src/Common/Combo.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Common.h b/src/Common/Common.h index 05e2e12f..cd88882f 100644 --- a/src/Common/Common.h +++ b/src/Common/Common.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Common.rc b/src/Common/Common.rc index 1e529c63..b84fba8e 100644 --- a/src/Common/Common.rc +++ b/src/Common/Common.rc @@ -337,7 +337,7 @@ END // #ifdef APSTUDIO_INVOKED -GUIDELINES DESIGNINFO +GUIDELINES DESIGNINFO BEGIN IDD_ABOUT_DLG, DIALOG BEGIN @@ -547,18 +547,18 @@ IDR_LICENSE TEXT "..\\Resources\\Texts\\License.r // TEXTINCLUDE // -1 TEXTINCLUDE +1 TEXTINCLUDE BEGIN "resource.h\0" END -2 TEXTINCLUDE +2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END -3 TEXTINCLUDE +3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/src/Common/Crc.c b/src/Common/Crc.c index ba8777e6..5a73fc86 100644 --- a/src/Common/Crc.c +++ b/src/Common/Crc.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -19,7 +19,7 @@ /* CRC polynomial 0x04c11db7 */ unsigned __int32 crc_32_tab[]= -{ +{ 0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, diff --git a/src/Common/Crc.h b/src/Common/Crc.h index c89a6191..c5be1778 100644 --- a/src/Common/Crc.h +++ b/src/Common/Crc.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index a524fd97..e5a3218e 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -129,7 +129,7 @@ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks) case SERPENT: serpent_set_key (key, ks); break; - + case TWOFISH: twofish_set_key ((TwofishInstance *)ks, (const u4byte *)key); break; @@ -146,7 +146,7 @@ void EncipherBlock(int cipher, void *data, void *ks) { switch (cipher) { - case AES: + case AES: // In 32-bit kernel mode, due to KeSaveFloatingPointState() overhead, AES instructions can be used only when processing the whole data unit. #if (defined (_WIN64) || !defined (TC_WINDOWS_DRIVER)) && !defined (TC_WINDOWS_BOOT) if (IsAesHwCpuSupported()) @@ -399,11 +399,11 @@ BOOL EAInitMode (PCRYPTO_INFO ci) /* Note: XTS mode could potentially be initialized with a weak key causing all blocks in one data unit on the volume to be tweaked with zero tweaks (i.e. 512 bytes of the volume would be encrypted in ECB mode). However, to create a TrueCrypt volume with such a weak key, each human being on Earth would have - to create approximately 11,378,125,361,078,862 (about eleven quadrillion) TrueCrypt volumes (provided + to create approximately 11,378,125,361,078,862 (about eleven quadrillion) TrueCrypt volumes (provided that the size of each of the volumes is 1024 terabytes). */ break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -488,7 +488,7 @@ int EAGetNextMode (int ea, int previousModeId) int c, i = 0; while (c = EncryptionAlgorithms[ea].Modes[i++]) { - if (c == previousModeId) + if (c == previousModeId) return EncryptionAlgorithms[ea].Modes[i]; } @@ -591,7 +591,7 @@ int EAGetNextCipher (int ea, int previousCipherId) int c, i = 0; while (c = EncryptionAlgorithms[ea].Ciphers[i++]) { - if (c == previousCipherId) + if (c == previousCipherId) return EncryptionAlgorithms[ea].Ciphers[i]; } @@ -608,7 +608,7 @@ int EAGetPreviousCipher (int ea, int previousCipherId) while (c = EncryptionAlgorithms[ea].Ciphers[i++]) { - if (c == previousCipherId) + if (c == previousCipherId) return EncryptionAlgorithms[ea].Ciphers[i - 2]; } @@ -777,7 +777,7 @@ void crypto_close (PCRYPTO_INFO cryptoInfo) // EncryptBuffer // // buf: data to be encrypted; the start of the buffer is assumed to be aligned with the start of a data unit. -// len: number of bytes to encrypt; must be divisible by the block size (for cascaded ciphers, divisible +// len: number of bytes to encrypt; must be divisible by the block size (for cascaded ciphers, divisible // by the largest block size used within the cascade) void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo) { @@ -808,7 +808,7 @@ void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_ } break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -850,7 +850,7 @@ void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s } break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -859,7 +859,7 @@ void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s // DecryptBuffer // // buf: data to be decrypted; the start of the buffer is assumed to be aligned with the start of a data unit. -// len: number of bytes to decrypt; must be divisible by the block size (for cascaded ciphers, divisible +// len: number of bytes to decrypt; must be divisible by the block size (for cascaded ciphers, divisible // by the largest block size used within the cascade) void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo) { @@ -890,7 +890,7 @@ void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_ } break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -935,7 +935,7 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s } break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -955,7 +955,7 @@ void EncipherBlock(int cipher, void *data, void *ks) if (IsAesHwCpuSupported()) aes_hw_cpu_encrypt ((byte *) ks, data); else - aes_encrypt (data, data, ks); + aes_encrypt (data, data, ks); #elif defined (TC_WINDOWS_BOOT_SERPENT) serpent_encrypt (data, data, ks); #elif defined (TC_WINDOWS_BOOT_TWOFISH) @@ -969,7 +969,7 @@ void DecipherBlock(int cipher, void *data, void *ks) if (IsAesHwCpuSupported()) aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data); else - aes_decrypt (data, data, (aes_decrypt_ctx *) ((byte *) ks + sizeof(aes_encrypt_ctx))); + aes_decrypt (data, data, (aes_decrypt_ctx *) ((byte *) ks + sizeof(aes_encrypt_ctx))); #elif defined (TC_WINDOWS_BOOT_SERPENT) serpent_decrypt (data, data, ks); #elif defined (TC_WINDOWS_BOOT_TWOFISH) diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 96f0a9a6..5d9fff97 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -45,9 +45,9 @@ extern "C" { #define MASTER_KEYDATA_SIZE 256 // The first PRF to try when mounting -#define FIRST_PRF_ID 1 +#define FIRST_PRF_ID 1 -// Hash algorithms (pseudorandom functions). +// Hash algorithms (pseudorandom functions). enum { SHA512 = FIRST_PRF_ID, @@ -58,7 +58,7 @@ enum }; // The last PRF to try when mounting and also the number of implemented PRFs -#define LAST_PRF_ID (HASH_ENUM_END_ID - 1) +#define LAST_PRF_ID (HASH_ENUM_END_ID - 1) #define RIPEMD160_BLOCKSIZE 64 #define RIPEMD160_DIGESTSIZE 20 @@ -105,7 +105,7 @@ enum { NONE = 0, AES, - SERPENT, + SERPENT, TWOFISH }; @@ -221,12 +221,12 @@ typedef struct CRYPTO_INFO_t #ifndef TC_WINDOWS_BOOT uint16 HeaderVersion; - GfCtx gf_ctx; + GfCtx gf_ctx; unsigned __int8 master_keydata[MASTER_KEYDATA_SIZE]; /* This holds the volume header area containing concatenated master key(s) and secondary key(s) (XTS mode). For LRW (deprecated/legacy), it contains the tweak key before the master key(s). For CBC (deprecated/legacy), it contains the IV seed before the master key(s). */ unsigned __int8 k2[MASTER_KEYDATA_SIZE]; /* For XTS, this contains the secondary key (if cascade, multiple concatenated). For LRW (deprecated/legacy), it contains the tweak key. For CBC (deprecated/legacy), it contains the IV seed. */ unsigned __int8 salt[PKCS5_SALT_SIZE]; - int noIterations; + int noIterations; BOOL bTrueCryptMode; int volumePim; @@ -235,7 +235,7 @@ typedef struct CRYPTO_INFO_t BOOL bProtectHiddenVolume; // Indicates whether the volume contains a hidden volume to be protected against overwriting BOOL bHiddenVolProtectionAction; // TRUE if a write operation has been denied by the driver in order to prevent the hidden volume from being overwritten (set to FALSE upon volume mount). - + uint64 volDataAreaOffset; // Absolute position, in bytes, of the first data sector of the volume. uint64 hiddenVolumeSize; // Size of the hidden volume excluding the header (in bytes). Set to 0 for standard volumes. diff --git a/src/Common/Dictionary.c b/src/Common/Dictionary.c index 34741951..c6135e3e 100644 --- a/src/Common/Dictionary.c +++ b/src/Common/Dictionary.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -41,7 +41,7 @@ void AddDictionaryEntry (char *key, int intKey, void *value) void *GetDictionaryValue (const char *key) { map <string, void *>::const_iterator i = StringKeyMap.find (key); - + if (i == StringKeyMap.end()) return NULL; diff --git a/src/Common/Dictionary.h b/src/Common/Dictionary.h index 0fa9c7ee..97c7938c 100644 --- a/src/Common/Dictionary.h +++ b/src/Common/Dictionary.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index ef6a942f..fd2601b4 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -113,9 +113,9 @@ BOOL bMountFavoritesOnLogon = FALSE; BOOL bHistory = FALSE; -// Status of detection of hidden sectors (whole-system-drive encryption). +// Status of detection of hidden sectors (whole-system-drive encryption). // 0 - Unknown/undetermined/completed, 1: Detection is or was in progress (but did not complete e.g. due to system crash). -int HiddenSectorDetectionStatus = 0; +int HiddenSectorDetectionStatus = 0; OSVersionEnum nCurrentOS = WIN_UNKNOWN; int CurrentOSMajor = 0; @@ -128,7 +128,7 @@ BOOL bPortableModeConfirmed = FALSE; // TRUE if it is certain that the instance BOOL bInPlaceEncNonSysPending = FALSE; // TRUE if the non-system in-place encryption config file indicates that one or more partitions are scheduled to be encrypted. This flag is set only when config files are loaded during app startup. -/* Globals used by Mount and Format (separately per instance) */ +/* Globals used by Mount and Format (separately per instance) */ BOOL PimEnable = FALSE; BOOL KeyFilesEnable = FALSE; KeyFile *FirstKeyFile = NULL; @@ -147,7 +147,7 @@ BOOL WaitDialogDisplaying = FALSE; HANDLE hDriver = INVALID_HANDLE_VALUE; /* This mutex is used to prevent multiple instances of the wizard or main app from dealing with system encryption */ -volatile HANDLE hSysEncMutex = NULL; +volatile HANDLE hSysEncMutex = NULL; /* This mutex is used for non-system in-place encryption but only for informative (non-blocking) purposes, such as whether an app should prompt the user whether to resume scheduled process. */ @@ -171,7 +171,7 @@ ATOM hDlgClass, hSplashClass; /* This value may changed only by calling ChangeSystemEncryptionStatus(). Only the wizard can change it (others may still read it though). */ -int SystemEncryptionStatus = SYSENC_STATUS_NONE; +int SystemEncryptionStatus = SYSENC_STATUS_NONE; /* Only the wizard can change this value (others may only read it). */ WipeAlgorithmId nWipeMode = TC_WIPE_NONE; @@ -294,13 +294,13 @@ ChangeWindowMessageFilterPtr ChangeWindowMessageFilterFn = NULL; #error PKCS5_BENCHMARKS and HASH_FNC_BENCHMARKS are both TRUE (at least one of them should be FALSE). #endif -enum +enum { BENCHMARK_SORT_BY_NAME = 0, BENCHMARK_SORT_BY_SPEED }; -typedef struct +typedef struct { int id; wchar_t name[100]; @@ -319,7 +319,7 @@ LARGE_INTEGER benchmarkPerformanceFrequency; #endif // #ifndef SETUP -typedef struct +typedef struct { void *strings; BOOL bold; @@ -356,7 +356,7 @@ void cleanup () /* Close the device driver handle */ if (hDriver != INVALID_HANDLE_VALUE) { - // Unload driver mode if possible (non-install mode) + // Unload driver mode if possible (non-install mode) if (IsNonInstallMode ()) { // If a dismount was forced in the lifetime of the driver, Windows may later prevent it to be loaded again from @@ -710,7 +710,7 @@ BOOL IsDiskError (DWORD error) DWORD handleWin32Error (HWND hwndDlg, const char* srcPos) { PWSTR lpMsgBuf; - DWORD dwError = GetLastError (); + DWORD dwError = GetLastError (); wchar_t szErrorValue[32]; wchar_t* pszDesc; @@ -833,7 +833,7 @@ int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont) { SIZE sizes; TEXTMETRIC textMetrics; - HDC hdc = GetDC (hwndDlgItem); + HDC hdc = GetDC (hwndDlgItem); SelectObject(hdc, (HGDIOBJ) hFont); @@ -841,7 +841,7 @@ int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont) GetTextMetrics(hdc, &textMetrics); // Necessary for non-TrueType raster fonts (tmOverhang) - ReleaseDC (hwndDlgItem, hdc); + ReleaseDC (hwndDlgItem, hdc); return ((int) sizes.cx - (int) textMetrics.tmOverhang); } @@ -850,13 +850,13 @@ int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont) int GetTextGfxHeight (HWND hwndDlgItem, const wchar_t *text, HFONT hFont) { SIZE sizes; - HDC hdc = GetDC (hwndDlgItem); + HDC hdc = GetDC (hwndDlgItem); SelectObject(hdc, (HGDIOBJ) hFont); GetTextExtentPoint32W (hdc, text, (int) wcslen (text), &sizes); - ReleaseDC (hwndDlgItem, hdc); + ReleaseDC (hwndDlgItem, hdc); return ((int) sizes.cy); } @@ -872,7 +872,7 @@ std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::w rect.right = width; rect.bottom = LONG_MAX; - HDC hdc = GetDC (hwnd); + HDC hdc = GetDC (hwnd); SelectObject (hdc, (HGDIOBJ) hFont); wchar_t pathBuf[TC_MAX_PATH]; @@ -881,7 +881,7 @@ std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::w if (DrawText (hdc, pathBuf, (int) path.size(), &rect, DT_CALCRECT | DT_MODIFYSTRING | DT_PATH_ELLIPSIS | DT_SINGLELINE) != 0) newPath = pathBuf; - ReleaseDC (hwnd, hdc); + ReleaseDC (hwnd, hdc); return newPath; } @@ -961,12 +961,12 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h width = GetTextGfxWidth (hwndCtrl, text, hFont); height = GetTextGfxHeight (hwndCtrl, text, hFont); - GetClientRect (hwndCtrl, &rec); + GetClientRect (hwndCtrl, &rec); origWidth = rec.right; origHeight = rec.bottom; if (width >= 0 - && (!bFirstUpdate || origWidth > width)) // The original width of the field is the maximum allowed size + && (!bFirstUpdate || origWidth > width)) // The original width of the field is the maximum allowed size { horizSubOffset = origWidth - width; vertSubOffset = origHeight - height; @@ -989,7 +989,7 @@ void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT h alignPosDiff = horizSubOffset / 2; else if (windowInfo.dwStyle & SS_RIGHT) alignPosDiff = horizSubOffset; - + // Resize/move if (alignPosDiff > 0) { @@ -1044,7 +1044,7 @@ static LRESULT CALLBACK BootPwdFieldProc (HWND hwnd, UINT message, WPARAM wParam // Protects an input field from having its content updated by a Paste action. Used for pre-boot password -// input fields (only the US keyboard layout is supported in pre-boot environment so we must prevent the +// input fields (only the US keyboard layout is supported in pre-boot environment so we must prevent the // user from pasting a password typed using a non-US keyboard layout). void ToBootPwdField (HWND hwndDlg, UINT ctrlId) { @@ -1071,7 +1071,7 @@ BOOL CALLBACK AuxiliaryDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (hDC) { ScreenDPI = GetDeviceCaps (hDC, LOGPIXELSY); - ReleaseDC (hwndDlg, hDC); + ReleaseDC (hwndDlg, hDC); } DPIScaleFactorX = 1; @@ -1080,7 +1080,7 @@ BOOL CALLBACK AuxiliaryDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP if (ScreenDPI != USER_DEFAULT_SCREEN_DPI) { - // Windows skews the GUI aspect ratio if the user has a non-default DPI. Hence, working with + // Windows skews the GUI aspect ratio if the user has a non-default DPI. Hence, working with // actual screen DPI is redundant and leads to incorrect results. What really matters here is // how Windows actually renders our GUI. This is determined by comparing the expected and current // sizes of a hidden calibration text field. @@ -1139,7 +1139,7 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam GetClientRect (GetDlgItem (hwndDlg, IDC_ABOUT_LOGO_AREA), &rec); SetWindowPos (GetDlgItem (hwndDlg, IDC_ABOUT_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE); - // Resize the logo bitmap if the user has a non-default DPI + // Resize the logo bitmap if the user has a non-default DPI if (ScreenDPI != USER_DEFAULT_SCREEN_DPI) { // Logo (must recreate and keep the original aspect ratio as Windows distorts it) @@ -1455,7 +1455,7 @@ void InitDialog (HWND hwndDlg) void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess) { MSG paintMsg; - int msgCounter = maxMessagesToProcess; + int msgCounter = maxMessagesToProcess; while (PeekMessageW (&paintMsg, hwnd, 0, 0, PM_REMOVE | PM_QS_PAINT) != 0 && msgCounter-- > 0) { @@ -1483,16 +1483,16 @@ HDC CreateMemBitmap (HINSTANCE hInstance, HWND hwnd, wchar_t *resource) } -/* Renders the specified bitmap at the specified location and stretches it to fit (anti-aliasing is applied). +/* Renders the specified bitmap at the specified location and stretches it to fit (anti-aliasing is applied). If bDirectRender is FALSE and both nWidth and nHeight are zero, the width and height of hwndDest are retrieved and adjusted according to screen DPI (the width and height of the resultant image are adjusted the same way); furthermore, if bKeepAspectRatio is TRUE, the smaller DPI factor of the two (i.e. horiz. or vert.) is used both for horiz. and vert. scaling (note that the overall GUI aspect ratio changes irregularly in -both directions depending on the DPI). If bDirectRender is TRUE, bKeepAspectRatio is ignored. +both directions depending on the DPI). If bDirectRender is TRUE, bKeepAspectRatio is ignored. This function returns a handle to the scaled bitmap. When the bitmap is no longer needed, it should be -deleted by calling DeleteObject() with the handle passed as the parameter. -Known Windows issues: -- For some reason, anti-aliasing is not applied if the source bitmap contains less than 16K pixels. +deleted by calling DeleteObject() with the handle passed as the parameter. +Known Windows issues: +- For some reason, anti-aliasing is not applied if the source bitmap contains less than 16K pixels. - Windows 2000 may produce slightly inaccurate colors even when source, buffer, and target are 24-bit true color. */ HBITMAP RenderBitmap (wchar_t *resource, HWND hwndDest, int x, int y, int nWidth, int nHeight, BOOL bDirectRender, BOOL bKeepAspectRatio) { @@ -1541,11 +1541,11 @@ HBITMAP RenderBitmap (wchar_t *resource, HWND hwndDest, int x, int y, int nWidth GetObject (picture, sizeof (BITMAP), &bitmap); - hdcRescaled = CreateCompatibleDC (hdcSrc); + hdcRescaled = CreateCompatibleDC (hdcSrc); if (hdcRescaled) { - hbmpRescaled = CreateCompatibleBitmap (hdcSrc, nWidth, nHeight); + hbmpRescaled = CreateCompatibleBitmap (hdcSrc, nWidth, nHeight); SelectObject (hdcRescaled, hbmpRescaled); @@ -1561,7 +1561,7 @@ HBITMAP RenderBitmap (wchar_t *resource, HWND hwndDest, int x, int y, int nWidth hdcSrc, 0, 0, - bitmap.bmWidth, + bitmap.bmWidth, bitmap.bmHeight, SRCCOPY); @@ -1670,8 +1670,8 @@ RegisterRedTick (HINSTANCE hInstance) wc.hCursor = NULL; wc.hbrBackground = (HBRUSH) GetStockObject (LTGRAY_BRUSH); wc.lpszClassName = L"VCREDTICK"; - wc.lpfnWndProc = &RedTick; - + wc.lpfnWndProc = &RedTick; + rc = (ULONG) RegisterClassW (&wc); return rc == 0 ? FALSE : TRUE; @@ -1788,7 +1788,7 @@ void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, B { if (!bHeaderWipe) { - AddComboPair (hComboBox, GetString ("WIPE_MODE_NONE"), TC_WIPE_NONE); + AddComboPair (hComboBox, GetString ("WIPE_MODE_NONE"), TC_WIPE_NONE); } AddComboPair (hComboBox, GetString ("WIPE_MODE_1_RAND"), TC_WIPE_1_RAND); @@ -2055,7 +2055,7 @@ void ExceptionHandlerThread (void *threadArg) else lpack[0] = 0; - + sprintf (url, TC_APPLINK_SECURE "&dest=err-report%s&os=%s&osver=%d.%d.%d&arch=%s&cpus=%d&app=%s&cksum=%x&dlg=%s&err=%x&addr=%x" , lpack , GetWindowsEdition().c_str() @@ -2124,7 +2124,7 @@ static LRESULT CALLBACK NonInstallUacWndProc (HWND hWnd, UINT message, WPARAM wP // Mutex handling to prevent multiple instances of the wizard or main app from dealing with system encryption. -// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). +// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). BOOL CreateSysEncMutex (void) { return TCCreateMutex (&hSysEncMutex, TC_MUTEX_NAME_SYSENC); @@ -2144,7 +2144,7 @@ void CloseSysEncMutex (void) } -// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). +// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). BOOL CreateNonSysInplaceEncMutex (void) { return TCCreateMutex (&hNonSysInplaceEncMutex, TC_MUTEX_NAME_NONSYS_INPLACE_ENC); @@ -2166,14 +2166,14 @@ void CloseNonSysInplaceEncMutex (void) // Returns TRUE if another instance of the wizard is preparing, resuming or performing non-system in-place encryption BOOL NonSysInplaceEncInProgressElsewhere (void) { - return (!InstanceHasNonSysInplaceEncMutex () + return (!InstanceHasNonSysInplaceEncMutex () && MutexExistsOnSystem (TC_MUTEX_NAME_NONSYS_INPLACE_ENC)); } // Mutex handling to prevent multiple instances of the wizard or main app from trying to install // or register the driver or from trying to launch it in portable mode at the same time. -// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). +// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). BOOL CreateDriverSetupMutex (void) { return TCCreateMutex (&hDriverSetupMutex, TC_MUTEX_NAME_DRIVER_SETUP); @@ -2204,7 +2204,7 @@ BOOL IsTrueCryptInstallerRunning (void) } -// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). +// Returns TRUE if the mutex is (or had been) successfully acquired (otherwise FALSE). BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name) { if (*hMutex != NULL) @@ -2244,7 +2244,7 @@ void TCCloseMutex (volatile HANDLE *hMutex) } -// Returns TRUE if a process running on the system has the specified mutex (otherwise FALSE). +// Returns TRUE if a process running on the system has the specified mutex (otherwise FALSE). BOOL MutexExistsOnSystem (wchar_t *name) { if (name[0] == 0) @@ -2258,7 +2258,7 @@ BOOL MutexExistsOnSystem (wchar_t *name) return FALSE; if (GetLastError () == ERROR_ACCESS_DENIED) // On Vista, this is returned if the owner of the mutex is elevated while we are not - return TRUE; + return TRUE; // The call failed and it is not certain whether the mutex exists or not return FALSE; @@ -2530,8 +2530,8 @@ static void LoadSystemDll (LPCTSTR szModuleName, HMODULE *pHandle, BOOL bIgnoreE void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) { WNDCLASSW wc; - char langId[6]; - InitCommonControlsPtr InitCommonControlsFn = NULL; + char langId[6]; + InitCommonControlsPtr InitCommonControlsFn = NULL; InitOSVersionInfo(); @@ -2553,9 +2553,9 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) LoadSystemDll (L"Usp10.DLL", &hUsp10Dll, TRUE, SRC_POS); LoadSystemDll (L"UXTheme.dll", &hUXThemeDll, TRUE, SRC_POS); - LoadSystemDll (L"msls31.dll", &hMsls31, TRUE, SRC_POS); + LoadSystemDll (L"msls31.dll", &hMsls31, TRUE, SRC_POS); LoadSystemDll (L"SETUPAPI.DLL", &hSetupDll, FALSE, SRC_POS); - LoadSystemDll (L"SHLWAPI.DLL", &hShlwapiDll, FALSE, SRC_POS); + LoadSystemDll (L"SHLWAPI.DLL", &hShlwapiDll, FALSE, SRC_POS); LoadSystemDll (L"userenv.dll", &hUserenvDll, TRUE, SRC_POS); LoadSystemDll (L"rsaenh.dll", &hRsaenhDll, TRUE, SRC_POS); @@ -2572,7 +2572,7 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) } if (IsOSAtLeast (WIN_VISTA)) - { + { LoadSystemDll (L"netapi32.dll", &hnetapi32dll, TRUE, SRC_POS); LoadSystemDll (L"authz.dll", &hauthzdll, TRUE, SRC_POS); LoadSystemDll (L"xmllite.dll", &hxmllitedll, TRUE, SRC_POS); @@ -2580,7 +2580,7 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) } if (IsOSAtLeast (WIN_VISTA)) - { + { LoadSystemDll (L"spp.dll", &hsppdll, TRUE, SRC_POS); LoadSystemDll (L"vssapi.dll", &vssapidll, TRUE, SRC_POS); LoadSystemDll (L"vsstrace.dll", &hvsstracedll, TRUE, SRC_POS); @@ -2592,21 +2592,21 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) LoadSystemDll (L"cfgmgr32.dll", &hcfgmgr32dll, TRUE, SRC_POS); LoadSystemDll (L"devobj.dll", &hdevobjdll, TRUE, SRC_POS); LoadSystemDll (L"powrprof.dll", &hpowrprofdll, TRUE, SRC_POS); - + LoadSystemDll (L"dwmapi.dll", &hdwmapidll, TRUE, SRC_POS); - + LoadSystemDll (L"crypt32.dll", &hcrypt32dll, TRUE, SRC_POS); LoadSystemDll (L"bcrypt.dll", &hbcryptdll, TRUE, SRC_POS); - LoadSystemDll (L"bcryptprimitives.dll", &hbcryptprimitivesdll, TRUE, SRC_POS); + LoadSystemDll (L"bcryptprimitives.dll", &hbcryptprimitivesdll, TRUE, SRC_POS); } - } + } #else LoadSystemDll (L"WINSCARD.DLL", &hwinscarddll, TRUE, SRC_POS); #endif LoadSystemDll (L"COMCTL32.DLL", &hComctl32Dll, FALSE, SRC_POS); - + // call InitCommonControls function InitCommonControlsFn = (InitCommonControlsPtr) GetProcAddress (hComctl32Dll, "InitCommonControls"); ImageList_AddFn = (ImageList_AddPtr) GetProcAddress (hComctl32Dll, "ImageList_Add"); @@ -2667,7 +2667,7 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) // Language langId[0] = 0; SetPreferredLangId (ConfigReadString ("Language", "", langId, sizeof (langId))); - + if (langId[0] == 0) { if (IsNonInstallMode ()) @@ -2703,7 +2703,7 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) } memset (&wcex, 0, sizeof (wcex)); - wcex.cbSize = sizeof(WNDCLASSEX); + wcex.cbSize = sizeof(WNDCLASSEX); wcex.lpfnWndProc = (WNDPROC) NonInstallUacWndProc; wcex.hInstance = hInstance; wcex.lpszClassName = L"VeraCrypt"; @@ -2781,7 +2781,7 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) break; } } - + /* Get the attributes for the standard dialog class */ if ((GetClassInfoW (hInst, WINDOWS_DIALOG_CLASS, &wc)) == 0) { @@ -2972,7 +2972,7 @@ BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectF &dwResult, NULL); // check variable driver - if ( bResult + if ( bResult && ( (driver->bDetectTCBootLoader != TRUE && driver->bDetectTCBootLoader != FALSE) || (driver->TCBootLoaderDetected != TRUE && driver->TCBootLoaderDetected != FALSE) || (driver->DetectFilesystem != TRUE && driver->DetectFilesystem != FALSE) || @@ -2998,7 +2998,7 @@ BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectF else return FALSE; } - + return TRUE; } @@ -3026,10 +3026,10 @@ BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize) /* Stores the device path of the system partition in SysPartitionDevicePath and the device path of the system drive in SysDriveDevicePath. -IMPORTANT: As this may take a very long time if called for the first time, it should be called only before performing - a dangerous operation (such as header backup restore or formatting a supposedly non-system device) never - at WM_INITDIALOG or any other GUI events -- instead call IsSystemDevicePath (path, hwndDlg, FALSE) for - very fast preliminary GUI checks; also note that right after the "Select Device" dialog exits with an OK +IMPORTANT: As this may take a very long time if called for the first time, it should be called only before performing + a dangerous operation (such as header backup restore or formatting a supposedly non-system device) never + at WM_INITDIALOG or any other GUI events -- instead call IsSystemDevicePath (path, hwndDlg, FALSE) for + very fast preliminary GUI checks; also note that right after the "Select Device" dialog exits with an OK return code, you can use the global flags bSysPartitionSelected and bSysDriveSelected to see if the user selected the system partition/device. After this function completes successfully, the results are cached for the rest of the session and repeated @@ -3037,13 +3037,13 @@ executions complete very fast. Returns TRUE if successful (otherwise FALSE). */ BOOL GetSysDevicePaths (HWND hwndDlg) { if (!bCachedSysDevicePathsValid - || wcslen (SysPartitionDevicePath) <= 1 + || wcslen (SysPartitionDevicePath) <= 1 || wcslen (SysDriveDevicePath) <= 1) { foreach (const HostDevice &device, GetAvailableHostDevices (false, true)) { if (device.ContainsSystem) - StringCchCopyW (device.IsPartition ? SysPartitionDevicePath : SysDriveDevicePath, TC_MAX_PATH, device.Path.c_str()); + StringCchCopyW (device.IsPartition ? SysPartitionDevicePath : SysDriveDevicePath, TC_MAX_PATH, device.Path.c_str()); } if (IsOSAtLeast (WIN_7)) @@ -3070,24 +3070,24 @@ BOOL GetSysDevicePaths (HWND hwndDlg) bCachedSysDevicePathsValid = 1; } - return (bCachedSysDevicePathsValid - && wcslen (SysPartitionDevicePath) > 1 + return (bCachedSysDevicePathsValid + && wcslen (SysPartitionDevicePath) > 1 && wcslen (SysDriveDevicePath) > 1); } -/* Determines whether the device path is the path of the system partition or of the system drive (or neither). -If bReliableRequired is TRUE, very fast execution is guaranteed, but the results cannot be relied upon. +/* Determines whether the device path is the path of the system partition or of the system drive (or neither). +If bReliableRequired is TRUE, very fast execution is guaranteed, but the results cannot be relied upon. If it's FALSE and the function is called for the first time, execution may take up to one minute but the results are reliable. IMPORTANT: As the execution may take a very long time if called for the first time with bReliableRequired set to TRUE, it should be called with bReliableRequired set to TRUE only before performing a dangerous - operation (such as header backup restore or formatting a supposedly non-system device) never at - WM_INITDIALOG or any other GUI events (use IsSystemDevicePath(path, hwndDlg, FALSE) for fast - preliminary GUI checks; also note that right after the "Select Device" dialog exits with an OK + operation (such as header backup restore or formatting a supposedly non-system device) never at + WM_INITDIALOG or any other GUI events (use IsSystemDevicePath(path, hwndDlg, FALSE) for fast + preliminary GUI checks; also note that right after the "Select Device" dialog exits with an OK return code, you can use the global flags bSysPartitionSelected and bSysDriveSelected to see if the user selected the system partition/device). After this function completes successfully, the results are cached for the rest of the session, bReliableRequired -is ignored (TRUE implied), repeated executions complete very fast, and the results are always reliable. +is ignored (TRUE implied), repeated executions complete very fast, and the results are always reliable. Return codes: 1 - it is the system partition path (e.g. \Device\Harddisk0\Partition1) 2 - it is the system drive path (e.g. \Device\Harddisk0\Partition0) @@ -3122,10 +3122,10 @@ int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequire /* Determines whether the path points to a non-system partition on the system drive. IMPORTANT: As this may take a very long time if called for the first time, it should be called - only before performing a dangerous operation, never at WM_INITDIALOG or any other GUI events. + only before performing a dangerous operation, never at WM_INITDIALOG or any other GUI events. Return codes: -0 - it isn't a non-system partition on the system drive -1 - it's a non-system partition on the system drive +0 - it isn't a non-system partition on the system drive +1 - it's a non-system partition on the system drive -1 - the result can't be determined, isn't reliable, or there was an error. */ int IsNonSysPartitionOnSysDrive (const wchar_t *path) { @@ -3165,12 +3165,12 @@ int IsNonSysPartitionOnSysDrive (const wchar_t *path) if (wcsncmp (tmpPath, SysDriveDevicePath, max (wcslen(tmpPath), wcslen(SysDriveDevicePath))) == 0) { - // It is a non-system partition on the system drive + // It is a non-system partition on the system drive return 1; } - else + else { - // The partition is not on the system drive + // The partition is not on the system drive return 0; } } @@ -3415,17 +3415,17 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l LocalizeDialog (hwndDlg, "IDD_RAWDEVICES_DLG"); SendMessage (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0, - LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_TWOCLICKACTIVATE|LVS_EX_LABELTIP - ); + LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_TWOCLICKACTIVATE|LVS_EX_LABELTIP + ); - memset (&LvCol,0,sizeof(LvCol)); - LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; + memset (&LvCol,0,sizeof(LvCol)); + LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; LvCol.pszText = GetString ("DEVICE"); LvCol.cx = CompensateXDPI (186); LvCol.fmt = LVCFMT_LEFT; SendMessage (hList,LVM_INSERTCOLUMNW,0,(LPARAM)&LvCol); - LvCol.pszText = GetString ("DRIVE"); + LvCol.pszText = GetString ("DRIVE"); LvCol.cx = CompensateXDPI (38); LvCol.fmt = LVCFMT_LEFT; SendMessage (hList,LVM_INSERTCOLUMNW,1,(LPARAM)&LvCol); @@ -3479,7 +3479,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l // Path if (!device.IsPartition || device.DynamicVolume) { - if (!device.Floppy && (device.Size == 0) + if (!device.Floppy && (device.Size == 0) && (device.IsPartition || device.Partitions.empty() || device.Partitions[0].Size == 0) ) continue; @@ -3487,7 +3487,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l if (line > 1) { ListItemAdd (hList, item.iItem, L""); - item.iItem = line++; + item.iItem = line++; } if (device.Floppy || device.DynamicVolume) @@ -3540,7 +3540,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l } #endif - item.iItem = line++; + item.iItem = line++; } SendMessageW(hList, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0)); @@ -3563,8 +3563,8 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l { BOOL bEnableOkButton = FALSE; LVITEM LvItem; - memset(&LvItem,0,sizeof(LvItem)); - LvItem.mask = LVIF_TEXT | LVIF_PARAM; + memset(&LvItem,0,sizeof(LvItem)); + LvItem.mask = LVIF_TEXT | LVIF_PARAM; LvItem.iItem = ((LPNMLISTVIEW) lParam)->iItem; LvItem.pszText = lpszFileName; LvItem.cchTextMax = TC_MAX_PATH; @@ -3597,7 +3597,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l int selectedItem = ListView_GetSelectionMark (GetDlgItem (hwndDlg, IDC_DEVICELIST)); if (selectedItem == -1 || itemToDeviceMap.find (selectedItem) == itemToDeviceMap.end()) - return 1; // non-device line selected + return 1; // non-device line selected const HostDevice selectedDevice = itemToDeviceMap[selectedItem]; StringCchCopyW (lpszFileName, TC_MAX_PATH, selectedDevice.Path.c_str()); @@ -3710,7 +3710,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l } } - // Disallow format if the device contains partitions, but not if the partition is virtual or system + // Disallow format if the device contains partitions, but not if the partition is virtual or system if (!selectedDevice.IsVirtualPartition && !bHiddenVolDirect) { @@ -3731,7 +3731,7 @@ BOOL CALLBACK RawDevicesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM l #endif // #ifdef VOLFORMAT } - else + else bSysDriveSelected = FALSE; #ifdef VOLFORMAT @@ -3908,7 +3908,7 @@ BOOL DriverUnload () if (hDriver == INVALID_HANDLE_VALUE) return TRUE; - + try { if (BootEncryption (NULL).GetStatus().DeviceFilterActive) @@ -4025,7 +4025,7 @@ start: } // Try to open a handle to the driver again (keep the mutex in case the other instance failed) - goto start; + goto start; } else { @@ -4034,7 +4034,7 @@ start: if (SystemEncryptionStatus != SYSENC_STATUS_NONE) { // This is an inconsistent state. The config file indicates system encryption should be - // active, but the driver is not running. This may happen e.g. when the pretest fails and + // active, but the driver is not running. This may happen e.g. when the pretest fails and // the user selects "Last Known Good Configuration" from the Windows boot menu. // To fix this, we're going to reinstall the driver, start it, and register it for boot. @@ -4068,7 +4068,7 @@ load: return res; bPortableModeConfirmed = TRUE; - + if (hDriver != INVALID_HANDLE_VALUE) CloseHandle (hDriver); hDriver = CreateFile (WIN32_ROOT_PREFIX, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); @@ -4242,7 +4242,7 @@ BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileN | OFN_PATHMUSTEXIST | OFN_ALLOWMULTISELECT | (keepHistory ? 0 : OFN_DONTADDTORECENT); - + if (!keepHistory) CleanLastVisitedMRU (); @@ -4272,7 +4272,7 @@ BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileN CleanLastVisitedMRU (); status = TRUE; - + ret: SystemFileSelectorCallPending = FALSE; ResetCurrentDirectory(); @@ -4306,10 +4306,10 @@ BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName) } -static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) +static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) { switch(uMsg) { - case BFFM_INITIALIZED: + case BFFM_INITIALIZED: { /* WParam is TRUE since we are passing a path. It would be FALSE if we were passing a pidl. */ @@ -4317,12 +4317,12 @@ static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pDa break; } - case BFFM_SELCHANGED: + case BFFM_SELCHANGED: { wchar_t szDir[TC_MAX_PATH]; /* Set the status window to the currently selected path. */ - if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) + if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) { SendMessage (hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); } @@ -4346,7 +4346,7 @@ BOOL BrowseDirectories (HWND hwndDlg, char *lpszTitle, wchar_t *dirName) CoInitialize (NULL); - if (SUCCEEDED (SHGetMalloc (&pMalloc))) + if (SUCCEEDED (SHGetMalloc (&pMalloc))) { ZeroMemory (&bi, sizeof(bi)); bi.hwndOwner = hwndDlg; @@ -4358,9 +4358,9 @@ BOOL BrowseDirectories (HWND hwndDlg, char *lpszTitle, wchar_t *dirName) bi.lParam = (LPARAM)dirName; pidl = SHBrowseForFolderW (&bi); - if (pidl != NULL) + if (pidl != NULL) { - if (SHGetPathFromIDList(pidl, dirName)) + if (SHGetPathFromIDList(pidl, dirName)) { bOK = TRUE; } @@ -4574,7 +4574,7 @@ static BOOL CALLBACK LocalizeDialogEnum( HWND hwnd, LPARAM font) // Font SendMessageW (hwnd, WM_SETFONT, (WPARAM) font, 0); - + return TRUE; } @@ -4588,7 +4588,7 @@ void LocalizeDialog (HWND hwnd, char *stringId) SetWindowTextW (hwnd, L"VeraCrypt"); else SetWindowTextW (hwnd, GetString (stringId)); - + if (hUserFont != 0) EnumChildWindows (hwnd, LocalizeDialogEnum, (LPARAM) hUserFont); } @@ -4669,10 +4669,10 @@ BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValu DWORD cbLabelLen = (DWORD) ((wcslen (effectiveLabel) + 1) * sizeof (wchar_t)); BOOL bToBeDeleted = FALSE; - StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s\\DefaultLabel", driveStr); - + StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s\\DefaultLabel", driveStr); + if (bSetValue) - lStatus = RegCreateKeyExW (HKEY_CURRENT_USER, wszRegPath, NULL, NULL, 0, + lStatus = RegCreateKeyExW (HKEY_CURRENT_USER, wszRegPath, NULL, NULL, 0, KEY_READ | KEY_WRITE | KEY_SET_VALUE, NULL, &hKey, NULL); else lStatus = RegOpenKeyExW (HKEY_CURRENT_USER, wszRegPath, 0, KEY_READ | KEY_WRITE | KEY_SET_VALUE, &hKey); @@ -4696,7 +4696,7 @@ BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValu if (bToBeDeleted) { - StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s", driveStr); + StringCbPrintfW (wszRegPath, sizeof (wszRegPath), L"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\DriveIcons\\%s", driveStr); lStatus = RegOpenKeyExW (HKEY_CURRENT_USER, wszRegPath, 0, KEY_READ | KEY_WRITE | KEY_SET_VALUE, &hKey); if (ERROR_SUCCESS == lStatus) { @@ -4722,7 +4722,7 @@ wstring GetUserFriendlyVersionString (int version) versionString.insert (version > 0xfff ? 2 : 1,L"."); if (versionString[versionString.length()-1] == L'0') - versionString.erase (versionString.length()-1, 1); + versionString.erase (versionString.length()-1, 1); return (versionString); } @@ -4774,7 +4774,7 @@ bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr) arr.clear(); if (len %2) return false; - + for (i = 0; i < len/2; i++) { if (!HexToByte (*hexStr++, b1) || !HexToByte (*hexStr++, b2)) @@ -4837,7 +4837,7 @@ void GetSpeedString (unsigned __int64 speed, wchar_t *str, size_t cbStr) { static wchar_t *b, *kb, *mb, *gb, *tb, *pb; static int serNo; - + if (b == NULL || serNo != LocalizationSerialNo) { serNo = LocalizationSerialNo; @@ -4920,7 +4920,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) } break; } - + /* Render the results */ SendMessage (hList,LVM_DELETEALLITEMS,0,(LPARAM)&LvItem); @@ -4934,7 +4934,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) LvItem.iItem = i; LvItem.iSubItem = 0; LvItem.pszText = (LPWSTR) benchmarkTable[i].name; - SendMessageW (hList, LVM_INSERTITEM, 0, (LPARAM)&LvItem); + SendMessageW (hList, LVM_INSERTITEM, 0, (LPARAM)&LvItem); #if PKCS5_BENCHMARKS wcscpy (item1, L"-"); @@ -4944,7 +4944,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) LvItem.iSubItem = 1; LvItem.pszText = item1; - SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); + SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); #if PKCS5_BENCHMARKS wcscpy (item1, L"-"); @@ -4954,7 +4954,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) LvItem.iSubItem = 2; LvItem.pszText = item1; - SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); + SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); #if PKCS5_BENCHMARKS swprintf (item1, L"%d t", benchmarkTable[i].encSpeed); @@ -4964,7 +4964,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) LvItem.iSubItem = 3; LvItem.pszText = item1; - SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); + SendMessageW (hList, LVM_SETITEMW, 0, (LPARAM)&LvItem); } SendMessageW(hList, LVM_SETCOLUMNWIDTH, 0, MAKELPARAM(LVSCW_AUTOSIZE_USEHEADER, 0)); @@ -4978,7 +4978,7 @@ static void DisplayBenchmarkResults (HWND hwndDlg) typedef struct { HWND hBenchDlg; - BOOL bStatus; + BOOL bStatus; } BenchmarkThreadParam; static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg); @@ -5049,9 +5049,9 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) #if HASH_FNC_BENCHMARKS /* Measures the speed at which each of the hash algorithms processes the message to produce - a single digest. + a single digest. - The hash algorithm benchmarks are included here for development purposes only. Do not enable + The hash algorithm benchmarks are included here for development purposes only. Do not enable them when building a public release (the benchmark GUI strings wouldn't make sense). */ { @@ -5062,7 +5062,7 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) sha256_ctx s256ctx; int hid; - for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) + for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) { if (QueryPerformanceCounter (&performanceCountStart) == 0) goto counter_error; @@ -5112,21 +5112,21 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) #elif PKCS5_BENCHMARKS // #if HASH_FNC_BENCHMARKS /* Measures the time that it takes for the PKCS-5 routine to derive a header key using - each of the implemented PRF algorithms. + each of the implemented PRF algorithms. - The PKCS-5 benchmarks are included here for development purposes only. Do not enable + The PKCS-5 benchmarks are included here for development purposes only. Do not enable them when building a public release (the benchmark GUI strings wouldn't make sense). */ { int thid, i; char dk[MASTER_KEYDATA_SIZE]; char *tmp_salt = {"\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF\x01\x23\x45\x67\x89\xAB\xCD\xEF\x00\x11\x22\x33\x44\x55\x66\x77\x88\x99\xAA\xBB\xCC\xDD\xEE\xFF"}; - for (thid = FIRST_PRF_ID; thid <= LAST_PRF_ID; thid++) + for (thid = FIRST_PRF_ID; thid <= LAST_PRF_ID; thid++) { if (QueryPerformanceCounter (&performanceCountStart) == 0) goto counter_error; - for (i = 1; i <= 5; i++) + for (i = 1; i <= 5; i++) { switch (thid) { @@ -5167,7 +5167,7 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) #else // #elif PKCS5_BENCHMARKS /* Encryption algorithm benchmarks */ - + for (ci->ea = EAGetFirst(); ci->ea != 0; ci->ea = EAGetNext(ci->ea)) { if (!EAIsFormatEnabled (ci->ea)) @@ -5226,7 +5226,7 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) return TRUE; counter_error: - + if (ci) crypto_close (ci); @@ -5265,11 +5265,11 @@ BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lP benchmarkSortMethod = BENCHMARK_SORT_BY_SPEED; SendMessage (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0, - LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_LABELTIP - ); + LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_LABELTIP + ); - memset (&LvCol,0,sizeof(LvCol)); - LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; + memset (&LvCol,0,sizeof(LvCol)); + LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; LvCol.pszText = GetString ("ALGORITHM"); LvCol.cx = CompensateXDPI (114); LvCol.fmt = LVCFMT_LEFT; @@ -5518,7 +5518,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA SetTimer (hwndDlg, 0xfd, RANDPOOL_DISPLAY_REFRESH_INTERVAL, NULL); SendMessage (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE); - + hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR); SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel); SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0); @@ -5553,7 +5553,7 @@ static BOOL CALLBACK RandomPoolEnrichementDlgProc (HWND hwndDlg, UINT msg, WPARA else if (bUseMask) { /* use mask to compute a randomized ascii representation */ - tmpByte = (randPool[row * RANDPOOL_DISPLAY_COLUMNS + col] - + tmpByte = (randPool[row * RANDPOOL_DISPLAY_COLUMNS + col] - lastRandPool[row * RANDPOOL_DISPLAY_COLUMNS + col]) ^ maskRandPool [row * RANDPOOL_DISPLAY_COLUMNS + col]; tmp[0] = (wchar_t) (((tmpByte >> 4) % 6) + L'*'); tmp[1] = (wchar_t) (((tmpByte & 0x0F) % 6) + L'*'); @@ -5714,8 +5714,8 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0); SendMessage (hEntropyBar, PBM_SETSTATE, PBST_ERROR, 0); -#ifndef VOLFORMAT - if (Randinit ()) +#ifndef VOLFORMAT + if (Randinit ()) { handleError (hwndDlg, (CryptoAPILastError == ERROR_SUCCESS)? ERR_RAND_INIT_FAILED : ERR_CAPI_INIT_FAILED, SRC_POS); EndDialog (hwndDlg, IDCLOSE); @@ -5761,7 +5761,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP else if (bUseMask) { /* use mask to compute a randomized ASCII representation */ - tmpByte = (randPool[row * RANDPOOL_DISPLAY_COLUMNS + col] - + tmpByte = (randPool[row * RANDPOOL_DISPLAY_COLUMNS + col] - lastRandPool[row * RANDPOOL_DISPLAY_COLUMNS + col]) ^ maskRandPool [row * RANDPOOL_DISPLAY_COLUMNS + col]; tmp[0] = (wchar_t) (((tmpByte >> 4) % 6) + L'*'); tmp[1] = (wchar_t) (((tmpByte & 0x0F) % 6) + L'*'); @@ -5889,7 +5889,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP for (i= 0; i < keyfilesCount; i++) { StringCbCopyW(szFileName, sizeof(szFileName), szDirName); - + if (i > 0) { StringCbPrintfW(szSuffix, sizeof(szSuffix), L"_%d", i); @@ -5946,7 +5946,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP NormalCursor(); return 1; } - + /* since keyfilesSize < 1024 * 1024, we mask with 0x000FFFFF */ keyfilesSize = (long) (((unsigned long) keyfilesSize) & 0x000FFFFF); @@ -5954,7 +5954,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP keyfilesSize += 64; } - /* Generate the keyfile */ + /* Generate the keyfile */ if (!RandgetBytesFull (hwndDlg, keyfile, keyfilesSize, TRUE, TRUE)) { _close (fhKeyfile); @@ -5962,7 +5962,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP TCfree(keyfile); NormalCursor(); return 1; - } + } /* Write the keyfile */ status = _write (fhKeyfile, keyfile, keyfilesSize); @@ -5975,7 +5975,7 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP NormalCursor(); handleWin32Error (hwndDlg, SRC_POS); return 1; - } + } } TCfree(keyfile); @@ -5994,7 +5994,7 @@ exit: WaitCursor(); KillTimer (hwndDlg, 0xfd); -#ifndef VOLFORMAT +#ifndef VOLFORMAT RandStop (FALSE); #endif /* Cleanup */ @@ -6109,7 +6109,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { ShowWindow(GetDlgItem(hwndDlg, IDC_TESTS_MESSAGE), SW_SHOWNORMAL); SetWindowTextW(GetDlgItem(hwndDlg, IDC_TESTS_MESSAGE), GetString ("TESTS_FAILED")); - } + } else { ShowWindow(GetDlgItem(hwndDlg, IDC_TESTS_MESSAGE), SW_SHOWNORMAL); @@ -6215,7 +6215,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) inputtext[n] = (char) x; } - + // XTS if (bXTSTestEnabled) { @@ -6272,10 +6272,10 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) blockNo = (int) SendMessage (GetDlgItem (hwndDlg, IDC_TEST_BLOCK_NUMBER), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_TEST_BLOCK_NUMBER), CB_GETCURSEL, 0, 0), 0); } // if (bXTSTestEnabled) - + /* Perform the actual tests */ - if (ks != CB_ERR && pt != CB_ERR) + if (ks != CB_ERR && pt != CB_ERR) { char tmp[128]; int tmpRetVal; @@ -6372,7 +6372,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) return 0; } -void +void ResetCipherTest(HWND hwndDlg, int idTestCipher) { int ndx; @@ -6406,7 +6406,7 @@ ResetCipherTest(HWND hwndDlg, int idTestCipher) SetWindowText(GetDlgItem(hwndDlg, IDC_SECONDARY_KEY), L"0000000000000000000000000000000000000000000000000000000000000000"); SetWindowText(GetDlgItem(hwndDlg, IDC_TEST_DATA_UNIT_NUMBER), L"0"); - + SetWindowText(GetDlgItem(hwndDlg, IDC_PLAINTEXT), L"0000000000000000"); SetWindowText(GetDlgItem(hwndDlg, IDC_CIPHERTEXT), L"0000000000000000"); @@ -6476,7 +6476,7 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA pStr++; pwStr++; - do + do { if (*pStr != 0) { @@ -6490,7 +6490,7 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA hUserFont), nLongestButtonCaptionWidth); - nLongestButtonCaptionCharLen = max (nLongestButtonCaptionCharLen, + nLongestButtonCaptionCharLen = max (nLongestButtonCaptionCharLen, (int) wcslen ((const wchar_t *) (bResolve ? GetString(*pStr) : *pwStr))); } @@ -6509,14 +6509,14 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA // Length of main message in characters (not bytes) nMainTextLenInChars = (int) wcslen ((const wchar_t *) (bResolve ? GetString(*(pStrOrig+1)) : *(pwStrOrig+1))); - if (nMainTextLenInChars > 200 + if (nMainTextLenInChars > 200 && nMainTextLenInChars / nLongestButtonCaptionCharLen >= 10) { - // As the main text is longer than 200 characters, we will "pad" the widest button caption with - // spaces (if it is not wide enough) so as to increase the width of the whole dialog window. + // As the main text is longer than 200 characters, we will "pad" the widest button caption with + // spaces (if it is not wide enough) so as to increase the width of the whole dialog window. // Otherwise, it would look too tall (dialog boxes look better when they are more wide than tall). nLongestButtonCaptionWidth = CompensateXDPI (max ( - nLongestButtonCaptionWidth, + nLongestButtonCaptionWidth, min (350, nMainTextLenInChars))); } @@ -6544,10 +6544,10 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA do { - offset = FindString ((char *) (bResolve ? GetString(*(pStrOrig+1)) : *(pwStrOrig+1)), + offset = FindString ((char *) (bResolve ? GetString(*(pStrOrig+1)) : *(pwStrOrig+1)), (char *) L"\n", - nMainTextLenInChars * 2, - (int) wcslen (L"\n") * 2, + nMainTextLenInChars * 2, + (int) wcslen (L"\n") * 2, offset + 1); newLineSeqCount++; @@ -6568,8 +6568,8 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA // Reduction in height according to the number of shown buttons vertSubOffset = ((MAX_MULTI_CHOICES - nActiveChoices) * nBaseButtonHeight); - if (horizSubOffset > 0 - || vertMsgHeightOffset > 0 + if (horizSubOffset > 0 + || vertMsgHeightOffset > 0 || vertOffset > 0) { // Resize/move each button if necessary @@ -6603,7 +6603,7 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA trec.right + 2 + horizSubOffset, trec.bottom + 2, TRUE); - + GetWindowRect(GetDlgItem(hwndDlg, IDC_MC_DLG_HR2), &rec); GetClientRect(GetDlgItem(hwndDlg, IDC_MC_DLG_HR2), &trec); MoveWindow (GetDlgItem(hwndDlg, IDC_MC_DLG_HR2), @@ -6657,7 +6657,7 @@ BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPA BOOL CheckCapsLock (HWND hwnd, BOOL quiet) { - if ((GetKeyState(VK_CAPITAL) & 1) != 0) + if ((GetKeyState(VK_CAPITAL) & 1) != 0) { if (!quiet) { @@ -6686,7 +6686,7 @@ BOOL CheckFileExtension (wchar_t *fileName) L".vb", L".vbe", L".vbs", L".vsmacros", L".vss", L".vst", L".vsw", L".ws", L".wsc", L".wsf", L".wsh", L".xsd", L".xsl", // These additional file extensions are usually watched by antivirus programs L".386", L".acm", L".ade", L".adp", L".ani", L".app", L".asd", L".asf", L".asx", L".awx", L".ax", L".boo", L".bz2", L".cdf", - L".class", L".dhtm", L".dhtml",L".dlo", L".emf", L".eml", L".flt", L".fot", L".gz", L".hlp", L".htm", L".html", L".ini", + L".class", L".dhtm", L".dhtml",L".dlo", L".emf", L".eml", L".flt", L".fot", L".gz", L".hlp", L".htm", L".html", L".ini", L".j2k", L".jar", L".jff", L".jif", L".jmh", L".jng", L".jp2", L".jpe", L".jpeg", L".jpg", L".lsp", L".mod", L".nws", L".obj", L".olb", L".osd", L".ov1", L".ov2", L".ov3", L".ovl", L".ovl", L".ovr", L".pdr", L".pgm", L".php", L".pkg", L".pl", L".png", L".pot", L".pps", L".ppt", L".ps1", L".ps1xml", L".psc1", L".rar", L".rpl", L".rtf", L".sbf", L".script", L".sh", L".sha", L".shtm", @@ -6858,7 +6858,7 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced) memcpy (wszLabel, prop.wszLabel, sizeof (wszLabel)); bDriverSetLabel = prop.bDriverSetLabel; } - + unmount.nDosDriveNo = nDosDriveNo; unmount.ignoreOpenFiles = forced; @@ -6928,11 +6928,11 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap) } } - dbv.dbcv_size = sizeof (dbv); - dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME; + dbv.dbcv_size = sizeof (dbv); + dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME; dbv.dbcv_reserved = 0; dbv.dbcv_unitmask = driveMap; - dbv.dbcv_flags = 0; + dbv.dbcv_flags = 0; UINT timeOut = 1000; @@ -7032,8 +7032,8 @@ BOOL CALLBACK WaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) SetWindowLongPtrW (hProgress, GWL_STYLE, PBS_MARQUEE | GetWindowLongPtrW (hProgress, GWL_STYLE)); ::SendMessageW(hProgress, PBM_SETMARQUEE, (WPARAM) TRUE, (LPARAM) 0); } - - thParam->hwnd = hwndDlg; + + thParam->hwnd = hwndDlg; // For now, we don't have system menu is the resources but we leave this code // if it is enabled in the future @@ -7047,8 +7047,8 @@ BOOL CALLBACK WaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) HICON hIcon = (HICON)::LoadImage(hInst, MAKEINTRESOURCE(IDI_TRUECRYPT_ICON), IMAGE_ICON, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON), LR_DEFAULTCOLOR); ::SendMessage(hwndDlg, WM_SETICON, TRUE, (LPARAM)hIcon); HICON hIconSmall = (HICON)::LoadImage(hInst, MAKEINTRESOURCE(IDI_TRUECRYPT_ICON), IMAGE_ICON, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON), LR_DEFAULTCOLOR); - ::SendMessage(hwndDlg, WM_SETICON, FALSE, (LPARAM)hIconSmall); - } + ::SendMessage(hwndDlg, WM_SETICON, FALSE, (LPARAM)hIconSmall); + } LocalizeDialog (hwndDlg, NULL); _beginthread(WaitThread, 0, thParam); @@ -7076,26 +7076,26 @@ BOOL CALLBACK WaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) void BringToForeground(HWND hWnd) { if(!::IsWindow(hWnd)) return; - + DWORD lockTimeOut = 0; HWND hCurrWnd = ::GetForegroundWindow(); DWORD dwThisTID = ::GetCurrentThreadId(), dwCurrTID = ::GetWindowThreadProcessId(hCurrWnd,0); - + if (hCurrWnd != hWnd) { if(dwThisTID != dwCurrTID) { ::AttachThreadInput(dwThisTID, dwCurrTID, TRUE); - + ::SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT,0,&lockTimeOut,0); ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,0,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); - + ::AllowSetForegroundWindow(ASFW_ANY); } - + ::SetForegroundWindow(hWnd); - + if(dwThisTID != dwCurrTID) { ::SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT,0,(PVOID)lockTimeOut,SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE); @@ -7168,12 +7168,12 @@ static BOOL PerformMountIoctl (MOUNT_STRUCT* pmount, LPDWORD pdwResult, BOOL use CreateFullVolumePath (pmount->wszVolume, sizeof(pmount->wszVolume), devicePath.c_str(), &bDevice); } } - + return DeviceIoControl (hDriver, TC_IOCTL_MOUNT_VOLUME, pmount, sizeof (MOUNT_STRUCT), pmount, sizeof (MOUNT_STRUCT), pdwResult, NULL); } -// specific definitions and implementation for support of mount operation +// specific definitions and implementation for support of mount operation // in wait dialog mechanism typedef struct @@ -7306,7 +7306,7 @@ retry: path = path.substr (4); StringCchCopyW (volumePath, TC_MAX_PATH, path.c_str()); } - + if (path.find (L"Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2) { wstring resolvedPath = VolumeGuidPathToDevicePath (path); @@ -7318,7 +7318,7 @@ retry: if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0)) { std::vector<byte> arr; - if ( (path.length() == (3 + 2*VOLUME_ID_SIZE)) + if ( (path.length() == (3 + 2*VOLUME_ID_SIZE)) && HexWideStringToArray (path.c_str() + 3, arr) && (arr.size() == VOLUME_ID_SIZE) ) @@ -7355,7 +7355,7 @@ retry: mount.BytesPerSector = bps; mount.BytesPerPhysicalSector = bps; } - + if (IsOSAtLeast (WIN_VISTA)) { if ( (wcslen(root) >= 2) @@ -7463,7 +7463,7 @@ retry: goto retry; } - // Ask user + // Ask user if (IDYES == AskWarnNoYes ("FILE_IN_USE", hwndDlg)) { mount.bExclusiveAccess = FALSE; @@ -7484,12 +7484,12 @@ retry: { if (mount.nReturnCode == ERR_PASSWORD_WRONG) { - // Do not report wrong password, if not instructed to + // Do not report wrong password, if not instructed to if (bReportWrongPassword) { IncreaseWrongPwdRetryCount (1); // We increase the count here only if bReportWrongPassword is TRUE, because "Auto-Mount All Devices" and other callers do it separately - if (WrongPwdRetryCountOverLimit () + if (WrongPwdRetryCountOverLimit () && !mount.UseBackupHeader) { // Retry using embedded header backup (if any) @@ -7537,7 +7537,7 @@ retry: if (bReportWrongPassword && !Silent) Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK", hwndDlg); } - + LastMountedVolumeDirty = mount.FilesystemDirty; if (mount.FilesystemDirty) @@ -7661,7 +7661,7 @@ retry: } else { - ShowWaitDialog (hwndDlg, FALSE, UnmountWaitThreadProc, ¶m); + ShowWaitDialog (hwndDlg, FALSE, UnmountWaitThreadProc, ¶m); } SetLastError (param.dwLastError); @@ -7689,8 +7689,8 @@ retry: Error ("UNMOUNT_FAILED", hwndDlg); return FALSE; - } - + } + BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, nDosDriveNo, 0); return TRUE; @@ -7939,7 +7939,7 @@ BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry) ZeroMemory (diskGeometry, sizeof (DISK_GEOMETRY)); if ( DeviceIoControl (hDev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, diskGeometry, sizeof (DISK_GEOMETRY), &bytesRead, NULL) - && (bytesRead == sizeof (DISK_GEOMETRY)) + && (bytesRead == sizeof (DISK_GEOMETRY)) && diskGeometry->BytesPerSector) { bResult = TRUE; @@ -8006,7 +8006,7 @@ int FileSystemAppearsEmpty (const wchar_t *devicePath) // Returns the free space on the specified partition (volume) in bytes. If the 'occupiedBytes' pointer // is not NULL, size of occupied space (in bytes) is written to the pointed location. In addition, if the -// 'percent' pointer is not NULL, % of free space is stored in the pointed location. If there's an error, +// 'percent' pointer is not NULL, % of free space is stored in the pointed location. If there's an error, // returns -1. __int64 GetStatsFreeSpaceOnPartition (const wchar_t *devicePath, float *percentFree, __int64 *occupiedBytes, BOOL silent) { @@ -8094,12 +8094,12 @@ HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath) return INVALID_HANDLE_VALUE; - // Try to lock the volume first so that dismount is not forced. + // Try to lock the volume first so that dismount is not forced. // If we fail, we will dismount anyway even if it needs to be forced. CloseVolumeExplorerWindows (MainDlg, driveLetterNo); - while (!(bResult = DeviceIoControl (hVolume, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL)) + while (!(bResult = DeviceIoControl (hVolume, FSCTL_LOCK_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL)) && attempt > 0) { Sleep (UNMOUNT_AUTO_RETRY_DELAY); @@ -8111,7 +8111,7 @@ HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath) attempt = UNMOUNT_MAX_AUTO_RETRIES; - while (!(bResult = DeviceIoControl (hVolume, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL)) + while (!(bResult = DeviceIoControl (hVolume, FSCTL_DISMOUNT_VOLUME, NULL, 0, NULL, 0, &dwResult, NULL)) && attempt > 0) { Sleep (UNMOUNT_AUTO_RETRY_DELAY); @@ -8125,12 +8125,12 @@ HANDLE DismountDrive (wchar_t *devName, wchar_t *devicePath) } // Returns -1 if the specified string is not found in the buffer. Otherwise, returns the -// offset of the first occurrence of the string. The string and the buffer may contain zeroes, +// offset of the first occurrence of the string. The string and the buffer may contain zeroes, // which do NOT terminate them. int64 FindString (const char *buf, const char *str, int64 bufLen, int64 strLen, int64 startOffset) { - if (buf == NULL - || str == NULL + if (buf == NULL + || str == NULL || strLen > bufLen || bufLen < 1 || strLen < 1 @@ -8172,7 +8172,7 @@ BOOL FileExists (const wchar_t *filePathPtr) // Searches the file from its end for the LAST occurrence of the string str. // The string may contain zeroes, which do NOT terminate the string. -// If the string is found, its offset from the start of the file is returned. +// If the string is found, its offset from the start of the file is returned. // If the string isn't found or if any error occurs, -1 is returned. __int64 FindStringInFile (const wchar_t *filePath, const char* str, int strLen) { @@ -8188,8 +8188,8 @@ __int64 FindStringInFile (const wchar_t *filePath, const char* str, int strLen) int filePosStep; __int64 retVal = -1; - if (filePos <= 0 - || buffer == NULL + if (filePos <= 0 + || buffer == NULL || strLen > bufSize || strLen < 1) { @@ -8223,7 +8223,7 @@ __int64 FindStringInFile (const wchar_t *filePath, const char* str, int strLen) if (SetFilePointerEx (src, seekOffset, &seekOffsetNew, FILE_BEGIN) == 0) goto fsif_end; - if ((readRetVal = ReadFile (src, buffer, bufSize, &bytesRead, NULL)) == 0 + if ((readRetVal = ReadFile (src, buffer, bufSize, &bytesRead, NULL)) == 0 || bytesRead == 0) goto fsif_end; @@ -8316,7 +8316,7 @@ BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile) return TCCopyFileBase (src, dst); } -// If bAppend is TRUE, the buffer is appended to an existing file. If bAppend is FALSE, any existing file +// If bAppend is TRUE, the buffer is appended to an existing file. If bAppend is FALSE, any existing file // is replaced. If an error occurs, the incomplete file is deleted (provided that bAppend is FALSE). BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD inputLength, BOOL bAppend, BOOL bRenameIfFailed) { @@ -8355,7 +8355,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, } } } - + if (dst == INVALID_HANDLE_VALUE) { SetLastError (dwLastError); @@ -8376,7 +8376,7 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, { // If CREATE_ALWAYS is used, ERROR_ALREADY_EXISTS is returned after successful overwrite // of an existing file (it's not an error) - if (! (GetLastError() == ERROR_ALREADY_EXISTS && !bAppend) ) + if (! (GetLastError() == ERROR_ALREADY_EXISTS && !bAppend) ) handleWin32Error (MainDlg, SRC_POS); } @@ -8405,7 +8405,7 @@ BOOL TCFlushFile (FILE *f) // Prints a UTF-16 text (note that this involves a real printer, not a screen). // textByteLen - length of the text in bytes -// title - printed as part of the page header and used as the filename for a temporary file +// title - printed as part of the page header and used as the filename for a temporary file BOOL PrintHardCopyTextUTF16 (wchar_t *text, wchar_t *title, size_t textByteLen) { wchar_t cl [MAX_PATH*3] = {L"/p \""}; @@ -8486,7 +8486,7 @@ BOOL IsNonInstallMode () else { // This is also returned if we fail to determine the status (it does not mean that portable mode is disproved). - return FALSE; + return FALSE; } } else @@ -8510,7 +8510,7 @@ BOOL IsNonInstallMode () if (FileExists (path)) { // To maintain consistency and safety, if the system encryption config file exits, we cannot - // allow portable mode. (This happens e.g. when the pretest fails and the user selects + // allow portable mode. (This happens e.g. when the pretest fails and the user selects // "Last Known Good Configuration" from the Windows boot menu.) // However, if UAC elevation is needed, we have to confirm portable mode first (after we are elevated, we won't). @@ -8522,7 +8522,7 @@ BOOL IsNonInstallMode () } // As the driver was not found in the system path, we can predict that we will run in portable mode - return TRUE; + return TRUE; } else CloseHandle (hDriverTmp); @@ -8669,7 +8669,7 @@ void CleanLastVisitedMRU (void) if ((len = ReadRegistryBytes (regPath, key, (char *) strTmp, sizeof (strTmp))) > 0) { - if (_wcsicmp (strTmp, strToMatch) == 0) + if (_wcsicmp (strTmp, strToMatch) == 0) { char buf[65536], bufout[sizeof (buf)]; @@ -8752,7 +8752,7 @@ LRESULT ListItemAdd (HWND list, int index, const wchar_t *string) li.mask = LVIF_TEXT; li.pszText = (wchar_t*) string; - li.iItem = index; + li.iItem = index; li.iSubItem = 0; return ListView_InsertItem (list, &li); } @@ -8765,7 +8765,7 @@ LRESULT ListSubItemSet (HWND list, int index, int subIndex, const wchar_t *strin li.mask = LVIF_TEXT; li.pszText = (wchar_t*) string; - li.iItem = index; + li.iItem = index; li.iSubItem = subIndex; return ListView_SetItem (list, &li); } @@ -8825,7 +8825,7 @@ BOOL LoadInt32 (const wchar_t *filePath, unsigned __int32 *result, __int64 fileO if (SetFilePointerEx (src, seekOffset, &seekOffsetNew, FILE_BEGIN) == 0) goto fsif_end; - if (ReadFile (src, buffer, bufSize, &bytesRead, NULL) == 0 + if (ReadFile (src, buffer, bufSize, &bytesRead, NULL) == 0 || bytesRead != bufSize) goto fsif_end; @@ -8869,7 +8869,7 @@ BOOL LoadInt16 (const wchar_t *filePath, int *result, __int64 fileOffset) if (SetFilePointerEx (src, seekOffset, &seekOffsetNew, FILE_BEGIN) == 0) goto fsif_end; - if (ReadFile (src, buffer, bufSize, &bytesRead, NULL) == 0 + if (ReadFile (src, buffer, bufSize, &bytesRead, NULL) == 0 || bytesRead != bufSize) goto fsif_end; @@ -9038,7 +9038,7 @@ wchar_t *GetProgramConfigPath (wchar_t *fileName) std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy) { wchar_t sysPath[TC_MAX_PATH]; - + if (Is64BitOs() && useLegacy) { typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPWSTR lpBuffer, UINT uSize); @@ -9073,18 +9073,18 @@ void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *te return; } - NOTIFYICONDATAW tnid; + NOTIFYICONDATAW tnid; ZeroMemory (&tnid, sizeof (tnid)); - tnid.cbSize = sizeof (tnid); - tnid.hWnd = hwnd; - tnid.uID = IDI_TRUECRYPT_ICON; + tnid.cbSize = sizeof (tnid); + tnid.hWnd = hwnd; + tnid.uID = IDI_TRUECRYPT_ICON; //tnid.uVersion = (IsOSAtLeast (WIN_VISTA) ? NOTIFYICON_VERSION_4 : NOTIFYICON_VERSION); //Shell_NotifyIconW (NIM_SETVERSION, &tnid); - tnid.uFlags = NIF_INFO; + tnid.uFlags = NIF_INFO; tnid.dwInfoFlags = (warning ? NIIF_WARNING : NIIF_INFO); tnid.uTimeout = (IsOSAtLeast (WIN_VISTA) ? 1000 : 5000); // in ms @@ -9100,12 +9100,12 @@ void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *te // Either of the pointers may be NULL void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd) { - if (Silent) + if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, - headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), - textStringId == NULL ? L" " : GetString (textStringId), + headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), + textStringId == NULL ? L" " : GetString (textStringId), FALSE); } @@ -9113,12 +9113,12 @@ void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd) // Either of the pointers may be NULL void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd) { - if (Silent) + if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, - headingString == NULL ? L"VeraCrypt" : headingString, - textString == NULL ? L" " : textString, + headingString == NULL ? L"VeraCrypt" : headingString, + textString == NULL ? L" " : textString, FALSE); } @@ -9126,12 +9126,12 @@ void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd) // Either of the pointers may be NULL void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd) { - if (Silent) + if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, - headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), - textStringId == NULL ? L" " : GetString (textStringId), + headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), + textStringId == NULL ? L" " : GetString (textStringId), TRUE); } @@ -9139,12 +9139,12 @@ void WarningBalloon (char *headingStringId, char *textStringId, HWND hwnd) // Either of the pointers may be NULL void WarningBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd) { - if (Silent) + if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, - headingString == NULL ? L"VeraCrypt" : headingString, - textString == NULL ? L" " : textString, + headingString == NULL ? L"VeraCrypt" : headingString, + textString == NULL ? L" " : textString, TRUE); } @@ -9347,7 +9347,7 @@ int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd) params.strings = &strings[0]; params.bold = bBold; - return (int) DialogBoxParamW (hInst, + return (int) DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_MULTI_CHOICE_DLG), hwnd, (DLGPROC) MultiChoiceDialogProc, (LPARAM) ¶ms); } @@ -9356,7 +9356,7 @@ int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd) BOOL ConfigWriteBegin () { DWORD size; - if (ConfigFileHandle != NULL) + if (ConfigFileHandle != NULL) return FALSE; if (ConfigBuffer == NULL) @@ -9540,7 +9540,7 @@ void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, in *pbModified = TRUE; if (!bOnlyCheckModified) ConfigReadString (configKey, defaultValue, str, maxLen); - + } } @@ -9597,7 +9597,7 @@ BOOL LoadDefaultKeyFilesParam (void) char *xml = defaultKeyfilesFile; KeyFile *kf; - if (xml == NULL) + if (xml == NULL) return FALSE; KeyFileRemoveAll (&defaultKeyFilesParam.FirstKeyFile); @@ -9738,7 +9738,7 @@ BOOL IsServerOS () } -// Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if +// Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if // there's an error, returns FALSE. BOOL IsHiddenOSRunning (void) { @@ -9777,30 +9777,30 @@ BOOL EnableWow64FsRedirection (BOOL enable) BOOL RestartComputer (void) { - TOKEN_PRIVILEGES tokenPrivil; - HANDLE hTkn; + TOKEN_PRIVILEGES tokenPrivil; + HANDLE hTkn; if (!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY|TOKEN_ADJUST_PRIVILEGES, &hTkn)) { - return false; + return false; } - LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, &tokenPrivil.Privileges[0].Luid); - tokenPrivil.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; - tokenPrivil.PrivilegeCount = 1; + LookupPrivilegeValue (NULL, SE_SHUTDOWN_NAME, &tokenPrivil.Privileges[0].Luid); + tokenPrivil.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; + tokenPrivil.PrivilegeCount = 1; - AdjustTokenPrivileges (hTkn, false, &tokenPrivil, 0, (PTOKEN_PRIVILEGES) NULL, 0); - if (GetLastError() != ERROR_SUCCESS) + AdjustTokenPrivileges (hTkn, false, &tokenPrivil, 0, (PTOKEN_PRIVILEGES) NULL, 0); + if (GetLastError() != ERROR_SUCCESS) { CloseHandle(hTkn); - return false; + return false; } if (!ExitWindowsEx (EWX_REBOOT, - SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED)) + SHTDN_REASON_MAJOR_OTHER | SHTDN_REASON_MINOR_OTHER | SHTDN_REASON_FLAG_PLANNED)) { CloseHandle(hTkn); - return false; + return false; } CloseHandle(hTkn); @@ -9873,7 +9873,7 @@ std::wstring GetWindowsEdition () osname += L"-server"; if (IsOSAtLeast (WIN_VISTA)) - { + { if (home) osname += L"-home"; else if (wcsstr (productName, L"Standard") != 0) @@ -10068,7 +10068,7 @@ void HandleDriveNotReadyError (HWND hwnd) 0, KEY_READ, &hkey) != ERROR_SUCCESS) return; - if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS + if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS && value != 0) { Warning ("SYS_AUTOMOUNT_DISABLED", hwnd); @@ -10124,7 +10124,7 @@ BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam) BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size) { - HGLOBAL hResL; + HGLOBAL hResL; HRSRC hRes; hRes = FindResource (NULL, MAKEINTRESOURCE(resourceId), resourceType); @@ -10132,7 +10132,7 @@ BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size) if (size != NULL) *size = SizeofResource (NULL, hRes); - + return (BYTE *) LockResource (hResL); } @@ -10205,8 +10205,8 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password if (context->IsDevice) { - // Try to gain "raw" access to the partition in case there is a live filesystem on it (otherwise, - // the NTFS driver guards hidden sectors and prevents e.g. header backup restore after the user + // Try to gain "raw" access to the partition in case there is a live filesystem on it (otherwise, + // the NTFS driver guards hidden sectors and prevents e.g. header backup restore after the user // accidentally quick-formats a dismounted partition-hosted TrueCrypt volume as NTFS, etc.) DeviceIoControl (context->HostFileHandle, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &dwResult, NULL); @@ -10299,7 +10299,7 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password && context->IsDevice) { // If FSCTL_ALLOW_EXTENDED_DASD_IO failed and there is a live filesystem on the partition, then the - // filesystem driver may report EOF when we are reading hidden sectors (when the filesystem is + // filesystem driver may report EOF when we are reading hidden sectors (when the filesystem is // shorter than the partition). This can happen for example after the user quick-formats a dismounted // partition-hosted TrueCrypt volume and then tries to read the embedded backup header. @@ -10355,7 +10355,7 @@ void CloseVolume (OpenVolumeContext *context) int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode) { CRYPTO_INFO *newCryptoInfo = NULL; - + RandSetHashFunction (cryptoInfo->pkcs5); if (Randinit() != ERR_SUCCESS) @@ -10401,7 +10401,7 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly) wchar_t data[65536]; DWORD size = sizeof (data); - + if (IsPagingFileWildcardActive()) return TRUE; @@ -10426,7 +10426,7 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly) } HANDLE handle = CreateFile (drivePath.c_str(), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - + if (handle == INVALID_HANDLE_VALUE) continue; @@ -10446,7 +10446,7 @@ BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly) path[0] = drive; handle = CreateFile (path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); - + if (handle != INVALID_HANDLE_VALUE) CloseHandle (handle); else if (GetLastError() == ERROR_SHARING_VIOLATION) @@ -10488,7 +10488,7 @@ std::wstring SingleStringToWide (const std::string &singleString) WCHAR wbuf[65536]; int wideLen = MultiByteToWideChar (CP_ACP, 0, singleString.c_str(), -1, wbuf, array_capacity (wbuf) - 1); - + // We don't throw exception here and only return empty string. // All calls to this function use valid strings. // throw_sys_if (wideLen == 0); @@ -10531,7 +10531,7 @@ std::string WideToUtf8String (const std::wstring &wideString) BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); - static string *password; + static string *password; switch (msg) { @@ -10578,7 +10578,7 @@ BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wPara wchar_t tmp[SecurityToken::MaxPasswordLength+1]; wmemset (tmp, 'X', SecurityToken::MaxPasswordLength); tmp[SecurityToken::MaxPasswordLength] = 0; - SetWindowText (GetDlgItem (hwndDlg, IDC_TOKEN_PASSWORD), tmp); + SetWindowText (GetDlgItem (hwndDlg, IDC_TOKEN_PASSWORD), tmp); EndDialog (hwndDlg, lw); } @@ -10699,8 +10699,8 @@ static void SecurityTokenKeyfileDlgFillList (HWND hwndDlg, const vector <Securit foreach (const SecurityTokenKeyfile &keyfile, keyfiles) { memset (&lvItem, 0, sizeof(lvItem)); - lvItem.mask = LVIF_TEXT; - lvItem.iItem = line++; + lvItem.mask = LVIF_TEXT; + lvItem.iItem = line++; wstringstream s; s << keyfile.SlotId; @@ -10750,11 +10750,11 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam LocalizeDialog (hwndDlg, selectedTokenKeyfiles ? "SELECT_TOKEN_KEYFILES" : "IDD_TOKEN_KEYFILES"); SendMessage (tokenListControl,LVM_SETEXTENDEDLISTVIEWSTYLE, 0, - LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_TWOCLICKACTIVATE|LVS_EX_LABELTIP - ); + LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP|LVS_EX_TWOCLICKACTIVATE|LVS_EX_LABELTIP + ); - memset (&LvCol, 0, sizeof(LvCol)); - LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; + memset (&LvCol, 0, sizeof(LvCol)); + LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; LvCol.pszText = GetString ("TOKEN_SLOT_ID"); LvCol.cx = CompensateXDPI (40); LvCol.fmt = LVCFMT_CENTER; @@ -10794,7 +10794,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam return 1; } } - + SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles); return 1; } @@ -10808,7 +10808,7 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam foreach (const SecurityTokenKeyfile &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles)) { selectedTokenKeyfiles->push_back (SecurityTokenKeyfilePath (keyfile)); - } + } } EndDialog (hwndDlg, IDOK); @@ -11062,7 +11062,7 @@ std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties, bool || ((partNumber == 0) && GetPhysicalDriveGeometry (devNumber, &deviceGeometry)) ) { - device.Size = deviceGeometry.Cylinders.QuadPart * (LONGLONG) deviceGeometry.BytesPerSector + device.Size = deviceGeometry.Cylinders.QuadPart * (LONGLONG) deviceGeometry.BytesPerSector * (LONGLONG) deviceGeometry.SectorsPerTrack * (LONGLONG) deviceGeometry.TracksPerCylinder; } } @@ -11306,7 +11306,7 @@ int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL *pbDecrypt) return IDYES; default: break; - } + } } char *multiChoiceStr[] = { 0, "ASK_NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL", "DO_NOT_PROMPT_ME", "KEEP_PROMPTING_ME", 0 }; @@ -11399,7 +11399,7 @@ void EnableElevatedCursorChange (HWND parent) HWND hWnd; memset (&winClass, 0, sizeof (winClass)); - winClass.cbSize = sizeof (WNDCLASSEX); + winClass.cbSize = sizeof (WNDCLASSEX); winClass.lpfnWndProc = (WNDPROC) EnableElevatedCursorChangeWndProc; winClass.hInstance = hInst; winClass.lpszClassName = className; @@ -11430,7 +11430,7 @@ BOOL DisableFileCompression (HANDLE file) return TRUE; format = COMPRESSION_FORMAT_NONE; - return DeviceIoControl (file, FSCTL_SET_COMPRESSION, &format, sizeof (format), NULL, 0, &bytesOut, NULL); + return DeviceIoControl (file, FSCTL_SET_COMPRESSION, &format, sizeof (format), NULL, 0, &bytesOut, NULL); } @@ -11779,8 +11779,8 @@ void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCou } else { - if ( *pdwEntropy < dwMaxLevel - && (dwCounter >= *pdwInitialValue) + if ( *pdwEntropy < dwMaxLevel + && (dwCounter >= *pdwInitialValue) && (dwCounter - *pdwInitialValue) <= dwMaxLevel) *pdwEntropy = dwCounter - *pdwInitialValue; else @@ -11797,7 +11797,7 @@ void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCou SendMessage (hProgress, PBM_SETSTATE, state, 0); } - SendMessage (hProgress, PBM_SETPOS, + SendMessage (hProgress, PBM_SETPOS, (WPARAM) (*pdwEntropy), 0); } @@ -11834,7 +11834,7 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue) if ((pathLen >= 3) && (_wcsnicmp (pathValue, L"ID:", 3) == 0)) { std::vector<byte> arr; - if ( (pathLen == (3 + 2*VOLUME_ID_SIZE)) + if ( (pathLen == (3 + 2*VOLUME_ID_SIZE)) && HexWideStringToArray (pathValue + 3, arr) && (arr.size() == VOLUME_ID_SIZE) ) @@ -11859,7 +11859,7 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue) bRet = FALSE; } } - + return bRet; } diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index dd6eb801..9387336e 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -132,7 +132,7 @@ extern int CurrentOSServicePack; extern BOOL RemoteSession; extern HANDLE hDriver; extern HINSTANCE hInst; -extern int SystemEncryptionStatus; +extern int SystemEncryptionStatus; extern WipeAlgorithmId nWipeMode; extern BOOL bSysPartitionSelected; extern BOOL bSysDriveSelected; @@ -170,11 +170,11 @@ enum tc_app_msg_ids TC_APPMSG_SYSENC_CONFIG_UPDATE = WM_APP + 101, TC_APPMSG_TASKBAR_ICON = WM_APP + 102, TC_APPMSG_LOAD_TEXT_BOX_CONTENT = WM_APP + 103, - // Mount + // Mount TC_APPMSG_MOUNT_ENABLE_DISABLE_CONTROLS = WM_APP + 201, TC_APPMSG_MOUNT_SHOW_WINDOW = WM_APP + 202, TC_APPMSG_PREBOOT_PASSWORD_MODE = WM_APP + 203, - // Format + // Format TC_APPMSG_VOL_TRANSFORM_THREAD_ENDED = WM_APP + 301, TC_APPMSG_FORMAT_FINISHED = WM_APP + 302, TC_APPMSG_FORMAT_USER_QUIT = WM_APP + 303, diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c index 9cc641cc..f0889a34 100644 --- a/src/Common/EncryptionThreadPool.c +++ b/src/Common/EncryptionThreadPool.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -182,13 +182,13 @@ static TC_THREAD_PROC EncryptionThreadProc (void *threadArg) workItem->KeyDerivation.IterationCount, workItem->KeyDerivation.DerivedKey, GetMaxPkcs5OutSize()); break; - default: + default: TC_THROW_FATAL_EXCEPTION; - } + } InterlockedExchange (workItem->KeyDerivation.CompletionFlag, TRUE); TC_SET_EVENT (*workItem->KeyDerivation.CompletionEvent); - + if (InterlockedDecrement (workItem->KeyDerivation.OutstandingWorkItemCount) == 0) TC_SET_EVENT (*workItem->KeyDerivation.NoOutstandingWorkItemEvent); @@ -256,12 +256,12 @@ BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount) WorkItemReadyEvent = CreateEvent (NULL, FALSE, FALSE, NULL); if (!WorkItemReadyEvent) return FALSE; - + WorkItemCompletedEvent = CreateEvent (NULL, FALSE, FALSE, NULL); if (!WorkItemCompletedEvent) return FALSE; #endif - + #ifdef DEVICE_DRIVER ExInitializeFastMutex (&DequeueMutex); ExInitializeFastMutex (&EnqueueMutex); @@ -400,10 +400,10 @@ void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, EncryptionThreadPoolWorkItem *workItem; EncryptionThreadPoolWorkItem *firstFragmentWorkItem; - + if (unitCount == 0) return; - + if (!ThreadPoolRunning || unitCount == 1) { switch (type) @@ -432,7 +432,7 @@ void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, else { /* Note that it is not efficient to divide the data into fragments smaller than a few hundred bytes. - The reason is that the overhead associated with thread handling would in most cases make a multi-threaded + The reason is that the overhead associated with thread handling would in most cases make a multi-threaded process actually slower than a single-threaded process. */ fragmentCount = ThreadCount; @@ -442,7 +442,7 @@ void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, if (remainder > 0) ++unitsPerFragment; } - + fragmentData = data; fragmentStartUnitNo = startUnitNo->Value; diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h index 5ca131f5..9bc10c94 100644 --- a/src/Common/EncryptionThreadPool.h +++ b/src/Common/EncryptionThreadPool.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Endian.c b/src/Common/Endian.c index 44d96e40..0327a102 100644 --- a/src/Common/Endian.c +++ b/src/Common/Endian.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Endian.h b/src/Common/Endian.h index 7d97e5fb..00fed048 100644 --- a/src/Common/Endian.h +++ b/src/Common/Endian.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -110,7 +110,7 @@ extern "C" ( ( unsigned __int32 ) memPtr[ -2 ] << 8 ) | ( unsigned __int32 ) memPtr[ -1 ] ) #define mgetWord(memPtr) \ - ( memPtr += 2, ((( unsigned short ) memPtr[ -2 ] << 8 ) | ( ( unsigned short ) memPtr[ -1 ] )) ) + ( memPtr += 2, ((( unsigned short ) memPtr[ -2 ] << 8 ) | ( ( unsigned short ) memPtr[ -1 ] )) ) #define mgetByte(memPtr) \ ( ( unsigned char ) *memPtr++ ) @@ -139,7 +139,7 @@ unsigned __int16 MirrorBytes16 (unsigned __int16 x); unsigned __int32 MirrorBytes32 (unsigned __int32 x); #ifndef TC_NO_COMPILER_INT64 uint64 MirrorBytes64 (uint64 x); -#endif +#endif void LongReverse ( unsigned __int32 *buffer , unsigned byteCount ); #if defined(__cplusplus) diff --git a/src/Common/Exception.h b/src/Common/Exception.h index c4cd1b10..e7a790a1 100644 --- a/src/Common/Exception.h +++ b/src/Common/Exception.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Fat.c b/src/Common/Fat.c index fadb80b1..fb7dc1ff 100644 --- a/src/Common/Fat.c +++ b/src/Common/Fat.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -58,7 +58,7 @@ GetFatParams (fatparams * ft) clusterSize = 512; ft->cluster_size = clusterSize / ft->sector_size; - + if (ft->cluster_size == 0) ft->cluster_size = 1; @@ -73,8 +73,8 @@ GetFatParams (fatparams * ft) ft->cluster_size = 1; // Geometry always set to SECTORS/1/1 - ft->secs_track = 1; - ft->heads = 1; + ft->secs_track = 1; + ft->heads = 1; ft->dir_entries = 512; ft->fats = 2; @@ -98,7 +98,7 @@ GetFatParams (fatparams * ft) ft->cluster_count = (int) (((__int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size)); ft->fat_length = (ft->cluster_count * 2 + ft->sector_size - 1) / ft->sector_size; } - + if(ft->cluster_count >= 65525) // FAT32 { ft->size_fat = 32; @@ -165,13 +165,13 @@ PutBoot (fatparams * ft, unsigned char *boot) cnt += 2; boot[cnt++] = (__int8) ft->media; /* media byte */ - if(ft->size_fat == 32) + if(ft->size_fat == 32) { boot[cnt++] = 0x00; boot[cnt++] = 0x00; } - else - { + else + { *(__int16 *)(boot + cnt) = LE16((uint16) ft->fat_length); /* fat size */ cnt += 2; } @@ -233,13 +233,13 @@ static void PutFSInfo (unsigned char *sector, fatparams *ft) { memset (sector, 0, ft->sector_size); sector[3]=0x41; /* LeadSig */ - sector[2]=0x61; - sector[1]=0x52; - sector[0]=0x52; + sector[2]=0x61; + sector[1]=0x52; + sector[0]=0x52; sector[484+3]=0x61; /* StrucSig */ - sector[484+2]=0x41; - sector[484+1]=0x72; - sector[484+0]=0x72; + sector[484+2]=0x41; + sector[484+1]=0x72; + sector[484+0]=0x72; // Free cluster count *(uint32 *)(sector + 488) = LE32 (ft->cluster_count - ft->size_root_dir / ft->sector_size / ft->cluster_size); @@ -293,7 +293,7 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void goto fail; /* fat32 boot area */ - if (ft->size_fat == 32) + if (ft->size_fat == 32) { /* fsinfo */ PutFSInfo((unsigned char *) sector, ft); @@ -311,7 +311,7 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void cryptoInfo) == FALSE) goto fail; } - + /* bootsector backup */ memset (sector, 0, ft->sector_size); PutBoot (ft, (unsigned char *) sector); @@ -354,7 +354,7 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void fat_sig[8] = fat_sig[9] = fat_sig[10] = 0xff; fat_sig[11] = 0x0f; memcpy (sector, fat_sig, 12); - } + } else if (ft->size_fat == 16) { fat_sig[0] = (unsigned char) ft->media; @@ -407,7 +407,7 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void goto fail; // Temporary secondary key (XTS mode) - if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE)) + if (!RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof cryptoInfo->k2, FALSE)) goto fail; retVal = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks); diff --git a/src/Common/Fat.h b/src/Common/Fat.h index b637f8ec..2d1264c8 100644 --- a/src/Common/Fat.h +++ b/src/Common/Fat.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Format.c b/src/Common/Format.c index 43a96d04..f3114e5e 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -60,7 +60,7 @@ uint64 GetVolumeDataAreaSize (BOOL hiddenVolume, uint64 volumeSize) #if TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH < TC_MAX_VOLUME_SECTOR_SIZE # error TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH too small. #endif - + if (volumeSize < TC_VOLUME_SMALL_SIZE_THRESHOLD) reservedSize = TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE; else @@ -108,16 +108,16 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) || FormatSectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0) { Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg); - return ERR_DONT_REPORT; + return ERR_DONT_REPORT; } /* WARNING: Note that if Windows fails to format the volume as NTFS and the volume size is less than the maximum FAT size, the user is asked within this function whether he wants to instantly retry FAT format instead (to avoid having to re-create the whole container again). If the user - answers yes, some of the input parameters are modified, the code below 'begin_format' is re-executed - and some destructive operations that were performed during the first attempt must be (and are) skipped. + answers yes, some of the input parameters are modified, the code below 'begin_format' is re-executed + and some destructive operations that were performed during the first attempt must be (and are) skipped. Therefore, whenever adding or modifying any potentially destructive operations below 'begin_format', - determine whether they (or their portions) need to be skipped during such a second attempt; if so, + determine whether they (or their portions) need to be skipped during such a second attempt; if so, use the 'bInstantRetryOtherFilesys' flag to skip them. */ if (volParams->hiddenVol) @@ -187,17 +187,17 @@ begin_format: if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE) { Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg); - nStatus = ERR_DONT_REPORT; + nStatus = ERR_DONT_REPORT; goto error; } - /* Gain "raw" access to the partition (it contains a live filesystem and the filesystem driver + /* Gain "raw" access to the partition (it contains a live filesystem and the filesystem driver would otherwise prevent us from writing to hidden sectors). */ if (!DeviceIoControl (dev, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, - 0, + 0, NULL, 0, &dwResult, @@ -208,7 +208,7 @@ begin_format: } else if (IsOSAtLeast (WIN_VISTA) && driveLetter == -1) { - // Windows Vista doesn't allow overwriting sectors belonging to an unformatted partition + // Windows Vista doesn't allow overwriting sectors belonging to an unformatted partition // to which no drive letter has been assigned under the system. This problem can be worked // around by assigning a drive letter to the partition temporarily. @@ -219,7 +219,7 @@ begin_format: BOOL bResult = FALSE; tmpDriveLetter = GetFirstAvailableDrive (); - + if (tmpDriveLetter != -1) { rootPath[0] += (wchar_t) tmpDriveLetter; @@ -233,7 +233,7 @@ begin_format: szDriveLetter, volParams->volumePath); - if (bResult + if (bResult && SetVolumeMountPoint (rootPath, uniqVolName)) { // The drive letter can be removed now @@ -245,21 +245,21 @@ begin_format: // For extra safety, we will try to gain "raw" access to the partition. Note that this should actually be // redundant because if the filesystem was mounted, we already tried to obtain DASD above. If we failed, - // bFailedRequiredDASD was set to TRUE and therefore we will perform pseudo "quick format" below. However, + // bFailedRequiredDASD was set to TRUE and therefore we will perform pseudo "quick format" below. However, // for extra safety, in case IsDeviceMounted() failed to detect a live filesystem, we will blindly // send FSCTL_ALLOW_EXTENDED_DASD_IO (possibly for a second time) without checking the result. DeviceIoControl (dev, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, - 0, + 0, NULL, 0, &dwResult, NULL); - // If DASD is needed but we failed to obtain it, perform open - 'quick format' - close - open + // If DASD is needed but we failed to obtain it, perform open - 'quick format' - close - open // so that the filesystem driver does not prevent us from formatting hidden sectors. for (nPass = (bFailedRequiredDASD ? 0 : 1); nPass < 2; nPass++) { @@ -285,7 +285,7 @@ begin_format: { if (!volParams->bForceOperation && (Silent || (IDNO == MessageBoxW (volParams->hwndDlg, GetString ("DEVICE_IN_USE_FORMAT"), lpszTitle, MB_YESNO|MB_ICONWARNING|MB_DEFBUTTON2)))) { - nStatus = ERR_DONT_REPORT; + nStatus = ERR_DONT_REPORT; goto error; } } @@ -293,7 +293,7 @@ begin_format: { handleWin32Error (volParams->hwndDlg, SRC_POS); Error ("CANT_ACCESS_VOL", hwndDlg); - nStatus = ERR_DONT_REPORT; + nStatus = ERR_DONT_REPORT; goto error; } } @@ -306,13 +306,13 @@ begin_format: char buf [2 * TC_MAX_VOLUME_SECTOR_SIZE]; DWORD bw; - // Perform pseudo "quick format" so that the filesystem driver does not prevent us from + // Perform pseudo "quick format" so that the filesystem driver does not prevent us from // formatting hidden sectors memset (buf, 0, sizeof (buf)); if (!WriteFile (dev, buf, sizeof (buf), &bw, NULL)) { - nStatus = ERR_OS_ERROR; + nStatus = ERR_OS_ERROR; goto error; } @@ -325,7 +325,7 @@ begin_format: if (DeviceIoControl (dev, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &dwResult, NULL)) { Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg); - nStatus = ERR_DONT_REPORT; + nStatus = ERR_DONT_REPORT; goto error; } } @@ -339,7 +339,7 @@ begin_format: if (dev == INVALID_HANDLE_VALUE) { - nStatus = ERR_OS_ERROR; + nStatus = ERR_OS_ERROR; goto error; } @@ -356,7 +356,7 @@ begin_format: DWORD tmp; if (!DeviceIoControl (dev, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &tmp, NULL)) { - nStatus = ERR_OS_ERROR; + nStatus = ERR_OS_ERROR; goto error; } } @@ -391,13 +391,13 @@ begin_format: // Check hidden volume size if (volParams->hiddenVolHostSize < TC_MIN_HIDDEN_VOLUME_HOST_SIZE || volParams->hiddenVolHostSize > TC_MAX_HIDDEN_VOLUME_HOST_SIZE) - { + { nStatus = ERR_VOL_SIZE_WRONG; goto error; } // Seek to hidden volume header location - + headerOffset.QuadPart = TC_HIDDEN_VOLUME_HEADER_OFFSET; if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN)) @@ -458,7 +458,7 @@ begin_format: // Validate the offset if (dataOffset % FormatSectorSize != 0) { - nStatus = ERR_VOL_SIZE_WRONG; + nStatus = ERR_VOL_SIZE_WRONG; goto error; } @@ -478,7 +478,7 @@ begin_format: if (volParams->bDevice && !StartFormatWriteThread()) { - nStatus = ERR_OS_ERROR; + nStatus = ERR_OS_ERROR; goto error; } @@ -488,11 +488,11 @@ begin_format: StopFormatWriteThread(); break; - + case FILESYS_FAT: if (num_sectors > 0xFFFFffff) { - nStatus = ERR_VOL_SIZE_WRONG; + nStatus = ERR_VOL_SIZE_WRONG; goto error; } @@ -506,12 +506,12 @@ begin_format: ft.sector_size = (uint16) FormatSectorSize; ft.cluster_size = volParams->clusterSize; memcpy (ft.volume_name, "NO NAME ", 11); - GetFatParams (&ft); + GetFatParams (&ft); *(volParams->realClusterSize) = ft.cluster_size * FormatSectorSize; if (volParams->bDevice && !StartFormatWriteThread()) { - nStatus = ERR_OS_ERROR; + nStatus = ERR_OS_ERROR; goto error; } @@ -523,7 +523,7 @@ begin_format: break; default: - nStatus = ERR_PARAMETER_INCORRECT; + nStatus = ERR_PARAMETER_INCORRECT; goto error; } @@ -883,14 +883,14 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType) return FALSE; } - + if (GetSystemDirectory (dllPath, MAX_PATH)) { StringCchCatW(dllPath, ARRAYSIZE(dllPath), L"\\fmifs.dll"); } else StringCchCopyW(dllPath, ARRAYSIZE(dllPath), L"C:\\Windows\\System32\\fmifs.dll"); - + hModule = LoadLibrary (dllPath); if (hModule == NULL) @@ -905,7 +905,7 @@ BOOL FormatFs (int driveNo, int clusterSize, int fsType) StringCchCatW (dir, ARRAYSIZE(dir), L":\\"); FormatExError = TRUE; - + // Windows sometimes fails to format a volume (hosted on a removable medium) as NTFS. // It often helps to retry several times. for (i = 0; i < 50 && FormatExError; i++) @@ -939,7 +939,7 @@ BOOL WriteSector (void *dev, char *sector, if (*write_buf_cnt == FormatWriteBufferSize && !FlushFormatWriteBuffer (dev, write_buf, write_buf_cnt, nSecNo, cryptoInfo)) return FALSE; - + if (GetTickCount () - updateTime > 25) { if (UpdateProgressBar (*nSecNo * FormatSectorSize)) @@ -962,7 +962,7 @@ static HANDLE WriteBufferEmptyEvent; static HANDLE WriteBufferFullEvent; static volatile HANDLE WriteRequestHandle; -static volatile int WriteRequestSize; +static volatile int WriteRequestSize; static volatile DWORD WriteRequestResult; @@ -985,7 +985,7 @@ static void __cdecl FormatWriteThreadProc (void *arg) if (!WriteFile (WriteRequestHandle, WriteThreadBuffer, WriteRequestSize, &bytesWritten, NULL)) WriteRequestResult = GetLastError(); - else + else WriteRequestResult = ERROR_SUCCESS; if (!SetEvent (WriteBufferEmptyEvent)) @@ -1082,7 +1082,7 @@ BOOL FlushFormatWriteBuffer (void *dev, char *write_buf, int *write_buf_cnt, __i { if (WaitForSingleObject (WriteBufferEmptyEvent, INFINITE) == WAIT_FAILED) return FALSE; - + if (WriteRequestResult != ERROR_SUCCESS) { SetEvent (WriteBufferEmptyEvent); diff --git a/src/Common/Format.h b/src/Common/Format.h index de342b93..0d29ab3b 100644 --- a/src/Common/Format.h +++ b/src/Common/Format.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -21,7 +21,7 @@ extern "C" { #endif // FMIFS -typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( int command, DWORD subCommand, PVOID parameter ); +typedef BOOLEAN (__stdcall *PFMIFSCALLBACK)( int command, DWORD subCommand, PVOID parameter ); typedef VOID (__stdcall *PFORMATEX)( PWCHAR DriveRoot, DWORD MediaFlag, PWCHAR Format, PWCHAR Label, BOOL QuickFormat, DWORD ClusterSize, PFMIFSCALLBACK Callback ); typedef struct diff --git a/src/Common/GfMul.c b/src/Common/GfMul.c index 9cd74a89..970e6318 100644 --- a/src/Common/GfMul.c +++ b/src/Common/GfMul.c @@ -24,11 +24,11 @@ --------------------------------------------------------------------------- Issue Date: 31/01/2004 - My thanks to John Viega and David McGrew for their support in developing + My thanks to John Viega and David McGrew for their support in developing this code and to David for testing it on a big-endain system. */ -/* +/* --------------------------------------------------------------------------- Portions Copyright (c) 2005 TrueCrypt Developers Association @@ -630,9 +630,9 @@ int Gf128Tab64Init (unsigned __int8 *a, GfCtx *ctx) compile_8k_table (am, ctx8k); /* Convert 8k LSB-first table to 4k MSB-first */ - for (i = 16; i < 32; i++) + for (i = 16; i < 32; i++) { - for (j = 0; j < 16; j++) + for (j = 0; j < 16; j++) { int jm = 0; jm |= (j & 0x1) << 3; @@ -658,7 +658,7 @@ int Gf128Tab64Init (unsigned __int8 *a, GfCtx *ctx) /* Multiply a 128-bit number by a 64-bit number in the finite field GF(2^128) */ void Gf128MulBy64Tab (unsigned __int8 a[8], unsigned __int8 p[16], GfCtx *ctx) -{ +{ unsigned __int32 r[CBLK_LEN >> 2]; move_block_aligned(r, ctx->gf_t128[7*2][a[7] & 15]); @@ -751,7 +751,7 @@ BOOL GfMulSelfTest () } GfMul128Basic (a, b, p1); - + Gf128Tab64Init (a, gfCtx); Gf128MulBy64Tab (b + 8, p2, gfCtx); diff --git a/src/Common/Inflate.c b/src/Common/Inflate.c index 2d8c96b6..cb46b098 100644 --- a/src/Common/Inflate.c +++ b/src/Common/Inflate.c @@ -1311,7 +1311,7 @@ int DecompressDeflatedData (char *out, char *in, int inLength) G.incnt = inLength; G.outCounter = 0; - if (inflate(__G) != 0) + if (inflate(__G) != 0) { // Error decompressing return 0; diff --git a/src/Common/Inflate.h b/src/Common/Inflate.h index c2810c82..8420f3dc 100644 --- a/src/Common/Inflate.h +++ b/src/Common/Inflate.h @@ -10,17 +10,17 @@ typedef unsigned char uch; typedef unsigned short ush; typedef void zvoid; -typedef struct huft +typedef struct huft { uch b, e; - union + union { ush n; struct huft *t; }v; }; -typedef struct +typedef struct { uch *inptr, *outbufptr; int incnt; diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c index c59ab374..10f49b5d 100644 --- a/src/Common/Keyfiles.c +++ b/src/Common/Keyfiles.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -218,7 +218,7 @@ static BOOL KeyFileProcess (unsigned __int8 *keyPool, KeyFile *keyFile) else if (totalRead == 0) { status = FALSE; - SetLastError (ERROR_HANDLE_EOF); + SetLastError (ERROR_HANDLE_EOF); } close: @@ -275,7 +275,7 @@ BOOL KeyFilesApplyWithPin (HWND hwndDlg, Password *password, char* pin, KeyFile if (keyfileData.empty()) { - SetLastError (ERROR_HANDLE_EOF); + SetLastError (ERROR_HANDLE_EOF); handleWin32Error (hwndDlg, SRC_POS); Error ("ERR_PROCESS_KEYFILE", hwndDlg); status = FALSE; @@ -342,7 +342,7 @@ BOOL KeyFilesApplyWithPin (HWND hwndDlg, Password *password, char* pin, KeyFile StringCbPrintfW (kfSub->FileName, sizeof(kfSub->FileName), L"%s%c%s", kf->FileName, L'\\', fBuf.name - ); + ); // Determine whether it's a path or a file if (_wstat (kfSub->FileName, &statStruct) != 0) @@ -355,7 +355,7 @@ BOOL KeyFilesApplyWithPin (HWND hwndDlg, Password *password, char* pin, KeyFile else if (statStruct.st_mode & S_IFDIR) // If it's a directory { // Prevent recursive folder scanning - continue; + continue; } // Skip hidden files @@ -363,7 +363,7 @@ BOOL KeyFilesApplyWithPin (HWND hwndDlg, Password *password, char* pin, KeyFile && (fileAttributes.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) != 0) { HiddenFilesPresentInKeyfilePath = TRUE; - continue; + continue; } CorrectFileName (kfSub->FileName); @@ -474,18 +474,18 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendMessageW (hList,LVM_SETEXTENDEDLISTVIEWSTYLE,0, LVS_EX_FULLROWSELECT|LVS_EX_HEADERDRAGDROP - ); + ); - memset (&LvCol,0,sizeof(LvCol)); - LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; - LvCol.pszText = GetString ("KEYFILE"); + memset (&LvCol,0,sizeof(LvCol)); + LvCol.mask = LVCF_TEXT|LVCF_WIDTH|LVCF_SUBITEM|LVCF_FMT; + LvCol.pszText = GetString ("KEYFILE"); LvCol.cx = CompensateXDPI (374); LvCol.fmt = LVCFMT_LEFT; SendMessageW (hList, LVM_INSERTCOLUMNW, 0, (LPARAM)&LvCol); LoadKeyList (hwndDlg, param->FirstKeyFile); SetCheckBox (hwndDlg, IDC_KEYFILES_ENABLE, param->EnableKeyFiles); - + #ifdef TCMOUNT if ( (origParam.EnableKeyFiles == defaultKeyFilesParam.EnableKeyFiles) && (origParam.FirstKeyFile == defaultKeyFilesParam.FirstKeyFile) @@ -580,15 +580,15 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa HWND list = GetDlgItem (hwndDlg, IDC_KEYLIST); LVITEM LvItem; memset (&LvItem, 0, sizeof(LvItem)); - LvItem.mask = LVIF_PARAM; + LvItem.mask = LVIF_PARAM; LvItem.iItem = -1; while (-1 != (LvItem.iItem = ListView_GetNextItem (list, LvItem.iItem, LVIS_SELECTED))) { ListView_GetItem (list, &LvItem); param->FirstKeyFile = KeyFileRemove (param->FirstKeyFile, (KeyFile *) LvItem.lParam); - } - + } + LoadKeyList (hwndDlg, param->FirstKeyFile); return 1; } @@ -602,7 +602,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa if (lw == IDC_GENERATE_KEYFILE) { - DialogBoxParamW (hInst, + DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_KEYFILE_GENERATOR), hwndDlg, (DLGPROC) KeyfileGeneratorDlgProc, (LPARAM) 0); return 1; diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h index dea906b1..c94f1378 100644 --- a/src/Common/Keyfiles.h +++ b/src/Common/Keyfiles.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -51,4 +51,4 @@ extern BOOL HiddenFilesPresentInKeyfilePath; } #endif -#endif /* #ifndef KEYFILES_H */ +#endif /* #ifndef KEYFILES_H */ diff --git a/src/Common/Language.c b/src/Common/Language.c index 3d9b22d3..f03a4e54 100644 --- a/src/Common/Language.c +++ b/src/Common/Language.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -101,7 +101,7 @@ static char *MapNextLanguageFile () GetModuleFileNameW (NULL, f, sizeof (f) / sizeof (f[0])); t = wcsrchr (f, L'\\'); if (t == NULL) return NULL; - + *t = 0; StringCbCatW (f, sizeof(f), L"\\Language*.xml"); @@ -236,10 +236,10 @@ BOOL LoadLanguageFile () memset (&font, 0, sizeof (font)); XmlGetAttributeText (xml, "face", attr, sizeof (attr)); - + len = MultiByteToWideChar (CP_UTF8, 0, attr, -1, wattr, sizeof (wattr) / sizeof(wattr[0])); font.FaceName = AddPoolData ((void *) wattr, len * 2); - + XmlGetAttributeText (xml, "size", attr, sizeof (attr)); sscanf (attr, "%d", &font.Size); @@ -332,7 +332,7 @@ BOOL LoadLanguageFile () LocalizationSerialNo++; // Create control ID dictionary - + // Default controls AddDictionaryEntry (NULL, 1, GetString ("IDOK")); AddDictionaryEntry (NULL, 2, GetString ("IDCANCEL")); @@ -440,7 +440,7 @@ BOOL CALLBACK LanguageDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa SendDlgItemMessage (hwndDlg, IDC_LANGLIST, LB_SETCURSEL, i, 0); - // Language pack version + // Language pack version if (!ActiveLangPackVersion[0] || memcmp (ActiveLangPackVersion, "0.0.0", 5) == 0) { StringCbPrintfW (szVers, sizeof(szVers), GetString("LANG_PACK_VERSION"), L"--"); @@ -474,12 +474,12 @@ BOOL CALLBACK LanguageDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa if (lParam == 1) { // Auto mode - if (langCount < 2) + if (langCount < 2) EndDialog (hwndDlg, IDCANCEL); if (langCount == 2) StringCbCopyA (PreferredLangId, sizeof(PreferredLangId), lastLangId); - + EndDialog (hwndDlg, IDOK); } @@ -511,8 +511,8 @@ BOOL CALLBACK LanguageDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa l[3] = (char) (id >> 16); l[4] = id >> 24; l[5] = 0; - } - + } + if (SendDlgItemMessage (hwndDlg, IDC_LANGLIST, LB_GETCOUNT, 0, 0) > 1) StringCbCopyA (PreferredLangId, sizeof(PreferredLangId), l); } diff --git a/src/Common/Language.h b/src/Common/Language.h index 4e4c1795..3b5501d9 100644 --- a/src/Common/Language.h +++ b/src/Common/Language.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Password.c b/src/Common/Password.c index 4d7c7952..2c9e77c3 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -89,7 +89,7 @@ void VerifyPasswordAndUpdate (HWND hwndDlg, HWND hButton, HWND hPassword, BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw) { int i, len; - + if (hPassword == NULL) { if (ptrPw) @@ -113,7 +113,7 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw) len = GetWindowTextLength (hPassword); if (len > MAX_PASSWORD) - return FALSE; + return FALSE; GetWindowTextW (hPassword, s, sizeof (s) / sizeof (wchar_t)); @@ -126,7 +126,7 @@ BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw) burn (s, sizeof(s)); if (i < len) - return FALSE; + return FALSE; } return TRUE; @@ -141,7 +141,7 @@ BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim if (bCustomPimSmall) { Error (bForBoot? "BOOT_PIM_REQUIRE_LONG_PASSWORD": "PIM_REQUIRE_LONG_PASSWORD", hwndDlg); - return FALSE; + return FALSE; } #ifndef _DEBUG @@ -215,14 +215,14 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, else { nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice), szCFDevice, sizeof(szCFDevice),FALSE); - + if (nDosLinkCreated != 0) goto error; } dev = CreateFile (szCFDevice, GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); - if (dev == INVALID_HANDLE_VALUE) + if (dev == INVALID_HANDLE_VALUE) goto error; if (bDevice) @@ -328,7 +328,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, if (bytesRead != sizeof (buffer)) { - // Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS + // Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS memset (buffer, 0, sizeof (buffer)); } @@ -347,7 +347,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, cryptoInfo = NULL; goto error; } - else + else break; } @@ -374,12 +374,12 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, EnableElevatedCursorChange (hwndDlg); WaitCursor(); - /* Re-encrypt the volume header */ + /* Re-encrypt the volume header */ backupHeader = FALSE; while (TRUE) { - /* The header will be re-encrypted wipePassCount 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 @@ -447,7 +447,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, if (backupHeader || cryptoInfo->LegacyVolume) break; - + backupHeader = TRUE; headerOffset.QuadPart += hostSize - TC_VOLUME_HEADER_GROUP_SIZE; } diff --git a/src/Common/Password.h b/src/Common/Password.h index 8cc0b7ea..8818804e 100644 --- a/src/Common/Password.h +++ b/src/Common/Password.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -39,8 +39,8 @@ typedef struct #if defined(_WIN32) && !defined(TC_WINDOWS_DRIVER) void VerifyPasswordAndUpdate ( HWND hwndDlg , HWND hButton , HWND hPassword , HWND hVerify , unsigned char *szPassword , char *szVerify, BOOL keyFilesEnabled ); -BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning, BOOL bSkipPimWarning); -BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw); +BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim, BOOL bForBoot, BOOL bSkipPasswordWarning, BOOL bSkipPimWarning); +BOOL CheckPasswordCharEncoding (HWND hPassword, Password *ptrPw); int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, BOOL truecryptMode, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg); #endif // defined(_WIN32) && !defined(TC_WINDOWS_DRIVER) diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c index a71be573..8bc828ef 100644 --- a/src/Common/Pkcs5.c +++ b/src/Common/Pkcs5.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -150,7 +150,7 @@ static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, u char* k = hmac->k; char* u = hmac->u; uint32 c; - int i; + int i; #ifdef TC_WINDOWS_BOOT /* In bootloader mode, least significant bit of iterations is a boolean (TRUE for boot derivation mode, FALSE otherwise) @@ -169,7 +169,7 @@ static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, u /* iteration 1 */ memcpy (k, salt, salt_len); /* salt */ - + /* big-endian block number */ memset (&k[salt_len], 0, 3); k[salt_len + 3] = (char) b; @@ -191,7 +191,7 @@ static void derive_u_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, u void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) -{ +{ hmac_sha256_ctx hmac; sha256_ctx* ctx; char* buf = hmac.k; @@ -315,7 +315,7 @@ void hmac_sha512 char *k, /* secret key */ int lk, /* length of the key in bytes */ char *d, /* data and also output buffer of at least 64 bytes */ - int ld /* length of data in bytes */ + int ld /* length of data in bytes */ ) { hmac_sha512_ctx hmac; @@ -521,7 +521,7 @@ void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len) /* If the key is longer than the hash algorithm block size, let key = ripemd160(key), as per HMAC specifications. */ - if (keylen > RIPEMD160_BLOCKSIZE) + if (keylen > RIPEMD160_BLOCKSIZE) { RMD160_CTX tctx; @@ -533,14 +533,14 @@ void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len) keylen = RIPEMD160_DIGESTSIZE; burn (&tctx, sizeof(tctx)); // Prevent leaks - } + } /* perform inner RIPEMD-160 */ ctx = &(hmac.inner_digest_ctx); /* start out by storing key in pads */ memset(k_pad, 0x36, 64); /* XOR key with ipad and opad values */ - for (i=0; i<keylen; i++) + for (i=0; i<keylen; i++) { k_pad[i] ^= key[i]; } @@ -551,7 +551,7 @@ void hmac_ripemd160 (char *key, int keylen, char *input_digest, int len) /* perform outer RIPEMD-160 */ ctx = &(hmac.outer_digest_ctx); memset(k_pad, 0x5c, 64); - for (i=0; i<keylen; i++) + for (i=0; i<keylen; i++) { k_pad[i] ^= key[i]; } @@ -591,7 +591,7 @@ static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len /* iteration 1 */ memcpy (k, salt, salt_len); /* salt */ - + /* big-endian block number */ memset (&k[salt_len], 0, 3); k[salt_len + 3] = (char) b; @@ -612,7 +612,7 @@ static void derive_u_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len } void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) -{ +{ int b, l, r; hmac_ripemd160_ctx hmac; RMD160_CTX* ctx; @@ -621,7 +621,7 @@ void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uin unsigned char tk[RIPEMD160_DIGESTSIZE]; /* If the password is longer than the hash algorithm block size, let password = ripemd160(password), as per HMAC specifications. */ - if (pwd_len > RIPEMD160_BLOCKSIZE) + if (pwd_len > RIPEMD160_BLOCKSIZE) { RMD160_CTX tctx; @@ -652,7 +652,7 @@ void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uin /* start out by storing key in pads */ memset(k_pad, 0x36, 64); /* XOR key with ipad and opad values */ - for (b=0; b<pwd_len; b++) + for (b=0; b<pwd_len; b++) { k_pad[b] ^= pwd[b]; } @@ -663,7 +663,7 @@ void derive_key_ripemd160 (char *pwd, int pwd_len, char *salt, int salt_len, uin /* perform outer RIPEMD-160 */ ctx = &(hmac.outer_digest_ctx); memset(k_pad, 0x5c, 64); - for (b=0; b<pwd_len; b++) + for (b=0; b<pwd_len; b++) { k_pad[b] ^= pwd[b]; } @@ -797,7 +797,7 @@ static void derive_u_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len /* iteration 1 */ memcpy (k, salt, salt_len); /* salt */ /* big-endian block number */ - memset (&k[salt_len], 0, 3); + memset (&k[salt_len], 0, 3); k[salt_len + 3] = (char) b; hmac_whirlpool_internal (pwd, pwd_len, k, salt_len + 4, hmac); @@ -894,19 +894,19 @@ wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id) { switch (pkcs5_prf_id) { - case SHA512: + case SHA512: return L"HMAC-SHA-512"; - case SHA256: + case SHA256: return L"HMAC-SHA-256"; - case RIPEMD160: + case RIPEMD160: return L"HMAC-RIPEMD-160"; - case WHIRLPOOL: + case WHIRLPOOL: return L"HMAC-Whirlpool"; - default: + default: return L"(Unknown)"; } } @@ -925,7 +925,7 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BO switch (pkcs5_prf_id) { - case RIPEMD160: + case RIPEMD160: if (truecryptMode) return bBoot ? 1000 : 2000; else if (pim == 0) @@ -935,10 +935,10 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BO return bBoot? pim * 2048 : 15000 + pim * 1000; } - case SHA512: + case SHA512: return truecryptMode? 1000 : ((pim == 0)? 500000 : 15000 + pim * 1000); - case WHIRLPOOL: + case WHIRLPOOL: return truecryptMode? 1000 : ((pim == 0)? 500000 : 15000 + pim * 1000); case SHA256: @@ -951,7 +951,7 @@ int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL truecryptMode, BO return bBoot? pim * 2048 : 15000 + pim * 1000; } - default: + default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } return 0; diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h index ec9bf434..81d9de64 100644 --- a/src/Common/Pkcs5.h +++ b/src/Common/Pkcs5.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Progress.c b/src/Common/Progress.c index ceb528f2..42ff7639 100644 --- a/src/Common/Progress.c +++ b/src/Common/Progress.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -126,7 +126,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) prevTime = time; - SendMessage (hProgressBar, PBM_SETPOS, + SendMessage (hProgressBar, PBM_SETPOS, (int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)), 0); diff --git a/src/Common/Progress.h b/src/Common/Progress.h index f3579d69..0410023d 100644 --- a/src/Common/Progress.h +++ b/src/Common/Progress.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Random.c b/src/Common/Random.c index 56431262..32b38e44 100644 --- a/src/Common/Random.c +++ b/src/Common/Random.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -46,16 +46,16 @@ static HANDLE PeriodicFastPollThreadHandle = NULL; void RandAddInt (unsigned __int32 x) { - RandaddByte(x); - RandaddByte((x >> 8)); + RandaddByte(x); + RandaddByte((x >> 8)); RandaddByte((x >> 16)); RandaddByte((x >> 24)); } void RandAddInt64 (unsigned __int64 x) { - RandaddByte(x); - RandaddByte((x >> 8)); + RandaddByte(x); + RandaddByte((x >> 8)); RandaddByte((x >> 16)); RandaddByte((x >> 24)); @@ -97,7 +97,7 @@ int Randinit () if (GetMaxPkcs5OutSize() > RNG_POOL_SIZE) TC_THROW_FATAL_EXCEPTION; - if(bRandDidInit) + if(bRandDidInit) return 0; InitializeCriticalSection (&critRandProt); @@ -128,9 +128,9 @@ int Randinit () handleWin32Error (0, SRC_POS); goto error; } - + if (!CryptAcquireContext (&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) - { + { CryptoAPIAvailable = FALSE; CryptoAPILastError = GetLastError (); goto error; @@ -274,7 +274,7 @@ BOOL Randmix () if (RNG_POOL_SIZE % digestSize) TC_THROW_FATAL_EXCEPTION; - for (poolIndex = 0; poolIndex < RNG_POOL_SIZE; poolIndex += digestSize) + for (poolIndex = 0; poolIndex < RNG_POOL_SIZE; poolIndex += digestSize) { /* Compute the message digest of the entire pool using the selected hash function. */ switch (HashFunction) @@ -303,7 +303,7 @@ BOOL Randmix () WHIRLPOOL_finalize (&wctx, hashOutputBuffer); break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -316,26 +316,26 @@ BOOL Randmix () } /* Prevent leaks */ - burn (hashOutputBuffer, MAX_DIGESTSIZE); + burn (hashOutputBuffer, MAX_DIGESTSIZE); switch (HashFunction) { case RIPEMD160: - burn (&rctx, sizeof(rctx)); + burn (&rctx, sizeof(rctx)); break; case SHA512: - burn (&sctx, sizeof(sctx)); + burn (&sctx, sizeof(sctx)); break; case SHA256: - burn (&s256ctx, sizeof(s256ctx)); + burn (&s256ctx, sizeof(s256ctx)); break; case WHIRLPOOL: - burn (&wctx, sizeof(wctx)); + burn (&wctx, sizeof(wctx)); break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } @@ -360,7 +360,7 @@ BOOL RandpeekBytes (void* hwndDlg, unsigned char *buf, int len, DWORD* mouseCoun if (len > RNG_POOL_SIZE) { - Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg); + Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg); len = RNG_POOL_SIZE; } @@ -413,7 +413,7 @@ BOOL RandgetBytesFull ( void* hwndDlg, unsigned char *buf , int len, BOOL forceS /* There's never more than RNG_POOL_SIZE worth of randomess */ if ( (!allowAnyLength) && (len > RNG_POOL_SIZE)) { - Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg); + Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg); len = RNG_POOL_SIZE; LeaveCriticalSection (&critRandProt); return FALSE; @@ -515,7 +515,7 @@ LRESULT CALLBACK MouseProc (int nCode, WPARAM wParam, LPARAM lParam) EnterCriticalSection (&critRandProt); /* only count real mouse messages in entropy estimation */ - if ( (nCode == HC_ACTION) && (wParam == WM_MOUSEMOVE) + if ( (nCode == HC_ACTION) && (wParam == WM_MOUSEMOVE) && ((pt.x != lastPoint.x) || (pt.y != lastPoint.y))) { ProcessedMouseEventsCounter++; @@ -748,7 +748,7 @@ BOOL SlowPoll (void) // we keep the check for clarity purpose if ( !CryptoAPIAvailable ) return FALSE; - if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) + if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) { RandaddBuf (buffer, sizeof (buffer)); @@ -759,7 +759,7 @@ BOOL SlowPoll (void) else { /* return error in case CryptGenRandom fails */ - CryptoAPILastError = GetLastError (); + CryptoAPILastError = GetLastError (); return FALSE; } } @@ -870,7 +870,7 @@ BOOL FastPoll (void) // we keep the check for clarity purpose if ( !CryptoAPIAvailable ) return FALSE; - if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) + if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) { RandaddBuf (buffer, sizeof (buffer)); burn (buffer, sizeof(buffer)); diff --git a/src/Common/Random.h b/src/Common/Random.h index ecf04ca3..f41428f4 100644 --- a/src/Common/Random.h +++ b/src/Common/Random.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Registry.c b/src/Common/Registry.c index 1e5883a2..3daf3a45 100644 --- a/src/Common/Registry.c +++ b/src/Common/Registry.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -287,14 +287,14 @@ void DeleteRegistryValue (wchar_t *subKey, wchar_t *name) void GetStartupRegKeyName (wchar_t *regk, size_t cbRegk) { - // The string is split in order to prevent some antivirus packages from falsely reporting + // The string is split in order to prevent some antivirus packages from falsely reporting // VeraCrypt.exe to contain a possible Trojan horse because of this string (heuristic scan). StringCbPrintfW (regk, cbRegk,L"%s%s", L"Software\\Microsoft\\Windows\\Curren", L"tVersion\\Run"); } void GetRestorePointRegKeyName (wchar_t *regk, size_t cbRegk) { - // The string is split in order to prevent some antivirus packages from falsely reporting + // The string is split in order to prevent some antivirus packages from falsely reporting // VeraCrypt.exe to contain a possible Trojan horse because of this string (heuristic scan). StringCbPrintfW (regk, cbRegk,L"%s%s%s%s", L"Software\\Microsoft\\Windows", L" NT\\Curren", L"tVersion\\Sy", L"stemRestore"); }
\ No newline at end of file diff --git a/src/Common/Registry.h b/src/Common/Registry.h index be80fa4d..37bb1bdf 100644 --- a/src/Common/Registry.h +++ b/src/Common/Registry.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Resource.h b/src/Common/Resource.h index 3eca197e..03d42664 100644 --- a/src/Common/Resource.h +++ b/src/Common/Resource.h @@ -199,7 +199,7 @@ #define IDT_ENTROPY_BAR 5137 // Next default values for new objects -// +// #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index 8909059d..78a3e6c1 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -174,7 +174,7 @@ namespace VeraCrypt void SecurityToken::DeleteKeyfile (const SecurityTokenKeyfile &keyfile) { LoginUserIfRequired (keyfile.SlotId); - + CK_RV status = Pkcs11Functions->C_DestroyObject (Sessions[keyfile.SlotId].Handle, keyfile.Handle); if (status != CKR_OK) throw Pkcs11Exception (status); @@ -339,7 +339,7 @@ namespace VeraCrypt finally_do_arg (CK_SLOT_ID, slotId, { Pkcs11Functions->C_FindObjectsFinal (Sessions[finally_arg].Handle); }); - CK_ULONG objectCount; + CK_ULONG objectCount; vector <CK_OBJECT_HANDLE> objects; while (true) @@ -451,7 +451,7 @@ namespace VeraCrypt { CK_SESSION_INFO sessionInfo; status = Pkcs11Functions->C_GetSessionInfo (Sessions[slotId].Handle, &sessionInfo); - + if (status == CKR_OK) { Sessions[slotId].UserLoggedIn = (sessionInfo.state == CKS_RO_USER_FUNCTIONS || sessionInfo.state == CKS_RW_USER_FUNCTIONS); @@ -542,7 +542,7 @@ namespace VeraCrypt Pkcs11LibraryHandle = dlopen (pkcs11LibraryPath.c_str(), RTLD_NOW | RTLD_LOCAL); throw_sys_sub_if (!Pkcs11LibraryHandle, dlerror()); #endif - + typedef CK_RV (*C_GetFunctionList_t) (CK_FUNCTION_LIST_PTR_PTR ppFunctionList); #ifdef TC_WINDOWS diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h index 00d543a2..95d95fc8 100644 --- a/src/Common/SecurityToken.h +++ b/src/Common/SecurityToken.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -139,7 +139,7 @@ namespace VeraCrypt { void Show (HWND parent) const { Error (SecurityTokenLibraryPath[0] == 0 ? "NO_PKCS11_MODULE_SPECIFIED" : "PKCS11_MODULE_INIT_FAILED", parent); } }; - + struct InvalidSecurityTokenKeyfilePath : public Exception { void Show (HWND parent) const { Error ("INVALID_TOKEN_KEYFILE_PATH", parent); } @@ -197,7 +197,7 @@ namespace VeraCrypt #endif static bool IsInitialized () { return Initialized; } static bool IsKeyfilePathValid (const wstring &securityTokenKeyfilePath); - + static const size_t MaxPasswordLength = 128; protected: diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h index 85cb01d0..2d8a6fe3 100644 --- a/src/Common/Tcdefs.h +++ b/src/Common/Tcdefs.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -16,7 +16,7 @@ #define TC_APP_NAME "VeraCrypt" -// Version displayed to user +// Version displayed to user #define VERSION_STRING "1.17" // Version number to compare against driver @@ -106,9 +106,9 @@ typedef unsigned __int32 uint_32t; typedef uint64 uint_64t; #endif -typedef union +typedef union { - struct + struct { unsigned __int32 LowPart; unsigned __int32 HighPart; @@ -276,9 +276,9 @@ void EraseMemory (void *memory, int size); enum { - /* WARNING: ADD ANY NEW CODES AT THE END (DO NOT INSERT THEM BETWEEN EXISTING). DO *NOT* DELETE ANY + /* WARNING: ADD ANY NEW CODES AT THE END (DO NOT INSERT THEM BETWEEN EXISTING). DO *NOT* DELETE ANY EXISTING CODES! Changing these values or their meanings may cause incompatibility with other versions - (for example, if a new version of the TrueCrypt installer receives an error code from an installed + (for example, if a new version of the TrueCrypt installer receives an error code from an installed driver whose version is lower, it will report and interpret the error incorrectly). */ ERR_SUCCESS = 0, diff --git a/src/Common/Tests.c b/src/Common/Tests.c index 8dc72d2c..9d9e8118 100644 --- a/src/Common/Tests.c +++ b/src/Common/Tests.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -40,7 +40,7 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { { 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff }, 0, - { + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0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xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff }, - { + { 0x1c, 0x3b, 0x3a, 0x10, 0x2f, 0x77, 0x03, 0x86, 0xe4, 0x83, 0x6c, 0x99, 0xe3, 0x70, 0xcf, 0x9b, 0xea, 0x00, 0x80, 0x3f, 0x5e, 0x48, 0x23, 0x57, 0xa4, 0xae, 0x12, 0xd4, 0x14, 0xa3, 0xe6, 0x3b, 0x5d, 0x31, 0xe2, 0x76, 0xf8, 0xfe, 0x4a, 0x8d, 0x66, 0xb3, 0x17, 0xf9, 0xac, 0x68, 0x3f, 0x44, 0x68, 0x0a, 0x86, 0xac, 0x35, 0xad, 0xfc, 0x33, 0x45, 0xbe, 0xfe, 0xcb, 0x4b, 0xb1, 0x88, 0xfd, 0x57, 0x76, 0x92, 0x6c, 0x49, 0xa3, 0x09, 0x5e, 0xb1, 0x08, 0xfd, 0x10, 0x98, 0xba, 0xec, 0x70, 0xaa, 0xa6, 0x69, 0x99, 0xa7, 0x2a, 0x82, 0xf2, 0x7d, 0x84, 0x8b, 0x21, 0xd4, 0xa7, 0x41, 0xb0, @@ -74,7 +74,7 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { 0x6e, 0x33, 0x3b, 0x93, 0xeb, 0x4a, 0xff, 0x04, 0x79, 0xda, 0x9a, 0x41, 0x0e, 0x44, 0x50, 0xe0, 0xdd, 0x7a, 0xe4, 0xc6, 0xe2, 0x91, 0x09, 0x00, 0x57, 0x5d, 0xa4, 0x01, 0xfc, 0x07, 0x05, 0x9f, 0x64, 0x5e, 0x8b, 0x7e, 0x9b, 0xfd, 0xef, 0x33, 0x94, 0x30, 0x54, 0xff, 0x84, 0x01, 0x14, 0x93, 0xc2, 0x7b, 0x34, 0x29, 0xea, 0xed, 0xb4, 0xed, 0x53, 0x76, 0x44, 0x1a, 0x77, 0xed, 0x43, 0x85, 0x1a, 0xd7, 0x7f, 0x16, 0xf5, 0x41, 0xdf, 0xd2, 0x69, 0xd5, 0x0d, 0x6a, 0x5f, 0x14, 0xfb, 0x0a, 0xab, 0x1c, 0xbb, 0x4c, 0x15, 0x50, 0xbe, 0x97, 0xf7, 0xab, 0x40, 0x66, 0x19, 0x3c, 0x4c, 0xaa, - 0x77, 0x3d, 0xad, 0x38, 0x01, 0x4b, 0xd2, 0x09, 0x2f, 0xa7, 0x55, 0xc8, 0x24, 0xbb, 0x5e, 0x54, 0xc4, 0xf3, 0x6f, 0xfd, 0xa9, 0xfc, 0xea, 0x70, 0xb9, 0xc6, 0xe6, 0x93, 0xe1, 0x48, 0xc1, 0x51 + 0x77, 0x3d, 0xad, 0x38, 0x01, 0x4b, 0xd2, 0x09, 0x2f, 0xa7, 0x55, 0xc8, 0x24, 0xbb, 0x5e, 0x54, 0xc4, 0xf3, 0x6f, 0xfd, 0xa9, 0xfc, 0xea, 0x70, 0xb9, 0xc6, 0xe6, 0x93, 0xe1, 0x48, 0xc1, 0x51 } }, { @@ -83,8 +83,8 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27 }, { 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }, - 0, - { + 0, + { 0x00, 0x01, 0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T] = { 0x09, 0x4f, 0x7c, 0x45, 0x3b, 0x7f, 0xf8, 0x7c, 0xb5, 0xbb, 0x36, 0xb7, 0xc7, 0x9e, 0xfb, 0x08, 0x72, 0xd1, 0x70, 0x58, 0xb8, 0x3b, 0x15, 0xab, 0x08, 0x66, 0xad, 0x8a, 0x58, 0x65, 0x6c, 0x5a, 0x7e, 0x20, 0xdb, 0xdf, 0x30, 0x8b, 0x24, 0x61, 0xd9, 0x7c, 0x0e, 0xc0, 0x02, 0x4a, 0x27, 0x15, 0x05, 0x52, 0x49, 0xcf, 0x3b, 0x47, 0x8d, 0xdd, 0x47, 0x40, 0xde, 0x65, 0x4f, 0x75, 0xca, 0x68, 0x6e, 0x0d, 0x73, 0x45, 0xc6, 0x9e, 0xd5, 0x0c, 0xdc, 0x2a, 0x8b, 0x33, 0x2b, 0x1f, 0x88, 0x24, 0x10, 0x8a, 0xc9, 0x37, 0xeb, 0x05, 0x05, 0x85, 0x60, 0x8e, 0xe7, 0x34, 0x09, 0x7f, 0xc0, 0x90, - 0x54, 0xfb, 0xff, 0x89, 0xee, 0xae, 0xea, 0x79, 0x1f, 0x4a, 0x7a, 0xb1, 0xf9, 0x86, 0x82, 0x94, 0xa4, 0xf9, 0xe2, 0x7b, 0x42, 0xaf, 0x81, 0x00, 0xcb, 0x9d, 0x59, 0xce, 0xf9, 0x64, 0x58, 0x03 + 0x54, 0xfb, 0xff, 0x89, 0xee, 0xae, 0xea, 0x79, 0x1f, 0x4a, 0x7a, 0xb1, 0xf9, 0x86, 0x82, 0x94, 0xa4, 0xf9, 0xe2, 0x7b, 0x42, 0xaf, 0x81, 0x00, 0xcb, 0x9d, 0x59, 0xce, 0xf9, 0x64, 0x58, 0x03 } }, { @@ -127,8 +127,8 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27 }, { 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92 }, { 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff }, - 0, - { + 0, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, @@ -144,9 +144,9 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,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xed, 0x24, 0x2c, 0x89, 0x00, 0xdd, 0x1f, 0xa9, 0x65, 0xbc, 0x95, 0x0d, 0xfc, 0xe0, 0x9b, 0x13, 0x22, 0x63, 0xa1, 0xee, 0xf5, 0x2d, 0xd6, 0x88, 0x8c, 0x30, 0x9f, 0x5a, 0x7d, 0x71, 0x28, 0x26 } }, { @@ -171,8 +171,8 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27 }, { 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92 }, { 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff }, - 0, - { + 0, + { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 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8, 0xf2, 0x5f, 0x36, 0x7c, 0x87, 0xbb, 0x55, 0x78, 0xd6, 0x67, 0xae, 0x93, 0xf9, 0xe2, 0xfd, 0x99, 0xbc, 0xbc, 0x5f, 0x2f, 0xbb, 0xa8, 0x8c, - 0xf6, 0x51, 0x61, 0x39, 0x42, 0x0f, 0xcf, 0xf3, 0xb7, 0x36, 0x1d, 0x86, 0x32, 0x2c, 0x4b, 0xd8, 0x4c, 0x82, 0xf3, 0x35, 0xab, 0xb1, 0x52, 0xc4, 0xa9, 0x34, 0x11, 0x37, 0x3a, 0xaa, 0x82, 0x20 + 0xf6, 0x51, 0x61, 0x39, 0x42, 0x0f, 0xcf, 0xf3, 0xb7, 0x36, 0x1d, 0x86, 0x32, 0x2c, 0x4b, 0xd8, 0x4c, 0x82, 0xf3, 0x35, 0xab, 0xb1, 0x52, 0xc4, 0xa9, 0x34, 0x11, 0x37, 0x3a, 0xaa, 0x82, 0x20 } }, { @@ -217,42 +217,42 @@ XTS_TEST XTS_vectors[XTS_TEST_COUNT] = { { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27 }, { 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92 }, { 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff }, - 0, - { - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0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0xce, 0xcf, 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,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0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, + 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, + 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, + 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, + 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, + 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab, 0xac,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 0x53, 0x1f, 0x6a, 0x0a, 0x57, 0xb9 } } }; // XTS_TEST XTS_vectors[] @@ -446,9 +446,9 @@ char *hmac_whirlpool_test_vectors = "\x6a\xbf\xa4\x02" }; -unsigned char ks_tmp[MAX_EXPANDED_KEY]; +unsigned char ks_tmp[MAX_EXPANDED_KEY]; -void CipherInit2(int cipher, void* key, void* ks, int key_len) +void CipherInit2(int cipher, void* key, void* ks, int key_len) { switch (cipher) { @@ -465,7 +465,7 @@ void CipherInit2(int cipher, void* key, void* ks, int key_len) CipherInit(cipher,key,ks); break; - default: + default: /* Unknown/wrong ID */ TC_THROW_FATAL_EXCEPTION; } @@ -485,7 +485,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) int nTestsPerformed = 0; static unsigned char key1[] = - { + { 0x27, 0x18, 0x28, 0x18, 0x28, 0x45, 0x90, 0x45, 0x23, 0x53, 0x60, 0x28, 0x74, 0x71, 0x35, 0x26, 0x62, 0x49, 0x77, 0x57, 0x24, 0x70, 0x93, 0x69, 0x99, 0x59, 0x57, 0x49, 0x66, 0x96, 0x76, 0x27, 0x31, 0x41, 0x59, 0x26, 0x53, 0x58, 0x97, 0x93, 0x23, 0x84, 0x62, 0x64, 0x33, 0x83, 0x27, 0x95, 0x02, 0x88, 0x41, 0x97, 0x16, 0x93, 0x99, 0x37, 0x51, 0x05, 0x82, 0x09, 0x74, 0x94, 0x45, 0x92, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12, 0x13 @@ -501,8 +501,8 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) /* The buffer can accommodate 4 data units and we'll test 4 cases by "scrolling". The data unit 0xFFFFFFFFFF will "move" from the start of the buffer to its end. For a 512-byte data unit, the byte offset 562949953420800 corresponds to the data unit 0xFFFFFFFFFF. */ - for (writeOffset = 562949953420800ULL; - writeOffset > 562949953420800ULL - nbrUnits * ENCRYPTION_DATA_UNIT_SIZE; + for (writeOffset = 562949953420800ULL; + writeOffset > 562949953420800ULL - nbrUnits * ENCRYPTION_DATA_UNIT_SIZE; writeOffset -= ENCRYPTION_DATA_UNIT_SIZE) { unitNo.Value = writeOffset / ENCRYPTION_DATA_UNIT_SIZE; @@ -529,8 +529,8 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) // Each data unit will contain the same plaintext for (i = 0; i < nbrUnits; i++) { - memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, - XTS_vectors[XTS_TEST_COUNT-1].plaintext, + memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, + XTS_vectors[XTS_TEST_COUNT-1].plaintext, ENCRYPTION_DATA_UNIT_SIZE); } @@ -551,7 +551,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) // CRC of all data units in the buffer for each test case switch (testCase) { - case 0: + case 0: if (crc != 0x888f2990) return FALSE; nTestsPerformed++; @@ -792,8 +792,8 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) // Each data unit will contain the same plaintext for (i = 0; i < nbrUnits; i++) { - memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, - XTS_vectors[XTS_TEST_COUNT-1].plaintext, + memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, + XTS_vectors[XTS_TEST_COUNT-1].plaintext, ENCRYPTION_DATA_UNIT_SIZE); } @@ -881,7 +881,7 @@ static BOOL DoAutoTestAlgorithms (void) /* AES */ for (i = 0; i < AES_TEST_COUNT; i++) - { + { int cipher = AES; memcpy(key, aes_ecb_vectors[i].key, 32); memcpy(tmp, aes_ecb_vectors[i].plaintext, 16); @@ -926,7 +926,7 @@ static BOOL DoAutoTestAlgorithms (void) /* Serpent */ for (i = 0; i < SERPENT_TEST_COUNT; i++) - { + { int cipher = SERPENT; memcpy(key, serpent_vectors[i].key, 32); memcpy(tmp, serpent_vectors[i].plaintext, 16); @@ -947,7 +947,7 @@ static BOOL DoAutoTestAlgorithms (void) /* Twofish */ for (i = 0; i < TWOFISH_TEST_COUNT; i++) - { + { int cipher = TWOFISH; memcpy(key, twofish_vectors[i].key, 32); memcpy(tmp, twofish_vectors[i].plaintext, 16); @@ -964,7 +964,7 @@ static BOOL DoAutoTestAlgorithms (void) if (i != TWOFISH_TEST_COUNT) bFailed = TRUE; - + /* PKCS #5 and HMACs */ if (!test_pkcs5 ()) bFailed = TRUE; @@ -986,7 +986,7 @@ static BOOL DoAutoTestAlgorithms (void) /* Sector and buffer related algorithms */ if (!TestSectorBufEncryption (ci)) bFailed = TRUE; - + crypto_close (ci); return !bFailed; } diff --git a/src/Common/Tests.h b/src/Common/Tests.h index 5e56ff55..f2f99502 100644 --- a/src/Common/Tests.h +++ b/src/Common/Tests.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -15,7 +15,7 @@ extern "C" { #endif -extern unsigned char ks_tmp[MAX_EXPANDED_KEY]; +extern unsigned char ks_tmp[MAX_EXPANDED_KEY]; void CipherInit2(int cipher, void* key, void* ks, int key_len); BOOL test_hmac_sha512 (void); diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index d2a54b5c..007a1c08 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -243,7 +243,7 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int } #endif } - + #ifndef DEVICE_DRIVER VirtualLock (&keyInfo, sizeof (keyInfo)); VirtualLock (&dk, sizeof (dk)); @@ -256,7 +256,7 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int // Test all available PKCS5 PRFs for (enqPkcs5Prf = FIRST_PRF_ID; enqPkcs5Prf <= LAST_PRF_ID || queuedWorkItems > 0; ++enqPkcs5Prf) - { + { // if a PRF is specified, we skip all other PRFs if (selected_pkcs5_prf != 0 && enqPkcs5Prf != selected_pkcs5_prf) continue; @@ -282,7 +282,7 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int EncryptionThreadPoolBeginKeyDerivation (&keyDerivationCompletedEvent, &noOutstandingWorkItemEvent, &item->KeyReady, &outstandingWorkItemCount, enqPkcs5Prf, keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, get_pkcs5_iteration_count (enqPkcs5Prf, pim, truecryptMode, bBoot), item->DerivedKey); - + ++queuedWorkItems; break; } @@ -345,10 +345,10 @@ KeyReady: ; PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; - } + } } // Test all available modes of operation @@ -401,7 +401,7 @@ KeyReady: ; // Copy the header for decryption memcpy (header, encryptedHeader, sizeof (header)); - // Try to decrypt header + // Try to decrypt header DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); @@ -413,7 +413,7 @@ KeyReady: ; // Header version headerVersion = GetHeaderField16 (header, TC_HEADER_OFFSET_VERSION); - + if (headerVersion > VOLUME_HEADER_VERSION) { status = ERR_NEW_VERSION_REQUIRED; @@ -471,7 +471,7 @@ KeyReady: ; // Volume size cryptoInfo->VolumeSize = GetHeaderField64 (header, TC_HEADER_OFFSET_VOLUME_SIZE); - + // Encrypted area size and length cryptoInfo->EncryptedAreaStart = GetHeaderField64 (header, TC_HEADER_OFFSET_ENCRYPTED_AREA_START); cryptoInfo->EncryptedAreaLength = GetHeaderField64 (header, TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH); @@ -493,7 +493,7 @@ KeyReady: ; goto err; } - // Preserve scheduled header keys if requested + // Preserve scheduled header keys if requested if (retHeaderCryptoInfo) { if (retInfo == NULL) @@ -557,7 +557,7 @@ err: if (cryptoInfo != retHeaderCryptoInfo) { crypto_close(cryptoInfo); - *retInfo = NULL; + *retInfo = NULL; } ret: @@ -601,7 +601,7 @@ void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderS WHIRLPOOL_CTX whirlpool; sha512_ctx sha2; - + WHIRLPOOL_init (&whirlpool); sha512_begin (&sha2); @@ -690,9 +690,9 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCR EAInit (cryptoInfo->ea, dk + EAGetKeySize (cryptoInfo->ea), cryptoInfo->ks2); #endif - // Try to decrypt header + // Try to decrypt header DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); - + // Check magic 'VERA' and CRC-32 of header fields and master keydata if (GetHeaderField32 (header, TC_HEADER_OFFSET_MAGIC) != 0x56455241 || (GetHeaderField16 (header, TC_HEADER_OFFSET_VERSION) >= 4 && GetHeaderField32 (header, TC_HEADER_OFFSET_HEADER_CRC) != GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC)) @@ -774,7 +774,7 @@ err: if (cryptoInfo != retHeaderCryptoInfo) { crypto_close(cryptoInfo); - *retInfo = NULL; + *retInfo = NULL; } ret: @@ -844,7 +844,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, memcpy (keyInfo.master_keydata, masterKeydata, MASTER_KEYDATA_SIZE); } - // User key + // User key memcpy (keyInfo.userKey, password->Text, nUserKeyLen); keyInfo.keyLength = nUserKeyLen; keyInfo.noIterations = get_pkcs5_iteration_count (pkcs5_prf, pim, FALSE, bBoot); @@ -863,7 +863,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, // Salt for header key derivation if (!RandgetBytes (hwndDlg, keyInfo.salt, PKCS5_SALT_SIZE, !bWipeMode)) - return ERR_CIPHER_INIT_WEAK_KEY; + return ERR_CIPHER_INIT_WEAK_KEY; // PBKDF2 (PKCS5) is used to derive primary header key(s) and secondary header key(s) (XTS) from the password/keyfiles switch (pkcs5_prf) @@ -888,15 +888,15 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; - default: + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; - } + } /* Header setup */ // Salt - mputBytes (p, keyInfo.salt, PKCS5_SALT_SIZE); + mputBytes (p, keyInfo.salt, PKCS5_SALT_SIZE); // Magic mputLong (p, 0x56455241); @@ -985,7 +985,7 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, /* cryptoInfo setup for further use (disk format) */ - // Init with the master key(s) + // Init with the master key(s) retVal = EAInit (cryptoInfo->ea, keyInfo.master_keydata + primaryKeyOffset, cryptoInfo->ks); if (retVal != ERR_SUCCESS) return retVal; @@ -1080,7 +1080,7 @@ BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DW return FALSE; memcpy (header, sectorBuffer, min (*bytesRead, TC_VOLUME_HEADER_EFFECTIVE_SIZE)); - + if (*bytesRead > TC_VOLUME_HEADER_EFFECTIVE_SIZE) *bytesRead = TC_VOLUME_HEADER_EFFECTIVE_SIZE; @@ -1181,7 +1181,7 @@ int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE) || !RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE)) { - nStatus = ERR_PARAMETER_INCORRECT; + nStatus = ERR_PARAMETER_INCORRECT; goto final_seq; } diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h index 43aaaf73..fdd1444f 100644 --- a/src/Common/Volumes.h +++ b/src/Common/Volumes.h @@ -1,11 +1,11 @@ /* Legal Notice: Some portions of the source code contained in this file were - derived from the source code of TrueCrypt 7.1a, which is - Copyright (c) 2003-2012 TrueCrypt Developers Association and which is + derived from the source code of TrueCrypt 7.1a, which is + Copyright (c) 2003-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0, also from the source code of Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux - and which is governed by the 'License Agreement for Encryption for the Masses' - Modifications and additions to the original source code (contained in this file) + and which is governed by the 'License Agreement for Encryption for the Masses' + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -19,7 +19,7 @@ extern "C" { #endif // Volume header version -#define VOLUME_HEADER_VERSION 0x0005 +#define VOLUME_HEADER_VERSION 0x0005 // Version number written to volume header during format; // specifies the minimum program version required to mount the volume @@ -101,7 +101,7 @@ extern "C" { #define HEADER_SALT_OFFSET 0 #define HEADER_ENCRYPTED_DATA_OFFSET PKCS5_SALT_SIZE #define HEADER_MASTER_KEYDATA_OFFSET 256 - + #define TC_HEADER_OFFSET_MAGIC 64 #define TC_HEADER_OFFSET_VERSION 68 #define TC_HEADER_OFFSET_REQUIRED_VERSION 70 diff --git a/src/Common/Wipe.c b/src/Common/Wipe.c index 83099547..5b07ced5 100644 --- a/src/Common/Wipe.c +++ b/src/Common/Wipe.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Wipe.h b/src/Common/Wipe.h index 97011085..a6ca748f 100644 --- a/src/Common/Wipe.h +++ b/src/Common/Wipe.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Xml.c b/src/Common/Xml.c index 60dd8266..d733dac1 100644 --- a/src/Common/Xml.c +++ b/src/Common/Xml.c @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -172,7 +172,7 @@ char *XmlQuoteText (const char *textSrc, char *textDst, int textDstMaxSize) if (textDstMaxSize == 0) return NULL; - while (*textSrc != 0 && textDst <= textDstLast) + while (*textSrc != 0 && textDst <= textDstLast) { char c = *textSrc++; switch (c) @@ -217,7 +217,7 @@ wchar_t *XmlQuoteTextW (const wchar_t *textSrc, wchar_t *textDst, int textDstMax if (textDstMaxSize == 0) return NULL; - while (*textSrc != 0 && textDst <= textDstLast) + while (*textSrc != 0 && textDst <= textDstLast) { wchar_t c = *textSrc++; switch (c) diff --git a/src/Common/Xml.h b/src/Common/Xml.h index 41daf40f..3dfb58e1 100644 --- a/src/Common/Xml.h +++ b/src/Common/Xml.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source diff --git a/src/Common/Xts.c b/src/Common/Xts.c index 0bdb8271..02977887 100644 --- a/src/Common/Xts.c +++ b/src/Common/Xts.c @@ -3,14 +3,14 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ -/* If native 64-bit data types are not available, define TC_NO_COMPILER_INT64. +/* If native 64-bit data types are not available, define TC_NO_COMPILER_INT64. For big-endian platforms define BYTE_ORDER as BIG_ENDIAN. */ @@ -37,7 +37,7 @@ For big-endian platforms define BYTE_ORDER as BIG_ENDIAN. */ // ks2: the secondary key schedule // startDataUnitNo: The sequential number of the data unit with which the buffer starts. // startCipherBlockNo: The sequential number of the first plaintext block to encrypt inside the data unit startDataUnitNo. -// When encrypting the data unit from its first block, startCipherBlockNo is 0. +// When encrypting the data unit from its first block, startCipherBlockNo is 0. // The startCipherBlockNo value applies only to the first data unit in the buffer; each successive // data unit is encrypted from its first block. The start of the buffer does not have to be // aligned with the start of a data unit. If it is aligned, startCipherBlockNo must be 0; if it @@ -85,7 +85,7 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, the shift of the highest byte results in a carry, 135 is XORed into the lowest byte. The value 135 is derived from the modulus of the Galois Field (x^128+x^7+x^2+x+1). */ - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. // Note that as we are converting a 64-bit number into a 16-byte array we can always zero the last 8 bytes. dataUnitNo = startDataUnitNo->Value; *((unsigned __int64 *) byteBufUnitNo) = LE64 (dataUnitNo); @@ -107,7 +107,7 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, whiteningValuesPtr64 = finalInt64WhiteningValuesPtr; whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; - // Encrypt the data unit number using the secondary key (in order to generate the first + // Encrypt the data unit number using the secondary key (in order to generate the first // whitening value for this data unit) *whiteningValuePtr64 = *((unsigned __int64 *) byteBufUnitNo); *(whiteningValuePtr64 + 1) = 0; @@ -131,21 +131,21 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, // Little-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x8000000000000000) ? 135 : 0; *whiteningValuePtr64-- <<= 1; if (*whiteningValuePtr64 & 0x8000000000000000) - *(whiteningValuePtr64 + 1) |= 1; + *(whiteningValuePtr64 + 1) |= 1; *whiteningValuePtr64 <<= 1; #else // Big-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x80) ? 135 : 0; @@ -154,7 +154,7 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) - *(whiteningValuePtr64 + 1) |= 0x0100000000000000; + *(whiteningValuePtr64 + 1) |= 0x0100000000000000; *whiteningValuePtr64 = LE64 (LE64 (*whiteningValuePtr64) << 1); #endif @@ -176,7 +176,7 @@ static void EncryptBufferXTSParallel (unsigned __int8 *buffer, // Actual encryption EncipherBlocks (cipher, dataUnitBufPtr, ks, endBlock - startBlock); - + bufPtr = dataUnitBufPtr; whiteningValuesPtr64 = finalInt64WhiteningValuesPtr; @@ -222,7 +222,7 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, the shift of the highest byte results in a carry, 135 is XORed into the lowest byte. The value 135 is derived from the modulus of the Galois Field (x^128+x^7+x^2+x+1). */ - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. // Note that as we are converting a 64-bit number into a 16-byte array we can always zero the last 8 bytes. dataUnitNo = startDataUnitNo->Value; *((unsigned __int64 *) byteBufUnitNo) = LE64 (dataUnitNo); @@ -243,7 +243,7 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; - // Encrypt the data unit number using the secondary key (in order to generate the first + // Encrypt the data unit number using the secondary key (in order to generate the first // whitening value for this data unit) *whiteningValuePtr64 = *((unsigned __int64 *) byteBufUnitNo); *(whiteningValuePtr64 + 1) = 0; @@ -275,21 +275,21 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, // Little-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x8000000000000000) ? 135 : 0; *whiteningValuePtr64-- <<= 1; if (*whiteningValuePtr64 & 0x8000000000000000) - *(whiteningValuePtr64 + 1) |= 1; + *(whiteningValuePtr64 + 1) |= 1; *whiteningValuePtr64 <<= 1; #else // Big-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x80) ? 135 : 0; @@ -298,7 +298,7 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) - *(whiteningValuePtr64 + 1) |= 0x0100000000000000; + *(whiteningValuePtr64 + 1) |= 0x0100000000000000; *whiteningValuePtr64 = LE64 (LE64 (*whiteningValuePtr64) << 1); #endif @@ -353,7 +353,7 @@ static void DecryptBufferXTSParallel (unsigned __int8 *buffer, unsigned __int64 *const finalInt64WhiteningValuesPtr = whiteningValuesPtr64 + sizeof (whiteningValues) / sizeof (*whiteningValuesPtr64) - 1; TC_LARGEST_COMPILER_UINT blockCount, dataUnitNo; - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. // Note that as we are converting a 64-bit number into a 16-byte array we can always zero the last 8 bytes. dataUnitNo = startDataUnitNo->Value; *((unsigned __int64 *) byteBufUnitNo) = LE64 (dataUnitNo); @@ -375,7 +375,7 @@ static void DecryptBufferXTSParallel (unsigned __int8 *buffer, whiteningValuesPtr64 = finalInt64WhiteningValuesPtr; whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; - // Encrypt the data unit number using the secondary key (in order to generate the first + // Encrypt the data unit number using the secondary key (in order to generate the first // whitening value for this data unit) *whiteningValuePtr64 = *((unsigned __int64 *) byteBufUnitNo); *(whiteningValuePtr64 + 1) = 0; @@ -399,21 +399,21 @@ static void DecryptBufferXTSParallel (unsigned __int8 *buffer, // Little-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x8000000000000000) ? 135 : 0; *whiteningValuePtr64-- <<= 1; if (*whiteningValuePtr64 & 0x8000000000000000) - *(whiteningValuePtr64 + 1) |= 1; + *(whiteningValuePtr64 + 1) |= 1; *whiteningValuePtr64 <<= 1; #else // Big-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x80) ? 135 : 0; @@ -422,7 +422,7 @@ static void DecryptBufferXTSParallel (unsigned __int8 *buffer, whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) - *(whiteningValuePtr64 + 1) |= 0x0100000000000000; + *(whiteningValuePtr64 + 1) |= 0x0100000000000000; *whiteningValuePtr64 = LE64 (LE64 (*whiteningValuePtr64) << 1); #endif @@ -481,7 +481,7 @@ static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, unsigned int startBlock = startCipherBlockNo, endBlock, block; TC_LARGEST_COMPILER_UINT blockCount, dataUnitNo; - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. // Note that as we are converting a 64-bit number into a 16-byte array we can always zero the last 8 bytes. dataUnitNo = startDataUnitNo->Value; *((unsigned __int64 *) byteBufUnitNo) = LE64 (dataUnitNo); @@ -502,7 +502,7 @@ static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; - // Encrypt the data unit number using the secondary key (in order to generate the first + // Encrypt the data unit number using the secondary key (in order to generate the first // whitening value for this data unit) *whiteningValuePtr64 = *((unsigned __int64 *) byteBufUnitNo); *(whiteningValuePtr64 + 1) = 0; @@ -534,21 +534,21 @@ static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, // Little-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x8000000000000000) ? 135 : 0; *whiteningValuePtr64-- <<= 1; if (*whiteningValuePtr64 & 0x8000000000000000) - *(whiteningValuePtr64 + 1) |= 1; + *(whiteningValuePtr64 + 1) |= 1; *whiteningValuePtr64 <<= 1; #else // Big-endian platforms - finalCarry = + finalCarry = (*whiteningValuePtr64 & 0x80) ? 135 : 0; @@ -557,7 +557,7 @@ static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) - *(whiteningValuePtr64 + 1) |= 0x0100000000000000; + *(whiteningValuePtr64 + 1) |= 0x0100000000000000; *whiteningValuePtr64 = LE64 (LE64 (*whiteningValuePtr64) << 1); #endif @@ -581,7 +581,7 @@ static void DecryptBufferXTSNonParallel (unsigned __int8 *buffer, #if BYTE_ORDER == BIG_ENDIAN #error The TC_NO_COMPILER_INT64 version of the XTS code is not compatible with big-endian platforms -#endif +#endif // Converts a 64-bit unsigned integer (passed as two 32-bit integers for compatibility with non-64-bit @@ -627,7 +627,7 @@ static void EncryptDecryptBufferXTS32 (const unsigned __int8 *buffer, blockCount = length / BYTES_PER_XTS_BLOCK; - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. // (Passed as two 32-bit integers for compatibility with non-64-bit environments/platforms.) Uint64ToLE16ByteArray (byteBufUnitNo, dataUnitNo.HighPart, dataUnitNo.LowPart); @@ -639,7 +639,7 @@ static void EncryptDecryptBufferXTS32 (const unsigned __int8 *buffer, else endBlock = BLOCKS_PER_XTS_DATA_UNIT; - // Encrypt the data unit number using the secondary key (in order to generate the first + // Encrypt the data unit number using the secondary key (in order to generate the first // whitening value for this data unit) memcpy (whiteningValue, byteBufUnitNo, BYTES_PER_XTS_BLOCK); EncipherBlock (cipher, whiteningValue, ks2); @@ -690,7 +690,7 @@ static void EncryptDecryptBufferXTS32 (const unsigned __int8 *buffer, // A regular carry *(whiteningValuePtr32 + 1) |= 1; } - else + else { // The highest byte shift will result in a carry finalCarry = 135; @@ -712,7 +712,7 @@ static void EncryptDecryptBufferXTS32 (const unsigned __int8 *buffer, dataUnitNo.HighPart++; } - // Convert the 64-bit data unit number into a little-endian 16-byte array. + // Convert the 64-bit data unit number into a little-endian 16-byte array. Uint64ToLE16ByteArray (byteBufUnitNo, dataUnitNo.HighPart, dataUnitNo.LowPart); } diff --git a/src/Common/Xts.h b/src/Common/Xts.h index f4f4ab5b..2cf0a95d 100644 --- a/src/Common/Xts.h +++ b/src/Common/Xts.h @@ -3,7 +3,7 @@ Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed by the TrueCrypt License 3.0. - Modifications and additions to the original source code (contained in this file) + Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2016 IDRIX and are governed by the Apache License 2.0 the full text of which is contained in the file License.txt included in VeraCrypt binary and source @@ -54,9 +54,9 @@ extern "C" { #endif #ifndef TCDEFS_H -typedef union +typedef union { - struct + struct { unsigned __int32 LowPart; unsigned __int32 HighPart; |