diff options
Diffstat (limited to 'src')
354 files changed, 14013 insertions, 5802 deletions
diff --git a/src/Boot/Windows/Bios.h b/src/Boot/Windows/Bios.h index 7085e7a2..0282fad7 100644 --- a/src/Boot/Windows/Bios.h +++ b/src/Boot/Windows/Bios.h @@ -1,33 +1,33 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Boot_Bios #define TC_HEADER_Boot_Bios #include "Platform.h" #define TC_LB_SIZE_BIT_SHIFT_DIVISOR 9 #define TC_FIRST_BIOS_DRIVE 0x80 #define TC_LAST_BIOS_DRIVE 0x8f #define TC_INVALID_BIOS_DRIVE (TC_FIRST_BIOS_DRIVE - 1) enum { BiosResultSuccess = 0x00, BiosResultInvalidFunction = 0x01, BiosResultTimeout = 0x80 }; -typedef byte BiosResult; +typedef uint8 BiosResult; #endif // TC_HEADER_Boot_Bios diff --git a/src/Boot/Windows/BootCommon.h b/src/Boot/Windows/BootCommon.h index d2ee42a1..45a1a650 100644 --- a/src/Boot/Windows/BootCommon.h +++ b/src/Boot/Windows/BootCommon.h @@ -16,61 +16,61 @@ #include "Common/Password.h" #include "BootDefs.h" // The user will be advised to upgrade the rescue disk if upgrading from the following or any previous version #define TC_RESCUE_DISK_UPGRADE_NOTICE_MAX_VERSION 0x0125 #define TC_BOOT_LOADER_AREA_SIZE (TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) #define TC_BOOT_VOLUME_HEADER_SECTOR (TC_BOOT_LOADER_AREA_SECTOR_COUNT - 1) #define TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET (TC_BOOT_VOLUME_HEADER_SECTOR * TC_SECTOR_SIZE_BIOS) #define TC_CD_BOOTSECTOR_OFFSET 0xd000 #define TC_CD_BOOT_LOADER_SECTOR 26 #define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR TC_BOOT_LOADER_AREA_SECTOR_COUNT #define TC_ORIG_BOOT_LOADER_BACKUP_SECTOR_OFFSET (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR * TC_SECTOR_SIZE_BIOS) #define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR (TC_ORIG_BOOT_LOADER_BACKUP_SECTOR + TC_BOOT_LOADER_AREA_SECTOR_COUNT) #define TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET (TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR * TC_SECTOR_SIZE_BIOS) #define TC_MBR_SECTOR 0 #define TC_MAX_MBR_BOOT_CODE_SIZE 440 #define TC_MAX_EXTRA_BOOT_PARTITION_SIZE (512UL * 1024UL * 1024UL) #pragma pack (1) typedef struct { - byte Flags; + uint8 Flags; } BootSectorConfiguration; // Modifying this value can introduce incompatibility with previous versions #define TC_BOOT_LOADER_ARGS_OFFSET 0x10 typedef struct { // Modifying this structure can introduce incompatibility with previous versions char Signature[8]; uint16 BootLoaderVersion; uint16 CryptoInfoOffset; uint16 CryptoInfoLength; uint32 HeaderSaltCrc32; PasswordLegacy BootPassword; uint64 HiddenSystemPartitionStart; uint64 DecoySystemPartitionStart; uint32 Flags; uint32 BootDriveSignature; uint32 BootArgumentsCrc32; } BootArguments; // Modifying these values can introduce incompatibility with previous versions #define TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION 0x1 #pragma pack () // Boot arguments signature should not be defined as a static string @@ -93,126 +93,126 @@ typedef struct #define DE_IDX_MAINGPTENTRYS 4 #define DE_IDX_ALTGPTHDR 5 #define DE_IDX_ALTGPTENTRYS 6 #define DE_IDX_EXEC 7 #define DE_IDX_PWDCACHE 8 #define DE_IDX_RND 9 #define DE_IDX_TOTAL 10 CSTATIC_ASSERT(DE_IDX_TOTAL <= 15, DE_IDX_TOTAL_too_big); enum DcsDiskEntryTypes { DE_Unused = 0, DE_Sectors, DE_List, DE_DISKID, DE_ExecParams, DE_PwdCache, DE_Rnd }; #pragma pack(1) typedef struct _SECREGION_BOOT_PARAMS { uint64 Ptr; uint32 Size; uint32 Crc; } SECREGION_BOOT_PARAMS; typedef struct { uint32 Data1; uint16 Data2; uint16 Data3; - byte Data4[8]; + uint8 Data4[8]; } DCS_GUID; // DE types typedef struct _DCS_DISK_ENTRY_SECTORS { uint32 Type; uint32 Offset; // Offset in memory uint64 Reserved; uint64 Start; // Start on disk (byte) uint64 Length; // length on disk (byte) } DCS_DISK_ENTRY_SECTORS; CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_SECTORS) == 32, Wrong_size_DCS_DISK_ENTRY_SECTORS); typedef struct _DCS_DISK_ENTRY_PARAMS { uint32 Type; uint32 Offset; uint64 Reserved[2]; uint64 Length; // size of data } DCS_DISK_ENTRY_PARAMS; CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_PARAMS) == 32, Wrong_size_DCS_DISK_ENTRY_PARAMS); typedef struct _DCS_DISK_ENTRY_DISKID { uint32 Type; uint32 MbrID; uint64 ReservedDiskId; DCS_GUID GptID; } DCS_DISK_ENTRY_DISKID; CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_DISKID) == 32, Wrong_size_DCS_DISK_ENTRY_DISKID); #pragma warning(disable:4201) typedef struct _DCS_DISK_ENTRY { union { struct { uint32 Type; uint32 Offset; - byte reserved[16]; + uint8 reserved[16]; uint64 Length; // size of structure at Offset }; DCS_DISK_ENTRY_SECTORS Sectors; DCS_DISK_ENTRY_DISKID DiskId; DCS_DISK_ENTRY_PARAMS Prm; }; } DCS_DISK_ENTRY; #pragma warning(default:4201) CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY) == 32, Wrong_size_DCS_DISK_ENTRY); // Static compile time checks field offsets #ifndef FIELD_OFFSET #define FIELD_OFFSET(t, f) ((UINTN)(&((t*)0)->f)) #endif CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Type), Wrong_Type_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_DISKID, Type), Wrong_Type_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Type) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Type), Wrong_Type_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Length), Wrong_Length_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Length) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Length), Wrong_Length_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_SECTORS, Offset), Wrong_Offset_offset); CSTATIC_ASSERT(FIELD_OFFSET(DCS_DISK_ENTRY, Offset) == FIELD_OFFSET(DCS_DISK_ENTRY_PARAMS, Offset), Wrong_Offset_offset); // DE type specific data // DE List typedef struct _DCS_DISK_ENTRY_LIST { // EFI_TABLE_HEADER uint64 Signature; uint32 Revision; uint32 HeaderSize; //< The size, in bytes, of the entire table including the EFI_TABLE_HEADER. uint32 CRC32; //< The 32-bit CRC for the entire table. This value is computed by setting this field to 0, and computing the 32-bit CRC for HeaderSize bytes. uint32 Reserved; //< Reserved field that must be set to 0. // uint32 Count; uint32 DataSize; // DCS_DISK_ENTRY DE[15]; } DCS_DISK_ENTRY_LIST; CSTATIC_ASSERT(sizeof(DCS_DISK_ENTRY_LIST) == 512, Wrong_size_DCS_DISK_ENTRY_LIST); typedef struct _DCS_DEP_EXEC { DCS_GUID ExecPartGuid; uint16 ExecCmd[248]; } DCS_DEP_EXEC; CSTATIC_ASSERT(sizeof(DCS_DEP_EXEC) == 512, Wrong_size_DCS_DEP_EXEC); #define DCS_DEP_PWD_CACHE_SIGN SIGNATURE_64 ('P','W','D','C','A','C','H','E') typedef struct _DCS_DEP_PWD_CACHE { uint64 Sign; uint32 CRC; uint32 Count; PasswordLegacy Pwd[4]; int32 Pim[4]; - byte pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; + uint8 pad[512 - 8 - 4 - 4 - (sizeof(PasswordLegacy) + 4) * 4]; } DCS_DEP_PWD_CACHE; CSTATIC_ASSERT(sizeof(DCS_DEP_PWD_CACHE) == 512, Wrong_size_DCS_DEP_PWD_CACHE); #pragma pack() #endif // #if !defined(TC_WINDOWS_BOOT) #endif // TC_HEADER_Boot_BootCommon diff --git a/src/Boot/Windows/BootConfig.cpp b/src/Boot/Windows/BootConfig.cpp index 0412d082..948dfd93 100644 --- a/src/Boot/Windows/BootConfig.cpp +++ b/src/Boot/Windows/BootConfig.cpp @@ -1,116 +1,116 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "BootConfig.h" -byte BootSectorFlags; +uint8 BootSectorFlags; -byte BootLoaderDrive; -byte BootDrive; +uint8 BootLoaderDrive; +uint8 BootDrive; bool BootDriveGeometryValid = false; bool PreventNormalSystemBoot = false; bool PreventBootMenu = false; char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1]; uint32 OuterVolumeBackupHeaderCrc; bool BootStarted = false; DriveGeometry BootDriveGeometry; CRYPTO_INFO *BootCryptoInfo; Partition EncryptedVirtualPartition; Partition ActivePartition; Partition PartitionFollowingActive; bool ExtraBootPartitionPresent = false; uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage uint64 HiddenVolumeStartSector; #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE void ReadBootSectorUserConfiguration () { - byte userConfig; + uint8 userConfig; AcquireSectorBuffer(); if (ReadWriteMBR (false, BootLoaderDrive, true) != BiosResultSuccess) goto ret; userConfig = SectorBuffer[TC_BOOT_SECTOR_USER_CONFIG_OFFSET]; #ifdef TC_WINDOWS_BOOT_AES EnableHwEncryption (!(userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION)); #endif PreventBootMenu = (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_ESC); memcpy (CustomUserMessage, SectorBuffer + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH); CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH] = 0; if (userConfig & TC_BOOT_USER_CFG_FLAG_SILENT_MODE) { if (CustomUserMessage[0]) { InitVideoMode(); Print (CustomUserMessage); } DisableScreenOutput(); } if (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM) { PimValueOrHiddenVolumeStartUnitNo.LowPart = 0; memcpy (&PimValueOrHiddenVolumeStartUnitNo.LowPart, SectorBuffer + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, TC_BOOT_SECTOR_PIM_VALUE_SIZE); } else PimValueOrHiddenVolumeStartUnitNo.LowPart = -1; OuterVolumeBackupHeaderCrc = *(uint32 *) (SectorBuffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET); ret: ReleaseSectorBuffer(); } -BiosResult UpdateBootSectorConfiguration (byte drive) +BiosResult UpdateBootSectorConfiguration (uint8 drive) { uint64 mbrSector; mbrSector.HighPart = 0; mbrSector.LowPart = 0; AcquireSectorBuffer(); /* BiosResult result = ReadWriteMBR (false, drive); if (result != BiosResultSuccess) goto ret; SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags; result = ReadWriteMBR (true, drive); */ BiosResult result = ReadWriteSectors (false, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, mbrSector, 8, false); if (result != BiosResultSuccess) goto ret; CopyMemory (TC_BOOT_LOADER_BUFFER_SEGMENT, 0, SectorBuffer, TC_LB_SIZE); SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] = BootSectorFlags; CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT,0, TC_LB_SIZE); result = ReadWriteSectors (true, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, drive, mbrSector, 8, false); ret: ReleaseSectorBuffer(); return result; } diff --git a/src/Boot/Windows/BootConfig.h b/src/Boot/Windows/BootConfig.h index b66dc233..5338109f 100644 --- a/src/Boot/Windows/BootConfig.h +++ b/src/Boot/Windows/BootConfig.h @@ -1,46 +1,46 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Boot_BootConfig #define TC_HEADER_Boot_BootConfig #include "Crypto.h" #include "Platform.h" #include "BootDiskIo.h" -extern byte BootSectorFlags; +extern uint8 BootSectorFlags; -extern byte BootLoaderDrive; -extern byte BootDrive; +extern uint8 BootLoaderDrive; +extern uint8 BootDrive; extern bool BootDriveGeometryValid; extern DriveGeometry BootDriveGeometry; extern bool PreventNormalSystemBoot; extern bool PreventBootMenu; extern char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1]; extern uint32 OuterVolumeBackupHeaderCrc; extern bool BootStarted; extern CRYPTO_INFO *BootCryptoInfo; extern Partition EncryptedVirtualPartition; extern Partition ActivePartition; extern Partition PartitionFollowingActive; extern bool ExtraBootPartitionPresent; extern uint64 PimValueOrHiddenVolumeStartUnitNo; // reuse this variable for stored PIM value to reduce memory usage extern uint64 HiddenVolumeStartSector; void ReadBootSectorUserConfiguration (); -BiosResult UpdateBootSectorConfiguration (byte drive); +BiosResult UpdateBootSectorConfiguration (uint8 drive); #endif // TC_HEADER_Boot_BootConfig diff --git a/src/Boot/Windows/BootConsoleIo.cpp b/src/Boot/Windows/BootConsoleIo.cpp index 706e36f6..046f580b 100644 --- a/src/Boot/Windows/BootConsoleIo.cpp +++ b/src/Boot/Windows/BootConsoleIo.cpp @@ -74,71 +74,71 @@ void Print (const char *str) while (c = *str++) PrintChar (c); } void Print (uint32 number) { char str[12]; int pos = 0; while (number >= 10) { str[pos++] = (char) (number % 10) + '0'; number /= 10; } str[pos] = (char) (number % 10) + '0'; while (pos >= 0) PrintChar (str[pos--]); } void Print (const uint64 &number) { if (number.HighPart == 0) Print (number.LowPart); else PrintHex (number); } -void PrintHex (byte b) +void PrintHex (uint8 b) { PrintChar (((b >> 4) >= 0xA ? 'A' - 0xA : '0') + (b >> 4)); PrintChar (((b & 0xF) >= 0xA ? 'A' - 0xA : '0') + (b & 0xF)); } void PrintHex (uint16 data) { - PrintHex (byte (data >> 8)); - PrintHex (byte (data)); + PrintHex (uint8 (data >> 8)); + PrintHex (uint8 (data)); } void PrintHex (uint32 data) { PrintHex (uint16 (data >> 16)); PrintHex (uint16 (data)); } void PrintHex (const uint64 &data) { PrintHex (data.HighPart); PrintHex (data.LowPart); } void PrintRepeatedChar (char c, int n) { while (n-- > 0) PrintChar (c); } void PrintEndl () { Print ("\r\n"); } void PrintEndl (int cnt) @@ -192,177 +192,177 @@ void ClearScreen () mov ah, 2 int 0x10 } } void PrintBackspace () { PrintChar (TC_BIOS_CHAR_BACKSPACE); PrintCharAtCursor (' '); } void PrintError (const char *message) { Print (TC_BOOT_STR_ERROR); Print (message); PrintEndl(); Beep(); } void PrintErrorNoEndl (const char *message) { Print (TC_BOOT_STR_ERROR); Print (message); Beep(); } -byte GetShiftFlags () +uint8 GetShiftFlags () { - byte flags; + uint8 flags; __asm { mov ah, 2 int 0x16 mov flags, al } return flags; } -byte GetKeyboardChar () +uint8 GetKeyboardChar () { return GetKeyboardChar (nullptr); } /* inline void Sleep () { __asm { mov al, 0 mov ah, 0x86 // Sleep for 250 milliseconds = 250 000 microseconds = 0x0003D090 mov cx, 0x0003 mov dx, 0xD090 int 0x15 } } */ -byte GetKeyboardChar (byte *scanCode) +uint8 GetKeyboardChar (uint8 *scanCode) { // Work around potential BIOS bugs (Windows boot manager polls the keystroke buffer) while (!IsKeyboardCharAvailable()) { // reduce CPU usage by halting CPU until the next external interrupt is fired __asm { hlt } } - byte asciiCode; - byte scan; + uint8 asciiCode; + uint8 scan; __asm { mov ah, 0 int 0x16 mov asciiCode, al mov scan, ah } if (scanCode) *scanCode = scan; return asciiCode; } bool IsKeyboardCharAvailable () { bool available = false; __asm { mov ah, 1 int 0x16 jz not_avail mov available, true not_avail: } return available; } bool EscKeyPressed () { if (IsKeyboardCharAvailable ()) { - byte keyScanCode; + uint8 keyScanCode; GetKeyboardChar (&keyScanCode); return keyScanCode == TC_BIOS_KEY_ESC; } return false; } void ClearBiosKeystrokeBuffer () { __asm { push es xor ax, ax mov es, ax mov di, 0x41e mov cx, 32 cld rep stosb // reset position pointers at 0x41A and 0x41C to the begining // of keyboard buffer to avoid revealing password/PIM length mov ax, 0x001e mov es:[0x41a], ax mov es:[0x41c], ax pop es } } bool IsPrintable (char c) { return c >= ' ' && c <= '~'; } bool IsDigit (char c) { return c >= '0' && c <= '9'; } int GetString (char *buffer, size_t bufferSize) { - byte c; - byte scanCode; + uint8 c; + uint8 scanCode; size_t pos = 0; while (pos < bufferSize) { c = GetKeyboardChar (&scanCode); if (scanCode == TC_BIOS_KEY_ENTER) break; if (scanCode == TC_BIOS_KEY_ESC) return 0; buffer[pos++] = c; PrintChar (IsPrintable (c) ? c : ' '); } return pos; } diff --git a/src/Boot/Windows/BootConsoleIo.h b/src/Boot/Windows/BootConsoleIo.h index 349782eb..cf10d2c6 100644 --- a/src/Boot/Windows/BootConsoleIo.h +++ b/src/Boot/Windows/BootConsoleIo.h @@ -18,55 +18,55 @@ #define TC_DEBUG_PORT 0 #define TC_BIOS_KEY_ESC 1 #define TC_BIOS_KEY_BACKSPACE 14 #define TC_BIOS_KEY_ENTER 28 #define TC_BIOS_KEY_F1 0x3b #define TC_BIOS_KEY_F2 0x3c #define TC_BIOS_KEY_F3 0x3d #define TC_BIOS_KEY_F4 0x3e #define TC_BIOS_KEY_F5 0x3f #define TC_BIOS_KEY_F6 0x40 #define TC_BIOS_KEY_F7 0x41 #define TC_BIOS_KEY_F8 0x42 #define TC_BIOS_KEY_F9 0x43 #define TC_BIOS_KEY_F10 0x44 #define TC_BIOS_SHIFTMASK_CAPSLOCK (1 << 6) #define TC_BIOS_SHIFTMASK_LSHIFT (1 << 1) #define TC_BIOS_SHIFTMASK_RSHIFT (1 << 0) #define TC_BIOS_CHAR_BACKSPACE 8 #define TC_BIOS_MAX_CHARS_PER_LINE 80 void Beep (); void ClearBiosKeystrokeBuffer (); void ClearScreen (); void DisableScreenOutput (); void EnableScreenOutput (); bool EscKeyPressed (); -byte GetKeyboardChar (); -byte GetKeyboardChar (byte *scanCode); -byte GetShiftFlags (); +uint8 GetKeyboardChar (); +uint8 GetKeyboardChar (uint8 *scanCode); +uint8 GetShiftFlags (); int GetString (char *buffer, size_t bufferSize); void InitVideoMode (); bool IsKeyboardCharAvailable (); bool IsPrintable (char c); bool IsDigit (char c); void Print (const char *str); void Print (uint32 number); void Print (const uint64 &number); void PrintBackspace (); void PrintChar (char c); void PrintCharAtCursor (char c); void PrintEndl (); void PrintEndl (int cnt); void PrintRepeatedChar (char c, int n); void PrintError (const char *message); void PrintErrorNoEndl (const char *message); -void PrintHex (byte b); +void PrintHex (uint8 b); void PrintHex (uint16 data); void PrintHex (uint32 data); void PrintHex (const uint64 &data); #endif // TC_HEADER_Boot_BootConsoleIo diff --git a/src/Boot/Windows/BootDebug.cpp b/src/Boot/Windows/BootDebug.cpp index bea063c1..b490f5e8 100644 --- a/src/Boot/Windows/BootDebug.cpp +++ b/src/Boot/Windows/BootDebug.cpp @@ -7,161 +7,161 @@ and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Platform.h" #include "Bios.h" #include "BootConsoleIo.h" #include "BootDefs.h" #include "BootDiskIo.h" #include "BootDebug.h" #ifdef TC_BOOT_TRACING_ENABLED void InitDebugPort () { __asm { mov dx, TC_DEBUG_PORT mov ah, 1 int 0x17 mov dx, TC_DEBUG_PORT mov ah, 0xe2 int 0x17 } } -void WriteDebugPort (byte dataByte) +void WriteDebugPort (uint8 dataByte) { __asm { mov al, dataByte mov dx, TC_DEBUG_PORT mov ah, 0 int 0x17 } } #endif // TC_BOOT_TRACING_ENABLED #ifdef TC_BOOT_DEBUG_ENABLED extern "C" void PrintDebug (uint32 debugVal) { Print (debugVal); PrintEndl(); } void PrintVal (const char *message, const uint32 value, bool newLine, bool hex) { Print (message); Print (": "); if (hex) PrintHex (value); else Print (value); if (newLine) PrintEndl(); } void PrintVal (const char *message, const uint64 &value, bool newLine, bool hex) { Print (message); Print (": "); PrintHex (value); if (newLine) PrintEndl(); } -void PrintHexDump (byte *mem, size_t size, uint16 *memSegment) +void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment) { const size_t width = 16; for (size_t pos = 0; pos < size; ) { for (int pass = 1; pass <= 2; ++pass) { size_t i; for (i = 0; i < width && pos < size; ++i) { - byte dataByte; + uint8 dataByte; if (memSegment) { __asm { push es mov si, ss:memSegment mov es, ss:[si] mov si, ss:mem add si, pos mov al, es:[si] mov dataByte, al pop es } pos++; } else dataByte = mem[pos++]; if (pass == 1) { PrintHex (dataByte); PrintChar (' '); } else PrintChar (IsPrintable (dataByte) ? dataByte : '.'); } if (pass == 1) { pos -= i; PrintChar (' '); } } PrintEndl (); } } void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size) { - PrintHexDump ((byte *) memOffset, size, &memSegment); + PrintHexDump ((uint8 *) memOffset, size, &memSegment); } #endif // TC_BOOT_DEBUG_ENABLED #ifdef TC_BOOT_STACK_CHECKING_ENABLED extern "C" char end[]; static void PrintStackInfo () { uint16 spReg; __asm mov spReg, sp Print ("Stack: "); Print (TC_BOOT_LOADER_STACK_TOP - spReg); Print ("/"); Print (TC_BOOT_LOADER_STACK_TOP - (uint16) end); } void CheckStack () { uint16 spReg; __asm mov spReg, sp if (*(uint32 *) end != 0x12345678UL || spReg < (uint16) end) { __asm cli __asm mov sp, TC_BOOT_LOADER_STACK_TOP PrintError ("Stack overflow"); diff --git a/src/Boot/Windows/BootDebug.h b/src/Boot/Windows/BootDebug.h index f94ab900..35fce41f 100644 --- a/src/Boot/Windows/BootDebug.h +++ b/src/Boot/Windows/BootDebug.h @@ -24,37 +24,37 @@ # define TC_BOOT_STACK_CHECKING_ENABLED extern "C" void CheckStack (); #else # define CheckStack() #endif #if 0 # define TC_BOOT_TRACING_ENABLED # if 1 # define TC_TRACE_INT13 # endif # if 0 # define TC_TRACE_INT15 # endif #endif #ifdef TC_BOOT_DEBUG_ENABLED # define trace_point do { Print(__FILE__); PrintChar (':'); Print (TC_TO_STRING (__LINE__)); PrintEndl(); } while (false) # define trace_val(VAL) PrintVal (#VAL, VAL); # define trace_hex(VAL) do { Print (#VAL), PrintChar (':'); PrintHex (VAL); PrintEndl(); } while (false) # define assert(COND) do { if (!(COND)) { trace_point; __asm jmp $ } } while (false) #else # define trace_point # define trace_val(VAL) # define trace_hex(VAL) # define assert(COND) #endif void InitDebugPort (); void InitStackChecker (); -void WriteDebugPort (byte dataByte); -void PrintHexDump (byte *mem, size_t size, uint16 *memSegment = nullptr); +void WriteDebugPort (uint8 dataByte); +void PrintHexDump (uint8 *mem, size_t size, uint16 *memSegment = nullptr); void PrintHexDump (uint16 memSegment, uint16 memOffset, size_t size); void PrintVal (const char *message, const uint32 value, bool newLine = true, bool hex = false); void PrintVal (const char *message, const uint64 &value, bool newLine = true, bool hex = false); #endif // TC_HEADER_Boot_BootDebug diff --git a/src/Boot/Windows/BootDiskIo.cpp b/src/Boot/Windows/BootDiskIo.cpp index 437c462e..ddd00e1c 100644 --- a/src/Boot/Windows/BootDiskIo.cpp +++ b/src/Boot/Windows/BootDiskIo.cpp @@ -1,493 +1,493 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Bios.h" #include "BootConsoleIo.h" #include "BootConfig.h" #include "BootDebug.h" #include "BootDefs.h" #include "BootDiskIo.h" #include "BootStrings.h" -byte SectorBuffer[TC_LB_SIZE]; +uint8 SectorBuffer[TC_LB_SIZE]; #ifdef TC_BOOT_DEBUG_ENABLED static bool SectorBufferInUse = false; void AcquireSectorBuffer () { if (SectorBufferInUse) TC_THROW_FATAL_EXCEPTION; SectorBufferInUse = true; } void ReleaseSectorBuffer () { SectorBufferInUse = false; } #endif -bool IsLbaSupported (byte drive) +bool IsLbaSupported (uint8 drive) { - static byte CachedDrive = TC_INVALID_BIOS_DRIVE; + static uint8 CachedDrive = TC_INVALID_BIOS_DRIVE; static bool CachedStatus; uint16 result = 0; if (CachedDrive == drive) goto ret; __asm { mov bx, 0x55aa mov dl, drive mov ah, 0x41 int 0x13 jc err mov result, bx err: } CachedDrive = drive; CachedStatus = (result == 0xaa55); ret: return CachedStatus; } -void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs) +void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs) { PrintEndl(); Print (write ? "Write" : "Read"); Print (" error:"); Print (error); Print (" Drive:"); Print (drive ^ 0x80); if (sector) { Print (" Sector:"); Print (*sector); } if (chs) { Print (" CHS:"); Print (*chs); } PrintEndl(); Beep(); } void Print (const ChsAddress &chs) { Print (chs.Cylinder); PrintChar ('/'); Print (chs.Head); PrintChar ('/'); Print (chs.Sector); } void PrintSectorCountInMB (const uint64 §orCount) { Print (sectorCount >> (TC_LB_SIZE_BIT_SHIFT_DIVISOR + 2)); Print (" MiB "); } -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { CheckStack(); - byte cylinderLow = (byte) chs.Cylinder; - byte sector = chs.Sector; - sector |= byte (chs.Cylinder >> 2) & 0xc0; - byte function = write ? 0x03 : 0x02; + uint8 cylinderLow = (uint8) chs.Cylinder; + uint8 sector = chs.Sector; + sector |= uint8 (chs.Cylinder >> 2) & 0xc0; + uint8 function = write ? 0x03 : 0x02; BiosResult result; - byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; + uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; do { result = BiosResultSuccess; __asm { push es mov ax, bufferSegment mov es, ax mov bx, bufferOffset mov dl, drive mov ch, cylinderLow mov si, chs mov dh, [si].Head mov cl, sector mov al, sectorCount mov ah, function int 0x13 jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes mov result, ah ok: pop es } if (result == BiosResultEccCorrected) result = BiosResultSuccess; // Some BIOSes report I/O errors prematurely in some cases } while (result != BiosResultSuccess && --tryCount != 0); if (!silent && result != BiosResultSuccess) PrintDiskError (result, write, drive, nullptr, &chs); return result; } #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE -BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { uint16 codeSeg; __asm mov codeSeg, cs return ReadWriteSectors (write, codeSeg, (uint16) buffer, drive, chs, sectorCount, silent); } -BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { return ReadWriteSectors (false, buffer, drive, chs, sectorCount, silent); } #if 0 -BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent) +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent) { return ReadWriteSectors (true, buffer, drive, chs, sectorCount, silent); } #endif #endif -static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +static BiosResult ReadWriteSectors (bool write, BiosLbaPacket &dapPacket, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { CheckStack(); if (!IsLbaSupported (drive)) { DriveGeometry geometry; BiosResult result = GetDriveGeometry (drive, geometry, silent); if (result != BiosResultSuccess) return result; ChsAddress chs; LbaToChs (geometry, sector, chs); return ReadWriteSectors (write, (uint16) (dapPacket.Buffer >> 16), (uint16) dapPacket.Buffer, drive, chs, sectorCount, silent); } dapPacket.Size = sizeof (dapPacket); dapPacket.Reserved = 0; dapPacket.SectorCount = sectorCount; dapPacket.Sector = sector; - byte function = write ? 0x43 : 0x42; + uint8 function = write ? 0x43 : 0x42; BiosResult result; - byte tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; + uint8 tryCount = TC_MAX_BIOS_DISK_IO_RETRIES; do { result = BiosResultSuccess; __asm { mov bx, 0x55aa mov dl, drive mov si, [dapPacket] mov ah, function xor al, al int 0x13 jnc ok // If CF=0, ignore AH to prevent issues caused by potential bugs in BIOSes mov result, ah ok: } if (result == BiosResultEccCorrected) result = BiosResultSuccess; // Some BIOSes report I/O errors prematurely in some cases } while (result != BiosResultSuccess && --tryCount != 0); if (!silent && result != BiosResultSuccess) PrintDiskError (result, write, drive, §or); return result; } -BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosLbaPacket dapPacket; dapPacket.Buffer = (uint32) buffer; return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent); } -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosLbaPacket dapPacket; dapPacket.Buffer = ((uint32) bufferSegment << 16) | bufferOffset; return ReadWriteSectors (write, dapPacket, drive, sector, sectorCount, silent); } -BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { return ReadWriteSectors (false, bufferSegment, bufferOffset, drive, sector, sectorCount, silent); } -BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { BiosResult result; uint16 codeSeg; __asm mov codeSeg, cs result = ReadSectors (BootStarted ? codeSeg : TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, drive, sector, sectorCount, silent); // Alternative segment is used to prevent memory corruption caused by buggy BIOSes if (!BootStarted) CopyMemory (TC_BOOT_LOADER_ALT_SEGMENT, (uint16) buffer, buffer, sectorCount * TC_LB_SIZE); return result; } -BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent) +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent) { return ReadWriteSectors (true, buffer, drive, sector, sectorCount, silent); } -BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent) +BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent) { CheckStack(); - byte maxCylinderLow, maxHead, maxSector; + uint8 maxCylinderLow, maxHead, maxSector; BiosResult result; __asm { push es mov dl, drive mov ah, 0x08 int 0x13 mov result, ah mov maxCylinderLow, ch mov maxSector, cl mov maxHead, dh pop es } if (result == BiosResultSuccess) { geometry.Cylinders = (maxCylinderLow | (uint16 (maxSector & 0xc0) << 2)) + 1; geometry.Heads = maxHead + 1; geometry.Sectors = maxSector & ~0xc0; } else if (!silent) { Print ("Drive "); Print (drive ^ 0x80); Print (" not found: "); PrintErrorNoEndl (""); Print (result); PrintEndl(); } return result; } void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba) { lba.HighPart = 0; lba.LowPart = (uint32 (chs.Cylinder) * geometry.Heads + chs.Head) * geometry.Sectors + chs.Sector - 1; } void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs) { - chs.Sector = (byte) ((lba.LowPart % geometry.Sectors) + 1); + chs.Sector = (uint8) ((lba.LowPart % geometry.Sectors) + 1); uint32 ch = lba.LowPart / geometry.Sectors; - chs.Head = (byte) (ch % geometry.Heads); + chs.Head = (uint8) (ch % geometry.Heads); chs.Cylinder = (uint16) (ch / geometry.Heads); } void PartitionEntryMBRToPartition (const PartitionEntryMBR &partEntry, Partition &partition) { partition.Active = partEntry.BootIndicator == 0x80; partition.EndSector.HighPart = 0; partition.EndSector.LowPart = partEntry.StartLBA + partEntry.SectorCountLBA - 1; partition.SectorCount.HighPart = 0; partition.SectorCount.LowPart = partEntry.SectorCountLBA; partition.StartSector.HighPart = 0; partition.StartSector.LowPart = partEntry.StartLBA; partition.Type = partEntry.Type; } -BiosResult ReadWriteMBR (bool write, byte drive, bool silent) +BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent) { uint64 mbrSector; mbrSector.HighPart = 0; mbrSector.LowPart = 0; if (write) return WriteSectors (SectorBuffer, drive, mbrSector, 1, silent); return ReadSectors (SectorBuffer, drive, mbrSector, 1, silent); // Uses alternative segment } -BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent) +BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly, Partition *findPartitionFollowingThis, bool silent) { Partition *followingPartition; Partition tmpPartition; if (findPartitionFollowingThis) { assert (partitionArrayCapacity == 1); partitionArrayCapacity = 0xff; followingPartition = partitionArray; partitionArray = &tmpPartition; followingPartition->Drive = TC_INVALID_BIOS_DRIVE; followingPartition->StartSector.LowPart = 0xFFFFffffUL; } AcquireSectorBuffer(); BiosResult result = ReadWriteMBR (false, drive, silent); ReleaseSectorBuffer(); partitionCount = 0; MBR *mbr = (MBR *) SectorBuffer; if (result != BiosResultSuccess || mbr->Signature != 0xaa55) return result; PartitionEntryMBR mbrPartitions[4]; memcpy (mbrPartitions, mbr->Partitions, sizeof (mbrPartitions)); size_t partitionArrayPos = 0, partitionNumber; for (partitionNumber = 0; partitionNumber < array_capacity (mbrPartitions) && partitionArrayPos < partitionArrayCapacity; ++partitionNumber) { const PartitionEntryMBR &partEntry = mbrPartitions[partitionNumber]; if (partEntry.SectorCountLBA > 0) { Partition &partition = partitionArray[partitionArrayPos]; PartitionEntryMBRToPartition (partEntry, partition); if (activeOnly && !partition.Active) continue; partition.Drive = drive; partition.Number = partitionArrayPos; if (partEntry.Type == 0x5 || partEntry.Type == 0xf) // Extended partition { if (IsLbaSupported (drive)) { // Find all extended partitions uint64 firstExtStartLBA = partition.StartSector; uint64 extStartLBA = partition.StartSector; MBR *extMbr = (MBR *) SectorBuffer; while (partitionArrayPos < partitionArrayCapacity && - (result = ReadSectors ((byte *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess + (result = ReadSectors ((uint8 *) extMbr, drive, extStartLBA, 1, silent)) == BiosResultSuccess && extMbr->Signature == 0xaa55) { if (extMbr->Partitions[0].SectorCountLBA > 0) { Partition &logPart = partitionArray[partitionArrayPos]; PartitionEntryMBRToPartition (extMbr->Partitions[0], logPart); logPart.Drive = drive; logPart.Number = partitionArrayPos; logPart.Primary = false; logPart.StartSector.LowPart += extStartLBA.LowPart; logPart.EndSector.LowPart += extStartLBA.LowPart; if (findPartitionFollowingThis) { if (logPart.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart && logPart.StartSector.LowPart < followingPartition->StartSector.LowPart) { *followingPartition = logPart; } } else ++partitionArrayPos; } // Secondary extended if (extMbr->Partitions[1].Type != 0x5 && extMbr->Partitions[1].Type == 0xf || extMbr->Partitions[1].SectorCountLBA == 0) break; extStartLBA.LowPart = extMbr->Partitions[1].StartLBA + firstExtStartLBA.LowPart; } } } else { partition.Primary = true; if (findPartitionFollowingThis) { if (partition.StartSector.LowPart > findPartitionFollowingThis->EndSector.LowPart && partition.StartSector.LowPart < followingPartition->StartSector.LowPart) { *followingPartition = partition; } } else ++partitionArrayPos; } } } partitionCount = partitionArrayPos; return result; } -bool GetActivePartition (byte drive) +bool GetActivePartition (uint8 drive) { size_t partCount; if (GetDrivePartitions (drive, &ActivePartition, 1, partCount, true) != BiosResultSuccess || partCount < 1) { ActivePartition.Drive = TC_INVALID_BIOS_DRIVE; PrintError (TC_BOOT_STR_NO_BOOT_PARTITION); return false; } return true; } diff --git a/src/Boot/Windows/BootDiskIo.h b/src/Boot/Windows/BootDiskIo.h index 621acd8f..0b92aa29 100644 --- a/src/Boot/Windows/BootDiskIo.h +++ b/src/Boot/Windows/BootDiskIo.h @@ -1,121 +1,121 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Boot_BootDiskIo #define TC_HEADER_Boot_BootDiskIo #include "Bios.h" #include "BootDebug.h" #include "BootDefs.h" #define TC_MAX_BIOS_DISK_IO_RETRIES 5 enum { BiosResultEccCorrected = 0x11 }; #pragma pack(1) struct PartitionEntryMBR { - byte BootIndicator; + uint8 BootIndicator; - byte StartHead; - byte StartCylSector; - byte StartCylinder; + uint8 StartHead; + uint8 StartCylSector; + uint8 StartCylinder; - byte Type; + uint8 Type; - byte EndHead; - byte EndSector; - byte EndCylinder; + uint8 EndHead; + uint8 EndSector; + uint8 EndCylinder; uint32 StartLBA; uint32 SectorCountLBA; }; struct MBR { - byte Code[446]; + uint8 Code[446]; PartitionEntryMBR Partitions[4]; uint16 Signature; }; struct BiosLbaPacket { - byte Size; - byte Reserved; + uint8 Size; + uint8 Reserved; uint16 SectorCount; uint32 Buffer; uint64 Sector; }; #pragma pack() struct ChsAddress { uint16 Cylinder; - byte Head; - byte Sector; + uint8 Head; + uint8 Sector; }; struct Partition { - byte Number; - byte Drive; + uint8 Number; + uint8 Drive; bool Active; uint64 EndSector; bool Primary; uint64 SectorCount; uint64 StartSector; - byte Type; + uint8 Type; }; struct DriveGeometry { uint16 Cylinders; - byte Heads; - byte Sectors; + uint8 Heads; + uint8 Sectors; }; #ifdef TC_BOOT_DEBUG_ENABLED void AcquireSectorBuffer (); void ReleaseSectorBuffer (); #else # define AcquireSectorBuffer() # define ReleaseSectorBuffer() #endif void ChsToLba (const DriveGeometry &geometry, const ChsAddress &chs, uint64 &lba); -bool GetActivePartition (byte drive); -BiosResult GetDriveGeometry (byte drive, DriveGeometry &geometry, bool silent = false); -BiosResult GetDrivePartitions (byte drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); -bool IsLbaSupported (byte drive); +bool GetActivePartition (uint8 drive); +BiosResult GetDriveGeometry (uint8 drive, DriveGeometry &geometry, bool silent = false); +BiosResult GetDrivePartitions (uint8 drive, Partition *partitionArray, size_t partitionArrayCapacity, size_t &partitionCount, bool activeOnly = false, Partition *findPartitionFollowingThis = nullptr, bool silent = false); +bool IsLbaSupported (uint8 drive); void LbaToChs (const DriveGeometry &geometry, const uint64 &lba, ChsAddress &chs); void Print (const ChsAddress &chs); -void PrintDiskError (BiosResult error, bool write, byte drive, const uint64 *sector, const ChsAddress *chs = nullptr); +void PrintDiskError (BiosResult error, bool write, uint8 drive, const uint64 *sector, const ChsAddress *chs = nullptr); void PrintSectorCountInMB (const uint64 §orCount); -BiosResult ReadWriteMBR (bool write, byte drive, bool silent = false); -BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult ReadSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult ReadSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); -BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, byte drive, const uint64 §or, uint16 sectorCount, bool silent); -BiosResult ReadWriteSectors (bool write, byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent); -BiosResult WriteSectors (byte *buffer, byte drive, const uint64 §or, uint16 sectorCount, bool silent = false); -BiosResult WriteSectors (byte *buffer, byte drive, const ChsAddress &chs, byte sectorCount, bool silent = false); - -extern byte SectorBuffer[TC_LB_SIZE]; +BiosResult ReadWriteMBR (bool write, uint8 drive, bool silent = false); +BiosResult ReadSectors (uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult ReadSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false); +BiosResult ReadWriteSectors (bool write, uint16 bufferSegment, uint16 bufferOffset, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent); +BiosResult ReadWriteSectors (bool write, uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent); +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const uint64 §or, uint16 sectorCount, bool silent = false); +BiosResult WriteSectors (uint8 *buffer, uint8 drive, const ChsAddress &chs, uint8 sectorCount, bool silent = false); + +extern uint8 SectorBuffer[TC_LB_SIZE]; #endif // TC_HEADER_Boot_BootDiskIo diff --git a/src/Boot/Windows/BootEncryptedIo.cpp b/src/Boot/Windows/BootEncryptedIo.cpp index 8ca55635..24fbbbd0 100644 --- a/src/Boot/Windows/BootEncryptedIo.cpp +++ b/src/Boot/Windows/BootEncryptedIo.cpp @@ -1,109 +1,109 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Crypto.h" #include "Platform.h" #include "BootConfig.h" #include "BootDebug.h" #include "BootDefs.h" #include "BootDiskIo.h" #include "BootEncryptedIo.h" -BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result; bool decrypt = true; if (BootCryptoInfo->hiddenVolume) { if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount)) return BiosResultInvalidFunction; if (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector) { // Remap the request to the hidden volume sector -= EncryptedVirtualPartition.StartSector; sector += HiddenVolumeStartSector; } else decrypt = false; } result = ReadSectors (destSegment, destOffset, drive, sector, sectorCount); if (result != BiosResultSuccess || !decrypt) return result; if (BootCryptoInfo->hiddenVolume) { // Convert sector number to data unit number of the hidden volume sector -= HiddenVolumeStartSector; sector += PimValueOrHiddenVolumeStartUnitNo; } if (drive == EncryptedVirtualPartition.Drive) { while (sectorCount-- > 0) { if (BootCryptoInfo->hiddenVolume || (sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector)) { AcquireSectorBuffer(); CopyMemory (destSegment, destOffset, SectorBuffer, TC_LB_SIZE); DecryptDataUnits (SectorBuffer, §or, 1, BootCryptoInfo); CopyMemory (SectorBuffer, destSegment, destOffset, TC_LB_SIZE); ReleaseSectorBuffer(); } ++sector; destOffset += TC_LB_SIZE; } } return result; } -BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount) +BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount) { BiosResult result = BiosResultSuccess; AcquireSectorBuffer(); uint64 dataUnitNo; uint64 writeOffset; dataUnitNo = sector; writeOffset.HighPart = 0; writeOffset.LowPart = 0; if (BootCryptoInfo->hiddenVolume) { if (ReadWritePartiallyCoversEncryptedArea (sector, sectorCount)) return BiosResultInvalidFunction; // Remap the request to the hidden volume writeOffset = HiddenVolumeStartSector; writeOffset -= EncryptedVirtualPartition.StartSector; dataUnitNo -= EncryptedVirtualPartition.StartSector; dataUnitNo += PimValueOrHiddenVolumeStartUnitNo; } while (sectorCount-- > 0) { CopyMemory (sourceSegment, sourceOffset, SectorBuffer, TC_LB_SIZE); if (drive == EncryptedVirtualPartition.Drive && sector >= EncryptedVirtualPartition.StartSector && sector <= EncryptedVirtualPartition.EndSector) { EncryptDataUnits (SectorBuffer, &dataUnitNo, 1, BootCryptoInfo); } diff --git a/src/Boot/Windows/BootEncryptedIo.h b/src/Boot/Windows/BootEncryptedIo.h index d1c9e5f3..d2fa6d96 100644 --- a/src/Boot/Windows/BootEncryptedIo.h +++ b/src/Boot/Windows/BootEncryptedIo.h @@ -1,22 +1,22 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Boot_BootEncryptionIo #define TC_HEADER_Boot_BootEncryptionIo #include "Platform.h" -BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, byte drive, uint64 sector, uint16 sectorCount); -BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, byte drive, uint64 sector, uint16 sectorCount); +BiosResult ReadEncryptedSectors (uint16 destSegment, uint16 destOffset, uint8 drive, uint64 sector, uint16 sectorCount); +BiosResult WriteEncryptedSectors (uint16 sourceSegment, uint16 sourceOffset, uint8 drive, uint64 sector, uint16 sectorCount); static bool ReadWritePartiallyCoversEncryptedArea (const uint64 §or, uint16 sectorCount); #endif // TC_HEADER_Boot_BootEncryptionIo diff --git a/src/Boot/Windows/BootMain.cpp b/src/Boot/Windows/BootMain.cpp index 8bfbe4b3..e85f2be5 100644 --- a/src/Boot/Windows/BootMain.cpp +++ b/src/Boot/Windows/BootMain.cpp @@ -57,61 +57,61 @@ static void InitScreen () PrintEndl (2); } static void PrintMainMenu () { if (PreventBootMenu) return; Print (" Keyboard Controls:\r\n"); Print (" [F5] Hide/Show Password and PIM\r\n"); Print (" [Esc] "); #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE Print ((BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) != TC_HIDDEN_OS_CREATION_PHASE_NONE ? "Boot Non-Hidden System (Boot Manager)" : "Skip Authentication (Boot Manager)"); #else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE Print ("Skip Authentication (Boot Manager)"); Print ("\r\n [F8] "); Print ("Repair Options"); #endif // TC_WINDOWS_BOOT_RESCUE_DISK_MODE PrintEndl (3); } -static bool IsMenuKey (byte scanCode) +static bool IsMenuKey (uint8 scanCode) { #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE return scanCode == TC_MENU_KEY_REPAIR; #else return false; #endif } static bool AskYesNo (const char *message) { Print (message); Print ("? (y/n): "); while (true) { switch (GetKeyboardChar()) { case 'y': case 'Y': case 'z': case 'Z': Print ("y\r\n"); return true; case 'n': case 'N': Print ("n\r\n"); return false; default: @@ -122,66 +122,66 @@ static bool AskYesNo (const char *message) static int AskSelection (const char *options[], size_t optionCount) { for (int i = 0; i < optionCount; ++i) { Print ("["); Print (i + 1); Print ("] "); Print (options[i]); PrintEndl(); } Print ("[Esc] Cancel\r\n\r\n"); Print ("To select, press 1-9: "); char str; while (true) { if (GetString (&str, 1) == 0) return 0; if (str >= '1' && str <= optionCount + '0') return str - '0'; Beep(); PrintBackspace(); } } -static byte AskPassword (Password &password, int& pim) +static uint8 AskPassword (Password &password, int& pim) { size_t pos = 0; - byte scanCode; - byte asciiCode; - byte hidePassword = 1; + uint8 scanCode; + uint8 asciiCode; + uint8 hidePassword = 1; pim = 0; Print ("Enter password"); Print (PreventNormalSystemBoot ? " for hidden system:\r\n" : ": "); while (true) { asciiCode = GetKeyboardChar (&scanCode); switch (scanCode) { case TC_BIOS_KEY_ENTER: password.Length = pos; Print ("\r"); if (!PreventNormalSystemBoot) Print ("Enter password: "); pos = 0; while (pos < MAX_PASSWORD) { pos++; if (pos < MAX_PASSWORD) PrintChar ('*'); else PrintCharAtCursor ('*'); } ClearBiosKeystrokeBuffer(); PrintEndl(); @@ -285,87 +285,87 @@ static byte AskPassword (Password &password, int& pim) default: if (scanCode == TC_BIOS_KEY_ESC || IsMenuKey (scanCode)) { burn (password.Text, sizeof (password.Text)); ClearBiosKeystrokeBuffer(); PrintEndl(); return scanCode; } } if (!IsDigit (asciiCode) || pos == MAX_PIM) { Beep(); continue; } pim = 10*pim + (asciiCode - '0'); pos++; if (hidePassword) asciiCode = '*'; if (pos < MAX_PIM) PrintChar (asciiCode); else PrintCharAtCursor (asciiCode); } } } -static void ExecuteBootSector (byte drive, byte *sectorBuffer) +static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer) { Print ("Booting...\r\n"); CopyMemory (sectorBuffer, 0x0000, 0x7c00, TC_LB_SIZE); BootStarted = true; uint32 addr = 0x7c00; __asm { cli mov dl, drive // Boot drive mov dh, 0 xor ax, ax mov si, ax mov ds, ax mov es, ax mov ss, ax mov sp, 0x7c00 sti jmp cs:addr } } -static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden) +static bool OpenVolume (uint8 drive, Password &password, int pim, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32, bool skipNormal, bool skipHidden) { int volumeType; bool hiddenVolume; uint64 headerSec; AcquireSectorBuffer(); for (volumeType = 1; volumeType <= 2; ++volumeType) { hiddenVolume = (volumeType == 2); if (hiddenVolume) { if (skipHidden || PartitionFollowingActive.Drive != drive || PartitionFollowingActive.SectorCount <= ActivePartition.SectorCount) continue; headerSec = PartitionFollowingActive.StartSector + TC_HIDDEN_VOLUME_HEADER_OFFSET / TC_LB_SIZE; } else { if (skipNormal) continue; headerSec.HighPart = 0; headerSec.LowPart = TC_BOOT_VOLUME_HEADER_SECTOR; } if (ReadSectors (SectorBuffer, drive, headerSec, 1) != BiosResultSuccess) continue; @@ -393,61 +393,61 @@ static bool OpenVolume (byte drive, Password &password, int pim, CRYPTO_INFO **c static bool CheckMemoryRequirements () { uint16 codeSeg; __asm mov codeSeg, cs if (codeSeg == TC_BOOT_LOADER_LOWMEM_SEGMENT) { PrintErrorNoEndl ("BIOS reserved too much memory: "); uint16 memFree; __asm { push es xor ax, ax mov es, ax mov ax, es:[0x413] mov memFree, ax pop es } Print (memFree); PrintEndl(); Print (TC_BOOT_STR_UPGRADE_BIOS); return false; } return true; } -static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHidden) +static bool MountVolume (uint8 drive, uint8 &exitKey, bool skipNormal, bool skipHidden) { BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; int incorrectPasswordCount = 0, pim = 0; EraseMemory (bootArguments, sizeof (*bootArguments)); // Open volume header while (true) { exitKey = AskPassword (bootArguments->BootPassword, pim); if (exitKey != TC_BIOS_KEY_ENTER) return false; Print ("Verifying password..."); if (OpenVolume (BootDrive, bootArguments->BootPassword, pim, &BootCryptoInfo, &bootArguments->HeaderSaltCrc32, skipNormal, skipHidden)) { Print ("OK\r\n"); break; } if (GetShiftFlags() & TC_BIOS_SHIFTMASK_CAPSLOCK) Print ("Warning: Caps Lock is on.\r\n"); Print ("Incorrect password.\r\n\r\n"); if (++incorrectPasswordCount == 4) { #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE Print ("If you are sure the password is correct, the key data may be damaged.\r\n" @@ -472,163 +472,163 @@ static bool MountVolume (byte drive, byte &exitKey, bool skipNormal, bool skipHi bootArguments->Flags |= TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION; TC_SET_BOOT_ARGUMENTS_SIGNATURE (bootArguments->Signature); // Setup virtual encrypted partition if (BootCryptoInfo->EncryptedAreaLength.HighPart != 0 || BootCryptoInfo->EncryptedAreaLength.LowPart != 0) { EncryptedVirtualPartition.Drive = BootDrive; EncryptedVirtualPartition.StartSector = BootCryptoInfo->EncryptedAreaStart >> TC_LB_SIZE_BIT_SHIFT_DIVISOR; PimValueOrHiddenVolumeStartUnitNo = EncryptedVirtualPartition.StartSector; HiddenVolumeStartSector = PartitionFollowingActive.StartSector; HiddenVolumeStartSector += EncryptedVirtualPartition.StartSector; EncryptedVirtualPartition.SectorCount = BootCryptoInfo->EncryptedAreaLength >> TC_LB_SIZE_BIT_SHIFT_DIVISOR; EncryptedVirtualPartition.EndSector = EncryptedVirtualPartition.SectorCount - 1; EncryptedVirtualPartition.EndSector += EncryptedVirtualPartition.StartSector; } else { // Drive not encrypted EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE; } return true; } -static bool GetSystemPartitions (byte drive) +static bool GetSystemPartitions (uint8 drive) { size_t partCount; if (!GetActivePartition (drive)) return false; // Find partition following the active one GetDrivePartitions (drive, &PartitionFollowingActive, 1, partCount, false, &ActivePartition); // If there is an extra boot partition, use the partitions following it. // The real boot partition is determined in BootEncryptedDrive(). if (ActivePartition.SectorCount.HighPart == 0 && ActivePartition.SectorCount.LowPart <= TC_MAX_EXTRA_BOOT_PARTITION_SIZE / TC_LB_SIZE && PartitionFollowingActive.Drive != TC_INVALID_BIOS_DRIVE) { ExtraBootPartitionPresent = true; ActivePartition = PartitionFollowingActive; GetDrivePartitions (drive, &PartitionFollowingActive, 1, partCount, false, &ActivePartition); } return true; } -static byte BootEncryptedDrive () +static uint8 BootEncryptedDrive () { BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; - byte exitKey; + uint8 exitKey; BootCryptoInfo = NULL; if (!GetSystemPartitions (BootDrive)) goto err; if (!MountVolume (BootDrive, exitKey, PreventNormalSystemBoot, false)) return exitKey; if (!CheckMemoryRequirements ()) goto err; if (BootCryptoInfo->hiddenVolume) { EncryptedVirtualPartition = ActivePartition; bootArguments->DecoySystemPartitionStart = ActivePartition.StartSector << TC_LB_SIZE_BIT_SHIFT_DIVISOR; } if (ExtraBootPartitionPresent && !GetActivePartition (BootDrive)) goto err; if (ReadWriteMBR (false, ActivePartition.Drive) != BiosResultSuccess) goto err; bootArguments->BootDriveSignature = *(uint32 *) (SectorBuffer + 0x1b8); if (!InstallInterruptFilters()) goto err; - bootArguments->BootArgumentsCrc32 = GetCrc32 ((byte *) bootArguments, (byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments); + bootArguments->BootArgumentsCrc32 = GetCrc32 ((uint8 *) bootArguments, (uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments); while (true) { // Execute boot sector of the active partition if (ReadSectors (SectorBuffer, ActivePartition.Drive, ActivePartition.StartSector, 1) == BiosResultSuccess) { if (*(uint16 *) (SectorBuffer + 510) != 0xaa55) { PrintError (TC_BOOT_STR_NO_BOOT_PARTITION); GetKeyboardChar(); } ExecuteBootSector (ActivePartition.Drive, SectorBuffer); } GetKeyboardChar(); } err: if (BootCryptoInfo) { crypto_close (BootCryptoInfo); BootCryptoInfo = NULL; } #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE PimValueOrHiddenVolumeStartUnitNo.LowPart = -1; #endif EncryptedVirtualPartition.Drive = TC_INVALID_BIOS_DRIVE; EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments)); - byte scanCode; + uint8 scanCode; GetKeyboardChar (&scanCode); return scanCode; } static void BootMenu () { BiosResult result; Partition partitions[16]; Partition bootablePartitions[9]; size_t partitionCount; size_t bootablePartitionCount = 0; - for (byte drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive) + for (uint8 drive = TC_FIRST_BIOS_DRIVE; drive <= TC_LAST_BIOS_DRIVE; ++drive) { if (GetDrivePartitions (drive, partitions, array_capacity (partitions), partitionCount, false, nullptr, true) == BiosResultSuccess) { for (size_t i = 0; i < partitionCount; ++i) { const Partition &partition = partitions[i]; result = ReadSectors (SectorBuffer, drive, partition.StartSector, 1); if (result == BiosResultSuccess && *(uint16 *) (SectorBuffer + TC_LB_SIZE - 2) == 0xaa55) { // Windows writes boot loader on all NTFS/FAT filesytems it creates and, therefore, // NTFS/FAT partitions must have the boot indicator set to be considered bootable. if (!partition.Active && (*(uint32 *) (SectorBuffer + 3) == 0x5346544e // 'NTFS' || *(uint32 *) (SectorBuffer + 3) == 0x41465845 && SectorBuffer[7] == 'T' // 'exFAT' || *(uint16 *) (SectorBuffer + 54) == 0x4146 && SectorBuffer[56] == 'T' // 'FAT' || *(uint16 *) (SectorBuffer + 82) == 0x4146 && SectorBuffer[84] == 'T')) { continue; } // Bootable sector found if (bootablePartitionCount < array_capacity (bootablePartitions)) bootablePartitions[bootablePartitionCount++] = partition; } } } } if (bootablePartitionCount < 1) @@ -662,61 +662,61 @@ static void BootMenu () } else { Print ("[Esc] Cancel\r\n\r\n"); Print ("Press 1-9 to select partition: "); if (GetString (&partChar, 1) == 0) return; PrintEndl(); if (partChar < '1' || partChar > '0' + bootablePartitionCount) { Beep(); continue; } } const Partition &partition = bootablePartitions[partChar - '0' - 1]; if (ReadSectors (SectorBuffer, partition.Drive, partition.StartSector, 1) == BiosResultSuccess) { ExecuteBootSector (partition.Drive, SectorBuffer); } } } #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE -static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey) +static bool CopySystemPartitionToHiddenVolume (uint8 drive, uint8 &exitKey) { bool status = false; uint64 sectorsRemaining; uint64 sectorOffset; sectorOffset.LowPart = 0; sectorOffset.HighPart = 0; int fragmentSectorCount = 0x7f; // Maximum safe value supported by BIOS int statCount = 0; if (!CheckMemoryRequirements ()) goto err; if (!GetSystemPartitions (drive)) goto err; if (PartitionFollowingActive.Drive == TC_INVALID_BIOS_DRIVE) TC_THROW_FATAL_EXCEPTION; // Check if BIOS can read the last sector of the hidden system AcquireSectorBuffer(); if (ReadSectors (SectorBuffer, PartitionFollowingActive.Drive, PartitionFollowingActive.EndSector - (TC_VOLUME_HEADER_GROUP_SIZE / TC_LB_SIZE - 2), 1) != BiosResultSuccess || GetCrc32 (SectorBuffer, sizeof (SectorBuffer)) != OuterVolumeBackupHeaderCrc) { PrintErrorNoEndl ("Your BIOS does not support large drives"); Print (IsLbaSupported (PartitionFollowingActive.Drive) ? " due to a bug" : "\r\n- Enable LBA in BIOS"); PrintEndl(); Print (TC_BOOT_STR_UPGRADE_BIOS); @@ -785,63 +785,63 @@ static bool CopySystemPartitionToHiddenVolume (byte drive, byte &exitKey) Print ("\rRemaining: "); PrintSectorCountInMB (sectorsRemaining); } } crypto_close (BootCryptoInfo); if (sectorsRemaining.HighPart == 0 && sectorsRemaining.LowPart == 0) { status = true; Print ("\rCopying completed."); } PrintEndl (2); goto ret; err: exitKey = TC_BIOS_KEY_ESC; GetKeyboardChar(); ret: PimValueOrHiddenVolumeStartUnitNo.LowPart = -1; EraseMemory ((void *) TC_BOOT_LOADER_ARGS_OFFSET, sizeof (BootArguments)); return status; } #else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE -static void DecryptDrive (byte drive) +static void DecryptDrive (uint8 drive) { - byte exitKey; + uint8 exitKey; if (!MountVolume (drive, exitKey, false, true)) return; BootArguments *bootArguments = (BootArguments *) TC_BOOT_LOADER_ARGS_OFFSET; bool headerUpdateRequired = false; uint64 sectorsRemaining = EncryptedVirtualPartition.EndSector + 1 - EncryptedVirtualPartition.StartSector; uint64 sector = EncryptedVirtualPartition.EndSector + 1; int fragmentSectorCount = 0x7f; // Maximum safe value supported by BIOS int statCount = 0; bool skipBadSectors = false; Print ("\r\nUse only if Windows cannot start. Decryption under Windows is much faster\r\n" "(in VeraCrypt, select 'System' > 'Permanently Decrypt').\r\n\r\n"); if (!AskYesNo ("Decrypt now")) { crypto_close (BootCryptoInfo); goto ret; } if (EncryptedVirtualPartition.Drive == TC_INVALID_BIOS_DRIVE) { // Drive already decrypted sectorsRemaining.HighPart = 0; sectorsRemaining.LowPart = 0; } else @@ -898,69 +898,69 @@ askBadSectorSkip: skipBadSectors = true; sector = sector + fragmentSectorCount; fragmentSectorCount = 1; } crypto_close (BootCryptoInfo); if (headerUpdateRequired) { Print ("\rUpdating header..."); AcquireSectorBuffer(); uint64 headerSector; headerSector.HighPart = 0; headerSector.LowPart = TC_BOOT_VOLUME_HEADER_SECTOR; // Update encrypted area size in volume header CRYPTO_INFO *headerCryptoInfo = crypto_open(); while (ReadSectors (SectorBuffer, drive, headerSector, 1) != BiosResultSuccess); if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &bootArguments->BootPassword, (int) (bootArguments->Flags >> 16), NULL, headerCryptoInfo) == 0) { DecryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo); uint64 encryptedAreaLength = sectorsRemaining << TC_LB_SIZE_BIT_SHIFT_DIVISOR; for (int i = 7; i >= 0; --i) { - SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (byte) encryptedAreaLength.LowPart; + SectorBuffer[TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH + i] = (uint8) encryptedAreaLength.LowPart; encryptedAreaLength = encryptedAreaLength >> 8; } uint32 headerCrc32 = GetCrc32 (SectorBuffer + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); for (i = 3; i >= 0; --i) { - SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (byte) headerCrc32; + SectorBuffer[TC_HEADER_OFFSET_HEADER_CRC + i] = (uint8) headerCrc32; headerCrc32 >>= 8; } EncryptBuffer (SectorBuffer + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, headerCryptoInfo); } crypto_close (headerCryptoInfo); while (WriteSectors (SectorBuffer, drive, headerSector, 1) != BiosResultSuccess); ReleaseSectorBuffer(); Print ("Done!\r\n"); } if (sectorsRemaining.HighPart == 0 && sectorsRemaining.LowPart == 0) Print ("\rDrive decrypted.\r\n"); else Print ("\r\nDecryption deferred.\r\n"); GetKeyboardChar(); ret: EraseMemory (bootArguments, sizeof (*bootArguments)); } static void RepairMenu () { DriveGeometry bootLoaderDriveGeometry; if (GetDriveGeometry (BootLoaderDrive, bootLoaderDriveGeometry, true) != BiosResultSuccess) @@ -993,114 +993,114 @@ static void RepairMenu () (BootSectorFlags & TC_BOOT_CFG_FLAG_RESCUE_DISK_ORIG_SYS_LOADER) ? array_capacity (options) : array_capacity (options) - 1); PrintEndl(); switch (selection) { case RestoreNone: return; case DecryptVolume: DecryptDrive (BootDrive); continue; case RestoreOriginalSystemLoader: if (!AskYesNo ("Is the system partition/drive decrypted")) { Print ("Please decrypt it first.\r\n"); GetKeyboardChar(); continue; } break; } bool writeConfirmed = false; BiosResult result; uint64 sector; sector.HighPart = 0; ChsAddress chs; - byte mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE]; + uint8 mbrPartTable[TC_LB_SIZE - TC_MAX_MBR_BOOT_CODE_SIZE]; AcquireSectorBuffer(); for (int i = (selection == RestoreVolumeHeader ? TC_BOOT_VOLUME_HEADER_SECTOR : TC_MBR_SECTOR); i < TC_BOOT_LOADER_AREA_SECTOR_COUNT; ++i) { sector.LowPart = i; if (selection == RestoreOriginalSystemLoader) sector.LowPart += TC_ORIG_BOOT_LOADER_BACKUP_SECTOR; else if (selection == RestoreTrueCryptLoader) sector.LowPart += TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR; // The backup medium may be a floppy-emulated bootable CD. The emulation may fail if LBA addressing is used. // Therefore, only CHS addressing can be used. LbaToChs (bootLoaderDriveGeometry, sector, chs); sector.LowPart = i; if (i == TC_MBR_SECTOR) { // Read current partition table result = ReadSectors (SectorBuffer, TC_FIRST_BIOS_DRIVE, sector, 1); if (result != BiosResultSuccess) goto err; memcpy (mbrPartTable, SectorBuffer + TC_MAX_MBR_BOOT_CODE_SIZE, sizeof (mbrPartTable)); } result = ReadSectors (SectorBuffer, BootLoaderDrive, chs, 1); if (result != BiosResultSuccess) goto err; if (i == TC_MBR_SECTOR) { // Preserve current partition table memcpy (SectorBuffer + TC_MAX_MBR_BOOT_CODE_SIZE, mbrPartTable, sizeof (mbrPartTable)); } // Volume header if (i == TC_BOOT_VOLUME_HEADER_SECTOR) { if (selection == RestoreTrueCryptLoader) continue; if (selection == RestoreVolumeHeader) { while (true) { bool validHeaderPresent = false; uint32 masterKeyScheduleCrc; Password password; int pim; - byte exitKey = AskPassword (password, pim); + uint8 exitKey = AskPassword (password, pim); if (exitKey != TC_BIOS_KEY_ENTER) goto abort; CRYPTO_INFO *cryptoInfo; CopyMemory (SectorBuffer, TC_BOOT_LOADER_BUFFER_SEGMENT, 0, TC_LB_SIZE); ReleaseSectorBuffer(); // Restore volume header only if the current one cannot be used if (OpenVolume (TC_FIRST_BIOS_DRIVE, password, pim, &cryptoInfo, nullptr, false, true)) { validHeaderPresent = true; masterKeyScheduleCrc = GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks)); crypto_close (cryptoInfo); } AcquireSectorBuffer(); CopyMemory (TC_BOOT_LOADER_BUFFER_SEGMENT, 0, SectorBuffer, TC_LB_SIZE); if (ReadVolumeHeader (TRUE, (char *) SectorBuffer, &password, pim, &cryptoInfo, nullptr) == 0) { if (validHeaderPresent) { if (masterKeyScheduleCrc == GetCrc32 (cryptoInfo->ks, sizeof (cryptoInfo->ks))) { Print ("Original header preserved.\r\n"); goto err; } @@ -1194,67 +1194,67 @@ void main () else BootDriveGeometryValid = true; } else BootDriveGeometryValid = true; #ifdef TC_WINDOWS_BOOT_RESCUE_DISK_MODE // Check whether the user is not using the Rescue Disk to create a hidden system if (ReadWriteMBR (false, BootDrive, true) == BiosResultSuccess && *(uint32 *) (SectorBuffer + 6) == 0x61726556 && *(uint32 *) (SectorBuffer + 10) == 0x70797243 && (SectorBuffer[TC_BOOT_SECTOR_CONFIG_OFFSET] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) != TC_HIDDEN_OS_CREATION_PHASE_NONE) { PrintError ("It appears you are creating a hidden OS."); if (AskYesNo ("Is this correct")) { Print ("Please remove the Rescue Disk from the drive and restart."); while (true); } } #endif // TC_WINDOWS_BOOT_RESCUE_DISK_MODE // Main menu while (true) { - byte exitKey; + uint8 exitKey; InitScreen(); #ifndef TC_WINDOWS_BOOT_RESCUE_DISK_MODE // Hidden system setup - byte hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; + uint8 hiddenSystemCreationPhase = BootSectorFlags & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; if (hiddenSystemCreationPhase != TC_HIDDEN_OS_CREATION_PHASE_NONE) { PreventNormalSystemBoot = true; PrintMainMenu(); if (hiddenSystemCreationPhase == TC_HIDDEN_OS_CREATION_PHASE_CLONING) { if (CopySystemPartitionToHiddenVolume (BootDrive, exitKey)) { BootSectorFlags = (BootSectorFlags & ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE) | TC_HIDDEN_OS_CREATION_PHASE_WIPING; UpdateBootSectorConfiguration (BootLoaderDrive); } else if (exitKey == TC_BIOS_KEY_ESC) goto bootMenu; else continue; } } else PrintMainMenu(); exitKey = BootEncryptedDrive(); #else // TC_WINDOWS_BOOT_RESCUE_DISK_MODE PrintMainMenu(); exitKey = BootEncryptedDrive(); if (exitKey == TC_MENU_KEY_REPAIR) diff --git a/src/Boot/Windows/BootMain.h b/src/Boot/Windows/BootMain.h index 52d5c8cc..af445024 100644 --- a/src/Boot/Windows/BootMain.h +++ b/src/Boot/Windows/BootMain.h @@ -1,34 +1,34 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Boot_BootMain #define TC_HEADER_Boot_BootMain #include "TCdefs.h" #include "Platform.h" -static byte AskPassword (Password &password, int& pim); +static uint8 AskPassword (Password &password, int& pim); static int AskSelection (const char *options[], size_t optionCount); static bool AskYesNo (const char *message); -static byte BootEncryptedDrive (); +static uint8 BootEncryptedDrive (); static void BootMenu (); -static void ExecuteBootSector (byte drive, byte *sectorBuffer); +static void ExecuteBootSector (uint8 drive, uint8 *sectorBuffer); static void InitScreen (); -static bool IsMenuKey (byte scanCode); -static bool MountVolume (byte drive, byte &exitKey); -static bool OpenVolume (byte drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false); +static bool IsMenuKey (uint8 scanCode); +static bool MountVolume (uint8 drive, uint8 &exitKey); +static bool OpenVolume (uint8 drive, Password &password, CRYPTO_INFO **cryptoInfo, uint32 *headerSaltCrc32 = nullptr, bool skipNormal = false, bool skipHidden = false); static void PrintMainMenu (); static void RepairMenu (); #define TC_MENU_KEY_REPAIR TC_BIOS_KEY_F8 #endif // TC_HEADER_Boot_BootMain diff --git a/src/Boot/Windows/IntFilter.cpp b/src/Boot/Windows/IntFilter.cpp index 9e5c8536..36837d58 100644 --- a/src/Boot/Windows/IntFilter.cpp +++ b/src/Boot/Windows/IntFilter.cpp @@ -11,151 +11,151 @@ */ #include "Platform.h" #include "BootMemory.h" #include "BootConfig.h" #include "BootConsoleIo.h" #include "BootDebug.h" #include "BootDefs.h" #include "BootDiskIo.h" #include "BootEncryptedIo.h" #include "BootStrings.h" #include "IntFilter.h" static uint32 OriginalInt13Handler; static uint32 OriginalInt15Handler; static Registers IntRegisters; bool Int13Filter () { CheckStack(); Registers regs; memcpy (®s, &IntRegisters, sizeof (regs)); __asm sti static int ReEntryCount = -1; ++ReEntryCount; - byte function = (byte) (regs.AX >> 8); + uint8 function = (uint8) (regs.AX >> 8); #ifdef TC_TRACE_INT13 DisableScreenOutput(); PrintHex (function); Print (" EN:"); Print (ReEntryCount); Print (" SS:"); PrintHex (regs.SS); uint16 spdbg; __asm mov spdbg, sp PrintChar (' '); PrintHex (spdbg); PrintChar ('<'); PrintHex (TC_BOOT_LOADER_STACK_TOP); #endif bool passOriginalRequest = true; switch (function) { case 0x2: // Read sectors case 0x3: // Write sectors { - byte drive = (byte) regs.DX; + uint8 drive = (uint8) regs.DX; ChsAddress chs; chs.Cylinder = ((regs.CX << 2) & 0x300) | (regs.CX >> 8); chs.Head = regs.DX >> 8; chs.Sector = regs.CX & 0x3f; - byte sectorCount = (byte) regs.AX; + uint8 sectorCount = (uint8) regs.AX; #ifdef TC_TRACE_INT13 PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); Print (" Chs: "); Print (chs); #endif uint64 sector; if (drive == BootDrive) { if (!BootDriveGeometryValid) TC_THROW_FATAL_EXCEPTION; ChsToLba (BootDriveGeometry, chs, sector); #ifdef TC_TRACE_INT13 PrintVal (" Sec", sector.LowPart, false); #endif } #ifdef TC_TRACE_INT13 PrintVal (" Count", sectorCount, false); Print (" Buf: "); PrintHex (regs.ES); PrintChar (':'); PrintHex (regs.BX); PrintEndl(); #endif if (ReEntryCount == 0 && drive == EncryptedVirtualPartition.Drive) { BiosResult result; if (function == 0x3) result = WriteEncryptedSectors (regs.ES, regs.BX, drive, sector, sectorCount); else result = ReadEncryptedSectors (regs.ES, regs.BX, drive, sector, sectorCount); __asm cli memcpy (&IntRegisters, ®s, sizeof (regs)); IntRegisters.AX = (uint16) result << 8; if (result == BiosResultSuccess) { IntRegisters.AX |= sectorCount; IntRegisters.Flags &= ~TC_X86_CARRY_FLAG; } else IntRegisters.Flags |= TC_X86_CARRY_FLAG; passOriginalRequest = false; } } break; case 0x42: // Read sectors LBA case 0x43: // Write sectors LBA { - byte drive = (byte) regs.DX; + uint8 drive = (uint8) regs.DX; BiosLbaPacket lba; - CopyMemory (regs.DS, regs.SI, (byte *) &lba, sizeof (lba)); + CopyMemory (regs.DS, regs.SI, (uint8 *) &lba, sizeof (lba)); #ifdef TC_TRACE_INT13 PrintVal (": Drive", drive - TC_FIRST_BIOS_DRIVE, false); PrintVal (" Sec", lba.Sector.LowPart, false); PrintVal (" Count", lba.SectorCount, false); PrintVal (" Buf", lba.Buffer, false, true); PrintEndl(); #endif if (ReEntryCount == 0 && drive == EncryptedVirtualPartition.Drive) { BiosResult result; uint16 segment = (uint16) (lba.Buffer >> 16); uint16 offset = (uint16) lba.Buffer; if (function == 0x43) result = WriteEncryptedSectors (segment, offset, drive, lba.Sector, lba.SectorCount); else result = ReadEncryptedSectors (segment, offset, drive, lba.Sector, lba.SectorCount); __asm cli memcpy (&IntRegisters, ®s, sizeof (regs)); IntRegisters.AX = (IntRegisters.AX & 0xff) | ((uint16) result << 8); if (result == BiosResultSuccess) IntRegisters.Flags &= ~TC_X86_CARRY_FLAG; else IntRegisters.Flags |= TC_X86_CARRY_FLAG; @@ -310,104 +310,104 @@ bool Int15Filter () DisableScreenOutput(); Print ("15-"); PrintHex (IntRegisters.AX); Print (" SS:"); PrintHex (IntRegisters.SS); uint16 spdbg; __asm mov spdbg, sp PrintChar (' '); PrintHex (spdbg); PrintChar ('<'); PrintHex (TC_BOOT_LOADER_STACK_TOP); Print (" EAX:"); PrintHex (IntRegisters.EAX); Print (" EBX:"); PrintHex (IntRegisters.EBX); Print (" ECX:"); PrintHex (IntRegisters.ECX); Print (" EDX:"); PrintHex (IntRegisters.EDX); Print (" DI:"); PrintHex (IntRegisters.DI); PrintEndl(); #endif if (IntRegisters.EBX >= BiosMemoryMapSize) { IntRegisters.Flags |= TC_X86_CARRY_FLAG; IntRegisters.EBX = 0; IntRegisters.AX = -1; } else { - CopyMemory ((byte *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0])); + CopyMemory ((uint8 *) &BiosMemoryMap[IntRegisters.EBX], IntRegisters.ES, IntRegisters.DI, sizeof (BiosMemoryMap[0])); IntRegisters.Flags &= ~TC_X86_CARRY_FLAG; IntRegisters.EAX = 0x534D4150UL; ++IntRegisters.EBX; if (IntRegisters.EBX >= BiosMemoryMapSize) IntRegisters.EBX = 0; IntRegisters.ECX = sizeof (BiosMemoryMap[0]); } if (IntRegisters.EBX == 0 && !(BootSectorFlags & TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER)) { // Uninstall filter when the modified map has been issued three times to prevent // problems with hardware drivers on some notebooks running Windows XP. static int CompleteMapIssueCount = 0; if (++CompleteMapIssueCount >= 3) { __asm { cli push es lea si, OriginalInt15Handler xor ax, ax mov es, ax mov di, 0x15 * 4 mov ax, [si] mov es:[di], ax mov ax, [si + 2] mov es:[di + 2], ax pop es sti } } } #ifdef TC_TRACE_INT15 BiosMemoryMapEntry entry; - CopyMemory (IntRegisters.ES, IntRegisters.DI, (byte *) &entry, sizeof (entry)); + CopyMemory (IntRegisters.ES, IntRegisters.DI, (uint8 *) &entry, sizeof (entry)); PrintHex (entry.Type); PrintChar (' '); PrintHex (entry.BaseAddress); PrintChar (' '); PrintHex (entry.Length); PrintChar (' '); PrintHex (entry.BaseAddress + entry.Length); PrintEndl(); Print ("EAX:"); PrintHex (IntRegisters.EAX); Print (" EBX:"); PrintHex (IntRegisters.EBX); Print (" ECX:"); PrintHex (IntRegisters.ECX); Print (" EDX:"); PrintHex (IntRegisters.EDX); Print (" DI:"); PrintHex (IntRegisters.DI); Print (" FL:"); PrintHex (IntRegisters.Flags); PrintEndl (2); #endif #ifdef TC_TRACE_INT15 EnableScreenOutput(); #endif return false; } void IntFilterEntry () { // No automatic variables should be used in this scope as SS may change static uint16 OrigStackPointer; static uint16 OrigStackSegment; __asm { pushf diff --git a/src/Boot/Windows/Platform.cpp b/src/Boot/Windows/Platform.cpp index 046fa4a4..3b94d22c 100644 --- a/src/Boot/Windows/Platform.cpp +++ b/src/Boot/Windows/Platform.cpp @@ -57,61 +57,61 @@ uint64 operator- (const uint64 &a, const uint64 &b) mov carry, 1 nocarry: } r.HighPart = a.HighPart - b.HighPart - carry; return r; } uint64 operator- (const uint64 &a, uint32 b) { uint64 b64; b64.HighPart = 0; b64.LowPart = b; return a - b64; } uint64 &operator-= (uint64 &a, const uint64 &b) { return a = a - b; } uint64 operator>> (const uint64 &a, int shiftCount) { uint64 r = a; while (shiftCount--) { r.LowPart >>= 1; - if ((byte) r.HighPart & 1) + if ((uint8) r.HighPart & 1) r.LowPart |= 0x80000000UL; r.HighPart >>= 1; } return r; } uint64 operator<< (const uint64 &a, int shiftCount) { uint64 r = a; while (shiftCount--) r += r; return r; } uint64 &operator++ (uint64 &a) { uint64 b; b.HighPart = 0; b.LowPart = 1; return a += b; } bool operator== (const uint64 &a, const uint64 &b) { return a.HighPart == b.HighPart && a.LowPart == b.LowPart; diff --git a/src/Boot/Windows/Release/BootLoader.com.gz b/src/Boot/Windows/Release/BootLoader.com.gz Binary files differindex d4cd2a66..9bf2133e 100644 --- a/src/Boot/Windows/Release/BootLoader.com.gz +++ b/src/Boot/Windows/Release/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_AES/BootLoader.com.gz b/src/Boot/Windows/Release_AES/BootLoader.com.gz Binary files differindex de7d9c35..222aa5a1 100644 --- a/src/Boot/Windows/Release_AES/BootLoader.com.gz +++ b/src/Boot/Windows/Release_AES/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz Binary files differindex 42c271aa..6aebbf06 100644 --- a/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Release_AES_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Camellia/BootLoader.com.gz b/src/Boot/Windows/Release_Camellia/BootLoader.com.gz Binary files differindex 090efd03..f090cdfb 100644 --- a/src/Boot/Windows/Release_Camellia/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Camellia/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz Binary files differindex 13ff1405..edc5e25f 100644 --- a/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Camellia_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_SHA2/BootLoader.com.gz Binary files differindex d596c445..b9d83263 100644 --- a/src/Boot/Windows/Release_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Release_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Serpent/BootLoader.com.gz b/src/Boot/Windows/Release_Serpent/BootLoader.com.gz Binary files differindex 9cb0b0cb..2a9cac0b 100644 --- a/src/Boot/Windows/Release_Serpent/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Serpent/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz Binary files differindex 7353e440..19ab043c 100644 --- a/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Serpent_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Twofish/BootLoader.com.gz b/src/Boot/Windows/Release_Twofish/BootLoader.com.gz Binary files differindex 69e3b264..885190f2 100644 --- a/src/Boot/Windows/Release_Twofish/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Twofish/BootLoader.com.gz diff --git a/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz b/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz Binary files differindex 6e008a19..0090b771 100644 --- a/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Release_Twofish_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue/BootLoader.com.gz b/src/Boot/Windows/Rescue/BootLoader.com.gz Binary files differindex 3e6ee5c3..181b2d35 100644 --- a/src/Boot/Windows/Rescue/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_AES/BootLoader.com.gz b/src/Boot/Windows/Rescue_AES/BootLoader.com.gz Binary files differindex 6a3cfdcb..5114925b 100644 --- a/src/Boot/Windows/Rescue_AES/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_AES/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz Binary files differindex 0cb31996..52382753 100644 --- a/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_AES_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz b/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz Binary files differindex 7c934a57..60d7d41a 100644 --- a/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Camellia/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz Binary files differindex ca2952aa..f2a0fc22 100644 --- a/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Camellia_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz Binary files differindex 3a9410ba..47e8283a 100644 --- a/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz b/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz Binary files differindex cd6fe5d5..c248eb6b 100644 --- a/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Serpent/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz Binary files differindex 37d4d02b..e3e889e0 100644 --- a/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Serpent_SHA2/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz b/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz Binary files differindex 6a2d1c5f..6525bcaa 100644 --- a/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Twofish/BootLoader.com.gz diff --git a/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz b/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz Binary files differindex f262a558..9837e671 100644 --- a/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz +++ b/src/Boot/Windows/Rescue_Twofish_SHA2/BootLoader.com.gz diff --git a/src/Build/CMakeLists.txt b/src/Build/CMakeLists.txt index eb4f8a6d..458040e8 100644 --- a/src/Build/CMakeLists.txt +++ b/src/Build/CMakeLists.txt @@ -1,45 +1,45 @@ # - Minimum CMake version cmake_minimum_required(VERSION 2.8.0) # - Obligatory parameters # -DVERACRYPT_BUILD_DIR : folder that contains 'usr' folder # -DNOGUI : TRUE if building 'Console' version, 'FALSE' if building 'GUI' version if ( NOT DEFINED VERACRYPT_BUILD_DIR ) MESSAGE(FATAL_ERROR "VERACRYPT_BUILD_DIR variable MUST BE set to the path of the folder which contains 'usr' folder") elseif ( NOT DEFINED NOGUI ) MESSAGE(FATAL_ERROR "NOGUI variable MUST BE set to TRUE if building 'Console' version, 'FALSE' otherwise") endif() # - Set version of the package -set( FULL_VERSION "1.26.4" ) -set( VERSION "1.26.4" ) +set( FULL_VERSION "1.26.15" ) +set( VERSION "1.26.15" ) set( RELEASE "1" ) # - Set PROJECT_NAME and CONFLICT_PACKAGE values if (NOGUI) set( PROJECT_NAME "veracrypt-console" ) set( CONFLICT_PACKAGE "veracrypt" ) else() set( PROJECT_NAME "veracrypt" ) set( CONFLICT_PACKAGE "veracrypt-console" ) endif() project(${PROJECT_NAME}) # - Check whether 'Tcdefs.h' and 'License.txt' exist if(NOT EXISTS "$ENV{SOURCEPATH}/Common/Tcdefs.h") MESSAGE(FATAL_ERROR "Tcdefs.h does not exist.") elseif(NOT EXISTS "$ENV{SOURCEPATH}/License.txt") MESSAGE(FATAL_ERROR "License.txt does not exist.") endif() # - Detect build system bitness # The following variable will be set # $SUFFIX 32 64 # $CMAKE_SYSTEM_NAME Windows Linux Darwin # N.B : # To build for 32-bit under 64-bit, set 'CMAKE_SIZEOF_VOID_P' to '4' if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # Build System is under 64-bit arch set (SUFFIX "64") MESSAGE(STATUS "Build System = ${CMAKE_SYSTEM_NAME} - Bitness : 64-bit - Compiler : ${CMAKE_CXX_COMPILER_ID}") @@ -84,114 +84,125 @@ if ( UNIX ) file(READ "/etc/lsb-release" UBUNTU_RELEASE) string(REGEX MATCH "DISTRIB_RELEASE=([0-9 /\\.]+)" _ ${UBUNTU_RELEASE}) set(PLATFORM_VERSION ${CMAKE_MATCH_1}) else() file(READ "/etc/debian_version" DEBIAN_RELEASE) string(REGEX MATCH "([0-9]+\\.[0-9]+)" _ ${DEBIAN_RELEASE}) set(PLATFORM_VERSION ${CMAKE_MATCH_1}) endif() # Get debian release version elseif(EXISTS "/etc/debian_version") file(READ "/etc/debian_version" DEBIAN_RELEASE) string(REGEX MATCH "([0-9]+\\.[0-9]+)" _ ${DEBIAN_RELEASE}) set(PLATFORM_VERSION ${CMAKE_MATCH_1}) endif() # Get centos release version elseif(EXISTS "/etc/centos-release") set ( PLATFORM "CentOS" ) file(READ "/etc/centos-release" CENTOS_RELEASE) string(REGEX MATCH "release ([0-9 /\\.]+)" _ ${CENTOS_RELEASE}) set(PLATFORM_VERSION ${CMAKE_MATCH_1}) + + # Get fedora release version + elseif(EXISTS "/etc/fedora-release") + + set ( PLATFORM "Fedora" ) + + file(READ "/etc/fedora-release" FEDORA_RELEASE) + string(REGEX MATCH "release ([0-9 /\\.]+)" _ ${FEDORA_RELEASE}) + set(PLATFORM_VERSION ${CMAKE_MATCH_1}) # Only if distribution uses systemd and if all previous files didn't exist # i.e OpenSUSE elseif(EXISTS "/etc/os-release") file(READ "/etc/os-release" OS_RELEASE_NAME) string(REGEX MATCH "NAME=\"([a-zA-Z0-9 /\\.]+)\"" _ ${OS_RELEASE_NAME}) set(FULL_PLATFORM ${CMAKE_MATCH_1}) if (FULL_PLATFORM MATCHES "^.*openSUSE.*$") set ( PLATFORM "openSUSE" ) elseif ( FULL_PLATFORM MATCHES "^.*Ubuntu.*$") set ( PLATFORM "Ubuntu" ) elseif ( FULL_PLATFORM MATCHES "^.*Debian.*$") set ( PLATFORM "Debian" ) elseif ( FULL_PLATFORM MATCHES "^.*CentOS.*$" ) set ( PLATFORM "CentOS" ) + elseif ( FULL_PLATFORM MATCHES "^.*Fedora.*$" ) + set ( PLATFORM "Fedora" ) endif ( ) # Get ditribution release version file(READ "/etc/os-release" OS_RELEASE) string(REGEX MATCH "VERSION=\"([a-zA-Z0-9 /\\.]+)\"" _ ${OS_RELEASE}) set(PLATFORM_VERSION ${CMAKE_MATCH_1}) endif() endif ( ) string(REGEX REPLACE " $" "" PLATFORM_VERSION "${PLATFORM_VERSION}") # Trim the last trailing whitespace set ( DISTRO_NAME ${PLATFORM}-${PLATFORM_VERSION} ) MESSAGE ( STATUS "Platform = ${PLATFORM}" ) MESSAGE ( STATUS "Platform Version = ${PLATFORM_VERSION}" ) MESSAGE ( STATUS "Distribution name = ${DISTRO_NAME}" ) # - Detect the architecture under OSX, Debian, CentOS and OpenSUSE platforms # The following variable will be set # $ARCHITECTURE if ( PLATFORM STREQUAL "Debian" OR PLATFORM STREQUAL "Ubuntu" ) # There is no such thing as i686 architecture on debian, i386 is to be used instead # dpkg --print-architecture find_program(DPKG_CMD dpkg) if(NOT DPKG_CMD) # Cannot find dpkg in path # Try best guess following SUFFIX value calculated from CMAKE_SIZEOF_VOID_P if (SUFFIX STREQUAL "32") SET(ARCHITECTURE i386) elseif (SUFFIX STREQUAL "64") SET(ARCHITECTURE amd64) endif() else( ) execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) endif( ) -elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) ) +elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) OR ( PLATFORM STREQUAL "Fedora" )) execute_process(COMMAND arch OUTPUT_VARIABLE ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE) else () MESSAGE(FATAL_ERROR "Unrecognized / unsupported distribution") endif ( ) MESSAGE ( STATUS "Architecture = ${ARCHITECTURE}" ) # - Create installation folder directory at install time # This won't lead to the files being actually installed (in CMAKE_INSTALL_PREFIX) # unless "cmake --build . --target install" is executed, which is not the case here. # # Doing things like the following # - install(DIRECTORY ${VERACRYPT_BUILD_DIR}/usr DESTINATION /) # - install(DIRECTORY ${VERACRYPT_BUILD_DIR}/usr/bin DESTINATION /usr) # lead to conflicts despite the usage of CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION # because install() forces CpackRPM to create the DESTINATION folders. # # We fix this by installing ALL directories inside '/usr' in '.', and setting # CPACK_PACKAGING_INSTALL_PREFIX to '/usr'. # This way, during the packaging, 'bin' and 'share' folders will be installed # inside '${CPACK_PACKAGE_DIRECTORY}/_CPack_Packages/<system_name>/DEB,RPM/${CPACK_PACKAGE_NAME}/${CPACK_PACKAGING_INSTALL_PREFIX}'. # # Also, we use USE_SOURCE_PERMISSIONS to save the permissions install(DIRECTORY ${VERACRYPT_BUILD_DIR}/usr/bin DESTINATION . USE_SOURCE_PERMISSIONS) install(DIRECTORY ${VERACRYPT_BUILD_DIR}/usr/sbin @@ -220,122 +231,131 @@ set( CONTACT "VeraCrypt Team <veracrypt@idrix.fr>" ) set( CPACK_PACKAGE_DESCRIPTION_SUMMARY "Disk encryption with strong security based on TrueCrypt." ) set( CPACK_PACKAGE_DESCRIPTION "This package contains binaries for VeraCrypt, a disk encryption with strong security based on TrueCrypt." ) set( CPACK_PACKAGE_NAME ${PROJECT_NAME} ) set( CPACK_PACKAGE_VERSION ${VERSION} ) set( CPACK_PACKAGE_RELEASE ${RELEASE} ) set( CPACK_PACKAGE_VENDOR ${VENDOR} ) set( CPACK_PACKAGE_LICENSE ${LICENSE} ) set( CPACK_RESOURCE_FILE_LICENSE "$ENV{SOURCEPATH}/License.txt") set( CPACK_PACKAGE_CONTACT ${CONTACT} ) set( CPACK_PACKAGE_FILE_NAME ${CPACK_PACKAGE_NAME}-${FULL_VERSION}-${DISTRO_NAME}-${ARCHITECTURE} ) set( CPACK_PACKAGE_CHECKSUM SHA256 ) set( CPACK_PACKAGE_RELOCATABLE "OFF") # Disable package relocation (especially for rpm) set( CPACK_PACKAGE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging ) if ( ( PLATFORM STREQUAL "Debian" ) OR ( PLATFORM STREQUAL "Ubuntu" ) ) # Debian control script(s) file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Packaging/debian-control/prerm ${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control/prerm) set( DEBIAN_PRERM ${CMAKE_CURRENT_BINARY_DIR}/Packaging/debian-control/prerm) set( CPACK_GENERATOR "DEB" ) # mandatory set( CPACK_DEBIAN_PACKAGE_NAME ${CPACK_PACKAGE_NAME} ) # mandatory set( CPACK_DEBIAN_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}.deb ) # mandatory set( CPACK_DEBIAN_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION} ) # mandatory set( CPACK_DEBIAN_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} ) set( CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${ARCHITECTURE} ) # mandatory if (NOGUI) # Link against statically built wxWidgets so that we don't depend on any GTK library - set( CPACK_DEBIAN_PACKAGE_DEPENDS "libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) + # In case of Ubuntu 24.04/ Debian 13 or newer, libfuse2 package was renamed libfuse2t64 + if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "13" ) ) + OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "24.04" ) ) ) + set( CPACK_DEBIAN_PACKAGE_DEPENDS "libfuse2t64, dmsetup, sudo, libpcsclite1, pcscd" ) + else () + set( CPACK_DEBIAN_PACKAGE_DEPENDS "libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) + endif() else () # Link against gtk3 version of wxWidgets if >= Debian 10 or >= Ubuntu 18.04 # Otherwise, link against gtk2 version of wxWidgets - if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "12" ) ) + # In case of Ubuntu 24.04, we depend on libfuse2t64 instead of libfuse2 and we link statically against wxWidgets + # because there is a bug in wxWidgets that ships with Ubuntu 24.04 and which was fixed in wxWidgets 3.2.5 + if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "13" ) ) + OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "24.04" ) ) ) + + set( CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk-3-0t64, libayatana-appindicator3-1, libfuse2t64, dmsetup, sudo, libpcsclite1, pcscd" ) + + elseif ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "12" ) ) OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "23.04" ) ) ) set( CPACK_DEBIAN_PACKAGE_DEPENDS "libwxgtk3.2-1, libayatana-appindicator3-1, libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) elseif ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "10" ) ) OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_GREATER_EQUAL "18.04" ) ) ) set( CPACK_DEBIAN_PACKAGE_DEPENDS "libwxgtk3.0-gtk3-0v5, libayatana-appindicator3-1, libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) else () # Link against statically built wxWidgets on Ubuntu 14.04 and older, and Debian 8 and older if ( ( ( PLATFORM STREQUAL "Debian" ) AND ( PLATFORM_VERSION VERSION_LESS_EQUAL "8" ) ) OR ( ( PLATFORM STREQUAL "Ubuntu" ) AND ( PLATFORM_VERSION VERSION_LESS_EQUAL "14.04" ) ) ) set( CPACK_DEBIAN_PACKAGE_DEPENDS "libgtk2.0-0, libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) else () set( CPACK_DEBIAN_PACKAGE_DEPENDS "libwxgtk3.0-0v5, libfuse2, dmsetup, sudo, libpcsclite1, pcscd" ) endif () endif() endif() set( CPACK_DEBIAN_PACKAGE_MAINTAINER ${CONTACT} ) # mandatory set( CPACK_DEBIAN_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION_SUMMARY} ) # mandatory set( CPACK_DEBIAN_ARCHIVE_TYPE "gnutar") # mandatory set( CPACK_DEBIAN_COMPRESSION_TYPE "gzip") # mandatory set( CPACK_DEBIAN_PACKAGE_PRIORITY "optional" ) # mandatory set( CPACK_DEBIAN_PACKAGE_SECTION "libs" ) # recommended, Section relative to Debian sections (https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections) set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${DEBIAN_PREINST};${DEBIAN_POSTINST};${DEBIAN_PRERM};${DEBIAN_POSTRM}) set(CPACK_DEBIAN_PACKAGE_CONFLICTS "${CONFLICT_PACKAGE}") -elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) ) +elseif ( ( PLATFORM STREQUAL "CentOS" ) OR ( PLATFORM STREQUAL "openSUSE" ) OR ( PLATFORM STREQUAL "Fedora" )) # RPM control script(s) file( MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Packaging/rpm-control/prerm.sh ${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control/prerm.sh) set( RPM_PRERM ${CMAKE_CURRENT_BINARY_DIR}/Packaging/rpm-control/prerm.sh) set( CPACK_GENERATOR "RPM" ) # mandatory set( CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_SUMMARY} ) # mandatory set( CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION} ) # mandatory set( CPACK_RPM_PACKAGE_NAME ${CPACK_PACKAGE_NAME} ) # mandatory set( CPACK_RPM_FILE_NAME ${CPACK_PACKAGE_FILE_NAME}.rpm ) # mandatory set( CPACK_RPM_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION} ) # mandatory set( CPACK_RPM_PACKAGE_ARCHITECTURE ${ARCHITECTURE} ) # mandatory set( CPACK_RPM_PACKAGE_RELEASE ${CPACK_PACKAGE_RELEASE} ) # mandatory set( CPACK_RPM_PACKAGE_LICENSE ${CPACK_PACKAGE_LICENSE} ) # mandatory set( CPACK_RPM_PACKAGE_GROUP "Applications/System" ) # mandatory, https://fedoraproject.org/wiki/RPMGroups set( CPACK_RPM_PACKAGE_VENDOR ${CPACK_PACKAGE_VENDOR} ) # mandatory set( CPACK_RPM_PACKAGE_AUTOREQ "no" ) # disable automatic shared libraries dependency detection (most of the time buggy) if (NOGUI) set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, sudo" ) else () - if ( PLATFORM STREQUAL "CentOS" ) - - if ( DEFINED WITHGTK3 AND WITHGTK3 ) - set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, gtk3, sudo, pcsc-lite" ) - else () - set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, gtk2, sudo, pcsc-lite" ) - endif() - - elseif ( PLATFORM STREQUAL "openSUSE" ) - - set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, gtk2, sudo, pcsc-lite" ) + find_package(PkgConfig REQUIRED) + pkg_check_modules(GTK3 gtk+-3.0) + + if(GTK3_FOUND) + set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, gtk3, sudo, pcsc-lite" ) + else() + set( CPACK_RPM_PACKAGE_REQUIRES "fuse, device-mapper, gtk2, sudo, pcsc-lite" ) endif() endif() set( CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE ${RPM_PRERM}) # optional # Prevents CPack from generating file conflicts # This is to avoid having %dir of these directories in the .spec file set( CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/bin" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/applications" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/doc" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/mime" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/mime/packages" ) list(APPEND CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/share/pixmaps" ) set( CPACK_RPM_PACKAGE_RELOCATABLE "OFF" ) set( CPACK_RPM_PACKAGE_CONFLICTS "${CONFLICT_PACKAGE}") endif() include(CPack) diff --git a/src/Build/Resources/MacOSX/Info.plist.legacy.xml b/src/Build/Resources/MacOSX/Info.plist.legacy.xml index 52c1a652..5b9ced6e 100644 --- a/src/Build/Resources/MacOSX/Info.plist.legacy.xml +++ b/src/Build/Resources/MacOSX/Info.plist.legacy.xml @@ -47,60 +47,60 @@ <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <!-- my app supports files with my custom extension (see UTExportedTypeDeclarations) --> <string>org.idrix.veracrypt.hc</string> </array> </dict> </array> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>VeraCrypt</string> <key>CFBundleIconFile</key> <string>VeraCrypt.icns</string> <key>CFBundleName</key> <string>VeraCrypt</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>TRUE</string> <key>CFBundleVersion</key> - <string>1.26.4</string> + <string>_VERSION_</string> <key>CFBundleShortVersionString</key> <string>_VERSION_</string> <key>CFBundleLongVersionString</key> <string>VeraCrypt _VERSION_</string> <key>LSArchitecturePriority</key> <array> <string>x86_64</string> <string>i386</string> </array> <key>LSMinimumSystemVersion</key> <string>10.7.0</string> <key>LSRequiresCarbon</key> <false/> <key>CSResourcesFileMapped</key> <true/> <key>NSHighResolutionCapable</key> <true/> <key>NSPrincipalClass</key> <string>NSApplication</string> </dict> </plist> diff --git a/src/Build/Resources/MacOSX/Info.plist.xml b/src/Build/Resources/MacOSX/Info.plist.xml index d6e71e2e..04ed21c1 100644 --- a/src/Build/Resources/MacOSX/Info.plist.xml +++ b/src/Build/Resources/MacOSX/Info.plist.xml @@ -47,54 +47,54 @@ <string>Viewer</string> <key>LSHandlerRank</key> <string>Owner</string> <key>LSItemContentTypes</key> <array> <!-- my app supports files with my custom extension (see UTExportedTypeDeclarations) --> <string>org.idrix.veracrypt.hc</string> </array> </dict> </array> <key>CFBundleDevelopmentRegion</key> <string>English</string> <key>CFBundleExecutable</key> <string>VeraCrypt</string> <key>CFBundleIconFile</key> <string>VeraCrypt.icns</string> <key>CFBundleName</key> <string>VeraCrypt</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleSignature</key> <string>TRUE</string> <key>CFBundleVersion</key> - <string>1.26.4</string> + <string>_VERSION_</string> <key>CFBundleShortVersionString</key> <string>_VERSION_</string> <key>CFBundleLongVersionString</key> <string>VeraCrypt _VERSION_</string> <key>LSMinimumSystemVersion</key> - <string>10.9.0</string> + <string>12.0.0</string> <key>LSRequiresCarbon</key> <false/> <key>CSResourcesFileMapped</key> <true/> <key>NSHighResolutionCapable</key> <true/> <key>NSPrincipalClass</key> <string>NSApplication</string> </dict> </plist> diff --git a/src/Build/Tools/MacOSX/yasm b/src/Build/Tools/MacOSX/yasm Binary files differindex d17889a9..36a9c0d4 100755 --- a/src/Build/Tools/MacOSX/yasm +++ b/src/Build/Tools/MacOSX/yasm diff --git a/src/Build/build_cmake_deb.sh b/src/Build/build_cmake_deb.sh index a6263a90..8bceb886 100755 --- a/src/Build/build_cmake_deb.sh +++ b/src/Build/build_cmake_deb.sh @@ -1,86 +1,114 @@ #!/bin/sh # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Errors should cause script to exit set -e # Absolute path to this script export SCRIPT=$(readlink -f "$0") # Absolute path this script is in export SCRIPTPATH=$(dirname "$SCRIPT") # Source directory which contains the Makefile export SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # Directory where the VeraCrypt has been checked out export PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") -# The sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" - -cd $SOURCEPATH - -if [ "$#" = "1" ] && [ "$1" = "WXSTATIC" ] -then -echo "Building GUI version of VeraCrypt for DEB using wxWidgets static libraries" - -# This will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildGUI - -# To build wxWidgets without GUI -make WXSTATIC=1 wxbuild || exit 1 -make WXSTATIC=1 clean || exit 1 -make WXSTATIC=1 || exit 1 -make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." else - -echo "Building GUI version of VeraCrypt for DEB using system wxWidgets" -make clean || exit 1 - -if [ "$#" = "1" ] && [ "$1" = "INDICATOR" ] -then - -make INDICATOR=1 || exit 1 -make INDICATOR=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - -else - -make || exit 1 -make install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi fi -fi +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 -echo "Building console version of VeraCrypt for DEB using wxWidgets static libraries" - -# This is to avoid " Error: Unable to initialize GTK+, is DISPLAY set properly?" -# when building over SSH without X11 Forwarding -# export DISPLAY=:0.0 +cd $SOURCEPATH -# This will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole +build_and_install() { + target=$1 + wxstatic=$2 + indicator=$3 + nogui="" + + # Determine wxWidgets build directory based on target + if [ "$target" = "Console" ]; then + export WX_BUILD_DIR="$PARENTDIR/wxBuildConsole" + nogui="NOGUI=1" + else + export WX_BUILD_DIR="$PARENTDIR/wxBuildGUI" + fi + + wxstatic_value="" + if [ "$wxstatic" = "WXSTATIC" ]; then + wxstatic_value="WXSTATIC=1" + # Check if wx-config exists in WX_BUILD_DIR + if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." + else + echo "Using wxWidgets sources in $WX_ROOT" + make $wxstatic_value $nogui wxbuild || exit 1 + fi + fi + + indicator_value="" + if [ "$indicator" = "INDICATOR" ]; then + indicator_value="INDICATOR=1" + fi + + make $wxstatic_value $indicator_value $nogui clean || exit 1 + make $wxstatic_value $indicator_value $nogui || exit 1 + make $wxstatic_value $indicator_value $nogui install DESTDIR="$PARENTDIR/VeraCrypt_Setup/$target" || exit 1 +} + +# Handle arguments +case "$1$2" in +"WXSTATIC") + echo "Building GUI version of VeraCrypt for DEB using wxWidgets static libraries" + build_and_install "GUI" "WXSTATIC" "" + ;; +"INDICATOR") + echo "Building GUI version of VeraCrypt for DEB using system wxWidgets and indicator" + build_and_install "GUI" "" "INDICATOR" + ;; +"WXSTATICINDICATOR"|"INDICATORWXSTATIC") + echo "Building GUI version of VeraCrypt for DEB using wxWidgets static libraries and indicator" + build_and_install "GUI" "WXSTATIC" "INDICATOR" + ;; +*) + echo "Building GUI version of VeraCrypt for DEB using system wxWidgets" + build_and_install "GUI" "" "" + ;; +esac -# To build wxWidgets without GUI -make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 -make WXSTATIC=1 NOGUI=1 clean || exit 1 -make WXSTATIC=1 NOGUI=1 || exit 1 -make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 +echo "Building console version of VeraCrypt for DEB using wxWidgets static libraries" +build_and_install "Console" "WXSTATIC" "" echo "Creating VeraCrypt DEB packages" # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack DEB # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack DEB -mkdir -p $PARENTDIR/VeraCrypt_Packaging/GUI -mkdir -p $PARENTDIR/VeraCrypt_Packaging/Console +mkdir -p $PARENTDIR/VeraCrypt_Packaging/{GUI,Console} cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DNOGUI=FALSE || exit 1 cpack --config $PARENTDIR/VeraCrypt_Packaging/GUI/CPackConfig.cmake || exit 1 + cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DNOGUI=TRUE || exit 1 -cpack --config $PARENTDIR/VeraCrypt_Packaging/Console/CPackConfig.cmake || exit 1 +cpack --config $PARENTDIR/VeraCrypt_Packaging/Console/CPackConfig.cmake || exit 1 diff --git a/src/Build/build_cmake_opensuse.sh b/src/Build/build_cmake_opensuse.sh index 622eb4cd..13a75bec 100644 --- a/src/Build/build_cmake_opensuse.sh +++ b/src/Build/build_cmake_opensuse.sh @@ -1,77 +1,96 @@ #!/bin/sh # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Errors should cause script to exit set -e # Absolute path to this script export SCRIPT=$(readlink -f "$0") # Absolute path this script is in export SCRIPTPATH=$(dirname "$SCRIPT") # Source directory which contains the Makefile export SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # Directory where the VeraCrypt has been checked out export PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") -# The sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi +fi + +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 cd $SOURCEPATH echo "Building GUI version of VeraCrypt for RPM using wxWidgets static libraries" # This will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildGui -# To build wxWidgets using GTK-2 -make WXSTATIC=1 wxbuild || exit 1 -ln -s $WX_BUILD_DIR/lib $WX_BUILD_DIR/lib64 +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 wxbuild || exit 1 + ln -s $WX_BUILD_DIR/lib $WX_BUILD_DIR/lib64 +fi + make WXSTATIC=1 clean || exit 1 make WXSTATIC=1 || exit 1 make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 clean || exit 1 -# make WXSTATIC=1 || exit 1 -# make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - echo "Building console version of VeraCrypt for RPM using wxWidgets static libraries" # This is to avoid " Error: Unable to initialize GTK+, is DISPLAY set properly?" # when building over SSH without X11 Forwarding # export DISPLAY=:0.0 # This will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole -# To build wxWidgets using GTK-2 -make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 -ln -s $WX_BUILD_DIR/lib $WX_BUILD_DIR/lib64 +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 + ln -s $WX_BUILD_DIR/lib $WX_BUILD_DIR/lib64 +fi + make WXSTATIC=1 NOGUI=1 clean || exit 1 make WXSTATIC=1 NOGUI=1 || exit 1 make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 NOGUI=1 clean || exit 1 -# make WXSTATIC=1 NOGUI=1 || exit 1 -# make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 - echo "Creating VeraCrypt RPM packages " # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM mkdir -p $PARENTDIR/VeraCrypt_Packaging/GUI mkdir -p $PARENTDIR/VeraCrypt_Packaging/Console -# wxWidgets was built using GTK-2 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DWITHGTK3=FALSE -DNOGUI=FALSE || exit 1 +# wxWidgets was built using native GTK version +cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DNOGUI=FALSE || exit 1 cpack --config $PARENTDIR/VeraCrypt_Packaging/GUI/CPackConfig.cmake || exit 1 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DWITHGTK3=FALSE -DNOGUI=TRUE || exit 1 +cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DNOGUI=TRUE || exit 1 cpack --config $PARENTDIR/VeraCrypt_Packaging/Console/CPackConfig.cmake|| exit 1 diff --git a/src/Build/build_cmake_rpm_gtk2.sh b/src/Build/build_cmake_rpm.sh index 3f33cc1c..ba6ea355 100644 --- a/src/Build/build_cmake_rpm_gtk2.sh +++ b/src/Build/build_cmake_rpm.sh @@ -1,75 +1,94 @@ #!/bin/sh # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Errors should cause script to exit set -e # Absolute path to this script export SCRIPT=$(readlink -f "$0") # Absolute path this script is in export SCRIPTPATH=$(dirname "$SCRIPT") # Source directory which contains the Makefile export SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # Directory where the VeraCrypt has been checked out export PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") -# The sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi +fi + +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 cd $SOURCEPATH echo "Building GUI version of VeraCrypt for RPM using wxWidgets static libraries" # This will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildGui -# To build wxWidgets using GTK-2 -make WXSTATIC=1 wxbuild || exit 1 +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 wxbuild || exit 1 +fi + make WXSTATIC=1 clean || exit 1 make WXSTATIC=1 || exit 1 make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 clean || exit 1 -# make WXSTATIC=1 || exit 1 -# make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - echo "Building console version of VeraCrypt for RPM using wxWidgets static libraries" # This is to avoid " Error: Unable to initialize GTK+, is DISPLAY set properly?" # when building over SSH without X11 Forwarding # export DISPLAY=:0.0 # This will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole -# To build wxWidgets using GTK-2 -make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 +fi + make WXSTATIC=1 NOGUI=1 clean || exit 1 make WXSTATIC=1 NOGUI=1 || exit 1 make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 NOGUI=1 clean || exit 1 -# make WXSTATIC=1 NOGUI=1 || exit 1 -# make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 - echo "Creating VeraCrypt RPM packages " # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM # -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM mkdir -p $PARENTDIR/VeraCrypt_Packaging/GUI mkdir -p $PARENTDIR/VeraCrypt_Packaging/Console -# wxWidgets was built using GTK-2 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DWITHGTK3=FALSE -DNOGUI=FALSE || exit 1 +# wxWidgets was built using native GTK version +cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DNOGUI=FALSE || exit 1 cpack --config $PARENTDIR/VeraCrypt_Packaging/GUI/CPackConfig.cmake || exit 1 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DWITHGTK3=FALSE -DNOGUI=TRUE || exit 1 +cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DNOGUI=TRUE || exit 1 cpack --config $PARENTDIR/VeraCrypt_Packaging/Console/CPackConfig.cmake || exit 1 diff --git a/src/Build/build_cmake_rpm_gtk3.sh b/src/Build/build_cmake_rpm_gtk3.sh deleted file mode 100644 index 72556dcf..00000000 --- a/src/Build/build_cmake_rpm_gtk3.sh +++ /dev/null @@ -1,75 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2013-2022 IDRIX -# 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. -# - -# Errors should cause script to exit -set -e - -# Absolute path to this script -export SCRIPT=$(readlink -f "$0") -# Absolute path this script is in -export SCRIPTPATH=$(dirname "$SCRIPT") -# Source directory which contains the Makefile -export SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") -# Directory where the VeraCrypt has been checked out -export PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") - -# The sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" - -cd $SOURCEPATH - -echo "Building GUI version of VeraCrypt for RPM using wxWidgets static libraries" - -# This will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildGui - -# To build wxWidgets using GTK-3 -make WXSTATIC=1 WITHGTK3=1 wxbuild || exit 1 -make WXSTATIC=1 clean || exit 1 -make WXSTATIC=1 || exit 1 -make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 clean || exit 1 -# make WXSTATIC=1 || exit 1 -# make WXSTATIC=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/GUI" || exit 1 - -echo "Building console version of VeraCrypt for RPM using wxWidgets static libraries" - -# This is to avoid " Error: Unable to initialize GTK+, is DISPLAY set properly?" -# when building over SSH without X11 Forwarding -# export DISPLAY=:0.0 - -# This will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole - -# To build wxWidgets using GTK-3 -make WXSTATIC=1 WITHGTK3=1 NOGUI=1 wxbuild || exit 1 -make WXSTATIC=1 NOGUI=1 clean || exit 1 -make WXSTATIC=1 NOGUI=1 || exit 1 -make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 - -# Uncomment below and comment lines above to reuse existing wxWidgets build -# make WXSTATIC=1 NOGUI=1 clean || exit 1 -# make WXSTATIC=1 NOGUI=1 || exit 1 -# make WXSTATIC=1 NOGUI=1 install DESTDIR="$PARENTDIR/VeraCrypt_Setup/Console" || exit 1 - -echo "Creating VeraCrypt RPM packages " - -# -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM -# -DCPACK_RPM_PACKAGE_DEBUG=TRUE for debugging cpack RPM - -mkdir -p $PARENTDIR/VeraCrypt_Packaging/GUI -mkdir -p $PARENTDIR/VeraCrypt_Packaging/Console - -# wxWidgets was built using GTK-3 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/GUI -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/GUI" -DWITHGTK3=TRUE -DNOGUI=FALSE || exit 1 -cpack --config $PARENTDIR/VeraCrypt_Packaging/GUI/CPackConfig.cmake || exit 1 -cmake -H$SCRIPTPATH -B$PARENTDIR/VeraCrypt_Packaging/Console -DVERACRYPT_BUILD_DIR="$PARENTDIR/VeraCrypt_Setup/Console" -DWITHGTK3=TRUE -DNOGUI=TRUE || exit 1 -cpack --config $PARENTDIR/VeraCrypt_Packaging/Console/CPackConfig.cmake|| exit 1 diff --git a/src/Build/build_veracrypt_freebsd.sh b/src/Build/build_veracrypt_freebsd.sh index 176c8499..892a7eed 100755 --- a/src/Build/build_veracrypt_freebsd.sh +++ b/src/Build/build_veracrypt_freebsd.sh @@ -1,48 +1,72 @@ #!/bin/sh # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Absolute path to this script SCRIPT=$(readlink -f "$0") # Absolute path this script is in SCRIPTPATH=$(dirname "$SCRIPT") # source directory which contains the Makefile SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # directory where the VeraCrypt has been checked out PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") -# Make sure only root can run our script -if [ "$(id -u)" != "0" ]; then - echo "VeraCrypt must be built by root" 1>&2 - exit 1 +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi fi -# the sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 cd $SOURCEPATH echo "Building GUI version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildGui -gmake WXSTATIC=1 wxbuild && gmake WXSTATIC=1 clean && gmake WXSTATIC=1 && gmake WXSTATIC=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + gmake WXSTATIC=1 wxbuild || exit 1 +fi -# Uncomment below and comment line above to reuse existing wxWidgets build -#gmake WXSTATIC=1 clean && gmake WXSTATIC=1 && gmake WXSTATIC=1 package +gmake WXSTATIC=1 clean || exit 1 +gmake WXSTATIC=1 || exit 1 +gmake WXSTATIC=1 package || exit 1 echo "Building console version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole -gmake WXSTATIC=1 NOGUI=1 wxbuild && gmake WXSTATIC=1 NOGUI=1 clean && gmake WXSTATIC=1 NOGUI=1 && gmake WXSTATIC=1 NOGUI=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -#gmake WXSTATIC=1 NOGUI=1 clean && gmake WXSTATIC=1 NOGUI=1 && gmake WXSTATIC=1 NOGUI=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + gmake WXSTATIC=1 NOGUI=1 wxbuild || exit 1 +fi +gmake WXSTATIC=1 NOGUI=1 clean || exit 1 +gmake WXSTATIC=1 NOGUI=1 || exit 1 +gmake WXSTATIC=1 NOGUI=1 package || exit 1 diff --git a/src/Build/build_veracrypt_linux.sh b/src/Build/build_veracrypt_linux.sh index fa928556..b6ac39ed 100755 --- a/src/Build/build_veracrypt_linux.sh +++ b/src/Build/build_veracrypt_linux.sh @@ -1,47 +1,76 @@ # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Absolute path to this script SCRIPT=$(readlink -f "$0") # Absolute path this script is in SCRIPTPATH=$(dirname "$SCRIPT") # source directory which contains the Makefile SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # directory where the VeraCrypt has been checked out PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") # Make sure only root can run our script if [ "$(id -u)" != "0" ]; then echo "VeraCrypt must be built by root" 1>&2 exit 1 fi -# the sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi +fi + +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 cd $SOURCEPATH echo "Building GUI version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildGui -make WXSTATIC=1 wxbuild && make WXSTATIC=1 clean && make WXSTATIC=1 && make WXSTATIC=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -# make WXSTATIC=1 clean && make WXSTATIC=1 && make WXSTATIC=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 wxbuild || exit 1 +fi +make WXSTATIC=1 clean || exit 1 +make WXSTATIC=1 || exit 1 +make WXSTATIC=1 package || exit 1 echo "Building console version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole -make WXSTATIC=1 NOGUI=1 wxbuild && make WXSTATIC=1 NOGUI=1 clean && make WXSTATIC=1 NOGUI=1 && make WXSTATIC=1 NOGUI=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -# make WXSTATIC=1 NOGUI=1 clean && make WXSTATIC=1 NOGUI=1 && make WXSTATIC=1 NOGUI=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 NOGUI=1 wxbuild || exit 1 +fi +make WXSTATIC=1 NOGUI=1 clean || exit 1 +make WXSTATIC=1 NOGUI=1 || exit 1 +make WXSTATIC=1 NOGUI=1 package || exit 1 diff --git a/src/Build/build_veracrypt_linux_gtk3.sh b/src/Build/build_veracrypt_linux_gtk3.sh deleted file mode 100644 index bae6a856..00000000 --- a/src/Build/build_veracrypt_linux_gtk3.sh +++ /dev/null @@ -1,47 +0,0 @@ -# -# Copyright (c) 2013-2022 IDRIX -# 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. -# - -# Absolute path to this script -SCRIPT=$(readlink -f "$0") -# Absolute path this script is in -SCRIPTPATH=$(dirname "$SCRIPT") -# source directory which contains the Makefile -SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") -# directory where the VeraCrypt has been checked out -PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") - -# Make sure only root can run our script -if [ "$(id -u)" != "0" ]; then - echo "VeraCrypt must be built by root" 1>&2 - exit 1 -fi - -# the sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" - -cd $SOURCEPATH - -echo "Building GUI version of VeraCrypt" - -# this will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildGui - -make WXSTATIC=1 WITHGTK3=1 wxbuild && make WXSTATIC=1 clean && make WXSTATIC=1 && make WXSTATIC=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -#make WXSTATIC=1 clean && make WXSTATIC=1 && make WXSTATIC=1 package - -echo "Building console version of VeraCrypt" - -# this will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuildConsole - -make WXSTATIC=1 WITHGTK3=1 NOGUI=1 wxbuild && make WXSTATIC=1 NOGUI=1 clean && make WXSTATIC=1 NOGUI=1 && make WXSTATIC=1 NOGUI=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -#make WXSTATIC=1 NOGUI=1 clean && make WXSTATIC=1 NOGUI=1 && make WXSTATIC=1 NOGUI=1 package diff --git a/src/Build/build_veracrypt_linux_no_sse2.sh b/src/Build/build_veracrypt_linux_no_sse2.sh index f68641b9..6f0739c7 100755 --- a/src/Build/build_veracrypt_linux_no_sse2.sh +++ b/src/Build/build_veracrypt_linux_no_sse2.sh @@ -1,47 +1,76 @@ # -# Copyright (c) 2013-2022 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # # Absolute path to this script SCRIPT=$(readlink -f "$0") # Absolute path this script is in SCRIPTPATH=$(dirname "$SCRIPT") # source directory which contains the Makefile SOURCEPATH=$(readlink -f "$SCRIPTPATH/..") # directory where the VeraCrypt has been checked out PARENTDIR=$(readlink -f "$SCRIPTPATH/../../..") # Make sure only root can run our script if [ "$(id -u)" != "0" ]; then echo "VeraCrypt must be built by root" 1>&2 exit 1 fi -# the sources of wxWidgets 3.2.2.1 must be extracted to the parent directory -export WX_ROOT=$PARENTDIR/wxWidgets-3.2.2.1 -echo "Using wxWidgets sources in $WX_ROOT" +# Check the condition of wxBuildConsole and wxWidgets-3.2.5 in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-3.2.5 is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-3.2.5" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-3.2.5 is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-3.2.5 found in /tmp. Exiting." + exit 1 + fi +fi + +# The sources of wxWidgets 3.2.5 must be extracted to the parent directory +export WX_ROOT=$PARENTDIR/wxWidgets-3.2.5 cd $SOURCEPATH echo "Building GUI version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildGuiNoSSE2 -make WXSTATIC=1 NOSSE2=1 wxbuild && make WXSTATIC=1 NOSSE2=1 clean && make WXSTATIC=1 NOSSE2=1 && make WXSTATIC=1 NOSSE2=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -# make WXSTATIC=1 NOSSE2=1 clean && make WXSTATIC=1 NOSSE2=1 && make WXSTATIC=1 NOSSE2=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 NOSSE2=1 wxbuild || exit 1 +fi +make WXSTATIC=1 NOSSE2=1 clean || exit 1 +make WXSTATIC=1 NOSSE2=1 || exit 1 +make WXSTATIC=1 NOSSE2=1 package || exit 1 echo "Building console version of VeraCrypt" # this will be the temporary wxWidgets directory export WX_BUILD_DIR=$PARENTDIR/wxBuildConsoleNoSSE2 -make WXSTATIC=1 NOGUI=1 NOSSE2=1 wxbuild && make WXSTATIC=1 NOGUI=1 NOSSE2=1 clean && make WXSTATIC=1 NOGUI=1 NOSSE2=1 && make WXSTATIC=1 NOGUI=1 NOSSE2=1 package - -# Uncomment below and comment line above to reuse existing wxWidgets build -# make WXSTATIC=1 NOGUI=1 NOSSE2=1 clean && make WXSTATIC=1 NOGUI=1 NOSSE2=1 && make WXSTATIC=1 NOGUI=1 NOSSE2=1 package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=1 NOGUI=1 NOSSE2=1 wxbuild || exit 1 +fi +make WXSTATIC=1 NOGUI=1 NOSSE2=1 clean || exit 1 +make WXSTATIC=1 NOGUI=1 NOSSE2=1 || exit 1 +make WXSTATIC=1 NOGUI=1 NOSSE2=1 package || exit diff --git a/src/Build/build_veracrypt_macosx.sh b/src/Build/build_veracrypt_macosx.sh index 4636d27d..13302442 100755 --- a/src/Build/build_veracrypt_macosx.sh +++ b/src/Build/build_veracrypt_macosx.sh @@ -1,33 +1,150 @@ +#!/usr/bin/env bash + # -# Copyright (c) 2013-2019 IDRIX +# Copyright (c) 2013-2024 IDRIX # 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. # +# Exit immediately if a command exits with a non-zero status +set -e + # Absolute path this script is in -SCRIPTPATH=$(cd "$(dirname "$0")"; pwd) +SCRIPTPATH=$(cd "$(dirname "$0")" && pwd) # source directory which contains the Makefile -SOURCEPATH=$(cd "$(dirname "$SCRIPTPATH/../.")"; pwd) +SOURCEPATH=$(cd "$(dirname "$SCRIPTPATH/../.")" && pwd) # directory where the VeraCrypt project has been checked out -PARENTDIR=$(cd "$(dirname "$SCRIPTPATH/../../../.")"; pwd) +PARENTDIR=$(cd "$(dirname "$SCRIPTPATH/../../../.")" && pwd) + +# Default wxWidgets version +DEFAULT_WX_VERSION="3.2.5" +WX_VERSION="$DEFAULT_WX_VERSION" + +# Initialize flags +brew=false +package=false +fuset=false +local_build=false + +# Function to display usage information +usage() { + echo "Usage: $0 [options]" + echo "Options:" + echo " -b Use Homebrew to build with precompiled packages" + echo " -p Create a package after building" + echo " -f Build with FUSE-T support" + echo " -l Use local wxWidgets and disable universal binaries" + echo " -v <version> Specify wxWidgets version (default: $DEFAULT_WX_VERSION)" + echo " -h Display this help message" + exit 1 +} + +# Parse command-line options +while getopts "bpflv:h" flag +do + case "${flag}" in + b) brew=true;; + p) package=true;; + f) fuset=true;; + l) local_build=true;; + v) + if [ -z "$OPTARG" ]; then + echo "Error: -v requires a version argument." + usage + fi + WX_VERSION=${OPTARG} + ;; + h) usage;; + *) usage;; + esac +done + +export VC_OSX_FUSET=$([ "$fuset" = true ] && echo 1 || echo 0) + +if [ "$fuset" = true ]; then + echo "Building VeraCrypt with FUSE-T support" +else + echo "Building VeraCrypt with MacFUSE support" +fi + +if [ "$brew" = true ]; then + if ! command -v brew &> /dev/null; then + echo "Homebrew is not installed. Please install Homebrew or run without the -b flag." + exit 1 + fi + + export VC_OSX_SDK=$(xcrun --show-sdk-version) # use the latest version installed, this might fail + export VC_OSX_TARGET=${VC_OSX_SDK} + echo "Using MacOSX SDK $VC_OSX_SDK with target set to $VC_OSX_TARGET" + cd "$SOURCEPATH" + + echo "Building VeraCrypt with precompiled homebrew packages" + cellar=$(brew --cellar "wxwidgets") + version=$(brew list --versions "wxwidgets" | head -1 | awk '{print $2}') + export WX_BUILD_DIR="$cellar/$version/bin" + # skip signing and build only for local arch + export LOCAL_DEVELOPMENT_BUILD=true + # set the correct CPU arch for Makefile + export CPU_ARCH=$(uname -m) + export AS=$(which yasm) + export COMPILE_ASM=$( if [[ "$CPU_ARCH" != "arm64" ]]; then echo true; else echo false; fi ) + make clean + make + if [ "$package" = true ]; then + make package + fi + exit 0 +fi + +if [ "$local_build" = true ]; then + echo "Building VeraCrypt with local wxWidgets support and no universal binary" + export LOCAL_DEVELOPMENT_BUILD=true +fi + +# Check the condition of wxBuildConsole and wxWidgets-$WX_VERSION in the original PARENTDIR +if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxBuildConsole is present." +elif [ -d "$PARENTDIR/wxWidgets-$WX_VERSION" ]; then + echo "Using existing PARENTDIR: $PARENTDIR, wxWidgets-$WX_VERSION is present." +else + # Change PARENTDIR to /tmp and check conditions again + export PARENTDIR="/tmp" + if [ -d "$PARENTDIR/wxBuildConsole" ]; then + echo "Switched to PARENTDIR: /tmp, wxBuildConsole is present in /tmp." + elif [ -d "$PARENTDIR/wxWidgets-$WX_VERSION" ]; then + echo "Switched to PARENTDIR: /tmp, wxWidgets-$WX_VERSION is present in /tmp." + else + echo "Error: Neither wxBuildConsole nor wxWidgets-$WX_VERSION found in /tmp. Exiting." + exit 1 + fi +fi -# the sources of wxWidgets 3.1.2 must be extracted to the parent directory (for night mode) -export WX_ROOT=$PARENTDIR/wxWidgets-3.1.2 -echo "Using wxWidgets sources in $WX_ROOT" +# The sources of wxWidgets $WX_VERSION must be extracted to the parent directory +export WX_ROOT="$PARENTDIR/wxWidgets-$WX_VERSION" # this will be the temporary wxWidgets directory -export WX_BUILD_DIR=$PARENTDIR/wxBuild-3.1.2 +export WX_BUILD_DIR="$PARENTDIR/wxBuild-$WX_VERSION" -# define the SDK version to use and OSX minimum target. We target 10.9 by default -export VC_OSX_TARGET=10.9 -export VC_OSX_SDK=11.3 +# define the SDK version to use and OSX minimum target. We target 12 by default +export VC_OSX_TARGET=12 +export VC_OSX_SDK=$(xcrun --show-sdk-version) #use the latest version installed echo "Using MacOSX SDK $VC_OSX_SDK with target set to $VC_OSX_TARGET" -cd $SOURCEPATH +cd "$SOURCEPATH" echo "Building VeraCrypt" -make WXSTATIC=FULL wxbuild && make WXSTATIC=FULL clean && make WXSTATIC=FULL && make WXSTATIC=FULL package +# Check if wx-config exists in WX_BUILD_DIR +if [ -L "${WX_BUILD_DIR}/wx-config" ]; then + echo "wx-config already exists in ${WX_BUILD_DIR}. Skipping wxbuild." +else + echo "Using wxWidgets sources in $WX_ROOT" + make WXSTATIC=FULL wxbuild +fi +make WXSTATIC=FULL clean +make WXSTATIC=FULL +if [ "$package" = true ]; then + make WXSTATIC=FULL package +fi -# Uncomment below and comment line above to reuse existing wxWidgets build -# make WXSTATIC=FULL clean && make WXSTATIC=FULL && make WXSTATIC=FULL package
\ No newline at end of file +echo "VeraCrypt build completed successfully." diff --git a/src/Build/sign_rpm.sh b/src/Build/sign_rpm.sh new file mode 100644 index 00000000..9abc041e --- /dev/null +++ b/src/Build/sign_rpm.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +# Function to display usage information +usage() { + echo "Usage: $0 <directory>" + exit 1 +} + +# Check if a directory was provided as an argument +if [ $# -ne 1 ]; then + usage +fi + +DIRECTORY="$1" + +# Check if the specified directory exists +if [ ! -d "$DIRECTORY" ]; then + echo "Error: Directory '$DIRECTORY' does not exist." + exit 1 +fi + +# Check if there are any RPM files in the directory +shopt -s nullglob # Make the glob return an empty array if no match +rpm_files=("$DIRECTORY"/*.rpm) + +if [ ${#rpm_files[@]} -eq 0 ]; then + echo "No RPM files found in directory '$DIRECTORY'." + exit 0 +fi + +# Iterate over each RPM file in the directory +for rpm_file in "${rpm_files[@]}"; do + echo "Processing $rpm_file..." + + # Remove the existing signature if any + echo "Removing existing signature from $rpm_file (if any)..." + rpmsign --delsign "$rpm_file" || { + echo "Failed to remove signature from $rpm_file." + exit 1 + } + + # Sign the RPM file + echo "Signing $rpm_file..." + rpmsign --define "_gpg_name veracrypt@idrix.fr" \ + --define "_gpg_digest_algo sha512" \ + --define "_source_filedigest_algorithm 10" \ + --define "_binary_filedigest_algorithm 10" \ + --addsign "$rpm_file" || { + echo "Failed to sign $rpm_file. Aborting." + exit 1 + } + + echo "Successfully signed $rpm_file." +done diff --git a/src/COMReg/COMReg.rc b/src/COMReg/COMReg.rc index 1bfaea38..8c16a632 100644 --- a/src/COMReg/COMReg.rc +++ b/src/COMReg/COMReg.rc @@ -1,82 +1,82 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt COMReg" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt COMReg.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END ///////////////////////////////////////////////////////////////////////////// // // REGISTRY // IDR_COMREG REGISTRY "..\Setup\ComSetup.rgs" ///////////////////////////////////////////////////////////////////////////// // // Icon // // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_COMREG ICON "..\Setup\Setup.ico" #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // diff --git a/src/COMReg/COMReg_vs2019.vcxproj b/src/COMReg/COMReg_vs2019.vcxproj new file mode 100644 index 00000000..b85658ac --- /dev/null +++ b/src/COMReg/COMReg_vs2019.vcxproj @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{C8914211-32AC-4F48-ACD9-8212E8DE53F3}</ProjectGuid> + <Keyword>Win32Proj</Keyword> + <RootNamespace>COMReg</RootNamespace> + <ProjectName>COMReg</ProjectName> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>true</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LinkIncremental>true</LinkIncremental> + <TargetName>VeraCryptCOMRegBase</TargetName> + <OutDir>$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(ConfigurationName)\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <LinkIncremental>false</LinkIncremental> + <TargetName>VeraCryptCOMRegBase</TargetName> + <OutDir>$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(ConfigurationName)\</IntDir> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <WarningLevel>Level3</WarningLevel> + <Optimization>Disabled</Optimization> + <PreprocessorDefinitions>WIN32;VC_COMREG;_DEBUG;_WINDOWS;HAVE_CONFIG_H;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <AdditionalIncludeDirectories>..\Setup;..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <AdditionalDependencies>..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + </Link> + <PostBuildEvent> + <Command>copy Debug\VeraCryptCOMRegBase.exe "..\Debug\Setup Files\VeraCryptCOMRegBase.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <WarningLevel>Level3</WarningLevel> + <PrecompiledHeader>NotUsing</PrecompiledHeader> + <Optimization>MaxSpeed</Optimization> + <FunctionLevelLinking>true</FunctionLevelLinking> + <IntrinsicFunctions>true</IntrinsicFunctions> + <PreprocessorDefinitions>WIN32;VC_COMREG;NDEBUG;_WINDOWS;HAVE_CONFIG_H;ZIP_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <AdditionalIncludeDirectories>..\Setup;..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <ControlFlowGuard>Guard</ControlFlowGuard> + </ClCompile> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <OptimizeReferences>true</OptimizeReferences> + <AdditionalDependencies>..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <GenerateMapFile>true</GenerateMapFile> + </Link> + <PostBuildEvent> + <Command>copy Release\VeraCryptCOMRegBase.exe "..\Release\Setup Files\VeraCryptCOMRegBase.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="..\Common\Crc.c" /> + <ClCompile Include="..\Common\Dlgcode.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Setup\SelfExtract.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Default</CompileAs> + </ClCompile> + <ClCompile Include="COMReg.cpp" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="COMReg.rc" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Crc.h" /> + <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Setup\SelfExtract.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/COMReg/COMReg_vs2019.vcxproj.filters b/src/COMReg/COMReg_vs2019.vcxproj.filters new file mode 100644 index 00000000..cc5c60a3 --- /dev/null +++ b/src/COMReg/COMReg_vs2019.vcxproj.filters @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{453a6bf1-2afd-4016-8b8f-e3821a6c8ab5}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files\Common"> + <UniqueIdentifier>{efcd999c-3973-4bd6-af14-0583669e6722}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="COMReg.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Setup\SelfExtract.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Crc.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="COMReg.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Setup\SelfExtract.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Dlgcode.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Crc.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/COMReg/COMReg_vs2019.vcxproj.user b/src/COMReg/COMReg_vs2019.vcxproj.user new file mode 100644 index 00000000..deea718b --- /dev/null +++ b/src/COMReg/COMReg_vs2019.vcxproj.user @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <LocalDebuggerCommand>$(TargetPath)</LocalDebuggerCommand> + <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> + </PropertyGroup> +</Project>
\ No newline at end of file diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index d8bfc74f..04d69c05 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -139,70 +139,72 @@ #pragma pack (push) #pragma pack(1) typedef struct { int nReturnCode; /* Return code back from driver */ BOOL FilesystemDirty; BOOL VolumeMountedReadOnlyAfterAccessDenied; BOOL VolumeMountedReadOnlyAfterDeviceWriteProtected; wchar_t wszVolume[TC_MAX_PATH]; /* Volume to be mounted */ Password VolumePassword; /* User password */ BOOL bCache; /* Cache passwords in driver */ int nDosDriveNo; /* Drive number to mount */ uint32 BytesPerSector; BOOL bMountReadOnly; /* Mount volume in read-only mode */ BOOL bMountRemovable; /* Mount volume as removable media */ BOOL bExclusiveAccess; /* Open host file/device in exclusive access mode */ BOOL bMountManager; /* Announce volume to mount manager */ BOOL bPreserveTimestamp; /* Preserve file container timestamp */ BOOL bPartitionInInactiveSysEncScope; /* If TRUE, we are to attempt to mount a partition located on an encrypted system drive without pre-boot authentication. */ int nPartitionInInactiveSysEncScopeDriveNo; /* If bPartitionInInactiveSysEncScope is TRUE, this contains the drive number of the system drive on which the partition is located. */ BOOL SystemFavorite; // Hidden volume protection BOOL bProtectHiddenVolume; /* TRUE if the user wants the hidden volume within this volume to be protected against being overwritten (damaged) */ Password ProtectedHidVolPassword; /* Password to the hidden volume to be protected against overwriting */ BOOL UseBackupHeader; BOOL RecoveryMode; int pkcs5_prf; int ProtectedHidVolPkcs5Prf; + BOOL VolumeMountedReadOnlyAfterPartialSysEnc; uint32 BytesPerPhysicalSector; int VolumePim; int ProtectedHidVolPim; wchar_t wszLabel[33]; // maximum label length is 32 for NTFS and 11 for FAT32 BOOL bIsNTFS; // output only BOOL bDriverSetLabel; BOOL bCachePim; ULONG MaximumTransferLength; ULONG MaximumPhysicalPages; ULONG AlignmentMask; + BOOL VolumeMasterKeyVulnerable; } MOUNT_STRUCT; typedef struct { int nDosDriveNo; /* Drive letter to unmount */ BOOL ignoreOpenFiles; BOOL HiddenVolumeProtectionTriggered; int nReturnCode; /* Return code back from driver */ } UNMOUNT_STRUCT; typedef struct { unsigned __int32 ulMountedDrives; /* Bitfield of all mounted drive letters */ wchar_t wszVolume[26][TC_MAX_PATH]; /* Volume names of mounted volumes */ wchar_t wszLabel[26][33]; /* Labels of mounted volumes */ wchar_t volumeID[26][VOLUME_ID_SIZE]; /* IDs of mounted volumes */ unsigned __int64 diskLength[26]; int ea[26]; int volumeType[26]; /* Volume type (e.g. PROP_VOL_TYPE_OUTER, PROP_VOL_TYPE_OUTER_VOL_WRITE_PREVENTED, etc.) */ BOOL reserved[26]; /* needed to keep the same size for the structure so that installer of new version can communicate with installed old version */ } MOUNT_LIST_STRUCT; typedef struct { int driveNo; int uniqueId; wchar_t wszVolume[TC_MAX_PATH]; unsigned __int64 diskLength; int ea; int mode; @@ -288,148 +290,152 @@ typedef struct BOOL DeviceFilterActive; uint16 BootLoaderVersion; BOOL DriveMounted; BOOL VolumeHeaderPresent; BOOL DriveEncrypted; LARGE_INTEGER BootDriveLength; int64 ConfiguredEncryptedAreaStart; int64 ConfiguredEncryptedAreaEnd; int64 EncryptedAreaStart; int64 EncryptedAreaEnd; uint32 VolumeHeaderSaltCrc32; BOOL SetupInProgress; BootEncryptionSetupMode SetupMode; BOOL TransformWaitingForIdle; uint32 HibernationPreventionCount; BOOL HiddenSystem; int64 HiddenSystemPartitionStart; // Number of times the filter driver answered that an unencrypted volume // is read-only (or mounted an outer/normal TrueCrypt volume as read only) uint32 HiddenSysLeakProtectionCount; + BOOL MasterKeyVulnerable; + } BootEncryptionStatus; typedef struct { BootEncryptionSetupMode SetupMode; WipeAlgorithmId WipeAlgorithm; BOOL ZeroUnreadableSectors; BOOL DiscardUnreadableEncryptedSectors; } BootEncryptionSetupRequest; typedef struct { Password VolumePassword; int pkcs5_prf; int pim; } ReopenBootVolumeHeaderRequest; typedef struct { char BootEncryptionAlgorithmName[256]; char BootPrfAlgorithmName[256]; } GetBootEncryptionAlgorithmNameRequest; typedef struct { - byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; + uint8 Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; } BootLoaderFingerprintRequest; typedef struct { wchar_t DevicePath[TC_MAX_PATH]; - byte Configuration; + uint8 Configuration; BOOL DriveIsDynamic; uint16 BootLoaderVersion; - byte UserConfiguration; + uint8 UserConfiguration; char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1]; } GetSystemDriveConfigurationRequest; typedef struct { WipeAlgorithmId WipeAlgorithm; - CRYPTOPP_ALIGN_DATA(16) byte WipeKey[MASTER_KEYDATA_SIZE]; + CRYPTOPP_ALIGN_DATA(16) uint8 WipeKey[MASTER_KEYDATA_SIZE]; } WipeDecoySystemRequest; typedef struct { BOOL WipeInProgress; WipeAlgorithmId WipeAlgorithm; int64 WipedAreaEnd; } DecoySystemWipeStatus; typedef struct { LARGE_INTEGER Offset; - byte Data[TC_SECTOR_SIZE_BIOS]; + uint8 Data[TC_SECTOR_SIZE_BIOS]; } WriteBootDriveSectorRequest; typedef struct { BOOL PagingFileCreationPrevented; BOOL SystemFavoriteVolumeDirty; } GetWarningFlagsRequest; typedef struct { struct _DriveFilterExtension *BootDriveFilterExtension; BOOL HwEncryptionEnabled; } GetSystemDriveDumpConfigRequest; typedef struct { int EncryptionIoRequestCount; int EncryptionItemCount; int EncryptionFragmentSize; } EncryptionQueueParameters; #pragma pack (pop) #define DRIVER_STR WIDE #define TC_UNIQUE_ID_PREFIX "VeraCryptVolume" #define TC_MOUNT_PREFIX L"\\Device\\VeraCryptVolume" #define NT_MOUNT_PREFIX DRIVER_STR("\\Device\\VeraCryptVolume") #define NT_ROOT_PREFIX DRIVER_STR("\\Device\\VeraCrypt") #define DOS_MOUNT_PREFIX_DEFAULT DRIVER_STR("\\DosDevices\\") #define DOS_MOUNT_PREFIX_GLOBAL DRIVER_STR("\\GLOBAL??\\") // Use Global MS-DOS device names for sanity checks on drive letters #define DOS_ROOT_PREFIX DRIVER_STR("\\DosDevices\\VeraCrypt") #define WIN32_ROOT_PREFIX DRIVER_STR("\\\\.\\VeraCrypt") #define TC_DRIVER_CONFIG_REG_VALUE_NAME DRIVER_STR("VeraCryptConfig") #define TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME DRIVER_STR("VeraCryptEncryptionFreeCpuCount") #define VC_ENCRYPTION_IO_REQUEST_COUNT DRIVER_STR("VeraCryptEncryptionIoRequestCount") #define VC_ENCRYPTION_ITEM_COUNT DRIVER_STR("VeraCryptEncryptionItemCount") #define VC_ENCRYPTION_FRAGMENT_SIZE DRIVER_STR("VeraCryptEncryptionFragmentSize") #define VC_ERASE_KEYS_SHUTDOWN DRIVER_STR("VeraCryptEraseKeysShutdown") +#define VC_ENABLE_MEMORY_PROTECTION DRIVER_STR("VeraCryptEnableMemoryProtection") + // WARNING: Modifying the following values can introduce incompatibility with previous versions. #define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD 0x1 #define TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD_FOR_SYS_FAVORITES 0x2 #define TC_DRIVER_CONFIG_DISABLE_NONADMIN_SYS_FAVORITES_ACCESS 0x4 #define TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION 0x8 #define TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL 0x10 #define TC_DRIVER_CONFIG_DISABLE_EVIL_MAID_ATTACK_DETECTION 0x20 #define TC_DRIVER_CONFIG_CACHE_BOOT_PIM 0x40 #define VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM 0x80 #define VC_DRIVER_CONFIG_BLOCK_SYS_TRIM 0x100 #define VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAG 0x200 #define VC_DRIVER_CONFIG_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION 0x400 #define VC_DRIVER_CONFIG_ENABLE_CPU_RNG 0x800 #define VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION 0x1000 #endif /* _WIN32 */ diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp index dde4b55d..25c70963 100644 --- a/src/Common/BaseCom.cpp +++ b/src/Common/BaseCom.cpp @@ -423,77 +423,82 @@ DWORD BaseCom::GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKe catch (SystemException &) { return GetLastError(); } catch (Exception &e) { e.Show (NULL); return ERROR_EXCEPTION_IN_SERVICE; } catch (...) { return ERROR_EXCEPTION_IN_SERVICE; } return ERROR_SUCCESS; } DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) { if (!customUserMessage) return ERROR_INVALID_PARAMETER; try { DWORD maxSize = ((DWORD *) ((BYTE *) customUserMessage))[-1]; char* msg = (char*) *customUserMessage; if (maxSize > 0) msg [maxSize - 1] = 0; std::string msgStr = maxSize > 0 ? msg : ""; BootEncryption bootEnc (NULL); - bootEnc.WriteEfiBootSectorUserConfig ((byte) userConfig, msgStr, pim, hashAlg); + bootEnc.WriteEfiBootSectorUserConfig ((uint8) userConfig, msgStr, pim, hashAlg); } catch (SystemException &) { return GetLastError(); } catch (Exception &e) { e.Show (NULL); return ERROR_EXCEPTION_IN_SERVICE; } catch (...) { return ERROR_EXCEPTION_IN_SERVICE; } return ERROR_SUCCESS; } DWORD BaseCom::UpdateSetupConfigFile (BOOL bForInstall) { try { BootEncryption bootEnc (NULL); bootEnc.UpdateSetupConfigFile (bForInstall? true : false); } catch (SystemException &) { return GetLastError(); } catch (Exception &e) { e.Show (NULL); return ERROR_EXCEPTION_IN_SERVICE; } catch (...) { return ERROR_EXCEPTION_IN_SERVICE; } return ERROR_SUCCESS; } DWORD BaseCom::NotifyService(DWORD dwNotifyCode) { return SendServiceNotification(dwNotifyCode); } + +DWORD BaseCom::FastFileResize (BSTR filePath, __int64 fileSize) +{ + return ::FastResizeFile (filePath, fileSize); +} diff --git a/src/Common/BaseCom.h b/src/Common/BaseCom.h index 937e37ec..431b0257 100644 --- a/src/Common/BaseCom.h +++ b/src/Common/BaseCom.h @@ -93,38 +93,39 @@ public: protected: DWORD MessageThreadId; LONG RefCount; LONG ServerLockCount; }; class BaseCom { public: static DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output); static DWORD CopyFile (BSTR sourceFile, BSTR destinationFile); static DWORD DeleteFile (BSTR file); static BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); static DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone); static DWORD RegisterFilterDriver (BOOL registerDriver, int filterType); static DWORD RegisterSystemFavoritesService (BOOL registerService); static DWORD SetDriverServiceStartType (DWORD startType); static DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value); static DWORD GetFileSize (BSTR filePath, unsigned __int64 *pSize); static DWORD DeviceIoControl (BOOL readOnly, BOOL device, BSTR filePath, DWORD dwIoControlCode, BSTR input, BSTR *output); static DWORD InstallEfiBootLoader (BOOL preserveUserConfig, BOOL hiddenOSCreation, int pim, int hashAlg); static DWORD BackupEfiSystemLoader (); static DWORD RestoreEfiSystemLoader (); static DWORD GetEfiBootDeviceNumber (BSTR* pSdn); static DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); static DWORD UpdateSetupConfigFile (BOOL bForInstall); static DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded); static DWORD NotifyService (DWORD dwNotifyCode); + static DWORD FastFileResize (BSTR filePath, __int64 fileSize); }; BOOL ComGetInstanceBase (HWND hWnd, REFCLSID clsid, REFIID iid, void **tcServer); HRESULT CreateElevatedComObject (HWND hwnd, REFGUID guid, REFIID iid, void **ppv); #endif // TC_HEADER_BASE_COM diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index 189d5a78..f79e7339 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -248,64 +248,64 @@ static unsigned char g_pbEFIDcsKEK[1137] = { 0x0D, 0xC3, 0x9F, 0xEA, 0x37, 0x7B, 0xCB, 0xC3, 0x65, 0x8D, 0x71, 0xBA, 0x97, 0xA8, 0x4F, 0x69, 0x25, 0x36, 0x1D, 0x7F, 0x08, 0x54, 0xB2, 0x9A, 0x56, 0xA0, 0x8B, 0x2F, 0xBC, 0x77, 0x16, 0x89, 0xBF, 0x5C, 0xB0, 0xD2, 0xB1, 0xDA, 0x3C, 0x08, 0xD1, 0x8A, 0xC5, 0xB5, 0xA0, 0xED, 0xD1, 0xDF, 0xB1, 0xAE, 0x5F, 0x82, 0x26, 0xA4, 0x0A, 0x12, 0x1E, 0x1F, 0x18, 0x7D, 0x9E, 0x57, 0xE1, 0xA4, 0xCC, 0x90, 0x15, 0x79, 0xC9, 0x19, 0x95, 0x98, 0xCB, 0x86, 0x75, 0xC1, 0x45, 0x67, 0xD8, 0x1D, 0x02, 0x84, 0xC6, 0xF3, 0x50, 0xD7, 0xB8, 0xAB, 0x92, 0xD2, 0x4E, 0xFB, 0xA0, 0xFF, 0x28, 0xB5, 0x69, 0x17, 0xFD, 0xA9, 0x18, 0x07, 0xAB, 0xD3, 0xCD, 0x3A, 0xE7, 0xE7, 0x54, 0x61, 0x6B, 0x73, 0x88, 0xF0, 0xD9, 0xB9, 0xD6 }; bool ZipAdd (zip_t *z, const char* name, const unsigned char* pbData, DWORD cbData) { zip_error_t zerr; zip_source_t* zin = zip_source_buffer_create (pbData, cbData, 0, &zerr); if (!zin) return false; if (-1 == zip_file_add (z, name, zin, 0)) { zip_source_free (zin); return false; } return true; } -static BOOL IsWindowsMBR (const byte *buffer, size_t bufferSize) +static BOOL IsWindowsMBR (const uint8 *buffer, size_t bufferSize) { BOOL bRet = FALSE; - byte g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0}; + uint8 g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0}; const char* g_szStr1 = "Invalid partition table"; const char* g_szStr2 = "Error loading operating system"; const char* g_szStr3 = "Missing operating system"; if ((0 == memcmp (buffer, g_pbMsSignature, 4)) && (BufferContainsString (buffer, bufferSize, g_szStr1) || BufferContainsString (buffer, bufferSize, g_szStr2) || BufferContainsString (buffer, bufferSize, g_szStr3) ) ) { bRet = TRUE; } return bRet; } namespace VeraCrypt { #if !defined (SETUP) class Elevator { public: static void AddReference () { ++ReferenceCount; } @@ -363,61 +363,61 @@ namespace VeraCrypt if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } static void DeleteFile (const wstring &file) { Elevate(); CComBSTR fileBstr; DWORD result; BSTR bstr = W2BSTR(file.c_str()); if (bstr) { fileBstr.Attach (bstr); result = ElevatedComInstance->DeleteFile (fileBstr); } else { result = ERROR_OUTOFMEMORY; } if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } - static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) + static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { Elevate(); DWORD result; CComBSTR bufferBstr, fileBstr; if (bufferBstr.AppendBytes ((const char *) buffer, size) != S_OK) throw ParameterIncorrect (SRC_POS); BSTR bstr = W2BSTR(filePath.c_str()); if (bstr) { fileBstr.Attach (bstr); result = ElevatedComInstance->ReadWriteFile (write, device, fileBstr, &bufferBstr, offset, size, sizeDone); } else { result = ERROR_OUTOFMEMORY; } if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } if (!write) memcpy (buffer, (BYTE *) bufferBstr.m_str, size); } static void GetFileSize (const wstring &filePath, unsigned __int64* pSize) { @@ -604,61 +604,61 @@ namespace VeraCrypt { SetLastError (ERROR_INVALID_PARAMETER); throw SystemException(SRC_POS); } DWORD result = ElevatedComInstance->GetEfiBootDeviceNumber (&outputBstr); if (pSdn) memcpy (pSdn, *(void **) &outputBstr, sizeof (STORAGE_DEVICE_NUMBER)); if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { Elevate(); DWORD result = ElevatedComInstance->GetSecureBootConfig (pSecureBootEnabled, pVeraCryptKeysLoaded); if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } - static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) + static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { Elevate(); DWORD result; CComBSTR customUserMessageBstr; BSTR bstr = A2BSTR(customUserMessage.c_str()); if (bstr) { customUserMessageBstr.Attach (bstr); result = ElevatedComInstance->WriteEfiBootSectorUserConfig ((DWORD) userConfig, customUserMessageBstr, pim, hashAlg); } else { result = ERROR_OUTOFMEMORY; } if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } static void UpdateSetupConfigFile (bool bForInstall) { Elevate(); DWORD result = ElevatedComInstance->UpdateSetupConfigFile (bForInstall ? TRUE : FALSE); if (result != ERROR_SUCCESS) { @@ -685,145 +685,145 @@ namespace VeraCrypt { ElevatedComInstance->Release(); ElevatedComInstance = nullptr; CoUninitialize (); } } static void SetDriverServiceStartType (DWORD startType) { Elevate(); DWORD result = ElevatedComInstance->SetDriverServiceStartType (startType); if (result != ERROR_SUCCESS) { SetLastError (result); throw SystemException(SRC_POS); } } protected: static void Elevate () { if (IsAdmin()) { SetLastError (ERROR_ACCESS_DENIED); throw SystemException(SRC_POS); } if (!ElevatedComInstance || ElevatedComInstanceThreadId != GetCurrentThreadId()) { - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); ElevatedComInstance = GetElevatedInstance (GetActiveWindow() ? GetActiveWindow() : MainDlg); ElevatedComInstanceThreadId = GetCurrentThreadId(); } } #if defined (TCMOUNT) static ITrueCryptMainCom *ElevatedComInstance; #elif defined (VOLFORMAT) static ITrueCryptFormatCom *ElevatedComInstance; #endif static DWORD ElevatedComInstanceThreadId; static int ReferenceCount; }; #if defined (TCMOUNT) ITrueCryptMainCom *Elevator::ElevatedComInstance; #elif defined (VOLFORMAT) ITrueCryptFormatCom *Elevator::ElevatedComInstance; #endif DWORD Elevator::ElevatedComInstanceThreadId; int Elevator::ReferenceCount = 0; #else // SETUP class Elevator { public: static void AddReference () { } static void CallDriver (DWORD ioctl, void *input, DWORD inputSize, void *output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); } - static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); } + static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); } static void RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType) { throw ParameterIncorrect (SRC_POS); } static void Release () { } static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); } static void GetFileSize (const wstring &filePath, unsigned __int64 *pSize) { throw ParameterIncorrect (SRC_POS); } static BOOL DeviceIoControl (BOOL readOnly, BOOL device, const wstring &filePath, DWORD dwIoControlCode, LPVOID input, DWORD inputSize, LPVOID output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); } static void InstallEfiBootLoader (bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); } static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); } static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); } - static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); } + static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); } static void UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); } static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { throw ParameterIncorrect (SRC_POS); } }; #endif // SETUP File::File (wstring path, bool readOnly, bool create) : Elevated (false), FileOpen (false), ReadOnly (readOnly), LastError(0) { Handle = CreateFile (path.c_str(), readOnly ? GENERIC_READ : GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, create ? CREATE_ALWAYS : OPEN_EXISTING, FILE_FLAG_RANDOM_ACCESS | FILE_FLAG_WRITE_THROUGH, NULL); if (Handle != INVALID_HANDLE_VALUE) { FileOpen = true; } else { LastError = GetLastError(); if (LastError == ERROR_ACCESS_DENIED && IsUacSupported()) { Elevated = true; FileOpen = true; } } FilePointerPosition = 0; IsDevice = false; Path = path; } void File::Close () { if (Handle != INVALID_HANDLE_VALUE) { CloseHandle (Handle); Handle = INVALID_HANDLE_VALUE; } FileOpen = false; } - DWORD File::Read (byte *buffer, DWORD size) + DWORD File::Read (uint8 *buffer, DWORD size) { DWORD bytesRead; if (!FileOpen) { SetLastError (LastError); throw SystemException (SRC_POS); } if (Elevated) { Elevator::ReadWriteFile (false, IsDevice, Path, buffer, FilePointerPosition, size, &bytesRead); FilePointerPosition += bytesRead; return bytesRead; } if (!ReadFile (Handle, buffer, size, &bytesRead, NULL)) { DWORD dwLastError = GetLastError(); if ((dwLastError == ERROR_INVALID_PARAMETER) && IsDevice && (size % 4096)) { DWORD remainingSize = (size % 4096); DWORD alignedSize = size - remainingSize; LARGE_INTEGER offset; if (alignedSize) { if (ReadFile (Handle, buffer, alignedSize, &bytesRead, NULL)) { if (bytesRead < alignedSize) @@ -874,61 +874,61 @@ namespace VeraCrypt } void File::GetFileSize (unsigned __int64& size) { if (!FileOpen) { SetLastError (LastError); throw SystemException (SRC_POS); } if (Elevated) { Elevator::GetFileSize (Path, &size); } else { LARGE_INTEGER lSize; lSize.QuadPart = 0; throw_sys_if (!GetFileSizeEx (Handle, &lSize)); size = (unsigned __int64) lSize.QuadPart; } } void File::GetFileSize (DWORD& dwSize) { unsigned __int64 size64; GetFileSize (size64); dwSize = (DWORD) size64; } - void File::Write (byte *buffer, DWORD size) + void File::Write (uint8 *buffer, DWORD size) { DWORD bytesWritten; if (!FileOpen) { SetLastError (LastError); throw SystemException (SRC_POS); } try { if (Elevated) { Elevator::ReadWriteFile (true, IsDevice, Path, buffer, FilePointerPosition, size, &bytesWritten); FilePointerPosition += bytesWritten; throw_sys_if (bytesWritten != size); } else { if (!WriteFile (Handle, buffer, size, &bytesWritten, NULL)) { DWORD dwLastError = GetLastError (); if ((ERROR_INVALID_PARAMETER == dwLastError) && IsDevice && !ReadOnly && (size % 4096)) { bool bSuccess = false; DWORD remainingSize = (size % 4096); DWORD alignedSize = size - remainingSize; DWORD bytesRead = 0; bytesWritten = 0; if (alignedSize) @@ -1121,61 +1121,61 @@ namespace VeraCrypt } } // Finds the first partition physically located behind the active one and returns its properties Partition BootEncryption::GetPartitionForHiddenOS () { Partition candidatePartition; memset (&candidatePartition, 0, sizeof(candidatePartition)); // The user may have modified/added/deleted partitions since the time the partition table was last scanned InvalidateCachedSysDriveProperties(); SystemDriveConfiguration config = GetSystemDriveConfiguration (); bool activePartitionFound = false; bool candidateForHiddenOSFound = false; 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 foreach (const Partition &partition, config.Partitions) { if (partition.Info.BootIndicator) { if (partition.Info.PartitionNumber != config.SystemPartition.Number) { // If there is an extra boot partition, the system partition must be located right behind it - if (IsOSAtLeast (WIN_7) && config.ExtraBootPartitionPresent) + if (config.ExtraBootPartitionPresent) { int64 minOffsetFound = config.DrivePartition.Info.PartitionLength.QuadPart; Partition bootPartition = partition; Partition partitionBehindBoot; foreach (const Partition &partition, config.Partitions) { if (partition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart && partition.Info.StartingOffset.QuadPart < minOffsetFound) { minOffsetFound = partition.Info.StartingOffset.QuadPart; partitionBehindBoot = partition; } } if (minOffsetFound != config.DrivePartition.Info.PartitionLength.QuadPart && partitionBehindBoot.Number == config.SystemPartition.Number) { activePartitionFound = true; break; } } throw ErrorException (wstring (GetString ("SYSTEM_PARTITION_NOT_ACTIVE")) + GetRemarksOnHiddenOS(), SRC_POS); } activePartitionFound = true; break; } @@ -1249,86 +1249,63 @@ namespace VeraCrypt wstring BootEncryption::GetRemarksOnHiddenOS () { return (wstring (L"\n\n") + GetString ("TWO_SYSTEMS_IN_ONE_PARTITION_REMARK") + L"\n\n" + GetString ("FOR_MORE_INFO_ON_PARTITIONS")); } void BootEncryption::SetDriverServiceStartType (DWORD startType) { if (!IsAdmin() && IsUacSupported()) { Elevator::SetDriverServiceStartType (startType); return; } BOOL startOnBoot = (startType == SERVICE_BOOT_START); SC_HANDLE serviceManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS); throw_sys_if (!serviceManager); finally_do_arg (SC_HANDLE, serviceManager, { CloseServiceHandle (finally_arg); }); SC_HANDLE service = OpenService (serviceManager, L"veracrypt", SERVICE_CHANGE_CONFIG); throw_sys_if (!service); finally_do_arg (SC_HANDLE, service, { CloseServiceHandle (finally_arg); }); - // Windows versions preceding Vista can be installed on FAT filesystem which does not - // support long filenames during boot. Convert the driver path to short form if required. - wstring driverPath; - if (startOnBoot && !IsOSAtLeast (WIN_VISTA)) - { - wchar_t pathBuf[MAX_PATH]; - wchar_t filesystem[128]; - - wstring path (GetWindowsDirectory()); - path += L"\\drivers\\veracrypt.sys"; - - if (GetVolumePathName (path.c_str(), pathBuf, ARRAYSIZE (pathBuf)) - && GetVolumeInformation (pathBuf, NULL, 0, NULL, NULL, NULL, filesystem, ARRAYSIZE(filesystem)) - && wmemcmp (filesystem, L"FAT", 3) == 0) - { - throw_sys_if (GetShortPathName (path.c_str(), pathBuf, ARRAYSIZE (pathBuf)) == 0); - - // Convert absolute path to relative to the Windows directory - driverPath = pathBuf; - driverPath = driverPath.substr (driverPath.rfind (L"\\", driverPath.rfind (L"\\", driverPath.rfind (L"\\") - 1) - 1) + 1); - } - } - throw_sys_if (!ChangeServiceConfig (service, SERVICE_NO_CHANGE, SERVICE_NO_CHANGE, startOnBoot ? SERVICE_ERROR_SEVERE : SERVICE_ERROR_NORMAL, - driverPath.empty() ? NULL : driverPath.c_str(), + NULL, startOnBoot ? L"Filter" : NULL, NULL, NULL, NULL, NULL, NULL)); // ChangeServiceConfig() rejects SERVICE_BOOT_START with ERROR_INVALID_PARAMETER throw_sys_if (!WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", L"Start", startType)); } void BootEncryption::ProbeRealSystemDriveSize () { if (RealSystemDriveSizeValid) return; GetSystemDriveConfiguration(); 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; RealSystemDriveSizeValid = true; if (request.TimeOut) throw TimeOut (SRC_POS); } void BootEncryption::InvalidateCachedSysDriveProperties () { @@ -1419,170 +1396,171 @@ namespace VeraCrypt #ifndef SETUP DISK_GEOMETRY_EX BootEncryption::GetDriveGeometry (int driveNumber) { wstringstream devName; devName << L"\\Device\\Harddisk" << driveNumber << L"\\Partition0"; DISK_GEOMETRY_EX geometry; throw_sys_if (!::GetDriveGeometry (devName.str().c_str(), &geometry)); return geometry; } #endif // !SETUP wstring BootEncryption::GetWindowsDirectory () { wchar_t buf[MAX_PATH]; throw_sys_if (GetSystemDirectory (buf, ARRAYSIZE (buf)) == 0); return wstring (buf); } uint16 BootEncryption::GetInstalledBootLoaderVersion () { uint16 version; CallDriver (TC_IOCTL_GET_BOOT_LOADER_VERSION, NULL, 0, &version, sizeof (version)); return version; } - void BootEncryption::GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]) + void BootEncryption::GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]) { BootLoaderFingerprintRequest request; CallDriver (VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT, NULL, 0, &request, sizeof (request)); memcpy (fingerprint, request.Fingerprint, sizeof (request.Fingerprint)); } #ifndef SETUP // Note that this does not require admin rights (it just requires the driver to be running) bool BootEncryption::IsBootLoaderOnDrive (wchar_t *devicePath) { try { OPEN_TEST_STRUCT openTestStruct; memset (&openTestStruct, 0, sizeof (openTestStruct)); DWORD dwResult; StringCchCopyW (&openTestStruct.wszFileName[0], ARRAYSIZE(openTestStruct.wszFileName),devicePath); openTestStruct.bDetectTCBootLoader = TRUE; return (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected); } catch (...) { return false; } } #endif BootEncryptionStatus BootEncryption::GetStatus () { /* IMPORTANT: Do NOT add any potentially time-consuming operations to this function. */ BootEncryptionStatus status; + memset (&status, 0, sizeof(status)); CallDriver (TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS, NULL, 0, &status, sizeof (status)); return status; } void BootEncryption::GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties) { if (properties == NULL) throw ParameterIncorrect (SRC_POS); CallDriver (TC_IOCTL_GET_BOOT_DRIVE_VOLUME_PROPERTIES, NULL, 0, properties, sizeof (*properties)); } bool BootEncryption::IsHiddenSystemRunning () { int hiddenSystemStatus; CallDriver (TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING, nullptr, 0, &hiddenSystemStatus, sizeof (hiddenSystemStatus)); return hiddenSystemStatus != 0; } - bool BootEncryption::SystemDriveContainsPartitionType (byte type) + bool BootEncryption::SystemDriveContainsPartitionType (uint8 type) { Device device (GetSystemDriveConfiguration().DevicePath, true); device.CheckOpened (SRC_POS); - byte mbrBuf[TC_SECTOR_SIZE_BIOS]; + uint8 mbrBuf[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbrBuf, sizeof (mbrBuf)); MBR *mbr = reinterpret_cast <MBR *> (mbrBuf); if (mbr->Signature != 0xaa55) throw ParameterIncorrect (SRC_POS); for (size_t i = 0; i < array_capacity (mbr->Partitions); ++i) { if (mbr->Partitions[i].Type == type) return true; } return false; } bool BootEncryption::SystemDriveContainsExtendedPartition () { return SystemDriveContainsPartitionType (PARTITION_EXTENDED) || SystemDriveContainsPartitionType (PARTITION_XINT13_EXTENDED); } bool BootEncryption::SystemDriveContainsNonStandardPartitions () { for (int partitionType = 1; partitionType <= 0xff; ++partitionType) { switch (partitionType) { case PARTITION_FAT_12: case PARTITION_FAT_16: case PARTITION_EXTENDED: case PARTITION_HUGE: case PARTITION_IFS: case PARTITION_FAT32: case PARTITION_FAT32_XINT13: case PARTITION_XINT13: case PARTITION_XINT13_EXTENDED: continue; } - if (SystemDriveContainsPartitionType ((byte) partitionType)) + if (SystemDriveContainsPartitionType ((uint8) partitionType)) return true; } return false; } bool BootEncryption::SystemDriveIsDynamic () { GetSystemDriveConfigurationRequest request; memset (&request, 0, sizeof (request)); StringCchCopyW (request.DevicePath, ARRAYSIZE (request.DevicePath), GetSystemDriveConfiguration().DeviceKernelPath.c_str()); CallDriver (TC_IOCTL_GET_SYSTEM_DRIVE_CONFIG, &request, sizeof (request), &request, sizeof (request)); return request.DriveIsDynamic ? true : false; } SystemDriveConfiguration BootEncryption::GetSystemDriveConfiguration () { if (DriveConfigValid) return DriveConfig; SystemDriveConfiguration config; wstring winDir = GetWindowsDirectory(); // Scan all drives for (int driveNumber = 0; driveNumber < 32; ++driveNumber) { @@ -1634,127 +1612,129 @@ namespace VeraCrypt config.DrivePartition = partitions.front(); partitions.pop_front(); config.Partitions = partitions; config.InitialUnallocatedSpace = 0x7fffFFFFffffFFFFull; config.TotalUnallocatedSpace = config.DrivePartition.Info.PartitionLength.QuadPart; foreach (const Partition &part, config.Partitions) { if (part.Info.StartingOffset.QuadPart < config.InitialUnallocatedSpace) config.InitialUnallocatedSpace = part.Info.StartingOffset.QuadPart; config.TotalUnallocatedSpace -= part.Info.PartitionLength.QuadPart; } DriveConfig = config; DriveConfigValid = true; return DriveConfig; } } throw ParameterIncorrect (SRC_POS); } bool BootEncryption::SystemPartitionCoversWholeDrive () { SystemDriveConfiguration config = GetSystemDriveConfiguration(); - if (IsOSAtLeast (WIN_7) - && config.Partitions.size() == 2 + if (config.Partitions.size() == 2 && config.ExtraBootPartitionPresent && config.DrivePartition.Info.PartitionLength.QuadPart - config.SystemPartition.Info.PartitionLength.QuadPart < 164 * BYTES_PER_MB) { return true; } return config.Partitions.size() == 1 && config.DrivePartition.Info.PartitionLength.QuadPart - config.SystemPartition.Info.PartitionLength.QuadPart < 64 * BYTES_PER_MB; } - uint32 BootEncryption::GetChecksum (byte *data, size_t size) + uint32 BootEncryption::GetChecksum (uint8 *data, size_t size) { uint32 sum = 0; while (size-- > 0) { sum += *data++; sum = _rotl (sum, 1); } return sum; } - void BootEncryption::CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation) + void BootEncryption::CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation) { if (bufferSize < TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE) throw ParameterIncorrect (SRC_POS); ZeroMemory (buffer, bufferSize); int ea = 0; int pkcs5_prf = 0; BOOL bIsGPT = GetSystemDriveConfiguration().SystemPartition.IsGPT; if (GetStatus().DriveMounted) { try { GetBootEncryptionAlgorithmNameRequest request; // since we added new field to GetBootEncryptionAlgorithmNameRequest since version 1.0f // we zero all the structure so that if we are talking to an older driver, the field // BootPrfAlgorithmName will be an empty string ZeroMemory(&request, sizeof(request)); CallDriver (TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME, NULL, 0, &request, sizeof (request)); if (_stricmp (request.BootEncryptionAlgorithmName, "AES") == 0) ea = AES; - else if (_stricmp (request.BootEncryptionAlgorithmName, "Serpent") == 0) + #ifndef WOLFCRYPT_BACKEND + else if (_stricmp (request.BootEncryptionAlgorithmName, "Camellia") == 0) + ea = CAMELLIA; + else if (_stricmp (request.BootEncryptionAlgorithmName, "Serpent") == 0) ea = SERPENT; else if (_stricmp (request.BootEncryptionAlgorithmName, "Twofish") == 0) ea = TWOFISH; - else if (_stricmp (request.BootEncryptionAlgorithmName, "Camellia") == 0) - ea = CAMELLIA; - + #endif if (_stricmp(request.BootPrfAlgorithmName, "SHA-256") == 0) pkcs5_prf = SHA256; - else if (_stricmp(request.BootPrfAlgorithmName, "BLAKE2s-256") == 0) - pkcs5_prf = BLAKE2S; - else if (_stricmp(request.BootPrfAlgorithmName, "SHA-512") == 0) + else if (_stricmp(request.BootPrfAlgorithmName, "SHA-512") == 0) pkcs5_prf = SHA512; + #ifndef WOLFCRYPT_BACKEND + else if (_stricmp(request.BootPrfAlgorithmName, "BLAKE2s-256") == 0) + pkcs5_prf = BLAKE2S; else if (_stricmp(request.BootPrfAlgorithmName, "Whirlpool") == 0) pkcs5_prf = WHIRLPOOL; else if (_stricmp(request.BootPrfAlgorithmName, "Streebog") == 0) pkcs5_prf = STREEBOG; + #endif else if (strlen(request.BootPrfAlgorithmName) == 0) // case of version < 1.0f pkcs5_prf = BLAKE2S; } catch (...) { try { VOLUME_PROPERTIES_STRUCT properties; GetVolumeProperties (&properties); ea = properties.ea; pkcs5_prf = properties.pkcs5; } catch (...) { } } if (pkcs5_prf == 0) throw ParameterIncorrect (SRC_POS); } else { if (SelectedEncryptionAlgorithmId == 0 || SelectedPrfAlgorithmId == 0) throw ParameterIncorrect (SRC_POS); ea = SelectedEncryptionAlgorithmId; pkcs5_prf = SelectedPrfAlgorithmId; } // Only BLAKE2s and SHA-256 are supported for MBR boot loader if (!bIsGPT && pkcs5_prf != BLAKE2S && pkcs5_prf != SHA256) throw ParameterIncorrect (SRC_POS); @@ -1803,122 +1783,121 @@ namespace VeraCrypt case TWOFISH: if (pkcs5_prf == SHA256) { bootSectorId = rescueDisk ? IDR_RESCUE_BOOT_SECTOR_TWOFISH_SHA2 : IDR_BOOT_SECTOR_TWOFISH_SHA2; bootLoaderId = rescueDisk ? IDR_RESCUE_LOADER_TWOFISH_SHA2 : IDR_BOOT_LOADER_TWOFISH_SHA2; } else { bootSectorId = rescueDisk ? IDR_RESCUE_BOOT_SECTOR_TWOFISH : IDR_BOOT_SECTOR_TWOFISH; bootLoaderId = rescueDisk ? IDR_RESCUE_LOADER_TWOFISH : IDR_BOOT_LOADER_TWOFISH; } break; case CAMELLIA: if (pkcs5_prf == SHA256) { bootSectorId = rescueDisk ? IDR_RESCUE_BOOT_SECTOR_CAMELLIA_SHA2 : IDR_BOOT_SECTOR_CAMELLIA_SHA2; bootLoaderId = rescueDisk ? IDR_RESCUE_LOADER_CAMELLIA_SHA2 : IDR_BOOT_LOADER_CAMELLIA_SHA2; } else { bootSectorId = rescueDisk ? IDR_RESCUE_BOOT_SECTOR_CAMELLIA : IDR_BOOT_SECTOR_CAMELLIA; bootLoaderId = rescueDisk ? IDR_RESCUE_LOADER_CAMELLIA : IDR_BOOT_LOADER_CAMELLIA; } break; } // Boot sector DWORD size; - byte *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size); + uint8 *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size); if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS) throw ParameterIncorrect (SRC_POS); memcpy (buffer, bootSecResourceImg, size); *(uint16 *) (buffer + TC_BOOT_SECTOR_VERSION_OFFSET) = BE16 (VERSION_NUM); - if (IsOSAtLeast (WIN_VISTA)) - buffer[TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER; + buffer[TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_WINDOWS_VISTA_OR_LATER; if (rescueDisk && (ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION)) buffer[TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_RESCUE_DISABLE_HW_ENCRYPTION; // Checksum of the backup header of the outer volume for the hidden system if (hiddenOSCreation) { Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); - byte headerSector[TC_SECTOR_SIZE_BIOS]; + uint8 headerSector[TC_SECTOR_SIZE_BIOS]; device.SeekAt (HiddenOSCandidatePartition.Info.StartingOffset.QuadPart + HiddenOSCandidatePartition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_GROUP_SIZE + TC_VOLUME_HEADER_EFFECTIVE_SIZE); device.Read (headerSector, sizeof (headerSector)); *(uint32 *) (buffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET) = GetCrc32 (headerSector, sizeof (headerSector)); } // Decompressor - byte *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size); + uint8 *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size); if (!decompressor || size > TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) throw ParameterIncorrect (SRC_POS); memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size); // Compressed boot loader - byte *bootLoader = MapResource (L"BIN", bootLoaderId, &size); + uint8 *bootLoader = MapResource (L"BIN", bootLoaderId, &size); if (!bootLoader || size > TC_MAX_BOOT_LOADER_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) throw ParameterIncorrect (SRC_POS); memcpy (buffer + TC_SECTOR_SIZE_BIOS + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS, bootLoader, size); // Boot loader and decompressor checksum *(uint16 *) (buffer + TC_BOOT_SECTOR_LOADER_LENGTH_OFFSET) = static_cast <uint16> (size); *(uint32 *) (buffer + TC_BOOT_SECTOR_LOADER_CHECKSUM_OFFSET) = GetChecksum (buffer + TC_SECTOR_SIZE_BIOS, TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS + size); // Backup of decompressor and boot loader if (size + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS <= TC_BOOT_LOADER_BACKUP_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS) { memcpy (buffer + TC_SECTOR_SIZE_BIOS + TC_BOOT_LOADER_BACKUP_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS, buffer + TC_SECTOR_SIZE_BIOS, TC_BOOT_LOADER_BACKUP_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS); buffer[TC_BOOT_SECTOR_CONFIG_OFFSET] |= TC_BOOT_CFG_FLAG_BACKUP_LOADER_AVAILABLE; } else if (!rescueDisk && bootLoaderId != IDR_BOOT_LOADER && bootLoaderId != IDR_BOOT_LOADER_SHA2) { throw ParameterIncorrect (SRC_POS); } } // return false when the user cancel an elevation request - bool BootEncryption::ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig, string *customUserMessage, uint16 *bootLoaderVersion) + bool BootEncryption::ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig, string *customUserMessage, uint16 *bootLoaderVersion) { bool bCanceled = false, bExceptionOccured = false; try { if (GetSystemDriveConfiguration().SystemPartition.IsGPT) { // for now, we don't support any boot config flags, like hidden OS one if (config) memset (config, 0, bufLength); // call ReadESPFile only when needed since it requires elevation if (userConfig || customUserMessage || bootLoaderVersion) { std::string confContent = ReadESPFile (L"\\EFI\\VeraCrypt\\DcsProp", true); EfiBootConf conf; conf.Load ((char*) confContent.c_str()); if (userConfig) { *userConfig = 0; if (!conf.requestPim) *userConfig |= TC_BOOT_USER_CFG_FLAG_DISABLE_PIM; if (!conf.requestHash) *userConfig |= TC_BOOT_USER_CFG_FLAG_STORE_HASH; } if (customUserMessage) customUserMessage->clear(); @@ -1957,176 +1936,176 @@ namespace VeraCrypt } catch (UserAbort&) { bCanceled = true; bExceptionOccured= true; } catch (...) { bExceptionOccured = true; } if (bExceptionOccured) { if (config) *config = 0; if (userConfig) *userConfig = 0; if (customUserMessage) customUserMessage->clear(); if (bootLoaderVersion) *bootLoaderVersion = 0; } return !bCanceled; } - void BootEncryption::WriteBootSectorConfig (const byte newConfig[]) + void BootEncryption::WriteBootSectorConfig (const uint8 newConfig[]) { Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbr, sizeof (mbr)); memcpy (mbr + TC_BOOT_SECTOR_CONFIG_OFFSET, newConfig, TC_BOOT_CFG_FLAG_AREA_SIZE); device.SeekAt (0); device.Write (mbr, sizeof (mbr)); - byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; + uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbrVerificationBuf, sizeof (mbr)); if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0) throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS); } - void BootEncryption::WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) + void BootEncryption::WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { if (!IsAdmin() && IsUacSupported()) { Elevator::WriteEfiBootSectorUserConfig (userConfig, customUserMessage, pim, hashAlg); } else { EfiBootInst.PrepareBootPartition(); if (! (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)) pim = -1; if (! (userConfig & TC_BOOT_USER_CFG_FLAG_STORE_HASH)) hashAlg = -1; EfiBootInst.UpdateConfig (L"\\EFI\\VeraCrypt\\DcsProp", pim, hashAlg, ParentWindow); } } - void BootEncryption::WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) + void BootEncryption::WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { if (GetSystemDriveConfiguration().SystemPartition.IsGPT) { WriteEfiBootSectorUserConfig (userConfig, customUserMessage, pim, hashAlg); } else { Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbr, sizeof (mbr)); if (!BufferContainsString (mbr, sizeof (mbr), TC_APP_NAME) || BE16 (*(uint16 *) (mbr + TC_BOOT_SECTOR_VERSION_OFFSET)) != VERSION_NUM) { return; } mbr[TC_BOOT_SECTOR_USER_CONFIG_OFFSET] = userConfig; memset (mbr + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, 0, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH); if (!customUserMessage.empty()) { if (customUserMessage.size() > TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH) throw ParameterIncorrect (SRC_POS); 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 // value is 65535 (0xFFFF) memcpy (mbr + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &pim, TC_BOOT_SECTOR_PIM_VALUE_SIZE); } else memset (mbr + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, 0, TC_BOOT_SECTOR_PIM_VALUE_SIZE); device.SeekAt (0); device.Write (mbr, sizeof (mbr)); - byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; + uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbrVerificationBuf, sizeof (mbr)); if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0) throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS); } } unsigned int BootEncryption::GetHiddenOSCreationPhase () { - byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; + uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; ReadBootSectorConfig (configFlags, sizeof(configFlags)); return (configFlags[0] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE); } void BootEncryption::SetHiddenOSCreationPhase (unsigned int newPhase) { #if TC_BOOT_CFG_FLAG_AREA_SIZE != 1 # error TC_BOOT_CFG_FLAG_AREA_SIZE != 1; revise GetHiddenOSCreationPhase() and SetHiddenOSCreationPhase() #endif - byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; + uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE]; ReadBootSectorConfig (configFlags, sizeof(configFlags)); - configFlags[0] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; + configFlags[0] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; configFlags[0] |= newPhase; WriteBootSectorConfig (configFlags); } #ifndef SETUP void BootEncryption::StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm) { if (!IsHiddenOSRunning()) throw ParameterIncorrect (SRC_POS); WipeDecoySystemRequest request; ZeroMemory (&request, sizeof (request)); request.WipeAlgorithm = wipeAlgorithm; if (Randinit() != ERR_SUCCESS) { if (CryptoAPILastError == ERROR_SUCCESS) throw RandInitFailed (SRC_POS, GetLastError ()); else throw CryptoApiFailed (SRC_POS, CryptoAPILastError); } /* force the display of the random enriching dialog */ SetRandomPoolEnrichedByUserStatus (FALSE); @@ -2149,89 +2128,89 @@ namespace VeraCrypt DecoySystemWipeStatus BootEncryption::GetDecoyOSWipeStatus () { DecoySystemWipeStatus status; CallDriver (TC_IOCTL_GET_DECOY_SYSTEM_WIPE_STATUS, NULL, 0, &status, sizeof (status)); return status; } void BootEncryption::CheckDecoyOSWipeResult () { CallDriver (TC_IOCTL_GET_DECOY_SYSTEM_WIPE_RESULT); } void BootEncryption::WipeHiddenOSCreationConfig () { if (IsHiddenOSRunning()) throw ParameterIncorrect (SRC_POS); if (Randinit() != ERR_SUCCESS) { if (CryptoAPILastError == ERROR_SUCCESS) throw RandInitFailed (SRC_POS, GetLastError ()); else throw CryptoApiFailed (SRC_POS, CryptoAPILastError); } Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened(SRC_POS); - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbr, sizeof (mbr)); finally_do_arg (BootEncryption *, this, { try { finally_arg->SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_NONE); } catch (...) { } }); #if PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE # error PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE #endif - byte randData[PRAND_DISK_WIPE_PASSES]; + uint8 randData[PRAND_DISK_WIPE_PASSES]; if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE)) throw ParameterIncorrect (SRC_POS); for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++) { for (int i = 0; i < TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE; ++i) { mbr[TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + i] = randData[wipePass]; } - mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; + mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] |= randData[wipePass] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE; if (wipePass == PRAND_DISK_WIPE_PASSES - 1) memset (mbr + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET, 0, TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE); device.SeekAt (0); device.Write (mbr, sizeof (mbr)); } for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES/4 + 1; wipePass++) { SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_NONE); SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_CLONING); SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_WIPING); SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_WIPED); } SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_NONE); } #endif // !SETUP EfiBootConf::EfiBootConf() : passwordType (0), passwordMsg ("Password: "), passwordPicture ("login.bmp"), hashMsg ("(0) TEST ALL (1) SHA512 (2) WHIRLPOOL (3) SHA256 (4) BLAKE2S (5) STREEBOG\nHash: "), hashAlgo (0), requestHash (0), pimMsg ("PIM (Leave empty for default): "), pim (0), @@ -2379,61 +2358,61 @@ namespace VeraCrypt XmlWriteHeader (configFile); fputws (L"\n\t<configuration>", configFile); WriteConfigInteger (configFile, configContent, "PasswordType", passwordType); WriteConfigString (configFile, configContent, "PasswordMsg", passwordMsg.c_str()); WriteConfigString (configFile, configContent, "PasswordPicture", passwordPicture.c_str()); WriteConfigString (configFile, configContent, "HashMsg", hashMsg.c_str()); WriteConfigInteger (configFile, configContent, "Hash", hashAlgo); WriteConfigInteger (configFile, configContent, "HashRqt", requestHash); WriteConfigString (configFile, configContent, "PimMsg", pimMsg.c_str()); WriteConfigInteger (configFile, configContent, "Pim", pim); WriteConfigInteger (configFile, configContent, "PimRqt", requestPim); WriteConfigInteger (configFile, configContent, "AuthorizeVisible", authorizeVisible); WriteConfigInteger (configFile, configContent, "AuthorizeRetry", authorizeRetry); WriteConfigInteger (configFile, configContent, "DcsBmlLockFlags", bmlLockFlags); WriteConfigInteger (configFile, configContent, "DcsBmlDriver", bmlDriverEnabled); string fieldValue; if (IsPostExecFileField(actionSuccessValue, fieldValue) && (0 == _stricmp(fieldValue.c_str(), "\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))) { // fix wrong configuration file since bootmgfw.efi is now a copy of VeraCrypt and if we don't fix the DcsProp // file, veraCrypt bootloader will call itself // We first check if bootmgfw.efi is original Microsoft one. If yes, we don't do anything, otherwise we set the field to bootmgfw_ms.vc unsigned __int64 loaderSize = 0; bool bModifiedMsBoot = true; EfiBootInst.GetFileSize(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", loaderSize); if (loaderSize > 32768) { - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string const char* g_szMsBootString = "bootmgfw.pdb"; if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { bModifiedMsBoot = false; } } if (bModifiedMsBoot) actionSuccessValue = "postexec file(EFI\\Microsoft\\Boot\\bootmgfw_ms.vc)"; } WriteConfigString (configFile, configContent, "ActionSuccess", actionSuccessValue.c_str()); // Write unmodified values char* xml = configContent; char key[128], value[2048]; while (xml && (xml = XmlFindElement (xml, "config"))) { XmlGetAttributeText (xml, "key", key, sizeof (key)); XmlGetNodeText (xml, value, sizeof (value)); fwprintf (configFile, L"\n\t\t<config key=\"%hs\">%hs</config>", key, value); xml++; } fputws (L"\n\t</configuration>", configFile); @@ -2630,426 +2609,452 @@ namespace VeraCrypt devicePath += BootVolumePath; Device dev(devicePath.c_str(), TRUE); try { dev.CheckOpened(SRC_POS); } catch (...) { if (!bDisableException) throw; } if (dev.IsOpened()) { bDeviceInfoValid = dev.IoCtl(IOCTL_STORAGE_GET_DEVICE_NUMBER, NULL, 0, &sdn, sizeof(sdn)) && dev.IoCtl(IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &partInfo, sizeof(partInfo)); DWORD dwLastError = GetLastError (); dev.Close(); if (!bDeviceInfoValid && !bDisableException) { SetLastError (dwLastError); throw SystemException(SRC_POS); } } } bool EfiBoot::IsEfiBoot() { DWORD BootOrderLen; BootOrderLen = GetFirmwareEnvironmentVariable(L"BootOrder", EfiVarGuid, tempBuf, sizeof(tempBuf)); - return BootOrderLen != 0; + return (BootOrderLen != 0) || (GetLastError() != ERROR_INVALID_FUNCTION); } void EfiBoot::DeleteStartExec(uint16 statrtOrderNum, wchar_t* type) { - SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE); + DWORD dwLastError; + BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_SYSTEM_ENVIRONMENT_NAME); + if (!bPrivilegesSet && !SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE)) + { + dwLastError = GetLastError(); + wchar_t szMsg[128]; + StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to set SE_SYSTEM_ENVIRONMENT_NAME privilege (error code 0x%.8X)", dwLastError); + throw ErrorException(szMsg, SRC_POS); + } // Check EFI if (!IsEfiBoot()) { - throw ErrorException(L"can not detect EFI environment", SRC_POS); + if (!bPrivilegesSet) + SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); + throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS); } wchar_t varName[256]; StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); SetFirmwareEnvironmentVariable(varName, EfiVarGuid, NULL, 0); wstring order = L"Order"; order.insert(0, type == NULL ? L"Boot" : type); uint32 startOrderLen = GetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, tempBuf, sizeof(tempBuf)); uint32 startOrderNumPos = UINT_MAX; bool startOrderUpdate = false; uint16* startOrder = (uint16*)tempBuf; for (uint32 i = 0; i < startOrderLen / 2; i++) { if (startOrder[i] == statrtOrderNum) { startOrderNumPos = i; break; } } // delete entry if present if (startOrderNumPos != UINT_MAX) { for (uint32 i = startOrderNumPos; i < ((startOrderLen / 2) - 1); ++i) { startOrder[i] = startOrder[i + 1]; } startOrderLen -= 2; startOrderUpdate = true; } if (startOrderUpdate) { SetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, startOrder, startOrderLen); // remove ourselves from BootNext value uint16 bootNextValue = 0; wstring next = L"Next"; next.insert(0, type == NULL ? L"Boot" : type); if ( (GetFirmwareEnvironmentVariable(next.c_str(), EfiVarGuid, &bootNextValue, 2) == 2) && (bootNextValue == statrtOrderNum) ) { SetFirmwareEnvironmentVariable(next.c_str(), EfiVarGuid, startOrder, 0); } } + + if (!bPrivilegesSet) + SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); } void EfiBoot::SetStartExec(wstring description, wstring execPath, bool setBootEntry, bool forceFirstBootEntry, bool setBootNext, uint16 statrtOrderNum , wchar_t* type, uint32 attr) { - SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE); + DWORD dwLastError; + BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_SYSTEM_ENVIRONMENT_NAME); + if (!bPrivilegesSet && !SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE)) + { + dwLastError = GetLastError(); + wchar_t szMsg[128]; + StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to set SE_SYSTEM_ENVIRONMENT_NAME privilege (error code 0x%.8X)", dwLastError); + throw ErrorException(szMsg, SRC_POS); + } // Check EFI if (!IsEfiBoot()) { - throw ErrorException(L"can not detect EFI environment", SRC_POS); + if (!bPrivilegesSet) + SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); + throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS); } if (bDeviceInfoValid) { uint32 varSize = 56; varSize += ((uint32) description.length()) * 2 + 2; varSize += ((uint32) execPath.length()) * 2 + 2; - byte *startVar = new byte[varSize]; - byte *pVar = startVar; + uint8 *startVar = new uint8[varSize]; + uint8 *pVar = startVar; // Attributes (1b Active, 1000b - Hidden) *(uint32 *)pVar = attr; pVar += sizeof(uint32); // Size Of device path + file path *(uint16 *)pVar = (uint16)(50 + execPath.length() * 2 + 2); pVar += sizeof(uint16); // description for (uint32 i = 0; i < description.length(); i++) { *(uint16 *)pVar = description[i]; pVar += sizeof(uint16); } *(uint16 *)pVar = 0; pVar += sizeof(uint16); /* EFI_DEVICE_PATH_PROTOCOL (HARDDRIVE_DEVICE_PATH \ FILE_PATH \ END) */ // Type - *(byte *)pVar = 0x04; - pVar += sizeof(byte); + *(uint8 *)pVar = 0x04; + pVar += sizeof(uint8); // SubType - *(byte *)pVar = 0x01; - pVar += sizeof(byte); + *(uint8 *)pVar = 0x01; + pVar += sizeof(uint8); // HDD dev path length *(uint16 *)pVar = 0x2A; // 42 pVar += sizeof(uint16); // PartitionNumber *(uint32 *)pVar = (uint32)partInfo.PartitionNumber; pVar += sizeof(uint32); // PartitionStart *(uint64 *)pVar = partInfo.StartingOffset.QuadPart >> 9; pVar += sizeof(uint64); // PartitiontSize *(uint64 *)pVar = partInfo.PartitionLength.QuadPart >> 9; pVar += sizeof(uint64); // GptGuid memcpy(pVar, &partInfo.Gpt.PartitionId, 16); pVar += 16; // MbrType - *(byte *)pVar = 0x02; - pVar += sizeof(byte); + *(uint8 *)pVar = 0x02; + pVar += sizeof(uint8); // SigType - *(byte *)pVar = 0x02; - pVar += sizeof(byte); + *(uint8 *)pVar = 0x02; + pVar += sizeof(uint8); // Type and sub type 04 04 (file path) *(uint16 *)pVar = 0x0404; pVar += sizeof(uint16); // SizeOfFilePath ((CHAR16)FullPath.length + sizeof(EndOfrecord marker) ) *(uint16 *)pVar = (uint16)(execPath.length() * 2 + 2 + sizeof(uint32)); pVar += sizeof(uint16); // FilePath for (uint32 i = 0; i < execPath.length(); i++) { *(uint16 *)pVar = execPath[i]; pVar += sizeof(uint16); } *(uint16 *)pVar = 0; pVar += sizeof(uint16); // EndOfrecord *(uint32 *)pVar = 0x04ff7f; pVar += sizeof(uint32); // Set variable wchar_t varName[256]; StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum); // only set value if it doesn't already exist - byte* existingVar = new byte[varSize]; + uint8* existingVar = new uint8[varSize]; DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, varSize); if ((existingVarLen != varSize) || (0 != memcmp (existingVar, startVar, varSize))) SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize); delete [] startVar; delete [] existingVar; } // Update order wstring order = L"Order"; order.insert(0, type == NULL ? L"Boot" : type); uint32 startOrderLen = GetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, tempBuf, sizeof(tempBuf)); uint32 startOrderNumPos = UINT_MAX; bool startOrderUpdate = false; uint16* startOrder = (uint16*)tempBuf; for (uint32 i = 0; i < startOrderLen / 2; i++) { if (startOrder[i] == statrtOrderNum) { startOrderNumPos = i; break; } } if (setBootEntry) { // check if first entry in BootOrder is Windows one bool bFirstEntryIsWindows = false; if (startOrderNumPos != 0) { wchar_t varName[256]; StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, startOrder[0]); - byte* existingVar = new byte[512]; + uint8* existingVar = new uint8[512]; DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, 512); if (existingVarLen > 0) { if (BufferContainsWideString (existingVar, existingVarLen, L"EFI\\Microsoft\\Boot\\bootmgfw.efi")) bFirstEntryIsWindows = true; } delete [] existingVar; } // Create new entry if absent if (startOrderNumPos == UINT_MAX) { if (bDeviceInfoValid) { if (forceFirstBootEntry && bFirstEntryIsWindows) { for (uint32 i = startOrderLen / 2; i > 0; --i) { startOrder[i] = startOrder[i - 1]; } startOrder[0] = statrtOrderNum; } else { startOrder[startOrderLen/2] = statrtOrderNum; } startOrderLen += 2; startOrderUpdate = true; } } else if ((startOrderNumPos > 0) && forceFirstBootEntry && bFirstEntryIsWindows) { for (uint32 i = startOrderNumPos; i > 0; --i) { startOrder[i] = startOrder[i - 1]; } startOrder[0] = statrtOrderNum; startOrderUpdate = true; } if (startOrderUpdate) { SetFirmwareEnvironmentVariable(order.c_str(), EfiVarGuid, startOrder, startOrderLen); } } if (setBootNext) { // set BootNext value wstring next = L"Next"; next.insert(0, type == NULL ? L"Boot" : type); SetFirmwareEnvironmentVariable(next.c_str(), EfiVarGuid, &statrtOrderNum, 2); } + + if (!bPrivilegesSet) + SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); } bool EfiBoot::CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2) { bool bRet = false; File f1 (fileName1, true); File f2 (fileName2, true); if (f1.IsOpened() && f2.IsOpened()) { try { DWORD size1, size2; f1.GetFileSize (size1); f2.GetFileSize (size2); if (size1 == size2) { // same size, so now we compare content - std::vector<byte> file1Buf (8096); - std::vector<byte> file2Buf (8096); + std::vector<uint8> file1Buf (8096); + std::vector<uint8> file2Buf (8096); DWORD remainingBytes = size1, dataToRead; while (remainingBytes) { dataToRead = VC_MIN (remainingBytes, (DWORD) file1Buf.size()); DWORD f1Bytes = f1.Read (file1Buf.data(), dataToRead); DWORD f2Bytes = f2.Read (file2Buf.data(), dataToRead); if ((f1Bytes != f2Bytes) || memcmp (file1Buf.data(), file2Buf.data(), (size_t) f1Bytes)) { break; } else { remainingBytes -= f1Bytes; } } if (0 == remainingBytes) { // content is the same bRet = true; } } } catch (...) {} } f1.Close(); f2.Close(); return bRet; } - bool EfiBoot::CompareFileData (const wchar_t* fileName, const byte* data, DWORD size) + bool EfiBoot::CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size) { bool bRet = false; File f(fileName, true); if (f.IsOpened ()) { try { // check if the file has the same content // if yes, don't perform any write operation to avoid changing its timestamp DWORD existingSize = 0; f.GetFileSize(existingSize); if (existingSize == size) { - std::vector<byte> fileBuf (8096); + std::vector<uint8> fileBuf (8096); DWORD remainingBytes = size, dataOffset = 0, dataToRead; while (remainingBytes) { dataToRead = VC_MIN (remainingBytes, (DWORD) fileBuf.size()); dataToRead = f.Read (fileBuf.data(), dataToRead); if (memcmp (data + dataOffset, fileBuf.data(), (size_t) dataToRead)) { break; } else { dataOffset += dataToRead; remainingBytes -= dataToRead; } } if (0 == remainingBytes) { // content is the same bRet = true; } } } catch (...){} } f.Close(); return bRet; } - void EfiBoot::SaveFile(const wchar_t* name, byte* data, DWORD size) { + void EfiBoot::SaveFile(const wchar_t* name, uint8* data, DWORD size) { wstring path = EfiBootPartPath; path += name; if (!CompareFileData (path.c_str(), data, size)) { File f(path, false, true); f.Write(data, size); f.Close(); } } bool EfiBoot::FileExists(const wchar_t* name) { wstring path = EfiBootPartPath; path += name; File f(path, true); bool bRet = f.IsOpened (); f.Close(); return bRet; } void EfiBoot::GetFileSize(const wchar_t* name, unsigned __int64& size) { wstring path = EfiBootPartPath; path += name; File f(path, true); f.GetFileSize(size); f.Close(); } - void EfiBoot::ReadFile(const wchar_t* name, byte* data, DWORD size) { + void EfiBoot::ReadFile(const wchar_t* name, uint8* data, DWORD size) { wstring path = EfiBootPartPath; path += name; File f(path, true); f.Read(data, size); f.Close(); } void EfiBoot::CopyFile(const wchar_t* name, const wchar_t* targetName) { wstring path = EfiBootPartPath; path += name; wstring targetPath; if (targetName[0] == L'\\') { targetPath = EfiBootPartPath; targetPath += targetName; } else targetPath = targetName; // if both files are the same, we don't perform copy operation if (!CompareFiles (path.c_str(), targetPath.c_str())) throw_sys_if (!::CopyFileW (path.c_str(), targetPath.c_str(), FALSE)); } BOOL EfiBoot::RenameFile(const wchar_t* name, const wchar_t* nameNew, BOOL bForce) { wstring path = EfiBootPartPath; path += name; wstring pathNew = EfiBootPartPath; pathNew += nameNew; @@ -3292,386 +3297,386 @@ namespace VeraCrypt } } } void BootEncryption::InstallBootLoader (bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg) { Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); InstallBootLoader (device, preserveUserConfig, hiddenOSCreation, pim, hashAlg); } void BootEncryption::InstallBootLoader (Device& device, bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg) { SystemDriveConfiguration config = GetSystemDriveConfiguration(); if (config.SystemPartition.IsGPT) { if (!IsAdmin()) { if (IsUacSupported()) { Elevator::InstallEfiBootLoader (preserveUserConfig, hiddenOSCreation, pim, hashAlg); return; } else { Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", ParentWindow); } } DWORD sizeDcsBoot; #ifdef _WIN64 - byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); + uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); #else - byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot); + uint8 *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot); #endif if (!dcsBootImg) throw ErrorException(L"Out of resource DcsBoot", SRC_POS); DWORD sizeDcsInt; #ifdef _WIN64 - byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); + uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); #else - byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt); + uint8 *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt); #endif if (!dcsIntImg) throw ErrorException(L"Out of resource DcsInt", SRC_POS); DWORD sizeDcsCfg; #ifdef _WIN64 - byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); + uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); #else - byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg); + uint8 *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg); #endif if (!dcsCfgImg) throw ErrorException(L"Out of resource DcsCfg", SRC_POS); DWORD sizeLegacySpeaker; #ifdef _WIN64 - byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); + uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); #else - byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker); + uint8 *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker); #endif if (!LegacySpeakerImg) throw ErrorException(L"Out of resource LegacySpeaker", SRC_POS); #ifdef VC_EFI_CUSTOM_MODE DWORD sizeBootMenuLocker; #ifdef _WIN64 - byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); + uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); #else - byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker); + uint8 *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker); #endif if (!BootMenuLockerImg) throw ErrorException(L"Out of resource DcsBml", SRC_POS); #endif DWORD sizeDcsInfo; #ifdef _WIN64 - byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); + uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); #else - byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo); + uint8 *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo); #endif if (!DcsInfoImg) throw ErrorException(L"Out of resource DcsInfo", SRC_POS); EfiBootInst.PrepareBootPartition(PostOOBEMode); try { // Save modules bool bAlreadyExist; const char* g_szMsBootString = "bootmgfw.pdb"; unsigned __int64 loaderSize = 0; const wchar_t * szStdEfiBootloader = Is64BitOs()? L"\\EFI\\Boot\\bootx64.efi": L"\\EFI\\Boot\\bootia32.efi"; const wchar_t * szBackupEfiBootloader = Is64BitOs()? L"\\EFI\\Boot\\original_bootx64.vc_backup": L"\\EFI\\Boot\\original_bootia32.vc_backup"; if (preserveUserConfig) { bool bModifiedMsBoot = true, bMissingMsBoot = false;; if (EfiBootInst.FileExists (L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi")) EfiBootInst.GetFileSize(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", loaderSize); else bMissingMsBoot = true; // restore boot menu entry in case of PostOOBE if (PostOOBEMode) EfiBootInst.SetStartExec(L"VeraCrypt BootLoader (DcsBoot)", L"\\EFI\\VeraCrypt\\DcsBoot.efi", SetBootEntry, ForceFirstBootEntry, SetBootNext); if (EfiBootInst.FileExists (L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc")) { if (loaderSize > 32768) { - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { bModifiedMsBoot = false; // replace the backup with this version EfiBootInst.RenameFile (L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", TRUE); } } } else { // DcsBoot.efi is always smaller than 32KB if (loaderSize > 32768) { - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) bModifiedMsBoot = false; } if (!bModifiedMsBoot) { EfiBootInst.RenameFile (L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", TRUE); } else { bool bFound = false; EfiBootConf conf; if (EfiBootInst.ReadConfig (L"\\EFI\\VeraCrypt\\DcsProp", conf) && strlen (conf.actionSuccessValue.c_str())) { wstring loaderPath; if (EfiBootConf::IsPostExecFileField (conf.actionSuccessValue, loaderPath)) { // check that it is not bootmgfw.efi if ( (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi")) && (EfiBootInst.FileExists (loaderPath.c_str())) ) { // look for bootmgfw.efi identifiant string EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize); - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { bFound = true; EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", TRUE); } } } } if (!bFound && !PostOOBEMode) throw ErrorException ("WINDOWS_EFI_BOOT_LOADER_MISSING", SRC_POS); } } if (PostOOBEMode && EfiBootInst.FileExists (L"\\EFI\\VeraCrypt\\DcsBoot.efi")) { // check if bootmgfw.efi has been set again to Microsoft version // if yes, replace it with our bootloader after it was copied to bootmgfw_ms.vc if (!bModifiedMsBoot || bMissingMsBoot) EfiBootInst.CopyFile (L"\\EFI\\VeraCrypt\\DcsBoot.efi", L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"); if (EfiBootInst.FileExists (szStdEfiBootloader)) { // check if standard bootloader under EFI\Boot has been set to Microsoft version // if yes, replace it with our bootloader EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize); if (loaderSize > 32768) { - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { EfiBootInst.RenameFile (szStdEfiBootloader, szBackupEfiBootloader, TRUE); EfiBootInst.CopyFile (L"\\EFI\\VeraCrypt\\DcsBoot.efi", szStdEfiBootloader); } } } return; } } EfiBootInst.MkDir(L"\\EFI\\VeraCrypt", bAlreadyExist); EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\DcsBoot.efi", dcsBootImg, sizeDcsBoot); EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\DcsInt.dcs", dcsIntImg, sizeDcsInt); EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\DcsCfg.dcs", dcsCfgImg, sizeDcsCfg); EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\LegacySpeaker.dcs", LegacySpeakerImg, sizeLegacySpeaker); #ifdef VC_EFI_CUSTOM_MODE EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\DcsBml.dcs", BootMenuLockerImg, sizeBootMenuLocker); #endif EfiBootInst.SaveFile(L"\\EFI\\VeraCrypt\\DcsInfo.dcs", DcsInfoImg, sizeDcsInfo); if (!preserveUserConfig) EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\PlatformInfo"); EfiBootInst.SetStartExec(L"VeraCrypt BootLoader (DcsBoot)", L"\\EFI\\VeraCrypt\\DcsBoot.efi", SetBootEntry, ForceFirstBootEntry, SetBootNext); if (EfiBootInst.FileExists (szStdEfiBootloader)) { // check if standard bootloader under EFI\Boot is Microsoft one or if it is ours // if both cases, replace it with our bootloader otherwise do nothing EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize); - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi or VeraCrypt identifiant strings if ( ((loaderSize > 32768) && BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) ) { EfiBootInst.RenameFile (szStdEfiBootloader, szBackupEfiBootloader, TRUE); EfiBootInst.SaveFile(szStdEfiBootloader, dcsBootImg, sizeDcsBoot); } if ( ((loaderSize <= 32768) && BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, _T(TC_APP_NAME), strlen (TC_APP_NAME) * 2)) ) { EfiBootInst.SaveFile(szStdEfiBootloader, dcsBootImg, sizeDcsBoot); } } EfiBootInst.SaveFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", dcsBootImg, sizeDcsBoot); // move configuration file from old location (if it exists) to new location // we don't force the move operation if the new location already exists EfiBootInst.RenameFile (L"\\DcsProp", L"\\EFI\\VeraCrypt\\DcsProp", FALSE); EfiBootInst.RenameFile (L"\\DcsBoot", L"\\EFI\\VeraCrypt\\DcsBoot", FALSE); // move the original bootloader backup from old location (if it exists) to new location // we don't force the move operation if the new location already exists if (Is64BitOs()) EfiBootInst.RenameFile (L"\\EFI\\Boot\\original_bootx64_vc_backup.efi", L"\\EFI\\Boot\\original_bootx64.vc_backup", FALSE); else EfiBootInst.RenameFile (L"\\EFI\\Boot\\original_bootia32_vc_backup.efi", L"\\EFI\\Boot\\original_bootia32.vc_backup", FALSE); // Clean beta9 EfiBootInst.DelFile(L"\\DcsBoot.efi"); EfiBootInst.DelFile(L"\\DcsInt.efi"); EfiBootInst.DelFile(L"\\DcsCfg.efi"); EfiBootInst.DelFile(L"\\LegacySpeaker.efi"); EfiBootInst.DelFile(L"\\DcsBoot"); EfiBootInst.DelFile(L"\\DcsProp"); #ifndef VC_EFI_CUSTOM_MODE // remove DcsBml if it exists since we don't use it in non-custom SecureBoot mode EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBml.dcs"); #endif } catch (...) { throw; } EfiBootInst.WriteConfig (L"\\EFI\\VeraCrypt\\DcsProp", preserveUserConfig, pim, hashAlg, NULL, ParentWindow); } else { try { - byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0}; + uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0}; CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation); // Write MBR - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbr, sizeof (mbr)); if (preserveUserConfig && BufferContainsString (mbr, sizeof (mbr), TC_APP_NAME)) { uint16 version = BE16 (*(uint16 *) (mbr + TC_BOOT_SECTOR_VERSION_OFFSET)); if (version != 0) { bootLoaderBuf[TC_BOOT_SECTOR_USER_CONFIG_OFFSET] = mbr[TC_BOOT_SECTOR_USER_CONFIG_OFFSET]; memcpy (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, mbr + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET, TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH); if (bootLoaderBuf[TC_BOOT_SECTOR_USER_CONFIG_OFFSET] & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM) { if (pim >= 0) { memcpy (bootLoaderBuf + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &pim, TC_BOOT_SECTOR_PIM_VALUE_SIZE); } else memcpy (bootLoaderBuf + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, mbr + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, TC_BOOT_SECTOR_PIM_VALUE_SIZE); } } } // perform actual write only if content is different and either we are not in PostOOBE mode or the MBR contains VeraCrypt/Windows signature. // this last check is done to avoid interfering with multi-boot configuration where MBR belongs to a boot manager like Grub if (memcmp (mbr, bootLoaderBuf, TC_MAX_MBR_BOOT_CODE_SIZE) && (!PostOOBEMode || BufferContainsString (mbr, sizeof (mbr), TC_APP_NAME) || IsWindowsMBR (mbr, sizeof (mbr)))) { memcpy (mbr, bootLoaderBuf, TC_MAX_MBR_BOOT_CODE_SIZE); device.SeekAt (0); device.Write (mbr, sizeof (mbr)); - byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; + uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbrVerificationBuf, sizeof (mbr)); if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0) throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS); } if (!PostOOBEMode) { // Write boot loader device.SeekAt (TC_SECTOR_SIZE_BIOS); device.Write (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, sizeof (bootLoaderBuf) - TC_SECTOR_SIZE_BIOS); } } catch (...) { if (!PostOOBEMode) throw; } } if (!IsAdmin() && IsUacSupported()) { Elevator::UpdateSetupConfigFile (true); } else { UpdateSetupConfigFile (true); } } #ifndef SETUP bool BootEncryption::CheckBootloaderFingerprint (bool bSilent) { SystemDriveConfiguration config = GetSystemDriveConfiguration(); // return true for now when EFI system encryption is used until we implement // a dedicated EFI fingerprinting mechanism in VeraCrypt driver if (config.SystemPartition.IsGPT) return true; - byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0}; - byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; - byte expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; + uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0}; + uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; + uint8 expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; bool bRet = false; try { // read bootloader fingerprint GetInstalledBootLoaderFingerprint (fingerprint); // compute expected fingerprint CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, false); ::ComputeBootloaderFingerprint (bootLoaderBuf, sizeof (bootLoaderBuf), expectedFingerprint); // compare values if (0 == memcmp (fingerprint, expectedFingerprint, sizeof (expectedFingerprint))) { bRet = true; } } catch (SystemException &e) { if (!bSilent && (GetLastError () != ERROR_INVALID_IMAGE_HASH)) e.Show (ParentWindow); } catch (Exception& e) { if (!bSilent) e.Show (ParentWindow); } return bRet; } @@ -3689,113 +3694,113 @@ namespace VeraCrypt return path + L'\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME; } void BootEncryption::RenameDeprecatedSystemLoaderBackup () { WCHAR pathBuf[MAX_PATH]; if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA, NULL, 0, pathBuf))) { wstring path = wstring (pathBuf) + L"\\" _T(TC_APP_NAME) + L'\\' + TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY; if (FileExists (path.c_str()) && !FileExists (GetSystemLoaderBackupPath().c_str())) throw_sys_if (_wrename (path.c_str(), GetSystemLoaderBackupPath().c_str()) != 0); } } #ifndef SETUP void BootEncryption::CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath) { BootEncryptionStatus encStatus = GetStatus(); if (encStatus.SetupInProgress) throw ParameterIncorrect (SRC_POS); BOOL bIsGPT = GetSystemDriveConfiguration().SystemPartition.IsGPT; if (bIsGPT) { // create EFI disk structure DWORD sizeDcsBoot; #ifdef _WIN64 - byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); + uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); #else - byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot); + uint8 *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot); #endif if (!dcsBootImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsInt; #ifdef _WIN64 - byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); + uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); #else - byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt); + uint8 *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt); #endif if (!dcsIntImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsCfg; #ifdef _WIN64 - byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); + uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); #else - byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg); + uint8 *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg); #endif if (!dcsCfgImg) throw ParameterIncorrect (SRC_POS); DWORD sizeLegacySpeaker; #ifdef _WIN64 - byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); + uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); #else - byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker); + uint8 *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker); #endif if (!LegacySpeakerImg) throw ParameterIncorrect (SRC_POS); #ifdef VC_EFI_CUSTOM_MODE DWORD sizeBootMenuLocker; #ifdef _WIN64 - byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); + uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); #else - byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker); + uint8 *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker); #endif if (!BootMenuLockerImg) throw ParameterIncorrect (SRC_POS); #endif DWORD sizeDcsRescue; #ifdef _WIN64 - byte *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue); + uint8 *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue); #else - byte *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue); + uint8 *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue); #endif if (!DcsRescueImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsInfo; #ifdef _WIN64 - byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); + uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); #else - byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo); + uint8 *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo); #endif if (!DcsInfoImg) throw ParameterIncorrect (SRC_POS); WCHAR szTmpPath[MAX_PATH + 1], szTmpFilePath[MAX_PATH + 1]; if (!GetTempPathW (MAX_PATH, szTmpPath)) throw SystemException (SRC_POS); if (!GetTempFileNameW (szTmpPath, L"_vrd", 0, szTmpFilePath)) throw SystemException (SRC_POS); finally_do_arg (WCHAR*, szTmpFilePath, { DeleteFileW (finally_arg);}); int ierr; // convert szTmpFilePath to UTF-8 since this is what zip_open expected char szUtf8Path[2*MAX_PATH + 1]; int utf8Len = WideCharToMultiByte (CP_UTF8, 0, szTmpFilePath, -1, szUtf8Path, sizeof (szUtf8Path), NULL, NULL); if (utf8Len <= 0) throw SystemException (SRC_POS); zip_t* z = zip_open (szUtf8Path, ZIP_CREATE | ZIP_TRUNCATE | ZIP_CHECKCONS, &ierr); if (!z) throw ParameterIncorrect (SRC_POS); finally_do_arg (zip_t**, &z, { if (*finally_arg) zip_discard (*finally_arg);}); if (!ZipAdd (z, Is64BitOs()? "EFI/Boot/bootx64.efi": "EFI/Boot/bootia32.efi", DcsRescueImg, sizeDcsRescue)) throw ParameterIncorrect (SRC_POS); #ifdef VC_EFI_CUSTOM_MODE if (!ZipAdd (z, "EFI/VeraCrypt/DcsBml.dcs", BootMenuLockerImg, sizeBootMenuLocker)) @@ -3861,84 +3866,84 @@ namespace VeraCrypt finally_do_arg (wstring, dcsPropFileName, { DeleteFileW (finally_arg.c_str()); }); if (conf.Save(dcsPropFileName.c_str(), ParentWindow)) { DWORD fileSize = 0; File propFile (dcsPropFileName, true, false); propFile.CheckOpened (SRC_POS); propFile.GetFileSize(fileSize); propBuf.Resize (fileSize); DWORD sizeDcsProp = propFile.Read (propBuf.Ptr (), fileSize); if (!ZipAdd (z, "EFI/VeraCrypt/DcsProp", propBuf.Ptr (), sizeDcsProp)) throw ParameterIncorrect (SRC_POS); } else throw ParameterIncorrect (SRC_POS); // flush the zip content to the temporary file if (zip_close (z) < 0) throw ParameterIncorrect (SRC_POS); z = NULL; // read the zip data from the temporary file FILE* ftmpFile = _wfopen (szTmpFilePath, L"rb"); if (!ftmpFile) throw ParameterIncorrect (SRC_POS); finally_do_arg (FILE*, ftmpFile, { fclose (finally_arg); }); unsigned long ulZipSize = (unsigned long) _filelength (_fileno (ftmpFile)); - RescueZipData = new byte[ulZipSize]; + RescueZipData = new uint8[ulZipSize]; if (!RescueZipData) throw bad_alloc(); if (ulZipSize != fread (RescueZipData, 1, ulZipSize, ftmpFile)) { delete [] RescueZipData; RescueZipData = NULL; throw ParameterIncorrect (SRC_POS); } RescueZipSize = ulZipSize; if (!isoImagePath.empty()) { File isoFile (isoImagePath, false, true); isoFile.Write (RescueZipData, RescueZipSize); } } else { Buffer imageBuf (RescueIsoImageSize); - byte *image = imageBuf.Ptr(); + uint8 *image = imageBuf.Ptr(); memset (image, 0, RescueIsoImageSize); // Primary volume descriptor const char* szPrimVolDesc = "\001CD001\001"; const char* szPrimVolLabel = "VeraCrypt Rescue Disk "; memcpy (image + 0x8000, szPrimVolDesc, strlen(szPrimVolDesc) + 1); memcpy (image + 0x7fff + 41, szPrimVolLabel, strlen(szPrimVolLabel) + 1); *(uint32 *) (image + 0x7fff + 81) = RescueIsoImageSize / 2048; *(uint32 *) (image + 0x7fff + 85) = BE32 (RescueIsoImageSize / 2048); image[0x7fff + 121] = 1; image[0x7fff + 124] = 1; image[0x7fff + 125] = 1; image[0x7fff + 128] = 1; image[0x7fff + 130] = 8; image[0x7fff + 131] = 8; image[0x7fff + 133] = 10; image[0x7fff + 140] = 10; image[0x7fff + 141] = 0x14; image[0x7fff + 157] = 0x22; image[0x7fff + 159] = 0x18; // Boot record volume descriptor const char* szBootRecDesc = "CD001\001EL TORITO SPECIFICATION"; memcpy (image + 0x8801, szBootRecDesc, strlen(szBootRecDesc) + 1); image[0x8800 + 0x47] = 0x19; // Volume descriptor set terminator const char* szVolDescTerm = "\377CD001\001"; memcpy (image + 0x9000, szVolDescTerm, strlen(szVolDescTerm) + 1); @@ -3992,61 +3997,61 @@ namespace VeraCrypt throw ParameterIncorrect (SRC_POS); memcpy (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET, RescueVolumeHeader, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); } else { Device bootDevice (GetSystemDriveConfiguration().DevicePath, true); bootDevice.CheckOpened (SRC_POS); bootDevice.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET); bootDevice.Read (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); } // Original system loader try { 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) { 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); - RescueIsoImage = new byte[RescueIsoImageSize]; + RescueIsoImage = new uint8[RescueIsoImageSize]; if (!RescueIsoImage) throw bad_alloc(); memcpy (RescueIsoImage, image, RescueIsoImageSize); if (!isoImagePath.empty()) { File isoFile (isoImagePath, false, true); isoFile.Write (image, RescueIsoImageSize); } } } #endif bool BootEncryption::IsCDRecorderPresent () { ICDBurn* pICDBurn; BOOL bHasRecorder = FALSE; if (SUCCEEDED( CoCreateInstance (CLSID_CDBurn, NULL,CLSCTX_INPROC_SERVER,IID_ICDBurn,(LPVOID*)&pICDBurn))) { if (pICDBurn->HasRecordableDrive (&bHasRecorder) != S_OK) { bHasRecorder = FALSE; } pICDBurn->Release(); } return bHasRecorder? true : false; } @@ -4365,186 +4370,186 @@ namespace VeraCrypt } return false; } #ifndef SETUP void BootEncryption::CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim) { PCRYPTO_INFO cryptoInfo = NULL; if (!IsRandomNumberGeneratorStarted()) throw ParameterIncorrect (SRC_POS); throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, pim, NULL, &cryptoInfo, volumeSize, 0, encryptedAreaStart, 0, TC_SYSENC_KEYSCOPE_MIN_REQ_PROG_VERSION, TC_HEADER_FLAG_ENCRYPTED_SYSTEM, TC_SECTOR_SIZE_BIOS, FALSE) != 0); finally_do_arg (PCRYPTO_INFO*, &cryptoInfo, { crypto_close (*finally_arg); }); // Initial rescue disk assumes encryption of the drive has been completed (EncryptedAreaLength == volumeSize) memcpy (RescueVolumeHeader, VolumeHeader, sizeof (RescueVolumeHeader)); if (0 != ReadVolumeHeader (TRUE, (char *) RescueVolumeHeader, password, pkcs5, pim, NULL, cryptoInfo)) throw ParameterIncorrect (SRC_POS); DecryptBuffer (RescueVolumeHeader + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); if (GetHeaderField32 (RescueVolumeHeader, TC_HEADER_OFFSET_MAGIC) != 0x56455241) throw ParameterIncorrect (SRC_POS); - byte *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH; + uint8 *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH; mputInt64 (fieldPos, volumeSize); // CRC of the header fields uint32 crc = GetCrc32 (RescueVolumeHeader + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_HEADER_CRC; mputLong (fieldPos, crc); EncryptBuffer (RescueVolumeHeader + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); VolumeHeaderValid = true; RescueVolumeHeaderValid = true; } void BootEncryption::InstallVolumeHeader () { if (!VolumeHeaderValid) throw ParameterIncorrect (SRC_POS); Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET); - device.Write ((byte *) VolumeHeader, sizeof (VolumeHeader)); + device.Write ((uint8 *) VolumeHeader, sizeof (VolumeHeader)); } // For synchronous operations use AbortSetupWait() void BootEncryption::AbortSetup () { CallDriver (TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP); } // For asynchronous operations use AbortSetup() void BootEncryption::AbortSetupWait () { CallDriver (TC_IOCTL_ABORT_BOOT_ENCRYPTION_SETUP); BootEncryptionStatus encStatus = GetStatus(); while (encStatus.SetupInProgress) { Sleep (TC_ABORT_TRANSFORM_WAIT_INTERVAL); encStatus = GetStatus(); } } void BootEncryption::BackupSystemLoader () { if (GetSystemDriveConfiguration().SystemPartition.IsGPT) { if (!IsAdmin()) { if (IsUacSupported()) { Elevator::BackupEfiSystemLoader (); return; } else { Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", ParentWindow); } } unsigned __int64 loaderSize = 0; - std::vector<byte> bootLoaderBuf; + std::vector<uint8> bootLoaderBuf; const wchar_t * szStdMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"; const wchar_t * szBackupMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc"; const char* g_szMsBootString = "bootmgfw.pdb"; bool bModifiedMsBoot = true; EfiBootInst.PrepareBootPartition(); EfiBootInst.GetFileSize(szStdMsBootloader, loaderSize); bootLoaderBuf.resize ((size_t) loaderSize); EfiBootInst.ReadFile(szStdMsBootloader, &bootLoaderBuf[0], (DWORD) loaderSize); // DcsBoot.efi is always smaller than 32KB if (loaderSize > 32768) { // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) bModifiedMsBoot = false; } else { if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, _T(TC_APP_NAME), wcslen (_T(TC_APP_NAME)) * 2)) { if (AskWarnNoYes ("TC_BOOT_LOADER_ALREADY_INSTALLED", ParentWindow) == IDNO) throw UserAbort (SRC_POS); // check if backup exists already and if it has bootmgfw signature if (EfiBootInst.FileExists (szBackupMsBootloader)) { EfiBootInst.GetFileSize(szBackupMsBootloader, loaderSize); bootLoaderBuf.resize ((size_t) loaderSize); EfiBootInst.ReadFile(szBackupMsBootloader, &bootLoaderBuf[0], (DWORD) loaderSize); if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { // copy it to original location EfiBootInst.CopyFile (szBackupMsBootloader, szStdMsBootloader); bModifiedMsBoot = false; } } if (bModifiedMsBoot) return; } } if (bModifiedMsBoot) { Error ("WINDOWS_EFI_BOOT_LOADER_MISSING", ParentWindow); throw UserAbort (SRC_POS); } EfiBootInst.CopyFile (szStdMsBootloader, szBackupMsBootloader); EfiBootInst.CopyFile (szStdMsBootloader, GetSystemLoaderBackupPath().c_str()); } else { Device device (GetSystemDriveConfiguration().DevicePath, true); device.CheckOpened (SRC_POS); - byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS]; + uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (bootLoaderBuf, sizeof (bootLoaderBuf)); // Prevent TrueCrypt loader from being backed up for (size_t i = 0; i < sizeof (bootLoaderBuf) - strlen (TC_APP_NAME); ++i) { if (memcmp (bootLoaderBuf + i, TC_APP_NAME, strlen (TC_APP_NAME)) == 0) { if (AskWarnNoYes ("TC_BOOT_LOADER_ALREADY_INSTALLED", ParentWindow) == IDNO) throw UserAbort (SRC_POS); return; } } File backupFile (GetSystemLoaderBackupPath(), false, true); backupFile.Write (bootLoaderBuf, sizeof (bootLoaderBuf)); } } void BootEncryption::RestoreSystemLoader () { SystemDriveConfiguration config = GetSystemDriveConfiguration(); if (config.SystemPartition.IsGPT) { if (!IsAdmin()) { if (IsUacSupported()) { Elevator::RestoreEfiSystemLoader (); return; @@ -4553,106 +4558,106 @@ namespace VeraCrypt { Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", ParentWindow); } } EfiBootInst.PrepareBootPartition(); EfiBootInst.DeleteStartExec(); EfiBootInst.DeleteStartExec(0xDC5B, L"Driver"); // remove DcsBml boot driver it was installed if (Is64BitOs()) EfiBootInst.RenameFile(L"\\EFI\\Boot\\original_bootx64.vc_backup", L"\\EFI\\Boot\\bootx64.efi", TRUE); else EfiBootInst.RenameFile(L"\\EFI\\Boot\\original_bootia32.vc_backup", L"\\EFI\\Boot\\bootia32.efi", TRUE); if (!EfiBootInst.RenameFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", TRUE)) { EfiBootConf conf; if (EfiBootInst.ReadConfig (L"\\EFI\\VeraCrypt\\DcsProp", conf) && strlen (conf.actionSuccessValue.c_str())) { wstring loaderPath; if (EfiBootConf::IsPostExecFileField (conf.actionSuccessValue, loaderPath)) { // check that it is not bootmgfw_ms.vc or bootmgfw.efi if ( (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc")) && (0 != _wcsicmp (loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi")) ) { const char* g_szMsBootString = "bootmgfw.pdb"; unsigned __int64 loaderSize = 0; EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize); - std::vector<byte> bootLoaderBuf ((size_t) loaderSize); + std::vector<uint8> bootLoaderBuf ((size_t) loaderSize); EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize); // look for bootmgfw.efi identifiant string if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString))) { EfiBootInst.RenameFile(loaderPath.c_str(), L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", TRUE); } } } } } EfiBootInst.DelFile(L"\\DcsBoot.efi"); EfiBootInst.DelFile(L"\\DcsInt.efi"); EfiBootInst.DelFile(L"\\DcsCfg.efi"); EfiBootInst.DelFile(L"\\LegacySpeaker.efi"); EfiBootInst.DelFile(L"\\DcsBoot"); EfiBootInst.DelFile(L"\\DcsProp"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBoot.efi"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsInt.dcs"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsCfg.dcs"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\LegacySpeaker.dcs"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBml.dcs"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsBoot"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsInfo.dcs"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\PlatformInfo"); EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsProp"); EfiBootInst.DelDir (L"\\EFI\\VeraCrypt"); } else { - byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS]; + uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS]; File backupFile (GetSystemLoaderBackupPath(), true); backupFile.CheckOpened(SRC_POS); if (backupFile.Read (bootLoaderBuf, sizeof (bootLoaderBuf)) != sizeof (bootLoaderBuf)) throw ParameterIncorrect (SRC_POS); Device device (GetSystemDriveConfiguration().DevicePath); device.CheckOpened (SRC_POS); // Preserve current partition table - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; device.SeekAt (0); device.Read (mbr, sizeof (mbr)); memcpy (bootLoaderBuf + TC_MAX_MBR_BOOT_CODE_SIZE, mbr + TC_MAX_MBR_BOOT_CODE_SIZE, sizeof (mbr) - TC_MAX_MBR_BOOT_CODE_SIZE); device.SeekAt (0); device.Write (bootLoaderBuf, sizeof (bootLoaderBuf)); } if (!IsAdmin() && IsUacSupported()) { Elevator::UpdateSetupConfigFile (false); } else { UpdateSetupConfigFile (false); } } #endif // SETUP static bool CompareMultiString (const char* str1, const char* str2) { size_t l1, l2; if (!str1 || !str2) return false; while (true) { l1 = strlen (str1); l2 = strlen (str2); if (l1 == l2) @@ -4718,155 +4723,152 @@ namespace VeraCrypt bRet = true; break; } offset = (DWORD) strlen (mszDest) + 1; mszDest += offset; remainingSize -= offset; } } return bRet; } void BootEncryption::RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid) { string filter; string filterReg; HKEY regKey; switch (filterType) { case DriveFilter: case VolumeFilter: filter = "veracrypt"; filterReg = "UpperFilters"; regKey = OpenDeviceClassRegKey (deviceClassGuid); throw_sys_if (regKey == INVALID_HANDLE_VALUE); break; case DumpFilter: - if (!IsOSAtLeast (WIN_VISTA)) - return; - filter = "veracrypt.sys"; filterReg = "DumpFilters"; SetLastError (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Control\\CrashControl", 0, KEY_READ | KEY_WRITE, ®Key)); throw_sys_if (GetLastError() != ERROR_SUCCESS); break; default: throw ParameterIncorrect (SRC_POS); } finally_do_arg (HKEY, regKey, { RegCloseKey (finally_arg); }); if (registerFilter) { if (filterType != DumpFilter) { // Register class filter below all other filters in the stack size_t strSize = filter.size() + 1; - byte regKeyBuf[65536]; + uint8 regKeyBuf[65536]; DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize); // SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly StringCchCopyA ((char *) regKeyBuf, ARRAYSIZE(regKeyBuf), filter.c_str()); if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, regKeyBuf + strSize, &size) != ERROR_SUCCESS) size = 1; SetLastError (RegSetValueExA (regKey, filterReg.c_str(), 0, REG_MULTI_SZ, regKeyBuf, (DWORD) strSize + size)); throw_sys_if (GetLastError() != ERROR_SUCCESS); } else { // workaround rare SetupInstallFromInfSection which overwrite value instead of appending new value // read initial value DWORD strSize = (DWORD) filter.size() + 1, expectedSize; Buffer expectedRegKeyBuf(65536), outputRegKeyBuf(65536); - byte* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr (); - byte* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr (); + uint8* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr (); + uint8* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr (); DWORD initialSize = (DWORD) (expectedRegKeyBuf.Size() - strSize - 2); if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbExpectedRegKeyBuf, &initialSize) != ERROR_SUCCESS) { StringCchCopyA ((char *) pbExpectedRegKeyBuf, expectedRegKeyBuf.Size(), filter.c_str()); pbExpectedRegKeyBuf [strSize] = 0; expectedSize = strSize + 1; } else { expectedSize = initialSize; AppendToMultiString ((char *) pbExpectedRegKeyBuf, (DWORD) expectedRegKeyBuf.Size(), expectedSize, filter.c_str()); } RegisterDriverInf (registerFilter, filter, filterReg, ParentWindow, regKey); // check if operation successful initialSize = (DWORD) outputRegKeyBuf.Size() - 2; if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbOutputRegKeyBuf, &initialSize) != ERROR_SUCCESS) { pbOutputRegKeyBuf [0] = 0; pbOutputRegKeyBuf [1] = 0; } else { // append two \0 at the end if they are missing if (pbOutputRegKeyBuf [initialSize - 1] != 0) { pbOutputRegKeyBuf [initialSize] = 0; pbOutputRegKeyBuf [initialSize + 1] = 0; } else if (pbOutputRegKeyBuf [initialSize - 2] != 0) { pbOutputRegKeyBuf [initialSize] = 0; } } if (!CompareMultiString ((char *) pbExpectedRegKeyBuf, (char *) pbOutputRegKeyBuf)) { // Set value manually SetLastError (RegSetValueExA (regKey, filterReg.c_str(), 0, REG_MULTI_SZ, pbExpectedRegKeyBuf, expectedSize)); throw_sys_if (GetLastError() != ERROR_SUCCESS); } } } else { RegisterDriverInf (registerFilter, filter, filterReg, ParentWindow, regKey); // remove value in case it was not done properly Buffer regKeyBuf(65536); - byte* pbRegKeyBuf = regKeyBuf.Ptr (); + uint8* pbRegKeyBuf = regKeyBuf.Ptr (); DWORD initialSize = (DWORD) regKeyBuf.Size() - 2; if ( (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbRegKeyBuf, &initialSize) == ERROR_SUCCESS) && (initialSize >= ((DWORD) filter.size())) ) { // append two \0 at the end if they are missing if (pbRegKeyBuf [initialSize - 1] != 0) { pbRegKeyBuf [initialSize] = 0; pbRegKeyBuf [initialSize + 1] = 0; initialSize += 2; } else if (pbRegKeyBuf [initialSize - 2] != 0) { pbRegKeyBuf [initialSize] = 0; initialSize ++; } if (RemoveFromMultiString ((char*) pbRegKeyBuf, initialSize, filter.c_str())) { // Set value manually SetLastError (RegSetValueExA (regKey, filterReg.c_str(), 0, REG_MULTI_SZ, pbRegKeyBuf, initialSize)); throw_sys_if (GetLastError() != ERROR_SUCCESS); } } } } @@ -5054,61 +5056,61 @@ namespace VeraCrypt NULL, NULL, NULL, NULL, _T(TC_APP_NAME) L" System Favorites")); } else { RegisterSystemFavoritesService (TRUE, TRUE); } } void BootEncryption::SetDriverConfigurationFlag (uint32 flag, bool state) { DWORD configMap = ReadDriverConfigurationFlags(); if (state) configMap |= flag; else configMap &= ~flag; #ifdef SETUP WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap); #else WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, configMap); #endif } void BootEncryption::SetServiceConfigurationFlag (uint32 flag, bool state) { - DWORD configMap = ReadDriverConfigurationFlags(); + DWORD configMap = ReadServiceConfigurationFlags(); if (state) configMap |= flag; else configMap &= ~flag; #ifdef SETUP WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, TC_SYSTEM_FAVORITES_SERVICE_NAME L"Config", configMap); #else WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, TC_SYSTEM_FAVORITES_SERVICE_NAME L"Config", configMap); #endif } #ifndef SETUP void BootEncryption::RegisterSystemFavoritesService (BOOL registerService) { if (!IsAdmin() && IsUacSupported()) { Elevator::RegisterSystemFavoritesService (registerService); return; } RegisterSystemFavoritesService (registerService, FALSE); } void BootEncryption::GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { SystemDriveConfiguration config = GetSystemDriveConfiguration (); if (config.SystemPartition.IsGPT && pSdn) { @@ -5300,66 +5302,66 @@ namespace VeraCrypt 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")) + GetString ("LEAKS_OUTSIDE_SYSPART_UNIVERSAL_EXPLANATION"), SRC_POS); } } // This operation may take a long time when an antivirus is installed and its real-time protection enabled. // Therefore, if calling it without the wizard displayed, it should be called with displayWaitDialog set to true. void BootEncryption::Deinstall (bool displayWaitDialog) { BootEncryptionStatus encStatus = GetStatus(); if (encStatus.DriveEncrypted || encStatus.DriveMounted) throw ParameterIncorrect (SRC_POS); SystemDriveConfiguration config = GetSystemDriveConfiguration (); if (!config.SystemPartition.IsGPT) { if (encStatus.VolumeHeaderPresent) { // Verify CRC of header salt Device device(config.DevicePath, true); device.CheckOpened(SRC_POS); - byte header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; + uint8 header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; device.SeekAt(TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET); device.Read(header, sizeof(header)); - if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((byte *)header, PKCS5_SALT_SIZE)) + if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((uint8 *)header, PKCS5_SALT_SIZE)) throw ParameterIncorrect(SRC_POS); } } try { RegisterFilterDriver (false, DriveFilter); RegisterFilterDriver (false, VolumeFilter); RegisterFilterDriver (false, DumpFilter); SetDriverServiceStartType (SERVICE_SYSTEM_START); } catch (...) { try { RegisterBootDriver (IsHiddenSystemRunning()); } catch (...) { } throw; } SetHiddenOSCreationPhase (TC_HIDDEN_OS_CREATION_PHASE_NONE); // In case RestoreSystemLoader() fails try { RegisterSystemFavoritesService (FALSE); } catch (...) { } @@ -5392,67 +5394,71 @@ namespace VeraCrypt char header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; Device device (config.DevicePath); device.CheckOpened (SRC_POS); // Only one algorithm is currently supported if (pkcs5 != 0) throw ParameterIncorrect (SRC_POS); int64 headerOffset = TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET; int64 backupHeaderOffset = -1; if (encStatus.HiddenSystem) { headerOffset = encStatus.HiddenSystemPartitionStart + TC_HIDDEN_VOLUME_HEADER_OFFSET; // Find hidden system partition foreach (const Partition &partition, config.Partitions) { if (partition.Info.StartingOffset.QuadPart == encStatus.HiddenSystemPartitionStart) { backupHeaderOffset = partition.Info.StartingOffset.QuadPart + partition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_SIZE; break; } } if (backupHeaderOffset == -1) throw ParameterIncorrect (SRC_POS); } device.SeekAt (headerOffset); - device.Read ((byte *) header, sizeof (header)); + device.Read ((uint8 *) header, sizeof (header)); PCRYPTO_INFO cryptoInfo = NULL; int status = ReadVolumeHeader (!encStatus.HiddenSystem, header, oldPassword, old_pkcs5, old_pim, &cryptoInfo, NULL); finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); }); + // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed + if ((status == 0) && cryptoInfo->bVulnerableMasterKey) + status = ERR_SYSENC_XTS_MASTERKEY_VULNERABLE; + if (status != 0) { handleError (hwndDlg, status, SRC_POS); return status; } // Change the PKCS-5 PRF if requested by user if (pkcs5 != 0) { cryptoInfo->pkcs5 = pkcs5; RandSetHashFunction (pkcs5); } if (Randinit() != 0) { if (CryptoAPILastError == ERROR_SUCCESS) throw RandInitFailed (SRC_POS, GetLastError ()); else throw CryptoApiFailed (SRC_POS, CryptoAPILastError); } finally_do ({ RandStop (FALSE); }); /* force the display of the random enriching dialog */ SetRandomPoolEnrichedByUserStatus (FALSE); NormalCursor(); UserEnrichRandomPool (hwndDlg); WaitCursor(); /* The header will be re-encrypted wipePassCount times to prevent adversaries from using @@ -5480,92 +5486,92 @@ namespace VeraCrypt PCRYPTO_INFO tmpCryptoInfo = NULL; status = CreateVolumeHeaderInMemory (hwndDlg, !encStatus.HiddenSystem, header, cryptoInfo->ea, cryptoInfo->mode, newPassword, cryptoInfo->pkcs5, pim, (char *) cryptoInfo->master_keydata, &tmpCryptoInfo, cryptoInfo->VolumeSize.Value, cryptoInfo->hiddenVolumeSize, cryptoInfo->EncryptedAreaStart.Value, cryptoInfo->EncryptedAreaLength.Value, cryptoInfo->RequiredProgramVersion, cryptoInfo->HeaderFlags | TC_HEADER_FLAG_ENCRYPTED_SYSTEM, cryptoInfo->SectorSize, wipePass < wipePassCount - 1); if (tmpCryptoInfo) crypto_close (tmpCryptoInfo); if (status != 0) { handleError (hwndDlg, status, SRC_POS); return status; } device.SeekAt (headerOffset); - device.Write ((byte *) header, sizeof (header)); + device.Write ((uint8 *) header, sizeof (header)); headerUpdated = true; } if (!encStatus.HiddenSystem || backupHeader) break; backupHeader = TRUE; headerOffset = backupHeaderOffset; } } catch (Exception &e) { e.Show (hwndDlg); result = ERR_OS_ERROR; } if (headerUpdated) { bool storedPimUpdateNeeded = false; ReopenBootVolumeHeaderRequest reopenRequest; reopenRequest.VolumePassword = *newPassword; reopenRequest.pkcs5_prf = cryptoInfo->pkcs5; reopenRequest.pim = pim; finally_do_arg (ReopenBootVolumeHeaderRequest*, &reopenRequest, { burn (finally_arg, sizeof (*finally_arg)); }); if (old_pim != pim) { try { // check if PIM is stored in MBR - byte userConfig = 0; + uint8 userConfig = 0; if ( ReadBootSectorConfig (nullptr, 0, &userConfig) && (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM) ) { storedPimUpdateNeeded = true; } } catch (...) { } } try { // force update of bootloader if fingerprint doesn't match or if the stored PIM changed if (storedPimUpdateNeeded || !CheckBootloaderFingerprint (true)) InstallBootLoader (device, true, false, pim, cryptoInfo->pkcs5); } catch (...) {} CallDriver (TC_IOCTL_REOPEN_BOOT_VOLUME_HEADER, &reopenRequest, sizeof (reopenRequest)); } return result; } void BootEncryption::CheckEncryptionSetupResult () { @@ -5788,61 +5794,61 @@ namespace VeraCrypt void BootEncryption::DeleteFileAdmin (const wstring &file) { if (!IsAdmin() && IsUacSupported()) Elevator::DeleteFile (file); else throw_sys_if (!::DeleteFile (file.c_str())); } #endif // !SETUP uint32 BootEncryption::ReadDriverConfigurationFlags () { DWORD configMap; if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap)) configMap = 0; return configMap; } uint32 BootEncryption::ReadServiceConfigurationFlags () { DWORD configMap; if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, TC_SYSTEM_FAVORITES_SERVICE_NAME L"Config", &configMap)) configMap = 0; return configMap; } - void BootEncryption::WriteBootDriveSector (uint64 offset, byte *data) + void BootEncryption::WriteBootDriveSector (uint64 offset, uint8 *data) { WriteBootDriveSectorRequest request; request.Offset.QuadPart = offset; memcpy (request.Data, data, sizeof (request.Data)); CallDriver (TC_IOCTL_WRITE_BOOT_DRIVE_SECTOR, &request, sizeof (request), NULL, 0); } void BootEncryption::RegisterBootDriver (bool hiddenSystem) { SetDriverServiceStartType (SERVICE_BOOT_START); try { RegisterFilterDriver (false, DriveFilter); RegisterFilterDriver (false, VolumeFilter); RegisterFilterDriver (false, DumpFilter); } catch (...) { } try { RegisterFilterDriver (true, DriveFilter); if (hiddenSystem) RegisterFilterDriver (true, VolumeFilter); RegisterFilterDriver (true, DumpFilter); } catch (...) diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h index ddf6f3e5..2ec92503 100644 --- a/src/Common/BootEncryption.h +++ b/src/Common/BootEncryption.h @@ -10,157 +10,157 @@ code distribution packages. */ #ifndef TC_HEADER_Common_BootEncryption #define TC_HEADER_Common_BootEncryption #include "Tcdefs.h" #include "Dlgcode.h" #include "Exception.h" #include "Platform/PlatformBase.h" #include "Volumes.h" typedef ULONG (WINAPI *RtlNtStatusToDosErrorFn)( NTSTATUS Status ); using namespace std; namespace VeraCrypt { class File { public: File () : Elevated (false), FileOpen (false), ReadOnly (false), FilePointerPosition(0), Handle(INVALID_HANDLE_VALUE), IsDevice(false), LastError(0) { } File (wstring path,bool readOnly = false, bool create = false); virtual ~File () { Close(); } bool IsOpened () const { return FileOpen;} void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} } void Close (); - DWORD Read (byte *buffer, DWORD size); - void Write (byte *buffer, DWORD size); + DWORD Read (uint8 *buffer, DWORD size); + void Write (uint8 *buffer, DWORD size); void SeekAt (int64 position); void GetFileSize (unsigned __int64& size); void GetFileSize (DWORD& dwSize); bool IoCtl(DWORD code, void* inBuf, DWORD inBufSize, void* outBuf, DWORD outBufSize); protected: bool Elevated; bool FileOpen; bool ReadOnly; uint64 FilePointerPosition; HANDLE Handle; bool IsDevice; wstring Path; DWORD LastError; BYTE ReadBuffer[4096]; }; class Device : public File { public: Device (wstring path,bool readOnly = false); virtual ~Device () {} }; class Buffer { public: Buffer (size_t size) : DataSize (size) { - DataPtr = new byte[size]; + DataPtr = new uint8[size]; if (!DataPtr) throw bad_alloc(); } ~Buffer () { delete[] DataPtr; } - byte *Ptr () const { return DataPtr; } + uint8 *Ptr () const { return DataPtr; } size_t Size () const { return DataSize; } void Resize (size_t newSize) { if (newSize > DataSize) { - byte *tmp = new byte[newSize]; + uint8 *tmp = new uint8[newSize]; if (!tmp) throw bad_alloc(); memcpy (tmp, DataPtr, DataSize); delete [] DataPtr; DataPtr = tmp; } DataSize = newSize; } protected: - byte *DataPtr; + uint8 *DataPtr; size_t DataSize; }; struct Partition { wstring DevicePath; PARTITION_INFORMATION Info; wstring MountPoint; size_t Number; BOOL IsGPT; wstring VolumeNameId; }; typedef list <Partition> PartitionList; #pragma pack (push) #pragma pack(1) struct PartitionEntryMBR { - byte BootIndicator; + uint8 BootIndicator; - byte StartHead; - byte StartCylSector; - byte StartCylinder; + uint8 StartHead; + uint8 StartCylSector; + uint8 StartCylinder; - byte Type; + uint8 Type; - byte EndHead; - byte EndSector; - byte EndCylinder; + uint8 EndHead; + uint8 EndSector; + uint8 EndCylinder; uint32 StartLBA; uint32 SectorCountLBA; }; struct MBR { - byte Code[446]; + uint8 Code[446]; PartitionEntryMBR Partitions[4]; uint16 Signature; }; #pragma pack (pop) struct SystemDriveConfiguration { wstring DeviceKernelPath; wstring DevicePath; int DriveNumber; Partition DrivePartition; bool ExtraBootPartitionPresent; int64 InitialUnallocatedSpace; PartitionList Partitions; Partition SystemPartition; int64 TotalUnallocatedSpace; bool SystemLoaderPresent; }; class EfiBootConf { public: int passwordType; string passwordMsg; string passwordPicture; string hashMsg; int hashAlgo; int requestHash; @@ -173,199 +173,199 @@ namespace VeraCrypt int bmlDriverEnabled; string actionSuccessValue; EfiBootConf(); static BOOL ReadConfigValue (char* configContent, const char *configKey, char *configValue, int maxValueSize); static int ReadConfigInteger (char* configContent, const char *configKey, int defaultValue); static char *ReadConfigString (char* configContent, const char *configKey, char *defaultValue, char *str, int maxLen); static BOOL WriteConfigString (FILE* configFile, char* configContent, const char *configKey, const char *configValue); static BOOL WriteConfigInteger (FILE* configFile, char* configContent, const char *configKey, int configValue); BOOL Load (const wchar_t* fileName); void Load (char* configContent); BOOL Save (const wchar_t* fileName, HWND hwnd); static BOOL IsPostExecFileField (const string& szFieldValue, string& filePath); static BOOL IsPostExecFileField (const string& szFieldValue, wstring& filePath); }; void GetVolumeESP(wstring& path, wstring& bootVolumePath); std::string ReadESPFile (LPCWSTR szFilePath, bool bSkipUTF8BOM); void WriteESPFile (LPCWSTR szFilePath, LPBYTE pbData, DWORD dwDataLen, bool bAddUTF8BOM); class EfiBoot { public: EfiBoot(); void PrepareBootPartition(bool bDisableException = false); bool IsEfiBoot(); void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL); void SetStartExec(wstring description, wstring execPath, bool setBootEntry = true, bool forceFirstBootEntry = true, bool setBootNext = true, uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL, uint32 attr = 1); - void SaveFile(const wchar_t* name, byte* data, DWORD size); + void SaveFile(const wchar_t* name, uint8* data, DWORD size); void GetFileSize(const wchar_t* name, unsigned __int64& size); - void ReadFile(const wchar_t* name, byte* data, DWORD size); + void ReadFile(const wchar_t* name, uint8* data, DWORD size); void CopyFile(const wchar_t* name, const wchar_t* targetName); bool FileExists(const wchar_t* name); static bool CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2); - static bool CompareFileData (const wchar_t* fileName, const byte* data, DWORD size); + static bool CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size); BOOL RenameFile(const wchar_t* name, const wchar_t* nameNew, BOOL bForce); BOOL DelFile(const wchar_t* name); BOOL MkDir(const wchar_t* name, bool& bAlreadyExists); BOOL ReadConfig (const wchar_t* name, EfiBootConf& conf); BOOL UpdateConfig (const wchar_t* name, int pim, int hashAlgo, HWND hwndDlg); BOOL WriteConfig (const wchar_t* name, bool preserveUserConfig, int pim, int hashAlgo, const char* passPromptMsg, HWND hwndDlg); BOOL DelDir(const wchar_t* name); PSTORAGE_DEVICE_NUMBER GetStorageDeviceNumber () { if (bDeviceInfoValid) return &sdn; else { SetLastError (ERROR_INVALID_DRIVE); throw SystemException(SRC_POS);}} protected: bool m_bMounted; std::wstring EfiBootPartPath; STORAGE_DEVICE_NUMBER sdn; PARTITION_INFORMATION_EX partInfo; bool bDeviceInfoValid; WCHAR tempBuf[1024]; std::wstring BootVolumePath; }; class BootEncryption { public: BootEncryption (HWND parent, bool postOOBE = false, bool setBootEntry = true, bool forceFirstBootEntry = true, bool setBootNext = false); ~BootEncryption (); enum FilterType { DriveFilter, VolumeFilter, DumpFilter }; void SetParentWindow (HWND parent) { ParentWindow = parent; } void AbortDecoyOSWipe (); void AbortSetup (); void AbortSetupWait (); void CallDriver (DWORD ioctl, void *input = nullptr, DWORD inputSize = 0, void *output = nullptr, DWORD outputSize = 0); int ChangePassword (Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg); void CheckDecoyOSWipeResult (); void CheckEncryptionSetupResult (); void CheckRequirements (); void CheckRequirementsHiddenOS (); void CopyFileAdmin (const wstring &sourceFile, const wstring &destinationFile); void CreateRescueIsoImage (bool initialSetup, const wstring &isoImagePath); void Deinstall (bool displayWaitDialog = false); void DeleteFileAdmin (const wstring &file); DecoySystemWipeStatus GetDecoyOSWipeStatus (); DWORD GetDriverServiceStartType (); unsigned int GetHiddenOSCreationPhase (); uint16 GetInstalledBootLoaderVersion (); - void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]); + void GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]); Partition GetPartitionForHiddenOS (); bool IsBootLoaderOnDrive (wchar_t *devicePath); BootEncryptionStatus GetStatus (); void GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties); SystemDriveConfiguration GetSystemDriveConfiguration (); void Install (bool hiddenSystem, int hashAlgo); void InstallBootLoader (Device& device, bool preserveUserConfig = false, bool hiddenOSCreation = false, int pim = -1, int hashAlg = -1); void InstallBootLoader (bool preserveUserConfig = false, bool hiddenOSCreation = false, int pim = -1, int hashAlg = -1); bool CheckBootloaderFingerprint (bool bSilent = false); void InvalidateCachedSysDriveProperties (); bool IsCDRecorderPresent (); bool IsHiddenSystemRunning (); bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); void PrepareHiddenOSCreation (int ea, int mode, int pkcs5); void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath); void ProbeRealSystemDriveSize (); - bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr); + bool ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr); uint32 ReadDriverConfigurationFlags (); uint32 ReadServiceConfigurationFlags (); void RegisterBootDriver (bool hiddenSystem); void RegisterFilterDriver (bool registerDriver, FilterType filterType); void RegisterSystemFavoritesService (BOOL registerService); void RegisterSystemFavoritesService (BOOL registerService, BOOL noFileHandling); bool IsSystemFavoritesServiceRunning (); void UpdateSystemFavoritesService (); void RenameDeprecatedSystemLoaderBackup (); bool RestartComputer (BOOL bShutdown = FALSE); void InitialSecurityChecksForHiddenOS (); void RestrictPagingFilesToSystemPartition (); void SetDriverConfigurationFlag (uint32 flag, bool state); void SetServiceConfigurationFlag (uint32 flag, bool state); void SetDriverServiceStartType (DWORD startType); void SetHiddenOSCreationPhase (unsigned int newPhase); void StartDecryption (BOOL discardUnreadableEncryptedSectors); void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm); void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors); - bool SystemDriveContainsPartitionType (byte type); + bool SystemDriveContainsPartitionType (uint8 type); bool SystemDriveContainsExtendedPartition (); bool SystemDriveContainsNonStandardPartitions (); bool SystemPartitionCoversWholeDrive (); bool SystemDriveIsDynamic (); bool VerifyRescueDisk (); bool VerifyRescueDiskImage (const wchar_t* imageFile); void WipeHiddenOSCreationConfig (); - void WriteBootDriveSector (uint64 offset, byte *data); - void WriteBootSectorConfig (const byte newConfig[]); - void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg); - void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg); + void WriteBootDriveSector (uint64 offset, uint8 *data); + void WriteBootSectorConfig (const uint8 newConfig[]); + void WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg); + void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg); void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value); void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn); void BackupSystemLoader (); void RestoreSystemLoader (); static void UpdateSetupConfigFile (bool bForInstall); void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded); bool IsUsingUnsupportedAlgorithm(LONG driverVersion); void NotifyService (DWORD dwNotifyCmd); protected: static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image - void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false); + void CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false); void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim); wstring GetSystemLoaderBackupPath (); - uint32 GetChecksum (byte *data, size_t size); + uint32 GetChecksum (uint8 *data, size_t size); DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber); PartitionList GetDrivePartitions (int driveNumber); wstring GetRemarksOnHiddenOS (); wstring GetWindowsDirectory (); void RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid = nullptr); void InstallVolumeHeader (); HWND ParentWindow; SystemDriveConfiguration DriveConfig; int SelectedEncryptionAlgorithmId; int SelectedPrfAlgorithmId; Partition HiddenOSCandidatePartition; - byte *RescueIsoImage; - byte *RescueZipData; + uint8 *RescueIsoImage; + uint8 *RescueZipData; unsigned long RescueZipSize; - byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; - byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; + uint8 RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; + uint8 VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; bool DriveConfigValid; bool RealSystemDriveSizeValid; bool RescueVolumeHeaderValid; bool VolumeHeaderValid; bool PostOOBEMode; bool SetBootNext; bool SetBootEntry; bool ForceFirstBootEntry; }; } #define TC_ABORT_TRANSFORM_WAIT_INTERVAL 10 #define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_NTFS 2.1 #define MIN_HIDDENOS_DECOY_PARTITION_SIZE_RATIO_FAT 1.05 #define TC_SYS_BOOT_LOADER_BACKUP_NAME L"Original System Loader" #define TC_SYS_BOOT_LOADER_BACKUP_NAME_LEGACY L"Original System Loader.bak" // Deprecated to prevent removal by some "cleaners" #define TC_SYSTEM_FAVORITES_SERVICE_NAME _T(TC_APP_NAME) L"SystemFavorites" #define TC_SYSTEM_FAVORITES_SERVICE_LOAD_ORDER_GROUP L"Event Log" #define TC_SYSTEM_FAVORITES_SERVICE_CMDLINE_OPTION L"/systemFavoritesService" #define VC_SYSTEM_FAVORITES_SERVICE_ARG_SKIP_MOUNT L"/SkipMount" #define VC_SYSTEM_FAVORITES_SERVICE_ARG_UPDATE_LOADER L"/UpdateLoader" #define VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER 0x1 #define VC_SYSTEM_FAVORITES_SERVICE_CONFIG_FORCE_SET_BOOTNEXT 0x2 #define VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_SET_BOOTENTRY 0x4 #define VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_FORCE_FIRST_BOOTENTRY 0x8 diff --git a/src/Common/CommandAPDU.cpp b/src/Common/CommandAPDU.cpp index b202cb13..46aab465 100644 --- a/src/Common/CommandAPDU.cpp +++ b/src/Common/CommandAPDU.cpp @@ -89,278 +89,278 @@ namespace VeraCrypt // case 3e m_nc = l2; m_dataOffset = 7; m_isExtendedAPDU = true; goto success; } if (m_apdu.size() == 4 + 5 + l2) { // case 4e m_nc = l2; m_dataOffset = 7; leOfs = m_apdu.size() - 2; l3 = ((m_apdu[leOfs] & 0xff) << 8) | (m_apdu[leOfs + 1] & 0xff); m_ne = (l3 == 0) ? 65536 : l3; m_isExtendedAPDU = true; goto success; } else { m_parsingErrorStr = vformat("Invalid APDU : b1 = %u, b2||b3 = %u, expected length to be %u or %u, got %zu", l1, l2, 4 + 3 + l2, 4 + 5 + l2, m_apdu.size()); goto failure; } success: m_parsedSuccessfully = true; failure: clear(); } - void CommandAPDU::init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne) + void CommandAPDU::init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne) { m_nc = 0; m_ne = 0; m_dataOffset = 0; m_isExtendedAPDU = false; m_parsingErrorStr = ""; m_parsedSuccessfully = false; if (dataLength > 65535) { m_parsingErrorStr = vformat("dataLength is too large (> 65535) - dataLength = %u", dataLength); clear(); return; } if (ne > 65536) { m_parsingErrorStr = vformat("ne is too large (> 65536) - ne = %u", ne); clear(); return; } m_ne = ne; m_nc = dataLength; if (dataLength == 0) { if (m_ne == 0) { // case 1 m_apdu.resize(4, 0); setHeader(cla, ins, p1, p2); } else { // case 2s or 2e if (ne <= 256) { // case 2s // 256 is encoded as 0x00 - byte len = (m_ne != 256) ? (byte)m_ne : 0; + uint8 len = (m_ne != 256) ? (uint8)m_ne : 0; m_apdu.resize(5, 0); setHeader(cla, ins, p1, p2); m_apdu[4] = len; } else { // case 2e - byte l1, l2; + uint8 l1, l2; // 65536 is encoded as 0x00 0x00 if (m_ne == 65536) { l1 = 0; l2 = 0; } else { - l1 = (byte)(m_ne >> 8); - l2 = (byte)m_ne; + l1 = (uint8)(m_ne >> 8); + l2 = (uint8)m_ne; } m_apdu.resize(7, 0); setHeader(cla, ins, p1, p2); m_apdu[5] = l1; m_apdu[6] = l2; m_isExtendedAPDU = true; } } } else { if (m_ne == 0) { // case 3s or 3e if (dataLength <= 255) { // case 3s m_apdu.resize(4 + 1 + dataLength, 0); setHeader(cla, ins, p1, p2); - m_apdu[4] = (byte)dataLength; + m_apdu[4] = (uint8)dataLength; m_dataOffset = 5; memcpy(m_apdu.data() + 5, data + dataOffset, dataLength); } else { // case 3e m_apdu.resize(4 + 3 + dataLength, 0); setHeader(cla, ins, p1, p2); m_apdu[4] = 0; - m_apdu[5] = (byte)(dataLength >> 8); - m_apdu[6] = (byte)dataLength; + m_apdu[5] = (uint8)(dataLength >> 8); + m_apdu[6] = (uint8)dataLength; m_dataOffset = 7; memcpy(m_apdu.data() + 7, data + dataOffset, dataLength); m_isExtendedAPDU = true; } } else { // case 4s or 4e if ((dataLength <= 255) && (m_ne <= 256)) { // case 4s m_apdu.resize(4 + 2 + dataLength, 0); setHeader(cla, ins, p1, p2); - m_apdu[4] = (byte)dataLength; + m_apdu[4] = (uint8)dataLength; m_dataOffset = 5; memcpy(m_apdu.data() + 5, data + dataOffset, dataLength); - m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (byte)m_ne : 0; + m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (uint8)m_ne : 0; } else { // case 4e m_apdu.resize(4 + 5 + dataLength, 0); setHeader(cla, ins, p1, p2); m_apdu[4] = 0; - m_apdu[5] = (byte)(dataLength >> 8); - m_apdu[6] = (byte)dataLength; + m_apdu[5] = (uint8)(dataLength >> 8); + m_apdu[6] = (uint8)dataLength; m_dataOffset = 7; memcpy(m_apdu.data() + 7, data + dataOffset, dataLength); if (ne != 65536) { size_t leOfs = m_apdu.size() - 2; - m_apdu[leOfs] = (byte)(m_ne >> 8); - m_apdu[leOfs + 1] = (byte)m_ne; + m_apdu[leOfs] = (uint8)(m_ne >> 8); + m_apdu[leOfs + 1] = (uint8)m_ne; } // else le == 65536: no need to fill in, encoded as 0 m_isExtendedAPDU = true; } } } m_parsedSuccessfully = true; } - void CommandAPDU::setHeader(byte cla, byte ins, byte p1, byte p2) + void CommandAPDU::setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2) { - m_apdu[0] = (byte)cla; - m_apdu[1] = (byte)ins; - m_apdu[2] = (byte)p1; - m_apdu[3] = (byte)p2; + m_apdu[0] = (uint8)cla; + m_apdu[1] = (uint8)ins; + m_apdu[2] = (uint8)p1; + m_apdu[3] = (uint8)p2; } void CommandAPDU::clear() { m_apdu.clear(); m_nc = 0; m_ne = 0; m_dataOffset = 0; } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne) { init(cla, ins, p1, p2, data, dataOffset, dataLength, ne); } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2) { init(cla, ins, p1, p2, NULL, 0, 0, 0); } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne) { init(cla, ins, p1, p2, NULL, 0, 0, ne); } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data) { init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), 0); } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength) { init(cla, ins, p1, p2, data, dataOffset, dataLength, 0); } - CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne) + CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne) { init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), ne); } - CommandAPDU::CommandAPDU(const vector<byte>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false) + CommandAPDU::CommandAPDU(const vector<uint8>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false) { m_apdu = apdu; parse(); } - byte CommandAPDU::getCLA() + uint8 CommandAPDU::getCLA() { return m_apdu[0] & 0xff; } - byte CommandAPDU::getINS() + uint8 CommandAPDU::getINS() { return m_apdu[1] & 0xff; } - byte CommandAPDU::getP1() + uint8 CommandAPDU::getP1() { return m_apdu[2] & 0xff; } - byte CommandAPDU::getP2() + uint8 CommandAPDU::getP2() { return m_apdu[3] & 0xff; } uint32 CommandAPDU::getNc() { return m_nc; } - const vector<byte> CommandAPDU::getData() + const vector<uint8> CommandAPDU::getData() { - vector<byte> data; + vector<uint8> data; if (m_nc > 0) { data.resize(m_nc, 0); memcpy(data.data(), m_apdu.data() + m_dataOffset, data.size()); } return data; } uint32 CommandAPDU::getNe() { return m_ne; } - const vector<byte> CommandAPDU::getAPDU() + const vector<uint8> CommandAPDU::getAPDU() { return m_apdu; } bool CommandAPDU::isExtended() { return m_isExtendedAPDU; } bool CommandAPDU::isValid() { return m_parsedSuccessfully; } std::string CommandAPDU::getErrorStr() { return m_parsingErrorStr; } } diff --git a/src/Common/CommandAPDU.h b/src/Common/CommandAPDU.h index 98825faa..f1adf176 100644 --- a/src/Common/CommandAPDU.h +++ b/src/Common/CommandAPDU.h @@ -7,87 +7,87 @@ namespace VeraCrypt { inline const std::string vformat(const char* zcFormat, ...) { if (zcFormat) { va_list vaArgs; va_start(vaArgs, zcFormat); const int iLen = vsnprintf(NULL, 0, zcFormat, vaArgs); va_end(vaArgs); if (iLen) { std::vector<char> zc((size_t)iLen + 1); va_start(vaArgs, zcFormat); vsnprintf(zc.data(), zc.size(), zcFormat, vaArgs); va_end(vaArgs); return std::string(zc.data(), iLen); } } return ""; } class CommandAPDU { protected: - vector<byte> m_apdu; + vector<uint8> m_apdu; uint32 m_nc; uint32 m_ne; uint32 m_dataOffset; bool m_isExtendedAPDU; std::string m_parsingErrorStr; bool m_parsedSuccessfully; void parse(); - void init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne); - void setHeader(byte cla, byte ins, byte p1, byte p2); + void init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne); + void setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2); public: void clear(); CommandAPDU(); - CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne); - CommandAPDU(byte cla, byte ins, byte p1, byte p2); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2); - CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne); - CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data); - CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength); - CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne); + CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne); - CommandAPDU(const vector<byte>& apdu); + CommandAPDU(const vector<uint8>& apdu); - byte getCLA(); + uint8 getCLA(); - byte getINS(); + uint8 getINS(); - byte getP1(); + uint8 getP1(); - byte getP2(); + uint8 getP2(); uint32 getNc(); - const vector<byte> getData(); + const vector<uint8> getData(); uint32 getNe(); - const vector<byte> getAPDU(); + const vector<uint8> getAPDU(); bool isValid(); std::string getErrorStr(); bool isExtended(); }; }; #endif // TC_HEADER_Common_CommandAPDU
\ No newline at end of file diff --git a/src/Common/Common.rc b/src/Common/Common.rc index aa1ca18f..41778dfc 100644 --- a/src/Common/Common.rc +++ b/src/Common/Common.rc @@ -73,82 +73,83 @@ BEGIN CONTROL "Mount volume as read-&only",IDC_MOUNT_READONLY,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,11,231,10 CONTROL "Mount volume as removable &medium",IDC_MOUNT_REMOVABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,25,231,10 CONTROL "Use backup header embedded in &volume if available",IDC_USE_EMBEDDED_HEADER_BAK, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,39,295,11 CONTROL "Mount partition &using system encryption without pre-boot authentication",IDC_MOUNT_SYSENC_PART_WITHOUT_PBA, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,53,295,11 EDITTEXT IDC_VOLUME_LABEL,134,82,167,14,ES_AUTOHSCROLL CONTROL "&Protect hidden volume against damage caused by writing to outer volume",IDC_PROTECT_HIDDEN_VOL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,115,283,10 EDITTEXT IDC_PASSWORD_PROT_HIDVOL,134,133,167,14,ES_PASSWORD | ES_AUTOHSCROLL COMBOBOX IDC_PKCS5_PRF_ID,134,154,91,90,CBS_DROPDOWNLIST | WS_TABSTOP EDITTEXT IDC_PIM,134,174,42,14,ES_RIGHT | ES_PASSWORD | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE CONTROL "Use P&IM",IDC_PIM_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,179,97,10 LTEXT "(Empty or 0 for default iterations)",IDC_PIM_HELP,181,177,121,8,NOT WS_VISIBLE CONTROL "&Display password",IDC_SHOW_PASSWORD_MO,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,192,90,10 CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE_HIDVOL_PROT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,134,205,90,10 PUSHBUTTON "&Keyfiles...",IDC_KEYFILES_HIDVOL_PROT,239,201,60,14 DEFPUSHBUTTON "OK",IDOK,246,7,60,14 PUSHBUTTON "Cancel",IDCANCEL,246,24,60,14 LTEXT "What is hidden volume protection?",IDC_LINK_HIDVOL_PROTECTION_INFO,16,220,279,10,SS_NOTIFY RTEXT "P&assword to hidden volume:\n(if empty, cache is used)",IDT_HIDDEN_PROT_PASSWD,15,132,115,17,0,WS_EX_RIGHT GROUPBOX "Hidden Volume Protection",IDT_HIDDEN_VOL_PROTECTION,6,101,299,136 RTEXT "PKCS-5 PRF:",IDT_PKCS5_PRF,15,155,115,17 RTEXT "Volume PIM:",IDT_PIM,15,177,115,17,NOT WS_VISIBLE LTEXT "Volume Label in Windows:",IDT_VOLUME_LABEL,12,85,115,8 CONTROL "Only create virtual device without mounting on selected drive letter",IDC_DISABLE_MOUNT_MANAGER, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,12,67,297,10 END -IDD_KEYFILES DIALOGEX 0, 0, 363, 251 +IDD_KEYFILES DIALOGEX 0, 0, 363, 264 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Keyfiles" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_KEYLIST,"SysListView32",LVS_REPORT | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,8,275,118 PUSHBUTTON "Add &Files...",IDC_KEYADD,7,132,61,14 PUSHBUTTON "Add &Path...",IDC_ADD_KEYFILE_PATH,79,132,61,14 PUSHBUTTON "Add &Token Files...",IDC_TOKEN_FILES_ADD,151,132,65,14 PUSHBUTTON "&Remove",IDC_KEYREMOVE,227,132,61,14 PUSHBUTTON "Remove &All",IDC_KEYREMOVEALL,299,132,61,14 - CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,232,100,11 - PUSHBUTTON "&Generate Random Keyfile...",IDC_GENERATE_KEYFILE,237,230,123,14 + CONTROL "U&se keyfiles",IDC_KEYFILES_ENABLE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,7,244,100,11 + PUSHBUTTON "&Generate Random Keyfile...",IDC_GENERATE_KEYFILE,237,243,123,14 DEFPUSHBUTTON "OK",IDOK,290,8,70,14 PUSHBUTTON "Cancel",IDCANCEL,290,25,70,14 LTEXT "",IDT_KEYFILES_NOTE,10,161,346,41,0,WS_EX_TRANSPARENT LTEXT "WARNING: If you lose a keyfile or if any bit of its first 1024 kilobytes changes, it will be impossible to mount volumes that use the keyfile!",IDT_KEYFILE_WARNING,290,44,69,85,0,WS_EX_TRANSPARENT CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,154,361,1,WS_EX_STATICEDGE - CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,209,361,1,WS_EX_STATICEDGE - LTEXT "More information on keyfiles",IDC_LINK_KEYFILES_INFO,111,233,124,10,SS_NOTIFY + CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,224,361,1,WS_EX_STATICEDGE + LTEXT "More information on keyfiles",IDC_LINK_KEYFILES_INFO,111,245,124,10,SS_NOTIFY CONTROL "Try first to mount with an empty password",IDC_KEYFILES_TRY_EMPTY_PASSWORD, - "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,7,217,310,10 + "Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,7,229,310,10 + RTEXT "Important information on using third-party file extensions",IDC_LINK_KEYFILES_EXTENSIONS_WARNING,161,210,195,8,SS_NOTIFY END IDD_LANGUAGE DIALOGEX 0, 0, 209, 183 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Language" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LISTBOX IDC_LANGLIST,6,7,197,67,LBS_SORT | LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_LANGPACK_CREDITS,6,108,197,28,ES_MULTILINE | ES_READONLY | WS_VSCROLL | NOT WS_TABSTOP CTEXT "Download language pack",IDC_GET_LANG_PACKS,2,146,205,10,SS_NOTIFY DEFPUSHBUTTON "OK",IDOK,97,165,50,14 PUSHBUTTON "Cancel",IDCANCEL,153,165,50,14 LTEXT "Translated by:",IDT_LANGPACK_AUTHORS,6,99,101,9,SS_NOTIFY,WS_EX_TRANSPARENT RTEXT "",IDC_LANGPACK_VERSION,79,86,118,11 GROUPBOX "Active language pack",IDT_ACTIVE_LANG_PACK,0,77,209,65 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,158,208,1,WS_EX_STATICEDGE END IDD_BENCHMARK_DLG DIALOGEX 0, 0, 330, 247 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Algorithms Benchmark" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN COMBOBOX IDC_BENCHMARK_LIST,55,11,87,53,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_BENCHMARK_BUFFER_SIZE,209,11,87,129,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP EDITTEXT IDC_PIM,209,11,42,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER | NOT WS_VISIBLE CONTROL "Pre-Boot",IDC_BENCHMARK_PREBOOT,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,258,14,71,10 COMBOBOX IDC_BENCHMARK_SORT_METHOD,55,40,139,74,CBS_DROPDOWNLIST | CBS_AUTOHSCROLL | WS_VSCROLL | WS_TABSTOP DEFPUSHBUTTON "Benchmark",IDC_PERFORM_BENCHMARK,265,60,58,14 PUSHBUTTON "Close",IDCLOSE,265,79,58,14 @@ -184,85 +185,86 @@ BEGIN PUSHBUTTON "&Decrypt",IDC_DECRYPT,65,229,52,14 PUSHBUTTON "&Auto-Test All",IDC_AUTO,129,229,67,14,BS_MULTILINE PUSHBUTTON "&Reset",IDC_RESET,208,229,52,14 PUSHBUTTON "Close",IDCLOSE,266,229,52,14 GROUPBOX "Key (hexadecimal)",IDT_TEST_KEY,1,26,323,49 GROUPBOX "Plaintext (hexadecimal)",IDT_TEST_PLAINTEXT,1,140,323,33 GROUPBOX "Ciphertext (hexadecimal)",IDT_TEST_CIPHERTEXT,1,174,323,33 RTEXT "",IDC_TESTS_MESSAGE,50,213,178,10 CONTROL "",IDC_REDTICK,"VCREDTICK",0x0,234,214,10,8 RTEXT "Key size:",IDT_KEY,8,57,56,8 RTEXT "Plaintext size:",IDT_PLAINTEXT,174,153,79,8 LTEXT "bits",IDT_KEY_UNIT,114,57,45,8 RTEXT "Cipher:",IDT_CIPHER,38,13,68,8 LTEXT "bits",IDT_PLAINTEXT_SIZE_UNIT,298,153,22,8 GROUPBOX "XTS mode",IDT_XTS_MODE,1,75,323,65 LTEXT "Secondary key (hexadecimal)",IDT_SECONDARY_KEY,8,84,187,8 LTEXT "Data unit number (64-bit hexadecimal, data unit size is 512 bytes)",IDT_TEST_DATA_UNIT_NUMBER,8,109,308,8 RTEXT "Block number:",IDT_TEST_BLOCK_NUMBER,134,122,119,8 COMBOBOX IDC_TEST_BLOCK_NUMBER,258,119,36,126,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP END IDD_TEXT_INFO_DIALOG_BOX_DLG DIALOGEX 0, 0, 372, 220 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN DEFPUSHBUTTON "OK",IDOK,305,200,58,14 PUSHBUTTON "&Print",IDC_PRINT,156,200,58,14 CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_READONLY | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,5,6,361,188 END -IDD_KEYFILE_GENERATOR DIALOGEX 0, 0, 357, 369 +IDD_KEYFILE_GENERATOR DIALOGEX 0, 0, 357, 385 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Keyfile Generator" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN DEFPUSHBUTTON "Close",IDCLOSE,291,10,59,14 COMBOBOX IDC_PRF_ID,97,49,91,90,CBS_DROPDOWNLIST | WS_TABSTOP CONTROL "Display pool content",IDC_DISPLAY_POOL_CONTENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,209,51,141,10 EDITTEXT IDC_NUMBER_KEYFILES,124,278,51,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER EDITTEXT IDC_KEYFILES_SIZE,124,298,51,14,ES_RIGHT | ES_AUTOHSCROLL | ES_NUMBER COMBOBOX IDC_KEYFILES_SIZE_UNIT,182,299,41,137,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Random size ( 64 <-> 1048576 )",IDC_KEYFILES_RANDOM_SIZE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,124,317,174,10 EDITTEXT IDC_KEYFILES_BASE_NAME,124,331,141,14,ES_AUTOHSCROLL PUSHBUTTON "Generate and Save Keyfile...",IDC_GENERATE_AND_SAVE_KEYFILE,124,349,141,14 LTEXT "IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the keyfile.",IDT_KEYFILE_GENERATOR_NOTE,11,5,271,33 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,40,356,1,WS_EX_STATICEDGE RTEXT "Mixing PRF:",IDT_PRF,7,51,85,10,SS_CENTERIMAGE GROUPBOX "Current Pool Content",IDT_POOL_CONTENTS,6,70,344,170 CTEXT "",IDC_POOL_CONTENTS,16,83,323,148,0,WS_EX_TRANSPARENT RTEXT "Number of keyfiles:",IDT_NUMBER_KEYFILES,9,281,110,8 RTEXT "Keyfiles base name:",IDT_KEYFILES_BASE_NAME,9,334,110,8 RTEXT "Keyfiles size:",IDT_KEYFILES_SIZE,9,300,110,8 CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,18,255,321,12 GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,6,244,344,29 + RTEXT "Important information on using third-party file extensions",IDC_LINK_KEYFILES_EXTENSIONS_WARNING,7,370,346,8,SS_NOTIFY END IDD_MULTI_CHOICE_DLG DIALOGEX 0, 0, 167, 322 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN PUSHBUTTON "",IDC_CHOICE10,7,292,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE9,7,268,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE8,7,244,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE7,7,220,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE6,7,196,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE5,7,172,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE4,7,148,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE3,7,124,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE2,7,100,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE PUSHBUTTON "",IDC_CHOICE1,7,76,153,24,BS_CENTER | BS_MULTILINE,WS_EX_STATICEDGE LTEXT "",IDC_MULTI_CHOICE_MSG,7,7,153,56,0,WS_EX_TRANSPARENT CONTROL "",IDC_MC_DLG_HR2,"Static",SS_ETCHEDHORZ,0,69,168,1,WS_EX_STATICEDGE CONTROL "",IDC_MC_DLG_HR1,"Static",SS_ETCHEDHORZ,0,1,168,1,WS_EX_STATICEDGE END IDD_AUXILIARY_DLG DIALOGEX 0, 0, 426, 296 STYLE DS_SETFONT | DS_FIXEDSYS | DS_NOFAILCREATE | WS_POPUP EXSTYLE WS_EX_TRANSPARENT FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "",IDC_ASPECT_RATIO_CALIBRATION_BOX,3,2,282,282,WS_DISABLED END IDD_TOKEN_PASSWORD DIALOGEX 0, 0, 281, 47 @@ -315,144 +317,144 @@ BEGIN RTEXT "Mixing PRF:",IDT_PRF,6,51,67,10,SS_CENTERIMAGE GROUPBOX "Current Pool Content",IDT_POOL_CONTENTS,6,70,296,170 CONTROL "",IDC_POOL_CONTENTS,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,16,83,282,148,WS_EX_TRANSPARENT CONTROL "Display pool content",IDC_DISPLAY_POOL_CONTENTS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,191,51,111,10 CONTROL "",IDC_ENTROPY_BAR,"msctls_progress32",PBS_SMOOTH | WS_BORDER,16,255,275,12 GROUPBOX "Randomness Collected From Mouse Movements",IDT_ENTROPY_BAR,7,244,294,29 END IDD_STATIC_MODELESS_WAIT_DLG DIALOGEX 0, 0, 292, 42 STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION EXSTYLE WS_EX_TOPMOST | WS_EX_TOOLWINDOW CAPTION "VeraCrypt" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN LTEXT "Please wait. This process may take a long time...",IDT_STATIC_MODELESS_WAIT_DLG_INFO,9,8,274,27 END IDD_STATIC_MODAL_WAIT_DLG DIALOGEX 0, 0, 292, 74 STYLE DS_SETFONT | DS_MODALFRAME | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION CAPTION "VeraCrypt" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN CTEXT "Please wait...\nThis process may take a long time and VeraCrypt may seem unresponsive.",IDT_STATIC_MODAL_WAIT_DLG_INFO,9,11,274,33 CONTROL "",IDC_WAIT_PROGRESS_BAR,"msctls_progress32",WS_BORDER,7,49,278,14 END IDD_TEXT_EDIT_DLG DIALOGEX 0, 0, 372, 220 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN - PUSHBUTTON "OK",IDOK,306,201,58,14 + PUSHBUTTON "OK",IDOK,244,201,58,14 CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_WANTRETURN | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,5,6,361,188 - DEFPUSHBUTTON "Cancel",IDCANCEL,240,201,58,14 + DEFPUSHBUTTON "Cancel",IDCANCEL,308,201,58,14 END ///////////////////////////////////////////////////////////////////////////// // // DESIGNINFO // #ifdef APSTUDIO_INVOKED GUIDELINES DESIGNINFO BEGIN IDD_ABOUT_DLG, DIALOG BEGIN END IDD_COMMANDHELP_DLG, DIALOG BEGIN BOTTOMMARGIN, 281 END IDD_RAWDEVICES_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 298 TOPMARGIN, 7 BOTTOMMARGIN, 205 END IDD_MOUNT_OPTIONS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 309 TOPMARGIN, 7 BOTTOMMARGIN, 238 END IDD_KEYFILES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 345 TOPMARGIN, 7 - BOTTOMMARGIN, 244 + BOTTOMMARGIN, 257 END IDD_LANGUAGE, DIALOG BEGIN LEFTMARGIN, 6 RIGHTMARGIN, 202 TOPMARGIN, 7 BOTTOMMARGIN, 176 END IDD_BENCHMARK_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 323 TOPMARGIN, 7 BOTTOMMARGIN, 240 END IDD_CIPHER_TEST_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 319 TOPMARGIN, 7 BOTTOMMARGIN, 242 END IDD_TEXT_INFO_DIALOG_BOX_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 365 TOPMARGIN, 7 BOTTOMMARGIN, 213 END IDD_KEYFILE_GENERATOR, DIALOG BEGIN LEFTMARGIN, 7 TOPMARGIN, 7 - BOTTOMMARGIN, 365 + BOTTOMMARGIN, 381 END IDD_MULTI_CHOICE_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 160 TOPMARGIN, 7 BOTTOMMARGIN, 316 END IDD_AUXILIARY_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 419 TOPMARGIN, 7 BOTTOMMARGIN, 289 END IDD_TOKEN_PASSWORD, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 274 TOPMARGIN, 7 BOTTOMMARGIN, 40 END IDD_TOKEN_KEYFILES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 330 diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index e87aea35..9c4ee5a3 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -30,381 +30,401 @@ #endif #endif #include "Volumes.h" #include "cpu.h" #pragma warning (disable:4706) // assignment within conditional expression /* Update the following when adding a new cipher or EA: Crypto.h: ID #define MAX_EXPANDED_KEY #define Crypto.c: Ciphers[] EncryptionAlgorithms[] CipherInit() EncipherBlock() DecipherBlock() */ #ifndef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE // Cipher configuration static Cipher Ciphers[] = { // Block Size Key Size Key Schedule Size // ID Name (Bytes) (Bytes) (Bytes) #ifdef TC_WINDOWS_BOOT { AES, "AES", 16, 32, AES_KS }, - { SERPENT, "Serpent", 16, 32, 140*4 }, +#ifndef WOLFCRYPT_BACKEND + { SERPENT, "Serpent", 16, 32, 140*4 }, { TWOFISH, "Twofish", 16, 32, TWOFISH_KS }, +#endif #else { AES, L"AES", 16, 32, AES_KS }, +#ifndef WOLFCRYPT_BACKEND { SERPENT, L"Serpent", 16, 32, 140*4 }, { TWOFISH, L"Twofish", 16, 32, TWOFISH_KS }, { CAMELLIA, L"Camellia", 16, 32, CAMELLIA_KS }, { KUZNYECHIK, L"Kuznyechik",16, 32, KUZNYECHIK_KS }, #endif +#endif { 0, 0, 0, 0, 0 } }; // Encryption algorithm configuration static EncryptionAlgorithm EncryptionAlgorithms[] = { // Cipher(s) Modes FormatEnabled #ifndef TC_WINDOWS_BOOT { { 0, 0 }, { 0, 0}, 0, 0 }, // Must be all-zero { { AES, 0 }, { XTS, 0 }, 1, 1 }, +#ifndef WOLFCRYPT_BACKEND { { SERPENT, 0 }, { XTS, 0 }, 1, 1 }, { { TWOFISH, 0 }, { XTS, 0 }, 1, 1 }, { { CAMELLIA, 0 }, { XTS, 0 }, 1, 1 }, { { KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 }, { { TWOFISH, AES, 0 }, { XTS, 0 }, 1, 1 }, { { SERPENT, TWOFISH, AES, 0 }, { XTS, 0 }, 1, 1 }, { { AES, SERPENT, 0 }, { XTS, 0 }, 1, 1 }, { { AES, TWOFISH, SERPENT, 0 }, { XTS, 0 }, 1, 1 }, { { SERPENT, TWOFISH, 0 }, { XTS, 0 }, 1, 1 }, { { KUZNYECHIK, CAMELLIA, 0 }, { XTS, 0 }, 0, 1 }, { { TWOFISH, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 }, { { SERPENT, CAMELLIA, 0 }, { XTS, 0 }, 0, 1 }, { { AES, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 }, { { CAMELLIA, SERPENT, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 }, +#endif { { 0, 0 }, { 0, 0}, 0, 0 } // Must be all-zero #else // TC_WINDOWS_BOOT // Encryption algorithms available for boot drive encryption { { 0, 0 }, { 0, 0 }, 0 }, // Must be all-zero { { AES, 0 }, { XTS, 0 }, 1 }, +#ifndef WOLFCRYPT_BACKEND { { SERPENT, 0 }, { XTS, 0 }, 1 }, { { TWOFISH, 0 }, { XTS, 0 }, 1 }, { { TWOFISH, AES, 0 }, { XTS, 0 }, 1 }, { { SERPENT, TWOFISH, AES, 0 }, { XTS, 0 }, 1 }, { { AES, SERPENT, 0 }, { XTS, 0 }, 1 }, { { AES, TWOFISH, SERPENT, 0 }, { XTS, 0 }, 1 }, { { SERPENT, TWOFISH, 0 }, { XTS, 0 }, 1 }, +#endif { { 0, 0 }, { 0, 0 }, 0 }, // Must be all-zero #endif }; #ifndef TC_WINDOWS_BOOT // Hash algorithms static Hash Hashes[] = { // ID Name Deprecated System Encryption { SHA512, L"SHA-512", FALSE, FALSE }, - { WHIRLPOOL, L"Whirlpool", FALSE, FALSE }, - { BLAKE2S, L"BLAKE2s-256", FALSE, TRUE }, { SHA256, L"SHA-256", FALSE, TRUE }, + #ifndef WOLFCRYPT_BACKEND + { BLAKE2S, L"BLAKE2s-256", FALSE, TRUE }, + { WHIRLPOOL, L"Whirlpool", FALSE, FALSE }, { STREEBOG, L"Streebog", FALSE, FALSE }, - { 0, 0, 0 } + #endif + { 0, 0, 0 } }; #endif /* Return values: 0 = success, ERR_CIPHER_INIT_FAILURE (fatal), ERR_CIPHER_INIT_WEAK_KEY (non-fatal) */ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks) { int retVal = ERR_SUCCESS; switch (cipher) { case AES: #ifndef TC_WINDOWS_BOOT if (aes_encrypt_key256 (key, (aes_encrypt_ctx *) ks) != EXIT_SUCCESS) return ERR_CIPHER_INIT_FAILURE; if (aes_decrypt_key256 (key, (aes_decrypt_ctx *) (ks + sizeof(aes_encrypt_ctx))) != EXIT_SUCCESS) return ERR_CIPHER_INIT_FAILURE; #else if (aes_set_key (key, (length_type) CipherGetKeySize(AES), (aes_context *) ks) != 0) return ERR_CIPHER_INIT_FAILURE; #endif break; +#ifndef WOLFCRYPT_BACKEND case SERPENT: serpent_set_key (key, ks); break; case TWOFISH: twofish_set_key ((TwofishInstance *)ks, (const u4byte *)key); break; #if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_CAMELLIA) case CAMELLIA: camellia_set_key (key, ks); break; #endif #if !defined(TC_WINDOWS_BOOT) case KUZNYECHIK: kuznyechik_set_key(key, (kuznyechik_kds*)ks); break; #endif // !defined(TC_WINDOWS_BOOT) +#endif default: // Unknown/wrong cipher ID return ERR_CIPHER_INIT_FAILURE; } return retVal; } void EncipherBlock(int cipher, void *data, void *ks) { switch (cipher) { 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()) aes_hw_cpu_encrypt (ks, data); else #endif aes_encrypt (data, data, ks); break; +#ifndef WOLFCRYPT_BACKEND case TWOFISH: twofish_encrypt (ks, data, data); break; case SERPENT: serpent_encrypt (data, data, ks); break; #if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_CAMELLIA) case CAMELLIA: camellia_encrypt (data, data, ks); break; #endif #if !defined(TC_WINDOWS_BOOT) case KUZNYECHIK: kuznyechik_encrypt_block(data, data, ks); break; #endif // !defined(TC_WINDOWS_BOOT) +#endif default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } } #ifndef TC_WINDOWS_BOOT void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) { - byte *data = dataPtr; + uint8 *data = dataPtr; #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KFLOATING_SAVE floatingPointState; #endif if (cipher == AES && (blockCount & (32 - 1)) == 0 && IsAesHwCpuSupported() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { while (blockCount > 0) { aes_hw_cpu_encrypt_32_blocks (ks, data); data += 32 * 16; blockCount -= 32; } #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } +#ifndef WOLFCRYPT_BACKEND #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI) else if (cipher == SERPENT && (blockCount >= 4) && HasSSE2() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { serpent_encrypt_blocks (data, data, blockCount, ks); #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } #endif #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) else if (cipher == TWOFISH) { twofish_encrypt_blocks(ks, data, data, (uint32) blockCount); } else if (cipher == CAMELLIA) { camellia_encrypt_blocks(ks, data, data, (uint32) blockCount); } #endif #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI) else if (cipher == KUZNYECHIK && HasSSE2() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { kuznyechik_encrypt_blocks (data, data, blockCount, ks); #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } #endif +#endif else { size_t blockSize = CipherGetBlockSize (cipher); while (blockCount-- > 0) { EncipherBlock (cipher, data, ks); data += blockSize; } } } #endif // !TC_WINDOWS_BOOT void DecipherBlock(int cipher, void *data, void *ks) { switch (cipher) { +#ifndef WOLFCRYPT_BACKEND case SERPENT: serpent_decrypt (data, data, ks); break; case TWOFISH: twofish_decrypt (ks, data, data); break; #if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_CAMELLIA) case CAMELLIA: camellia_decrypt (data, data, ks); break; #endif #if !defined(TC_WINDOWS_BOOT) case KUZNYECHIK: kuznyechik_decrypt_block(data, data, ks); break; #endif // !defined(TC_WINDOWS_BOOT) +#endif #ifndef TC_WINDOWS_BOOT case AES: #if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER) if (IsAesHwCpuSupported()) - aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx), data); + aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx), data); else #endif aes_decrypt (data, data, (void *) ((char *) ks + sizeof(aes_encrypt_ctx))); break; #else case AES: aes_decrypt (data, data, ks); break; #endif default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } } #ifndef TC_WINDOWS_BOOT void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) { - byte *data = dataPtr; + uint8 *data = dataPtr; #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KFLOATING_SAVE floatingPointState; #endif if (cipher == AES && (blockCount & (32 - 1)) == 0 && IsAesHwCpuSupported() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { while (blockCount > 0) { - aes_hw_cpu_decrypt_32_blocks ((byte *) ks + sizeof (aes_encrypt_ctx), data); + aes_hw_cpu_decrypt_32_blocks ((uint8 *) ks + sizeof (aes_encrypt_ctx), data); data += 32 * 16; blockCount -= 32; } #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } +#ifndef WOLFCRYPT_BACKEND #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI) else if (cipher == SERPENT && (blockCount >= 4) && HasSSE2() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { serpent_decrypt_blocks (data, data, blockCount, ks); #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } #endif #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) else if (cipher == TWOFISH) { twofish_decrypt_blocks(ks, data, data, (uint32) blockCount); } else if (cipher == CAMELLIA) { camellia_decrypt_blocks(ks, data, data, (uint32) blockCount); } #endif #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI) else if (cipher == KUZNYECHIK && HasSSE2() #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState)) #endif ) { kuznyechik_decrypt_blocks (data, data, blockCount, ks); #if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64) KeRestoreFloatingPointState (&floatingPointState); #endif } #endif +#endif else { size_t blockSize = CipherGetBlockSize (cipher); while (blockCount-- > 0) { DecipherBlock (cipher, data, ks); data += blockSize; } } } #endif // !TC_WINDOWS_BOOT // Ciphers support Cipher *CipherGet (int id) { int i; for (i = 0; Ciphers[i].Id != 0; i++) if (Ciphers[i].Id == id) return &Ciphers[i]; return NULL; } #ifndef TC_WINDOWS_BOOT const wchar_t *CipherGetName (int cipherId) { Cipher* pCipher = CipherGet (cipherId); @@ -496,62 +516,70 @@ int EAInit (int ea, unsigned char *key, unsigned __int8 *ks) for (c = EAGetFirstCipher (ea); c != 0; c = EAGetNextCipher (ea, c)) { switch (CipherInit (c, key, ks)) { case ERR_CIPHER_INIT_FAILURE: return ERR_CIPHER_INIT_FAILURE; case ERR_CIPHER_INIT_WEAK_KEY: retVal = ERR_CIPHER_INIT_WEAK_KEY; // Non-fatal error break; } key += CipherGetKeySize (c); ks += CipherGetKeyScheduleSize (c); } return retVal; } #ifndef TC_WINDOWS_BOOT BOOL EAInitMode (PCRYPTO_INFO ci, unsigned char* key2) { switch (ci->mode) { case XTS: // Secondary key schedule if (EAInit (ci->ea, key2, ci->ks2) != ERR_SUCCESS) return FALSE; + + #ifdef WOLFCRYPT_BACKEND + if (xts_encrypt_key256 (key2, (aes_encrypt_ctx *) ci->ks) != EXIT_SUCCESS) + return ERR_CIPHER_INIT_FAILURE; - /* Note: XTS mode could potentially be initialized with a weak key causing all blocks in one data unit + if (xts_decrypt_key256 (key2, (aes_decrypt_ctx *) (ci->ks + sizeof(aes_encrypt_ctx))) != EXIT_SUCCESS) + return ERR_CIPHER_INIT_FAILURE; + #endif + + /* 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 that the size of each of the volumes is 1024 terabytes). */ break; default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } return TRUE; } static void EAGetDisplayName(wchar_t *buf, size_t bufLen, int ea, int i) { StringCchCopyW (buf, bufLen, CipherGetName (i)); if (i = EAGetPreviousCipher(ea, i)) { size_t curLen; StringCchCatW (buf, bufLen, L"("); curLen = wcslen(buf); EAGetDisplayName (&buf[curLen], bufLen - curLen, ea, i); StringCchCatW (buf, bufLen, L")"); } } // Returns name of EA, cascaded cipher names are separated by hyphens wchar_t *EAGetName (wchar_t *buf, size_t bufLen, int ea, int guiDisplay) { if (guiDisplay) @@ -800,61 +828,61 @@ int EAGetLargestKeyForMode (int mode) for (ea = EAGetFirst (); ea != 0; ea = EAGetNext (ea)) { if (!EAIsModeSupported (ea, mode)) continue; if (EAGetKeySize (ea) >= key) key = EAGetKeySize (ea); } return key; } // Returns the maximum number of bytes necessary to be generated by the PBKDF2 (PKCS #5) int GetMaxPkcs5OutSize (void) { int size = 32; size = VC_MAX (size, EAGetLargestKeyForMode (XTS) * 2); // Sizes of primary + secondary keys return size; } #endif #endif // TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE #ifdef TC_WINDOWS_BOOT -static byte CryptoInfoBufferInUse = 0; +static uint8 CryptoInfoBufferInUse = 0; CRYPTO_INFO CryptoInfoBuffer; #endif PCRYPTO_INFO crypto_open () { #ifndef TC_WINDOWS_BOOT /* Do the crt allocation */ PCRYPTO_INFO cryptoInfo = (PCRYPTO_INFO) TCalloc (sizeof (CRYPTO_INFO)); if (cryptoInfo == NULL) return NULL; memset (cryptoInfo, 0, sizeof (CRYPTO_INFO)); #if !defined(DEVICE_DRIVER) && !defined(_UEFI) VirtualLock (cryptoInfo, sizeof (CRYPTO_INFO)); #endif cryptoInfo->ea = -1; return cryptoInfo; #else // TC_WINDOWS_BOOT #if 0 if (CryptoInfoBufferInUse) TC_THROW_FATAL_EXCEPTION; #endif CryptoInfoBufferInUse = 1; return &CryptoInfoBuffer; @@ -1063,84 +1091,84 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s ks2 -= CipherGetKeyScheduleSize (cipher); DecryptBufferXTS (buf, nbrUnits * ENCRYPTION_DATA_UNIT_SIZE, structUnitNo, 0, ks, ks2, cipher); } break; default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } } #else // TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE #if !defined (TC_WINDOWS_BOOT_AES) && !defined (TC_WINDOWS_BOOT_SERPENT) && !defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (TC_WINDOWS_BOOT_CAMELLIA) #error No cipher defined #endif void EncipherBlock(int cipher, void *data, void *ks) { #ifdef TC_WINDOWS_BOOT_AES if (IsAesHwCpuSupported()) - aes_hw_cpu_encrypt ((byte *) ks, data); + aes_hw_cpu_encrypt ((uint8 *) ks, data); else aes_encrypt (data, data, ks); -#elif defined (TC_WINDOWS_BOOT_SERPENT) +#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_encrypt (data, data, ks); -#elif defined (TC_WINDOWS_BOOT_TWOFISH) +#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_encrypt (ks, data, data); -#elif defined (TC_WINDOWS_BOOT_CAMELLIA) +#elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_encrypt (data, data, ks); #endif } void DecipherBlock(int cipher, void *data, void *ks) { #ifdef TC_WINDOWS_BOOT_AES if (IsAesHwCpuSupported()) - aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data); + aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data); else - aes_decrypt (data, data, (aes_decrypt_ctx *) ((byte *) ks + sizeof(aes_encrypt_ctx))); -#elif defined (TC_WINDOWS_BOOT_SERPENT) + aes_decrypt (data, data, (aes_decrypt_ctx *) ((uint8 *) ks + sizeof(aes_encrypt_ctx))); +#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_decrypt (data, data, ks); -#elif defined (TC_WINDOWS_BOOT_TWOFISH) +#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_decrypt (ks, data, data); -#elif defined (TC_WINDOWS_BOOT_CAMELLIA) +#elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_decrypt (data, data, ks); #endif } #ifdef TC_WINDOWS_BOOT_AES int EAInit (unsigned char *key, unsigned __int8 *ks) { aes_init(); if (aes_encrypt_key256 (key, (aes_encrypt_ctx *) ks) != EXIT_SUCCESS) return ERR_CIPHER_INIT_FAILURE; if (aes_decrypt_key256 (key, (aes_decrypt_ctx *) (ks + sizeof (aes_encrypt_ctx))) != EXIT_SUCCESS) return ERR_CIPHER_INIT_FAILURE; return ERR_SUCCESS; } #endif void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo) { UINT64_STRUCT dataUnitNo; dataUnitNo.LowPart = 0; dataUnitNo.HighPart = 0; EncryptBufferXTS (buf, len, &dataUnitNo, 0, cryptoInfo->ks, cryptoInfo->ks2, 1); } void EncryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci) @@ -1223,269 +1251,307 @@ void EnableCpuRng (BOOL enable) } BOOL IsCpuRngEnabled () { return !CpuRngDisabled; } BOOL IsRamEncryptionSupported () { #ifdef _WIN64 if (t1ha_selfcheck__t1ha2() == 0) return TRUE; else return FALSE; #else return FALSE; #endif } void EnableRamEncryption (BOOL enable) { RamEncryptionEnabled = enable; } BOOL IsRamEncryptionEnabled () { return RamEncryptionEnabled; } /* masking for random index to remove bias */ -byte GetRngMask (byte count) +uint8 GetRngMask (uint8 count) { if (count >= 128) return 0xFF; if (count >= 64) return 0x7F; if (count >= 32) return 0x3F; if (count >= 16) return 0x1F; if (count >= 8) return 0x0F; if (count >= 4) return 0x07; if (count >= 2) return 0x03; return 1; } -byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount) +uint8 GetRandomIndex (ChaCha20RngCtx* pCtx, uint8 elementsCount) { - byte index = 0; - byte mask = GetRngMask (elementsCount); + uint8 index = 0; + uint8 mask = GetRngMask (elementsCount); while (TRUE) { ChaCha20RngGetBytes (pCtx, &index, 1); index &= mask; if (index < elementsCount) break; } return index; } #if defined(_WIN64) && !defined (_UEFI) /* declaration of variables and functions used for RAM encryption on 64-bit build */ -static byte* pbKeyDerivationArea = NULL; +static uint8* pbKeyDerivationArea = NULL; static ULONG cbKeyDerivationArea = 0; static uint64 HashSeedMask = 0; static uint64 CipherIVMask = 0; #ifdef TC_WINDOWS_DRIVER ULONG AllocTag = 'MMCV'; #endif #if !defined(PAGE_SIZE) #define PAGE_SIZE 4096 #endif BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback) { ChaCha20RngCtx ctx; - byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; + uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; #ifdef TC_WINDOWS_DRIVER - byte i, tagLength; - + uint8 i; + char randomStr[4]; Dump ("InitializeSecurityParameters BEGIN\n"); #endif rngCallback (pbSeed, sizeof (pbSeed)); ChaCha20RngInit (&ctx, pbSeed, rngCallback, 0); #ifdef TC_WINDOWS_DRIVER - /* generate random tag length between 1 and 4 */ - tagLength = GetRandomIndex (&ctx, 4) + 1; - /* generate random value for tag: - * Each ASCII character in the tag must be a value in the range 0x20 (space) to 0x7E (tilde) - * So we have 95 possibility + /* Generate random value for tag that is similar to pool tag values used by Windows kernel. + * Fully random tag would be too suspicious and outstanding. + * First character is always a capital letter. + * Second character is a letter, lowercase or uppercase. + * Third character is a letter, lowercase or uppercase. + * Fourth character is a letter or a digit. */ + + /* 1. First character (Capital Letter) */ + randomStr[0] = 'A' + GetRandomIndex(&ctx, 26); + + /* 2. Second character (Letter) */ + i = GetRandomIndex(&ctx, 52); + if (i < 26) + randomStr[1] = 'A' + i; + else + randomStr[1] = 'a' + (i - 26); + + /* 3. Third character (Letter) */ + i = GetRandomIndex(&ctx, 52); + if (i < 26) + randomStr[2] = 'A' + i; + else + randomStr[2] = 'a' + (i - 26); + + /* 4. Fourth character (Letter or Digit) */ + i = GetRandomIndex(&ctx, 62); + if (i < 26) + randomStr[3] = 'A' + i; + else if (i < 52) + randomStr[3] = 'a' + (i - 26); + else + randomStr[3] = '0' + (i - 52); + + /* combine all characters in reverse order as explained in MSDN */ AllocTag = 0; - for (i = 0; i < tagLength; i++) + for (i = 0; i < 4; i++) { - AllocTag = (AllocTag << 8) + (((ULONG) GetRandomIndex (&ctx, 95)) + 0x20); + AllocTag = (AllocTag << 8) + randomStr[3-i]; } #endif cbKeyDerivationArea = 1024 * 1024; - pbKeyDerivationArea = (byte*) TCalloc(cbKeyDerivationArea); - if (!pbKeyDerivationArea) + do { - cbKeyDerivationArea = 2 * PAGE_SIZE; - pbKeyDerivationArea = (byte*) TCalloc(cbKeyDerivationArea); - } + pbKeyDerivationArea = (uint8*) TCalloc(cbKeyDerivationArea); + if (!pbKeyDerivationArea) + cbKeyDerivationArea >>= 1; + } while (!pbKeyDerivationArea && (cbKeyDerivationArea >= (2*PAGE_SIZE))); if (!pbKeyDerivationArea) { cbKeyDerivationArea = 0; Dump ("InitializeSecurityParameters return=FALSE END\n"); return FALSE; } /* fill key derivation area with random bytes */ ChaCha20RngGetBytes (&ctx, pbKeyDerivationArea, cbKeyDerivationArea); /* generate hash seed mask */ ChaCha20RngGetBytes(&ctx, (unsigned char*) &HashSeedMask, sizeof (HashSeedMask)); /* generate IV mask */ ChaCha20RngGetBytes(&ctx, (unsigned char*) &CipherIVMask, sizeof (CipherIVMask)); FAST_ERASE64 (pbSeed, sizeof (pbSeed)); burn (&ctx, sizeof (ctx)); #ifdef TC_WINDOWS_DRIVER - burn (&tagLength, 1); + burn (randomStr, sizeof(randomStr)); Dump ("InitializeSecurityParameters return=TRUE END\n"); #endif return TRUE; } void ClearSecurityParameters() { Dump ("ClearSecurityParameters BEGIN\n"); if (pbKeyDerivationArea) { FAST_ERASE64 (pbKeyDerivationArea, cbKeyDerivationArea); TCfree (pbKeyDerivationArea); pbKeyDerivationArea =NULL; cbKeyDerivationArea = 0; } FAST_ERASE64 (&HashSeedMask, 8); FAST_ERASE64 (&CipherIVMask, 8); #ifdef TC_WINDOWS_DRIVER burn (&AllocTag, sizeof (AllocTag)); #endif Dump ("ClearSecurityParameters END\n"); } #ifdef TC_WINDOWS_DRIVER void VcProtectMemory (uint64 encID, unsigned char* pbData, size_t cbData, unsigned char* pbData2, size_t cbData2) #else void VcProtectMemory (uint64 encID, unsigned char* pbData, size_t cbData, unsigned char* pbData2, size_t cbData2, unsigned char* pbData3, size_t cbData3, unsigned char* pbData4, size_t cbData4) #endif { if (pbKeyDerivationArea) { uint64 hashLow, hashHigh, hashSeed, cipherIV; uint64 pbKey[4]; ChaCha256Ctx ctx; hashSeed = (((uint64) pbKeyDerivationArea) + encID) ^ HashSeedMask; hashLow = t1ha2_atonce128(&hashHigh, pbKeyDerivationArea, cbKeyDerivationArea, hashSeed); /* set the key to the hash result */ - pbKey[0] = pbKey[2] = hashLow; - pbKey[1] = pbKey[3] = hashHigh; + pbKey[0] = hashLow; + pbKey[1] = hashHigh; + /* we now have a 128-bit key and we will expand it to 256-bit by using ChaCha12 cipher */ + /* first we need to generate a the other 128-bit half of the key */ + pbKey[2] = hashLow ^ hashHigh; + pbKey[3] = hashLow + hashHigh; + + /* Initialize ChaCha12 cipher */ + ChaCha256Init (&ctx, (unsigned char*) pbKey, (unsigned char*) &hashSeed, 12); + /* encrypt the key by itself */ + ChaCha256Encrypt (&ctx, (unsigned char*) pbKey, sizeof(pbKey), (unsigned char*) pbKey); /* Initialize ChaCha12 cipher */ - cipherIV = encID ^ CipherIVMask; + cipherIV = (((uint64) pbKeyDerivationArea) + encID) ^ CipherIVMask; ChaCha256Init (&ctx, (unsigned char*) pbKey, (unsigned char*) &cipherIV, 12); ChaCha256Encrypt (&ctx, pbData, cbData, pbData); ChaCha256Encrypt (&ctx, pbData2, cbData2, pbData2); #ifndef TC_WINDOWS_DRIVER ChaCha256Encrypt (&ctx, pbData3, cbData3, pbData3); ChaCha256Encrypt (&ctx, pbData4, cbData4, pbData4); #endif FAST_ERASE64 (pbKey, sizeof(pbKey)); FAST_ERASE64 (&hashLow, 8); FAST_ERASE64 (&hashHigh, 8); FAST_ERASE64 (&hashSeed, 8); FAST_ERASE64 (&cipherIV, 8); burn (&ctx, sizeof (ctx)); } } uint64 VcGetEncryptionID (PCRYPTO_INFO pCryptoInfo) { return ((uint64) pCryptoInfo->ks) + ((uint64) pCryptoInfo->ks2) #ifndef TC_WINDOWS_DRIVER + ((uint64) pCryptoInfo->master_keydata) + ((uint64) pCryptoInfo->k2) #endif ; } static void VcInternalProtectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID) { #ifdef TC_WINDOWS_DRIVER VcProtectMemory (encID, pCryptoInfo->ks, MAX_EXPANDED_KEY, pCryptoInfo->ks2, MAX_EXPANDED_KEY); #else VcProtectMemory (encID, pCryptoInfo->ks, MAX_EXPANDED_KEY, pCryptoInfo->ks2, MAX_EXPANDED_KEY, pCryptoInfo->master_keydata, MASTER_KEYDATA_SIZE, pCryptoInfo->k2, MASTER_KEYDATA_SIZE); #endif } void VcProtectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID) { Dump ("VcProtectKeys BEGIN\n"); VcInternalProtectKeys (pCryptoInfo, encID); Dump ("VcProtectKeys END\n"); } void VcUnprotectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID) { Dump ("VcUnprotectKeys BEGIN\n"); VcInternalProtectKeys (pCryptoInfo, encID); Dump ("VcUnprotectKeys END\n"); } #endif #endif #if defined(_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__) /* dummy implementation that should never be called */ -void aes_hw_cpu_decrypt(const byte* ks, byte* data) +void aes_hw_cpu_decrypt(const uint8* ks, uint8* data) { ks = ks; data = data; } -void aes_hw_cpu_decrypt_32_blocks(const byte* ks, byte* data) +void aes_hw_cpu_decrypt_32_blocks(const uint8* ks, uint8* data) { ks = ks; data = data; } -void aes_hw_cpu_encrypt(const byte* ks, byte* data) +void aes_hw_cpu_encrypt(const uint8* ks, uint8* data) { ks = ks; data = data; } -void aes_hw_cpu_encrypt_32_blocks(const byte* ks, byte* data) +void aes_hw_cpu_encrypt_32_blocks(const uint8* ks, uint8* data) { ks = ks; data = data; } #endif diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 178e08e1..89d22f0e 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -250,60 +250,62 @@ typedef struct CRYPTO_INFO_t uint16 HeaderVersion; #ifdef TC_WINDOWS_DRIVER unsigned __int8 master_keydata_hash[BLAKE2S_DIGESTSIZE]; #else CRYPTOPP_ALIGN_DATA(16) 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). */ CRYPTOPP_ALIGN_DATA(16) 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. */ #endif int noIterations; int volumePim; 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. uint64 hiddenVolumeOffset; // Absolute position, in bytes, of the first hidden volume data sector within the host volume (provided that there is a hidden volume within). This must be set for all hidden volumes; in case of a normal volume, this variable is only used when protecting a hidden volume within it. uint64 hiddenVolumeProtectedSize; BOOL bPartitionInInactiveSysEncScope; // If TRUE, the volume is a partition located on an encrypted system drive and mounted without pre-boot authentication. UINT64_STRUCT FirstDataUnitNo; // First data unit number of the volume. This is 0 for file-hosted and non-system partition-hosted volumes. For partitions within key scope of system encryption this reflects real physical offset within the device (this is used e.g. when such a partition is mounted as a regular volume without pre-boot authentication). uint16 RequiredProgramVersion; BOOL LegacyVolume; uint32 SectorSize; + BOOL bVulnerableMasterKey; // TRUE if XTS primary key is identical to secondary key (i.e. the volume is vulnerable to attack on XTS mode) + #endif // !TC_WINDOWS_BOOT UINT64_STRUCT VolumeSize; UINT64_STRUCT EncryptedAreaStart; UINT64_STRUCT EncryptedAreaLength; uint32 HeaderFlags; } CRYPTO_INFO, *PCRYPTO_INFO; #if defined(_WIN32) || defined(_UEFI) #pragma pack (push) #pragma pack(1) typedef struct BOOT_CRYPTO_HEADER_t { __int16 ea; /* Encryption algorithm ID */ __int16 mode; /* Mode of operation (e.g., XTS) */ __int16 pkcs5; /* PRF algorithm */ } BOOT_CRYPTO_HEADER, *PBOOT_CRYPTO_HEADER; #pragma pack (pop) #endif PCRYPTO_INFO crypto_open (void); #ifndef TC_WINDOWS_BOOT diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index b137c57b..b91167d4 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -1,120 +1,127 @@ /* 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 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 all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Tcdefs.h" #include <windowsx.h> #include <dbghelp.h> #include <dbt.h> #include <Setupapi.h> #include <aclapi.h> +#include <Netlistmgr.h> #include <fcntl.h> #include <io.h> #include <math.h> #include <shlobj.h> #include <shlwapi.h> #include <sys/stat.h> #include <stdlib.h> #include <time.h> #include <tchar.h> #include <Richedit.h> #if defined (TCMOUNT) || defined (VOLFORMAT) #include <process.h> #include <Tlhelp32.h> #endif +#if _WIN32_WINNT >= 0x0602 +#include "processthreadsapi.h" +#endif #include "Resource.h" #include "Platform/Finally.h" #include "Platform/ForEach.h" #include "Apidrvr.h" #include "BootEncryption.h" #include "Combo.h" #include "Crc.h" #include "Crypto.h" #include "Dictionary.h" #include "Dlgcode.h" #include "EncryptionThreadPool.h" #include "Endian.h" #include "Format/Inplace.h" #include "Language.h" #include "Keyfiles.h" #include "Pkcs5.h" #include "Random.h" #include "Registry.h" #include "SecurityToken.h" #include "Tests.h" #include "Volumes.h" #include "Wipe.h" #include "Xml.h" #include "Xts.h" #include "Boot/Windows/BootCommon.h" #include "Progress.h" #include "zip.h" #include "rdrand.h" #include "jitterentropy.h" #ifdef TCMOUNT #include "Mount/Mount.h" #include "Mount/resource.h" #endif #ifdef VOLFORMAT #include "Format/Tcformat.h" #endif #ifdef SETUP #include "Setup/Setup.h" #endif #include <Setupapi.h> #include <Softpub.h> #include <WinTrust.h> #include <strsafe.h> #define _WIN32_DCOM #include <comdef.h> #include <Wbemidl.h> #pragma comment(lib, "wbemuuid.lib") -#pragma comment( lib, "setupapi.lib" ) +#pragma comment(lib, "Shlwapi.lib") +#pragma comment(lib, "setupapi.lib" ) +#pragma comment(lib, "Wintrust.lib" ) +#pragma comment(lib, "Comctl32.lib" ) #ifndef TTI_INFO_LARGE #define TTI_INFO_LARGE 4 #endif #ifndef TTI_WARNING_LARGE #define TTI_WARNING_LARGE 5 #endif #ifndef TTI_ERROR_LARGE #define TTI_ERROR_LARGE 6 #endif /* GPT Partition Type GUIDs */ #define LOCAL_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) const GUID name = {l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8} LOCAL_DEFINE_GUID(PARTITION_ENTRY_UNUSED_GUID, 0x00000000L, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00); // Entry unused LOCAL_DEFINE_GUID(PARTITION_SYSTEM_GUID, 0xC12A7328L, 0xF81F, 0x11D2, 0xBA, 0x4B, 0x00, 0xA0, 0xC9, 0x3E, 0xC9, 0x3B); // EFI system partition LOCAL_DEFINE_GUID(PARTITION_MSFT_RESERVED_GUID, 0xE3C9E316L, 0x0B5C, 0x4DB8, 0x81, 0x7D, 0xF9, 0x2D, 0xF0, 0x02, 0x15, 0xAE); // Microsoft reserved space LOCAL_DEFINE_GUID(PARTITION_BASIC_DATA_GUID, 0xEBD0A0A2L, 0xB9E5, 0x4433, 0x87, 0xC0, 0x68, 0xB6, 0xB7, 0x26, 0x99, 0xC7); // Basic data partition LOCAL_DEFINE_GUID(PARTITION_LDM_METADATA_GUID, 0x5808C8AAL, 0x7E8F, 0x42E0, 0x85, 0xD2, 0xE1, 0xE9, 0x04, 0x34, 0xCF, 0xB3); // Logical Disk Manager metadata partition LOCAL_DEFINE_GUID(PARTITION_LDM_DATA_GUID, 0xAF9B60A0L, 0x1431, 0x4F62, 0xBC, 0x68, 0x33, 0x11, 0x71, 0x4A, 0x69, 0xAD); // Logical Disk Manager data partition LOCAL_DEFINE_GUID(PARTITION_MSFT_RECOVERY_GUID, 0xDE94BBA4L, 0x06D1, 0x4D40, 0xA1, 0x6A, 0xBF, 0xD5, 0x01, 0x79, 0xD6, 0xAC); // Microsoft recovery partition LOCAL_DEFINE_GUID(PARTITION_CLUSTER_GUID, 0xdb97dba9L, 0x0840, 0x4bae, 0x97, 0xf0, 0xff, 0xb9, 0xa3, 0x27, 0xc7, 0xe1); // Cluster metadata partition #ifndef PROCESSOR_ARCHITECTURE_ARM64 #define PROCESSOR_ARCHITECTURE_ARM64 12 #endif #ifndef IMAGE_FILE_MACHINE_ARM64 #define IMAGE_FILE_MACHINE_ARM64 0xAA64 @@ -186,60 +193,62 @@ int HiddenSectorDetectionStatus = 0; OSVersionEnum nCurrentOS = WIN_UNKNOWN; int CurrentOSMajor = 0; int CurrentOSMinor = 0; int CurrentOSServicePack = 0; int CurrentOSBuildNumber = 0; BOOL RemoteSession = FALSE; BOOL UacElevated = FALSE; BOOL bPortableModeConfirmed = FALSE; // TRUE if it is certain that the instance is running in portable mode 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) */ BOOL PimEnable = FALSE; BOOL KeyFilesEnable = FALSE; KeyFile *FirstKeyFile = NULL; KeyFilesDlgParam defaultKeyFilesParam = {0}; BOOL IgnoreWmDeviceChange = FALSE; BOOL DeviceChangeBroadcastDisabled = FALSE; BOOL LastMountedVolumeDirty; BOOL MountVolumesAsSystemFavorite = FALSE; BOOL FavoriteMountOnArrivalInProgress = FALSE; BOOL MultipleMountOperationInProgress = FALSE; BOOL EMVSupportEnabled = FALSE; volatile BOOL NeedPeriodicDeviceListUpdate = FALSE; BOOL DisablePeriodicDeviceListUpdate = FALSE; BOOL EnableMemoryProtection = FALSE; +BOOL MemoryProtectionActivated = FALSE; + BOOL WaitDialogDisplaying = FALSE; /* Handle to the device driver */ 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; /* 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. */ volatile HANDLE hNonSysInplaceEncMutex = NULL; /* This mutex is used 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. */ volatile HANDLE hDriverSetupMutex = NULL; /* This mutex is used to prevent users from running the main TrueCrypt app or the wizard while an instance of the TrueCrypt installer is running (which is also useful for enforcing restart before the apps can be used). */ volatile HANDLE hAppSetupMutex = NULL; /* Critical section used to protect access to global variables used in WNetGetConnection calls */ CRITICAL_SECTION csWNetCalls; /* Critical section used to protect access to global list of physical drives */ CRITICAL_SECTION csMountableDevices; CRITICAL_SECTION csVolumeIdCandidates; static std::vector<HostDevice> mountableDevices; static std::vector<HostDevice> rawHostDeviceList; @@ -258,218 +267,84 @@ 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; /* Only the wizard can change this value (others may only read it). */ WipeAlgorithmId nWipeMode = TC_WIPE_NONE; BOOL bSysPartitionSelected = FALSE; /* TRUE if the user selected the system partition via the Select Device dialog */ BOOL bSysDriveSelected = FALSE; /* TRUE if the user selected the system drive via the Select Device dialog */ /* To populate these arrays, call GetSysDevicePaths(). If they contain valid paths, bCachedSysDevicePathsValid is TRUE. */ wchar_t SysPartitionDevicePath [TC_MAX_PATH]; wchar_t SysDriveDevicePath [TC_MAX_PATH]; wstring ExtraBootPartitionDevicePath; char bCachedSysDevicePathsValid = FALSE; BOOL bHyperLinkBeingTracked = FALSE; int WrongPwdRetryCounter = 0; static FILE *ConfigFileHandle; char *ConfigBuffer; BOOL SystemFileSelectorCallPending = FALSE; DWORD SystemFileSelectorCallerThreadId; #define RANDPOOL_DISPLAY_REFRESH_INTERVAL 30 #define RANDPOOL_DISPLAY_ROWS 16 #define RANDPOOL_DISPLAY_COLUMNS 20 -HMODULE hRichEditDll = NULL; -HMODULE hComctl32Dll = NULL; -HMODULE hSetupDll = NULL; -HMODULE hShlwapiDll = NULL; -HMODULE hProfApiDll = NULL; -HMODULE hUsp10Dll = NULL; -HMODULE hCryptSpDll = NULL; -HMODULE hUXThemeDll = NULL; -HMODULE hUserenvDll = NULL; -HMODULE hRsaenhDll = NULL; -HMODULE himm32dll = NULL; -HMODULE hMSCTFdll = NULL; -HMODULE hfltlibdll = NULL; -HMODULE hframedyndll = NULL; -HMODULE hpsapidll = NULL; -HMODULE hsecur32dll = NULL; -HMODULE hnetapi32dll = NULL; -HMODULE hauthzdll = NULL; -HMODULE hxmllitedll = NULL; -HMODULE hmprdll = NULL; -HMODULE hsppdll = NULL; -HMODULE vssapidll = NULL; -HMODULE hvsstracedll = NULL; -HMODULE hcfgmgr32dll = NULL; -HMODULE hdevobjdll = NULL; -HMODULE hpowrprofdll = NULL; -HMODULE hsspiclidll = NULL; -HMODULE hcryptbasedll = NULL; -HMODULE hdwmapidll = NULL; -HMODULE hmsasn1dll = NULL; -HMODULE hcrypt32dll = NULL; -HMODULE hbcryptdll = NULL; -HMODULE hbcryptprimitivesdll = NULL; -HMODULE hMsls31 = NULL; -HMODULE hntmartadll = NULL; -HMODULE hwinscarddll = NULL; -HMODULE hmsvcrtdll = NULL; -HMODULE hWinTrustLib = NULL; -HMODULE hAdvapi32Dll = NULL; - -#define FREE_DLL(h) if (h) { FreeLibrary (h); h = NULL;} - -#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE -#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001 -#endif - -#ifndef BASE_SEARCH_PATH_PERMANENT -#define BASE_SEARCH_PATH_PERMANENT 0x00008000 -#endif #ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 #endif - -typedef BOOL (WINAPI *SetDllDirectoryPtr)(LPCWSTR lpPathName); -typedef BOOL (WINAPI *SetSearchPathModePtr)(DWORD Flags); typedef BOOL (WINAPI *SetDefaultDllDirectoriesPtr)(DWORD DirectoryFlags); - -typedef void (WINAPI *InitCommonControlsPtr)(void); -typedef HIMAGELIST (WINAPI *ImageList_CreatePtr)(int cx, int cy, UINT flags, int cInitial, int cGrow); -typedef int (WINAPI *ImageList_AddPtr)(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask); - -typedef VOID (WINAPI *SetupCloseInfFilePtr)(HINF InfHandle); -typedef HKEY (WINAPI *SetupDiOpenClassRegKeyPtr)(CONST GUID *ClassGuid,REGSAM samDesired); -typedef BOOL (WINAPI *SetupInstallFromInfSectionWPtr)(HWND,HINF,PCWSTR,UINT,HKEY,PCWSTR,UINT,PSP_FILE_CALLBACK_W,PVOID,HDEVINFO,PSP_DEVINFO_DATA); -typedef HINF (WINAPI *SetupOpenInfFileWPtr)(PCWSTR FileName,PCWSTR InfClass,DWORD InfStyle,PUINT ErrorLine); - -typedef LSTATUS (STDAPICALLTYPE *SHDeleteKeyWPtr)(HKEY hkey, LPCWSTR pszSubKey); - -typedef HRESULT (STDAPICALLTYPE *SHStrDupWPtr)(LPCWSTR psz, LPWSTR *ppwsz); - -typedef HRESULT (STDAPICALLTYPE *UrlUnescapeWPtr)( - PWSTR pszUrl, - PWSTR pszUnescaped, - DWORD *pcchUnescaped, - DWORD dwFlags -); - -// ChangeWindowMessageFilter -typedef BOOL (WINAPI *ChangeWindowMessageFilterPtr) (UINT, DWORD); - -typedef BOOL (WINAPI *CreateProcessWithTokenWFn)( - __in HANDLE hToken, - __in DWORD dwLogonFlags, - __in_opt LPCWSTR lpApplicationName, - __inout_opt LPWSTR lpCommandLine, - __in DWORD dwCreationFlags, - __in_opt LPVOID lpEnvironment, - __in_opt LPCWSTR lpCurrentDirectory, - __in LPSTARTUPINFOW lpStartupInfo, - __out LPPROCESS_INFORMATION lpProcessInformation - ); - -typedef HRESULT (WINAPI *IUnknown_QueryServiceFn)( - __in IUnknown* punk, - __in REFGUID guidService, - __in REFIID riid, - __deref_out void ** ppvOut); - -SetDllDirectoryPtr SetDllDirectoryFn = NULL; -SetSearchPathModePtr SetSearchPathModeFn = NULL; -SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn = NULL; - -ImageList_CreatePtr ImageList_CreateFn = NULL; -ImageList_AddPtr ImageList_AddFn = NULL; - -SetupCloseInfFilePtr SetupCloseInfFileFn = NULL; -SetupDiOpenClassRegKeyPtr SetupDiOpenClassRegKeyFn = NULL; -SetupInstallFromInfSectionWPtr SetupInstallFromInfSectionWFn = NULL; -SetupOpenInfFileWPtr SetupOpenInfFileWFn = NULL; -SHDeleteKeyWPtr SHDeleteKeyWFn = NULL; -SHStrDupWPtr SHStrDupWFn = NULL; -UrlUnescapeWPtr UrlUnescapeWFn = NULL; -ChangeWindowMessageFilterPtr ChangeWindowMessageFilterFn = NULL; -CreateProcessWithTokenWFn CreateProcessWithTokenWPtr = NULL; -IUnknown_QueryServiceFn IUnknown_QueryServicePtr = NULL; - -typedef LONG (WINAPI *WINVERIFYTRUST)(HWND hwnd, GUID *pgActionID, LPVOID pWVTData); -typedef CRYPT_PROVIDER_DATA* (WINAPI *WTHELPERPROVDATAFROMSTATEDATA)(HANDLE hStateData); -typedef CRYPT_PROVIDER_SGNR* (WINAPI *WTHELPERGETPROVSIGNERFROMCHAIN)(CRYPT_PROVIDER_DATA *pProvData, - DWORD idxSigner, - BOOL fCounterSigner, - DWORD idxCounterSigner); -typedef CRYPT_PROVIDER_CERT* (WINAPI *WTHELPERGETPROVCERTFROMCHAIN)(CRYPT_PROVIDER_SGNR *pSgnr, - DWORD idxCert); - -static WINVERIFYTRUST WinVerifyTrustFn = NULL; -static WTHELPERPROVDATAFROMSTATEDATA WTHelperProvDataFromStateDataFn = NULL; -static WTHELPERGETPROVSIGNERFROMCHAIN WTHelperGetProvSignerFromChainFn = NULL; -static WTHELPERGETPROVCERTFROMCHAIN WTHelperGetProvCertFromChainFn = NULL; - static unsigned char gpbSha512CodeSignCertFingerprint[64] = { 0x9C, 0xA0, 0x21, 0xD3, 0x7C, 0x90, 0x61, 0x88, 0xEF, 0x5F, 0x99, 0x3D, 0x54, 0x9F, 0xB8, 0xCE, 0x72, 0x32, 0x4F, 0x57, 0x4F, 0x19, 0xD2, 0xA4, 0xDC, 0x84, 0xFF, 0xE2, 0x84, 0x2B, 0xD4, 0x30, 0xAB, 0xA7, 0xE4, 0x63, 0x18, 0xD1, 0xD8, 0x32, 0x0E, 0xA4, 0x81, 0x3C, 0x19, 0xBF, 0x13, 0x11, 0xA4, 0x37, 0xD6, 0xDB, 0x26, 0xBA, 0xDC, 0x8F, 0x86, 0x96, 0x55, 0x96, 0xDB, 0x6F, 0xC0, 0x62 }; static unsigned char gpbSha512MSCodeSignCertFingerprint[64] = { 0xEB, 0x76, 0x2E, 0xD3, 0x5B, 0x4A, 0xB1, 0x0E, 0xF5, 0x3B, 0x99, 0x4E, 0xC1, 0xF7, 0x48, 0x88, 0xF6, 0xA0, 0xE9, 0xAC, 0x32, 0x69, 0xCF, 0x20, 0xE1, 0x60, 0xC4, 0x0C, 0xEF, 0x01, 0x1F, 0xCB, 0x41, 0x95, 0x72, 0xB9, 0xED, 0x63, 0x0C, 0x6B, 0xB9, 0xE9, 0xA2, 0x72, 0xA6, 0x78, 0x96, 0x4C, 0x69, 0x9F, 0x90, 0x3F, 0xB1, 0x3C, 0x64, 0xF2, 0xAB, 0xCF, 0x14, 0x1D, 0xEC, 0x7C, 0xB0, 0xC7 }; - -typedef HRESULT (WINAPI *SHGETKNOWNFOLDERPATH) ( - _In_ REFKNOWNFOLDERID rfid, - _In_ DWORD dwFlags, - _In_opt_ HANDLE hToken, - _Out_ PWSTR *ppszPath -); - /* Windows dialog class */ #define WINDOWS_DIALOG_CLASS L"#32770" /* Custom class names */ #define TC_DLG_CLASS L"VeraCryptCustomDlg" #define TC_SPLASH_CLASS L"VeraCryptSplashDlg" /* constant used by ChangeWindowMessageFilter calls */ #ifndef MSGFLT_ADD #define MSGFLT_ADD 1 #endif /* undocumented message sent during drag-n-drop */ #ifndef WM_COPYGLOBALDATA #define WM_COPYGLOBALDATA 0x0049 #endif /* Benchmarks */ #ifndef SETUP #define BENCHMARK_MAX_ITEMS 100 #define BENCHMARK_DEFAULT_BUF_SIZE BYTES_PER_MB #define HASH_FNC_BENCHMARKS FALSE // For development purposes only. Must be FALSE when building a public release. #define PKCS5_BENCHMARKS FALSE // For development purposes only. Must be FALSE when building a public release. #if PKCS5_BENCHMARKS && HASH_FNC_BENCHMARKS #error PKCS5_BENCHMARKS and HASH_FNC_BENCHMARKS are both TRUE (at least one of them should be FALSE). #endif enum @@ -946,184 +821,131 @@ BOOL TCCopyFileBase (HANDLE src, HANDLE dst) CloseHandle (dst); free (buffer); return res != 0; } BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile) { HANDLE src, dst; src = CreateFileW (sourceFileName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (src == INVALID_HANDLE_VALUE) return FALSE; dst = CreateFileW (destinationFile, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); if (dst == INVALID_HANDLE_VALUE) { CloseHandle (src); return FALSE; } return TCCopyFileBase (src, dst); } -#if defined(NDEBUG) && !defined(VC_SKIP_OS_DRIVER_REQ_CHECK) -static BOOL InitializeWintrust() -{ - if (!hWinTrustLib) - { - wchar_t szPath[MAX_PATH] = {0}; - - if (GetSystemDirectory(szPath, MAX_PATH)) - StringCchCatW (szPath, MAX_PATH, L"\\Wintrust.dll"); - else - StringCchCopyW (szPath, MAX_PATH, L"C:\\Windows\\System32\\Wintrust.dll"); - - hWinTrustLib = LoadLibrary (szPath); - if (hWinTrustLib) - { - WinVerifyTrustFn = (WINVERIFYTRUST) GetProcAddress (hWinTrustLib, "WinVerifyTrust"); - WTHelperProvDataFromStateDataFn = (WTHELPERPROVDATAFROMSTATEDATA) GetProcAddress (hWinTrustLib, "WTHelperProvDataFromStateData"); - WTHelperGetProvSignerFromChainFn = (WTHELPERGETPROVSIGNERFROMCHAIN) GetProcAddress (hWinTrustLib, "WTHelperGetProvSignerFromChain"); - WTHelperGetProvCertFromChainFn = (WTHELPERGETPROVCERTFROMCHAIN) GetProcAddress (hWinTrustLib, "WTHelperGetProvCertFromChain"); - - if ( !WinVerifyTrustFn - || !WTHelperProvDataFromStateDataFn - || !WTHelperGetProvSignerFromChainFn - || !WTHelperGetProvCertFromChainFn) - { - FreeLibrary (hWinTrustLib); - hWinTrustLib = NULL; - } - - } - } - - if (hWinTrustLib) - return TRUE; - else - return FALSE; -} - -static void FinalizeWintrust() -{ - if (hWinTrustLib) - { - FreeLibrary (hWinTrustLib); - hWinTrustLib = NULL; - } -} - -#endif BOOL VerifyModuleSignature (const wchar_t* path) { #if defined(NDEBUG) && !defined (VC_SKIP_OS_DRIVER_REQ_CHECK) BOOL bResult = FALSE; HRESULT hResult; GUID gActionID = WINTRUST_ACTION_GENERIC_VERIFY_V2; WINTRUST_FILE_INFO fileInfo = {0}; WINTRUST_DATA WVTData = {0}; wchar_t filePath [TC_MAX_PATH + 1024]; // we check our own authenticode signature only starting from Windows 10 since this is // the minimal supported OS apart from XP where we can't verify SHA256 signatures if (!IsOSAtLeast (WIN_10)) return TRUE; // Strip quotation marks (if any) if (path [0] == L'"') { StringCbCopyW (filePath, sizeof(filePath), path + 1); } else { StringCbCopyW (filePath, sizeof(filePath), path); } // Strip quotation marks (if any) if (filePath [wcslen (filePath) - 1] == L'"') filePath [wcslen (filePath) - 1] = 0; - if (!InitializeWintrust ()) - return FALSE; - fileInfo.cbStruct = sizeof(WINTRUST_FILE_INFO); fileInfo.pcwszFilePath = filePath; fileInfo.hFile = NULL; WVTData.cbStruct = sizeof(WINTRUST_DATA); WVTData.dwUIChoice = WTD_UI_NONE; WVTData.fdwRevocationChecks = WTD_REVOKE_NONE; WVTData.dwUnionChoice = WTD_CHOICE_FILE; WVTData.pFile = &fileInfo; WVTData.dwStateAction = WTD_STATEACTION_VERIFY; WVTData.dwProvFlags = WTD_REVOCATION_CHECK_NONE | WTD_CACHE_ONLY_URL_RETRIEVAL; - hResult = WinVerifyTrustFn(0, &gActionID, &WVTData); + hResult = WinVerifyTrust(0, &gActionID, &WVTData); if (0 == hResult) { - PCRYPT_PROVIDER_DATA pProviderData = WTHelperProvDataFromStateDataFn (WVTData.hWVTStateData); + PCRYPT_PROVIDER_DATA pProviderData = WTHelperProvDataFromStateData (WVTData.hWVTStateData); if (pProviderData) { - PCRYPT_PROVIDER_SGNR pProviderSigner = WTHelperGetProvSignerFromChainFn (pProviderData, 0, FALSE, 0); + PCRYPT_PROVIDER_SGNR pProviderSigner = WTHelperGetProvSignerFromChain (pProviderData, 0, FALSE, 0); if (pProviderSigner) { - PCRYPT_PROVIDER_CERT pProviderCert = WTHelperGetProvCertFromChainFn (pProviderSigner, 0); + PCRYPT_PROVIDER_CERT pProviderCert = WTHelperGetProvCertFromChain (pProviderSigner, 0); if (pProviderCert && (pProviderCert->pCert)) { BYTE hashVal[64]; sha512 (hashVal, pProviderCert->pCert->pbCertEncoded, pProviderCert->pCert->cbCertEncoded); if ( (0 == memcmp (hashVal, gpbSha512CodeSignCertFingerprint, 64)) || (0 == memcmp (hashVal, gpbSha512MSCodeSignCertFingerprint, 64)) ) { bResult = TRUE; } } } } } WVTData.dwUIChoice = WTD_UI_NONE; WVTData.dwStateAction = WTD_STATEACTION_CLOSE; - WinVerifyTrustFn(0, &gActionID, &WVTData); - - FinalizeWintrust (); + WinVerifyTrust(0, &gActionID, &WVTData); return bResult; #else return TRUE; #endif } DWORD handleWin32Error (HWND hwndDlg, const char* srcPos) { #ifndef VC_COMREG PWSTR lpMsgBuf; DWORD dwError = GetLastError (); wchar_t szErrorValue[32]; wchar_t* pszDesc; if (Silent || dwError == 0 || dwError == ERROR_INVALID_WINDOW_HANDLE) return dwError; // Access denied if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ()) { ErrorDirect ( AppendSrcPos (GetString ("ERR_ACCESS_DENIED"), srcPos).c_str (), hwndDlg); SetLastError (dwError); // Preserve the original error code return dwError; } FormatMessageW ( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwError, @@ -1338,159 +1160,78 @@ void InitOSVersionInfo () } #pragma warning(push) #pragma warning(disable:4702) void *err_malloc (size_t size) { void *z = (void *) TCalloc (size); if (z) return z; AbortProcess ("OUTOFMEMORY"); return 0; } #pragma warning(pop) char *err_strdup (char *lpszText) { size_t j = (strlen (lpszText) + 1) * sizeof (char); char *z = (char *) err_malloc (j); memmove (z, lpszText, j); return z; } void AbortProcessDirect (wchar_t *abortMsg) { // Note that this function also causes localcleanup() to be called (see atexit()) MessageBeep (MB_ICONEXCLAMATION); MessageBoxW (NULL, abortMsg, lpszTitle, ICON_HAND); -#ifndef VC_COMREG - FREE_DLL (hRichEditDll); - FREE_DLL (hComctl32Dll); - FREE_DLL (hSetupDll); - FREE_DLL (hShlwapiDll); - FREE_DLL (hProfApiDll); - FREE_DLL (hUsp10Dll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hUXThemeDll); - FREE_DLL (hUserenvDll); - FREE_DLL (hRsaenhDll); - FREE_DLL (himm32dll); - FREE_DLL (hMSCTFdll); - FREE_DLL (hfltlibdll); - FREE_DLL (hframedyndll); - FREE_DLL (hpsapidll); - FREE_DLL (hsecur32dll); - FREE_DLL (hnetapi32dll); - FREE_DLL (hauthzdll); - FREE_DLL (hxmllitedll); - FREE_DLL (hmprdll); - FREE_DLL (hsppdll); - FREE_DLL (vssapidll); - FREE_DLL (hvsstracedll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hcfgmgr32dll); - FREE_DLL (hdevobjdll); - FREE_DLL (hpowrprofdll); - FREE_DLL (hsspiclidll); - FREE_DLL (hcryptbasedll); - FREE_DLL (hdwmapidll); - FREE_DLL (hmsasn1dll); - FREE_DLL (hcrypt32dll); - FREE_DLL (hbcryptdll); - FREE_DLL (hbcryptprimitivesdll); - FREE_DLL (hMsls31); - FREE_DLL (hntmartadll); - FREE_DLL (hwinscarddll); - FREE_DLL (hmsvcrtdll); - FREE_DLL (hAdvapi32Dll); -#endif exit (1); } void AbortProcess (char *stringId) { // Note that this function also causes localcleanup() to be called (see atexit()) #ifndef VC_COMREG AbortProcessDirect (GetString (stringId)); #else static wchar_t g_wszUnknown[1024]; StringCbPrintfW (g_wszUnknown, sizeof(g_wszUnknown), UNKNOWN_STRING_ID L"%hs" UNKNOWN_STRING_ID, stringId); AbortProcessDirect (g_wszUnknown); #endif } #ifndef VC_COMREG void AbortProcessSilent (void) { - FREE_DLL (hRichEditDll); - FREE_DLL (hComctl32Dll); - FREE_DLL (hSetupDll); - FREE_DLL (hShlwapiDll); - FREE_DLL (hProfApiDll); - FREE_DLL (hUsp10Dll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hUXThemeDll); - FREE_DLL (hUserenvDll); - FREE_DLL (hRsaenhDll); - FREE_DLL (himm32dll); - FREE_DLL (hMSCTFdll); - FREE_DLL (hfltlibdll); - FREE_DLL (hframedyndll); - FREE_DLL (hpsapidll); - FREE_DLL (hsecur32dll); - FREE_DLL (hnetapi32dll); - FREE_DLL (hauthzdll); - FREE_DLL (hxmllitedll); - FREE_DLL (hmprdll); - FREE_DLL (hsppdll); - FREE_DLL (vssapidll); - FREE_DLL (hvsstracedll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hcfgmgr32dll); - FREE_DLL (hdevobjdll); - FREE_DLL (hpowrprofdll); - FREE_DLL (hsspiclidll); - FREE_DLL (hcryptbasedll); - FREE_DLL (hdwmapidll); - FREE_DLL (hmsasn1dll); - FREE_DLL (hcrypt32dll); - FREE_DLL (hbcryptdll); - FREE_DLL (hbcryptprimitivesdll); - FREE_DLL (hMsls31); - FREE_DLL (hntmartadll); - FREE_DLL (hwinscarddll); - FREE_DLL (hmsvcrtdll); - FREE_DLL (hAdvapi32Dll); - // Note that this function also causes localcleanup() to be called (see atexit()) exit (1); } void InitGlobalLocks () { InitializeCriticalSection (&csWNetCalls); InitializeCriticalSection (&csMountableDevices); InitializeCriticalSection (&csVolumeIdCandidates); InitializeCriticalSection (&csSecureDesktop); } void FinalizeGlobalLocks () { DeleteCriticalSection (&csWNetCalls); DeleteCriticalSection (&csMountableDevices); DeleteCriticalSection (&csVolumeIdCandidates); DeleteCriticalSection (&csSecureDesktop); } void cleanup () { burn (&CmdTokenPin, sizeof (CmdTokenPin)); #ifndef SETUP KeyFileRemoveAll (&FirstKeyFile); KeyFileRemoveAll (&defaultKeyFilesParam.FirstKeyFile); #endif /* Cleanup the GDI fonts */ if (hFixedFont != NULL) @@ -1992,60 +1733,142 @@ 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) { // Resize and move the text field MoveWindow (hwndCtrl, rec.left - wrec.left - (bBorderlessWindow ? 0 : GetSystemMetrics(SM_CXFIXEDFRAME)) + alignPosDiff, rec.top - wrec.top - vertOffset, origWidth - horizSubOffset, origHeight - vertSubOffset, TRUE); } else { // Resize the text field SetWindowPos (hwndCtrl, 0, 0, 0, origWidth - horizSubOffset, origHeight - vertSubOffset, SWP_NOMOVE | SWP_NOZORDER); } SetWindowPos (hwndCtrl, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); InvalidateRect (hwndCtrl, NULL, TRUE); } } +// Resizes width of a checkbox according to actual width in pixels of its label text (font size is taken into account) +void AccommodateCheckBoxTextWidth (HWND hwndDlg, UINT ctrlId) +{ + RECT rec; + HWND hwndCtrl = GetDlgItem (hwndDlg, ctrlId); + int width, origWidth, origHeight; + int horizSubOffset; + wchar_t text [MAX_URL_LENGTH]; + HFONT hFont = (HFONT) SendDlgItemMessage (hwndDlg, ctrlId, WM_GETFONT, 0, 0); + + // Resize the field according to its length and font size and move if centered or right-aligned + + GetWindowTextW (hwndCtrl, text, sizeof (text) / sizeof (wchar_t)); + + width = GetTextGfxWidth (hwndCtrl, text, hFont); + + // add to width variable value the width of the checkbox square. We use SM_CXMENUCHECK which is a little larger than actual width + width += GetSystemMetrics(SM_CXMENUCHECK); + + + GetClientRect (hwndCtrl, &rec); + origWidth = rec.right; + origHeight = rec.bottom; + + if (width >= 0 + && (origWidth > width)) // The original width of the field is the maximum allowed size + { + horizSubOffset = origWidth - width; + + // Resize the text field + SetWindowPos (hwndCtrl, 0, 0, 0, + origWidth - horizSubOffset, + origHeight, + SWP_NOMOVE | SWP_NOZORDER); + + InvalidateRect (hwndCtrl, NULL, TRUE); + } +} + +// makes controls contiguous by moving the second control right next to the first one horizontally +void MakeControlsContiguous(HWND hwndDlg, UINT ctrl1ID, UINT ctrl2ID) { + HWND hwndCtrl1 = GetDlgItem(hwndDlg, ctrl1ID); + HWND hwndCtrl2 = GetDlgItem(hwndDlg, ctrl2ID); + RECT rect1, rect2; + POINT pt1, pt2; + int newLeftPosition; + + // Exit silently if one or both controls are missing + if (!hwndCtrl1 || !hwndCtrl2) { + return; + } + + + GetWindowRect(hwndCtrl1, &rect1); + GetWindowRect(hwndCtrl2, &rect2); + + // Convert the top-right point of the first control from screen to client coordinates + pt1.x = rect1.right; + pt1.y = rect1.top; + if (!ScreenToClient(hwndDlg, &pt1)) { + return; // Exit if the conversion fails + } + + // Convert the top-left point of the second control from screen to client coordinates + pt2.x = rect2.left; + pt2.y = rect2.top; + if (!ScreenToClient(hwndDlg, &pt2)) { + return; // Exit if the conversion fails + } + + // Ensure the second control is always placed to the right of the first one + newLeftPosition = pt1.x + 1; + + if (pt2.x < pt1.x) { // if the second control is to the left of the first one + newLeftPosition += (pt1.x - pt2.x); + } + + // Move the second control to its new position + SetWindowPos(hwndCtrl2, NULL, newLeftPosition, pt2.y, 0, 0, SWP_NOZORDER | SWP_NOSIZE); +} + + // Note that the user can still close the window by right-clicking its taskbar icon and selecting 'Close window', or by pressing Alt-F4, or using the Task Manager. void DisableCloseButton (HWND hwndDlg) { EnableMenuItem (GetSystemMenu (hwndDlg, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED); } void EnableCloseButton (HWND hwndDlg) { EnableMenuItem (GetSystemMenu (hwndDlg, FALSE), SC_CLOSE, MF_BYCOMMAND | MF_ENABLED); } void HandlePasswordEditWmChar (HWND hwnd, WPARAM wParam) { DWORD dwStartPos = 0, dwEndPos = 0; short vk = VkKeyScanW ((WCHAR) wParam); BYTE vkCode = LOBYTE (vk); BYTE vkState = HIBYTE (vk); bool ctrlPressed = (vkState & 2) && !(vkState & 4); int dwMaxPassLen = (int) SendMessage (hwnd, EM_GETLIMITTEXT, 0, 0); // check if there is a selected text SendMessage (hwnd, EM_GETSEL, (WPARAM) &dwStartPos, (LPARAM) &dwEndPos); if ((dwStartPos == dwEndPos) && (vkCode != VK_DELETE) && (vkCode != VK_BACK) && !ctrlPressed && (GetWindowTextLength (hwnd) == dwMaxPassLen)) { EDITBALLOONTIP ebt; @@ -2306,116 +2129,152 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam 0, 0, 0, 0, FALSE, TRUE); SetWindowPos (GetDlgItem (hwndDlg, IDC_ABOUT_BKG), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); } // Version SendMessage (GetDlgItem (hwndDlg, IDT_ABOUT_VERSION), WM_SETFONT, (WPARAM) hUserBoldFont, 0); StringCbPrintfW (szTmp, sizeof(szTmp), L"VeraCrypt %s", _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); #ifdef _WIN64 StringCbCatW (szTmp, sizeof(szTmp), L" (64-bit)"); #else StringCbCatW (szTmp, sizeof(szTmp), L" (32-bit)"); #endif #if (defined(_DEBUG) || defined(DEBUG)) StringCbCatW (szTmp, sizeof(szTmp), L" (debug)"); #endif SetDlgItemText (hwndDlg, IDT_ABOUT_VERSION, szTmp); SetDlgItemText (hwndDlg, IDT_ABOUT_RELEASE, TC_STR_RELEASED_BY); // Credits SendMessage (GetDlgItem (hwndDlg, IDC_ABOUT_CREDITS), WM_SETFONT, (WPARAM) hUserFont, (LPARAM) 0); SendMessage (hwndDlg, WM_APP, 0, 0); return 1; } case WM_APP: SetWindowText (GetDlgItem (hwndDlg, IDC_ABOUT_CREDITS), L"Based on TrueCrypt 7.1a, freely available at http://www.truecrypt.org/ .\r\n\r\n" L"Portions of this software:\r\n" - L"Copyright \xA9 2013-2023 IDRIX. All rights reserved.\r\n" + L"Copyright \xA9 2013-2024 IDRIX. All rights reserved.\r\n" L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\r\n" L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\r\n" L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\r\n" - L"Copyright \xA9 1995-2017 Jean-loup Gailly and Mark Adler.\r\n" + L"Copyright \xA9 1995-2023 Jean-loup Gailly and Mark Adler.\r\n" L"Copyright \xA9 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov.\r\n" - L"Copyright \xA9 1999-2020 Dieter Baron and Thomas Klausner.\r\n" + L"Copyright \xA9 1999-2023 Dieter Baron and Thomas Klausner.\r\n" L"Copyright \xA9 2013, Alexey Degtyarev. All rights reserved.\r\n" L"Copyright \xA9 1999-2016 Jack Lloyd. All rights reserved.\r\n" L"Copyright \xA9 2013-2019 Stephan Mueller <smueller@chronox.de>\r\n" - L"Copyright \xA9 1999-2021 Igor Pavlov\r\n\r\n" + L"Copyright \xA9 1999-2023 Igor Pavlov\r\n\r\n" L"This software as a whole:\r\n" - L"Copyright \xA9 2013-2023 IDRIX. All rights reserved.\r\n\r\n" + L"Copyright \xA9 2013-2024 IDRIX. All rights reserved.\r\n\r\n" L"An IDRIX Release"); return 1; case WM_COMMAND: if (lw == IDOK || lw == IDCANCEL) { PostMessage (hwndDlg, WM_CLOSE, 0, 0); return 1; } if (lw == IDC_HOMEPAGE) { Applink ("main"); return 1; } // Disallow modification of credits if (HIWORD (wParam) == EN_UPDATE) { SendMessage (hwndDlg, WM_APP, 0, 0); return 1; } return 0; case WM_CLOSE: /* Delete buffered bitmaps (if any) */ if (hbmTextualLogoBitmapRescaled != NULL) { DeleteObject ((HGDIOBJ) hbmTextualLogoBitmapRescaled); hbmTextualLogoBitmapRescaled = NULL; } EndDialog (hwndDlg, 0); return 1; } return 0; } +HWND CreateToolTip(int toolID, HWND hDlg, const char* strID) +{ + if (!toolID || !hDlg) + { + return FALSE; + } + + // Create the tooltip. + HWND hwndTip = CreateWindowExW(NULL, TOOLTIPS_CLASS, NULL, + WS_POPUP | TTS_ALWAYSTIP | TTS_NOPREFIX | TTS_BALLOON, + CW_USEDEFAULT, CW_USEDEFAULT, + CW_USEDEFAULT, CW_USEDEFAULT, + hDlg, NULL, + hInst, NULL); + + if (!hwndTip) + { + return (HWND)NULL; + } + + // Associate the tooltip with the tool. + TOOLINFOW toolInfo = { 0 }; + toolInfo.cbSize = sizeof(toolInfo); + toolInfo.hwnd = hDlg; + toolInfo.uFlags = TTF_SUBCLASS | TTF_IDISHWND; + toolInfo.uId = (UINT_PTR) GetDlgItem(hDlg, toolID); + toolInfo.lpszText = GetString(strID); + + // set tooltip maximum width + SendMessage(hwndTip, TTM_SETMAXTIPWIDTH, 0, (LPARAM) 300); + + SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo); + + return hwndTip; +} + static HWND StaticModelessWaitDlgHandle = NULL; // Call DisplayStaticModelessWaitDlg() to open this dialog and CloseStaticModelessWaitDlg() to close it. static BOOL CALLBACK StaticModelessWaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); switch (msg) { case WM_INITDIALOG: { LocalizeDialog (hwndDlg, NULL); return 0; } case WM_COMMAND: if (lw == IDOK || lw == IDCANCEL) return 1; return 0; case WM_CLOSE: StaticModelessWaitDlgHandle = NULL; EndDialog (hwndDlg, 0); return 1; } @@ -2481,61 +2340,61 @@ void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler) be called only once in the dialogs WM_INITDIALOG message handler */ void InitDialog (HWND hwndDlg) { NONCLIENTMETRICSW metric; static BOOL aboutMenuAppended = FALSE; int nHeight; LOGFONTW lf; HMENU hMenu; Font *font; /* Fonts */ memset (&lf, 0, sizeof(lf)); // Normal font = GetFont ("font_normal"); metric.cbSize = sizeof (metric); SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof(metric), &metric, 0); WindowTitleBarFont = CreateFontIndirectW (&metric.lfCaptionFont); metric.lfMessageFont.lfHeight = CompensateDPIFont (!font ? -11 : -font->Size); metric.lfMessageFont.lfWidth = 0; if (font && wcscmp (font->FaceName, L"default") != 0) { StringCbCopyW ((WCHAR *)metric.lfMessageFont.lfFaceName, sizeof (metric.lfMessageFont.lfFaceName), font->FaceName); } - else if (IsOSAtLeast (WIN_VISTA)) + else { // Vista's new default font (size and spacing) breaks compatibility with Windows 2k/XP applications. // Force use of Tahoma (as Microsoft does in many dialogs) until a native Vista look is implemented. StringCbCopyW ((WCHAR *)metric.lfMessageFont.lfFaceName, sizeof (metric.lfMessageFont.lfFaceName), L"Tahoma"); } hUserFont = CreateFontIndirectW (&metric.lfMessageFont); metric.lfMessageFont.lfUnderline = TRUE; hUserUnderlineFont = CreateFontIndirectW (&metric.lfMessageFont); metric.lfMessageFont.lfUnderline = FALSE; metric.lfMessageFont.lfWeight = FW_BOLD; hUserBoldFont = CreateFontIndirectW (&metric.lfMessageFont); metric.lfMessageFont.lfUnderline = TRUE; metric.lfMessageFont.lfWeight = FW_BOLD; hUserUnderlineBoldFont = CreateFontIndirectW (&metric.lfMessageFont); // Fixed-size (hexadecimal digits) nHeight = CompensateDPIFont (-12); lf.lfHeight = nHeight; lf.lfWidth = 0; lf.lfEscapement = 0; lf.lfOrientation = 0; lf.lfWeight = FW_NORMAL; lf.lfItalic = FALSE; lf.lfUnderline = FALSE; lf.lfStrikeOut = FALSE; lf.lfCharSet = DEFAULT_CHARSET; @@ -2998,61 +2857,61 @@ wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition) && wcsstr (path, L"Partition0") == NULL) { *bIsPartition = TRUE; return GetString (bUpperCase ? "PARTITION_UPPER_CASE" : "PARTITION_LOWER_CASE"); } else if (wcsstr (path, L"HarddiskVolume")) { *bIsPartition = TRUE; return GetString (bUpperCase ? "VOLUME_UPPER_CASE" : "VOLUME_LOWER_CASE"); } *bIsPartition = FALSE; return GetString (bUpperCase ? "DEVICE_UPPER_CASE" : "DEVICE_LOWER_CASE"); } LRESULT CALLBACK CustomDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (uMsg == WM_SETCURSOR && hCursor != NULL) { SetCursor (hCursor); return TRUE; } return DefDlgProcW (hwnd, uMsg, wParam, lParam); } /* static BOOL IsReturnAddress (DWORD64 address) { static size_t codeEnd = 0; - byte *sp = (byte *) address; + uint8 *sp = (uint8 *) address; if (codeEnd == 0) { MEMORY_BASIC_INFORMATION mi; if (VirtualQuery ((LPCVOID) 0x401000, &mi, sizeof (mi)) >= sizeof (mi)) codeEnd = (size_t) mi.BaseAddress + mi.RegionSize; } if (address < 0x401000 + 8 || address > codeEnd) return FALSE; return sp[-5] == 0xe8 // call ADDR || (sp[-6] == 0xff && sp[-5] == 0x15) // call [ADDR] || (sp[-2] == 0xff && (sp[-1] & 0xf0) == 0xd0); // call REG } */ typedef struct { EXCEPTION_POINTERS *ExceptionPointers; HANDLE ExceptionThread; } ExceptionHandlerThreadArgs; void ExceptionHandlerThread (void *threadArg) { ExceptionHandlerThreadArgs *args = (ExceptionHandlerThreadArgs *) threadArg; EXCEPTION_POINTERS *ep = args->ExceptionPointers; @@ -3132,61 +2991,61 @@ void ExceptionHandlerThread (void *threadArg) { for (size_t i = 0; i < symbol->NameLen; ++i) { if (!isalnum (symbol->Name[i])) symbol->Name[i] = '_'; } if (symbol->Name != lastSymbol) callStack << "&st" << frameNumber++ << "=" << symbol->Name; lastSymbol = symbol->Name; } else if (frameNumber == 0 || IsReturnAddress (frame.AddrPC.Offset)) { callStack << "&st" << frameNumber++ << "=0x" << hex << frame.AddrPC.Offset << dec; } } } } } // StackWalk64() may fail due to missing frame pointers list <DWORD> retAddrs; if (frameNumber == 0) retAddrs.push_back (ep->ContextRecord->Eip); retAddrs.push_back (0); MEMORY_BASIC_INFORMATION mi; VirtualQuery (sp, &mi, sizeof (mi)); - PDWORD stackTop = (PDWORD)((byte *) mi.BaseAddress + mi.RegionSize); + PDWORD stackTop = (PDWORD)((uint8 *) mi.BaseAddress + mi.RegionSize); int i = 0; while (retAddrs.size() < 16 && &sp[i] < stackTop) { if (IsReturnAddress (sp[i])) { bool duplicate = false; foreach (DWORD prevAddr, retAddrs) { if (sp[i] == prevAddr) { duplicate = true; break; } } if (!duplicate) retAddrs.push_back (sp[i]); } i++; } if (retAddrs.size() > 1) { foreach (DWORD addr, retAddrs) { callStack << "&st" << frameNumber++ << "=0x" << hex << addr << dec; } } @@ -3476,60 +3335,78 @@ uint32 ReadDriverConfigurationFlags () { DWORD configMap; if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_DRIVER_CONFIG_REG_VALUE_NAME, &configMap)) configMap = 0; return configMap; } uint32 ReadServiceConfigurationFlags () { DWORD configMap; if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\" TC_SYSTEM_FAVORITES_SERVICE_NAME, TC_SYSTEM_FAVORITES_SERVICE_NAME L"Config", &configMap)) configMap = 0; return configMap; } uint32 ReadEncryptionThreadPoolFreeCpuCountLimit () { DWORD count; if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, &count)) count = 0; return count; } +BOOL ReadMemoryProtectionConfig () +{ + DWORD config; + + if (!ReadLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", VC_ENABLE_MEMORY_PROTECTION, &config)) + { + // enabled by default + config = 1; + } + return (config)? TRUE: FALSE; +} + +BOOL WriteMemoryProtectionConfig (BOOL bEnable) +{ + DWORD config = bEnable? 1: 0; + + return WriteLocalMachineRegistryDword (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", VC_ENABLE_MEMORY_PROTECTION, config); +} BOOL LoadSysEncSettings () { BOOL status = TRUE; DWORD size = 0; char *sysEncCfgFileBuf = LoadFile (GetConfigPath (TC_APPD_FILENAME_SYSTEM_ENCRYPTION), &size); char *xml = sysEncCfgFileBuf; char paramName[100], paramVal[MAX_PATH]; // Defaults int newSystemEncryptionStatus = SYSENC_STATUS_NONE; WipeAlgorithmId newnWipeMode = TC_WIPE_NONE; if (!FileExists (GetConfigPath (TC_APPD_FILENAME_SYSTEM_ENCRYPTION))) { SystemEncryptionStatus = newSystemEncryptionStatus; nWipeMode = newnWipeMode; } if (xml == NULL) { return FALSE; } while (xml = XmlFindElement (xml, "config")) { XmlGetAttributeText (xml, "key", paramName, sizeof (paramName)); XmlGetNodeText (xml, paramVal, sizeof (paramVal)); if (strcmp (paramName, "SystemEncryptionStatus") == 0) @@ -3652,249 +3529,154 @@ void DoPostInstallTasks (HWND hwndDlg) BOOL bDone = FALSE; if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_TUTORIAL))) { if (AskYesNo ("AFTER_INSTALL_TUTORIAL", hwndDlg) == IDYES) Applink ("beginnerstutorial"); bDone = TRUE; } if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RELEASE_NOTES))) { if (AskYesNo ("AFTER_UPGRADE_RELEASE_NOTES", hwndDlg) == IDYES) Applink ("releasenotes"); bDone = TRUE; } if (FileExists (GetConfigPath (TC_APPD_FILENAME_POST_INSTALL_TASK_RESCUE_DISK))) { if (AskYesNo ("AFTER_UPGRADE_RESCUE_DISK", hwndDlg) == IDYES) PostMessage (hwndDlg, VC_APPMSG_CREATE_RESCUE_DISK, 0, 0); bDone = TRUE; } if (bDone) SavePostInstallTasksSettings (TC_POST_INSTALL_CFG_REMOVE_ALL); } -static void LoadSystemDll (LPCTSTR szModuleName, HMODULE *pHandle, BOOL bIgnoreError, const char* srcPos) -{ - wchar_t dllPath[MAX_PATH]; - - /* Load dll explictely from System32 to avoid Dll hijacking attacks*/ - if (!GetSystemDirectory(dllPath, MAX_PATH)) - StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32"); +#ifndef SETUP_DLL +// Use an idea proposed in https://medium.com/@1ndahous3/safe-code-pitfalls-dll-side-loading-winapi-and-c-73baaf48bdf5 +// it allows to set safe DLL search mode for the entire process very early on, before even the CRT is initialized and global constructors are called +#pragma comment(linker, "/ENTRY:CustomMainCrtStartup") +extern "C" { + int wWinMainCRTStartup(); + int APIENTRY CustomMainCrtStartup() + { + SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn = NULL; + SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories"); + if (SetDefaultDllDirectoriesFn) + { + /* remove current directory from dll search path */ + SetDllDirectoryW (L""); + // Force loading dlls from system32 directory only + SetDefaultDllDirectoriesFn (LOAD_LIBRARY_SEARCH_SYSTEM32); + } - StringCbCatW(dllPath, sizeof(dllPath), L"\\"); - StringCbCatW(dllPath, sizeof(dllPath), szModuleName); + // activate process mitigations (currently only ASLR, dynamic code and extensions points) + ActivateProcessMitigations(); - if (((*pHandle = LoadLibrary(dllPath)) == NULL) && !bIgnoreError) - { - // This error is fatal - handleWin32Error (NULL, srcPos); - AbortProcess ("INIT_DLL"); +#ifndef SETUP + // call ActivateMemoryProtection if corresponding setting has been enabled (default is enabled) + if (ReadMemoryProtectionConfig()) + { + ActivateMemoryProtection(); + } +#endif + return wWinMainCRTStartup(); } } +#endif /* InitApp - initialize the application, this function is called once in the applications WinMain function, but before the main dialog has been created */ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) { WNDCLASSW wc; char langId[6]; - InitCommonControlsPtr InitCommonControlsFn = NULL; + SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn = NULL; +#if !defined(SETUP) wchar_t modPath[MAX_PATH]; - - GetModuleFileNameW (NULL, modPath, ARRAYSIZE (modPath)); - - /* remove current directory from dll search path */ - SetDllDirectoryFn = (SetDllDirectoryPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDllDirectoryW"); - SetSearchPathModeFn = (SetSearchPathModePtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetSearchPathMode"); - SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories"); - - if (SetDllDirectoryFn) - SetDllDirectoryFn (L""); - if (SetSearchPathModeFn) - SetSearchPathModeFn (BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT); - if (SetDefaultDllDirectoriesFn) - SetDefaultDllDirectoriesFn (LOAD_LIBRARY_SEARCH_SYSTEM32); - - InitOSVersionInfo(); - - VirtualLock (&CmdTokenPin, sizeof (CmdTokenPin)); - - InitGlobalLocks (); - - LoadSystemDll (L"msvcrt.dll", &hmsvcrtdll, TRUE, SRC_POS); - LoadSystemDll (L"ntmarta.dll", &hntmartadll, TRUE, SRC_POS); - LoadSystemDll (L"MPR.DLL", &hmprdll, TRUE, SRC_POS); -#ifdef SETUP - if (IsOSAtLeast (WIN_7)) - { - LoadSystemDll (L"ProfApi.DLL", &hProfApiDll, TRUE, SRC_POS); - LoadSystemDll (L"cryptbase.dll", &hcryptbasedll, TRUE, SRC_POS); - LoadSystemDll (L"sspicli.dll", &hsspiclidll, TRUE, SRC_POS); - } #endif - LoadSystemDll (L"psapi.dll", &hpsapidll, TRUE, SRC_POS); - LoadSystemDll (L"secur32.dll", &hsecur32dll, TRUE, SRC_POS); - LoadSystemDll (L"msasn1.dll", &hmsasn1dll, TRUE, SRC_POS); - LoadSystemDll (L"Usp10.DLL", &hUsp10Dll, TRUE, SRC_POS); - if (IsOSAtLeast (WIN_7)) - LoadSystemDll (L"dwmapi.dll", &hdwmapidll, TRUE, SRC_POS); - LoadSystemDll (L"UXTheme.dll", &hUXThemeDll, 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); + INITCOMMONCONTROLSEX InitCtrls; - LoadSystemDll (L"userenv.dll", &hUserenvDll, TRUE, SRC_POS); - LoadSystemDll (L"rsaenh.dll", &hRsaenhDll, TRUE, SRC_POS); + InitOSVersionInfo(); -#ifdef SETUP - if (nCurrentOS < WIN_7) + if (!IsOSAtLeast (WIN_7)) { - if (nCurrentOS == WIN_XP) - { - LoadSystemDll (L"imm32.dll", &himm32dll, TRUE, SRC_POS); - LoadSystemDll (L"MSCTF.dll", &hMSCTFdll, TRUE, SRC_POS); - LoadSystemDll (L"fltlib.dll", &hfltlibdll, TRUE, SRC_POS); - LoadSystemDll (L"wbem\\framedyn.dll", &hframedyndll, TRUE, SRC_POS); - } - - 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); - } + // abort using a message that says that VeraCrypt can run only on Windows 7 and later and that it is officially supported only on Windows 10 and later + AbortProcessDirect(L"VeraCrypt requires at least Windows 7 to run."); } - if (IsOSAtLeast (WIN_VISTA)) - { - LoadSystemDll (L"atl.dll", &hsppdll, TRUE, SRC_POS); - LoadSystemDll (L"vsstrace.dll", &hvsstracedll, TRUE, SRC_POS); - LoadSystemDll (L"vssapi.dll", &vssapidll, TRUE, SRC_POS); - LoadSystemDll (L"spp.dll", &hsppdll, TRUE, SRC_POS); - } -#endif - - LoadSystemDll (L"crypt32.dll", &hcrypt32dll, TRUE, SRC_POS); - - if (IsOSAtLeast (WIN_7)) + SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories"); + if (!SetDefaultDllDirectoriesFn) { - LoadSystemDll (L"CryptSP.dll", &hCryptSpDll, TRUE, SRC_POS); - - 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"bcrypt.dll", &hbcryptdll, TRUE, SRC_POS); - LoadSystemDll (L"bcryptprimitives.dll", &hbcryptprimitivesdll, TRUE, SRC_POS); - } + // This can happen only if KB2533623 is missing from Windows 7 + AbortProcessDirect(L"VeraCrypt requires KB2533623 to be installed on Windows 7 and Windows Server 2008 R2 in order to run."); + } -#ifndef SETUP - LoadSystemDll (L"WINSCARD.DLL", &hwinscarddll, TRUE, SRC_POS); -#endif + VirtualLock (&CmdTokenPin, sizeof (CmdTokenPin)); - LoadSystemDll (L"COMCTL32.DLL", &hComctl32Dll, FALSE, SRC_POS); + InitGlobalLocks (); - // call InitCommonControls function - InitCommonControlsFn = (InitCommonControlsPtr) GetProcAddress (hComctl32Dll, "InitCommonControls"); - ImageList_AddFn = (ImageList_AddPtr) GetProcAddress (hComctl32Dll, "ImageList_Add"); - ImageList_CreateFn = (ImageList_CreatePtr) GetProcAddress (hComctl32Dll, "ImageList_Create"); - - if (InitCommonControlsFn && ImageList_AddFn && ImageList_CreateFn) - { - InitCommonControlsFn(); - } - else - AbortProcess ("INIT_DLL"); + // call InitCommonControlsEx function to initialize the common controls + InitCtrls.dwSize = sizeof (InitCtrls); + InitCtrls.dwICC = ICC_WIN95_CLASSES | ICC_PAGESCROLLER_CLASS | ICC_NATIVEFNTCTL_CLASS | ICC_STANDARD_CLASSES | ICC_LINK_CLASS; + InitCommonControlsEx (&InitCtrls); - LoadSystemDll (L"Riched20.dll", &hRichEditDll, FALSE, SRC_POS); - LoadSystemDll (L"Advapi32.dll", &hAdvapi32Dll, FALSE, SRC_POS); + // Load RichEdit library in order to be able to use RichEdit20W class + LoadLibraryEx (L"Riched20.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); #if !defined(SETUP) + GetModuleFileNameW (NULL, modPath, ARRAYSIZE (modPath)); if (!VerifyModuleSignature (modPath)) - AbortProcess ("DIST_PACKAGE_CORRUPTED"); + AbortProcessDirect (L"This distribution package is damaged. Please try downloading it again (preferably from the official VeraCrypt website at https://www.veracrypt.fr)."); #endif - // Get SetupAPI functions pointers - SetupCloseInfFileFn = (SetupCloseInfFilePtr) GetProcAddress (hSetupDll, "SetupCloseInfFile"); - SetupDiOpenClassRegKeyFn = (SetupDiOpenClassRegKeyPtr) GetProcAddress (hSetupDll, "SetupDiOpenClassRegKey"); - SetupInstallFromInfSectionWFn = (SetupInstallFromInfSectionWPtr) GetProcAddress (hSetupDll, "SetupInstallFromInfSectionW"); - SetupOpenInfFileWFn = (SetupOpenInfFileWPtr) GetProcAddress (hSetupDll, "SetupOpenInfFileW"); - - if (!SetupCloseInfFileFn || !SetupDiOpenClassRegKeyFn || !SetupInstallFromInfSectionWFn || !SetupOpenInfFileWFn) - AbortProcess ("INIT_DLL"); - - // Get SHDeleteKeyW,SHStrDupW, UrlUnescapeW functions pointers - SHDeleteKeyWFn = (SHDeleteKeyWPtr) GetProcAddress (hShlwapiDll, "SHDeleteKeyW"); - SHStrDupWFn = (SHStrDupWPtr) GetProcAddress (hShlwapiDll, "SHStrDupW"); - UrlUnescapeWFn = (UrlUnescapeWPtr) GetProcAddress(hShlwapiDll, "UrlUnescapeW"); - IUnknown_QueryServicePtr = (IUnknown_QueryServiceFn) GetProcAddress(hShlwapiDll, "IUnknown_QueryService"); - if (!IUnknown_QueryServicePtr) - IUnknown_QueryServicePtr = (IUnknown_QueryServiceFn) GetProcAddress(hShlwapiDll, MAKEINTRESOURCEA(176)); - if (!SHDeleteKeyWFn || !SHStrDupWFn || !UrlUnescapeWFn || !IUnknown_QueryServicePtr) - AbortProcess ("INIT_DLL"); - - if (IsOSAtLeast (WIN_VISTA)) - { - /* Get ChangeWindowMessageFilter used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */ - ChangeWindowMessageFilterFn = (ChangeWindowMessageFilterPtr) GetProcAddress (GetModuleHandle (L"user32.dll"), "ChangeWindowMessageFilter"); #ifndef SETUP - /* enable drag-n-drop when we are running elevated */ - AllowMessageInUIPI (WM_DROPFILES); - AllowMessageInUIPI (WM_COPYDATA); - AllowMessageInUIPI (WM_COPYGLOBALDATA); + /* enable drag-n-drop when we are running elevated */ + AllowMessageInUIPI (WM_DROPFILES); + AllowMessageInUIPI (WM_COPYDATA); + AllowMessageInUIPI (WM_COPYGLOBALDATA); #endif - } - - // Get CreateProcessWithTokenW function pointer - CreateProcessWithTokenWPtr = (CreateProcessWithTokenWFn) GetProcAddress(hAdvapi32Dll, "CreateProcessWithTokenW"); /* Save the instance handle for later */ hInst = hInstance; SetErrorMode (SetErrorMode (0) | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); #ifndef SETUP // Application ID - typedef HRESULT (WINAPI *SetAppId_t) (PCWSTR appID); - SetAppId_t setAppId = (SetAppId_t) GetProcAddress (GetModuleHandle (L"shell32.dll"), "SetCurrentProcessExplicitAppUserModelID"); - - if (setAppId) - setAppId (TC_APPLICATION_ID); + SetCurrentProcessExplicitAppUserModelID (TC_APPLICATION_ID); #endif // Language langId[0] = 0; SetPreferredLangId (ConfigReadString ("Language", "", langId, sizeof (langId))); #ifndef SETUP if (langId[0] == 0) { // check if user selected a language during installation WCHAR uiLang[6]; ReadRegistryString (L"Software\\VeraCrypt", L"SetupUILanguage", L"", uiLang, sizeof (uiLang)); if (0 < WideCharToMultiByte (CP_ACP, 0, uiLang, -1, langId, sizeof (langId), NULL, NULL)) { SetPreferredLangId (langId); bLanguageSetInSetup = TRUE; } } #ifndef VCEXPANDER // delete the registry key created by the installer (if any) DeleteRegistryKey (HKEY_CURRENT_USER, L"Software\\VeraCrypt"); #endif #endif if (langId[0] == 0) { if (IsNonInstallMode ()) { @@ -3918,246 +3700,143 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) // A new instance of the application must be created with elevated privileges. if (IsNonInstallMode () && !IsAdmin () && IsUacSupported ()) { if (wcsstr (lpszCommandLine, L"/q UAC ") == lpszCommandLine) { Error ("UAC_INIT_ERROR", NULL); exit (1); } if (LaunchElevatedProcess (NULL, modPath, lpszCommandLine)) exit (0); else exit (1); } #endif SetUnhandledExceptionFilter (ExceptionHandler); _set_invalid_parameter_handler (InvalidParameterHandler); RemoteSession = GetSystemMetrics (SM_REMOTESESSION) != 0; #ifndef VC_SKIP_OS_DRIVER_REQ_CHECK if (!IsSupportedOS()) { MessageBoxW (NULL, GetString ("UNSUPPORTED_OS"), lpszTitle, MB_ICONSTOP); exit (1); } #else - // in TESTSIGNING mode, we support only Windows Vista, Windows 7, Windows 8/8.1 - if ( !IsOSVersionAtLeast(WIN_VISTA, 0) + // in TESTSIGNING mode, we support only Windows 7 and Windows 8/8.1 + if ( #ifndef SETUP - || IsOSVersionAtLeast(WIN_10, 0) + IsOSVersionAtLeast(WIN_10, 0) #else || (IsOSVersionAtLeast(WIN_10, 0) && !bMakePackage) #endif ) { MessageBoxW (NULL, L"TESTSIGNING version of VeraCrypt targets only Windows Vista, Windows 7 and Windows 8/8.1.\n\nPlease use the standard version of VeraCrypt instead.", lpszTitle, MB_ICONSTOP); exit (1); } else if ( !IsTestSigningModeEnabled() #ifdef SETUP && !bMakePackage #endif ) { MessageBoxW (NULL, L"Test-Signing Mode, which is required to run VeraCrypt TESTSIGNING binaries, is not enabled in Windows.\n\nExecution aborted!", lpszTitle, MB_ICONSTOP); exit (1); } #endif - else - { - // Service pack check & warnings about critical MS issues - switch (nCurrentOS) - { - case WIN_XP: - if (CurrentOSServicePack < 1) - { - HKEY k; - // PE environment does not report version of SP - if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"System\\CurrentControlSet\\Control\\minint", 0, KEY_READ, &k) != ERROR_SUCCESS) - Warning ("LARGE_IDE_WARNING_XP", NULL); - else - RegCloseKey (k); - } - break; - } - } /* Get the attributes for the standard dialog class */ if ((GetClassInfoW (hInst, WINDOWS_DIALOG_CLASS, &wc)) == 0) { handleWin32Error (NULL, SRC_POS); AbortProcess ("INIT_REGISTER"); } #ifndef SETUP wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_TRUECRYPT_ICON)); #else #include "../setup/resource.h" wc.hIcon = LoadIcon (hInstance, MAKEINTRESOURCE (IDI_SETUP)); #endif wc.lpszClassName = TC_DLG_CLASS; wc.lpfnWndProc = &CustomDlgProc; wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.cbWndExtra = DLGWINDOWEXTRA; hDlgClass = RegisterClassW (&wc); if (hDlgClass == 0) { handleWin32Error (NULL, SRC_POS); AbortProcess ("INIT_REGISTER"); } wc.lpszClassName = TC_SPLASH_CLASS; wc.lpfnWndProc = &SplashDlgProc; wc.hCursor = LoadCursor (NULL, IDC_ARROW); wc.cbWndExtra = DLGWINDOWEXTRA; hSplashClass = RegisterClassW (&wc); if (hSplashClass == 0) { handleWin32Error (NULL, SRC_POS); AbortProcess ("INIT_REGISTER"); } // DPI and GUI aspect ratio DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_AUXILIARY_DLG), NULL, (DLGPROC) AuxiliaryDlgProc, (LPARAM) 1); InitHelpFileName (); #ifndef SETUP #ifdef _WIN64 - if (IsOSAtLeast (WIN_7)) + EnableRamEncryption ((ReadDriverConfigurationFlags() & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION) ? TRUE : FALSE); + if (IsRamEncryptionEnabled()) { - EnableRamEncryption ((ReadDriverConfigurationFlags() & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION) ? TRUE : FALSE); - if (IsRamEncryptionEnabled()) - { - if (!InitializeSecurityParameters(GetAppRandomSeed)) - AbortProcess("OUTOFMEMORY"); - } + if (!InitializeSecurityParameters(GetAppRandomSeed)) + AbortProcess("OUTOFMEMORY"); } #endif if (!EncryptionThreadPoolStart (ReadEncryptionThreadPoolFreeCpuCountLimit())) { handleWin32Error (NULL, SRC_POS); - FREE_DLL (hRichEditDll); - FREE_DLL (hComctl32Dll); - FREE_DLL (hSetupDll); - FREE_DLL (hShlwapiDll); - FREE_DLL (hProfApiDll); - FREE_DLL (hUsp10Dll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hUXThemeDll); - FREE_DLL (hUserenvDll); - FREE_DLL (hRsaenhDll); - FREE_DLL (himm32dll); - FREE_DLL (hMSCTFdll); - FREE_DLL (hfltlibdll); - FREE_DLL (hframedyndll); - FREE_DLL (hpsapidll); - FREE_DLL (hsecur32dll); - FREE_DLL (hnetapi32dll); - FREE_DLL (hauthzdll); - FREE_DLL (hxmllitedll); - FREE_DLL (hmprdll); - FREE_DLL (hsppdll); - FREE_DLL (vssapidll); - FREE_DLL (hvsstracedll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hcfgmgr32dll); - FREE_DLL (hdevobjdll); - FREE_DLL (hpowrprofdll); - FREE_DLL (hsspiclidll); - FREE_DLL (hcryptbasedll); - FREE_DLL (hdwmapidll); - FREE_DLL (hmsasn1dll); - FREE_DLL (hcrypt32dll); - FREE_DLL (hbcryptdll); - FREE_DLL (hbcryptprimitivesdll); - FREE_DLL (hMsls31); - FREE_DLL (hntmartadll); - FREE_DLL (hwinscarddll); - FREE_DLL (hmsvcrtdll); - FREE_DLL (hAdvapi32Dll); exit (1); } #endif } -void FinalizeApp (void) -{ - FREE_DLL (hRichEditDll); - FREE_DLL (hComctl32Dll); - FREE_DLL (hSetupDll); - FREE_DLL (hShlwapiDll); - FREE_DLL (hProfApiDll); - FREE_DLL (hUsp10Dll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hUXThemeDll); - FREE_DLL (hUserenvDll); - FREE_DLL (hRsaenhDll); - FREE_DLL (himm32dll); - FREE_DLL (hMSCTFdll); - FREE_DLL (hfltlibdll); - FREE_DLL (hframedyndll); - FREE_DLL (hpsapidll); - FREE_DLL (hsecur32dll); - FREE_DLL (hnetapi32dll); - FREE_DLL (hauthzdll); - FREE_DLL (hxmllitedll); - FREE_DLL (hmprdll); - FREE_DLL (hsppdll); - FREE_DLL (vssapidll); - FREE_DLL (hvsstracedll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hcfgmgr32dll); - FREE_DLL (hdevobjdll); - FREE_DLL (hpowrprofdll); - FREE_DLL (hsspiclidll); - FREE_DLL (hcryptbasedll); - FREE_DLL (hdwmapidll); - FREE_DLL (hmsasn1dll); - FREE_DLL (hcrypt32dll); - FREE_DLL (hbcryptdll); - FREE_DLL (hbcryptprimitivesdll); - FREE_DLL (hMsls31); - FREE_DLL (hntmartadll); - FREE_DLL (hwinscarddll); - FREE_DLL (hmsvcrtdll); - FREE_DLL (hAdvapi32Dll); -} - void InitHelpFileName (void) { wchar_t *lpszTmp; GetModuleFileNameW (NULL, szHelpFile, ARRAYSIZE (szHelpFile)); lpszTmp = wcsrchr (szHelpFile, L'\\'); if (lpszTmp) { wchar_t szTemp[TC_MAX_PATH]; ++lpszTmp; *lpszTmp = 0; // add null terminating character to prepare for append operations // Primary file name if (strcmp (GetPreferredLangId(), "en") == 0 || strlen(GetPreferredLangId()) == 0) { StringCbCatW (szHelpFile, sizeof(szHelpFile), L"docs\\VeraCrypt User Guide.chm"); } else { StringCbPrintfW (szTemp, sizeof(szTemp), L"docs\\VeraCrypt User Guide.%S.chm", GetPreferredLangId()); StringCbCatW (szHelpFile, sizeof(szHelpFile), szTemp); } // Secondary file name (used when localized documentation is not found). GetModuleFileNameW (NULL, szHelpFile2, ARRAYSIZE (szHelpFile2)); lpszTmp = wcsrchr (szHelpFile2, L'\\'); if (lpszTmp) { @@ -4239,78 +3918,75 @@ BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize) DWORD fileSystemFlags; wchar_t root[] = { L'A' + (wchar_t) driveNo, L':', L'\\', 0 }; return GetVolumeInformationW (root, label, labelSize / 2, NULL, NULL, &fileSystemFlags, NULL, 0); } #ifndef SETUP /* 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 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 executions complete very fast. Returns TRUE if successful (otherwise FALSE). */ BOOL GetSysDevicePaths (HWND hwndDlg) { if (!bCachedSysDevicePathsValid || 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()); } - if (IsOSAtLeast (WIN_7)) + // Find extra boot partition + foreach (const HostDevice &drive, GetAvailableHostDevices (false, false)) { - // Find extra boot partition - foreach (const HostDevice &drive, GetAvailableHostDevices (false, false)) + if (drive.ContainsSystem) { - if (drive.ContainsSystem) + foreach (const HostDevice &sysDrivePartition, drive.Partitions) { - foreach (const HostDevice &sysDrivePartition, drive.Partitions) + if (sysDrivePartition.Bootable) { - if (sysDrivePartition.Bootable) - { - if (sysDrivePartition.Size <= TC_MAX_EXTRA_BOOT_PARTITION_SIZE) - ExtraBootPartitionDevicePath = sysDrivePartition.Path; - break; - } + if (sysDrivePartition.Size <= TC_MAX_EXTRA_BOOT_PARTITION_SIZE) + ExtraBootPartitionDevicePath = sysDrivePartition.Path; + break; } - break; } + break; } } bCachedSysDevicePathsValid = 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. 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 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. 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) 3 - it is the extra boot partition path 0 - it's not the system partition/drive path -1 - the result can't be determined, isn't reliable, or there was an error. */ @@ -4462,103 +4138,143 @@ struct _TEXT_EDIT_DIALOG_PARAM { _TEXT_EDIT_DIALOG_PARAM (const _TEXT_EDIT_DIALOG_PARAM& other) : ReadOnly (other.ReadOnly), Text (other.Text), Title (other.Title) {} _TEXT_EDIT_DIALOG_PARAM(BOOL _readOnly, const WCHAR* title, std::string& _text) : ReadOnly(_readOnly), Text(_text), Title(title) {} _TEXT_EDIT_DIALOG_PARAM& operator=( const _TEXT_EDIT_DIALOG_PARAM& other) { if (this != &other) { ReadOnly = other.ReadOnly; Text = other.Text; Title = other.Title; } return *this; } }; typedef struct _TEXT_EDIT_DIALOG_PARAM TEXT_INFO_DIALOG_PARAM,*TEXT_INFO_DIALOG_PARAM_PTR; INT_PTR TextEditDialogBox (BOOL readOnly, HWND parent, const WCHAR* Title, std::string& text) { TEXT_INFO_DIALOG_PARAM pm(readOnly, Title, text); return DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TEXT_EDIT_DLG), parent, (DLGPROC) TextEditDlgProc, (LPARAM) &pm); } BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); static int nID = 0; static TEXT_INFO_DIALOG_PARAM_PTR prm; switch (msg) { case WM_INITDIALOG: { prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam; + LocalizeDialog (hwndDlg, NULL); // increase size limit of rich edit control SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1); SetWindowTextW (hwndDlg, prm->Title); // Left margin for rich edit text field SendMessage (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4)); if (prm->ReadOnly) { // switch rich edit control to ReadOnly - SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), ES_READONLY, TRUE, 0); + SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETREADONLY , TRUE, 0); // hide cancel button - ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_HIDE); + HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL); + ShowWindow(hwndCancel, SW_HIDE); + + // Reposition OK button to Cancel button's position + HWND hwndOK = GetDlgItem(hwndDlg, IDOK); + if (hwndOK && hwndCancel) + { + // Get Cancel button's position in screen coordinates + RECT rectCancel; + if (GetWindowRect(hwndCancel, &rectCancel)) + { + // Convert Cancel button's position to dialog's client coordinates + POINT ptCancel = { rectCancel.left, rectCancel.top }; + ScreenToClient(hwndDlg, &ptCancel); + + // Get OK button's current size + RECT rectOK; + if (GetWindowRect(hwndOK, &rectOK)) + { + int width = rectOK.right - rectOK.left; + int height = rectOK.bottom - rectOK.top; + + // Move OK button to Cancel button's position + SetWindowPos( + hwndOK, + NULL, + ptCancel.x, + ptCancel.y, + width, + height, + SWP_NOZORDER | SWP_NOACTIVATE + ); + } + } + } } SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0); } return 0; case WM_COMMAND: if (lw == IDOK ) { if (!prm->ReadOnly) { - prm->Text.resize(GetWindowTextLengthA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT)) + 1); - GetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), &(prm->Text)[0], (int) prm->Text.size()); + // read content of the text box as UTF16 and then convert it to UTF8 + HWND hEdit = GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT); + int size = GetWindowTextLengthW(hEdit); + std::vector<WCHAR> buffer(size + 1); + GetWindowTextW(hEdit, buffer.data(), size + 1); + prm->Text = WideToUtf8String(buffer.data()); } NormalCursor (); EndDialog (hwndDlg, IDOK); return 1; } if (lw == IDCANCEL ) { NormalCursor (); EndDialog (hwndDlg, IDCANCEL); return 1; } return 0; case TC_APPMSG_LOAD_TEXT_BOX_CONTENT: { - SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), prm->Text.c_str()); + // convert prm->Text to UTF16 using Utf8StringToWide + SetWindowTextW(GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT), Utf8StringToWide(prm->Text).c_str()); } return 0; case WM_CLOSE: NormalCursor (); EndDialog (hwndDlg, 0); return 1; } return 0; } INT_PTR TextInfoDialogBox (int nID) { return DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TEXT_INFO_DIALOG_BOX_DLG), MainDlg, (DLGPROC) TextInfoDialogBoxDlgProc, (LPARAM) nID); } BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); static int nID = 0; switch (msg) { case WM_INITDIALOG: { nID = (int) lParam; // increase size limit of rich edit control SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1); @@ -5419,300 +5135,367 @@ load: CloseHandle (hDriver); hDriver = INVALID_HANDLE_VALUE; return ERR_DRIVER_VERSION; } } #else if (!bResult) DriverVersion = 0; #endif } return 0; } void ResetCurrentDirectory () { wchar_t p[MAX_PATH]; if (!IsNonInstallMode () && SHGetFolderPath (NULL, CSIDL_PROFILE, NULL, 0, p) == ERROR_SUCCESS) { SetCurrentDirectory (p); } else { GetModPath (p, ARRAYSIZE (p)); SetCurrentDirectory (p); } } -BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter) +BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode) { - return BrowseFilesInDir (hwndDlg, stringId, NULL, lpszFileName, keepHistory, saveMode, browseFilter); + return BrowseFilesInDir (hwndDlg, stringId, NULL, lpszFileName, keepHistory, saveMode, NULL); } - -BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName, const wchar_t *defaultExtension) +BOOL BrowseFilesInDir(HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName, const wchar_t *defaultExtension) { - OPENFILENAMEW ofn; - wchar_t file[TC_MAX_PATH] = { 0 }; + IFileDialog *pfd = NULL; + HRESULT hr; wchar_t filter[1024]; BOOL status = FALSE; - CoInitialize (NULL); - - ZeroMemory (&ofn, sizeof (ofn)); - *lpszFileName = 0; - - if (initialDir) + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (FAILED(hr)) { - ofn.lpstrInitialDir = initialDir; + return FALSE; } - if (initialFileName) - StringCchCopyW (file, array_capacity (file), initialFileName); - - ofn.lStructSize = sizeof (ofn); - ofn.hwndOwner = hwndDlg; - - StringCbPrintfW (filter, sizeof(filter), L"%ls (*.*)%c*.*%c%ls (*.hc)%c*.hc%c%c", - GetString ("ALL_FILES"), 0, 0, GetString ("TC_VOLUMES"), 0, 0, 0); - ofn.lpstrFilter = browseFilter ? browseFilter : filter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = file; - ofn.nMaxFile = sizeof (file) / sizeof (file[0]); - ofn.lpstrTitle = GetString (stringId); - ofn.lpstrDefExt = defaultExtension; - ofn.Flags = OFN_HIDEREADONLY - | OFN_PATHMUSTEXIST - | (keepHistory ? 0 : OFN_DONTADDTORECENT) - | (saveMode ? OFN_OVERWRITEPROMPT : 0); - - if (!keepHistory) - CleanLastVisitedMRU (); - - SystemFileSelectorCallerThreadId = GetCurrentThreadId(); - SystemFileSelectorCallPending = TRUE; - - if (!saveMode) + // Choose between the File Open or File Save dialog depending on the saveMode. + if (saveMode) { - if (!GetOpenFileNameW (&ofn)) - goto ret; + hr = CoCreateInstance(CLSID_FileSaveDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)); } else { - if (!GetSaveFileNameW (&ofn)) - goto ret; + hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)); } - SystemFileSelectorCallPending = FALSE; + if (SUCCEEDED(hr)) + { + // Set the options for the dialog. + DWORD dwFlags; + hr = pfd->GetOptions(&dwFlags); + if (SUCCEEDED(hr)) + { + dwFlags |= FOS_NOCHANGEDIR | FOS_FILEMUSTEXIST | FOS_PATHMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_NOVALIDATE; + if (!keepHistory) + dwFlags |= FOS_DONTADDTORECENT; + if (saveMode) + dwFlags |= FOS_NOTESTFILECREATE | FOS_OVERWRITEPROMPT | FOS_DEFAULTNOMINIMODE; + hr = pfd->SetOptions(dwFlags); + } - StringCchCopyW (lpszFileName, MAX_PATH, file); + // Set the initial directory, if provided. + if (initialDir) + { + IShellItem *psi; + hr = SHCreateItemFromParsingName(initialDir, NULL, IID_PPV_ARGS(&psi)); + if (SUCCEEDED(hr)) + { + pfd->SetFolder(psi); + psi->Release(); + } + } - if (!keepHistory) - CleanLastVisitedMRU (); + // Set the initial file name, if provided. + if (initialFileName) + { + pfd->SetFileName(initialFileName); + } - status = TRUE; + // Set the title. + pfd->SetTitle(GetString(stringId)); -ret: - SystemFileSelectorCallPending = FALSE; - ResetCurrentDirectory(); - CoUninitialize(); + // Set the default extension. + if (defaultExtension) + { + pfd->SetDefaultExtension(defaultExtension); + } - return status; -} + // Prepare the filter + COMDLG_FILTERSPEC filterSpec[5]; + UINT cfilterSpec = 0; + if (!browseFilter) + { + StringCbPrintfW(filter, sizeof(filter), L"%ls (*.*)%c*.*%c%ls (*.hc)%c*.hc%c%c", + GetString("ALL_FILES"), 0, 0, GetString("TC_VOLUMES"), 0, 0, 0); + browseFilter = filter; + } -static wchar_t SelectMultipleFilesPath[131072]; -static int SelectMultipleFilesOffset; + // Assume browseFilter is a formatted wide string like L"Text Files (*.txt)\0*.txt\0" + // loop over all the filters in the string and add them to filterSpec array + while (*browseFilter) + { + filterSpec[cfilterSpec].pszName = browseFilter; + browseFilter += wcslen(browseFilter) + 1; + filterSpec[cfilterSpec].pszSpec = browseFilter; + browseFilter += wcslen(browseFilter) + 1; + cfilterSpec++; -BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName,BOOL keepHistory) -{ - OPENFILENAMEW ofn; - wchar_t filter[1024]; - BOOL status = FALSE; + if (cfilterSpec >= ARRAYSIZE(filterSpec)) + break; + } - CoInitialize (NULL); - - ZeroMemory (&ofn, sizeof (ofn)); - - SelectMultipleFilesPath[0] = 0; - *lpszFileName = 0; - ofn.lStructSize = sizeof (ofn); - ofn.hwndOwner = hwndDlg; - StringCbPrintfW (filter, sizeof(filter), L"%ls (*.*)%c*.*%c%ls (*.hc)%c*.hc%c%c", - GetString ("ALL_FILES"), 0, 0, GetString ("TC_VOLUMES"), 0, 0, 0); - ofn.lpstrFilter = filter; - ofn.nFilterIndex = 1; - ofn.lpstrFile = SelectMultipleFilesPath; - ofn.nMaxFile = 0xffff * 2; // The size must not exceed 0xffff*2 due to a bug in Windows 2000 and XP SP1 - ofn.lpstrTitle = GetString (stringId); - ofn.Flags = OFN_HIDEREADONLY - | OFN_EXPLORER - | OFN_PATHMUSTEXIST - | OFN_ALLOWMULTISELECT - | (keepHistory ? 0 : OFN_DONTADDTORECENT); - - if (!keepHistory) - CleanLastVisitedMRU (); + // Set the file types filter. + hr = pfd->SetFileTypes(cfilterSpec, filterSpec); + hr = pfd->SetFileTypeIndex(1); - SystemFileSelectorCallerThreadId = GetCurrentThreadId(); - SystemFileSelectorCallPending = TRUE; + if (!keepHistory) + CleanLastVisitedMRU(); - if (!GetOpenFileNameW (&ofn)) - goto ret; + SystemFileSelectorCallerThreadId = GetCurrentThreadId(); + SystemFileSelectorCallPending = TRUE; - SystemFileSelectorCallPending = FALSE; + // Show the dialog. + hr = pfd->Show(hwndDlg); - if (SelectMultipleFilesPath[ofn.nFileOffset - 1] != 0) - { - // Single file selected - StringCbCopyW (lpszFileName, cbFileName, SelectMultipleFilesPath); - SelectMultipleFilesOffset = 0; - SecureZeroMemory (SelectMultipleFilesPath, sizeof (SelectMultipleFilesPath)); - } - else - { - // Multiple files selected - SelectMultipleFilesOffset = ofn.nFileOffset; - SelectMultipleFilesNext (lpszFileName, cbFileName); - } + // Obtain the result if the user clicked the "OK" button. + if (SUCCEEDED(hr)) + { + IShellItem *pItem; + hr = pfd->GetResult(&pItem); + if (SUCCEEDED(hr)) + { + PWSTR pszFilePath; + hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath); + if (SUCCEEDED(hr)) + { + StringCchCopyW(lpszFileName, MAX_PATH, pszFilePath); + CoTaskMemFree(pszFilePath); + status = TRUE; + } + pItem->Release(); + } + } - if (!keepHistory) - CleanLastVisitedMRU (); + pfd->Release(); + + if (!keepHistory) + CleanLastVisitedMRU(); + } - status = TRUE; - -ret: SystemFileSelectorCallPending = FALSE; ResetCurrentDirectory(); CoUninitialize(); return status; } - -BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName) +BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, std::vector<std::wstring> &filesList) { - if (SelectMultipleFilesOffset == 0) + IFileOpenDialog *pfd = NULL; + HRESULT hr; + BOOL status = FALSE; + + filesList.clear(); + + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (FAILED(hr)) + { return FALSE; + } - StringCbCopyW (lpszFileName, cbFileName,SelectMultipleFilesPath); - lpszFileName[TC_MAX_PATH - 1] = 0; + // Create the File Open Dialog object. + hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)); + if (SUCCEEDED(hr)) + { + DWORD dwFlags; + hr = pfd->GetOptions(&dwFlags); + if (SUCCEEDED(hr)) + { + dwFlags |= FOS_ALLOWMULTISELECT | FOS_NOCHANGEDIR | FOS_FILEMUSTEXIST | FOS_PATHMUSTEXIST | FOS_FORCEFILESYSTEM | FOS_NOVALIDATE; + if (!keepHistory) + dwFlags |= FOS_DONTADDTORECENT; - if (lpszFileName[wcslen (lpszFileName) - 1] != L'\\') - StringCbCatW (lpszFileName, cbFileName,L"\\"); + hr = pfd->SetOptions(dwFlags); + } - StringCbCatW (lpszFileName, cbFileName,SelectMultipleFilesPath + SelectMultipleFilesOffset); + // Set the title and filter + pfd->SetTitle(GetString(stringId)); - SelectMultipleFilesOffset += (int) wcslen (SelectMultipleFilesPath + SelectMultipleFilesOffset) + 1; - if (SelectMultipleFilesPath[SelectMultipleFilesOffset] == 0) - { - SelectMultipleFilesOffset = 0; - SecureZeroMemory (SelectMultipleFilesPath, sizeof (SelectMultipleFilesPath)); - } + wchar_t allFilesfilter[512]; + wchar_t volumesfilter[512]; - return TRUE; -} + StringCbPrintfW(allFilesfilter, sizeof(allFilesfilter), L"%ls (*.*)", GetString("ALL_FILES")); + StringCbPrintfW(volumesfilter, sizeof(volumesfilter), L"%ls (*.hc)", GetString("TC_VOLUMES")); + COMDLG_FILTERSPEC rgSpec[] = + { + {allFilesfilter, L"*.*"}, + {volumesfilter, L"*.hc"}}; + hr = pfd->SetFileTypes(ARRAYSIZE(rgSpec), rgSpec); -static int CALLBACK BrowseCallbackProc(HWND hwnd,UINT uMsg,LPARAM lp, LPARAM pData) -{ - switch(uMsg) { - case BFFM_INITIALIZED: - { - /* WParam is TRUE since we are passing a path. - It would be FALSE if we were passing a pidl. */ - SendMessageW (hwnd,BFFM_SETSELECTION,TRUE,(LPARAM)pData); - break; - } + if (!keepHistory) + CleanLastVisitedMRU(); - case BFFM_SELCHANGED: - { - wchar_t szDir[TC_MAX_PATH]; + // Show the dialog + hr = pfd->Show(hwndDlg); + if (SUCCEEDED(hr)) + { + IShellItemArray *psiaResults; + hr = pfd->GetResults(&psiaResults); + if (SUCCEEDED(hr)) + { + DWORD count; + hr = psiaResults->GetCount(&count); + if (SUCCEEDED(hr)) + { + for (DWORD i = 0; i < count; ++i) + { + IShellItem *psi; + hr = psiaResults->GetItemAt(i, &psi); + if (SUCCEEDED(hr)) + { + PWSTR pszFilePath; + hr = psi->GetDisplayName(SIGDN_FILESYSPATH, &pszFilePath); + if (SUCCEEDED(hr)) + { + filesList.push_back(pszFilePath); + CoTaskMemFree(pszFilePath); + } + psi->Release(); + } + } - /* Set the status window to the currently selected path. */ - if (SHGetPathFromIDList((LPITEMIDLIST) lp ,szDir)) - { - SendMessage (hwnd,BFFM_SETSTATUSTEXT,0,(LPARAM)szDir); - } - break; - } + status = TRUE; + } + psiaResults->Release(); + } + } - default: - break; + if (!keepHistory) + CleanLastVisitedMRU(); + + pfd->Release(); } - return 0; + CoUninitialize(); + return status; } - -BOOL BrowseDirectories (HWND hwndDlg, char *lpszTitle, wchar_t *dirName) +BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wchar_t *initialDir) { - BROWSEINFOW bi; - LPITEMIDLIST pidl; - LPMALLOC pMalloc; - BOOL bOK = FALSE; + IFileDialog *pfd = NULL; + HRESULT hr; + BOOL bOK = FALSE; - CoInitialize (NULL); + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (FAILED(hr)) + { + return FALSE; + } - if (SUCCEEDED (SHGetMalloc (&pMalloc))) + hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&pfd)); + if (SUCCEEDED(hr)) { - ZeroMemory (&bi, sizeof(bi)); - bi.hwndOwner = hwndDlg; - bi.pszDisplayName = 0; - bi.lpszTitle = GetString (lpszTitle); - bi.pidlRoot = 0; - bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT; - bi.lpfn = BrowseCallbackProc; - bi.lParam = (LPARAM)dirName; + // Set the options on the dialog. + DWORD dwFlags; + hr = pfd->GetOptions(&dwFlags); + if (SUCCEEDED(hr)) + { + dwFlags |= FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_NOCHANGEDIR; // Important to enable folder-picking mode + hr = pfd->SetOptions(dwFlags); + } + + // Set the title. + if (lpszTitle) + { + pfd->SetTitle(GetString(lpszTitle)); + } - pidl = SHBrowseForFolderW (&bi); - if (pidl != NULL) + IShellItem *psi; + if (initialDir) + { + // Set the initial directory, if provided. + hr = SHCreateItemFromParsingName(initialDir, NULL, IID_PPV_ARGS(&psi)); + } + else { - if (SHGetPathFromIDList(pidl, dirName)) + // set folder to "This PC" shel item + hr = SHCreateItemInKnownFolder(FOLDERID_ComputerFolder, 0, NULL, IID_PPV_ARGS(&psi)); + } + if (SUCCEEDED(hr)) + { + pfd->SetFolder(psi); + psi->Release(); + } + + // Show the dialog. + hr = pfd->Show(hwndDlg); + if (SUCCEEDED(hr)) + { + // Obtain the result when the user clicks the "OK" button. + // The result is an IShellItem object. + IShellItem *pItem; + hr = pfd->GetResult(&pItem); + if (SUCCEEDED(hr)) { - bOK = TRUE; + PWSTR pszFolderPath; + hr = pItem->GetDisplayName(SIGDN_FILESYSPATH, &pszFolderPath); + if (SUCCEEDED(hr)) + { + StringCchCopyW(dirName, MAX_PATH, pszFolderPath); + CoTaskMemFree(pszFolderPath); + bOK = TRUE; + } + pItem->Release(); } - - pMalloc->Free (pidl); - pMalloc->Release(); } + pfd->Release(); } CoUninitialize(); - return bOK; } - std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg) { WCHAR szTmp[8192]; StringCbPrintfW (szTmp, sizeof(szTmp), GetString (KeyFilesEnable ? "PASSWORD_OR_KEYFILE_WRONG" : "PASSWORD_WRONG")); if (CheckCapsLock (hwndDlg, TRUE)) StringCbCatW (szTmp, sizeof(szTmp), GetString ("PASSWORD_WRONG_CAPSLOCK_ON")); #ifdef TCMOUNT wchar_t szDevicePath [TC_MAX_PATH+1] = {0}; GetWindowText (GetDlgItem (MainDlg, IDC_VOLUME), szDevicePath, ARRAYSIZE (szDevicePath)); if (TCBootLoaderOnInactiveSysEncDrive (szDevicePath)) { StringCbPrintfW (szTmp, sizeof(szTmp), GetString (KeyFilesEnable ? "PASSWORD_OR_KEYFILE_OR_MODE_WRONG" : "PASSWORD_OR_MODE_WRONG")); if (CheckCapsLock (hwndDlg, TRUE)) StringCbCatW (szTmp, sizeof(szTmp), GetString ("PASSWORD_WRONG_CAPSLOCK_ON")); StringCbCatW (szTmp, sizeof(szTmp), GetString ("SYSENC_MOUNT_WITHOUT_PBA_NOTE")); } #endif wstring msg = szTmp; #ifdef TCMOUNT if (KeyFilesEnable && HiddenFilesPresentInKeyfilePath) { msg += GetString ("HIDDEN_FILES_PRESENT_IN_KEYFILE_PATH"); HiddenFilesPresentInKeyfilePath = FALSE; @@ -5807,60 +5590,68 @@ void handleError (HWND hwndDlg, int code, const char* srcPos) case ERR_NONSYS_INPLACE_ENC_INCOMPLETE: Error ("ERR_NONSYS_INPLACE_ENC_INCOMPLETE", hwndDlg); break; case ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG: Error ("ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG", hwndDlg); break; case ERR_PARAMETER_INCORRECT: Error ("ERR_PARAMETER_INCORRECT", hwndDlg); break; case ERR_USER_ABORT: case ERR_DONT_REPORT: // A non-error break; #ifndef SETUP case ERR_RAND_INIT_FAILED: StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("INIT_RAND"), SRC_POS, GetLastError ()); MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, MB_ICONERROR); break; case ERR_CAPI_INIT_FAILED: StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CAPI_RAND"), SRC_POS, CryptoAPILastError); MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, MB_ICONERROR); break; #endif + case ERR_XTS_MASTERKEY_VULNERABLE: + MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_XTS_MASTERKEY_VULNERABLE"), srcPos).c_str(), lpszTitle, ICON_HAND); + break; + + case ERR_SYSENC_XTS_MASTERKEY_VULNERABLE: + MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_SYSENC_XTS_MASTERKEY_VULNERABLE"), srcPos).c_str(), lpszTitle, ICON_HAND); + break; + default: StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("ERR_UNKNOWN"), code); MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, ICON_HAND); } } BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName) { if (ferror (file)) { wchar_t s[TC_MAX_PATH]; StringCbPrintfW (s, sizeof (s), GetString ("CANNOT_WRITE_FILE_X"), fileName); ErrorDirect (s, hwndDlg); return FALSE; } return TRUE; } static BOOL CALLBACK LocalizeDialogEnum( HWND hwnd, LPARAM font) { // Localization of controls if (LocalizationActive) { int ctrlId = GetDlgCtrlID (hwnd); if (ctrlId != 0) @@ -6026,78 +5817,78 @@ wstring GetUserFriendlyVersionString (int version) versionString.insert (version > 0xfff ? 2 : 1,L"."); return (versionString); } wstring IntToWideString (int val) { wchar_t szTmp [64]; StringCbPrintfW (szTmp, sizeof(szTmp), L"%d", val); return szTmp; } wstring ArrayToHexWideString (const unsigned char* pbData, int cbData) { static wchar_t* hexChar = L"0123456789ABCDEF"; wstring result; if (pbData) { for (int i = 0; i < cbData; i++) { result += hexChar[pbData[i] >> 4]; result += hexChar[pbData[i] & 0x0F]; } } return result; } -bool HexToByte (wchar_t c, byte& b) +bool HexToByte (wchar_t c, uint8& b) { bool bRet = true; if (c >= L'0' && c <= L'9') - b = (byte) (c - L'0'); + b = (uint8) (c - L'0'); else if (c >= L'a' && c <= L'z') - b = (byte) (c - L'a' + 10); + b = (uint8) (c - L'a' + 10); else if (c >= L'A' && c <= L'Z') - b = (byte) (c - L'A' + 10); + b = (uint8) (c - L'A' + 10); else bRet = false; return bRet; } -bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr) +bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr) { - byte b1, b2; + uint8 b1, b2; size_t i, len = wcslen (hexStr); arr.clear(); if (len %2) return false; for (i = 0; i < len/2; i++) { if (!HexToByte (*hexStr++, b1) || !HexToByte (*hexStr++, b2)) return false; arr.push_back (b1 << 4 | b2); } return true; } wstring GetTempPathString () { wchar_t tempPath[MAX_PATH]; DWORD tempLen = ::GetTempPath (ARRAYSIZE (tempPath), tempPath); if (tempLen == 0 || tempLen > ARRAYSIZE (tempPath)) throw ParameterIncorrect (SRC_POS); return wstring (tempPath); } void GetSizeString (unsigned __int64 size, wchar_t *str, size_t cbStr) { static wchar_t *b, *kb, *mb, *gb, *tb, *pb; static int serNo; @@ -6373,174 +6164,178 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) if (ci) crypto_close (ci); MessageBoxW (hwndDlg, GetString ("ERR_PERF_COUNTER"), lpszTitle, ICON_HAND); return FALSE; } if (benchmarkType != BENCHMARK_TYPE_PRF) { lpTestBuffer = (BYTE *) _aligned_malloc(benchmarkBufferSize - (benchmarkBufferSize % 16), 16); if (lpTestBuffer == NULL) { if (ci) crypto_close (ci); MessageBoxW (hwndDlg, GetString ("ERR_MEM_ALLOC"), lpszTitle, ICON_HAND); return FALSE; } VirtualLock (lpTestBuffer, benchmarkBufferSize - (benchmarkBufferSize % 16)); } WaitCursor (); benchmarkTotalItems = 0; switch(benchmarkType) { case BENCHMARK_TYPE_HASH: /* Measures the speed at which each of the hash algorithms processes the message to produce a single digest. */ { BYTE digest [MAX_DIGESTSIZE]; - WHIRLPOOL_CTX wctx; - blake2s_state bctx; + #ifndef WOLFCRYPT_BACKEND + WHIRLPOOL_CTX wctx; + STREEBOG_CTX stctx; + blake2s_state bctx; + #endif sha512_ctx s2ctx; sha256_ctx s256ctx; - STREEBOG_CTX stctx; int hid, i; for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++) { if (QueryPerformanceCounter (&performanceCountStart) == 0) goto counter_error; for (i = 1; i <= 2; i++) { switch (hid) { case SHA512: sha512_begin (&s2ctx); sha512_hash (lpTestBuffer, benchmarkBufferSize, &s2ctx); sha512_end ((unsigned char *) digest, &s2ctx); break; case SHA256: sha256_begin (&s256ctx); sha256_hash (lpTestBuffer, benchmarkBufferSize, &s256ctx); sha256_end ((unsigned char *) digest, &s256ctx); break; - + #ifndef WOLFCRYPT_BACKEND case BLAKE2S: blake2s_init(&bctx); blake2s_update(&bctx, lpTestBuffer, benchmarkBufferSize); blake2s_final(&bctx, (unsigned char *) digest); break; case WHIRLPOOL: WHIRLPOOL_init (&wctx); WHIRLPOOL_add (lpTestBuffer, benchmarkBufferSize, &wctx); WHIRLPOOL_finalize (&wctx, (unsigned char *) digest); break; case STREEBOG: STREEBOG_init(&stctx); STREEBOG_add(&stctx, lpTestBuffer, benchmarkBufferSize); STREEBOG_finalize(&stctx, (unsigned char *)digest); break; } - } + #endif + } if (QueryPerformanceCounter (&performanceCountEnd) == 0) goto counter_error; benchmarkTable[benchmarkTotalItems].encSpeed = performanceCountEnd.QuadPart - performanceCountStart.QuadPart; benchmarkTable[benchmarkTotalItems].decSpeed = benchmarkTable[benchmarkTotalItems].encSpeed; benchmarkTable[benchmarkTotalItems].id = hid; benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (unsigned __int64) (benchmarkBufferSize / ((float) benchmarkTable[benchmarkTotalItems].encSpeed / benchmarkPerformanceFrequency.QuadPart / 2)); StringCbPrintfW (benchmarkTable[benchmarkTotalItems].name, sizeof(benchmarkTable[benchmarkTotalItems].name),L"%s", HashGetName(hid)); benchmarkTotalItems++; } } break; case BENCHMARK_TYPE_PRF: /* Measures the time that it takes for the PKCS-5 routine to derive a header key using each of the implemented PRF algorithms. */ { 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++) { if (benchmarkPreBoot && !benchmarkGPT && !HashForSystemEncryption (thid)) continue; if (QueryPerformanceCounter (&performanceCountStart) == 0) goto counter_error; for (i = 1; i <= 2; i++) { switch (thid) { case SHA512: /* PKCS-5 test with HMAC-SHA-512 used as the PRF */ derive_key_sha512 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; case SHA256: /* PKCS-5 test with HMAC-SHA-256 used as the PRF */ derive_key_sha256 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; - + #ifndef WOLFCRYPT_BACKEND case BLAKE2S: /* PKCS-5 test with HMAC-BLAKE2s used as the PRF */ derive_key_blake2s ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; case WHIRLPOOL: /* PKCS-5 test with HMAC-Whirlpool used as the PRF */ derive_key_whirlpool ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; case STREEBOG: /* PKCS-5 test with HMAC-STREEBOG used as the PRF */ derive_key_streebog("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; } - } + #endif + } if (QueryPerformanceCounter (&performanceCountEnd) == 0) goto counter_error; benchmarkTable[benchmarkTotalItems].encSpeed = performanceCountEnd.QuadPart - performanceCountStart.QuadPart; benchmarkTable[benchmarkTotalItems].id = thid; benchmarkTable[benchmarkTotalItems].decSpeed = get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot); benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (unsigned __int64) (1000 * ((float) benchmarkTable[benchmarkTotalItems].encSpeed / benchmarkPerformanceFrequency.QuadPart / 2)); if (benchmarkPreBoot) { /* heuristics for boot times */ if (benchmarkGPT) { benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 8) / 5; } else { if (thid == SHA256) { #ifdef _WIN64 benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 26); #else benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 24); #endif } else { #ifdef _WIN64 benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 21) / 5; #else @@ -7188,60 +6983,62 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP AddComboPair (hSizeUnit, GetString ("KB"), 1); AddComboPair (hSizeUnit, GetString ("MB"), 2); AddComboPair (hSizeUnit, GetString ("GB"), 3); // set default keyfiles size unit SendMessage (hSizeUnit, CB_SETCURSEL, 0, 0); SetCheckBox (hwndDlg, IDC_DISPLAY_POOL_CONTENTS, bDisplayPoolContents); hEntropyBar = GetDlgItem (hwndDlg, IDC_ENTROPY_BAR); SendMessage (hEntropyBar, PBM_SETRANGE32, 0, maxEntropyLevel); SendMessage (hEntropyBar, PBM_SETSTEP, 1, 0); SendMessage (hEntropyBar, PBM_SETSTATE, PBST_ERROR, 0); #ifndef VOLFORMAT if (Randinit ()) { handleError (hwndDlg, (CryptoAPILastError == ERROR_SUCCESS)? ERR_RAND_INIT_FAILED : ERR_CAPI_INIT_FAILED, SRC_POS); EndDialog (hwndDlg, IDCLOSE); } #endif SetTimer (hwndDlg, 0xfd, RANDPOOL_DISPLAY_REFRESH_INTERVAL, NULL); SendMessage (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), WM_SETFONT, (WPARAM) hFixedDigitFont, (LPARAM) TRUE); // 9-digit limit for the number of keyfiles (more than enough!) SendMessage (GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), EM_SETLIMITTEXT, (WPARAM) 9, 0); SetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), L"1"); // maximum keyfile size is 1048576, so limit the edit control to 7 characters SendMessage (GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), EM_SETLIMITTEXT, (WPARAM) 7, 0); SetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), L"64"); // set the maximum length of the keyfile base name to (TC_MAX_PATH - 1) SendMessage (GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), EM_SETLIMITTEXT, (WPARAM) (TC_MAX_PATH - 1), 0); + + ToHyperlink (hwndDlg, IDC_LINK_KEYFILES_EXTENSIONS_WARNING); return 1; } case WM_TIMER: { wchar_t tmp[4]; unsigned char tmpByte; int col, row; DWORD mouseEventsCounter; RandpeekBytes (hwndDlg, randPool, sizeof (randPool), &mouseEventsCounter); ProcessEntropyEstimate (hEntropyBar, &mouseEventsInitialCount, mouseEventsCounter, maxEntropyLevel, &mouseEntropyGathered); if (memcmp (lastRandPool, randPool, sizeof(lastRandPool)) != 0) { outputDispBuffer[0] = 0; for (row = 0; row < RANDPOOL_DISPLAY_ROWS; row++) { for (col = 0; col < RANDPOOL_DISPLAY_COLUMNS; col++) { if (bDisplayPoolContents) { tmpByte = randPool[row * RANDPOOL_DISPLAY_COLUMNS + col]; StringCbPrintfW (tmp, sizeof(tmp), bRandPoolDispAscii ? ((tmpByte >= 32 && tmpByte < 255 && tmpByte != L'&') ? L" %c " : L" . ") : L"%02X ", tmpByte); } else if (bUseMask) { /* use mask to compute a randomized ASCII representation */ @@ -7275,60 +7072,66 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP goto exit; } if (lw == IDC_PRF_ID && hw == CBN_SELCHANGE) { hid = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PRF_ID), CB_GETCURSEL, 0, 0); hash_algo = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PRF_ID), CB_GETITEMDATA, hid, 0); RandSetHashFunction (hash_algo); return 1; } if (lw == IDC_DISPLAY_POOL_CONTENTS) { if (!(bDisplayPoolContents = GetCheckBox (hwndDlg, IDC_DISPLAY_POOL_CONTENTS))) { wchar_t tmp[RNG_POOL_SIZE+1]; wmemset (tmp, L' ', ARRAYSIZE(tmp)); tmp [RNG_POOL_SIZE] = 0; SetWindowText (GetDlgItem (hwndDlg, IDC_POOL_CONTENTS), tmp); } return 1; } if (lw == IDC_KEYFILES_RANDOM_SIZE) { EnableWindow(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), !GetCheckBox (hwndDlg, IDC_KEYFILES_RANDOM_SIZE)); EnableWindow(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE_UNIT), !GetCheckBox (hwndDlg, IDC_KEYFILES_RANDOM_SIZE)); } + if (lw == IDC_LINK_KEYFILES_EXTENSIONS_WARNING) + { + Applink ("keyfilesextensions"); + return 1; + } + if (lw == IDC_GENERATE_AND_SAVE_KEYFILE) { wchar_t szNumber[16] = {0}; wchar_t szFileBaseName[TC_MAX_PATH]; wchar_t szDirName[TC_MAX_PATH]; wchar_t szFileName [2*TC_MAX_PATH + 16]; unsigned char *keyfile = NULL; int fhKeyfile = -1, status; long keyfilesCount = 0, i; unsigned long long keyfilesSize = 0, remainingBytes = 0; int selectedUnitIndex, selectedUnitFactor, loopIndex, rndBytesLength; DWORD dwLastError = 0; wchar_t* fileExtensionPtr = 0; wchar_t szSuffix[32]; BOOL bRandomSize = GetCheckBox (hwndDlg, IDC_KEYFILES_RANDOM_SIZE); if (!GetWindowText(GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), szNumber, ARRAYSIZE(szNumber))) szNumber[0] = 0; keyfilesCount = wcstoul(szNumber, NULL, 0); if (keyfilesCount <= 0 || keyfilesCount == LONG_MAX) { Warning("KEYFILE_INCORRECT_NUMBER", hwndDlg); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_NUMBER_KEYFILES), TRUE); return 1; } if (!bRandomSize) { if (!GetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), szNumber, ARRAYSIZE(szNumber))) @@ -7346,61 +7149,61 @@ BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LP if (keyfilesSize < 64) { Warning("KEYFILE_INCORRECT_SIZE", hwndDlg); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_SIZE), TRUE); return 1; } } if (!GetWindowText(GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), szFileBaseName, TC_MAX_PATH)) szFileBaseName[0] = 0; // Trim trailing space if (TrimWhiteSpace(szFileBaseName) == 0) { Warning("KEYFILE_EMPTY_BASE_NAME", hwndDlg); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE); return 1; } if (!IsValidFileName(szFileBaseName)) { Warning("KEYFILE_INVALID_BASE_NAME", hwndDlg); SendMessage(hwndDlg, WM_NEXTDLGCTL, (WPARAM) GetDlgItem (hwndDlg, IDC_KEYFILES_BASE_NAME), TRUE); return 1; } fileExtensionPtr = wcsrchr(szFileBaseName, L'.'); /* Select directory */ - if (!BrowseDirectories (hwndDlg, "SELECT_KEYFILE_GENERATION_DIRECTORY", szDirName)) + if (!BrowseDirectories (hwndDlg, "SELECT_KEYFILE_GENERATION_DIRECTORY", szDirName, NULL)) return 1; if (szDirName[wcslen(szDirName) - 1] != L'\\' && szDirName[wcslen(szDirName) - 1] != L'/') StringCbCat(szDirName, sizeof(szDirName), L"\\"); WaitCursor(); keyfile = (unsigned char*) TCalloc(KEYFILE_MAX_READ_LEN); for (i= 0; i < keyfilesCount; i++) { StringCbCopyW(szFileName, sizeof(szFileName), szDirName); if (i > 0) { StringCbPrintfW(szSuffix, sizeof(szSuffix), L"_%d", i); // Append the counter to the name if (fileExtensionPtr) { StringCchCatN(szFileName, ARRAYSIZE(szFileName), szFileBaseName, (size_t) (fileExtensionPtr - szFileBaseName)); StringCbCat(szFileName, sizeof(szFileName), szSuffix); StringCbCat(szFileName, sizeof(szFileName), fileExtensionPtr); } else { StringCbCat(szFileName, sizeof(szFileName), szFileBaseName); StringCbCat(szFileName, sizeof(szFileName), szSuffix); } } else @@ -8419,61 +8222,61 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced) && !Silent) { wchar_t msg[4096]; VolumeNotificationsList.bHidVolDamagePrevReported [nDosDriveNo] = TRUE; StringCbPrintfW (msg, sizeof(msg), GetString ("DAMAGE_TO_HIDDEN_VOLUME_PREVENTED"), nDosDriveNo + L'A'); SetForegroundWindow (hwndDlg); MessageBoxW (hwndDlg, msg, lpszTitle, MB_ICONWARNING | MB_SETFOREGROUND | MB_TOPMOST); } #endif // #ifdef TCMOUNT return unmount.nReturnCode; } void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap) { DEV_BROADCAST_VOLUME dbv; DWORD_PTR dwResult; LONG eventId = 0; int i; if (DeviceChangeBroadcastDisabled) return; if (message == DBT_DEVICEARRIVAL) eventId = SHCNE_DRIVEADD; else if (message == DBT_DEVICEREMOVECOMPLETE) eventId = SHCNE_DRIVEREMOVED; - else if (IsOSAtLeast (WIN_7) && message == DBT_DEVICEREMOVEPENDING) // Explorer on Windows 7 holds open handles of all drives when 'Computer' is expanded in navigation pane. SHCNE_DRIVEREMOVED must be used as DBT_DEVICEREMOVEPENDING is ignored. + else if (message == DBT_DEVICEREMOVEPENDING) // Explorer on Windows 7 holds open handles of all drives when 'Computer' is expanded in navigation pane. SHCNE_DRIVEREMOVED must be used as DBT_DEVICEREMOVEPENDING is ignored. eventId = SHCNE_DRIVEREMOVED; if (driveMap == 0) driveMap = (1 << nDosDriveNo); if (eventId != 0) { for (i = 0; i < 26; i++) { if (driveMap & (1 << i)) { wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 }; SHChangeNotify (eventId, SHCNF_PATH, root, NULL); } } } dbv.dbcv_size = sizeof (dbv); dbv.dbcv_devicetype = DBT_DEVTYP_VOLUME; dbv.dbcv_reserved = 0; dbv.dbcv_unitmask = driveMap; dbv.dbcv_flags = 0; UINT timeOut = 1000; // SHChangeNotify() works on Vista, so the Explorer does not require WM_DEVICECHANGE if (CurrentOSMajor >= 6) timeOut = 100; @@ -8934,147 +8737,144 @@ retry: mount.bMountReadOnly = mountOptions->ReadOnly; mount.bMountRemovable = mountOptions->Removable; mount.bPreserveTimestamp = mountOptions->PreserveTimestamp; if (mountOptions->DisableMountManager) mount.bMountManager = FALSE; else mount.bMountManager = TRUE; mount.pkcs5_prf = pkcs5; mount.VolumePim = pim; wstring path = volumePath; if (path.find (L"\\\\?\\") == 0) { // Remove \\?\ prefix 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); if (!resolvedPath.empty()) StringCchCopyW (volumePath, TC_MAX_PATH, resolvedPath.c_str()); } if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0)) { - std::vector<byte> arr; + std::vector<uint8> arr; if ( (path.length() == (3 + 2*VOLUME_ID_SIZE)) && HexWideStringToArray (path.c_str() + 3, arr) && (arr.size() == VOLUME_ID_SIZE) ) { useVolumeID = TRUE; bDevice = TRUE; memcpy (volumeID, &arr[0], VOLUME_ID_SIZE); } else { if (!quiet) Error ("VOLUME_ID_INVALID", hwndDlg); SetLastError (ERROR_INVALID_PARAMETER); return -1; } } else CreateFullVolumePath (mount.wszVolume, sizeof(mount.wszVolume), volumePath, &bDevice); if (!bDevice) { // put default values mount.BytesPerSector = 512; mount.BytesPerPhysicalSector = 512; mount.MaximumTransferLength = 65536; mount.MaximumPhysicalPages = 17; mount.AlignmentMask = 0; // UNC path if (path.find (L"\\\\") == 0) { StringCbCopyW (mount.wszVolume, sizeof (mount.wszVolume), (L"UNC" + path.substr (1)).c_str()); } if (GetVolumePathName (volumePath, root, ARRAYSIZE (root) - 1)) { DWORD bps, flags, d; if (GetDiskFreeSpace (root, &d, &bps, &d, &d)) { mount.BytesPerSector = bps; mount.BytesPerPhysicalSector = bps; } - if (IsOSAtLeast (WIN_VISTA)) + if ( (wcslen(root) >= 2) + && (root[1] == L':') + && (towupper(root[0]) >= L'A' && towupper(root[0]) <= L'Z') + ) { - if ( (wcslen(root) >= 2) - && (root[1] == L':') - && (towupper(root[0]) >= L'A' && towupper(root[0]) <= L'Z') - ) - { - wstring drivePath = L"\\\\.\\X:"; - HANDLE dev = INVALID_HANDLE_VALUE; - VOLUME_DISK_EXTENTS extents = {0}; - DWORD dwResult = 0; - drivePath[4] = root[0]; + wstring drivePath = L"\\\\.\\X:"; + HANDLE dev = INVALID_HANDLE_VALUE; + VOLUME_DISK_EXTENTS extents = {0}; + DWORD dwResult = 0; + drivePath[4] = root[0]; - if ((dev = CreateFile (drivePath.c_str(),0, 0, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) + if ((dev = CreateFile (drivePath.c_str(),0, 0, NULL, OPEN_EXISTING, 0, NULL)) != INVALID_HANDLE_VALUE) + { + if (DeviceIoControl (dev, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &extents, sizeof(extents), &dwResult, NULL)) { - if (DeviceIoControl (dev, IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS, NULL, 0, &extents, sizeof(extents), &dwResult, NULL)) + if (extents.NumberOfDiskExtents > 0) { - if (extents.NumberOfDiskExtents > 0) + STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR accessDesc; + STORAGE_ADAPTER_DESCRIPTOR adapterDesc; + + if (GetPhysicalDriveStorageInformation (extents.Extents[0].DiskNumber, &accessDesc, &adapterDesc)) { - STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR accessDesc; - STORAGE_ADAPTER_DESCRIPTOR adapterDesc; + if (accessDesc.Size >= sizeof (STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)) + { + mount.BytesPerSector = accessDesc.BytesPerLogicalSector; + mount.BytesPerPhysicalSector = accessDesc.BytesPerPhysicalSector; + } - if (GetPhysicalDriveStorageInformation (extents.Extents[0].DiskNumber, &accessDesc, &adapterDesc)) + if (adapterDesc.Size >= sizeof (STORAGE_ADAPTER_DESCRIPTOR)) { - if (accessDesc.Size >= sizeof (STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR)) - { - mount.BytesPerSector = accessDesc.BytesPerLogicalSector; - mount.BytesPerPhysicalSector = accessDesc.BytesPerPhysicalSector; - } - - if (adapterDesc.Size >= sizeof (STORAGE_ADAPTER_DESCRIPTOR)) - { - mount.MaximumTransferLength = adapterDesc.MaximumTransferLength; - mount.MaximumPhysicalPages = adapterDesc.MaximumPhysicalPages; - mount.AlignmentMask = adapterDesc.AlignmentMask; - } + mount.MaximumTransferLength = adapterDesc.MaximumTransferLength; + mount.MaximumPhysicalPages = adapterDesc.MaximumPhysicalPages; + mount.AlignmentMask = adapterDesc.AlignmentMask; } } } - CloseHandle (dev); } + CloseHandle (dev); } } // Read-only host filesystem if (!mount.bMountReadOnly && GetVolumeInformation (root, NULL, 0, NULL, &d, &flags, NULL, 0)) mount.bMountReadOnly = (flags & FILE_READ_ONLY_VOLUME) != 0; } } if (mountOptions->PartitionInInactiveSysEncScope) { if (mount.wszVolume == NULL || swscanf_s ((const wchar_t *) mount.wszVolume, WIDE("\\Device\\Harddisk%d\\Partition"), &mount.nPartitionInInactiveSysEncScopeDriveNo) != 1) { if (!quiet) Warning ("NO_SYSENC_PARTITION_SELECTED", hwndDlg); return -1; } mount.bPartitionInInactiveSysEncScope = TRUE; } if (!quiet) { MountThreadParam mountThreadParam; mountThreadParam.pmount = &mount; mountThreadParam.useVolumeID = useVolumeID; memcpy (mountThreadParam.volumeID, volumeID, VOLUME_ID_SIZE); mountThreadParam.pbResult = &bResult; @@ -9174,112 +8974,129 @@ retry: if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected) WarningDirect ((GetWrongPasswordErrorMessage (hwndDlg) + L"\n\n" + GetString ("HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT")).c_str(), hwndDlg); else handleError (hwndDlg, mount.nReturnCode, SRC_POS); } } else handleError (hwndDlg, mount.nReturnCode, SRC_POS); } return 0; } if (!quiet) handleError (hwndDlg, mount.nReturnCode, SRC_POS); return 0; } // Mount successful if (mount.UseBackupHeader != mountOptions->UseBackupHeader && mount.UseBackupHeader) { if (bReportWrongPassword && !Silent) Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK", hwndDlg); } LastMountedVolumeDirty = mount.FilesystemDirty; + if (mount.VolumeMasterKeyVulnerable + && !Silent) + { + Warning ("ERR_XTS_MASTERKEY_VULNERABLE", hwndDlg); + } + if (mount.FilesystemDirty) { wchar_t msg[1024]; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint); if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES) CheckFilesystem (hwndDlg, driveNo, TRUE); } if (mount.VolumeMountedReadOnlyAfterAccessDenied && !Silent && !bDevice && !FileHasReadOnlyAttribute (volumePath) && !IsFileOnReadOnlyFilesystem (volumePath)) { wchar_t msg[1024]; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint); WarningDirect (msg, hwndDlg); } if (mount.VolumeMountedReadOnlyAfterAccessDenied && !Silent && bDevice) { wchar_t msg[1024]; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint); WarningDirect (msg, hwndDlg); } if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected && !Silent && wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath) { wchar_t msg[1024]; wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint); WarningDirect (msg, hwndDlg); if (CurrentOSMajor >= 6 && wcsstr (volumePath, L"\\Device\\HarddiskVolume") != volumePath && AskNoYes ("ASK_REMOVE_DEVICE_WRITE_PROTECTION", hwndDlg) == IDYES) { RemoveDeviceWriteProtection (hwndDlg, volumePath); } } + if (mount.VolumeMountedReadOnlyAfterPartialSysEnc + && !Silent + && bDevice) + { + wchar_t msg[1024]; + wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + StringCbPrintfW (msg, sizeof(msg), GetString ("PARTIAL_SYSENC_MOUNT_READONLY"), mountPoint); + + WarningDirect (msg, hwndDlg); + } + if (mount.wszLabel[0] && !mount.bDriverSetLabel) { // try setting the drive label on user-mode using registry UpdateDriveCustomLabel (driveNo, mount.wszLabel, TRUE); } ResetWrongPwdRetryCount (); BroadcastDeviceChange (DBT_DEVICEARRIVAL, driveNo, 0); if (mount.bExclusiveAccess == FALSE) return 2; return 1; } #endif typedef struct { int nDosDriveNo; BOOL forced; int dismountMaxRetries; DWORD retryDelay; int* presult; DWORD dwLastError; } UnmountThreadParam; void CALLBACK UnmountWaitThreadProc(void* pArg, HWND hwnd) { @@ -9312,66 +9129,63 @@ static BOOL UnmountVolumeBase (HWND hwndDlg, int nDosDriveNo, BOOL forceUnmount, retry: BroadcastDeviceChange (DBT_DEVICEREMOVEPENDING, nDosDriveNo, 0); param.nDosDriveNo = nDosDriveNo; param.forced = forced; param.dismountMaxRetries = dismountMaxRetries; param.retryDelay = retryDelay; param.presult = &result; if (Silent) { UnmountWaitThreadProc (¶m, hwndDlg); } else { ShowWaitDialog (hwndDlg, FALSE, UnmountWaitThreadProc, ¶m); } SetLastError (param.dwLastError); if (result != 0) { if (result == ERR_FILES_OPEN && !Silent) { if (IDYES == AskWarnYesNoTopmost ("UNMOUNT_LOCK_FAILED", hwndDlg)) { forced = TRUE; goto retry; } - if (IsOSAtLeast (WIN_7)) - { - // Undo SHCNE_DRIVEREMOVED - wchar_t root[] = { (wchar_t) nDosDriveNo + L'A', L':', L'\\', 0 }; - SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); - } + // Undo SHCNE_DRIVEREMOVED + wchar_t root[] = { (wchar_t) nDosDriveNo + L'A', L':', L'\\', 0 }; + SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); return FALSE; } Error ("UNMOUNT_FAILED", hwndDlg); return FALSE; } BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, nDosDriveNo, 0); return TRUE; } BOOL UnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forceUnmount) { return UnmountVolumeBase (hwndDlg, nDosDriveNo, forceUnmount, FALSE); } BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo) { return UnmountVolumeBase (hwndDlg, nDosDriveNo, FALSE, TRUE); } BOOL IsPasswordCacheEmpty (void) { DWORD dw; return !DeviceIoControl (hDriver, TC_IOCTL_GET_PASSWORD_CACHE_STATUS, 0, 0, 0, 0, &dw, 0); } @@ -9381,61 +9195,61 @@ BOOL IsMountedVolumeID (BYTE volumeID[VOLUME_ID_SIZE]) DWORD dwResult; int i; memset (&mlist, 0, sizeof (mlist)); if ( !DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist, sizeof (mlist), &mlist, sizeof (mlist), &dwResult, NULL) || (mlist.ulMountedDrives >= (1 << 26)) ) { return FALSE; } if (mlist.ulMountedDrives) { for (i=0 ; i<26; i++) { if ((mlist.ulMountedDrives & (1 << i)) && (0 == memcmp (mlist.volumeID[i], volumeID, VOLUME_ID_SIZE))) return TRUE; } } return FALSE; } BOOL IsMountedVolume (const wchar_t *volname) { if ((wcslen (volname) == (3 + 2*VOLUME_ID_SIZE)) && _wcsnicmp (volname, L"ID:", 3) == 0) { /* Volume ID specified. Use it for matching mounted volumes. */ - std::vector<byte> arr; + std::vector<uint8> arr; if (HexWideStringToArray (&volname[3], arr) && (arr.size() == VOLUME_ID_SIZE)) { return IsMountedVolumeID (&arr[0]); } } else { MOUNT_LIST_STRUCT mlist; DWORD dwResult; int i; wchar_t volume[TC_MAX_PATH*2+16]; StringCbCopyW (volume, sizeof(volume), volname); if (wcsstr (volname, L"\\Device\\") != volname) StringCbPrintfW(volume, sizeof(volume), L"\\??\\%s", volname); wstring resolvedPath = VolumeGuidPathToDevicePath (volname); if (!resolvedPath.empty()) StringCbCopyW (volume, sizeof (volume), resolvedPath.c_str()); memset (&mlist, 0, sizeof (mlist)); if ( !DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, &mlist, sizeof (mlist), &mlist, sizeof (mlist), &dwResult, NULL) || (mlist.ulMountedDrives >= (1 << 26)) ) { return FALSE; } @@ -9517,63 +9331,60 @@ BOOL IsBuiltInAdmin () { HANDLE procToken; DWORD size; if (!IsAdmin() || !OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &procToken)) return FALSE; finally_do_arg (HANDLE, procToken, { CloseHandle (finally_arg); }); if (GetTokenInformation (procToken, TokenUser, NULL, 0, &size) || GetLastError() != ERROR_INSUFFICIENT_BUFFER) return FALSE; TOKEN_USER *tokenUser = (TOKEN_USER *) malloc (size); if (!tokenUser) return FALSE; finally_do_arg (void *, tokenUser, { free (finally_arg); }); if (!GetTokenInformation (procToken, TokenUser, tokenUser, size, &size)) return FALSE; return IsWellKnownSid (tokenUser->User.Sid, WinAccountAdministratorSid); } BOOL IsUacSupported () { HKEY hkey; DWORD value = 1, size = sizeof (DWORD); - if (!IsOSAtLeast (WIN_VISTA)) - return FALSE; - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", 0, KEY_READ, &hkey) == ERROR_SUCCESS) { if (RegQueryValueEx (hkey, L"EnableLUA", 0, 0, (LPBYTE) &value, &size) != ERROR_SUCCESS) value = 1; RegCloseKey (hkey); } return value != 0; } BOOL ResolveSymbolicLink (const wchar_t *symLinkName, PWSTR targetName, size_t cbTargetName) { BOOL bResult; DWORD dwResult; RESOLVE_SYMLINK_STRUCT resolve; memset (&resolve, 0, sizeof(resolve)); StringCbCopyW (resolve.symLinkName, sizeof(resolve.symLinkName), symLinkName); bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_RESOLVED_SYMLINK, &resolve, sizeof (resolve), &resolve, sizeof (resolve), &dwResult, NULL); StringCbCopyW (targetName, cbTargetName, resolve.targetName); return bResult; } @@ -10186,123 +9997,101 @@ void ManageStartupSeqWiz (BOOL bRemove, const wchar_t *arg) if (wcslen (arg) > 0) { StringCchCatW (exe, exeSize, L"\" "); StringCchCatW (exe, exeSize, arg); } WriteRegistryString (regk, L"VeraCrypt Format", exe); free(exe); } else DeleteRegistryValue (regk, L"VeraCrypt Format"); } // Delete the last used Windows file selector path for TrueCrypt from the registry void CleanLastVisitedMRU (void) { WCHAR exeFilename[MAX_PATH]; WCHAR *strToMatch; WCHAR strTmp[4096]; WCHAR regPath[128]; WCHAR key[64]; int id, len; GetModuleFileNameW (NULL, exeFilename, sizeof (exeFilename) / sizeof(exeFilename[0])); strToMatch = wcsrchr (exeFilename, L'\\') + 1; - StringCbPrintfW (regPath, sizeof(regPath), L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisited%sMRU", IsOSAtLeast (WIN_VISTA) ? L"Pidl" : L""); + StringCbCopyW (regPath, sizeof(regPath), L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU"); - for (id = (IsOSAtLeast (WIN_VISTA) ? 0 : L'a'); id <= (IsOSAtLeast (WIN_VISTA) ? 1000 : L'z'); id++) + for (id = 0; id <= 1000; id++) { *strTmp = 0; - StringCbPrintfW (key, sizeof(key), (IsOSAtLeast (WIN_VISTA) ? L"%d" : L"%c"), id); + StringCbPrintfW (key, sizeof(key), L"%d", id); if ((len = ReadRegistryBytes (regPath, key, (char *) strTmp, sizeof (strTmp))) > 0) { if (_wcsicmp (strTmp, strToMatch) == 0) { char buf[65536], bufout[sizeof (buf)]; // Overwrite the entry with zeroes while keeping its original size memset (strTmp, 0, len); if (!WriteRegistryBytes (regPath, key, (char *) strTmp, len)) MessageBoxW (NULL, GetString ("CLEAN_WINMRU_FAILED"), lpszTitle, ICON_HAND); DeleteRegistryValue (regPath, key); // Remove ID from MRUList - if (IsOSAtLeast (WIN_VISTA)) - { - int *p = (int *)buf; - int *pout = (int *)bufout; - int l; - - l = len = ReadRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", buf, sizeof (buf)); - while (l > 0) - { - l -= sizeof (int); + int *p = (int *)buf; + int *pout = (int *)bufout; + int l; - if (*p == id) - { - p++; - len -= sizeof (int); - continue; - } - *pout++ = *p++; - } - - WriteRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", bufout, len); - } - else + l = len = ReadRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", buf, sizeof (buf)); + while (l > 0) { - wchar_t *p = (wchar_t*) buf; - wchar_t *pout = (wchar_t*) bufout; + l -= sizeof (int); - ReadRegistryString (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", L"MRUList", L"", (wchar_t*) buf, sizeof (buf)); - while (*p) + if (*p == id) { - if (*p == id) - { - p++; - continue; - } - *pout++ = *p++; + p++; + len -= sizeof (int); + continue; } - *pout++ = 0; - - WriteRegistryString (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedMRU", L"MRUList", (wchar_t*) bufout); + *pout++ = *p++; } + WriteRegistryBytes (L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\ComDlg32\\LastVisitedPidlMRU", L"MRUListEx", bufout, len); + break; } } } } #ifndef SETUP void ClearHistory (HWND hwndDlgItem) { ArrowWaitCursor (); ClearCombo (hwndDlgItem); DumpCombo (hwndDlgItem, TRUE); CleanLastVisitedMRU (); NormalCursor (); } #endif // #ifndef SETUP LRESULT ListItemAdd (HWND list, int index, const wchar_t *string) { LVITEM li; memset (&li, 0, sizeof(li)); li.mask = LVIF_TEXT; li.pszText = (wchar_t*) string; li.iItem = index; @@ -10429,61 +10218,61 @@ std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy) } // Returns 0 if an error occurs or the drive letter (as an upper-case char) of the system partition (e.g. 'C'); wchar_t GetSystemDriveLetter (void) { wchar_t systemDir [MAX_PATH]; if (GetSystemDirectory (systemDir, ARRAYSIZE (systemDir))) return (wchar_t) (towupper (systemDir [0])); else return 0; } void TaskBarIconDisplayBalloonTooltip (HWND hwnd, wchar_t *headline, wchar_t *text, BOOL warning) { NOTIFYICONDATAW tnid; ZeroMemory (&tnid, sizeof (tnid)); 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.dwInfoFlags = (warning ? NIIF_WARNING : NIIF_INFO); - tnid.uTimeout = (IsOSAtLeast (WIN_VISTA) ? 1000 : 5000); // in ms + tnid.uTimeout = 1000; // in ms StringCbCopyW (tnid.szInfoTitle, sizeof(tnid.szInfoTitle), headline); StringCbCopyW (tnid.szInfo, sizeof(tnid.szInfo),text); // Display the balloon tooltip quickly twice in a row to avoid the slow and unwanted "fade-in" phase Shell_NotifyIconW (NIM_MODIFY, &tnid); Shell_NotifyIconW (NIM_MODIFY, &tnid); } // Either of the pointers may be NULL void InfoBalloon (char *headingStringId, char *textStringId, HWND hwnd) { if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, headingStringId == NULL ? L"VeraCrypt" : GetString (headingStringId), textStringId == NULL ? L" " : GetString (textStringId), FALSE); } // Either of the pointers may be NULL void InfoBalloonDirect (wchar_t *headingString, wchar_t *textString, HWND hwnd) { if (Silent) return; TaskBarIconDisplayBalloonTooltip (hwnd, @@ -11026,71 +10815,62 @@ void Debug (char *format, ...) } void DebugMsgBox (char *format, ...) { char buf[1024]; va_list val; va_start(val, format); StringCbVPrintfA (buf, sizeof (buf), format, val); va_end(val); MessageBoxA (MainDlg, buf, "VeraCrypt debug", 0); } BOOL IsSupportedOS () { BOOL bRet = FALSE; #ifdef SETUP static const wchar_t* szWin7KBs[] = {L"KB3033929", L"KB4474419"}; static const wchar_t* szWinVistaKBs[] = {L"KB4039648", L"KB4474419"}; if (IsOSAtLeast(WIN_8)) bRet = TRUE; else if (IsOSAtLeast(WIN_7)) { if (OneOfKBsInstalled(szWin7KBs, 2)) bRet = TRUE; else MessageBoxW (NULL, L"SHA-2 support missing from Windows.\n\nPlease Install KB3033929 or KB4474419", lpszTitle, MB_ICONWARNING); } - else if (IsOSAtLeast(WIN_VISTA)) - { - if (OneOfKBsInstalled(szWinVistaKBs, 2)) - bRet = TRUE; - else - MessageBoxW (NULL, L"SHA-2 support missing from Windows.\n\nPlease Install KB4039648 or KB4474419", lpszTitle, MB_ICONWARNING); - } - else if (IsOSAtLeast(WIN_XP)) - bRet = TRUE; #else - if (IsOSAtLeast(WIN_XP)) + if (IsOSAtLeast(WIN_7)) bRet = TRUE; #endif return bRet; } BOOL Is64BitOs() { #ifdef _WIN64 return TRUE; #else static BOOL isWow64 = FALSE; static BOOL valid = FALSE; typedef BOOL(__stdcall* LPFN_ISWOW64PROCESS) (HANDLE hProcess, PBOOL Wow64Process); typedef BOOL(__stdcall* LPFN_ISWOW64PROCESS2)( HANDLE hProcess, USHORT* pProcessMachine, USHORT* pNativeMachine ); LPFN_ISWOW64PROCESS fnIsWow64Process; LPFN_ISWOW64PROCESS2 fnIsWow64Process2; if (valid) return isWow64; fnIsWow64Process = (LPFN_ISWOW64PROCESS)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process"); fnIsWow64Process2 = (LPFN_ISWOW64PROCESS2)GetProcAddress(GetModuleHandle(L"kernel32"), "IsWow64Process2"); if (fnIsWow64Process2) { @@ -11374,60 +11154,64 @@ void Applink (const char *dest) } else if (strcmp(dest, "beginnerstutorial") == 0 || strcmp(dest,"tutorial") == 0) { StringCbCopyW (page, sizeof (page),L"Beginner%27s%20Tutorial.html"); } else if (strcmp(dest, "releasenotes") == 0 || strcmp(dest, "history") == 0) { StringCbCopyW (page, sizeof (page),L"Release%20Notes.html"); } else if (strcmp(dest, "hwacceleration") == 0) { StringCbCopyW (page, sizeof (page),L"Hardware%20Acceleration.html"); } else if (strcmp(dest, "parallelization") == 0) { StringCbCopyW (page, sizeof (page),L"Parallelization.html"); } else if (strcmp(dest, "help") == 0) { StringCbCopyW (page, sizeof (page),L"Documentation.html"); } else if (strcmp(dest, "onlinehelp") == 0) { StringCbCopyW (url, sizeof (url),L"https://www.veracrypt.fr/en/Documentation.html"); buildUrl = FALSE; } else if (strcmp(dest, "keyfiles") == 0) { StringCbCopyW (page, sizeof (page),L"Keyfiles.html"); } + else if (strcmp(dest, "keyfilesextensions") == 0) + { + StringCbCopyW (page, sizeof (page),L"Avoid%20Third-Party%20File%20Extensions.html"); + } else if (strcmp(dest, "introcontainer") == 0) { StringCbCopyW (page, sizeof (page),L"Creating%20New%20Volumes.html"); } else if (strcmp(dest, "introsysenc") == 0) { StringCbCopyW (page, sizeof (page),L"System%20Encryption.html"); } else if (strcmp(dest, "hiddensysenc") == 0) { StringCbCopyW (page, sizeof (page),L"VeraCrypt%20Hidden%20Operating%20System.html"); } else if (strcmp(dest, "sysencprogressinfo") == 0) { StringCbCopyW (page, sizeof (page),L"System%20Encryption.html"); } else if (strcmp(dest, "hiddenvolume") == 0) { StringCbCopyW (page, sizeof (page),L"Hidden%20Volume.html"); } else if (strcmp(dest, "aes") == 0) { StringCbCopyW (page, sizeof (page),L"AES.html"); } else if (strcmp(dest, "serpent") == 0) { StringCbCopyW (page, sizeof (page),L"Serpent.html"); } else if (strcmp(dest, "twofish") == 0) { @@ -11459,83 +11243,101 @@ void Applink (const char *dest) StringCbCopyW (page, sizeof (page),L"System%20Favorite%20Volumes.html"); } else if (strcmp(dest, "favorites") == 0) { StringCbCopyW (page, sizeof (page),L"Favorite%20Volumes.html"); } else if (strcmp(dest, "hiddenvolprotection") == 0) { StringCbCopyW (page, sizeof (page),L"Protection%20of%20Hidden%20Volumes.html"); } else if (strcmp(dest, "faq") == 0) { StringCbCopyW (page, sizeof (page),L"FAQ.html"); } else if (strcmp(dest, "downloads") == 0) { StringCbCopyW (page, sizeof (page),L"Downloads.html"); } else if (strcmp(dest, "news") == 0) { StringCbCopyW (page, sizeof (page),L"News.html"); } else if (strcmp(dest, "contact") == 0) { StringCbCopyW (page, sizeof (page),L"Contact.html"); } else if (strcmp(dest, "pim") == 0) { StringCbCopyW (page, sizeof (page),L"Personal%20Iterations%20Multiplier%20%28PIM%29.html"); } + else if (strcmp(dest, "memoryprotection") == 0) + { + StringCbCopyW (page, sizeof (page),L"VeraCrypt%20Memory%20Protection.html"); + } else { StringCbCopyW (url, sizeof (url),TC_APPLINK); buildUrl = FALSE; } if (buildUrl) { + // in case of setup, open the online documentation if we are connected to Internet because existing documentation may be outdated +#ifdef SETUP + if (IsInternetConnected()) + { + StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page); + buildUrl = FALSE; + } + else + { + StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page); + CorrectURL (url); + } +#else StringCbPrintfW (url, sizeof (url), L"file:///%sdocs/html/en/%s", installDir, page); CorrectURL (url); +#endif } - if (IsOSAtLeast (WIN_VISTA) && IsAdmin ()) + if (IsAdmin ()) { int openDone = 0; if (buildUrl) { wchar_t pageFileName [TC_MAX_PATH] = {0}; DWORD cchUnescaped = ARRAYSIZE(pageFileName); StringCbCopyW (pageFileName, sizeof(pageFileName), page); /* remove escape sequences from the page name before calling FileExists function */ - if (S_OK == UrlUnescapeWFn (pageFileName, pageFileName, &cchUnescaped, URL_UNESCAPE_INPLACE)) + if (S_OK == UrlUnescapeW (pageFileName, pageFileName, &cchUnescaped, URL_UNESCAPE_INPLACE)) { std::wstring pageFullPath = installDir; pageFullPath += L"docs\\html\\en\\"; pageFullPath += pageFileName; if (!FileExists (pageFullPath.c_str())) { // fallback to online resources StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page); SafeOpenURL (url); openDone = 1; } } } if (!openDone) { SafeOpenURL (url); } } else { r = (int) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); if (((r == ERROR_FILE_NOT_FOUND) || (r == ERROR_PATH_NOT_FOUND)) && buildUrl) { // fallback to online resources StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page); ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); } @@ -11553,77 +11355,76 @@ wchar_t *RelativePath2Absolute (wchar_t *szFileName) && wcsstr (szFileName, L"Volume{") != szFileName) { wchar_t path[MAX_PATH*2]; GetCurrentDirectory (MAX_PATH, path); if (path[wcslen (path) - 1] != L'\\') StringCbCatW (path, (MAX_PATH * 2), L"\\"); StringCbCatW (path, (MAX_PATH * 2), szFileName); StringCbCopyW (szFileName, MAX_PATH + 1, path); // szFileName size is always at least (MAX_PATH + 1) } return szFileName; } void HandleDriveNotReadyError (HWND hwnd) { HKEY hkey = 0; DWORD value = 0, size = sizeof (DWORD); if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\MountMgr", 0, KEY_READ, &hkey) != ERROR_SUCCESS) return; if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS && value != 0) { Warning ("SYS_AUTOMOUNT_DISABLED", hwnd); } - else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1) - Warning ("SYS_ASSIGN_DRIVE_LETTER", hwnd); else Warning ("DEVICE_NOT_READY_ERROR", hwnd); RegCloseKey (hkey); } BOOL CALLBACK CloseTCWindowsEnum (HWND hwnd, LPARAM lParam) { LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA); if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs { wchar_t name[1024] = { 0 }; GetWindowText (hwnd, name, ARRAYSIZE (name) - 1); - if (hwnd != MainDlg && wcsstr (name, L"VeraCrypt")) + // check if the window is a VeraCrypt window, excluding current process main dialog and VeraCrypt Setup window + if (hwnd != MainDlg && wcsstr (name, L"VeraCrypt") && !wcsstr (name, L"VeraCrypt Setup")) { PostMessage (hwnd, TC_APPMSG_CLOSE_BKG_TASK, 0, 0); PostMessage (hwnd, WM_CLOSE, 0, 0); if (lParam != 0) *((BOOL *)lParam) = TRUE; } } return TRUE; } BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam) { if (*(HWND *)lParam == hwnd) return TRUE; LONG_PTR userDataVal = GetWindowLongPtrW (hwnd, GWLP_USERDATA); if ((userDataVal == (LONG_PTR) 'VERA') || (userDataVal == (LONG_PTR) 'TRUE')) // Prior to 1.0e, 'TRUE' was used for VeraCrypt dialogs { wchar_t name[32] = { 0 }; GetWindowText (hwnd, name, ARRAYSIZE (name) - 1); if (hwnd != MainDlg && wcscmp (name, L"VeraCrypt") == 0) { if (lParam != 0) *((HWND *)lParam) = hwnd; } } return TRUE; } @@ -11803,61 +11604,61 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password context->HostSize = fileSize.QuadPart; } for (volumeType = TC_VOLUME_TYPE_NORMAL; volumeType < TC_VOLUME_TYPE_COUNT; volumeType++) { // Seek the volume header switch (volumeType) { case TC_VOLUME_TYPE_NORMAL: headerOffset.QuadPart = useBackupHeader ? context->HostSize - TC_VOLUME_HEADER_GROUP_SIZE : TC_VOLUME_HEADER_OFFSET; break; case TC_VOLUME_TYPE_HIDDEN: if (TC_HIDDEN_VOLUME_HEADER_OFFSET + TC_VOLUME_HEADER_SIZE > context->HostSize) continue; headerOffset.QuadPart = useBackupHeader ? context->HostSize - TC_VOLUME_HEADER_SIZE : TC_HIDDEN_VOLUME_HEADER_OFFSET; break; } if (!SetFilePointerEx ((HANDLE) context->HostFileHandle, headerOffset, NULL, FILE_BEGIN)) { status = ERR_OS_ERROR; goto error; } // Read volume header DWORD bytesRead; - if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (byte *) buffer, &bytesRead)) + if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (uint8 *) buffer, &bytesRead)) { status = ERR_OS_ERROR; goto error; } if (bytesRead != sizeof (buffer) && 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 // 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. memset (buffer, 0, sizeof (buffer)); } // Decrypt volume header status = ReadVolumeHeader (FALSE, buffer, password, pkcs5_prf, pim, &context->CryptoInfo, NULL); if (status == ERR_PASSWORD_WRONG) continue; // Try next volume type break; } if (status == ERR_SUCCESS) return status; error: DWORD sysError = GetLastError (); @@ -12385,142 +12186,142 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam { BOOL selected = (ListView_GetNextItem (GetDlgItem (hwndDlg, IDC_TOKEN_FILE_LIST), -1, LVIS_SELECTED) != -1); BOOL deletable = selected; // Multiple key files can be selected. // Therefore, if one of them is not deletable, it means the delete button must be disabled for all. foreach (const shared_ptr<TokenKeyfile> &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles)) { if (!keyfile->Token->isEditable()) { deletable = false; break; } } EnableWindow (GetDlgItem (hwndDlg, IDC_EXPORT), selected); EnableWindow (GetDlgItem (hwndDlg, IDC_DELETE), deletable); return 1; } if (msg == WM_COMMAND) { switch (lw) { case IDCANCEL: EndDialog (hwndDlg, IDCANCEL); return 1; case IDC_IMPORT_KEYFILE: { wchar_t keyfilePath[TC_MAX_PATH]; - if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE, NULL)) + if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE)) { DWORD keyfileSize; - byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize); + uint8 *keyfileData = (uint8 *) LoadFile (keyfilePath, &keyfileSize); if (!keyfileData) { handleWin32Error (hwndDlg, SRC_POS); return 1; } if (keyfileSize != 0) { NewSecurityTokenKeyfileDlgProcParams newParams; newParams.Name = WideToUtf8String (keyfilePath); size_t lastBackSlash = newParams.Name.find_last_of ('\\'); if (lastBackSlash != string::npos) newParams.Name = newParams.Name.substr (lastBackSlash + 1); if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_NEW_TOKEN_KEYFILE), hwndDlg, (DLGPROC) NewSecurityTokenKeyfileDlgProc, (LPARAM) &newParams) == IDOK) { - vector <byte> keyfileDataVector (keyfileSize); + vector <uint8> keyfileDataVector (keyfileSize); memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize); try { WaitCursor(); finally_do ({ NormalCursor(); }); SecurityToken::CreateKeyfile (newParams.SlotId, keyfileDataVector, newParams.Name); keyfiles = Token::GetAvailableKeyfiles(EMVSupportEnabled? true : false); SecurityTokenKeyfileDlgFillList (hwndDlg, keyfiles); } catch (Exception &e) { e.Show (hwndDlg); } burn (&keyfileDataVector.front(), keyfileSize); } } else { SetLastError (ERROR_HANDLE_EOF); handleWin32Error (hwndDlg, SRC_POS); } burn (keyfileData, keyfileSize); TCfree (keyfileData); } return 1; } case IDC_EXPORT: { try { foreach (const shared_ptr<TokenKeyfile> &keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles)) { wchar_t keyfilePath[TC_MAX_PATH]; - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", keyfilePath, bHistory, TRUE, NULL)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", keyfilePath, bHistory, TRUE)) break; { WaitCursor(); finally_do ({ NormalCursor(); }); - vector <byte> keyfileData; + vector <uint8> keyfileData; keyfile->GetKeyfileData (keyfileData); if (keyfileData.empty()) { SetLastError (ERROR_HANDLE_EOF); handleWin32Error (hwndDlg, SRC_POS); return 1; } - finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); }); + finally_do_arg (vector <uint8> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); }); if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, (DWORD) keyfileData.size(), FALSE, FALSE)) throw SystemException (SRC_POS); } Info ("KEYFILE_EXPORTED", hwndDlg); } } catch (Exception &e) { e.Show (hwndDlg); } return 1; } case IDC_DELETE: { if (AskNoYes ("CONFIRM_SEL_FILES_DELETE", hwndDlg) == IDNO) return 1; try { WaitCursor(); finally_do ({ NormalCursor(); }); foreach (const shared_ptr<TokenKeyfile> keyfile, SecurityTokenKeyfileDlgGetSelected (hwndDlg, keyfiles)) { SecurityToken::DeleteKeyfile (dynamic_cast<SecurityTokenKeyfile&>(*keyfile.get())); } @@ -13249,85 +13050,85 @@ BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path) DWORD flags, d; if (!GetVolumeInformation (root, NULL, 0, NULL, &d, &flags, NULL, 0)) return FALSE; return (flags & FILE_READ_ONLY_VOLUME) ? TRUE : FALSE; } void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors) { wchar_t msg[1024], param[1024], cmdPath[MAX_PATH]; wchar_t driveRoot[] = { L'A' + (wchar_t) driveNo, L':', 0 }; if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO) return; StringCbPrintfW (msg, sizeof(msg), GetString (fixErrors ? "REPAIRING_FS" : "CHECKING_FS"), driveRoot); StringCbPrintfW (param, sizeof(param), fixErrors ? L"/C echo %s & chkdsk %s /F /X & pause" : L"/C echo %s & chkdsk %s & pause", msg, driveRoot); if (GetSystemDirectoryW(cmdPath, MAX_PATH)) { StringCbCatW(cmdPath, sizeof(cmdPath), L"\\cmd.exe"); } else StringCbCopyW(cmdPath, sizeof(cmdPath), L"C:\\Windows\\System32\\cmd.exe"); ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", cmdPath, param, NULL, SW_SHOW); } -BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize) +BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize) { if (bufferSize < patternSize) return FALSE; bufferSize -= patternSize; for (size_t i = 0; i < bufferSize; ++i) { if (memcmp (buffer + i, pattern, patternSize) == 0) return TRUE; } return FALSE; } -BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str) +BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str) { - return BufferContainsPattern (buffer, bufferSize, (const byte*) str, strlen (str)); + return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, strlen (str)); } -BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str) +BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str) { - return BufferContainsPattern (buffer, bufferSize, (const byte*) str, 2 * wcslen (str)); + return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, 2 * wcslen (str)); } #ifndef SETUP int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL *pbDecrypt) { if (AskWarnYesNo ("NONSYS_INPLACE_ENC_RESUME_PROMPT", hwndDlg) == IDYES) { char *tmpStr[] = {0, "CHOOSE_ENCRYPT_OR_DECRYPT", "ENCRYPT", "DECRYPT", "IDCANCEL", 0}; switch (AskMultiChoice ((void **) tmpStr, FALSE, hwndDlg)) { case 1: *pbDecrypt = FALSE; return IDYES; case 2: *pbDecrypt = TRUE; return IDYES; default: break; } } char *multiChoiceStr[] = { 0, "ASK_NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL", "DO_NOT_PROMPT_ME", "KEEP_PROMPTING_ME", 0 }; @@ -13463,65 +13264,60 @@ BOOL VolumePathExists (const wchar_t *volumePath) UpperCaseCopy (upperCasePath, sizeof(upperCasePath), volumePath); if (wcsstr (upperCasePath, L"\\DEVICE\\") == upperCasePath) return OpenDevice (volumePath, &openTest, FALSE, FALSE); wstring path = volumePath; if (path.find (L"\\\\?\\Volume{") == 0 && path.rfind (L"}\\") == path.size() - 2) { wchar_t devicePath[TC_MAX_PATH]; if (QueryDosDevice (path.substr (4, path.size() - 5).c_str(), devicePath, TC_MAX_PATH) != 0) return TRUE; } if (_waccess (volumePath, 0) == 0) return TRUE; else { DWORD dwResult = GetLastError (); if (dwResult == ERROR_SHARING_VIOLATION) return TRUE; else return FALSE; } } BOOL IsWindowsIsoBurnerAvailable () { wchar_t path[MAX_PATH*2] = { 0 }; - if (!IsOSAtLeast (WIN_7)) - { - return FALSE; - } - if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path))) { StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL); return (FileExists (path)); } return FALSE; } BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath) { wchar_t path[MAX_PATH*2] = { 0 }; int r; if (SUCCEEDED(SHGetFolderPath (NULL, CSIDL_SYSTEM, NULL, 0, path))) StringCbCatW (path, MAX_PATH*2, L"\\" ISO_BURNER_TOOL); else StringCbCopyW (path, MAX_PATH*2, L"C:\\Windows\\System32\\" ISO_BURNER_TOOL); r = (int) ShellExecute (hwnd, L"open", path, (wstring (L"\"") + isoPath + L"\"").c_str(), NULL, SW_SHOWNORMAL); if (r <= 32) { SetLastError (r); handleWin32Error (hwnd, SRC_POS); return FALSE; } @@ -13738,165 +13534,160 @@ void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, } SendMessageW (GetDlgItem (hwndDlg, edit1Id), EM_SETPASSWORDCHAR, GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar, 0); InvalidateRect (GetDlgItem (hwndDlg, edit1Id), NULL, TRUE); if (edit2Id) { SendMessageW (GetDlgItem (hwndDlg, edit2Id), EM_SETPASSWORDCHAR, GetCheckBox (hwndDlg, checkBoxId) ? 0 : EditPasswordChar, 0); InvalidateRect (GetDlgItem (hwndDlg, edit2Id), NULL, TRUE); } } void RegisterDriverInf (bool registerFilter, const string& filter, const string& filterReg, HWND ParentWindow, HKEY regKey) { wstring infFileName = GetTempPathString() + L"\\veracrypt_driver_setup.inf"; File infFile (infFileName, false, true); finally_do_arg (wstring, infFileName, { DeleteFile (finally_arg.c_str()); }); string infTxt = "[veracrypt]\r\n" + string (registerFilter ? "Add" : "Del") + "Reg=veracrypt_reg\r\n\r\n" "[veracrypt_reg]\r\n" "HKR,,\"" + filterReg + "\",0x0001" + string (registerFilter ? "0008" : "8002") + ",\"" + filter + "\"\r\n"; - infFile.Write ((byte *) infTxt.c_str(), (DWORD) infTxt.size()); + infFile.Write ((uint8 *) infTxt.c_str(), (DWORD) infTxt.size()); infFile.Close(); - HINF hInf = SetupOpenInfFileWFn (infFileName.c_str(), NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); + HINF hInf = SetupOpenInfFileW (infFileName.c_str(), NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL); throw_sys_if (hInf == INVALID_HANDLE_VALUE); - finally_do_arg (HINF, hInf, { SetupCloseInfFileFn (finally_arg); }); + finally_do_arg (HINF, hInf, { SetupCloseInfFile (finally_arg); }); - throw_sys_if (!SetupInstallFromInfSectionWFn (ParentWindow, hInf, L"veracrypt", SPINST_REGISTRY, regKey, NULL, 0, NULL, NULL, NULL, NULL)); + throw_sys_if (!SetupInstallFromInfSectionW (ParentWindow, hInf, L"veracrypt", SPINST_REGISTRY, regKey, NULL, 0, NULL, NULL, NULL, NULL)); } HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid) { - return SetupDiOpenClassRegKeyFn (deviceClassGuid, KEY_READ | KEY_WRITE); + return SetupDiOpenClassRegKey (deviceClassGuid, KEY_READ | KEY_WRITE); } LSTATUS DeleteRegistryKey (HKEY hKey, LPCTSTR keyName) { - return SHDeleteKeyWFn(hKey, keyName); + return SHDeleteKeyW(hKey, keyName); } HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow) { - return ImageList_CreateFn(cx, cy, flags, cInitial, cGrow); + return ImageList_Create(cx, cy, flags, cInitial, cGrow); } int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask) { - return ImageList_AddFn(himl, hbmImage, hbmMask); + return ImageList_Add(himl, hbmImage, hbmMask); } HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz) { - return SHStrDupWFn (psz, ppwsz); + return SHStrDupW (psz, ppwsz); } void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy) { /* conservative estimate: 1 mouse move event brings 1 bit of entropy * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848 */ if (*pdwEntropy == 0xFFFFFFFF) { *pdwInitialValue = dwCounter; *pdwEntropy = 0; } else { if ( *pdwEntropy < dwMaxLevel && (dwCounter >= *pdwInitialValue) && (dwCounter - *pdwInitialValue) <= dwMaxLevel) *pdwEntropy = dwCounter - *pdwInitialValue; else *pdwEntropy = dwMaxLevel; - if (IsOSAtLeast (WIN_VISTA)) - { - int state = PBST_ERROR; - if (*pdwEntropy >= (dwMaxLevel/2)) - state = PBST_NORMAL; - else if (*pdwEntropy >= (dwMaxLevel/4)) - state = PBST_PAUSED; + int state = PBST_ERROR; + if (*pdwEntropy >= (dwMaxLevel/2)) + state = PBST_NORMAL; + else if (*pdwEntropy >= (dwMaxLevel/4)) + state = PBST_PAUSED; - SendMessage (hProgress, PBM_SETSTATE, state, 0); - } + SendMessage (hProgress, PBM_SETSTATE, state, 0); SendMessage (hProgress, PBM_SETPOS, (WPARAM) (*pdwEntropy), 0); } } void AllowMessageInUIPI (UINT msg) { - if (ChangeWindowMessageFilterFn) - { - ChangeWindowMessageFilterFn (msg, MSGFLT_ADD); - } + /* ChangeWindowMessageFilter is used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */ + ChangeWindowMessageFilter (msg, MSGFLT_ADD); } -BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize) +BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize) { if (buffer && bufferSize) { size_t i; for (i = 0; i < bufferSize; i++) { if (*buffer++ != value) return FALSE; } return TRUE; } else return FALSE; } #ifndef SETUP BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue) { BOOL bRet = TRUE; size_t pathLen = pathValue? wcslen (pathValue) : 0; if ((pathLen >= 3) && (_wcsnicmp (pathValue, L"ID:", 3) == 0)) { - std::vector<byte> arr; + std::vector<uint8> arr; if ( (pathLen == (3 + 2*VOLUME_ID_SIZE)) && HexWideStringToArray (pathValue + 3, arr) && (arr.size() == VOLUME_ID_SIZE) ) { std::wstring devicePath = FindDeviceByVolumeID (&arr[0], FALSE); if (devicePath.length() > 0) StringCchCopyW (pathValue, cchPathValue, devicePath.c_str()); else { if (!Silent && !MultipleMountOperationInProgress) Error ("VOLUME_ID_NOT_FOUND", hwndDlg); SetLastError (ERROR_PATH_NOT_FOUND); bRet = FALSE; } } else { if (!Silent) Error ("VOLUME_ID_INVALID", hwndDlg); SetLastError (ERROR_INVALID_PARAMETER); bRet = FALSE; } } return bRet; } #endif @@ -13928,121 +13719,156 @@ BOOL CopyTextToClipboard (LPCWSTR txtValue) } BOOL GetFreeDriveLetter(WCHAR* pCh) { DWORD dwUsedDrives = GetLogicalDrives(); WCHAR l; for (l = L'A'; l <= L'Z'; l++) { if ((dwUsedDrives & 1) == 0) { *pCh = l; return TRUE; } dwUsedDrives = dwUsedDrives >> 1; } return FALSE; } BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable) { HANDLE hToken; TOKEN_PRIVILEGES tkp; BOOL bRet = FALSE; DWORD dwLastError = 0; if (OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) { if (LookupPrivilegeValue(NULL, szPrivilegeName, &tkp.Privileges[0].Luid)) { tkp.PrivilegeCount = 1; - tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED; + tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : 0; bRet = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL); dwLastError = GetLastError (); - if ( ERROR_SUCCESS != dwLastError) + if (bRet && (ERROR_NOT_ALL_ASSIGNED == dwLastError)) { bRet = FALSE; } } else dwLastError = GetLastError (); CloseHandle(hToken); } else dwLastError = GetLastError (); SetLastError (dwLastError); return bRet; } +BOOL IsPrivilegeEnabled (LPTSTR szPrivilegeName) +{ + HANDLE hToken; + TOKEN_PRIVILEGES tkp; + BOOL bRet = FALSE; + DWORD dwLastError = 0; + + if (OpenProcessToken(GetCurrentProcess(), + TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, + &hToken)) + { + if (LookupPrivilegeValue(NULL, szPrivilegeName, + &tkp.Privileges[0].Luid)) + { + DWORD dwSize = sizeof (tkp); + if (GetTokenInformation (hToken, TokenPrivileges, &tkp, dwSize, &dwSize)) + { + bRet = (tkp.Privileges[0].Attributes & SE_PRIVILEGE_ENABLED) != 0; + } + else + dwLastError = GetLastError (); + } + else + dwLastError = GetLastError (); + + CloseHandle(hToken); + } + else + dwLastError = GetLastError (); + + SetLastError (dwLastError); + + return bRet; +} + BOOL DeleteDirectory (const wchar_t* szDirName) { BOOL bStatus = RemoveDirectory (szDirName); if (!bStatus) { /* force removal of the non empty directory */ wchar_t szOpPath[TC_MAX_PATH + 1] = {0}; SHFILEOPSTRUCTW op; StringCchCopyW(szOpPath, ARRAYSIZE(szOpPath)-1, szDirName); ZeroMemory(&op, sizeof(op)); op.wFunc = FO_DELETE; op.pFrom = szOpPath; op.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR; if ((0 == SHFileOperation(&op)) && (!op.fAnyOperationsAborted)) bStatus = TRUE; } return bStatus; } #if defined (TCMOUNT) || defined (VOLFORMAT) /*********************************************************************/ static BOOL GenerateRandomString (HWND hwndDlg, LPTSTR szName, DWORD maxCharsCount) { BOOL bRet = FALSE; int alreadyInitialized = 0; if (RandinitWithCheck (&alreadyInitialized) != ERR_SUCCESS) { handleError (hwndDlg, (CryptoAPILastError == ERROR_SUCCESS)? ERR_RAND_INIT_FAILED : ERR_CAPI_INIT_FAILED, SRC_POS); } else { BYTE* indexes = (BYTE*) malloc (maxCharsCount + 1); bRet = RandgetBytesFull (hwndDlg, indexes, maxCharsCount + 1, TRUE, TRUE); if (bRet) { - static LPCTSTR chars = _T("0123456789@#$%^&_-*abcdefghijklmnopqrstuvwxyz"); + static LPCTSTR chars = _T("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_"); DWORD i, charsLen = (DWORD) _tcslen (chars); DWORD effectiveLen = (indexes[0] % (64 - 16)) + 16; // random length between 16 to 64 effectiveLen = (effectiveLen > maxCharsCount)? maxCharsCount : effectiveLen; for (i = 0; i < effectiveLen; i++) { szName[i] = chars[indexes[i + 1] % charsLen]; } szName[effectiveLen] = 0; } burn (indexes, maxCharsCount + 1); free (indexes); /* If RNG was not initialized before us, then stop it in order to * stop the fast poll thread which consumes CPU. Next time a critical operation * that requires RNG is performed, it will be initialized again. * * We do this because since the addition of secure desktop support, every time * secure desktop is displayed, the RNG fast poll thread was started even if the * user will never perform any critical operation that requires random bytes. */ if (!alreadyInitialized) { RandStop (FALSE); } } return bRet; } @@ -14070,260 +13896,308 @@ typedef struct // This thread checks if VeraCrypt secure desktop is the one that has user input // and if it is not then it will call SwitchDesktop to make it the input desktop static unsigned int __stdcall SecureDesktopMonitoringThread( LPVOID lpThreadParameter ) { SecureDesktopMonitoringThreadParam* pMonitorParam = (SecureDesktopMonitoringThreadParam*) lpThreadParameter; if (pMonitorParam) { HANDLE hStopEvent = pMonitorParam->hStopEvent; LPCWSTR szVCDesktopName = pMonitorParam->szVCDesktopName; HDESK hVcDesktop = pMonitorParam->hVcDesktop; // loop until the stop event is signaled while (WaitForSingleObject (hStopEvent, SECUREDESKTOP_MONOTIR_PERIOD) == WAIT_TIMEOUT) { // check that our secure desktop is still the input desktop // otherwise, switch to it BOOL bPerformSwitch = FALSE; HDESK currentDesk = OpenInputDesktop (0, FALSE, GENERIC_READ); if (currentDesk) { LPWSTR szName = NULL; DWORD dwLen = 0; if (!GetUserObjectInformation (currentDesk, UOI_NAME, NULL, 0, &dwLen)) { szName = (LPWSTR) malloc (dwLen); if (szName) { if (GetUserObjectInformation (currentDesk, UOI_NAME, szName, dwLen, &dwLen)) { - if (0 != _wcsicmp (szName, szVCDesktopName)) + if (0 == _wcsicmp(szName, L"Default")) // default input desktop for the interactive window station + bPerformSwitch = TRUE; + else if (0 != _wcsicmp (szName, szVCDesktopName)) bPerformSwitch = TRUE; } free (szName); } } CloseDesktop (currentDesk); } if (bPerformSwitch) SwitchDesktop (hVcDesktop); } } return 0; } static unsigned int __stdcall SecureDesktopThread( LPVOID lpThreadParameter ) { HANDLE hMonitoringThread = NULL; unsigned int monitoringThreadID = 0; SecureDesktopThreadParam* pParam = (SecureDesktopThreadParam*) lpThreadParameter; SecureDesktopMonitoringThreadParam monitorParam; BOOL bNewDesktopSet = FALSE; + HDESK hSecureDesk; + DWORD desktopAccess = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS; - // wait for SwitchDesktop to succeed before using it for current thread - while (true) + hSecureDesk = CreateDesktop (pParam->szDesktopName, NULL, NULL, 0, desktopAccess, NULL); + if (!hSecureDesk) { - if (SwitchDesktop (pParam->hDesk)) - { - break; - } - Sleep (SECUREDESKTOP_MONOTIR_PERIOD); + return 0; } + + StringCbCopy(SecureDesktopName, sizeof (SecureDesktopName), pParam->szDesktopName); + pParam->hDesk = hSecureDesk; - bNewDesktopSet = SetThreadDesktop (pParam->hDesk); + bNewDesktopSet = SetThreadDesktop (hSecureDesk); if (bNewDesktopSet) { + // call ImmDisableIME from imm32.dll to disable IME since it can create issue with secure desktop + // cf: https://keepass.info/help/kb/sec_desk.html#ime + HMODULE hImmDll = LoadLibraryEx (L"imm32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + if (hImmDll) + { + typedef BOOL (WINAPI *ImmDisableIME_t)(DWORD); + ImmDisableIME_t ImmDisableIME = (ImmDisableIME_t) GetProcAddress (hImmDll, "ImmDisableIME"); + if (ImmDisableIME) + { + ImmDisableIME (0); + } + } + + // wait for SwitchDesktop to succeed before using it for current thread + while (true) + { + if (SwitchDesktop (hSecureDesk)) + { + break; + } + Sleep (SECUREDESKTOP_MONOTIR_PERIOD); + } + // create the thread that will ensure that VeraCrypt secure desktop has always user input // this is done only if the stop event is created successfully HANDLE hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL); if (hStopEvent) { monitorParam.szVCDesktopName = pParam->szDesktopName; - monitorParam.hVcDesktop = pParam->hDesk; + monitorParam.hVcDesktop = hSecureDesk; monitorParam.hStopEvent = hStopEvent; hMonitoringThread = (HANDLE) _beginthreadex (NULL, 0, SecureDesktopMonitoringThread, (LPVOID) &monitorParam, 0, &monitoringThreadID); } pParam->retValue = DialogBoxParamW (pParam->hInstance, pParam->lpTemplateName, NULL, pParam->lpDialogFunc, pParam->dwInitParam); if (hMonitoringThread) { // notify the monitoring thread to stop SetEvent(hStopEvent); WaitForSingleObject (hMonitoringThread, INFINITE); CloseHandle (hMonitoringThread); } if (hStopEvent) { CloseHandle (hStopEvent); } pParam->bDlgDisplayed = TRUE; + + // free imm32.dll handle + if (hImmDll) + { + FreeLibrary (hImmDll); + } } else { pParam->bDlgDisplayed = FALSE; } return 0; } static void GetCtfMonProcessIdList (map<DWORD, BOOL>& processIdList) { HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL); PROCESSENTRY32 pEntry; BOOL hRes; pEntry.dwSize = sizeof (pEntry); processIdList.clear(); hRes = Process32First(hSnapShot, &pEntry); while (hRes) { LPTSTR szFileName = PathFindFileName (pEntry.szExeFile); if (_wcsicmp(szFileName, L"ctfmon.exe") == 0) { processIdList[pEntry.th32ProcessID] = TRUE; } hRes = Process32Next(hSnapShot, &pEntry); } CloseHandle(hSnapShot); } static void KillProcess (DWORD dwProcessId) { HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, dwProcessId); if (hProcess != NULL) { TerminateProcess(hProcess, (UINT) -1); CloseHandle(hProcess); } } INT_PTR SecureDesktopDialogBoxParam( HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) { TCHAR szDesktopName[65] = {0}; BOOL bSuccess = FALSE; INT_PTR retValue = 0; BOOL bEffectiveUseSecureDesktop = bCmdUseSecureDesktopValid? bCmdUseSecureDesktop : bUseSecureDesktop; if (bEffectiveUseSecureDesktop && !IsThreadInSecureDesktop(GetCurrentThreadId())) { + BOOL bRandomNameGenerated = FALSE; + HDESK existedDesk = NULL; EnterCriticalSection (&csSecureDesktop); bSecureDesktopOngoing = TRUE; finally_do ({ bSecureDesktopOngoing = FALSE; LeaveCriticalSection (&csSecureDesktop); }); - if (GenerateRandomString (hWndParent, szDesktopName, 64)) + // ensure that the randomly generated name is not already used + do + { + if (existedDesk) + { + CloseDesktop (existedDesk); + existedDesk = NULL; + } + if (GenerateRandomString (hWndParent, szDesktopName, 64)) + { + existedDesk = OpenDesktop (szDesktopName, 0, FALSE, GENERIC_READ); + if (!existedDesk) + { + bRandomNameGenerated = TRUE; + } + } + } while (existedDesk); + + if (bRandomNameGenerated) { map<DWORD, BOOL> ctfmonBeforeList, ctfmonAfterList; - DWORD desktopAccess = DESKTOP_CREATEMENU | DESKTOP_CREATEWINDOW | DESKTOP_READOBJECTS | DESKTOP_SWITCHDESKTOP | DESKTOP_WRITEOBJECTS; - HDESK hSecureDesk; - HDESK hOriginalDesk = GetThreadDesktop (GetCurrentThreadId()); + HDESK hOriginalDesk = NULL; + SecureDesktopThreadParam param; - HDESK hInputDesk = NULL; // wait for the input desktop to be available before switching to // secure desktop. Under Windows 10, the user session can be started // in the background even before the user has authenticated and in this // case, we wait for the user to be really authenticated before starting // secure desktop mechanism - while (!(hInputDesk = OpenInputDesktop (0, TRUE, GENERIC_READ))) + while (!(hOriginalDesk = OpenInputDesktop (0, TRUE, GENERIC_ALL))) { Sleep (SECUREDESKTOP_MONOTIR_PERIOD); } - - CloseDesktop (hInputDesk); // get the initial list of ctfmon.exe processes before creating new desktop GetCtfMonProcessIdList (ctfmonBeforeList); - hSecureDesk = CreateDesktop (szDesktopName, NULL, NULL, 0, desktopAccess, NULL); - if (hSecureDesk) + param.hDesk = NULL; + param.szDesktopName = szDesktopName; + param.hInstance = hInstance; + param.lpTemplateName = lpTemplateName; + param.lpDialogFunc = lpDialogFunc; + param.dwInitParam = dwInitParam; + param.retValue = 0; + param.bDlgDisplayed = FALSE; + + // use _beginthreadex instead of CreateThread because lpDialogFunc may be using the C runtime library + HANDLE hThread = (HANDLE) _beginthreadex (NULL, 0, SecureDesktopThread, (LPVOID) ¶m, 0, NULL); + if (hThread) { - SecureDesktopThreadParam param; - - param.hDesk = hSecureDesk; - param.szDesktopName = szDesktopName; - param.hInstance = hInstance; - param.lpTemplateName = lpTemplateName; - param.lpDialogFunc = lpDialogFunc; - param.dwInitParam = dwInitParam; - param.retValue = 0; - param.bDlgDisplayed = FALSE; - - // use _beginthreadex instead of CreateThread because lpDialogFunc may be using the C runtime library - HANDLE hThread = (HANDLE) _beginthreadex (NULL, 0, SecureDesktopThread, (LPVOID) ¶m, 0, NULL); - if (hThread) - { - StringCbCopy(SecureDesktopName, sizeof (SecureDesktopName), szDesktopName); + WaitForSingleObject (hThread, INFINITE); + CloseHandle (hThread); - WaitForSingleObject (hThread, INFINITE); - CloseHandle (hThread); + if (param.bDlgDisplayed) + { + // dialog box was indeed displayed in Secure Desktop + retValue = param.retValue; + bSuccess = TRUE; - if (param.bDlgDisplayed) + // switch back to the original desktop + while (!SwitchDesktop (hOriginalDesk)) { - // dialog box was indeed displayed in Secure Desktop - retValue = param.retValue; - bSuccess = TRUE; + Sleep (SECUREDESKTOP_MONOTIR_PERIOD); } - // switch back to original desktop - SwitchDesktop (hOriginalDesk); + SetThreadDesktop (hOriginalDesk); } - CloseDesktop (hSecureDesk); + if (param.hDesk) + { + CloseDesktop (param.hDesk); + } + } - // get the new list of ctfmon.exe processes in order to find the ID of the - // ctfmon.exe instance that corresponds to the desktop we create so that - // we can kill it, otherwise it would remain running - GetCtfMonProcessIdList (ctfmonAfterList); + // get the new list of ctfmon.exe processes in order to find the ID of the + // ctfmon.exe instance that corresponds to the desktop we create so that + // we can kill it, otherwise it would remain running + GetCtfMonProcessIdList (ctfmonAfterList); - for (map<DWORD, BOOL>::iterator It = ctfmonAfterList.begin(); - It != ctfmonAfterList.end(); It++) + for (map<DWORD, BOOL>::iterator It = ctfmonAfterList.begin(); + It != ctfmonAfterList.end(); It++) + { + if (ctfmonBeforeList[It->first] != TRUE) { - if (ctfmonBeforeList[It->first] != TRUE) - { - // Kill process - KillProcess (It->first); - } + // Kill process + KillProcess (It->first); } } CloseDesktop(hOriginalDesk); burn (szDesktopName, sizeof (szDesktopName)); } } if (!bSuccess) { // fallback to displaying in normal desktop retValue = DialogBoxParamW (hInstance, lpTemplateName, hWndParent, lpDialogFunc, dwInitParam); } return retValue; } #endif void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined) { HKEY hkey; BOOL bInstallPathDetermined = FALSE; wchar_t path[MAX_PATH+20]; ITEMIDLIST *itemList; memset (szInstallPath, 0, cchSize * sizeof (wchar_t)); // Determine if VeraCrypt is already installed and try to determine its "Program Files" location if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", 0, KEY_READ | KEY_WOW64_32KEY, &hkey) == ERROR_SUCCESS) @@ -14368,239 +14242,343 @@ void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, B if (Is64BitOs()) { // Use a unified default installation path (registry redirection of %ProgramFiles% does not work if the installation path is user-selectable) wstring s = path; size_t p = s.find (L" (x86)"); if (p != wstring::npos) { s = s.substr (0, p); if (_waccess (s.c_str(), 0) != -1) StringCbCopyW (path, sizeof (path), s.c_str()); } } StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\"); StringCbCopyW (szInstallPath, cchSize, path); } // Make sure the path ends with a backslash if (szInstallPath [wcslen (szInstallPath) - 1] != L'\\') { StringCbCatW (szInstallPath, cchSize, L"\\"); } if (pbInstallPathDetermined) *pbInstallPathDetermined = bInstallPathDetermined; } BOOL GetSetupconfigLocation (wchar_t* path, DWORD cchSize) { - wchar_t szShell32Path[MAX_PATH] = {0}; - HMODULE hShell32 = NULL; BOOL bResult = FALSE; path[0] = 0; - if (GetSystemDirectory(szShell32Path, MAX_PATH)) - StringCchCatW (szShell32Path, MAX_PATH, L"\\Shell32.dll"); - else - StringCchCopyW (szShell32Path, MAX_PATH, L"C:\\Windows\\System32\\Shell32.dll"); - - hShell32 = LoadLibrary (szShell32Path); - if (hShell32) + wchar_t* pszUsersPath = NULL; + if (S_OK == SHGetKnownFolderPath (FOLDERID_UserProfiles, 0, NULL, &pszUsersPath)) { - SHGETKNOWNFOLDERPATH SHGetKnownFolderPathFn = (SHGETKNOWNFOLDERPATH) GetProcAddress (hShell32, "SHGetKnownFolderPath"); - if (SHGetKnownFolderPathFn) - { - wchar_t* pszUsersPath = NULL; - if (S_OK == SHGetKnownFolderPathFn (FOLDERID_UserProfiles, 0, NULL, &pszUsersPath)) - { - StringCchPrintfW (path, cchSize, L"%s\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", pszUsersPath); - CoTaskMemFree (pszUsersPath); - bResult = TRUE; - } - } - FreeLibrary (hShell32); + StringCchPrintfW (path, cchSize, L"%s\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", pszUsersPath); + CoTaskMemFree (pszUsersPath); + bResult = TRUE; } if (!bResult && CurrentOSMajor >= 10) { - StringCchPrintfW (path, cchSize, L"%c:\\Users\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", szShell32Path[0]); + wchar_t szSys32Path[MAX_PATH]; + if (!GetSystemDirectory (szSys32Path, ARRAYSIZE (szSys32Path))) + { + StringCchCopy(szSys32Path, ARRAYSIZE (szSys32Path), L"C:\\Windows\\System32"); + } + StringCchPrintfW (path, cchSize, L"%c:\\Users\\Default\\AppData\\Local\\Microsoft\\Windows\\WSUS\\", szSys32Path[0]); bResult = TRUE; } return bResult; } BOOL BufferHasPattern (const unsigned char* buffer, size_t bufferLen, const void* pattern, size_t patternLen) { BOOL bRet = FALSE; if (patternLen <= bufferLen) { size_t i; for (i = 0; i <= (bufferLen - patternLen); ++i) { if (memcmp (&buffer[i], pattern, patternLen) == 0) { bRet = TRUE; break; } } } return bRet; } -/* Implementation borrowed from KeePassXC source code (https://github.com/keepassxreboot/keepassxc/blob/release/2.4.0/src/core/Bootstrap.cpp#L150) +/* Implementation borrowed from KeePassXC source code (https://github.com/keepassxreboot/keepassxc/blob/2.7.8/src/core/Bootstrap.cpp#L121) * * Reduce current user acess rights for this process to the minimum in order to forbid non-admin users from reading the process memory. + * Restrict access to changing DACL's after the process is started. This prevents the creator of veracrypt process from simply adding + * the permission to read memory back to the DACL list. */ -BOOL EnableProcessProtection() +BOOL ActivateMemoryProtection() { BOOL bSuccess = FALSE; // Process token and user HANDLE hToken = NULL; PTOKEN_USER pTokenUser = NULL; DWORD cbBufferSize = 0; + PSID pOwnerRightsSid = NULL; + DWORD pOwnerRightsSidSize = SECURITY_MAX_SID_SIZE; // Access control list PACL pACL = NULL; DWORD cbACL = 0; // Acces mask DWORD dwAccessMask = SYNCHRONIZE | PROCESS_QUERY_LIMITED_INFORMATION | PROCESS_TERMINATE; // same as protected process - + + if (MemoryProtectionActivated) + return TRUE; + if (IsAdmin ()) { // if we are running elevated, we allow CreateProcessXXX calls alongside PROCESS_DUP_HANDLE and PROCESS_QUERY_INFORMATION in order to be able // to implement secure way to open URLs (cf RunAsDesktopUser) // we are still protecting against memory access from non-admon processes dwAccessMask |= PROCESS_CREATE_PROCESS | PROCESS_DUP_HANDLE | PROCESS_QUERY_INFORMATION; } // Open the access token associated with the calling process if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) { goto Cleanup; } // Retrieve the token information in a TOKEN_USER structure GetTokenInformation(hToken, TokenUser, NULL, 0, &cbBufferSize); pTokenUser = (PTOKEN_USER) HeapAlloc(GetProcessHeap(), 0, cbBufferSize); if (pTokenUser == NULL) { goto Cleanup; } if (!GetTokenInformation(hToken, TokenUser, pTokenUser, cbBufferSize, &cbBufferSize)) { goto Cleanup; } if (!IsValidSid(pTokenUser->User.Sid)) { goto Cleanup; } + // Retrieve CreaterOwnerRights SID + pOwnerRightsSid = (PSID) HeapAlloc(GetProcessHeap(), 0, pOwnerRightsSidSize); + if (pOwnerRightsSid == NULL) { + goto Cleanup; + } + + if (!CreateWellKnownSid(WinCreatorOwnerRightsSid, NULL, pOwnerRightsSid, &pOwnerRightsSidSize)) { + goto Cleanup; + } + // Calculate the amount of memory that must be allocated for the DACL - cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid); + cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid) + + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pOwnerRightsSid); // Create and initialize an ACL pACL = (PACL) HeapAlloc(GetProcessHeap(), 0, cbACL); if (pACL == NULL) { goto Cleanup; } if (!InitializeAcl(pACL, cbACL, ACL_REVISION)) { goto Cleanup; } // Add allowed access control entries, everything else is denied if (!AddAccessAllowedAce( pACL, ACL_REVISION, dwAccessMask, pTokenUser->User.Sid // pointer to the trustee's SID )) { goto Cleanup; } + // Explicitly set "Process Owner" rights to Read Only. The default is Full Control. + if (!AddAccessAllowedAce( + pACL, + ACL_REVISION, + READ_CONTROL, + pOwnerRightsSid + )) { + goto Cleanup; + } + + // Set discretionary access control list bSuccess = (ERROR_SUCCESS == SetSecurityInfo(GetCurrentProcess(), // object handle SE_KERNEL_OBJECT, // type of object DACL_SECURITY_INFORMATION, // change only the objects DACL NULL, NULL, // do not change owner or group pACL, // DACL specified NULL // do not change SACL ))? TRUE: FALSE; + if (bSuccess) + MemoryProtectionActivated = TRUE; + Cleanup: if (pACL != NULL) { HeapFree(GetProcessHeap(), 0, pACL); } + if (pOwnerRightsSid != NULL) { + HeapFree(GetProcessHeap(), 0, pOwnerRightsSid); + } if (pTokenUser != NULL) { HeapFree(GetProcessHeap(), 0, pTokenUser); } if (hToken != NULL) { CloseHandle(hToken); } return bSuccess; } +// define missing structures Windows 8 +#if (_WIN32_WINNT < 0x0602) + +typedef struct _PROCESS_MITIGATION_ASLR_POLICY { + union { + DWORD Flags; + struct { + DWORD EnableBottomUpRandomization : 1; + DWORD EnableForceRelocateImages : 1; + DWORD EnableHighEntropy : 1; + DWORD DisallowStrippedImages : 1; + DWORD ReservedFlags : 28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_MITIGATION_ASLR_POLICY, *PPROCESS_MITIGATION_ASLR_POLICY; + +typedef struct _PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY { + union { + DWORD Flags; + struct { + DWORD DisableExtensionPoints : 1; + DWORD ReservedFlags : 31; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY, *PPROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY; + +typedef struct _PROCESS_MITIGATION_DYNAMIC_CODE_POLICY { + union { + DWORD Flags; + struct { + DWORD ProhibitDynamicCode : 1; + DWORD AllowThreadOptOut : 1; + DWORD AllowRemoteDowngrade : 1; + DWORD AuditProhibitDynamicCode : 1; + DWORD ReservedFlags : 28; + } DUMMYSTRUCTNAME; + } DUMMYUNIONNAME; +} PROCESS_MITIGATION_DYNAMIC_CODE_POLICY, *PPROCESS_MITIGATION_DYNAMIC_CODE_POLICY; + +typedef enum _PROCESS_MITIGATION_POLICY { + ProcessDEPPolicy, + ProcessASLRPolicy, + ProcessDynamicCodePolicy, + ProcessStrictHandleCheckPolicy, + ProcessSystemCallDisablePolicy, + ProcessMitigationOptionsMask, + ProcessExtensionPointDisablePolicy, + ProcessControlFlowGuardPolicy, + ProcessSignaturePolicy, + ProcessFontDisablePolicy, + ProcessImageLoadPolicy, + ProcessSystemCallFilterPolicy, + ProcessPayloadRestrictionPolicy, + ProcessChildProcessPolicy, + ProcessSideChannelIsolationPolicy, + ProcessUserShadowStackPolicy, + MaxProcessMitigationPolicy +} PROCESS_MITIGATION_POLICY, *PPROCESS_MITIGATION_POLICY; + +#endif + +void ActivateProcessMitigations() +{ + // we load the function pointer of SetProcessMitigationPolicy dynamically because we are building with Windows 7 SDK that does not have the definition of this function + typedef BOOL (WINAPI *SetProcessMitigationPolicyFunc) (PROCESS_MITIGATION_POLICY MitigationPolicy, PVOID lpBuffer, SIZE_T dwLength); + SetProcessMitigationPolicyFunc SetProcessMitigationPolicyPtr = (SetProcessMitigationPolicyFunc) GetProcAddress (GetModuleHandle (L"kernel32.dll"), "SetProcessMitigationPolicy"); + if (SetProcessMitigationPolicyPtr) + { + PROCESS_MITIGATION_ASLR_POLICY aslrPolicy = { 0 }; + PROCESS_MITIGATION_DYNAMIC_CODE_POLICY dynCodePolicy = { 0 }; + PROCESS_MITIGATION_EXTENSION_POINT_DISABLE_POLICY extensionPointDisablePolicy = { 0 }; + + aslrPolicy.EnableBottomUpRandomization = TRUE; + aslrPolicy.EnableForceRelocateImages = TRUE; + aslrPolicy.EnableHighEntropy = TRUE; + + dynCodePolicy.ProhibitDynamicCode = TRUE; + + extensionPointDisablePolicy.DisableExtensionPoints = TRUE; + + SetProcessMitigationPolicyPtr (ProcessASLRPolicy, &aslrPolicy, sizeof (aslrPolicy)); + SetProcessMitigationPolicyPtr (ProcessDynamicCodePolicy, &dynCodePolicy, sizeof (dynCodePolicy)); + SetProcessMitigationPolicyPtr (ProcessExtensionPointDisablePolicy, &extensionPointDisablePolicy, sizeof (extensionPointDisablePolicy)); + } +} + // Based on sample code from: // https://blogs.msdn.microsoft.com/aaron_margosis/2009/06/06/faq-how-do-i-start-a-program-as-the-desktop-user-from-an-elevated-app/ // start a program non-elevated as the desktop user from an elevated app static bool RunAsDesktopUser( __in const wchar_t * szApp, __in wchar_t * szCmdLine) { HANDLE hThreadToken = NULL, hShellProcess = NULL, hShellProcessToken = NULL, hPrimaryToken = NULL; HWND hwnd = NULL; DWORD dwPID = 0; BOOL ret; DWORD dwLastErr; STARTUPINFOW si; PROCESS_INFORMATION pi; bool retval = false; SecureZeroMemory(&si, sizeof(si)); SecureZeroMemory(&pi, sizeof(pi)); si.cb = sizeof(si); - // locate CreateProcessWithTokenW in Advapi32.dll - if (!CreateProcessWithTokenWPtr) - { - return false; - } - if (!ImpersonateSelf (SecurityImpersonation)) { return false; } if (!OpenThreadToken (GetCurrentThread(), TOKEN_ADJUST_PRIVILEGES, TRUE, &hThreadToken)) { return false; } else { TOKEN_PRIVILEGES tkp; tkp.PrivilegeCount = 1; LookupPrivilegeValueW(NULL, SE_INCREASE_QUOTA_NAME, &tkp.Privileges[0].Luid); tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED; if (!SetThreadToken(NULL, NULL)) { goto cleanup; } AdjustTokenPrivileges(hThreadToken, FALSE, &tkp, 0, NULL, NULL); dwLastErr = GetLastError(); if (ERROR_SUCCESS != dwLastErr) { goto cleanup; } } // From this point down, we have handles to close, so make sure to clean up. @@ -14624,61 +14602,61 @@ static bool RunAsDesktopUser( goto cleanup; } // Open the desktop shell process in order to query it (get the token) hShellProcess = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, dwPID); if (!hShellProcess) { dwLastErr = GetLastError(); goto cleanup; } // Get the process token of the desktop shell. ret = OpenProcessToken(hShellProcess, TOKEN_DUPLICATE, &hShellProcessToken); if (!ret) { dwLastErr = GetLastError(); goto cleanup; } // Duplicate the shell's process token to get a primary token. // Based on experimentation, this is the minimal set of rights required for CreateProcessWithTokenW (contrary to current documentation). const DWORD dwTokenRights = TOKEN_QUERY | TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_ADJUST_DEFAULT | TOKEN_ADJUST_SESSIONID; ret = DuplicateTokenEx(hShellProcessToken, dwTokenRights, NULL, SecurityImpersonation, TokenPrimary, &hPrimaryToken); if (!ret) { dwLastErr = GetLastError(); goto cleanup; } // Start the target process with the new token. - ret = CreateProcessWithTokenWPtr( + ret = CreateProcessWithTokenW( hPrimaryToken, 0, szApp, szCmdLine, 0, NULL, NULL, &si, &pi); if (!ret) { dwLastErr = GetLastError(); goto cleanup; } // Make sure to close HANDLEs return in the PROCESS_INFORMATION. CloseHandle(pi.hProcess); CloseHandle(pi.hThread); retval = true; cleanup: // Clean up resources if (hShellProcessToken) CloseHandle(hShellProcessToken); if (hPrimaryToken) CloseHandle(hPrimaryToken); if (hShellProcess) CloseHandle(hShellProcess); if (hThreadToken) CloseHandle(hThreadToken); if (!RevertToSelf()) return false; @@ -14698,190 +14676,190 @@ BOOL IsElevated() if(OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken)) { if(GetTokenInformation(hToken, TokenElevation, &tokenInformation, sizeof(TOKEN_ELEVATION), &dwSize)) { if (tokenInformation.TokenIsElevated) bReturn = TRUE; } CloseHandle(hToken); } return bReturn; } // Based on code from: // https://github.com/microsoft/Windows-classic-samples/blob/main/Samples/Win7Samples/winui/shell/appplatform/ExecInExplorer/ExecInExplorer.cpp HRESULT GetShellViewForDesktop(REFIID riid, void **ppv) { *ppv = NULL; IShellWindows *psw; HRESULT hr = CoCreateInstance(CLSID_ShellWindows, NULL, CLSCTX_LOCAL_SERVER, IID_PPV_ARGS(&psw)); if (SUCCEEDED(hr)) { HWND hwnd; IDispatch* pdisp; VARIANT vEmpty = {}; // VT_EMPTY if (S_OK == psw->FindWindowSW(&vEmpty, &vEmpty, SWC_DESKTOP, (long*)&hwnd, SWFO_NEEDDISPATCH, &pdisp)) { IShellBrowser *psb; - hr = IUnknown_QueryServicePtr(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb)); + hr = IUnknown_QueryService(pdisp, SID_STopLevelBrowser, IID_PPV_ARGS(&psb)); if (SUCCEEDED(hr)) { IShellView *psv; hr = psb->QueryActiveShellView(&psv); if (SUCCEEDED(hr)) { hr = psv->QueryInterface(riid, ppv); psv->Release(); } psb->Release(); } pdisp->Release(); } else { hr = E_FAIL; } psw->Release(); } return hr; } HRESULT GetShellDispatchFromView(IShellView *psv, REFIID riid, void **ppv) { *ppv = NULL; IDispatch *pdispBackground; HRESULT hr = psv->GetItemObject(SVGIO_BACKGROUND, IID_PPV_ARGS(&pdispBackground)); if (SUCCEEDED(hr)) { IShellFolderViewDual *psfvd; hr = pdispBackground->QueryInterface(IID_PPV_ARGS(&psfvd)); if (SUCCEEDED(hr)) { IDispatch *pdisp; hr = psfvd->get_Application(&pdisp); if (SUCCEEDED(hr)) { hr = pdisp->QueryInterface(riid, ppv); pdisp->Release(); } psfvd->Release(); } pdispBackground->Release(); } return hr; } HRESULT ShellExecInExplorerProcess(PCWSTR pszFile) { IShellView *psv; - CoInitialize(NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); HRESULT hr = GetShellViewForDesktop(IID_PPV_ARGS(&psv)); if (SUCCEEDED(hr)) { IShellDispatch2 *psd; hr = GetShellDispatchFromView(psv, IID_PPV_ARGS(&psd)); if (SUCCEEDED(hr)) { BSTR bstrFile = SysAllocString(pszFile); hr = bstrFile ? S_OK : E_OUTOFMEMORY; if (SUCCEEDED(hr)) { VARIANT vtEmpty = {}; // VT_EMPTY hr = psd->ShellExecuteW(bstrFile, vtEmpty, vtEmpty, vtEmpty, vtEmpty); SysFreeString(bstrFile); } psd->Release(); } psv->Release(); } CoUninitialize(); return hr; } // This function always loads a URL in a non-privileged mode // If current process has admin privileges, we execute the command "rundll32 url.dll,FileProtocolHandler URL" as non-elevated // Use this security mechanism only starting from Windows Vista and only if we can get the window of the Shell's desktop since // we rely on the Shell to be already running in a non-privileges mode. If the Shell is not running or if it has been modified, // then we can't protect the user in such non standard environment void SafeOpenURL (LPCWSTR szUrl) { BOOL bFallback = TRUE; - if (IsOSAtLeast (WIN_VISTA) && IsUacSupported() && IsAdmin () && IsElevated() && GetShellWindow()) + if (IsUacSupported() && IsAdmin () && IsElevated() && GetShellWindow()) { WCHAR szRunDllPath[TC_MAX_PATH]; WCHAR szUrlDllPath[TC_MAX_PATH]; WCHAR szSystemPath[TC_MAX_PATH]; LPWSTR szCommandLine = new WCHAR[1024]; if (!GetSystemDirectory(szSystemPath, MAX_PATH)) StringCbCopyW(szSystemPath, sizeof(szSystemPath), L"C:\\Windows\\System32"); StringCbPrintfW(szRunDllPath, sizeof(szRunDllPath), L"%s\\%s", szSystemPath, L"rundll32.exe"); StringCbPrintfW(szUrlDllPath, sizeof(szUrlDllPath), L"%s\\%s", szSystemPath, L"url.dll"); StringCchPrintfW(szCommandLine, 1024, L"%s %s,FileProtocolHandler %s", szRunDllPath, szUrlDllPath, szUrl); if (RunAsDesktopUser (NULL, szCommandLine)) { bFallback = FALSE; } else { // fallback to IShellDispatch2::ShellExecuteW if (SUCCEEDED(ShellExecInExplorerProcess(szUrl))) { bFallback = FALSE; } } delete [] szCommandLine; } if (bFallback) { ShellExecuteW (NULL, L"open", szUrl, NULL, NULL, SW_SHOWNORMAL); } } #if !defined(SETUP) && defined(_WIN64) #define RtlGenRandom SystemFunction036 extern "C" BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed) { LARGE_INTEGER iSeed; SYSTEMTIME sysTime; - byte digest[WHIRLPOOL_DIGESTSIZE]; + uint8 digest[WHIRLPOOL_DIGESTSIZE]; WHIRLPOOL_CTX tctx; size_t count; while (cbRandSeed) { WHIRLPOOL_init (&tctx); // we hash current content of digest buffer which is uninitialized the first time WHIRLPOOL_add (digest, WHIRLPOOL_DIGESTSIZE, &tctx); // we use various time information as source of entropy GetSystemTime (&sysTime); WHIRLPOOL_add ((unsigned char *) &sysTime, sizeof(sysTime), &tctx); if (QueryPerformanceCounter (&iSeed)) WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); if (QueryPerformanceFrequency (&iSeed)) WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); /* use Windows random generator as entropy source */ if (RtlGenRandom (digest, sizeof (digest))) WHIRLPOOL_add (digest, sizeof(digest), &tctx); /* use JitterEntropy library to get good quality random bytes based on CPU timing jitter */ if (0 == jent_entropy_init ()) { struct rand_data *ec = jent_entropy_collector_alloc (1, 0); if (ec) { ssize_t rndLen = jent_read_entropy (ec, (char*) digest, sizeof (digest)); if (rndLen > 0) WHIRLPOOL_add (digest, (unsigned int) rndLen, &tctx); @@ -14922,123 +14900,103 @@ typedef enum BitLockerProtectionState { BL_State_FullyDecrypted = 0, BL_State_FullyEncrypted = 1, BL_State_EncryptionInProgress = 2, BL_State_DecryptionInProgress = 3, BL_State_EncryptionSuspended = 4, BL_State_DecryptionSuspended = 5, BL_State_FullyEncryptedWipeInProgress = 6, BL_State_FullyEncryptedWipeSuspended = 7 } BitLockerProtectionState; typedef HRESULT (WINAPI *SHCreateItemFromParsingNameFn)( PCWSTR pszPath, IBindCtx* pbc, REFIID riid, void** ppv ); typedef HRESULT (WINAPI *PSGetPropertyKeyFromNameFn)( _In_ PCWSTR pszName, _Out_ PROPERTYKEY* ppropkey); /* Code derived from https://stackoverflow.com/questions/23841973/how-to-tell-if-drive-is-bitlocker-encrypted-without-admin-privilege/47192128#47192128 */ BitLockerEncryptionStatus GetBitLockerEncryptionStatus(WCHAR driveLetter) { HRESULT hr; BitLockerEncryptionStatus blStatus = BL_Status_Unknown; - wchar_t szDllPath[MAX_PATH] = { 0 }; - HMODULE hShell32 = NULL; + wchar_t szDllPath[MAX_PATH] = { 0 }; + HMODULE hPropsys = NULL; - CoInitialize(NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (GetSystemDirectory(szDllPath, MAX_PATH)) - StringCchCatW(szDllPath, MAX_PATH, L"\\Shell32.dll"); + StringCchCatW(szDllPath, MAX_PATH, L"\\Propsys.dll"); else - StringCchCopyW(szDllPath, MAX_PATH, L"C:\\Windows\\System32\\Shell32.dll"); + StringCchCopyW(szDllPath, MAX_PATH, L"C:\\Windows\\System32\\Propsys.dll"); - hShell32 = LoadLibrary(szDllPath); - if (hShell32) + hPropsys = LoadLibrary(szDllPath); + if (hPropsys) { - SHCreateItemFromParsingNameFn SHCreateItemFromParsingNamePtr = (SHCreateItemFromParsingNameFn)GetProcAddress(hShell32, "SHCreateItemFromParsingName"); - if (SHCreateItemFromParsingNamePtr) + PSGetPropertyKeyFromNameFn PSGetPropertyKeyFromNamePtr = (PSGetPropertyKeyFromNameFn)GetProcAddress(hPropsys, "PSGetPropertyKeyFromName"); + if (PSGetPropertyKeyFromNamePtr) { - HMODULE hPropsys = NULL; - - if (GetSystemDirectory(szDllPath, MAX_PATH)) - StringCchCatW(szDllPath, MAX_PATH, L"\\Propsys.dll"); - else - StringCchCopyW(szDllPath, MAX_PATH, L"C:\\Windows\\System32\\Propsys.dll"); - - hPropsys = LoadLibrary(szDllPath); - if (hPropsys) - { - PSGetPropertyKeyFromNameFn PSGetPropertyKeyFromNamePtr = (PSGetPropertyKeyFromNameFn)GetProcAddress(hPropsys, "PSGetPropertyKeyFromName"); - if (PSGetPropertyKeyFromNamePtr) - { - WCHAR parsingName[3] = {driveLetter, L':', 0}; - IShellItem2* drive = NULL; - hr = SHCreateItemFromParsingNamePtr(parsingName, NULL, IID_PPV_ARGS(&drive)); + WCHAR parsingName[3] = {driveLetter, L':', 0}; + IShellItem2* drive = NULL; + hr = SHCreateItemFromParsingName(parsingName, NULL, IID_PPV_ARGS(&drive)); + if (SUCCEEDED(hr)) { + PROPERTYKEY pKey; + hr = PSGetPropertyKeyFromNamePtr(L"System.Volume.BitLockerProtection", &pKey); + if (SUCCEEDED(hr)) { + PROPVARIANT prop; + PropVariantInit(&prop); + hr = drive->GetProperty(pKey, &prop); if (SUCCEEDED(hr)) { - PROPERTYKEY pKey; - hr = PSGetPropertyKeyFromNamePtr(L"System.Volume.BitLockerProtection", &pKey); - if (SUCCEEDED(hr)) { - PROPVARIANT prop; - PropVariantInit(&prop); - hr = drive->GetProperty(pKey, &prop); - if (SUCCEEDED(hr)) { - int status = prop.intVal; - if (status == BL_State_FullyEncrypted || status == BL_State_DecryptionInProgress || status == BL_State_DecryptionSuspended) - blStatus = BL_Status_Protected; - else - blStatus = BL_Status_Unprotected; - } - } + int status = prop.intVal; + if (status == BL_State_FullyEncrypted || status == BL_State_DecryptionInProgress || status == BL_State_DecryptionSuspended) + blStatus = BL_Status_Protected; + else + blStatus = BL_Status_Unprotected; } - if (drive) - drive->Release(); } - - FreeLibrary(hPropsys); } - } - else - { - blStatus = BL_Status_Unprotected; // before Vista, there was no Bitlocker + if (drive) + drive->Release(); } - FreeLibrary(hShell32); + FreeLibrary(hPropsys); } + CoUninitialize(); return blStatus; } //////////////////////////////////////////////////////////////////////////////////////// static CLIPFORMAT g_supportedFormats[] = { CF_UNICODETEXT, CF_TEXT, CF_OEMTEXT}; //************************************************************* // GenericDropTarget //************************************************************* GenericDropTarget::GenericDropTarget(CLIPFORMAT* pFormats, size_t count) : m_DropTargetWnd(NULL), m_dwRefCount(1), m_KeyState(0L), m_Data(NULL) { m_DropPoint.x = 0; m_DropPoint.y = 0; if (pFormats && count) { for (size_t i = 0; i < count; i++) { m_SupportedFormat.push_back (pFormats[i]); } } } GenericDropTarget::~GenericDropTarget() @@ -15393,60 +15351,87 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format) { EDITBALLOONTIP ebt; DWORD dwTextSize = (DWORD) wcslen (GetString ("PASSWORD_PASTED_TRUNCATED")) + 16; WCHAR* szErrorText = (WCHAR*) malloc (dwTextSize * sizeof (WCHAR)); StringCchPrintf (szErrorText, dwTextSize, GetString ("PASSWORD_PASTED_TRUNCATED"), maxLen); ebt.cbStruct = sizeof( EDITBALLOONTIP ); ebt.pszText = szErrorText; ebt.pszTitle = lpszTitle; ebt.ttiIcon = TTI_WARNING_LARGE; // tooltip warning icon SendMessage(hChild, EM_SHOWBALLOONTIP, 0, (LPARAM)&ebt); MessageBeep (0xFFFFFFFF); free (szErrorText); } } if (bFree) { burn (wszText, wlen * sizeof (WCHAR)); delete [] wszText; } } } } +// check if the PC is connected to the internet using INetworkListManager interface +BOOL IsInternetConnected() +{ + HRESULT hr; + BOOL isConnected = FALSE; + INetworkListManager* pNetworkListManager = nullptr; + + hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + if (SUCCEEDED(hr)) + { + hr = CoCreateInstance(CLSID_NetworkListManager, NULL, CLSCTX_ALL, IID_PPV_ARGS(&pNetworkListManager)); + if (SUCCEEDED(hr)) + { + VARIANT_BOOL isConnectedVariant; + hr = pNetworkListManager->get_IsConnectedToInternet(&isConnectedVariant); + if (SUCCEEDED(hr)) + { + isConnected = isConnectedVariant == VARIANT_TRUE; + } + pNetworkListManager->Release(); + } + CoUninitialize(); + } + + return isConnected; +} + /* * Query the status of Hibernate and Fast Startup */ typedef BOOLEAN (WINAPI *GetPwrCapabilitiesFn)( PSYSTEM_POWER_CAPABILITIES lpspc ); BOOL GetHibernateStatus (BOOL& bHibernateEnabled, BOOL& bHiberbootEnabled) { wchar_t szPowrProfPath[MAX_PATH] = {0}; HMODULE hPowrProf = NULL; BOOL bResult = FALSE; bHibernateEnabled = bHiberbootEnabled = FALSE; if (GetSystemDirectory(szPowrProfPath, MAX_PATH)) StringCchCatW (szPowrProfPath, MAX_PATH, L"\\PowrProf.dll"); else StringCchCopyW (szPowrProfPath, MAX_PATH, L"C:\\Windows\\System32\\PowrProf.dll"); hPowrProf = LoadLibrary (szPowrProfPath); if (hPowrProf) { GetPwrCapabilitiesFn GetPwrCapabilitiesPtr = (GetPwrCapabilitiesFn) GetProcAddress (hPowrProf, "GetPwrCapabilities"); if ( GetPwrCapabilitiesPtr) { SYSTEM_POWER_CAPABILITIES spc; BOOLEAN bRet = GetPwrCapabilitiesPtr (&spc); if (bRet) @@ -15501,61 +15486,61 @@ BOOL GetHibernateStatus (BOOL& bHibernateEnabled, BOOL& bHiberbootEnabled) BOOL IsTestSigningModeEnabled () { BOOL bEnabled = FALSE; NtQuerySystemInformationFn NtQuerySystemInformationPtr = (NtQuerySystemInformationFn) GetProcAddress (GetModuleHandle (L"ntdll.dll"), "NtQuerySystemInformation"); if(NtQuerySystemInformationPtr) { SYSTEM_CODEINTEGRITY_INFORMATION info = {0}; ULONG cbReturnedData = 0; info.Length = sizeof(info); if ( (NtQuerySystemInformationPtr((SYSTEM_INFORMATION_CLASS) SYSTEMCODEINTEGRITYINFORMATION, &info, sizeof(info), &cbReturnedData) >= 0) && (cbReturnedData == sizeof(info)) ) { if ((info.CodeIntegrityOptions & (CODEINTEGRITY_OPTION_TESTSIGN | CODEINTEGRITY_OPTION_ENABLED)) == (CODEINTEGRITY_OPTION_TESTSIGN | CODEINTEGRITY_OPTION_ENABLED)) { bEnabled = TRUE; } } } return bEnabled; } // Adapted from https://docs.microsoft.com/en-us/windows/win32/wmisdk/example-creating-a-wmi-application bool GetKbList (std::vector<std::wstring>& kbList) { HRESULT hres; kbList.clear(); // Initialize COM. - hres = CoInitialize(NULL); + hres = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (FAILED(hres)) { return false; } // Initialize hres = CoInitializeSecurity( NULL, -1, // COM negotiates service NULL, // Authentication services NULL, // Reserved RPC_C_AUTHN_LEVEL_DEFAULT, // authentication RPC_C_IMP_LEVEL_IMPERSONATE, // Impersonation NULL, // Authentication info EOAC_NONE, // Additional capabilities NULL // Reserved ); if (FAILED(hres)) { CoUninitialize(); return false; } // Obtain the initial locator to Windows Management // on a particular host computer. IWbemLocator *pLoc = 0; hres = CoCreateInstance( @@ -15716,31 +15701,81 @@ DWORD SendServiceNotification (DWORD dwNotificationCmd) { DWORD dwRet = ERROR_INVALID_PARAMETER; // We only support clearing keys on new device insertion if (VC_DRIVER_CONFIG_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION == dwNotificationCmd) { DWORD dwServiceControlCode = VC_SERVICE_CONTROL_BUILD_DEVICE_LIST; // send this control code to VeraCrypt SystemFavorites service SC_HANDLE hSCManager = OpenSCManager (NULL, NULL, SC_MANAGER_CONNECT); if (hSCManager != NULL) { SC_HANDLE hService = OpenService (hSCManager, TC_SYSTEM_FAVORITES_SERVICE_NAME, SERVICE_ALL_ACCESS); if (hService != NULL) { SERVICE_STATUS ss; if (ControlService (hService, dwServiceControlCode, &ss)) dwRet = ERROR_SUCCESS; else dwRet = GetLastError (); CloseServiceHandle (hService); } else dwRet = GetLastError (); CloseServiceHandle (hSCManager); } else dwRet = GetLastError (); } return dwRet; } -#endif // VC_COMREG
\ No newline at end of file + +DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize) +{ + DWORD dwRet = ERROR_INVALID_PARAMETER; + if (filePath && fileSize > 0) + { + // we set required privileges to speedup file creation before we create the file so that the file handle inherits the privileges + BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_MANAGE_VOLUME_NAME); + if (!bPrivilegesSet && !SetPrivilege(SE_MANAGE_VOLUME_NAME, TRUE)) + { + dwRet = GetLastError (); + } + else + { + HANDLE dev = CreateFile (filePath, GENERIC_WRITE | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL); + if (dev != INVALID_HANDLE_VALUE) + { + LARGE_INTEGER liSize; + liSize.QuadPart = fileSize; + // Preallocate the file with desired size + if (!SetFilePointerEx (dev, liSize, NULL, FILE_BEGIN) + || !SetEndOfFile (dev)) + { + dwRet = GetLastError (); + } + else + { + if (!SetFileValidData (dev, fileSize)) + { + dwRet = GetLastError (); + } + else + { + dwRet = ERROR_SUCCESS; + } + } + + FlushFileBuffers (dev); + CloseHandle (dev); + } + else + dwRet = GetLastError (); + + if (!bPrivilegesSet) + SetPrivilege(SE_MANAGE_VOLUME_NAME, FALSE); + } + } + + return dwRet; +} +#endif // VC_COMREG diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index 4a7e40c7..288daecd 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -300,112 +300,114 @@ void AbortProcess ( char *stringId ); void AbortProcessSilent ( void ); void *err_malloc ( size_t size ); char *err_strdup ( char *lpszText ); DWORD handleWin32Error ( HWND hwndDlg, const char* srcPos ); BOOL IsDiskReadError (DWORD error); BOOL IsDiskWriteError (DWORD error); BOOL IsDiskError (DWORD error); BOOL translateWin32Error ( wchar_t *lpszMsgBuf , int nWSizeOfBuf ); BOOL CALLBACK AboutDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); static BOOL CALLBACK StaticModelessWaitDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void DisplayStaticModelessWaitDlg (HWND parent); void CloseStaticModelessWaitDlg (void); BOOL IsButtonChecked ( HWND hButton ); void CheckButton ( HWND hButton ); void LeftPadString (wchar_t *szTmp, int len, int targetLen, wchar_t filler); void InitDialog ( HWND hwndDlg ); void ProcessPaintMessages (HWND hwnd, int maxMessagesToProcess); HDC CreateMemBitmap ( HINSTANCE hInstance , HWND hwnd , wchar_t *resource ); HBITMAP RenderBitmap ( wchar_t *resource , HWND hwndDest , int x , int y , int nWidth , int nHeight , BOOL bDirectRender , BOOL bKeepAspectRatio); LRESULT CALLBACK RedTick ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL RegisterRedTick ( HINSTANCE hInstance ); BOOL UnregisterRedTick ( HINSTANCE hInstance ); LRESULT CALLBACK SplashDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); void WaitCursor ( void ); void NormalCursor ( void ); void ArrowWaitCursor ( void ); void HandCursor (); void AddComboPair (HWND hComboBox, const wchar_t *lpszItem, int value); void SelectAlgo ( HWND hComboBox , int *nCipher ); void PopulateWipeModeCombo (HWND hComboBox, BOOL bNA, BOOL bInPlaceEncryption, BOOL bHeaderWipe); +HWND CreateToolTip(int toolID, HWND hDlg, const char* strID); wchar_t *GetWipeModeName (WipeAlgorithmId modeId); wchar_t *GetPathType (const wchar_t *path, BOOL bUpperCase, BOOL *bIsPartition); LRESULT CALLBACK CustomDlgProc ( HWND hwnd , UINT uMsg , WPARAM wParam , LPARAM lParam ); BOOL TCCreateMutex (volatile HANDLE *hMutex, wchar_t *name); void TCCloseMutex (volatile HANDLE *hMutex); BOOL MutexExistsOnSystem (wchar_t *name); BOOL CreateSysEncMutex (void); BOOL InstanceHasSysEncMutex (void); void CloseSysEncMutex (void); BOOL CreateNonSysInplaceEncMutex (void); BOOL InstanceHasNonSysInplaceEncMutex (void); void CloseNonSysInplaceEncMutex (void); BOOL NonSysInplaceEncInProgressElsewhere (void); BOOL CreateDriverSetupMutex (void); void CloseDriverSetupMutex (void); BOOL CreateAppSetupMutex (void); BOOL InstanceHasAppSetupMutex (void); void CloseAppSetupMutex (void); BOOL IsTrueCryptInstallerRunning (void); uint32 ReadDriverConfigurationFlags (); uint32 ReadServiceConfigurationFlags (); uint32 ReadEncryptionThreadPoolFreeCpuCountLimit (); +BOOL ReadMemoryProtectionConfig (); +BOOL WriteMemoryProtectionConfig (BOOL bEnable); BOOL LoadSysEncSettings (); int LoadNonSysInPlaceEncSettings (WipeAlgorithmId *wipeAlgorithm); void RemoveNonSysInPlaceEncNotifications (void); void SavePostInstallTasksSettings (int command); void DoPostInstallTasks (HWND hwndDlg); void InitOSVersionInfo (); void InitApp ( HINSTANCE hInstance, wchar_t *lpszCommandLine ); -void FinalizeApp (void); void InitHelpFileName (void); BOOL OpenDevice (const wchar_t *lpszPath, OPEN_TEST_STRUCT *driver, BOOL detectFilesystem, BOOL computeVolumeID); void NotifyDriverOfPortableMode (void); int GetAvailableFixedDisks ( HWND hComboBox , char *lpszRootPath ); int GetAvailableRemovables ( HWND hComboBox , char *lpszRootPath ); int IsSystemDevicePath (const wchar_t *path, HWND hwndDlg, BOOL bReliableRequired); int IsNonSysPartitionOnSysDrive (const wchar_t *path); BOOL CALLBACK RawDevicesDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); INT_PTR TextInfoDialogBox (int nID); BOOL CALLBACK TextInfoDialogBoxDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); char * GetLegalNotices (); BOOL CALLBACK BenchmarkDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); void UserEnrichRandomPool (HWND hwndDlg); BOOL CALLBACK KeyfileGeneratorDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK MultiChoiceDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); int DriverAttach ( void ); BOOL CALLBACK CipherTestDialogProc ( HWND hwndDlg , UINT uMsg , WPARAM wParam , LPARAM lParam ); void ResetCipherTest ( HWND hwndDlg , int idTestCipher ); void ResetCurrentDirectory (); -BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter); -BOOL BrowseDirectories (HWND hWnd, char *lpszTitle, wchar_t *dirName); +BOOL BrowseFiles (HWND hwndDlg, char *stringId, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode); +BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wchar_t *initialDir); void handleError ( HWND hwndDlg , int code, const char* srcPos ); BOOL CheckFileStreamWriteErrors (HWND hwndDlg, FILE *file, const wchar_t *fileName); void LocalizeDialog ( HWND hwnd, char *stringId ); void OpenVolumeExplorerWindow (int driveNo); static BOOL CALLBACK CloseVolumeExplorerWindowsEnum( HWND hwnd, LPARAM driveNo); BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo); BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue); BOOL CheckCapsLock (HWND hwnd, BOOL quiet); BOOL CheckFileExtension (wchar_t *fileName); void CorrectFileName (wchar_t* fileName); void CorrectURL (wchar_t* fileName); void IncreaseWrongPwdRetryCount (int count); void ResetWrongPwdRetryCount (void); BOOL WrongPwdRetryCountOverLimit (void); DWORD GetUsedLogicalDrives (void); int GetFirstAvailableDrive (); int GetLastAvailableDrive (); BOOL IsDriveAvailable (int driveNo); BOOL IsDeviceMounted (wchar_t *deviceName); int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced); void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap); int MountVolume (HWND hwndDlg, int driveNo, wchar_t *volumePath, Password *password, int pkcs5, int pim, BOOL cachePassword, BOOL cachePim, BOOL sharedAccess, const MountOptions* const mountOptions, BOOL quiet, BOOL bReportWrongPassword); BOOL UnmountVolume (HWND hwndDlg , int nDosDriveNo, BOOL forceUnmount); BOOL UnmountVolumeAfterFormatExCall (HWND hwndDlg, int nDosDriveNo); BOOL IsPasswordCacheEmpty (void); BOOL IsMountedVolumeID (BYTE volumeID[VOLUME_ID_SIZE]); BOOL IsMountedVolume (const wchar_t *volname); int GetMountedVolumeDriveNo (wchar_t *volname); BOOL IsAdmin (void); BOOL IsBuiltInAdmin (); @@ -486,139 +488,143 @@ int AskMultiChoice (void *strings[], BOOL bBold, HWND hwnd); BOOL ConfigWriteBegin (); BOOL ConfigWriteEnd (HWND hwnd); BOOL ConfigWriteString (char *configKey, char *configValue); BOOL ConfigWriteStringW (char *configKey, wchar_t *configValue); BOOL ConfigWriteInt (char *configKey, int configValue); int ConfigReadInt (char *configKey, int defaultValue); char *ConfigReadString (char *configKey, char *defaultValue, char *str, int maxLen); void ConfigReadCompareInt(char *configKey, int defaultValue, int* pOutputValue, BOOL bOnlyCheckModified, BOOL* pbModified); void ConfigReadCompareString (char *configKey, char *defaultValue, char *str, int maxLen, BOOL bOnlyCheckModified, BOOL *pbModified); void RestoreDefaultKeyFilesParam (void); BOOL LoadDefaultKeyFilesParam (void); void Debug (char *format, ...); void DebugMsgBox (char *format, ...); BOOL IsOSAtLeast (OSVersionEnum reqMinOS); BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack); BOOL IsSupportedOS (); BOOL Is64BitOs (); BOOL IsARM(); BOOL IsServerOS (); BOOL IsHiddenOSRunning (void); BOOL EnableWow64FsRedirection (BOOL enable); BOOL RestartComputer (BOOL bShutdown); void Applink (const char *dest); wchar_t *RelativePath2Absolute (wchar_t *szFileName); void HandleDriveNotReadyError (HWND hwnd); BOOL CALLBACK CloseTCWindowsEnum( HWND hwnd, LPARAM lParam); BOOL CALLBACK FindTCWindowEnum (HWND hwnd, LPARAM lParam); BYTE *MapResource (wchar_t *resourceType, int resourceId, PDWORD size); void InconsistencyResolved (char *msg); void ReportUnexpectedState (const char *techInfo); -BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, wchar_t *lpszFileName, size_t cbFileName, BOOL keepHistory); -BOOL SelectMultipleFilesNext (wchar_t *lpszFileName, size_t cbFileName); void OpenOnlineHelp (); BOOL GetPartitionInfo (const wchar_t *deviceName, PPARTITION_INFORMATION rpartInfo); BOOL GetDeviceInfo (const wchar_t *deviceName, DISK_PARTITION_INFO_STRUCT *info); BOOL GetDriveGeometry (const wchar_t *deviceName, PDISK_GEOMETRY_EX diskGeometry); BOOL GetPhysicalDriveGeometry (int driveNumber, PDISK_GEOMETRY diskGeometry); BOOL IsVolumeDeviceHosted (const wchar_t *lpszDiskFile); int CompensateXDPI (int val); int CompensateYDPI (int val); int CompensateDPIFont (int val); int GetTextGfxWidth (HWND hwndDlgItem, const wchar_t *text, HFONT hFont); int GetTextGfxHeight (HWND hwndDlgItem, const wchar_t *text, HFONT hFont); BOOL ToHyperlink (HWND hwndDlg, UINT ctrlId); BOOL ToCustHyperlink (HWND hwndDlg, UINT ctrlId, HFONT hFont); void DisableCloseButton (HWND hwndDlg); void EnableCloseButton (HWND hwndDlg); void ToBootPwdField (HWND hwndDlg, UINT ctrlId); void ToNormalPwdField (HWND hwndDlg, UINT ctrlId); void AccommodateTextField (HWND hwndDlg, UINT ctrlId, BOOL bFirstUpdate, HFONT hFont); +void AccommodateCheckBoxTextWidth (HWND hwndDlg, UINT ctrlId); +void MakeControlsContiguous(HWND hwndDlg, UINT ctrl1ID, UINT ctrl2ID); BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize); BOOL GetSysDevicePaths (HWND hwndDlg); BOOL DoDriverInstall (HWND hwndDlg); int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader); void CloseVolume (OpenVolumeContext *context); int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); BOOL IsPagingFileWildcardActive (); BOOL DisablePagingFile (); BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); BOOL InitSecurityTokenLibrary (HWND hwndDlg); BOOL FileHasReadOnlyAttribute (const wchar_t *path); BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path); void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors); -BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize); -BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str); -BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str); +BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize); +BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str); +BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str); int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt); BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath); void EnableElevatedCursorChange (HWND parent); BOOL DisableFileCompression (HANDLE file); BOOL VolumePathExists (const wchar_t *volumePath); BOOL IsWindowsIsoBurnerAvailable (); BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath); BOOL IsApplicationInstalled (const wchar_t *appName); int GetPim (HWND hwndDlg, UINT ctrlId, int defaultPim); void SetPim (HWND hwndDlg, UINT ctrlId, int pim); BOOL GetPassword (HWND hwndDlg, UINT ctrlID, char* passValue, int bufSize, BOOL bLegacyPassword, BOOL bShowError); void SetPassword (HWND hwndDlg, UINT ctrlID, char* passValue); void HandleShowPasswordFieldAction (HWND hwndDlg, UINT checkBoxId, UINT edit1Id, UINT edit2Id); HKEY OpenDeviceClassRegKey (const GUID *deviceClassGuid); LSTATUS DeleteRegistryKey (HKEY, LPCTSTR); HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow); int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask); HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz); void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy); void AllowMessageInUIPI (UINT msg); -BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize); +BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize); BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue); BOOL CopyTextToClipboard (const wchar_t* txtValue); BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args); BOOL GetFreeDriveLetter(WCHAR* pCh); BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable); +BOOL IsPrivilegeEnabled (LPTSTR szPrivilegeName); BOOL DeleteDirectory (const wchar_t* szDirName); BOOL IsThreadInSecureDesktop(DWORD dwThreadID); INT_PTR SecureDesktopDialogBoxParam (HINSTANCE, LPCWSTR, HWND, DLGPROC, LPARAM); BOOL VerifyModuleSignature (const wchar_t* path); void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, BOOL* pbInstallPathDetermined); BOOL GetSetupconfigLocation (wchar_t* path, DWORD cchSize); BOOL BufferHasPattern (const unsigned char* buffer, size_t bufferLen, const void* pattern, size_t patternLen); -BOOL EnableProcessProtection(); +void ActivateProcessMitigations(); +BOOL ActivateMemoryProtection(); void SafeOpenURL (LPCWSTR szUrl); BitLockerEncryptionStatus GetBitLockerEncryptionStatus(WCHAR driveLetter); BOOL IsTestSigningModeEnabled (); DWORD SendServiceNotification (DWORD dwNotificationCmd); +DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize); #ifdef _WIN64 void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed); #endif +BOOL IsInternetConnected(); #ifdef __cplusplus } #include <vector> #include <string> typedef std::vector<unsigned char> ByteArray; struct HostDevice { HostDevice () : Bootable (false), ContainsSystem (false), DynamicVolume (false), Floppy (false), IsPartition (false), IsVirtualPartition (false), HasUnencryptedFilesystem (false), Removable (false), Size (0), SystemNumber((uint32) -1), HasVolumeIDs (false) { ZeroMemory (VolumeIDs, sizeof (VolumeIDs)); } HostDevice (const HostDevice& device) : Bootable (device.Bootable), @@ -664,77 +670,78 @@ struct HostDevice memcpy (VolumeIDs, device.VolumeIDs, sizeof (VolumeIDs)); } return *this; } bool Bootable; bool ContainsSystem; bool DynamicVolume; bool Floppy; bool IsPartition; bool IsVirtualPartition; bool HasUnencryptedFilesystem; std::wstring MountPoint; std::wstring Name; std::wstring Path; bool Removable; uint64 Size; uint32 SystemNumber; BYTE VolumeIDs[TC_VOLUME_TYPE_COUNT][VOLUME_ID_SIZE]; bool HasVolumeIDs; std::vector <HostDevice> Partitions; }; struct RawDevicesDlgParam { std::vector <HostDevice> devices; wchar_t *pszFileName; }; +BOOL SelectMultipleFiles (HWND hwndDlg, const char *stringId, BOOL keepHistory, std::vector<std::wstring>& filesList); BOOL BrowseFilesInDir (HWND hwndDlg, char *stringId, wchar_t *initialDir, wchar_t *lpszFileName, BOOL keepHistory, BOOL saveMode, wchar_t *browseFilter, const wchar_t *initialFileName = NULL, const wchar_t *defaultExtension = NULL); std::wstring SingleStringToWide (const std::string &singleString); std::wstring Utf8StringToWide (const std::string &utf8String); std::string WideToUtf8String (const std::wstring &wideString); std::vector <HostDevice> GetAvailableHostDevices (bool noDeviceProperties = false, bool singleList = false, bool noFloppy = true, bool detectUnencryptedFilesystems = false); std::wstring ToUpperCase (const std::wstring &str); std::wstring GetWrongPasswordErrorMessage (HWND hwndDlg); std::wstring GetWindowsEdition (); std::wstring FitPathInGfxWidth (HWND hwnd, HFONT hFont, LONG width, const std::wstring &path); std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy); std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath); std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath); std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile); std::wstring GetUserFriendlyVersionString (int version); std::wstring IntToWideString (int val); std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData); -bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr); +bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr); std::wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromService); void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey); std::wstring GetTempPathString (); void CorrectFileName (std::wstring& fileName); inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos) { return std::wstring (msg? msg : L"") + L"\n\nSource: " + SingleStringToWide (srcPos); } void UpdateMountableHostDeviceList (); INT_PTR TextEditDialogBox (BOOL readOnly, HWND parent, const WCHAR* Title, std::string& text); // Display a wait dialog while calling the provided callback with the given parameter typedef void (CALLBACK* WaitThreadProc)(void* pArg, HWND hWaitDlg); void BringToForeground(HWND hWnd); void ShowWaitDialog(HWND hwnd, BOOL bUseHwndAsParent, WaitThreadProc callback, void* pArg); // classes used to implement support for password drag-n-drop from KeePass Password Safe // Implementation based the following source code with many modifications to fix isses and add features // URL: https://www.codeguru.com/cpp/misc/misc/draganddrop/article.php/c349/Drag-And-Drop-between-Window-Controls.htm interface GenericDropTarget : public IDropTarget { public: GenericDropTarget(CLIPFORMAT* pFormats, size_t count); ~GenericDropTarget(); // basic IUnknown stuff HRESULT STDMETHODCALLTYPE QueryInterface(REFIID iid, void ** ppvObject); ULONG STDMETHODCALLTYPE AddRef(void); ULONG STDMETHODCALLTYPE Release(void); diff --git a/src/Common/EMVCard.cpp b/src/Common/EMVCard.cpp index 172a9628..59dc3cf0 100644 --- a/src/Common/EMVCard.cpp +++ b/src/Common/EMVCard.cpp @@ -1,85 +1,85 @@ #include "EMVCard.h" #include "TLVParser.h" #include "SCardReader.h" #include "PCSCException.h" #include "Platform/Finally.h" #include "Platform/ForEach.h" #include <vector> #include <iostream> #include <algorithm> #if !defined(TC_WINDOWS) || defined(TC_PROTOTYPE) #include "Platform/SerializerFactory.h" #include "Platform/StringConverter.h" #include "Platform/SystemException.h" #else #include "Dictionary.h" #include "Language.h" #endif using namespace std; namespace VeraCrypt { #ifndef TC_WINDOWS wstring ArrayToHexWideString(const unsigned char * pbData, size_t cbData) { - static wchar_t* hexChar = L"0123456789ABCDEF"; + static const wchar_t* hexChar = L"0123456789ABCDEF"; wstring result; if (pbData) { - for (int i = 0; i < cbData; i++) + for (size_t i = 0; i < cbData; i++) { result += hexChar[pbData[i] >> 4]; result += hexChar[pbData[i] & 0x0F]; } } return result; } #endif - map<EMVCardType, vector<byte>> InitializeSupportedAIDs() + map<EMVCardType, vector<uint8>> InitializeSupportedAIDs() { - map<EMVCardType, vector<byte>> supportedAIDs; - supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<byte>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + (std::end(EMVCard::AMEX_AID) - std::begin(EMVCard::AMEX_AID))))); - supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<byte>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + (std::end(EMVCard::MASTERCARD_AID) - std::begin(EMVCard::MASTERCARD_AID))))); - supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<byte>(EMVCard::VISA_AID, EMVCard::VISA_AID + (std::end(EMVCard::VISA_AID) - std::begin(EMVCard::VISA_AID))))); + map<EMVCardType, vector<uint8>> supportedAIDs; + supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<uint8>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + sizeof(EMVCard::AMEX_AID)))); + supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<uint8>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + sizeof(EMVCard::MASTERCARD_AID)))); + supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<uint8>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID)))); return supportedAIDs; } - const byte EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10}; - const byte EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10}; - const byte EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10}; - const map<EMVCardType, vector<byte>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs(); + const uint8 EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10}; + const uint8 EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10}; + const uint8 EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10}; + const map<EMVCardType, vector<uint8>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs(); EMVCard::EMVCard() : SCard(), m_lastPANDigits(L"") { } EMVCard::EMVCard(size_t slotId) : SCard(slotId), m_lastPANDigits(L"") { } EMVCard::~EMVCard() { Clear(); } EMVCard::EMVCard(const EMVCard& other) : SCard(other), m_aid(other.m_aid), m_supportedAids(other.m_supportedAids), m_iccCert(other.m_iccCert), m_issuerCert(other.m_issuerCert), m_cplcData(other.m_cplcData), m_lastPANDigits(other.m_lastPANDigits) { } EMVCard::EMVCard(EMVCard&& other) : SCard(other), m_aid(std::move(other.m_aid)), m_supportedAids(std::move(other.m_supportedAids)), m_iccCert(std::move(other.m_iccCert)), @@ -103,80 +103,80 @@ namespace VeraCrypt } return *this; } EMVCard& EMVCard::operator = (EMVCard&& other) { if (this != &other) { SCard::operator=(other); m_reader = std::move(other.m_reader); m_aid = std::move(other.m_aid); m_supportedAids = std::move(other.m_supportedAids); m_iccCert = std::move(other.m_iccCert); m_issuerCert = std::move(other.m_issuerCert); m_cplcData = std::move(other.m_cplcData); m_lastPANDigits = std::move(other.m_lastPANDigits); } return *this; } void EMVCard::Clear(void) { m_aid.clear(); m_supportedAids.clear(); m_iccCert.clear(); m_issuerCert.clear(); m_cplcData.clear(); m_lastPANDigits.clear(); } - vector<byte> EMVCard::GetCardAID(bool forceContactless) + vector<uint8> EMVCard::GetCardAID(bool forceContactless) { - vector<vector<byte>> supportedAIDs; - vector<byte> supportedAIDsPriorities; - vector<pair<byte, vector<byte>>> supportedAIDsSorted; + vector<vector<uint8>> supportedAIDs; + vector<uint8> supportedAIDsPriorities; + vector<pair<uint8, vector<uint8>>> supportedAIDsSorted; bool hasBeenReset = false; CommandAPDU command; ResponseAPDU response; - vector<byte> responseData; + vector<uint8> responseData; shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> fciNode; shared_ptr<TLVNode> dfNameNode; shared_ptr<TLVNode> sfiNode; shared_ptr<TLVNode> fciIssuerNode; shared_ptr<TLVNode> fciIssuerDiscretionaryDataNode; shared_ptr<TLVNode> templateNode; vector<shared_ptr<TLVNode>> pseDirectoryNodes; unsigned char sfi; bool usingContactless = false; - vector<byte> tokenAID; + vector<uint8> tokenAID; if (m_aid.size()) return m_aid; if (m_reader) { if (m_reader->IsCardPresent()) { m_reader->Connect(SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, hasBeenReset, true); m_reader->BeginTransaction(); finally_do_arg (shared_ptr<SCardReader>, m_reader, { finally_arg->EndTransaction(); }); try { for (auto it = EMVCard::SUPPORTED_AIDS.begin(); it != EMVCard::SUPPORTED_AIDS.end(); it++) { command = CommandAPDU(CLA_ISO7816, INS_SELECT_FILE, 0x04, 0x00, it->second, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR) { tokenAID = it->second; break; } } if (tokenAID.size()) { m_supportedAids.push_back(tokenAID); m_aid = tokenAID; } @@ -214,61 +214,61 @@ namespace VeraCrypt { fciIssuerNode = TLVParser::TLV_Find(fciNode, EMV_FCI_ISSUER_TAG); if (fciIssuerNode && fciIssuerNode->Subs->size() >= 1) { fciIssuerDiscretionaryDataNode = TLVParser::TLV_Find(fciIssuerNode, EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG); if (fciIssuerDiscretionaryDataNode && fciIssuerDiscretionaryDataNode->Subs->size() >= 1) { for (size_t i = 0; i < fciIssuerDiscretionaryDataNode->Subs->size(); i++) { if (fciIssuerDiscretionaryDataNode->Subs->at(i)->Tag == EMV_DIRECTORY_ENTRY_TAG) { pseDirectoryNodes.push_back(fciIssuerDiscretionaryDataNode->Subs->at(i)); } } } } } else { dfNameNode = TLVParser::TLV_Find(fciNode, EMV_DFNAME_TAG); if (dfNameNode) { fciIssuerNode = TLVParser::TLV_Find(fciNode, EMV_FCI_ISSUER_TAG); if (fciIssuerNode) { sfiNode = TLVParser::TLV_Find(fciIssuerNode, EMV_SFI_TAG); if (sfiNode && sfiNode->Value->size() == 1) { sfi = sfiNode->Value->at(0); - byte rec = 1; + uint8 rec = 1; do { command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec++, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0) { responseData = response.getData(); try { templateNode = TLVParser::TLV_Parse(responseData.data(), responseData.size()); if (templateNode && templateNode->Tag == EMV_TEMPLATE_TAG && templateNode->Subs->size() >= 1) { for (size_t i = 0; i < templateNode->Subs->size(); i++) { if (templateNode->Subs->at(i)->Tag == EMV_DIRECTORY_ENTRY_TAG) { pseDirectoryNodes.push_back(templateNode->Subs->at(i)); } } } } catch(TLVException) { continue; } } } while (response.getData().size() > 0); } } @@ -289,235 +289,235 @@ namespace VeraCrypt supportedAIDsPriorities.push_back(aidNode->Value->at(0)); } } for(size_t i = 0; i < supportedAIDs.size(); i++) { supportedAIDsSorted.push_back(make_pair(supportedAIDsPriorities[i], supportedAIDs[i])); } std::sort(supportedAIDsSorted.begin(), supportedAIDsSorted.end()); for(size_t i = 0; i < supportedAIDs.size(); i++) { supportedAIDs[i] = supportedAIDsSorted[i].second; } if (supportedAIDs.size()) { m_supportedAids = supportedAIDs; tokenAID = supportedAIDs[0]; m_aid = tokenAID; } } } catch (...) { } } } return tokenAID; } - void EMVCard::GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData) + void EMVCard::GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData) { bool hasBeenReset = false; bool aidSelected = false; bool iccFound = false; bool issuerFound = false; bool cplcFound = false; - vector<byte> emvCardAid; + vector<uint8> emvCardAid; shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> iccPublicKeyCertNode; shared_ptr<TLVNode> issuerPublicKeyCertNode; CommandAPDU command; ResponseAPDU response; - vector<byte> responseData; + vector<uint8> responseData; iccCert.clear(); issuerCert.clear(); cplcData.clear(); if (m_iccCert.size() && m_issuerCert.size() && m_cplcData.size()) { iccCert = m_iccCert; issuerCert = m_issuerCert; cplcData = m_cplcData; return; } emvCardAid = GetCardAID(); if (emvCardAid.size() == 0) { throw EMVUnknownCardType(); } if (m_reader) { if (m_reader->IsCardPresent()) { m_reader->Connect(SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, hasBeenReset, true); m_reader->BeginTransaction(); finally_do_arg (shared_ptr<SCardReader>, m_reader, { finally_arg->EndTransaction(); }); // First get CPLC before selecting the AID of the card. command = CommandAPDU(0x80, INS_GET_DATA, (EMV_CPLC_TAG >> 8) & 0xFF, EMV_CPLC_TAG & 0xFF, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0) { cplcFound = true; cplcData = response.getData(); // Then get the certs. command = CommandAPDU(CLA_ISO7816, INS_SELECT_FILE, 0x04, 0x00, emvCardAid, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR) { aidSelected = true; // TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL, // which will then be used to get the actual start and end of sfi and rec. - for (byte sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++) + for (uint8 sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++) { - for (byte rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++) + for (uint8 rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++) { command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0) { responseData = response.getData(); try { rootNode = TLVParser::TLV_Parse(responseData.data(), responseData.size()); } catch(TLVException) { continue; } iccPublicKeyCertNode = TLVParser::TLV_Find(rootNode, EMV_ICC_PK_CERT_TAG); if (iccPublicKeyCertNode && iccPublicKeyCertNode->Value->size() > 0) { iccFound = true; iccCert = *iccPublicKeyCertNode->Value.get(); } issuerPublicKeyCertNode = TLVParser::TLV_Find(rootNode, EMV_ISS_PK_CERT_TAG); if (issuerPublicKeyCertNode && issuerPublicKeyCertNode->Value->size() > 0) { issuerFound = true; issuerCert = *issuerPublicKeyCertNode->Value.get(); } } } } } } } } if (!cplcFound) throw EMVCPLCNotFound(); if (!aidSelected) throw EMVSelectAIDFailed(); if (!iccFound) throw EMVIccCertNotFound(); if (!issuerFound) throw EMVIssuerCertNotFound(); m_iccCert = iccCert; m_issuerCert = issuerCert; m_cplcData = cplcData; } void EMVCard::GetCardPAN(wstring& lastPANDigits) { bool hasBeenReset = false; bool panFound = false; bool aidSelected = false; - vector<byte> EMVCardAid; - vector<byte> panData; + vector<uint8> EMVCardAid; + vector<uint8> panData; shared_ptr<TLVNode> rootNode; shared_ptr<TLVNode> panNode; CommandAPDU command; ResponseAPDU response; - vector<byte> responseData; + vector<uint8> responseData; lastPANDigits = L""; if (m_lastPANDigits != L"") { lastPANDigits = m_lastPANDigits; return; } EMVCardAid = GetCardAID(); if (EMVCardAid.size() == 0) { throw EMVUnknownCardType(); } if (m_reader) { if (m_reader->IsCardPresent()) { m_reader->Connect(SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, hasBeenReset, true); m_reader->BeginTransaction(); finally_do_arg (shared_ptr<SCardReader>, m_reader, { finally_arg->EndTransaction(); }); command = CommandAPDU(CLA_ISO7816, INS_SELECT_FILE, 0x04, 0x00, EMVCardAid, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR) { aidSelected = true; // TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL, // which will then be used to get the actual start and end of sfi and rec. - for (byte sfi = 1; sfi < 32 && !panFound; sfi++) + for (uint8 sfi = 1; sfi < 32 && !panFound; sfi++) { - for (byte rec = 1; rec < 17 && !panFound; rec++) + for (uint8 rec = 1; rec < 17 && !panFound; rec++) { command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize); m_reader->ApduProcessData(command, response); if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0) { responseData = response.getData(); try { rootNode = TLVParser::TLV_Parse(responseData.data(), responseData.size()); } catch(TLVException) { continue; } panNode = TLVParser::TLV_Find(rootNode, EMV_PAN_TAG); if (panNode && panNode->Value->size() >= 8) { panFound = true; panData = *panNode->Value.get(); - panData = vector<byte>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits + panData = vector<uint8>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits std::swap(panData[0], panData[1]); lastPANDigits = ArrayToHexWideString(panData.data(), (int) panData.size()); } } } } } } } if (panData.size()) burn(panData.data(), panData.size()); if (!aidSelected) throw EMVSelectAIDFailed(); if (!panFound) throw EMVPANNotFound(); m_lastPANDigits = lastPANDigits; } } diff --git a/src/Common/EMVCard.h b/src/Common/EMVCard.h index 116de705..70ef035f 100644 --- a/src/Common/EMVCard.h +++ b/src/Common/EMVCard.h @@ -2,68 +2,68 @@ #define TC_HEADER_Common_EMVCard #include "Platform/PlatformBase.h" #if defined (TC_WINDOWS) && !defined (TC_PROTOTYPE) # include "Exception.h" #else # include "Platform/Exception.h" #endif #include "Token.h" #include "SCard.h" namespace VeraCrypt { typedef enum EMVCardType { NONE = 0, AMEX, MASTERCARD, VISA } EMVCardType; class EMVCard : public SCard { protected: // The following fields will only be empty if the card has not been read yet. // After the card has been read, and if some or all fields cannot be read, the EMVCard // object will be considered invalid and will not be included in the list of available cards // of EMVToken. - vector<byte> m_aid; - vector<vector<byte>> m_supportedAids; - vector<byte> m_iccCert; - vector<byte> m_issuerCert; - vector<byte> m_cplcData; + vector<uint8> m_aid; + vector<vector<uint8>> m_supportedAids; + vector<uint8> m_iccCert; + vector<uint8> m_issuerCert; + vector<uint8> m_cplcData; wstring m_lastPANDigits; public: // Add other AIDS // https://gist.github.com/pvieito/6224eed92c99b069f6401996c548d0e4 // https://ambimat.com/developer-resources/list-of-application-identifiers-aid/ - const static byte AMEX_AID[7]; - const static byte MASTERCARD_AID[7]; - const static byte VISA_AID[7]; - const static map<EMVCardType, vector<byte>> SUPPORTED_AIDS; + const static uint8 AMEX_AID[7]; + const static uint8 MASTERCARD_AID[7]; + const static uint8 VISA_AID[7]; + const static map<EMVCardType, vector<uint8>> SUPPORTED_AIDS; EMVCard(); EMVCard(size_t slotId); EMVCard(const EMVCard& other); EMVCard(EMVCard&& other); EMVCard& operator = (const EMVCard& other); EMVCard& operator = (EMVCard&& other); virtual ~EMVCard(); void Clear(void); // Retrieves the card's AID. // It first checks the card against a list of supported AIDs. // If that fails, it tries getting the AID from the card using PSE - vector<byte> GetCardAID(bool forceContactless = false); + vector<uint8> GetCardAID(bool forceContactless = false); - void GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData); + void GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData); void GetCardPAN(wstring& lastPANDigits); }; } #endif // TC_HEADER_Common_EMVCard diff --git a/src/Common/EMVToken.cpp b/src/Common/EMVToken.cpp index 0fe3dc1f..8f89cb7e 100644 --- a/src/Common/EMVToken.cpp +++ b/src/Common/EMVToken.cpp @@ -1,113 +1,113 @@ #include "EMVToken.h" #include "TLVParser.h" #include "SCardReader.h" #include "PCSCException.h" #include "Platform/Finally.h" #include "Platform/ForEach.h" #include <vector> #include <iostream> #include <algorithm> #if !defined(TC_WINDOWS) || defined(TC_PROTOTYPE) #include "Platform/SerializerFactory.h" #include "Platform/StringConverter.h" #include "Platform/SystemException.h" #else #include "Dictionary.h" #include "Language.h" #endif using namespace std; namespace VeraCrypt { - void AppendData(vector<byte>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false) + void AppendData(vector<uint8>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false) { if (cbData > 0 && from <= cbData - 2 && length > 0 && length <= cbData - from) { size_t offset = (bEncodeLength ? 4 : 0); size_t orgSize = buffer.size(); buffer.resize(orgSize + length + offset); if (bEncodeLength) { unsigned int dwLength = (unsigned int)(length); memcpy(buffer.data() + orgSize, &dwLength, 4); } memcpy(buffer.data() + orgSize + offset, pbData + from, length); } } /* ****************************************************************************************************************************************** */ map <unsigned long int, shared_ptr<EMVCard>> EMVToken::EMVCards; EMVTokenInfo::~EMVTokenInfo() { if (Label.size() > 0) burn(&Label[0], Label.size() * sizeof(wchar_t)); } EMVTokenKeyfile::EMVTokenKeyfile() { Id = EMV_CARDS_LABEL; Token = shared_ptr<EMVTokenInfo>(new EMVTokenInfo()); } EMVTokenKeyfile::EMVTokenKeyfile(const TokenKeyfilePath& path) { wstring pathStr = path; unsigned long slotId; if (swscanf(pathStr.c_str(), TC_EMV_TOKEN_KEYFILE_URL_PREFIX TC_EMV_TOKEN_KEYFILE_URL_SLOT L"/%lu", &slotId) != 1) throw InvalidEMVPath(); Id = EMV_CARDS_LABEL; Token = shared_ptr<EMVTokenInfo>(new EMVTokenInfo()); Token->SlotId = slotId; } EMVTokenKeyfile::operator TokenKeyfilePath () const { wstringstream path; path << TC_EMV_TOKEN_KEYFILE_URL_PREFIX TC_EMV_TOKEN_KEYFILE_URL_SLOT L"/" << Token->SlotId; return path.str(); } - void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const + void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const { map <unsigned long int, shared_ptr<EMVCard>>::iterator emvCardsIt; shared_ptr<EMVCard> card; - vector<byte> iccCert; - vector<byte> issuerCert; - vector<byte> cplcData; + vector<uint8> iccCert; + vector<uint8> issuerCert; + vector<uint8> cplcData; bool addNewCard = true; keyfileData.clear(); emvCardsIt = EMVToken::EMVCards.find(Token->SlotId); if (emvCardsIt != EMVToken::EMVCards.end()) { // An EMVCard object has already been created for this slotId. // We check that it's SCard handle is still valid. // If it is, we use the existing EMVCard to get the card's content. // If it is not, we remove the EMVCard from EMVCards and create a new one. if (emvCardsIt->second->IsCardHandleValid()) { emvCardsIt->second->GetCardContent(iccCert, issuerCert, cplcData); addNewCard = false; } else { EMVToken::EMVCards.erase(emvCardsIt); } } if (addNewCard) { // An EMVCard object does not exist for this slotId, or exists but its handle is not valid anymore. // We create a new one and then add it to EMVCards. card = make_shared<EMVCard>(Token->SlotId); card->GetCardContent(iccCert, issuerCert, cplcData); EMVToken::EMVCards.insert(make_pair(Token->SlotId, card)); diff --git a/src/Common/EMVToken.h b/src/Common/EMVToken.h index a1c0a2e1..d82ea542 100644 --- a/src/Common/EMVToken.h +++ b/src/Common/EMVToken.h @@ -1,42 +1,42 @@ #ifndef TC_HEADER_Common_EMVToken #define TC_HEADER_Common_EMVToken #define TC_EMV_TOKEN_KEYFILE_URL_PREFIX L"emv://" #define TC_EMV_TOKEN_KEYFILE_URL_SLOT L"slot" #define EMV_CARDS_LABEL L"EMV Certificates" #include "EMVCard.h" namespace VeraCrypt { struct EMVTokenInfo: TokenInfo { virtual ~EMVTokenInfo(); virtual BOOL isEditable() const { return false; } }; struct EMVTokenKeyfile: TokenKeyfile { EMVTokenKeyfile(); EMVTokenKeyfile(const TokenKeyfilePath& path); virtual ~EMVTokenKeyfile() {}; virtual operator TokenKeyfilePath () const; - virtual void GetKeyfileData(vector <byte>& keyfileData) const; + virtual void GetKeyfileData(vector <uint8>& keyfileData) const; }; class EMVToken { public: static bool IsKeyfilePathValid(const wstring& emvTokenKeyfilePath); static vector<EMVTokenKeyfile> GetAvailableKeyfiles(unsigned long int* slotIdFilter = nullptr, const wstring& keyfileIdFilter = wstring()); static EMVTokenInfo GetTokenInfo(unsigned long int slotId); - friend void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const; + friend void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const; static map <unsigned long int, shared_ptr<EMVCard>> EMVCards; }; } #endif diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c index 62b2cae8..79f1c890 100644 --- a/src/Common/EncryptionThreadPool.c +++ b/src/Common/EncryptionThreadPool.c @@ -61,61 +61,61 @@ typedef WORD (WINAPI* GetActiveProcessorGroupCountFn)(); typedef DWORD (WINAPI *GetActiveProcessorCountFn)( WORD GroupNumber ); #endif // !DEVICE_DRIVER typedef enum { WorkItemFree, WorkItemReady, WorkItemBusy } WorkItemState; typedef struct EncryptionThreadPoolWorkItemStruct { WorkItemState State; EncryptionThreadPoolWorkType Type; TC_EVENT ItemCompletedEvent; struct EncryptionThreadPoolWorkItemStruct *FirstFragment; LONG OutstandingFragmentCount; union { struct { PCRYPTO_INFO CryptoInfo; - byte *Data; + uint8 *Data; UINT64_STRUCT StartUnitNo; uint32 UnitCount; } Encryption; struct { TC_EVENT *CompletionEvent; LONG *CompletionFlag; char *DerivedKey; int IterationCount; TC_EVENT *NoOutstandingWorkItemEvent; LONG *OutstandingWorkItemCount; char *Password; int PasswordLength; int Pkcs5Prf; char *Salt; } KeyDerivation; struct { TC_EVENT *KeyDerivationCompletedEvent; TC_EVENT *NoOutstandingWorkItemEvent; LONG *outstandingWorkItemCount; void* keyInfoBuffer; int keyInfoBufferSize; void* keyDerivationWorkItems; int keyDerivationWorkItemsSize; @@ -579,67 +579,67 @@ void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivat if (!ThreadPoolRunning) TC_THROW_FATAL_EXCEPTION; TC_ACQUIRE_MUTEX (&EnqueueMutex); workItem = &WorkItemQueue[EnqueuePosition++]; if (EnqueuePosition >= ThreadQueueSize) EnqueuePosition = 0; while (GetWorkItemState (workItem) != WorkItemFree) { TC_WAIT_EVENT (WorkItemCompletedEvent); } workItem->Type = ReadVolumeHeaderFinalizationWork; workItem->ReadVolumeHeaderFinalization.NoOutstandingWorkItemEvent = noOutstandingWorkItemEvent; workItem->ReadVolumeHeaderFinalization.KeyDerivationCompletedEvent = keyDerivationCompletedEvent; workItem->ReadVolumeHeaderFinalization.keyInfoBuffer = keyInfoBuffer; workItem->ReadVolumeHeaderFinalization.keyInfoBufferSize = keyInfoBufferSize; workItem->ReadVolumeHeaderFinalization.keyDerivationWorkItems = keyDerivationWorkItems; workItem->ReadVolumeHeaderFinalization.keyDerivationWorkItemsSize = keyDerivationWorkItemsSize; workItem->ReadVolumeHeaderFinalization.outstandingWorkItemCount = outstandingWorkItemCount; SetWorkItemState (workItem, WorkItemReady); TC_SET_EVENT (WorkItemReadyEvent); TC_RELEASE_MUTEX (&EnqueueMutex); } -void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo) +void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo) { uint32 fragmentCount; uint32 unitsPerFragment; uint32 remainder; - byte *fragmentData; + uint8 *fragmentData; uint64 fragmentStartUnitNo; EncryptionThreadPoolWorkItem *workItem; EncryptionThreadPoolWorkItem *firstFragmentWorkItem; if (unitCount == 0) return; if (!ThreadPoolRunning || unitCount == 1) { switch (type) { case DecryptDataUnitsWork: DecryptDataUnitsCurrentThreadEx (data, startUnitNo, unitCount, cryptoInfo); break; case EncryptDataUnitsWork: EncryptDataUnitsCurrentThreadEx (data, startUnitNo, unitCount, cryptoInfo); break; default: TC_THROW_FATAL_EXCEPTION; } return; } if (unitCount <= ThreadCount) { fragmentCount = unitCount; diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h index 053d4107..71df4e4d 100644 --- a/src/Common/EncryptionThreadPool.h +++ b/src/Common/EncryptionThreadPool.h @@ -7,42 +7,42 @@ and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_ENCRYPTION_THREAD_POOL #define TC_HEADER_ENCRYPTION_THREAD_POOL #include "Tcdefs.h" #include "Crypto.h" #ifdef __cplusplus extern "C" { #endif typedef enum { EncryptDataUnitsWork, DecryptDataUnitsWork, DeriveKeyWork, ReadVolumeHeaderFinalizationWork } EncryptionThreadPoolWorkType; #ifndef DEVICE_DRIVER size_t GetCpuCount (WORD* pGroupCount); #endif void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey); void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivationCompletedEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG* outstandingWorkItemCount, void* keyInfoBuffer, int keyInfoBufferSize, void* keyDerivationWorkItems, int keyDerivationWorkItemsSize); -void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo); +void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo); BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount); void EncryptionThreadPoolStop (); size_t GetEncryptionThreadCount (); size_t GetMaxEncryptionThreadCount (); BOOL IsEncryptionThreadPoolRunning (); #ifdef __cplusplus } #endif #endif // TC_HEADER_ENCRYPTION_THREAD_POOL diff --git a/src/Common/Fat.h b/src/Common/Fat.h index b2457be2..19b5cebb 100644 --- a/src/Common/Fat.h +++ b/src/Common/Fat.h @@ -1,47 +1,47 @@ /* 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 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 all other portions of this file are Copyright (c) 2013-2017 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. */ typedef struct fatparams_t { char volume_name[11]; - byte volume_id[4]; + uint8 volume_id[4]; unsigned int num_sectors; /* total number of sectors */ int cluster_count; /* number of clusters */ int size_root_dir; /* size of the root directory in bytes */ int size_fat; /* size of FAT */ int fats; int media; unsigned int cluster_size; int fat_length; uint16 dir_entries; uint16 sector_size; int hidden; __int16 reserved; uint16 sectors; unsigned int total_sect; uint16 heads; uint16 secs_track; } fatparams; struct msdos_boot_sector { unsigned char boot_jump[3]; /* Boot strap short or near jump */ char system_id[8]; /* Name - can be used to special case partition manager volumes */ unsigned char sector_size[2]; /* bytes per logical sector */ unsigned char cluster_size; /* sectors/cluster */ unsigned short reserved;/* reserved sectors */ unsigned char fats; /* number of FATs */ diff --git a/src/Common/Format.c b/src/Common/Format.c index 6c3e2fff..7eff80e6 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -191,61 +191,61 @@ begin_format: DWORD dwResult; int nPass; if (FakeDosNameForDevice (volParams->volumePath, dosDev, sizeof(dosDev), devName, sizeof(devName), FALSE) != 0) return ERR_OS_ERROR; if (IsDeviceMounted (devName)) { if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE) { Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg); nStatus = ERR_DONT_REPORT; goto error; } /* 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, NULL, 0, &dwResult, NULL)) { bFailedRequiredDASD = TRUE; } } - else if (IsOSAtLeast (WIN_VISTA) && driveLetter == -1) + else if (driveLetter == -1) { // 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. wchar_t szDriveLetter[] = { L'A', L':', 0 }; wchar_t rootPath[] = { L'A', L':', L'\\', 0 }; wchar_t uniqVolName[MAX_PATH+1] = { 0 }; int tmpDriveLetter = -1; BOOL bResult = FALSE; tmpDriveLetter = GetFirstAvailableDrive (); if (tmpDriveLetter != -1) { rootPath[0] += (wchar_t) tmpDriveLetter; szDriveLetter[0] += (wchar_t) tmpDriveLetter; if (DefineDosDevice (DDD_RAW_TARGET_PATH, szDriveLetter, volParams->volumePath)) { bResult = GetVolumeNameForVolumeMountPoint (rootPath, uniqVolName, MAX_PATH); DefineDosDevice (DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE, szDriveLetter, volParams->volumePath); if (bResult && SetVolumeMountPoint (rootPath, uniqVolName)) { // The drive letter can be removed now @@ -318,137 +318,180 @@ 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 // formatting hidden sectors memset (buf, 0, sizeof (buf)); if (!WriteFile (dev, buf, sizeof (buf), &bw, NULL)) { nStatus = ERR_OS_ERROR; goto error; } FlushFileBuffers (dev); CloseHandle (dev); dev = INVALID_HANDLE_VALUE; } } if (DeviceIoControl (dev, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &dwResult, NULL)) { Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg); nStatus = ERR_DONT_REPORT; goto error; } } else { /* File-hosted volume */ BOOL speedupFileCreation = FALSE; + BOOL delayedSpeedupFileCreation = FALSE; // speedup for file creation only makes sens when using quick format for non hidden volumes if (!volParams->hiddenVol && !bInstantRetryOtherFilesys && volParams->quickFormat && volParams->fastCreateFile) { // we set required privileges to speedup file creation before we create the file so that the file handle inherits the privileges if (!SetPrivilege(SE_MANAGE_VOLUME_NAME, TRUE)) { DWORD dwLastError = GetLastError(); - if (Silent || (MessageBoxW(hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_MANAGE_VOLUME"), lpszTitle, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDNO)) + if (!IsAdmin () && IsUacSupported ()) + { + speedupFileCreation = TRUE; + delayedSpeedupFileCreation = TRUE; + } + else if (Silent || (MessageBoxW(hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_MANAGE_VOLUME"), lpszTitle, MB_YESNO | MB_ICONWARNING | MB_DEFBUTTON2) == IDNO)) { SetLastError(dwLastError); nStatus = ERR_OS_ERROR; goto error; } } else { speedupFileCreation = TRUE; } } dev = CreateFile (volParams->volumePath, GENERIC_READ | GENERIC_WRITE, (volParams->hiddenVol || bInstantRetryOtherFilesys) ? (FILE_SHARE_READ | FILE_SHARE_WRITE) : 0, NULL, (volParams->hiddenVol || bInstantRetryOtherFilesys) ? OPEN_EXISTING : CREATE_ALWAYS, 0, NULL); if (dev == INVALID_HANDLE_VALUE) { nStatus = ERR_OS_ERROR; goto error; } else if (volParams->hiddenVol && bPreserveTimestamp) { // ensure that Last Access and Last Write timestamps are not modified ftLastAccessTime.dwHighDateTime = 0xFFFFFFFF; ftLastAccessTime.dwLowDateTime = 0xFFFFFFFF; SetFileTime (dev, NULL, &ftLastAccessTime, NULL); if (GetFileTime ((HANDLE) dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime) == 0) bTimeStampValid = FALSE; else bTimeStampValid = TRUE; } DisableFileCompression (dev); if (!volParams->hiddenVol && !bInstantRetryOtherFilesys) { LARGE_INTEGER volumeSize; volumeSize.QuadPart = dataAreaSize + TC_VOLUME_HEADER_GROUP_SIZE; if (volParams->sparseFileSwitch && volParams->quickFormat) { // Create as sparse file container DWORD tmp; if (!DeviceIoControl (dev, FSCTL_SET_SPARSE, NULL, 0, NULL, 0, &tmp, NULL)) { nStatus = ERR_OS_ERROR; goto error; } } - // Preallocate the file - if (!SetFilePointerEx (dev, volumeSize, NULL, FILE_BEGIN) - || !SetEndOfFile (dev)) + if (!delayedSpeedupFileCreation) { - nStatus = ERR_OS_ERROR; - goto error; + // Preallocate the file + if (!SetFilePointerEx (dev, volumeSize, NULL, FILE_BEGIN) + || !SetEndOfFile (dev)) + { + nStatus = ERR_OS_ERROR; + goto error; + } } if (speedupFileCreation) { // accelerate file creation by telling Windows not to fill all file content with zeros // this has security issues since it will put existing disk content into file container // We use this mechanism only when switch /fastCreateFile specific and when quick format // also specified and which is documented to have security issues. - // we don't check returned status because failure is not issue for us - if (!SetFileValidData (dev, volumeSize.QuadPart)) + if (delayedSpeedupFileCreation) + { + // in case of delayed speedup we need to set the file size to a minimal value before performing the real preallocation through UAC + LARGE_INTEGER minimalSize; + DWORD dwOpStatus; + // 16K + minimalSize.QuadPart = 16 * 1024; + if (!SetFilePointerEx (dev, minimalSize, NULL, FILE_BEGIN) + || !SetEndOfFile (dev)) + { + nStatus = ERR_OS_ERROR; + goto error; + } + + FlushFileBuffers (dev); + CloseHandle (dev); + dev = INVALID_HANDLE_VALUE; + + dwOpStatus = UacFastFileCreation (volParams->hwndDlg, volParams->volumePath, volumeSize.QuadPart); + if (dwOpStatus != 0) + { + SetLastError(dwOpStatus); + nStatus = ERR_OS_ERROR; + goto error; + } + + // open again the file now that it was created + dev = CreateFile (volParams->volumePath, GENERIC_READ | GENERIC_WRITE, + 0, NULL, OPEN_EXISTING, 0, NULL); + if (dev == INVALID_HANDLE_VALUE) + { + nStatus = ERR_OS_ERROR; + goto error; + } + } + else if (!SetFileValidData (dev, volumeSize.QuadPart)) { nStatus = ERR_OS_ERROR; goto error; } } if (SetFilePointer (dev, 0, NULL, FILE_BEGIN) != 0) { nStatus = ERR_OS_ERROR; goto error; } } } if (volParams->hwndDlg && volParams->bGuiMode) KillTimer (volParams->hwndDlg, TIMER_ID_RANDVIEW); /* Volume header */ // Hidden volume setup if (volParams->hiddenVol) { LARGE_INTEGER headerOffset; // 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; } @@ -462,61 +505,61 @@ begin_format: nStatus = ERR_OS_ERROR; goto error; } } else if (bInstantRetryOtherFilesys) { // The previous file system format failed and the user wants to try again with a different file system. // The volume header had been written successfully so we need to seek to the byte after the header. LARGE_INTEGER offset; offset.QuadPart = TC_VOLUME_DATA_OFFSET; if (!SetFilePointerEx ((HANDLE) dev, offset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } } if (!bInstantRetryOtherFilesys) { // Write the volume header if (!WriteEffectiveVolumeHeader (volParams->bDevice, dev, header)) { nStatus = ERR_OS_ERROR; goto error; } // To prevent fragmentation, write zeroes to reserved header sectors which are going to be filled with random data if (!volParams->bDevice && !volParams->hiddenVol) { - byte buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE]; + uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE]; DWORD bytesWritten; ZeroMemory (buf, sizeof (buf)); if (!WriteFile (dev, buf, sizeof (buf), &bytesWritten, NULL)) { nStatus = ERR_OS_ERROR; goto error; } if (bytesWritten != sizeof (buf)) { nStatus = ERR_PARAMETER_INCORRECT; goto error; } } } if (volParams->hiddenVol) { // Calculate data area position of hidden volume cryptoInfo->hiddenVolumeOffset = dataOffset; // Validate the offset if (dataOffset % FormatSectorSize != 0) { nStatus = ERR_VOL_SIZE_WRONG; goto error; } volParams->quickFormat = TRUE; // To entirely format a hidden volume would be redundant @@ -1322,61 +1365,61 @@ BOOL WriteSector (void *dev, char *sector, char *write_buf, int *write_buf_cnt, unsigned __int64 *nSecNo, unsigned __int64 startSector, PCRYPTO_INFO cryptoInfo) { static __int32 updateTime = 0; (*nSecNo)++; memcpy (write_buf + *write_buf_cnt, sector, FormatSectorSize); (*write_buf_cnt) += FormatSectorSize; if (*write_buf_cnt == FormatWriteBufferSize && !FlushFormatWriteBuffer (dev, write_buf, write_buf_cnt, nSecNo, cryptoInfo)) return FALSE; if (GetTickCount () - updateTime > 25) { if (UpdateProgressBar ((*nSecNo - startSector) * FormatSectorSize)) return FALSE; updateTime = GetTickCount (); } return TRUE; } static volatile BOOL WriteThreadRunning; static volatile BOOL WriteThreadExitRequested; static HANDLE WriteThreadHandle; -static byte *WriteThreadBuffer; +static uint8 *WriteThreadBuffer; static HANDLE WriteBufferEmptyEvent; static HANDLE WriteBufferFullEvent; static volatile HANDLE WriteRequestHandle; static volatile int WriteRequestSize; static volatile DWORD WriteRequestResult; static void __cdecl FormatWriteThreadProc (void *arg) { DWORD bytesWritten; SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_HIGHEST); while (!WriteThreadExitRequested) { if (WaitForSingleObject (WriteBufferFullEvent, INFINITE) == WAIT_FAILED) { handleWin32Error (NULL, SRC_POS); break; } if (WriteThreadExitRequested) break; if (!WriteFile (WriteRequestHandle, WriteThreadBuffer, WriteRequestSize, &bytesWritten, NULL)) WriteRequestResult = GetLastError(); else WriteRequestResult = ERROR_SUCCESS; diff --git a/src/Common/GfMul.c b/src/Common/GfMul.c index 970e6318..db51f499 100644 --- a/src/Common/GfMul.c +++ b/src/Common/GfMul.c @@ -260,154 +260,154 @@ in_line void xor_block_aligned64( void *p, const void *q) #define xp(i) xp_fun( \ (i & 0x80 ? 0xe1 : 0) ^ (i & 0x40 ? 0x70 : 0) ^ \ (i & 0x20 ? 0x38 : 0) ^ (i & 0x10 ? 0x1c : 0) ^ \ (i & 0x08 ? 0x0e : 0) ^ (i & 0x04 ? 0x07 : 0) ^ \ (i & 0x02 ? 0x03 : 0) ^ (i & 0x01 ? 0x01 : 0), \ (i & 0x80 ? 0x00 : 0) ^ (i & 0x40 ? 0x80 : 0) ^ \ (i & 0x20 ? 0x40 : 0) ^ (i & 0x10 ? 0x20 : 0) ^ \ (i & 0x08 ? 0x10 : 0) ^ (i & 0x04 ? 0x08 : 0) ^ \ (i & 0x02 ? 0x84 : 0) ^ (i & 0x01 ? 0xc2 : 0) ) #define xp64(i) xp_fun( \ (i & 0x80 ? 0xd8 : 0) ^ (i & 0x40 ? 0x6c : 0) ^ \ (i & 0x20 ? 0x36 : 0) ^ (i & 0x10 ? 0x1b : 0) ^ \ (i & 0x08 ? 0x0d : 0) ^ (i & 0x04 ? 0x06 : 0) ^ \ (i & 0x02 ? 0x03 : 0) ^ (i & 0x01 ? 0x01 : 0), \ (i & 0x80 ? 0x00 : 0) ^ (i & 0x40 ? 0x00 : 0) ^ \ (i & 0x20 ? 0x00 : 0) ^ (i & 0x10 ? 0x00 : 0) ^ \ (i & 0x08 ? 0x80 : 0) ^ (i & 0x04 ? 0xc0 : 0) ^ \ (i & 0x02 ? 0x60 : 0) ^ (i & 0x01 ? 0xb0 : 0) ) static mode(32t) gf_poly[2] = { 0, 0xe1000000 }; static mode(32t) gf_poly64[2] = { 0, 0xd8000000 }; /* Multiply of a GF128 field element by x. The field element */ /* is held in an array of bytes in which field bits 8n..8n + 7 */ /* are held in byte[n], with lower indexed bits placed in the */ /* more numerically significant bit positions in bytes. */ /* This function multiples a field element x, in the polynomial */ /* field representation. It uses 32-bit word operations to gain */ -/* speed but compensates for machine endianess and hence works */ +/* speed but compensates for machine endianness and hence works */ /* correctly on both styles of machine */ in_line void mul_x(mode(32t) x[4]) { mode(32t) t; bsw_32(x, 4); /* at this point the filed element bits 0..127 are set out */ /* as follows in 32-bit words (where the most significant */ /* (ms) numeric bits are to the left) */ /* */ /* x[0] x[1] x[2] x[3] */ /* ms ls ms ls ms ls ms ls */ /* field: 0 ... 31 32 .. 63 64 .. 95 96 .. 127 */ t = gf_poly[x[3] & 1]; /* bit 127 of the element */ x[3] = (x[3] >> 1) | (x[2] << 31); /* shift bits up by one */ x[2] = (x[2] >> 1) | (x[1] << 31); /* position */ x[1] = (x[1] >> 1) | (x[0] << 31); /* if bit 7 is 1 xor in */ x[0] = (x[0] >> 1) ^ t; /* the field polynomial */ bsw_32(x, 4); } in_line void mul_x64(mode(32t) x[2]) { mode(32t) t; bsw_32(x, 2); /* at this point the filed element bits 0..127 are set out */ /* as follows in 32-bit words (where the most significant */ /* (ms) numeric bits are to the left) */ /* */ /* x[0] x[1] x[2] x[3] */ /* ms ls ms ls ms ls ms ls */ /* field: 0 ... 31 32 .. 63 64 .. 95 96 .. 127 */ t = gf_poly64[x[1] & 1]; /* bit 127 of the element */ /* shift bits up by one */ /* position */ x[1] = (x[1] >> 1) | (x[0] << 31); /* if bit 7 is 1 xor in */ x[0] = (x[0] >> 1) ^ t; /* the field polynomial */ bsw_32(x, 2); } /* Multiply of a GF128 field element by x^8 using 32-bit words */ -/* for speed - machine endianess matters here */ +/* for speed - machine endianness matters here */ #if (PLATFORM_BYTE_ORDER == BRG_LITTLE_ENDIAN) #define xp_fun(x,y) ((mode(32t))(x)) | (((mode(32t))(y)) << 8) static const unsigned __int16 gft_le[256] = gf_dat(xp); static const unsigned __int16 gft_le64[256] = gf_dat(xp64); in_line void mul_lex8(mode(32t) x[4]) /* mutiply with long words */ { mode(32t) t = (x[3] >> 24); /* in little endian format */ x[3] = (x[3] << 8) | (x[2] >> 24); x[2] = (x[2] << 8) | (x[1] >> 24); x[1] = (x[1] << 8) | (x[0] >> 24); x[0] = (x[0] << 8) ^ gft_le[t]; } in_line void mul_lex8_64(mode(32t) x[2]) /* mutiply with long words */ { mode(32t) t = (x[1] >> 24); /* in little endian format */ x[1] = (x[1] << 8) | (x[0] >> 24); x[0] = (x[0] << 8) ^ gft_le64[t]; } #endif #if 1 || (PLATFORM_BYTE_ORDER == BRG_LITTLE_ENDIAN) #undef xp_fun #define xp_fun(x,y) ((mode(32t))(y)) | (((mode(32t))(x)) << 8) static const unsigned __int16 gft_be[256] = gf_dat(xp); static const unsigned __int16 gft_be64[256] = gf_dat(xp64); in_line void mul_bex8(mode(32t) x[4]) /* mutiply with long words */ { mode(32t) t = (x[3] & 0xff); /* in big endian format */ x[3] = (x[3] >> 8) | (x[2] << 24); x[2] = (x[2] >> 8) | (x[1] << 24); x[1] = (x[1] >> 8) | (x[0] << 24); x[0] = (x[0] >> 8) ^ (((mode(32t))gft_be[t]) << 16); } in_line void mul_bex8_64(mode(32t) x[2]) /* mutiply with long words */ { mode(32t) t = (x[1] & 0xff); /* in big endian format */ x[1] = (x[1] >> 8) | (x[0] << 24); x[0] = (x[0] >> 8) ^ (((mode(32t))gft_be64[t]) << 16); } #endif -/* hence choose the correct version for the machine endianess */ +/* hence choose the correct version for the machine endianness */ #if PLATFORM_BYTE_ORDER == BRG_BIG_ENDIAN #define mul_x8 mul_bex8 #define mul_x8_64 mul_bex8_64 #else #define mul_x8 mul_lex8 #define mul_x8_64 mul_lex8_64 #endif /* different versions of the general gf_mul function are provided */ /* here. Sadly none are very fast :-( */ void GfMul128 (void *a, const void* b) { mode(32t) r[CBLK_LEN >> 2], p[8][CBLK_LEN >> 2]; int i; move_block_aligned(p[0], b); bsw_32(p[0], 4); for(i = 0; i < 7; ++i) { p[i + 1][3] = (p[i][3] >> 1) | (p[i][2] << 31); p[i + 1][2] = (p[i][2] >> 1) | (p[i][1] << 31); p[i + 1][1] = (p[i][1] >> 1) | (p[i][0] << 31); p[i + 1][0] = (p[i][0] >> 1) ^ gf_poly[p[i][3] & 1]; } memset(r, 0, CBLK_LEN); for(i = 0; i < 16; ++i) { if(i) mul_bex8(r); /* order is always big endian here */ diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c index 058fa975..6d9907cd 100644 --- a/src/Common/Keyfiles.c +++ b/src/Common/Keyfiles.c @@ -226,61 +226,61 @@ close: BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, const wchar_t* volumeFileName) { BOOL status = TRUE; KeyFile kfSubStruct; KeyFile *kf; KeyFile *kfSub = &kfSubStruct; static unsigned __int8 keyPool [KEYFILE_POOL_SIZE]; size_t i; struct stat statStruct; wchar_t searchPath [TC_MAX_PATH*2]; struct _wfinddata_t fBuf; intptr_t searchHandle; unsigned __int32 keyPoolSize = password->Length <= MAX_LEGACY_PASSWORD? KEYFILE_POOL_LEGACY_SIZE : KEYFILE_POOL_SIZE; HiddenFilesPresentInKeyfilePath = FALSE; if (firstKeyFile == NULL) return TRUE; VirtualLock (keyPool, sizeof (keyPool)); memset (keyPool, 0, sizeof (keyPool)); for (kf = firstKeyFile; kf != NULL; kf = kf->Next) { // Determine whether it's a security token path try { if (Token::IsKeyfilePathValid (kf->FileName, EMVSupportEnabled? true : false)) { // Apply security token keyfile - vector <byte> keyfileData; + vector <uint8> keyfileData; TokenKeyfilePath secPath (kf->FileName); Token::getTokenKeyfile (secPath)->GetKeyfileData (keyfileData); if (keyfileData.empty()) { SetLastError (ERROR_HANDLE_EOF); handleWin32Error (hwndDlg, SRC_POS); Error ("ERR_PROCESS_KEYFILE", hwndDlg); status = FALSE; continue; } unsigned __int32 crc = 0xffffffff; unsigned __int32 writePos = 0; size_t totalRead = 0; for (size_t i = 0; i < keyfileData.size(); i++) { crc = UPDC32 (keyfileData[i], crc); keyPool[writePos++] += (unsigned __int8) (crc >> 24); keyPool[writePos++] += (unsigned __int8) (crc >> 16); keyPool[writePos++] += (unsigned __int8) (crc >> 8); keyPool[writePos++] += (unsigned __int8) crc; if (writePos >= keyPoolSize) writePos = 0; if (++totalRead >= KEYFILE_MAX_READ_LEN) break; @@ -457,110 +457,128 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa DragAcceptFiles (hwndDlg, TRUE); 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"); 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) ) { /* default keyfile dialog case */ SetCheckBox (hwndDlg, IDC_KEYFILES_TRY_EMPTY_PASSWORD, bTryEmptyPasswordWhenKeyfileUsed); ShowWindow(GetDlgItem(hwndDlg, IDC_KEYFILES_TRY_EMPTY_PASSWORD), SW_SHOW); } #endif SetWindowTextW(GetDlgItem(hwndDlg, IDT_KEYFILES_NOTE), GetString ("KEYFILES_NOTE")); ToHyperlink (hwndDlg, IDC_LINK_KEYFILES_INFO); + ToHyperlink (hwndDlg, IDC_LINK_KEYFILES_EXTENSIONS_WARNING); } return 1; + case WM_CTLCOLORSTATIC: + { + if (((HWND)lParam == GetDlgItem(hwndDlg, IDT_KEYFILE_WARNING)) ) + { + // we're about to draw the static + // set the text colour in (HDC)wParam + SetBkMode((HDC)wParam,TRANSPARENT); + SetTextColor((HDC)wParam, RGB(255,0,0)); + return (BOOL)GetSysColorBrush(COLOR_MENU); + } + } + return 0; + case WM_COMMAND: if (lw == IDC_KEYADD) { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { - if (SelectMultipleFiles (hwndDlg, "SELECT_KEYFILE", kf->FileName, sizeof(kf->FileName),bHistory)) + std::vector<std::wstring> filesList; + if (SelectMultipleFiles (hwndDlg, "SELECT_KEYFILE", bHistory, filesList)) { bool containerFileSkipped = false; - do + for (std::vector<std::wstring>::const_iterator it = filesList.begin(); + it != filesList.end(); + ++it) { + StringCbCopyW (kf->FileName, sizeof (kf->FileName), it->c_str()); CorrectFileName (kf->FileName); if (_wcsicmp (param->VolumeFileName, kf->FileName) == 0) containerFileSkipped = true; else { param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); LoadKeyList (hwndDlg, param->FirstKeyFile); kf = (KeyFile *) malloc (sizeof (KeyFile)); - if (!kf) - { - Warning ("ERR_MEM_ALLOC", hwndDlg); - break; - } + if (!kf) + { + Warning ("ERR_MEM_ALLOC", hwndDlg); + break; + } } - } while (SelectMultipleFilesNext (kf->FileName, sizeof(kf->FileName))); + } if (containerFileSkipped) { Warning ("SELECTED_KEYFILE_IS_CONTAINER_FILE", hwndDlg); } } if (kf) free (kf); } return 1; } if (lw == IDC_ADD_KEYFILE_PATH) { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { - if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName)) + if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName, NULL)) { param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); LoadKeyList (hwndDlg, param->FirstKeyFile); } else { free (kf); } } else { Warning ("ERR_MEM_ALLOC", hwndDlg); } return 1; } if (lw == IDC_TOKEN_FILES_ADD) { list <TokenKeyfilePath> selectedTokenKeyfiles; if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_KEYFILES), hwndDlg, (DLGPROC) SecurityTokenKeyfileDlgProc, (LPARAM) &selectedTokenKeyfiles) == IDOK) { foreach (const TokenKeyfilePath &keyPath, selectedTokenKeyfiles) { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { StringCbCopyW (kf->FileName, sizeof (kf->FileName), wstring(keyPath).c_str ()); param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); LoadKeyList (hwndDlg, param->FirstKeyFile); @@ -583,60 +601,66 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa { ListView_GetItem (list, &LvItem); param->FirstKeyFile = KeyFileRemove (param->FirstKeyFile, (KeyFile *) LvItem.lParam); } LoadKeyList (hwndDlg, param->FirstKeyFile); return 1; } if (lw == IDC_KEYREMOVEALL) { KeyFileRemoveAll (¶m->FirstKeyFile); LoadKeyList (hwndDlg, NULL); return 1; } if (lw == IDC_GENERATE_KEYFILE) { DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_KEYFILE_GENERATOR), hwndDlg, (DLGPROC) KeyfileGeneratorDlgProc, (LPARAM) 0); return 1; } if (lw == IDC_LINK_KEYFILES_INFO) { Applink ("keyfiles"); return 1; } + if (lw == IDC_LINK_KEYFILES_EXTENSIONS_WARNING) + { + Applink ("keyfilesextensions"); + return 1; + } + if (lw == IDOK) { param->EnableKeyFiles = IsButtonChecked (GetDlgItem (hwndDlg, IDC_KEYFILES_ENABLE)); #ifdef TCMOUNT if (IsWindowVisible (GetDlgItem (hwndDlg, IDC_KEYFILES_TRY_EMPTY_PASSWORD))) { bTryEmptyPasswordWhenKeyfileUsed = IsButtonChecked (GetDlgItem (hwndDlg, IDC_KEYFILES_TRY_EMPTY_PASSWORD)); if (UsePreferences) { WaitCursor (); SaveSettings (hwndDlg); NormalCursor (); } } #endif EndDialog (hwndDlg, IDOK); return 1; } if (lw == IDCANCEL) { KeyFileRemoveAll (¶m->FirstKeyFile); *param = origParam; EndDialog (hwndDlg, IDCLOSE); return 1; } break; @@ -684,89 +708,93 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa return 0; } #define IDM_KEYFILES_POPUP_ADD_FILES 9001 #define IDM_KEYFILES_POPUP_ADD_DIR 9002 #define IDM_KEYFILES_POPUP_ADD_TOKEN_FILES 9003 BOOL KeyfilesPopupMenu (HWND hwndDlg, POINT popupPosition, KeyFilesDlgParam *param) { HMENU popup = CreatePopupMenu (); if (!popup) return FALSE; int sel; BOOL status = FALSE; AppendMenuW (popup, MF_STRING, IDM_KEYFILES_POPUP_ADD_FILES, GetString ("IDC_KEYADD")); AppendMenuW (popup, MF_STRING, IDM_KEYFILES_POPUP_ADD_DIR, GetString ("IDC_ADD_KEYFILE_PATH")); AppendMenuW (popup, MF_STRING, IDM_KEYFILES_POPUP_ADD_TOKEN_FILES, GetString ("IDC_TOKEN_FILES_ADD")); sel = TrackPopupMenu (popup, TPM_RETURNCMD | TPM_LEFTBUTTON, popupPosition.x, popupPosition.y, 0, hwndDlg, NULL); switch (sel) { case IDM_KEYFILES_POPUP_ADD_FILES: { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { - if (SelectMultipleFiles (hwndDlg, "SELECT_KEYFILE", kf->FileName, sizeof(kf->FileName),bHistory)) + std::vector<std::wstring> filesList; + if (SelectMultipleFiles (hwndDlg, "SELECT_KEYFILE", bHistory, filesList)) { - do + for (std::vector<std::wstring>::const_iterator it = filesList.begin(); + it != filesList.end(); + ++it) { + StringCbCopyW (kf->FileName, sizeof (kf->FileName), it->c_str()); param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); kf = (KeyFile *) malloc (sizeof (KeyFile)); if (!kf) { Warning ("ERR_MEM_ALLOC", hwndDlg); break; } - } while (SelectMultipleFilesNext (kf->FileName, sizeof(kf->FileName))); + } param->EnableKeyFiles = TRUE; status = TRUE; } if (kf) free (kf); } } break; case IDM_KEYFILES_POPUP_ADD_DIR: { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { - if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName)) + if (BrowseDirectories (hwndDlg,"SELECT_KEYFILE_PATH", kf->FileName, NULL)) { param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); param->EnableKeyFiles = TRUE; status = TRUE; } else { free (kf); } } else { Warning ("ERR_MEM_ALLOC", hwndDlg); } } break; case IDM_KEYFILES_POPUP_ADD_TOKEN_FILES: { list <TokenKeyfilePath> selectedTokenKeyfiles; if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_KEYFILES), hwndDlg, (DLGPROC) SecurityTokenKeyfileDlgProc, (LPARAM) &selectedTokenKeyfiles) == IDOK) { foreach (const TokenKeyfilePath &keyPath, selectedTokenKeyfiles) { KeyFile *kf = (KeyFile *) malloc (sizeof (KeyFile)); if (kf) { StringCbCopyW (kf->FileName, sizeof (kf->FileName), wstring (keyPath).c_str()); param->FirstKeyFile = KeyFileAdd (param->FirstKeyFile, kf); diff --git a/src/Common/Language.c b/src/Common/Language.c index 278b7dd1..a6bc9891 100644 --- a/src/Common/Language.c +++ b/src/Common/Language.c @@ -56,99 +56,143 @@ static char *MapFirstLanguageFile () if (LanguageFileBuffer != NULL) { free (LanguageFileBuffer); LanguageFileBuffer = NULL; } LanguageResourceId = 0; if (LanguageResource == NULL) { DWORD size; LanguageResource = MapResource (L"Xml", IDR_LANGUAGE, &size); if (LanguageResource) LanguageResourceSize = size; } if (LanguageResource) { LanguageFileBuffer = malloc(LanguageResourceSize + 1); if (LanguageFileBuffer) { memcpy (LanguageFileBuffer, LanguageResource, LanguageResourceSize); LanguageFileBuffer[LanguageResourceSize] = 0; } } return LanguageFileBuffer; } +static int IsValidLanguageFileName(const wchar_t* filename) { + size_t len = wcslen(filename); + + // Check the base format and length directly + if (_wcsnicmp(filename, L"Language.", 9) != 0 || (len != 15 && len != 18)) + return 0; // Does not start with "Language." or has incorrect length + + // Check for the ".xml" suffix + if (_wcsicmp(filename + len - 4, L".xml") != 0) + return 0; // Does not end with ".xml" + + // Detailed checks based on the specific length + if (len == 15) { + // Format should be Language.xx.xml + if (iswalpha(filename[9]) && iswalpha(filename[10])) + return 1; // Valid format for short code + } else if (len == 18) { + // Format should be Language.xx-yy.xml + if (iswalpha(filename[9]) && iswalpha(filename[10]) && filename[11] == L'-' && + iswalpha(filename[12]) && iswalpha(filename[13])) + return 1; // Valid format for long code + } + + return 0; // If none of the conditions are met, the filename is invalid +} static char *MapNextLanguageFile (int resourceid) { wchar_t f[TC_MAX_PATH*2], *t; WIN32_FIND_DATAW find; HANDLE file; DWORD read; BOOL bStatus; + BOOL validFileFound = FALSE; /* free memory here to avoid leaks */ if (LanguageFileBuffer != NULL) { free (LanguageFileBuffer); LanguageFileBuffer = NULL; } if (resourceid == 0) { if (LanguageFileFindHandle == INVALID_HANDLE_VALUE) { GetModuleFileNameW (NULL, f, sizeof (f) / sizeof (f[0])); t = wcsrchr (f, L'\\'); if (t == NULL) return NULL; *t = 0; StringCbCatW (f, sizeof(f), L"\\Languages\\Language*.xml"); LanguageFileFindHandle = FindFirstFileW (f, &find); } else if (!FindNextFileW (LanguageFileFindHandle, &find)) { FindClose (LanguageFileFindHandle); LanguageFileFindHandle = INVALID_HANDLE_VALUE; return NULL; } if (LanguageFileFindHandle == INVALID_HANDLE_VALUE) return NULL; if (find.nFileSizeHigh != 0) return NULL; + // Validate the file name format + while (!validFileFound) + { + if (!IsValidLanguageFileName(find.cFileName)) + { + if (!FindNextFileW(LanguageFileFindHandle, &find)) + { + FindClose(LanguageFileFindHandle); + LanguageFileFindHandle = INVALID_HANDLE_VALUE; + return NULL; + } + } + else + { + validFileFound = TRUE; + } + } + LanguageFileBuffer = malloc(find.nFileSizeLow + 1); if (LanguageFileBuffer == NULL) return NULL; GetModuleFileNameW (NULL, f, sizeof (f) / sizeof(f[0])); t = wcsrchr (f, L'\\'); if (t == NULL) { free(LanguageFileBuffer); LanguageFileBuffer = NULL; return NULL; } t[1] = 0; StringCbCatW (f, sizeof(f), L"Languages\\"); StringCbCatW (f, sizeof(f),find.cFileName); file = CreateFileW (f, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL); if (file == INVALID_HANDLE_VALUE) { free(LanguageFileBuffer); LanguageFileBuffer = NULL; return NULL; } bStatus = ReadFile (file, LanguageFileBuffer, find.nFileSizeLow, &read, NULL); CloseHandle (file); if (!bStatus || (read != find.nFileSizeLow)) { free(LanguageFileBuffer); LanguageFileBuffer = NULL; diff --git a/src/Common/Language.xml b/src/Common/Language.xml index 1abee9d6..9821bbe9 100644 --- a/src/Common/Language.xml +++ b/src/Common/Language.xml @@ -586,85 +586,85 @@ <entry lang="en" key="NO_FREE_DRIVE_FOR_OUTER_VOL">No free drive letter for the outer volume! Volume creation cannot continue.</entry> <entry lang="en" key="NO_OS_VER">Could not determine your operating system version or you are using an unsupported operating system.</entry> <entry lang="en" key="NO_PATH_SELECTED">No path selected!</entry> <entry lang="en" key="NO_SPACE_FOR_HIDDEN_VOL">Not enough free space for the hidden volume! Volume creation cannot continue.</entry> <entry lang="en" key="HIDDEN_VOLUME_TOO_SMALL_FOR_OS_CLONE">Error: The files you copied to the outer volume occupy too much space. Therefore, there is not enough free space on the outer volume for the hidden volume.\n\nNote that the hidden volume must be as large as the system partition (the partition where the currently running operating system is installed). The reason is that the hidden operating system needs to be created by copying the content of the system partition to the hidden volume.\n\n\nThe process of creation of the hidden operating system cannot continue.</entry> <entry lang="en" key="OPENFILES_DRIVER">The driver is unable to dismount the volume. Some files located on the volume are probably still open.</entry> <entry lang="en" key="OPENFILES_LOCK">Unable to lock the volume. There are still open files on the volume. Therefore, it cannot be dismounted.</entry> <entry lang="en" key="VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT">VeraCrypt cannot lock the volume because it is in use by the system or applications (there may be open files on the volume).\n\nDo you want to force dismount on the volume?</entry> <entry lang="en" key="OPEN_VOL_TITLE">Select a VeraCrypt Volume</entry> <entry lang="en" key="OPEN_TITLE">Specify Path and File Name</entry> <entry lang="en" key="SELECT_PKCS11_MODULE">Select PKCS #11 Library</entry> <entry lang="en" key="OUTOFMEMORY">Out of Memory</entry> <entry lang="en" key="FORMAT_DEVICE_FOR_ADVANCED_ONLY">IMPORTANT: We strongly recommend that inexperienced users create a VeraCrypt file container on the selected device/partition, instead of attempting to encrypt the entire device/partition.\n\nWhen you create a VeraCrypt file container (as opposed to encrypting a device or partition) there is, for example, no risk of destroying a large number of files. Note that a VeraCrypt file container (even though it contains a virtual encrypted disk) is actually just like any normal file. For more information, see the chapter Beginner's Tutorial in the VeraCrypt User Guide.\n\nAre you sure you want to encrypt the entire device/partition?</entry> <entry lang="en" key="OVERWRITEPROMPT">WARNING: The file '%s' already exists!\n\nIMPORTANT: VERACRYPT WILL NOT ENCRYPT THE FILE, BUT IT WILL DELETE IT. Are you sure you want to delete the file and replace it with a new VeraCrypt container?</entry> <entry lang="en" key="OVERWRITEPROMPT_DEVICE">CAUTION: ALL FILES CURRENTLY STORED ON THE SELECTED %s '%s'%s WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</entry> <entry lang="en" key="NONSYS_INPLACE_ENC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully encrypted.\n\nAre you sure you want to start encrypting the selected %s '%s'%s?</entry> <entry lang="en" key="NONSYS_INPLACE_DEC_CONFIRM">WARNING: You will not be able to mount the volume or access any files stored on it until it has been fully decrypted.\n\nAre you sure you want to start decrypting the selected %s '%s'%s?</entry> <entry lang="en" key="NONSYS_INPLACE_ENC_CONFIRM_BACKUP">WARNING: Please note that if power supply is suddenly interrupted while encrypting/decrypting existing data in place, or when the operating system crashes due to a software error or hardware malfunction while VeraCrypt is encrypting/decrypting existing data in place, portions of the data will be corrupted or lost. Therefore, before you start encrypting/decrypting, please make sure that you have backup copies of the files you want to encrypt/decrypt.\n\nDo you have such a backup?</entry> <entry lang="en" key="OVERWRITEPROMPT_DEVICE_HIDDEN_OS_PARTITION">CAUTION: ANY FILES CURRENTLY STORED ON THE PARTITION '%s'%s (I.E. ON THE FIRST PARTITION BEHIND THE SYSTEM PARTITION) WILL BE ERASED AND LOST (THEY WILL NOT BE ENCRYPTED)!\n\nAre you sure you want to proceed with format?</entry> <entry lang="en" key="OVERWRITEPROMPT_DEVICE_SECOND_WARNING_LOTS_OF_DATA">WARNING: THE SELECTED PARTITION CONTAINS A LARGE AMOUNT OF DATA! Any files stored on the partition will be erased and lost (they will NOT be encrypted)!</entry> <entry lang="en" key="ERASE_FILES_BY_CREATING_VOLUME">Erase any files stored on the partition by creating a VeraCrypt volume within it</entry> <entry lang="en" key="PASSWORD">Password</entry> <entry lang="en" key="PIM">PIM</entry> <entry lang="en" key="IDD_PCDM_CHANGE_PKCS5_PRF">Set Header Key Derivation Algorithm</entry> <entry lang="en" key="IDD_PCDM_ADD_REMOVE_VOL_KEYFILES">Add/Remove Keyfiles to/from Volume</entry> <entry lang="en" key="IDD_PCDM_REMOVE_ALL_KEYFILES_FROM_VOL">Remove All Keyfiles from Volume</entry> <entry lang="en" key="PASSWORD_CHANGED">Password, PIM and/or keyfile(s) successfully changed.\n\nIMPORTANT: Please make sure you have read the section 'Changing Passwords and Keyfiles' in the chapter 'Security Requirements and Precautions' in the VeraCrypt User Guide.</entry> <entry lang="en" key="FAVORITE_PIM_CHANGED">This volume is registered as a System Favorite and its PIM was changed.\nDo you want VeraCrypt to automatically update the System Favorite configuration (administrator privileges required)?\n\nPlease note that if you answer no, you'll have to update the System Favorite manually.</entry> <entry lang="en" key="SYS_PASSWORD_CHANGED_ASK_RESCUE_DISK">IMPORTANT: If you did not destroy your VeraCrypt Rescue Disk, your system partition/drive can still be decrypted using the old password (by booting the VeraCrypt Rescue Disk and entering the old password). You should create a new VeraCrypt Rescue Disk and then destroy the old one.\n\nDo you want to create a new VeraCrypt Rescue Disk?</entry> <entry lang="en" key="SYS_HKD_ALGO_CHANGED_ASK_RESCUE_DISK">Note that your VeraCrypt Rescue Disk still uses the previous algorithm. If you consider the previous algorithm insecure, you should create a new VeraCrypt Rescue Disk and then destroy the old one.\n\nDo you want to create a new VeraCrypt Rescue Disk?</entry> - <entry lang="en" key="KEYFILES_NOTE">Any kind of file (for example, .mp3, .jpg, .zip, .avi) may be used as a VeraCrypt keyfile. Note that VeraCrypt never modifies the keyfile contents. You can select more than one keyfile (the order does not matter). If you add a folder, all non-hidden files found in it will be used as keyfiles. Click 'Add Token Files' to select keyfiles stored on security tokens or smart cards (or to import keyfiles to security tokens or smart cards).</entry> + <entry lang="en" key="KEYFILES_NOTE">Note that VeraCrypt never modifies the keyfile contents. You can select more than one keyfile (the order does not matter). If you add a folder, all non-hidden files found in it will be used as keyfiles. Click 'Add Token Files' to select keyfiles stored on security tokens or smart cards (or to import keyfiles to security tokens or smart cards).</entry> <entry lang="en" key="KEYFILE_CHANGED">Keyfile(s) successfully added/removed.</entry> <entry lang="en" key="KEYFILE_EXPORTED">Keyfile exported.</entry> <entry lang="en" key="PKCS5_PRF_CHANGED">Header key derivation algorithm successfully set.</entry> <entry lang="en" key="NONSYS_INPLACE_ENC_RESUME_PASSWORD_PAGE_HELP">Please enter the password and/or keyfile(s) for the non-system volume where you want to resume the process of in-place encryption/decryption.\n\nRemark: After you click Next, VeraCrypt will attempt to find all non-system volumes where the process of encryption/decryption has been interrupted and where the VeraCrypt volume header can be deciphered using the supplied password and/or keyfile(s). If more than one such volume is found, you will need to select one of them in the next step.</entry> <entry lang="en" key="NONSYS_INPLACE_ENC_RESUME_VOL_SELECT_HELP">Please select one of the listed volumes. The list contains each accessible non-system volume where the process of encryption/decryption has been interrupted and where the volume header was successfully deciphered using the supplied password and/or keyfile(s).</entry> <entry lang="en" key="NONSYS_INPLACE_DEC_PASSWORD_PAGE_HELP">Please enter the password and/or keyfile(s) for the non-system VeraCrypt volume that you want to decrypt.</entry> <entry lang="en" key="PASSWORD_HELP">It is very important that you choose a good password. You should avoid choosing one that contains only a single word that can be found in a dictionary (or a combination of 2, 3, or 4 such words). It should not contain any names or dates of birth. It should not be easy to guess. A good password is a random combination of upper and lower case letters, numbers, and special characters, such as @ ^ = $ * + etc. We recommend choosing a password consisting of 20 or more characters (the longer, the better). The maximum possible length is 128 characters.</entry> <entry lang="en" key="PASSWORD_HIDDENVOL_HELP">Please choose a password for the hidden volume. </entry> <entry lang="en" key="PASSWORD_HIDDEN_OS_HELP">Please choose a password for the hidden operating system (i.e. for the hidden volume). </entry> <entry lang="en" key="PASSWORD_HIDDEN_OS_NOTE">IMPORTANT: The password that you choose for the hidden operating system in this step must be substantially different from the other two passwords (i.e. from the password for the outer volume and from the password for the decoy operating system).</entry> <entry lang="en" key="PASSWORD_HIDDENVOL_HOST_DIRECT_HELP">Please enter the password for the volume within which you wish to create a hidden volume.\n\nAfter you click Next, VeraCrypt will attempt to mount the volume. As soon as the volume is mounted, its cluster bitmap will be scanned to determine the size of the uninterrupted area of free space (if there is any) whose end is aligned with the end of the volume. This area will accommodate the hidden volume and therefore will limit its maximum possible size. Cluster map scanning is necessary to ensure that no data on the outer volume will be overwritten by the hidden volume.</entry> <entry lang="en" key="PASSWORD_HIDDENVOL_HOST_HELP">\nPlease choose a password for the outer volume. This will be the password that you will be able to reveal to an adversary if you are asked or forced to do so.\n\nIMPORTANT: The password must be substantially different from the one you will choose for the hidden volume.\n\nNote: The maximum possible password length is 128 characters.</entry> <entry lang="en" key="PASSWORD_SYSENC_OUTERVOL_HELP">Please choose a password for the outer volume. This will be the password you will be able to reveal to anyone forcing you to disclose the password for the first partition behind the system partition, where both the outer volume and the hidden volume (containing the hidden operating system) will reside. The existence of the hidden volume (and of the hidden operating system) will remain secret. Note that this password is not for the decoy operating system.\n\nIMPORTANT: The password must be substantially different from the one you will choose for the hidden volume (i.e. for the hidden operating system).</entry> <entry lang="en" key="PASSWORD_HIDVOL_HOST_TITLE">Outer Volume Password</entry> <entry lang="en" key="PASSWORD_HIDVOL_TITLE">Hidden Volume Password</entry> <entry lang="en" key="PASSWORD_HIDDEN_OS_TITLE">Password for Hidden Operating System</entry> <entry lang="en" key="PASSWORD_LENGTH_WARNING">WARNING: Short passwords are easy to crack using brute force techniques!\n\nWe recommend choosing a password consisting of 20 or more characters. Are you sure you want to use a short password?</entry> <entry lang="en" key="PASSWORD_TITLE">Volume Password</entry> - <entry lang="en" key="PASSWORD_WRONG">Operation failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry> - <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG">Operation failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry> - <entry lang="en" key="PASSWORD_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry> - <entry lang="en" key="PASSWORD_OR_KEYFILE_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry> - <entry lang="en" key="PASSWORD_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</entry> - <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</entry> + <entry lang="en" key="PASSWORD_WRONG">Operation failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> + <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG">Operation failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> + <entry lang="en" key="PASSWORD_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> + <entry lang="en" key="PASSWORD_OR_KEYFILE_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> + <entry lang="en" key="PASSWORD_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> + <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry> <entry lang="en" key="PASSWORD_WRONG_CAPSLOCK_ON">\n\nWarning: Caps Lock is on. This may cause you to enter your password incorrectly.</entry> <entry lang="en" key="PIM_CHANGE_WARNING">Remember Number to Mount Volume</entry> <entry lang="en" key="PIM_HIDVOL_HOST_TITLE">Outer Volume PIM</entry> <entry lang="en" key="PIM_HIDVOL_TITLE">Hidden Volume PIM</entry> <entry lang="en" key="PIM_HIDDEN_OS_TITLE">PIM for Hidden Operating System</entry> <entry lang="en" key="PIM_HELP">PIM (Personal Iterations Multiplier) is a value that controls the number of iterations used by the header key derivation as follows:\n Iterations = 15000 + (PIM x 1000).\n\nWhen left empty or set to 0, VeraCrypt will use a default value (485) that ensures a high security.\n\nWhen the password is less than 20 characters, PIM can't be smaller than 485 in order to maintain a minimal security level.\nWhen the password is 20 characters or more, PIM can be set to any value.\n\nA PIM value larger than 485 will lead to slower mount. A small PIM value (less than 485) will lead to a quicker mount but it can reduce security if the password is not strong enough.</entry> <entry lang="en" key="PIM_SYSENC_HELP">PIM (Personal Iterations Multiplier) is a value that controls the number of iterations used by the header key derivation as follows:\n Iterations = PIM x 2048.\n\nWhen left empty or set to 0, VeraCrypt will use a default value that ensures a high security.\n\nWhen the password is less than 20 characters, PIM can't be smaller than 98 in order to maintain a minimal security level.\nWhen the password is 20 characters or more, PIM can be set to any value.\n\nA PIM value larger than 98 will lead to slower boot. A small PIM value (less than 98) will lead to a quicker boot but it can reduce security if the password is not strong enough.</entry> <entry lang="en" key="PIM_SYSENC_CHANGE_WARNING">Remember Number to Boot System</entry> <entry lang="en" key="PIM_LARGE_WARNING">You have chosen a PIM value that is larger than VeraCrypt default value.\nPlease note that this will lead to much slower mount/boot.</entry> <entry lang="en" key="PIM_SMALL_WARNING">You have chosen a Personal Iterations Multiplier (PIM) that is smaller than the default VeraCrypt value. Please note that if your password is not strong enough, this could lead to a weaker security.\n\nDo you confirm that you are using a strong password?</entry> <entry lang="en" key="PIM_SYSENC_TOO_BIG">Personal Iterations Multiplier (PIM) maximum value for system encryption is 65535.</entry> <entry lang="en" key="PIM_TITLE">Volume PIM</entry> <entry lang="en" key="HIDDEN_FILES_PRESENT_IN_KEYFILE_PATH">\n\nWARNING: Hidden file(s) have been found in a keyfile search path. Such hidden files cannot be used as keyfiles. If you need to use them as keyfiles, remove their 'Hidden' attribute (right-click each of them, select 'Properties', uncheck 'Hidden' and click OK). Note: Hidden files are visible only if the corresponding option is enabled (Computer > Organize > 'Folder and search options' > View).</entry> <entry lang="en" key="HIDDEN_VOL_PROT_PASSWORD_US_KEYB_LAYOUT">If you are attempting to protect a hidden volume containing a hidden system, please make sure you are using the standard US keyboard layout when typing the password for the hidden volume. This is required due to the fact that the password needs to be typed in the pre-boot environment (before Windows starts) where non-US Windows keyboard layouts are not available.</entry> <entry lang="en" key="FOUND_NO_PARTITION_W_DEFERRED_INPLACE_ENC">VeraCrypt has not found any volume where the process of encryption/decryption of a non-system volume has been interrupted and where the volume header can be deciphered using the supplied password and/or keyfile(s).\n\nPlease make sure the password and/or keyfile(s) are correct and that the partition/volume is not being used by the system or applications (including antivirus software).</entry> <entry lang="en" key="SELECTED_PARTITION_ALREADY_INPLACE_ENC">The selected partition/device is already fully encrypted.\nHeader Flags = 0x%.8X</entry> <entry lang="en" key="SELECTED_PARTITION_NOT_INPLACE_ENC">The selected partition/device is not using in-place encryption.\nHeader Flags = 0x%.8X</entry> <entry lang="en" key="SYSENC_MOUNT_WITHOUT_PBA_NOTE">\n\nNote: If you are attempting to mount a partition located on an encrypted system drive without pre-boot authentication or to mount the encrypted system partition of an operating system that is not running, you can do so by selecting 'System' > 'Mount Without Pre-Boot Authentication'.</entry> <entry lang="en" key="MOUNT_WITHOUT_PBA_VOL_ON_ACTIVE_SYSENC_DRIVE">In this mode, you cannot mount a partition located on a drive whose portion is within the key scope of active system encryption.\n\nBefore you can mount this partition in this mode, you need to either boot an operating system installed on a different drive (encrypted or unencrypted) or boot an unencrypted operating system.</entry> <entry lang="en" key="CANT_DECRYPT_PARTITION_ON_ENTIRELY_ENCRYPTED_SYS_DRIVE">VeraCrypt cannot decrypt an individual partition on an entirely encrypted system drive (you can decrypt only the entire system drive).</entry> <entry lang="en" key="CANT_DECRYPT_PARTITION_ON_ENTIRELY_ENCRYPTED_SYS_DRIVE_UNSURE">Warning: As the drive contains the VeraCrypt Boot Loader, it may be an entirely encrypted system drive. If it is, please note that VeraCrypt cannot decrypt an individual partition on an entirely encrypted system drive (you can decrypt only the entire system drive). If that is the case, you will be able to continue now but you will receive the 'Incorrect password' error message later.</entry> <entry lang="en" key="PREV">< &Back</entry> <entry lang="en" key="RAWDEVICES">Unable to list raw devices installed on your system!</entry> <entry lang="en" key="READONLYPROMPT">The volume '%s' exists, and is read-only. Are you sure you want to replace it?</entry> <entry lang="en" key="SELECT_DEST_DIR">Select destination directory</entry> <entry lang="en" key="SELECT_KEYFILE">Select Keyfile</entry> <entry lang="en" key="SELECT_KEYFILE_PATH">Select a keyfile search path. WARNING: Note that only the path will be remembered, not the filenames!</entry> <entry lang="en" key="SELECT_KEYFILE_GENERATION_DIRECTORY">Select a directory where to store the keyfiles.</entry> <entry lang="en" key="SELECTED_KEYFILE_IS_CONTAINER_FILE">The current container file was selected as a keyfile. It will be skipped.</entry> <entry lang="en" key="SERPENT_HELP">Designed by Ross Anderson, Eli Biham, and Lars Knudsen. Published in 1998. 256-bit key, 128-bit block. Mode of operation is XTS. Serpent was one of the AES finalists.</entry> @@ -1557,107 +1557,117 @@ <entry lang="en" key="EXCEPTION_OCCURRED">Exception occurred</entry> <entry lang="en" key="ENTER_PASSWORD">Enter password</entry> <entry lang="en" key="ENTER_TC_VOL_PASSWORD">Enter VeraCrypt Volume Password</entry> <entry lang="en" key="MOUNT">Mount</entry> <entry lang="en" key="MOUNT_POINT">Mount Directory</entry> <entry lang="en" key="NO_VOLUMES_MOUNTED">No volumes mounted.</entry> <entry lang="en" key="OPEN_NEW_VOLUME">Specify a New VeraCrypt Volume</entry> <entry lang="en" key="PARAMETER_INCORRECT">Parameter incorrect</entry> <entry lang="en" key="SELECT_KEYFILES">Select Keyfiles</entry> <entry lang="en" key="START_TC">Start VeraCrypt</entry> <entry lang="en" key="VOLUME_ALREADY_MOUNTED">The volume {0} is already mounted.</entry> <entry lang="en" key="UNKNOWN_OPTION">Unknown option</entry> <entry lang="en" key="VOLUME_LOCATION">Volume Location</entry> <entry lang="en" key="VOLUME_HOST_IN_USE">WARNING: The host file/device {0} is already in use!\n\nIgnoring this can cause undesired results including system instability. All applications that might be using the host file/device should be closed before mounting the volume.\n\nContinue mounting?</entry> <entry lang="en" key="CANT_INSTALL_WITH_EXE_OVER_MSI">VeraCrypt was previously installed using an MSI package and so it can't be updated using the standard installer.\n\nPlease use the MSI package to update your VeraCrypt installation.</entry> <entry lang="en" key="IDC_USE_ALL_FREE_SPACE">Use all available free space</entry> <entry lang="en" key="SYS_ENCRYPTION_UPGRADE_UNSUPPORTED_ALGORITHM">VeraCrypt cannot be upgraded because the system partition/drive was encrypted using an algorithm that is not supported anymore.\nPlease decrypt your system before upgrading VeraCrypt and then encrypt it again.</entry> <entry lang="en" key="LINUX_EX2MSG_TERMINALNOTFOUND">Supported terminal application could not be found, you need either xterm, konsole or gnome-terminal (with dbus-x11).</entry> <entry lang="en" key="IDM_MOUNT_NO_CACHE">Mount Without Cache</entry> <entry lang="en" key="EXPANDER_INFO">:: VeraCrypt Expander ::\n\nExpand a VeraCrypt volume on the fly without reformatting\n\n\nAll kind of volumes (container files, disks and partitions) formatted with NTFS are supported. The only condition is that there must be enough free space on the host drive or host device of the VeraCrypt volume.\n\nDo not use this software to expand an outer volume containing a hidden volume, because this destroys the hidden volume!\n</entry> <entry lang="en" key="IDC_STEPSEXPAND">1. Select the VeraCrypt volume to be expanded\n2. Click the 'Mount' button</entry> <entry lang="en" key="IDT_VOL_NAME">Volume: </entry> <entry lang="en" key="IDT_FILE_SYS">File system: </entry> <entry lang="en" key="IDT_CURRENT_SIZE">Current size: </entry> <entry lang="en" key="IDT_NEW_SIZE">New size: </entry> <entry lang="en" key="IDT_NEW_SIZE_BOX_TITLE">Enter new volume size</entry> <entry lang="en" key="IDC_INIT_NEWSPACE">Fill new space with random data</entry> <entry lang="en" key="IDC_QUICKEXPAND">Quick Expand</entry> <entry lang="en" key="IDT_INIT_SPACE">Fill new space: </entry> <entry lang="en" key="EXPANDER_FREE_SPACE">%s free space available on host drive</entry> - <entry lang="en" key="EXPANDER_HELP_DEVICE">This is a device-based VeraCrypt volume.\n\nThe new volume size will be choosen automatically as the size of the host device.</entry> + <entry lang="en" key="EXPANDER_HELP_DEVICE">This is a device-based VeraCrypt volume.\n\nThe new volume size will be chosen automatically as the size of the host device.</entry> <entry lang="en" key="EXPANDER_HELP_FILE">Please specify the new size of the VeraCrypt volume (must be at least %I64u KB larger than the current size).</entry> <entry lang="en" key="QUICK_EXPAND_WARNING">WARNING: You should use Quick Expand only in the following cases:\n\n1) The device where the file container is located contains no sensitive data and you do not need plausible deniability.\n2) The device where the file container is located has already been securely and fully encrypted.\n\nAre you sure you want to use Quick Expand?</entry> <entry lang="en" key="EXPANDER_STATUS_TEXT">IMPORTANT: Move your mouse as randomly as possible within this window. The longer you move it, the better. This significantly increases the cryptographic strength of the encryption keys. Then click 'Continue' to expand the volume.</entry> <entry lang="en" key="EXPANDER_STATUS_TEXT_LEGACY">Click 'Continue' to expand the volume.</entry> <entry lang="en" key="EXPANDER_FINISH_ERROR">Error: volume expansion failed.</entry> <entry lang="en" key="EXPANDER_FINISH_ABORT">Error: operation aborted by user.</entry> <entry lang="en" key="EXPANDER_FINISH_OK">Finished. Volume successfully expanded.</entry> <entry lang="en" key="EXPANDER_CANCEL_WARNING">Warning: Volume expansion is in progress!\n\nStopping now may result in a damaged volume.\n\nDo you really want to cancel?</entry> <entry lang="en" key="EXPANDER_STARTING_STATUS">Starting volume expansion ...\n</entry> <entry lang="en" key="EXPANDER_HIDDEN_VOLUME_ERROR">An outer volume containing a hidden volume can't be expanded, because this destroys the hidden volume.\n</entry> <entry lang="en" key="EXPANDER_SYSTEM_VOLUME_ERROR">A VeraCrypt system volume can't be expanded.</entry> <entry lang="en" key="EXPANDER_NO_FREE_SPACE">Not enough free space to expand the volume</entry> <entry lang="en" key="EXPANDER_WARNING_FILE_CONTAINER_JUNK">Warning: The container file is larger than the VeraCrypt volume area. The data after the VeraCrypt volume area will be overwritten.\n\nDo you want to continue?</entry> <entry lang="en" key="EXPANDER_WARNING_FAT">Warning: The VeraCrypt volume contains a FAT file system!\n\nOnly the VeraCrypt volume itself will be expanded, but not the file system.\n\nDo you want to continue?</entry> <entry lang="en" key="EXPANDER_WARNING_EXFAT">Warning: The VeraCrypt volume contains an exFAT file system!\n\nOnly the VeraCrypt volume itself will be expanded, but not the file system.\n\nDo you want to continue?</entry> <entry lang="en" key="EXPANDER_WARNING_UNKNOWN_FS">Warning: The VeraCrypt volume contains an unknown or no file system!\n\nOnly the VeraCrypt volume itself will be expanded, the file system remains unchanged.\n\nDo you want to continue?</entry> - <entry lang="en" key="EXPANDER_ERROR_VOLUME_SIZE_TOO_SMALL">New volume size too small, must be at least %I64u kB larger than the current size.</entry> + <entry lang="en" key="EXPANDER_ERROR_VOLUME_SIZE_TOO_SMALL">New volume size too small, must be at least %I64u KiB larger than the current size.</entry> <entry lang="en" key="EXPANDER_ERROR_VOLUME_SIZE_TOO_LARGE">New volume size too large, not enough space on host drive.</entry> <entry lang="en" key="EXPANDER_ERROR_MAX_FILE_SIZE_EXCEEDED">Maximum file size of %I64u MB on host drive exceeded.</entry> <entry lang="en" key="EXPANDER_ERROR_QUICKEXPAND_PRIVILEGES">Error: Failed to get necessary privileges to enable Quick Expand!\nPlease uncheck Quick Expand option and try again.</entry> <entry lang="en" key="EXPANDER_ERROR_MAX_VC_VOLUME_SIZE_EXCEEDED">Maximum VeraCrypt volume size of %I64u TB exceeded!\n</entry> <entry lang="en" key="FULL_FORMAT">Full Format</entry> <entry lang="en" key="FAST_CREATE">Fast Create</entry> <entry lang="en" key="WARN_FAST_CREATE">WARNING: You should use Fast Create only in the following cases:\n\n1) The device contains no sensitive data and you do not need plausible deniability.\n2) The device has already been securely and fully encrypted.\n\nAre you sure you want to use Fast Create?</entry> <entry lang="en" key="IDC_ENABLE_EMV_SUPPORT">Enable EMV Support</entry> <entry lang="en" key="COMMAND_APDU_INVALID">The APDU command sent to the card is not valid.</entry> <entry lang="en" key="EXTENDED_APDU_UNSUPPORTED">Extended APDU commands cannot be used with the current token.</entry> <entry lang="en" key="SCARD_MODULE_INIT_FAILED">Error when loading the WinSCard / PCSC library.</entry> <entry lang="en" key="EMV_UNKNOWN_CARD_TYPE">The card in the reader is not a supported EMV card.</entry> <entry lang="en" key="EMV_SELECT_AID_FAILED">The AID of the card in the reader could not be selected.</entry> <entry lang="en" key="EMV_ICC_CERT_NOTFOUND">ICC Public Key Certificate was not found in the card.</entry> <entry lang="en" key="EMV_ISSUER_CERT_NOTFOUND">Issuer Public Key Certificate was not found in the card.</entry> - <entry lang="en" key="EMV_CPLC_NOTFOUND">CLPC was not found in the EMV card.</entry> + <entry lang="en" key="EMV_CPLC_NOTFOUND">CPLC was not found in the EMV card.</entry> <entry lang="en" key="EMV_PAN_NOTFOUND">No Primary Account Number (PAN) found in the EMV card.</entry> <entry lang="en" key="INVALID_EMV_PATH">EMV path is invalid.</entry> - <entry lang="en" key="EMV_KEYFILE_DATA_NOTFOUND">Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data.</entry> + <entry lang="en" key="EMV_KEYFILE_DATA_NOTFOUND">Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPLC data.</entry> <entry lang="en" key="SCARD_W_REMOVED_CARD">No card in the reader.\n\nPlease make sure the card is correctly slotted.</entry> <entry lang="en" key="FORMAT_EXTERNAL_FAILED">Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API.</entry> <entry lang="en" key="FORMATEX_API_FAILED">Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s.</entry> <entry lang="en" key="EXPANDER_WRITING_RANDOM_DATA">Writing random data to new space ...\n</entry> <entry lang="en" key="EXPANDER_WRITING_ENCRYPTED_BACKUP">Writing re-encrypted backup header ...\n</entry> <entry lang="en" key="EXPANDER_WRITING_ENCRYPTED_PRIMARY">Writing re-encrypted primary header ...\n</entry> <entry lang="en" key="EXPANDER_WIPING_OLD_HEADER">Wiping old backup header ...\n</entry> <entry lang="en" key="EXPANDER_MOUNTING_VOLUME">Mounting volume ...\n</entry> <entry lang="en" key="EXPANDER_UNMOUNTING_VOLUME">Unmounting volume ...\n</entry> <entry lang="en" key="EXPANDER_EXTENDING_FILESYSTEM">Extending file system ...\n</entry> + <entry lang="en" key="PARTIAL_SYSENC_MOUNT_READONLY">Warning: The system partition you attempted to mount was not fully encrypted. As a safety measure to prevent potential corruption or unwanted modifications, volume '%s' was mounted as read-only.</entry> + <entry lang="en" key="IDC_LINK_KEYFILES_EXTENSIONS_WARNING">Important information on using third-party file extensions</entry> + <entry lang="en" key="IDC_DISABLE_MEMORY_PROTECTION">Disable memory protection for Accessibility tools compatibility</entry> + <entry lang="en" key="DISABLE_MEMORY_PROTECTION_WARNING">WARNING: Disabling memory protection significantly reduces security. Enable this option ONLY if you rely on Accessibility tools, like Screen Readers, to interact with VeraCrypt's UI.</entry> + <entry lang="en" key="LINUX_LANGUAGE">Language</entry> + <entry lang="en" key="LINUX_SELECT_SYS_DEFAULT_LANG">Select system's default language</entry> + <entry lang="en" key="LINUX_RESTART_FOR_LANGUAGE_CHANGE">For the language change to come into effect, VeraCrypt needs to be restarted.</entry> + <entry lang="en" key="ERR_XTS_MASTERKEY_VULNERABLE">WARNING: The volume's master key is vulnerable to an attack that compromises data security.\n\nPlease create a new volume and transfer the data to it.</entry> + <entry lang="en" key="ERR_SYSENC_XTS_MASTERKEY_VULNERABLE">WARNING: The encrypted system's master key is vulnerable to an attack that compromises data security.\nPlease decrypt the system partition/drive and then re-encrypt it.</entry> + <entry lang="en" key="ERR_XTS_MASTERKEY_VULNERABLE_SHORT">WARNING: The volume's master key has a security vulnerability.</entry> </localization> <xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:element name="VeraCrypt"> <xs:complexType> <xs:sequence> <xs:element name="localization"> <xs:complexType> <xs:sequence> <xs:element name="language"> <xs:complexType> <xs:attribute name="langid" type="xs:string" use="required" /> <xs:attribute name="name" type="xs:string" use="required" /> <xs:attribute name="en-name" type="xs:string" use="required" /> <xs:attribute name="version" type="xs:string" use="required" /> <xs:attribute name="translators" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element minOccurs="4" maxOccurs="4" name="font"> <xs:complexType> <xs:attribute name="lang" type="xs:string" use="required" /> <xs:attribute name="class" type="xs:string" use="required" /> <xs:attribute name="size" type="xs:unsignedByte" use="required" /> <xs:attribute name="face" type="xs:string" use="required" /> </xs:complexType> </xs:element> <xs:element maxOccurs="unbounded" name="entry"> <xs:complexType> <xs:simpleContent> <xs:extension base="xs:string"> <xs:attribute name="lang" type="xs:string" use="required" /> diff --git a/src/Common/Lzma_vs2019.vcxproj b/src/Common/Lzma_vs2019.vcxproj index 81a57daa..9f640dc5 100644 --- a/src/Common/Lzma_vs2019.vcxproj +++ b/src/Common/Lzma_vs2019.vcxproj @@ -34,60 +34,61 @@ <ClCompile Include="lzma\Alloc.c" /> <ClCompile Include="lzma\CpuArch.c" /> <ClCompile Include="lzma\LzFind.c" /> <ClCompile Include="lzma\LzFindMt.c" /> <ClCompile Include="lzma\LzFindOpt.c" /> <ClCompile Include="lzma\LzmaDec.c" /> <ClCompile Include="lzma\LzmaEnc.c" /> <ClCompile Include="lzma\LzmaLib.c" /> <ClCompile Include="lzma\Threads.c" /> </ItemGroup> <ItemGroup> <ClInclude Include="lzma\7zTypes.h" /> <ClInclude Include="lzma\7zWindows.h" /> <ClInclude Include="lzma\Alloc.h" /> <ClInclude Include="lzma\Compiler.h" /> <ClInclude Include="lzma\CpuArch.h" /> <ClInclude Include="lzma\LzFind.h" /> <ClInclude Include="lzma\LzFindMt.h" /> <ClInclude Include="lzma\LzHash.h" /> <ClInclude Include="lzma\LzmaDec.h" /> <ClInclude Include="lzma\LzmaEnc.h" /> <ClInclude Include="lzma\LzmaLib.h" /> <ClInclude Include="lzma\Precomp.h" /> <ClInclude Include="lzma\Threads.h" /> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{B896FE1F-6BF3-4F75-9148-F841829073D9}</ProjectGuid> <Keyword>Win32Proj</Keyword> <RootNamespace>Lzma</RootNamespace> <ProjectName>Lzma</ProjectName> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> @@ -101,147 +102,156 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> </Project>
\ No newline at end of file diff --git a/src/Common/PCSCException.cpp b/src/Common/PCSCException.cpp index 93fff181..dc5eead3 100644 --- a/src/Common/PCSCException.cpp +++ b/src/Common/PCSCException.cpp @@ -113,68 +113,71 @@ namespace VeraCrypt if (!GetDictionaryValue(errorString.c_str())) { if (errorString.find("SCARD_E_") == 0 || errorString.find("SCARD_F_") == 0 || errorString.find("SCARD_W_") == 0) { errorString = errorString.substr(8); for (size_t i = 0; i < errorString.size(); ++i) { if (errorString[i] == '_') errorString[i] = ' '; } } wchar_t err[8192]; StringCbPrintfW(err, sizeof(err), L"%s:\n\n%hs%s", GetString("PCSC_ERROR"), errorString.c_str()); ErrorDirect(err, parent); } else { wstring err = GetString(errorString.c_str()); ErrorDirect(err.c_str(), parent); } } } #endif // TC_HEADER_Common_Exception #ifdef TC_HEADER_Platform_Exception void PCSCException::Deserialize(shared_ptr <Stream> stream) { Exception::Deserialize(stream); Serializer sr(stream); - sr.Deserialize("ErrorCode", ErrorCode); + int64 v; + sr.Deserialize("ErrorCode", v); + ErrorCode = (LONG_PCSC)v; } void PCSCException::Serialize(shared_ptr <Stream> stream) const { Exception::Serialize(stream); Serializer sr(stream); - sr.Serialize("ErrorCode", ErrorCode); + int64 v = (int64)ErrorCode; + sr.Serialize("ErrorCode", v); } # define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) # undef TC_EXCEPTION_NODECL # define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET(PCSCException); #endif CommandAPDUNotValid::operator string() const { return string(ErrorStr); } #ifdef TC_HEADER_Common_Exception void CommandAPDUNotValid::Show(HWND parent) const { string msgBody = "Command APDU invalid.\n\n\n(If you report a bug in connection with this, please include the following technical information in the bug report:\n" + SrcPos + "\nLast Error = " + ErrorStr + ")"; MessageBoxA (parent, msgBody.c_str(), "VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND); } #endif // TC_HEADER_Common_Exception #ifdef TC_HEADER_Platform_Exception void CommandAPDUNotValid::Deserialize(shared_ptr <Stream> stream) { Exception::Deserialize(stream); Serializer sr(stream); sr.Deserialize("SrcPos", SrcPos); diff --git a/src/Common/Password.c b/src/Common/Password.c index ae6b8035..c0247207 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -344,60 +344,64 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, headerOffset.QuadPart = TC_HIDDEN_VOLUME_HEADER_OFFSET; break; } if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } /* Read in volume header */ if (!ReadEffectiveVolumeHeader (bDevice, dev, buffer, &bytesRead)) { nStatus = ERR_OS_ERROR; goto error; } if (bytesRead != sizeof (buffer)) { // Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS memset (buffer, 0, sizeof (buffer)); } /* Try to decrypt the header */ nStatus = ReadVolumeHeader (FALSE, buffer, oldPassword, old_pkcs5, old_pim, &cryptoInfo, NULL); if (nStatus == ERR_CIPHER_INIT_WEAK_KEY) nStatus = 0; // We can ignore this error here + // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed + if ((nStatus == 0) && cryptoInfo->bVulnerableMasterKey) + nStatus = ERR_XTS_MASTERKEY_VULNERABLE; + if (nStatus == ERR_PASSWORD_WRONG) { continue; // Try next volume type } else if (nStatus != 0) { cryptoInfo = NULL; goto error; } else break; } if (nStatus != 0) { cryptoInfo = NULL; goto error; } if (cryptoInfo->HeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM) { nStatus = ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG; goto error; } // Change the PKCS-5 PRF if requested by user if (pkcs5 != 0) cryptoInfo->pkcs5 = pkcs5; RandSetHashFunction (cryptoInfo->pkcs5); diff --git a/src/Common/Random.c b/src/Common/Random.c index fd836c7f..ee3fcf53 100644 --- a/src/Common/Random.c +++ b/src/Common/Random.c @@ -235,167 +235,172 @@ BOOL IsRandomNumberGeneratorStarted () void RandSetHashFunction (int hash_algo_id) { if (HashIsDeprecated (hash_algo_id)) hash_algo_id = DEFAULT_HASH_ALGORITHM; HashFunction = hash_algo_id; } int RandGetHashFunction (void) { return HashFunction; } void SetRandomPoolEnrichedByUserStatus (BOOL enriched) { RandomPoolEnrichedByUser = enriched; } BOOL IsRandomPoolEnrichedByUser () { return RandomPoolEnrichedByUser; } /* The random pool mixing function */ BOOL Randmix () { if (bRandmixEnabled) { unsigned char hashOutputBuffer [MAX_DIGESTSIZE]; - WHIRLPOOL_CTX wctx; - blake2s_state bctx; + #ifndef WOLFCRYPT_BACKEND + WHIRLPOOL_CTX wctx; + blake2s_state bctx; + STREEBOG_CTX stctx; + #endif sha512_ctx sctx; sha256_ctx s256ctx; - STREEBOG_CTX stctx; int poolIndex, digestIndex, digestSize; switch (HashFunction) { - case BLAKE2S: - digestSize = BLAKE2S_DIGESTSIZE; - break; - case SHA512: digestSize = SHA512_DIGESTSIZE; break; case SHA256: digestSize = SHA256_DIGESTSIZE; break; + #ifndef WOLFCRYPT_BACKEND + case BLAKE2S: + digestSize = BLAKE2S_DIGESTSIZE; + break; + case WHIRLPOOL: digestSize = WHIRLPOOL_DIGESTSIZE; break; case STREEBOG: digestSize = STREEBOG_DIGESTSIZE; break; - + #endif default: TC_THROW_FATAL_EXCEPTION; } if (RNG_POOL_SIZE % digestSize) TC_THROW_FATAL_EXCEPTION; for (poolIndex = 0; poolIndex < RNG_POOL_SIZE; poolIndex += digestSize) { /* Compute the message digest of the entire pool using the selected hash function. */ switch (HashFunction) { - case BLAKE2S: - blake2s_init(&bctx); - blake2s_update(&bctx, pRandPool, RNG_POOL_SIZE); - blake2s_final(&bctx, hashOutputBuffer); - break; - case SHA512: sha512_begin (&sctx); sha512_hash (pRandPool, RNG_POOL_SIZE, &sctx); sha512_end (hashOutputBuffer, &sctx); break; case SHA256: sha256_begin (&s256ctx); sha256_hash (pRandPool, RNG_POOL_SIZE, &s256ctx); sha256_end (hashOutputBuffer, &s256ctx); break; + #ifndef WOLFCRYPT_BACKEND + case BLAKE2S: + blake2s_init(&bctx); + blake2s_update(&bctx, pRandPool, RNG_POOL_SIZE); + blake2s_final(&bctx, hashOutputBuffer); + break; + case WHIRLPOOL: WHIRLPOOL_init (&wctx); WHIRLPOOL_add (pRandPool, RNG_POOL_SIZE, &wctx); WHIRLPOOL_finalize (&wctx, hashOutputBuffer); break; case STREEBOG: STREEBOG_init (&stctx); STREEBOG_add (&stctx, pRandPool, RNG_POOL_SIZE); STREEBOG_finalize (&stctx, hashOutputBuffer); break; - + #endif default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } /* XOR the resultant message digest to the pool at the poolIndex position. */ for (digestIndex = 0; digestIndex < digestSize; digestIndex++) { pRandPool [poolIndex + digestIndex] ^= hashOutputBuffer [digestIndex]; } } /* Prevent leaks */ burn (hashOutputBuffer, MAX_DIGESTSIZE); switch (HashFunction) { - case BLAKE2S: - burn (&bctx, sizeof(bctx)); - break; - case SHA512: burn (&sctx, sizeof(sctx)); break; case SHA256: burn (&s256ctx, sizeof(s256ctx)); break; + #ifndef WOLFCRYPT_BACKEND + case BLAKE2S: + burn (&bctx, sizeof(bctx)); + break; + case WHIRLPOOL: burn (&wctx, sizeof(wctx)); break; case STREEBOG: burn (&stctx, sizeof(sctx)); break; - + #endif default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } } return TRUE; } /* Add a buffer to the pool */ void RandaddBuf (void *buf, int len) { int i; for (i = 0; i < len; i++) { RandaddByte (((unsigned char *) buf)[i]); } } BOOL RandpeekBytes (void* hwndDlg, unsigned char *buf, int len, DWORD* mouseCounter) { if (!bRandDidInit) return FALSE; if (len > RNG_POOL_SIZE) { Error ("ERR_NOT_ENOUGH_RANDOM_DATA", (HWND) hwndDlg); len = RNG_POOL_SIZE; } EnterCriticalSection (&critRandProt); diff --git a/src/Common/Resource.h b/src/Common/Resource.h index c9142ece..0098542e 100644 --- a/src/Common/Resource.h +++ b/src/Common/Resource.h @@ -198,42 +198,45 @@ #define IDC_CONTINUE 5114 #define IDT_ABOUT_RELEASE 5115 #define IDT_STATIC_MODELESS_WAIT_DLG_INFO 5116 #define IDT_NUMBER_KEYFILES 5117 #define IDC_NUMBER_KEYFILES 5118 #define IDT_KEYFILES_BASE_NAME 5119 #define IDC_KEYFILES_BASE_NAME 5120 #define IDC_KEYFILES_SIZE 5121 #define IDC_KEYFILES_RANDOM_SIZE 5122 #define IDT_KEYFILES_SIZE 5123 #define IDD_STATIC_MODAL_WAIT_DLG 5124 #define IDT_STATIC_MODAL_WAIT_DLG_INFO 5125 #define IDC_WAIT_PROGRESS_BAR 5126 #define IDC_PKCS5_PRF_ID 5127 #define IDT_PKCS5_PRF 5128 #define IDT_PIM 5129 #define IDC_PIM 5130 #define IDC_PIM_HELP 5131 #define IDC_PIM_ENABLE 5132 #define IDC_VOLUME_LABEL 5133 #define IDT_VOLUME_LABEL 5134 #define IDC_KEYFILES_TRY_EMPTY_PASSWORD 5135 #define IDC_ENTROPY_BAR 5136 #define IDT_ENTROPY_BAR 5137 #define IDT_BENCHMARK 5138 #define IDC_BENCHMARK_LIST 5139 #define IDC_BENCHMARK_PREBOOT 5140 #define IDD_TEXT_EDIT_DLG 5141 #define IDC_DISABLE_MOUNT_MANAGER 5142 #define IDC_KEYFILES_SIZE_UNIT 5143 +#define IDC_LINK_KEYFILES_EXTENSIONS_WARNING 5144 +#define IDC_DISABLE_MEMORY_PROTECTION 5145 +#define IDC_DISABLE_MEMORY_PROTECTION_HELP 5146 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 578 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 5144 +#define _APS_NEXT_CONTROL_VALUE 5147 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/Common/ResponseAPDU.cpp b/src/Common/ResponseAPDU.cpp index 8a7f069c..3fe3b6de 100644 --- a/src/Common/ResponseAPDU.cpp +++ b/src/Common/ResponseAPDU.cpp @@ -1,111 +1,111 @@ #include "ResponseAPDU.h" #include <string.h> using namespace std; namespace VeraCrypt { - uint16 BytesToUInt16(const vector<byte>& buff) + uint16 BytesToUInt16(const vector<uint8>& buff) { uint16 value = 0; for (uint16 i = 0; i < buff.size(); i++) { value <<= 8; value |= (uint16)buff.at(i); } return value; } - void AppendData (vector<byte>& buffer, const byte* pbData, size_t cbData) + void AppendData (vector<uint8>& buffer, const uint8* pbData, size_t cbData) { size_t orgSize = buffer.size (); buffer.resize (orgSize + cbData); memcpy (buffer.data () + orgSize, pbData, cbData); } /*********************************************************************************/ void ResponseAPDU::clear() { m_data.clear(); m_SW = 0; } ResponseAPDU::ResponseAPDU() : m_SW(0) { } - ResponseAPDU::ResponseAPDU(const vector<byte>& data, uint16 SW) + ResponseAPDU::ResponseAPDU(const vector<uint8>& data, uint16 SW) { m_data = data; m_SW = SW; } uint32 ResponseAPDU::getNr() { return (uint32)m_data.size(); } - const vector<byte> ResponseAPDU::getData() + const vector<uint8> ResponseAPDU::getData() { return m_data; } - byte ResponseAPDU::getSW1() + uint8 ResponseAPDU::getSW1() { - return (byte)((0xFF00 & m_SW) >> 8); + return (uint8)((0xFF00 & m_SW) >> 8); } - byte ResponseAPDU::getSW2() + uint8 ResponseAPDU::getSW2() { - return (byte)(0x00FF & m_SW); + return (uint8)(0x00FF & m_SW); } uint16 ResponseAPDU::getSW() { return m_SW; } - const vector<byte> ResponseAPDU::getBytes() + const vector<uint8> ResponseAPDU::getBytes() { - vector<byte> apdu; + vector<uint8> apdu; AppendData(apdu, m_data.data(), m_data.size()); - apdu.push_back((byte)getSW1()); - apdu.push_back((byte)getSW2()); + apdu.push_back((uint8)getSW1()); + apdu.push_back((uint8)getSW2()); return apdu; } - void ResponseAPDU::appendData(const vector<byte>& data) + void ResponseAPDU::appendData(const vector<uint8>& data) { appendData(data.data(), data.size()); } - void ResponseAPDU::appendData(const byte* data, size_t dataLen) + void ResponseAPDU::appendData(const uint8* data, size_t dataLen) { AppendData(m_data, data, dataLen); } void ResponseAPDU::setSW(uint16 SW) { m_SW = SW; } - void ResponseAPDU::setBytes(const vector<byte>& bytes) + void ResponseAPDU::setBytes(const vector<uint8>& bytes) { clear(); if (bytes.size() >= 2) { - vector<byte> SWBytes; + vector<uint8> SWBytes; m_data.resize(bytes.size() - 2); SWBytes.resize(2); memcpy(m_data.data(), bytes.data(), bytes.size() - 2); memcpy(SWBytes.data(), bytes.data() + bytes.size() - 2, 2); m_SW = BytesToUInt16(SWBytes); } } } diff --git a/src/Common/ResponseAPDU.h b/src/Common/ResponseAPDU.h index b9aa4adc..f279afca 100644 --- a/src/Common/ResponseAPDU.h +++ b/src/Common/ResponseAPDU.h @@ -1,44 +1,44 @@ #ifndef TC_HEADER_Common_ResponseAPDU #define TC_HEADER_Common_ResponseAPDU #include "Platform/PlatformBase.h" namespace VeraCrypt { class ResponseAPDU { protected: - vector<byte> m_data; + vector<uint8> m_data; uint16 m_SW; public: void clear(); ResponseAPDU(); - ResponseAPDU(const vector<byte>& data, uint16 SW); + ResponseAPDU(const vector<uint8>& data, uint16 SW); uint32 getNr(); - const vector<byte> getData(); + const vector<uint8> getData(); - byte getSW1(); + uint8 getSW1(); - byte getSW2(); + uint8 getSW2(); uint16 getSW(); - const vector<byte> getBytes(); + const vector<uint8> getBytes(); void setSW(uint16 SW); - void setBytes(const vector<byte>& bytes); + void setBytes(const vector<uint8>& bytes); - void appendData(const vector<byte>& data); - void appendData(const byte* data, size_t dataLen); + void appendData(const vector<uint8>& data); + void appendData(const uint8* data, size_t dataLen); }; }; #endif // TC_HEADER_Common_ResponseAPDU
\ No newline at end of file diff --git a/src/Common/SCard.cpp b/src/Common/SCard.cpp index 9f8d1145..edd315f6 100644 --- a/src/Common/SCard.cpp +++ b/src/Common/SCard.cpp @@ -1,39 +1,39 @@ #include "SCard.h" using namespace std; namespace VeraCrypt { SCardManager SCard::manager; - SCard::SCard() : m_reader(NULL) + SCard::SCard() { } SCard::SCard(size_t slotId) { m_reader = SCard::manager.GetReader(slotId); } SCard::~SCard() { if (m_reader) { m_reader->Disconnect(); } } SCard::SCard(const SCard& other) : m_reader(other.m_reader) { } SCard::SCard(SCard&& other) : m_reader(std::move(other.m_reader)) { } SCard& SCard::operator = (const SCard& other) { if (this != &other) { m_reader = other.m_reader; } diff --git a/src/Common/SCardLoader.cpp b/src/Common/SCardLoader.cpp index 16026e62..24486002 100644 --- a/src/Common/SCardLoader.cpp +++ b/src/Common/SCardLoader.cpp @@ -293,61 +293,61 @@ namespace VeraCrypt LONG SCardLoader::SCardBeginTransaction(SCARDHANDLE hCard) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardBeginTransaction(hCard); } LONG SCardLoader::SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardEndTransaction(hCard, dwDisposition); } LONG SCardLoader::SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen); } - LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders) + LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardGetStatusChange(hContext, dwTimeout, rgReaderStates, cReaders); } LONG SCardLoader::SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardControl(hCard, dwControlCode, pbSendBuffer, cbSendLength, pbRecvBuffer, cbRecvLength, lpBytesReturned); } LONG SCardLoader::SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardTransmit(hCard, pioSendPci, pbSendBuffer, cbSendLength, pioRecvPci, pbRecvBuffer, pcbRecvLength); } LONG SCardLoader::SCardListReaderGroups(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups) @@ -372,31 +372,31 @@ namespace VeraCrypt LONG SCardLoader::SCardCancel(SCARDCONTEXT hContext) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardCancel(hContext); } LONG SCardLoader::SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, BYTE* pbAttr, LPDWORD pcbAttrLen) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardGetAttrib(hCard, dwAttrId, pbAttr, pcbAttrLen); } LONG SCardLoader::SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, const BYTE* pbAttr, DWORD cbAttrLen) { Initialize(); if (!bInitialized) throw ScardLibraryInitializationFailed(); return scardSetAttrib(hCard, dwAttrId, pbAttr, cbAttrLen); } -}
\ No newline at end of file +} diff --git a/src/Common/SCardLoader.h b/src/Common/SCardLoader.h index b1ab114b..af0758ed 100644 --- a/src/Common/SCardLoader.h +++ b/src/Common/SCardLoader.h @@ -1,81 +1,78 @@ #ifndef TC_HEADER_Common_SCardLoader #define TC_HEADER_Common_SCardLoader #include "Platform/PlatformBase.h" #ifdef TC_WINDOWS #include <winscard.h> #include <windows.h> #else #ifdef TC_MACOSX #undef BOOL #include <PCSC/pcsclite.h> #include <PCSC/winscard.h> #include <PCSC/wintypes.h> #include "reader.h" -typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE; -using VeraCrypt::byte; #define BOOL int #else #undef BOOL #include "pcsclite.h" #include <winscard.h> #include <wintypes.h> #include <reader.h> -using VeraCrypt::byte; #define BOOL int #endif #endif #ifndef TC_WINDOWS typedef void* HMODULE; #define SCARD_CALL_SPEC #else #define SCARD_CALL_SPEC WINAPI #endif namespace VeraCrypt { typedef LONG (SCARD_CALL_SPEC *SCardEstablishContextPtr)(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext); typedef LONG (SCARD_CALL_SPEC *SCardReleaseContextPtr)(SCARDCONTEXT hContext); typedef LONG (SCARD_CALL_SPEC *SCardIsValidContextPtr)(SCARDCONTEXT hContext); #ifndef TC_MACOSX typedef LONG (SCARD_CALL_SPEC *SCardFreeMemoryPtr)(SCARDCONTEXT hContext, LPCVOID pvMem); #endif typedef LONG (SCARD_CALL_SPEC *SCardConnectPtr)(SCARDCONTEXT hContext, LPCTSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); typedef LONG (SCARD_CALL_SPEC *SCardReconnectPtr)(SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol); typedef LONG (SCARD_CALL_SPEC *SCardDisconnectPtr)(SCARDHANDLE hCard, DWORD dwDisposition); typedef LONG (SCARD_CALL_SPEC *SCardBeginTransactionPtr)(SCARDHANDLE hCard); typedef LONG (SCARD_CALL_SPEC *SCardEndTransactionPtr)(SCARDHANDLE hCard, DWORD dwDisposition); typedef LONG (SCARD_CALL_SPEC *SCardStatusPtr)(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen); - typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders); + typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders); typedef LONG (SCARD_CALL_SPEC *SCardControlPtr)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned); typedef LONG (SCARD_CALL_SPEC *SCardTransmitPtr)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength); typedef LONG (SCARD_CALL_SPEC *SCardListReaderGroupsPtr)(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups); typedef LONG (SCARD_CALL_SPEC *SCardListReadersPtr)(SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders); typedef LONG (SCARD_CALL_SPEC *SCardCancelPtr)(SCARDCONTEXT hContext); typedef LONG (SCARD_CALL_SPEC *SCardGetAttribPtr)(SCARDHANDLE hCard, DWORD dwAttrId, BYTE* pbAttr, LPDWORD pcbAttrLen); typedef LONG (SCARD_CALL_SPEC *SCardSetAttribPtr)(SCARDHANDLE hCard, DWORD dwAttrId, const BYTE* pbAttr, DWORD cbAttrLen); class SCardLoader { protected: static HMODULE hScardModule; static SCARDCONTEXT hScardContext; static SCardEstablishContextPtr scardEstablishContext; static SCardReleaseContextPtr scardReleaseContext; static SCardIsValidContextPtr scardIsValidContext; #ifndef TC_MACOSX static SCardFreeMemoryPtr scardFreeMemory; #endif static SCardConnectPtr scardConnect; static SCardReconnectPtr scardReconnect; static SCardDisconnectPtr scardDisconnect; static SCardBeginTransactionPtr scardBeginTransaction; static SCardEndTransactionPtr scardEndTransaction; static SCardStatusPtr scardStatus; static SCardGetStatusChangePtr scardGetStatusChange; static SCardControlPtr scardControl; static SCardTransmitPtr scardTransmit; static SCardListReaderGroupsPtr scardListReaderGroups; static SCardListReadersPtr scardListReaders; @@ -84,42 +81,42 @@ namespace VeraCrypt static SCardSetAttribPtr scardSetAttrib; static bool bInitialized; public: static SCARD_IO_REQUEST* scardT0Pci; static SCARD_IO_REQUEST* scardT1Pci; static SCARD_IO_REQUEST* scardRawPci; SCardLoader() { }; static void Initialize(); static void Finalize(); #ifdef TC_WINDOWS static wstring GetSCardPath(); #else static string GetSCardPath(); #endif static SCARDCONTEXT GetSCardContext(); static LONG SCardEstablishContext(DWORD dwScope, LPCVOID pvReserved1, LPCVOID pvReserved2, LPSCARDCONTEXT phContext); static LONG SCardReleaseContext(SCARDCONTEXT hContext); static LONG SCardIsValidContext(SCARDCONTEXT hContext); #ifndef TC_MACOSX static LONG SCardFreeMemory(SCARDCONTEXT hContext, LPCVOID pvMem); #endif static LONG SCardConnect(SCARDCONTEXT hContext, LPCTSTR szReader, DWORD dwShareMode, DWORD dwPreferredProtocols, LPSCARDHANDLE phCard, LPDWORD pdwActiveProtocol); static LONG SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol); static LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition); static LONG SCardBeginTransaction(SCARDHANDLE hCard); static LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition); static LONG SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen); - static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders); + static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders); static LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned); static LONG SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength); static LONG SCardListReaderGroups(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups); static LONG SCardListReaders(SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders); static LONG SCardCancel(SCARDCONTEXT hContext); static LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, BYTE* pbAttr, LPDWORD pcbAttrLen); static LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, const BYTE* pbAttr, DWORD cbAttrLen); }; }; -#endif // TC_HEADER_Common_SCardLoader
\ No newline at end of file +#endif // TC_HEADER_Common_SCardLoader diff --git a/src/Common/SCardReader.cpp b/src/Common/SCardReader.cpp index 3a762415..6c5f654a 100644 --- a/src/Common/SCardReader.cpp +++ b/src/Common/SCardReader.cpp @@ -1,50 +1,50 @@ #include "SCardReader.h" #include "PCSCException.h" #include <locale> using namespace std; namespace VeraCrypt { void SCardReader::Init(const wstring& szSCReaderName, const shared_ptr<SCardLoader> scardLoader, const SCARDHANDLE& hCard, const DWORD& dwProtocol, LPCSCARD_IO_REQUEST pIO_Protocol) { m_szSCReaderName = szSCReaderName; if (scardLoader) { m_scardLoader = scardLoader; m_hSCReaderContext = m_scardLoader->GetSCardContext(); } else { - m_scardLoader = NULL; + m_scardLoader.reset(); m_hSCReaderContext = 0; } m_hCard = hCard; m_dwProtocol = dwProtocol; m_pIO_Protocol = pIO_Protocol; } SCardReader::SCardReader(const wstring &szName, const shared_ptr<SCardLoader> scardLoader) { Init(szName, scardLoader, 0, 0, NULL); } SCardReader::SCardReader(const SCardReader& other) : m_szSCReaderName(other.m_szSCReaderName), m_scardLoader(other.m_scardLoader), m_hSCReaderContext(other.m_hSCReaderContext), m_hCard(other.m_hCard), m_dwProtocol(other.m_dwProtocol), m_pIO_Protocol(other.m_pIO_Protocol) { } SCardReader::SCardReader(SCardReader&& other) : m_szSCReaderName(other.m_szSCReaderName), m_scardLoader(other.m_scardLoader), m_hSCReaderContext(other.m_hSCReaderContext), m_hCard(other.m_hCard), m_dwProtocol(other.m_dwProtocol), m_pIO_Protocol(other.m_pIO_Protocol) { @@ -57,142 +57,142 @@ namespace VeraCrypt { m_szSCReaderName = other.m_szSCReaderName; m_scardLoader = other.m_scardLoader; m_hSCReaderContext = other.m_hSCReaderContext; m_hCard = other.m_hCard; m_dwProtocol = other.m_dwProtocol; m_pIO_Protocol = other.m_pIO_Protocol; } return *this; } SCardReader& SCardReader::operator=(SCardReader&& other) { if (this != &other) { m_szSCReaderName = other.m_szSCReaderName; m_scardLoader = other.m_scardLoader; m_hSCReaderContext = other.m_hSCReaderContext; m_hCard = other.m_hCard; m_dwProtocol = other.m_dwProtocol; m_pIO_Protocol = other.m_pIO_Protocol; other.Clear(); } return *this; } void SCardReader::Clear(void) { m_szSCReaderName = L""; - m_scardLoader = NULL; + m_scardLoader.reset(); m_hSCReaderContext = 0; m_hCard = 0; m_dwProtocol = 0; m_pIO_Protocol = NULL; } SCardReader::~SCardReader() { Clear(); } const wstring SCardReader::GetNameWide() const { return m_szSCReaderName; } const string SCardReader::GetName() const { string name = ""; size_t size = wcstombs(NULL, m_szSCReaderName.c_str(), 0) + 1; if (size) { name.resize(size); size = wcstombs(&name[0], m_szSCReaderName.c_str(), size); if (size) { name.resize(size); } } return name; } - bool SCardReader::IsCardPresent(vector<byte>& cardAtr) + bool SCardReader::IsCardPresent(vector<uint8>& cardAtr) { LONG lRet = SCARD_S_SUCCESS; SCARD_READERSTATE state; bool bIsCardPresent = false; #ifdef TC_WINDOWS wstring readerName = GetNameWide(); #else string readerName = GetName(); #endif if (!m_scardLoader) throw ScardLibraryInitializationFailed(); cardAtr.clear(); burn(&state, sizeof(SCARD_READERSTATE)); state.szReader = readerName.c_str(); lRet = m_scardLoader->SCardIsValidContext(m_hSCReaderContext); if (SCARD_S_SUCCESS != lRet) { m_scardLoader->SCardReleaseContext(m_hSCReaderContext); lRet = m_scardLoader->SCardEstablishContext(SCARD_SCOPE_USER, NULL, NULL, &m_hSCReaderContext); if (lRet != SCARD_S_SUCCESS) throw PCSCException(lRet); } lRet = m_scardLoader->SCardGetStatusChange(m_hSCReaderContext, 0, &state, 1); if (lRet == SCARD_S_SUCCESS) { if ((state.dwEventState & SCARD_STATE_PRESENT) == SCARD_STATE_PRESENT && (state.dwEventState & SCARD_STATE_MUTE) == 0) { cardAtr.resize(state.cbAtr, 0); memcpy(cardAtr.data(), state.rgbAtr, state.cbAtr); bIsCardPresent = true; burn(&state, sizeof(SCARD_READERSTATE)); } } else { throw PCSCException(lRet); } return bIsCardPresent; } bool SCardReader::IsCardPresent() { - vector<byte> dummy; + vector<uint8> dummy; return IsCardPresent(dummy); } LONG SCardReader::CardHandleStatus() { LONG lRet = SCARD_E_INVALID_HANDLE; if (!m_scardLoader) throw ScardLibraryInitializationFailed(); if (m_hCard != 0) { #ifdef TC_WINDOWS wchar_t #else char #endif szName[TC_MAX_PATH] = {}; BYTE pbAtr[36] = {}; DWORD dwState, dwProtocol, dwNameLen = TC_MAX_PATH, dwAtrLen = 36; lRet = m_scardLoader->SCardStatus(m_hCard, szName, &dwNameLen, &dwState, &dwProtocol, pbAtr, &dwAtrLen); } return lRet; } void SCardReader::Connect(DWORD dwProtocolToUse, bool& bHasBeenReset, bool resetAfterConnect) { LONG lRet = SCARD_S_SUCCESS; bHasBeenReset = false; @@ -371,181 +371,181 @@ namespace VeraCrypt { #ifndef _DEBUG lRet = m_scardLoader->SCardEndTransaction(m_hCard, SCARD_LEAVE_CARD); if (lRet != SCARD_S_SUCCESS) { throw PCSCException(lRet); } #endif lRet = SCARD_S_SUCCESS; } else { lRet = SCARD_E_INVALID_HANDLE; throw PCSCException(lRet); } } void SCardReader::ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const { LONG lRet = 0; uint16 SW = 0; uint32 nc = 0, ne = 0; bool expectingResponse = false; bool useExtendedAPDU = false; size_t indexOfLe = 0; size_t indexOfLcData = 0; - vector<byte> pbSendBuffer; - vector<byte> pbRecvBuffer; + vector<uint8> pbSendBuffer; + vector<uint8> pbRecvBuffer; DWORD cbSendLength = 0; DWORD cbRecvLength = 0; responseAPDU.clear(); if (!commandAPDU.isValid()) { throw CommandAPDUNotValid(SRC_POS, commandAPDU.getErrorStr()); } // See whether the CommandAPDU is extended or not useExtendedAPDU = commandAPDU.isExtended(); // If T != 1, cannot use Extended-APDU if (m_dwProtocol != SCARD_PROTOCOL_T1 && useExtendedAPDU) { throw ExtendedAPDUNotSupported(); } // Set some needed vars nc = commandAPDU.getNc(); ne = commandAPDU.getNe(); pbSendBuffer.resize(useExtendedAPDU ? extendedAPDUMaxSendSize : shortAPDUMaxSendSize, 0); pbRecvBuffer.resize(useExtendedAPDU ? extendedAPDUMaxRecvSize : shortAPDUMaxRecvSize, 0); cbRecvLength = (DWORD)pbRecvBuffer.size(); if (nc > (useExtendedAPDU ? extendedAPDUMaxTransSize : shortAPDUMaxTransSize) - 1) // Max = 255 or 65535 { std::string errStr = vformat("Nc > %d", (useExtendedAPDU ? extendedAPDUMaxTransSize : shortAPDUMaxTransSize) - 1); throw CommandAPDUNotValid(SRC_POS, commandAPDU.getErrorStr()); } if (ne > (useExtendedAPDU ? extendedAPDUMaxTransSize : shortAPDUMaxTransSize)) // Max = 256 or 65536 { std::string errStr = vformat("Ne > %d", (useExtendedAPDU ? extendedAPDUMaxTransSize : shortAPDUMaxTransSize) - 1); throw CommandAPDUNotValid(SRC_POS, commandAPDU.getErrorStr()); } // Create and populate buffer to send to card pbSendBuffer[0] = commandAPDU.getCLA(); pbSendBuffer[1] = commandAPDU.getINS(); pbSendBuffer[2] = commandAPDU.getP1(); pbSendBuffer[3] = commandAPDU.getP2(); if (nc == 0) { if (ne == 0) { // case 1 cbSendLength = 4; } else { expectingResponse = true; // case 2s or 2e if (ne <= 256) { // case 2s // 256 is encoded as 0x00 pbSendBuffer[4] = (BYTE)ne; indexOfLe = 4; - cbSendLength = 4 + 1; // header || Le (1 byte) + cbSendLength = 4 + 1; // header || Le (1 uint8) } else { // case 2e // 65536 is encoded as 0x00 0x00 0x00 BYTE l1, l2; if (ne == 65536) { l1 = 0; l2 = 0; } else { l1 = (BYTE)(ne >> 8); l2 = (BYTE)ne; } pbSendBuffer[4] = 0x00; pbSendBuffer[5] = l1; pbSendBuffer[6] = l2; cbSendLength = 4 + 3; // header || Le (3 bytes) } } } else { if (ne == 0) { // case 3s or 3e if (nc <= 255) { // case 3s pbSendBuffer[4] = (BYTE)nc; indexOfLcData = 5; - cbSendLength = 4 + 1 + nc; // header || Lc (1 byte) || Data + cbSendLength = 4 + 1 + nc; // header || Lc (1 uint8) || Data memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc); } else { // case 3e pbSendBuffer[4] = 0; pbSendBuffer[5] = (BYTE)(nc >> 8); pbSendBuffer[6] = (BYTE)nc; indexOfLcData = 7; cbSendLength = 4 + 3 + nc; // header || Lc (3 bytes) || Data memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc); } } else { expectingResponse = true; // case 4s or 4e if ((nc <= 255) && (ne <= 256)) { // case 4s pbSendBuffer[4] = (BYTE)nc; indexOfLcData = 5; - cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 byte) || Data || Le (1 byte) + cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 uint8) || Data || Le (1 uint8) memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc); pbSendBuffer[indexOfLcData + nc] = (ne != 256) ? (BYTE)ne : 0; indexOfLe = indexOfLcData + nc; } else { // case 4e pbSendBuffer[4] = 0; pbSendBuffer[5] = (BYTE)(nc >> 8); pbSendBuffer[6] = (BYTE)nc; indexOfLcData = 7; cbSendLength = 4 + 3 + nc + 2; // header || Lc (3 bytes) || Data || Le (2 bytes) memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc); if (ne != 65536) { size_t leOfs = cbSendLength - 2; pbSendBuffer[leOfs] = (BYTE)(ne >> 8); pbSendBuffer[leOfs + 1] = (BYTE)ne; }// 65536 is 0x00 0x00 and the buffer has already been initialized with 0s } } } cbRecvLength = (DWORD)pbRecvBuffer.size(); lRet = SendAPDU(pbSendBuffer.data(), cbSendLength, pbRecvBuffer.data(), &cbRecvLength, SW); if (lRet != SCARD_S_SUCCESS) { responseAPDU.setSW(SW); goto end; } @@ -619,63 +619,63 @@ namespace VeraCrypt if (SW != SW_NO_ERROR) { responseAPDU.setSW(SW); goto end; } // Response is complete in 1 ResponseAPDU if (cbRecvLength) responseAPDU.appendData(pbRecvBuffer.data(), cbRecvLength); } if (lRet == SCARD_S_SUCCESS) { responseAPDU.setSW(SW); } } else { responseAPDU.setSW(SW); } end: burn(pbSendBuffer.data(), pbSendBuffer.size()); burn(pbRecvBuffer.data(), pbRecvBuffer.size()); if (lRet != SCARD_S_SUCCESS) throw PCSCException(lRet); } - void SCardReader::GetATRFromHandle(vector<byte>& atrValue) + void SCardReader::GetATRFromHandle(vector<uint8>& atrValue) { - vector<byte> pbATR; + vector<uint8> pbATR; DWORD cByte = 0; LONG lRet = 0; atrValue.clear(); if (!m_scardLoader) throw ScardLibraryInitializationFailed(); lRet = m_scardLoader->SCardGetAttrib(m_hCard, SCARD_ATTR_ATR_STRING, NULL, &cByte); if (lRet == SCARD_S_SUCCESS) { pbATR.resize(cByte, 0); lRet = m_scardLoader->SCardGetAttrib(m_hCard, SCARD_ATTR_ATR_STRING, pbATR.data(), &cByte); if (lRet == SCARD_S_SUCCESS) { atrValue = pbATR; } else { throw PCSCException(lRet); } } else { throw PCSCException(lRet); } } } diff --git a/src/Common/SCardReader.h b/src/Common/SCardReader.h index 95586963..8814bce0 100644 --- a/src/Common/SCardReader.h +++ b/src/Common/SCardReader.h @@ -24,177 +24,177 @@ namespace VeraCrypt const uint16 SW_LAST_COMMAND_EXPECTED = (uint16)0x6883; const uint16 SW_SECURITY_STATUS_NOT_SATISFIED = (uint16)0x6982; const uint16 SW_FILE_INVALID = (uint16)0x6983; const uint16 SW_DATA_INVALID = (uint16)0x6984; const uint16 SW_CONDITIONS_NOT_SATISFIED = (uint16)0x6985; const uint16 SW_COMMAND_NOT_ALLOWED = (uint16)0x6986; const uint16 SW_EXPECTED_SM_DATA_OBJECTS_MISSING = (uint16)0x6987; const uint16 SW_SM_DATA_OBJECTS_INCORRECT = (uint16)0x6988; const uint16 SW_APPLET_SELECT_FAILED = (uint16)0x6999; const uint16 SW_KEY_USAGE_ERROR = (uint16)0x69C1; const uint16 SW_WRONG_DATA = (uint16)0x6A80; const uint16 SW_FILEHEADER_INCONSISTENT = (uint16)0x6A80; const uint16 SW_FUNC_NOT_SUPPORTED = (uint16)0x6A81; const uint16 SW_FILE_NOT_FOUND = (uint16)0x6A82; const uint16 SW_RECORD_NOT_FOUND = (uint16)0x6A83; const uint16 SW_FILE_FULL = (uint16)0x6A84; const uint16 SW_OUT_OF_MEMORY = (uint16)0x6A84; const uint16 SW_INCORRECT_P1P2 = (uint16)0x6A86; const uint16 SW_KEY_NOT_FOUND = (uint16)0x6A88; const uint16 SW_WRONG_P1P2 = (uint16)0x6B00; const uint16 SW_CORRECT_LENGTH_00 = (uint16)0x6C00; const uint16 SW_INS_NOT_SUPPORTED = (uint16)0x6D00; const uint16 SW_CLA_NOT_SUPPORTED = (uint16)0x6E00; const uint16 SW_UNKNOWN = (uint16)0x6F00; const uint16 SW_CARD_TERMINATED = (uint16)0x6FFF; const uint16 SW_NO_ERROR = (uint16)0x9000; /* ================================================================================================ */ /* CLA values */ /* ================================================================================================ */ - const byte CLA_ISO7816 = (byte)0x00; - const byte CLA_COMMAND_CHAINING = (byte)0x10; + const uint8 CLA_ISO7816 = (uint8)0x00; + const uint8 CLA_COMMAND_CHAINING = (uint8)0x10; /* ================================================================================================ */ /* INS values */ /* ================================================================================================ */ - const byte INS_ERASE_BINARY = 0x0E; - const byte INS_VERIFY = 0x20; - const byte INS_CHANGE_CHV = 0x24; - const byte INS_UNBLOCK_CHV = 0x2C; - const byte INS_DECREASE = 0x30; - const byte INS_INCREASE = 0x32; - const byte INS_DECREASE_STAMPED = 0x34; - const byte INS_REHABILITATE_CHV = 0x44; - const byte INS_MANAGE_CHANNEL = 0x70; - const byte INS_EXTERNAL_AUTHENTICATE = (byte)0x82; - const byte INS_MUTUAL_AUTHENTICATE = (byte)0x82; - const byte INS_GET_CHALLENGE = (byte)0x84; - const byte INS_ASK_RANDOM = (byte)0x84; - const byte INS_GIVE_RANDOM = (byte)0x86; - const byte INS_INTERNAL_AUTHENTICATE = (byte)0x88; - const byte INS_SEEK = (byte)0xA2; - const byte INS_SELECT = (byte)0xA4; - const byte INS_SELECT_FILE = (byte)0xA4; - const byte INS_CLOSE_APPLICATION = (byte)0xAC; - const byte INS_READ_BINARY = (byte)0xB0; - const byte INS_READ_BINARY2 = (byte)0xB1; - const byte INS_READ_RECORD = (byte)0xB2; - const byte INS_READ_RECORD2 = (byte)0xB3; - const byte INS_READ_RECORDS = (byte)0xB2; - const byte INS_READ_BINARY_STAMPED = (byte)0xB4; - const byte INS_READ_RECORD_STAMPED = (byte)0xB6; - const byte INS_GET_RESPONSE = (byte)0xC0; - const byte INS_ENVELOPE = (byte)0xC2; - const byte INS_GET_DATA = (byte)0xCA; - const byte INS_WRITE_BINARY = (byte)0xD0; - const byte INS_WRITE_RECORD = (byte)0xD2; - const byte INS_UPDATE_BINARY = (byte)0xD6; - const byte INS_LOAD_KEY_FILE = (byte)0xD8; - const byte INS_PUT_DATA = (byte)0xDA; - const byte INS_UPDATE_RECORD = (byte)0xDC; - const byte INS_CREATE_FILE = (byte)0xE0; - const byte INS_APPEND_RECORD = (byte)0xE2; - const byte INS_DELETE_FILE = (byte)0xE4; - const byte INS_PSO = (byte)0x2A; - const byte INS_MSE = (byte)0x22; + const uint8 INS_ERASE_BINARY = 0x0E; + const uint8 INS_VERIFY = 0x20; + const uint8 INS_CHANGE_CHV = 0x24; + const uint8 INS_UNBLOCK_CHV = 0x2C; + const uint8 INS_DECREASE = 0x30; + const uint8 INS_INCREASE = 0x32; + const uint8 INS_DECREASE_STAMPED = 0x34; + const uint8 INS_REHABILITATE_CHV = 0x44; + const uint8 INS_MANAGE_CHANNEL = 0x70; + const uint8 INS_EXTERNAL_AUTHENTICATE = (uint8)0x82; + const uint8 INS_MUTUAL_AUTHENTICATE = (uint8)0x82; + const uint8 INS_GET_CHALLENGE = (uint8)0x84; + const uint8 INS_ASK_RANDOM = (uint8)0x84; + const uint8 INS_GIVE_RANDOM = (uint8)0x86; + const uint8 INS_INTERNAL_AUTHENTICATE = (uint8)0x88; + const uint8 INS_SEEK = (uint8)0xA2; + const uint8 INS_SELECT = (uint8)0xA4; + const uint8 INS_SELECT_FILE = (uint8)0xA4; + const uint8 INS_CLOSE_APPLICATION = (uint8)0xAC; + const uint8 INS_READ_BINARY = (uint8)0xB0; + const uint8 INS_READ_BINARY2 = (uint8)0xB1; + const uint8 INS_READ_RECORD = (uint8)0xB2; + const uint8 INS_READ_RECORD2 = (uint8)0xB3; + const uint8 INS_READ_RECORDS = (uint8)0xB2; + const uint8 INS_READ_BINARY_STAMPED = (uint8)0xB4; + const uint8 INS_READ_RECORD_STAMPED = (uint8)0xB6; + const uint8 INS_GET_RESPONSE = (uint8)0xC0; + const uint8 INS_ENVELOPE = (uint8)0xC2; + const uint8 INS_GET_DATA = (uint8)0xCA; + const uint8 INS_WRITE_BINARY = (uint8)0xD0; + const uint8 INS_WRITE_RECORD = (uint8)0xD2; + const uint8 INS_UPDATE_BINARY = (uint8)0xD6; + const uint8 INS_LOAD_KEY_FILE = (uint8)0xD8; + const uint8 INS_PUT_DATA = (uint8)0xDA; + const uint8 INS_UPDATE_RECORD = (uint8)0xDC; + const uint8 INS_CREATE_FILE = (uint8)0xE0; + const uint8 INS_APPEND_RECORD = (uint8)0xE2; + const uint8 INS_DELETE_FILE = (uint8)0xE4; + const uint8 INS_PSO = (uint8)0x2A; + const uint8 INS_MSE = (uint8)0x22; /* ================================================================================================ */ /* EMV values */ /* ================================================================================================ */ const uint16 EMV_CPLC_TAG = (uint16)0x9F7F; const uint16 EMV_ICC_PK_CERT_TAG = (uint16)0x9F46; const uint16 EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG = (uint16)0xBF0C; - const byte EMV_ISS_PK_CERT_TAG = (byte)0x90; - const byte EMV_PAN_TAG = (byte)0x5A; - const byte EMV_FCI_TAG = (byte)0x6F; - const byte EMV_DFNAME_TAG = (byte)0x84; - const byte EMV_FCI_ISSUER_TAG = (byte)0xA5; - const byte EMV_DIRECTORY_ENTRY_TAG = (byte)0x61; - const byte EMV_SFI_TAG = (byte)0x88; - const byte EMV_TEMPLATE_TAG = (byte)0x70; - const byte EMV_AID_TAG = (byte)0x4F; - const byte EMV_LABEL_TAG = (byte)0x50; - const byte EMV_PRIORITY_TAG = (byte)0x87; - const byte EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact) - const byte EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless) + const uint8 EMV_ISS_PK_CERT_TAG = (uint8)0x90; + const uint8 EMV_PAN_TAG = (uint8)0x5A; + const uint8 EMV_FCI_TAG = (uint8)0x6F; + const uint8 EMV_DFNAME_TAG = (uint8)0x84; + const uint8 EMV_FCI_ISSUER_TAG = (uint8)0xA5; + const uint8 EMV_DIRECTORY_ENTRY_TAG = (uint8)0x61; + const uint8 EMV_SFI_TAG = (uint8)0x88; + const uint8 EMV_TEMPLATE_TAG = (uint8)0x70; + const uint8 EMV_AID_TAG = (uint8)0x4F; + const uint8 EMV_LABEL_TAG = (uint8)0x50; + const uint8 EMV_PRIORITY_TAG = (uint8)0x87; + const uint8 EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact) + const uint8 EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless) /* ================================================================================================ */ class SCardReader { protected: wstring m_szSCReaderName; shared_ptr<SCardLoader> m_scardLoader; mutable SCARDCONTEXT m_hSCReaderContext; mutable SCARDHANDLE m_hCard; mutable DWORD m_dwProtocol; mutable LPCSCARD_IO_REQUEST m_pIO_Protocol; void Init(const wstring& szSCReaderName, const shared_ptr<SCardLoader> scardLoader, const SCARDHANDLE& hCard, const DWORD& dwProtocol, LPCSCARD_IO_REQUEST pIO_Protocol); public: /* Card variables */ // Max Command APDU total size ; Typically either 261 (short) or 65544 (extended) // Max Response APDU total size ; Typically either 258 (short) or 65538 (extended) // Max Response APDU data size ; Ne ; Typically either 256 (short : 0x00) of 65536 (extended : 0x0000) const static uint32 shortAPDUMaxSendSize = 261; const static uint32 shortAPDUMaxRecvSize = 258; const static uint32 shortAPDUMaxTransSize = 256; const static uint32 extendedAPDUMaxSendSize = 65544; const static uint32 extendedAPDUMaxRecvSize = 65538; const static uint32 extendedAPDUMaxTransSize = 65536; // ------------------------------------------------------------------------------------------------------------------------------------- // // Ctors, dtors // ------------------------------------------------------------------------------------------------------------------------------------- // SCardReader(const wstring &szName, const shared_ptr<SCardLoader> scardLoader); SCardReader(const SCardReader& other); SCardReader(SCardReader&& other); SCardReader& operator = (const SCardReader& other); SCardReader& operator = (SCardReader&& other); void Clear(void); ~SCardReader(); // ------------------------------------------------------------------------------------------------------------------------------------- // // Getters & Setters // ------------------------------------------------------------------------------------------------------------------------------------- // const wstring GetNameWide() const; const string GetName() const; // ------------------------------------------------------------------------------------------------------------------------------------- // // Card Connection management methods // ------------------------------------------------------------------------------------------------------------------------------------- // - bool IsCardPresent(vector<byte>& cardAtr); + bool IsCardPresent(vector<uint8>& cardAtr); bool IsCardPresent(); LONG CardHandleStatus(); void Connect(DWORD dwProtocolToUse, bool& bHasBeenReset, bool resetAfterConnect = false); bool IsConnected(); void Disconnect() const; LONG SendAPDU(LPCBYTE pbSendBuffer, DWORD cbSendLength, LPBYTE pbRecvBuffer, LPDWORD pcbRecvLength, uint16& SW) const; void BeginTransaction(); void EndTransaction(); void ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const; - void GetATRFromHandle(vector<byte>& atrValue); + void GetATRFromHandle(vector<uint8>& atrValue); }; }; #endif // TC_HEADER_Common_SCardReader
\ No newline at end of file diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index ad8ed33e..2a8222e6 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -96,171 +96,171 @@ namespace VeraCrypt Initialized = false; } } void SecurityToken::CloseAllSessions() throw () { if (!Initialized) return; typedef pair <CK_SLOT_ID, Pkcs11Session> SessionMapPair; foreach(SessionMapPair p, Sessions) { try { CloseSession(p.first); } catch (...) {} } } void SecurityToken::CloseSession(CK_SLOT_ID slotId) { if (Sessions.find(slotId) == Sessions.end()) throw ParameterIncorrect(SRC_POS); Pkcs11Functions->C_CloseSession(Sessions[slotId].Handle); Sessions.erase(Sessions.find(slotId)); } - void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name) + void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name) { if (name.empty()) throw ParameterIncorrect(SRC_POS); LoginUserIfRequired(slotId); foreach(const SecurityTokenKeyfile & keyfile, GetAvailableKeyfiles(&slotId)) { if (keyfile.IdUtf8 == name) throw SecurityTokenKeyfileAlreadyExists(); } CK_OBJECT_CLASS dataClass = CKO_DATA; CK_BBOOL trueVal = CK_TRUE; CK_ATTRIBUTE keyfileTemplate[] = { { CKA_CLASS, &dataClass, sizeof(dataClass) }, { CKA_TOKEN, &trueVal, sizeof(trueVal) }, { CKA_PRIVATE, &trueVal, sizeof(trueVal) }, { CKA_LABEL, (CK_UTF8CHAR*)name.c_str(), (CK_ULONG)name.size() }, { CKA_VALUE, &keyfileData.front(), (CK_ULONG)keyfileData.size() } }; CK_OBJECT_HANDLE keyfileHandle; CK_RV status = Pkcs11Functions->C_CreateObject(Sessions[slotId].Handle, keyfileTemplate, array_capacity(keyfileTemplate), &keyfileHandle); switch (status) { case CKR_DATA_LEN_RANGE: status = CKR_DEVICE_MEMORY; break; case CKR_SESSION_READ_ONLY: status = CKR_TOKEN_WRITE_PROTECTED; break; } if (status != CKR_OK) throw Pkcs11Exception(status); // Some tokens report success even if the new object was truncated to fit in the available memory - vector <byte> objectData; + vector <uint8> objectData; GetObjectAttribute(slotId, keyfileHandle, CKA_VALUE, objectData); - finally_do_arg(vector <byte> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); }); + finally_do_arg(vector <uint8> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); }); if (objectData.size() != keyfileData.size()) { Pkcs11Functions->C_DestroyObject(Sessions[slotId].Handle, keyfileHandle); throw Pkcs11Exception(CKR_DEVICE_MEMORY); } } void SecurityToken::DeleteKeyfile(const SecurityTokenKeyfile& keyfile) { LoginUserIfRequired(keyfile.Token->SlotId); CK_RV status = Pkcs11Functions->C_DestroyObject(Sessions[keyfile.Token->SlotId].Handle, keyfile.Handle); if (status != CKR_OK) throw Pkcs11Exception(status); } vector <SecurityTokenKeyfile> SecurityToken::GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter, const wstring keyfileIdFilter) { bool unrecognizedTokenPresent = false; vector <SecurityTokenKeyfile> keyfiles; foreach(const CK_SLOT_ID & slotId, GetTokenSlots()) { SecurityTokenInfo token; if (slotIdFilter && *slotIdFilter != slotId) continue; try { LoginUserIfRequired(slotId); token = GetTokenInfo(slotId); } catch (UserAbort&) { continue; } catch (Pkcs11Exception& e) { if (e.GetErrorCode() == CKR_TOKEN_NOT_RECOGNIZED) { unrecognizedTokenPresent = true; continue; } throw; } foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA)) { SecurityTokenKeyfile keyfile; keyfile.Handle = dataHandle; keyfile.Token->SlotId = slotId; keyfile.Token = shared_ptr<SecurityTokenInfo>(new SecurityTokenInfo(token)); - vector <byte> privateAttrib; + vector <uint8> privateAttrib; GetObjectAttribute(slotId, dataHandle, CKA_PRIVATE, privateAttrib); if (privateAttrib.size() == sizeof(CK_BBOOL) && *(CK_BBOOL*)&privateAttrib.front() != CK_TRUE) continue; - vector <byte> label; + vector <uint8> label; GetObjectAttribute(slotId, dataHandle, CKA_LABEL, label); label.push_back(0); keyfile.IdUtf8 = (char*)&label.front(); #if defined (TC_WINDOWS) && !defined (TC_PROTOTYPE) keyfile.Id = Utf8StringToWide((const char*)&label.front()); #else keyfile.Id = StringConverter::ToWide((const char*)&label.front()); #endif if (keyfile.Id.empty() || (!keyfileIdFilter.empty() && keyfileIdFilter != keyfile.Id)) continue; keyfiles.push_back(keyfile); if (!keyfileIdFilter.empty()) break; } } if (keyfiles.empty() && unrecognizedTokenPresent) throw Pkcs11Exception(CKR_TOKEN_NOT_RECOGNIZED); return keyfiles; } list <SecurityTokenInfo> SecurityToken::GetAvailableTokens() { bool unrecognizedTokenPresent = false; list <SecurityTokenInfo> tokens; @@ -293,120 +293,120 @@ namespace VeraCrypt { CK_TOKEN_INFO info; CK_RV status = Pkcs11Functions->C_GetTokenInfo(slotId, &info); if (status != CKR_OK) throw Pkcs11Exception(status); SecurityTokenInfo token; token.SlotId = slotId; token.Flags = info.flags; char label[sizeof(info.label) + 1]; memset(label, 0, sizeof(label)); memcpy(label, info.label, sizeof(info.label)); token.LabelUtf8 = label; size_t lastSpace = token.LabelUtf8.find_last_not_of(' '); if (lastSpace == string::npos) token.LabelUtf8.clear(); else token.LabelUtf8 = token.LabelUtf8.substr(0, lastSpace + 1); #if defined (TC_WINDOWS) && !defined (TC_PROTOTYPE) token.Label = Utf8StringToWide(token.LabelUtf8); #else token.Label = StringConverter::ToWide(token.LabelUtf8); #endif return token; } - void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const + void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const { SecurityToken::LoginUserIfRequired(Token->SlotId); SecurityToken::GetObjectAttribute(Token->SlotId, Handle, CKA_VALUE, keyfileData); } vector <CK_OBJECT_HANDLE> SecurityToken::GetObjects(CK_SLOT_ID slotId, CK_ATTRIBUTE_TYPE objectClass) { if (Sessions.find(slotId) == Sessions.end()) throw ParameterIncorrect(SRC_POS); CK_ATTRIBUTE findTemplate; findTemplate.type = CKA_CLASS; findTemplate.pValue = &objectClass; findTemplate.ulValueLen = sizeof(objectClass); CK_RV status = Pkcs11Functions->C_FindObjectsInit(Sessions[slotId].Handle, &findTemplate, 1); if (status != CKR_OK) throw Pkcs11Exception(status); finally_do_arg(CK_SLOT_ID, slotId, { Pkcs11Functions->C_FindObjectsFinal(Sessions[finally_arg].Handle); }); CK_ULONG objectCount; vector <CK_OBJECT_HANDLE> objects; while (true) { CK_OBJECT_HANDLE object; CK_RV status = Pkcs11Functions->C_FindObjects(Sessions[slotId].Handle, &object, 1, &objectCount); if (status != CKR_OK) throw Pkcs11Exception(status); if (objectCount != 1) break; objects.push_back(object); } return objects; } - void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue) + void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue) { attributeValue.clear(); if (Sessions.find(slotId) == Sessions.end()) throw ParameterIncorrect(SRC_POS); CK_ATTRIBUTE attribute; attribute.type = attributeType; attribute.pValue = NULL_PTR; CK_RV status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1); if (status != CKR_OK) throw Pkcs11Exception(status); if (attribute.ulValueLen == 0) return; - attributeValue = vector <byte>(attribute.ulValueLen); + attributeValue = vector <uint8>(attribute.ulValueLen); attribute.pValue = &attributeValue.front(); status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1); if (status != CKR_OK) throw Pkcs11Exception(status); } list <CK_SLOT_ID> SecurityToken::GetTokenSlots() { CheckLibraryStatus(); list <CK_SLOT_ID> slots; CK_ULONG slotCount; CK_RV status = Pkcs11Functions->C_GetSlotList(TRUE, NULL_PTR, &slotCount); if (status != CKR_OK) throw Pkcs11Exception(status); if (slotCount > 0) { vector <CK_SLOT_ID> slotArray(slotCount); status = Pkcs11Functions->C_GetSlotList(TRUE, &slotArray.front(), &slotCount); if (status != CKR_OK) throw Pkcs11Exception(status); for (size_t i = 0; i < slotCount; i++) { CK_SLOT_INFO slotInfo; status = Pkcs11Functions->C_GetSlotInfo(slotArray[i], &slotInfo); diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h index 4dff42fa..6c454def 100644 --- a/src/Common/SecurityToken.h +++ b/src/Common/SecurityToken.h @@ -49,61 +49,61 @@ #endif // !TC_WINDOWS #define TC_SECURITY_TOKEN_KEYFILE_URL_PREFIX L"token://" #define TC_SECURITY_TOKEN_KEYFILE_URL_SLOT L"slot" #define TC_SECURITY_TOKEN_KEYFILE_URL_FILE L"file" #include "Token.h" namespace VeraCrypt { struct SecurityTokenInfo: TokenInfo { virtual ~SecurityTokenInfo() {}; virtual BOOL isEditable() const {return true;} CK_FLAGS Flags; string LabelUtf8; }; struct SecurityTokenKeyfile: TokenKeyfile { SecurityTokenKeyfile(); SecurityTokenKeyfile(const TokenKeyfilePath& path); virtual ~SecurityTokenKeyfile() {} operator TokenKeyfilePath () const; - void GetKeyfileData(vector<byte>& keyfileData) const; + void GetKeyfileData(vector<uint8>& keyfileData) const; string IdUtf8; CK_OBJECT_HANDLE Handle; }; struct Pkcs11Exception: public Exception { Pkcs11Exception(CK_RV errorCode = (CK_RV)-1) : ErrorCode(errorCode), SubjectErrorCodeValid(false), SubjectErrorCode((uint64)-1) { } Pkcs11Exception(CK_RV errorCode, uint64 subjectErrorCode) : ErrorCode(errorCode), SubjectErrorCodeValid(true), SubjectErrorCode(subjectErrorCode) { } #ifdef TC_HEADER_Platform_Exception virtual ~Pkcs11Exception() throw () { } TC_SERIALIZABLE_EXCEPTION(Pkcs11Exception); #else void Show(HWND parent) const; #endif operator string () const; CK_RV GetErrorCode() const { return ErrorCode; } @@ -154,71 +154,71 @@ namespace VeraCrypt #endif // !TC_HEADER_Platform_Exception struct Pkcs11Session { Pkcs11Session(): Handle(CK_UNAVAILABLE_INFORMATION), UserLoggedIn(false) { } CK_SESSION_HANDLE Handle; bool UserLoggedIn; }; struct GetPinFunctor { virtual ~GetPinFunctor() { } virtual void operator() (string& str) = 0; virtual void notifyIncorrectPin() = 0; }; struct SendExceptionFunctor { virtual ~SendExceptionFunctor() { } virtual void operator() (const Exception& e) = 0; }; class SecurityToken { public: static void CloseAllSessions() throw (); static void CloseLibrary(); - static void CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name); + static void CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name); static void DeleteKeyfile(const SecurityTokenKeyfile& keyfile); static vector <SecurityTokenKeyfile> GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter = nullptr, const wstring keyfileIdFilter = wstring()); static list <SecurityTokenInfo> GetAvailableTokens(); static SecurityTokenInfo GetTokenInfo(CK_SLOT_ID slotId); #ifdef TC_WINDOWS static void InitLibrary(const wstring& pkcs11LibraryPath, unique_ptr <GetPinFunctor> pinCallback, unique_ptr <SendExceptionFunctor> warningCallback); #else static void InitLibrary(const string& pkcs11LibraryPath, unique_ptr <GetPinFunctor> pinCallback, unique_ptr <SendExceptionFunctor> warningCallback); #endif static bool IsInitialized() { return Initialized; } static bool IsKeyfilePathValid(const wstring& securityTokenKeyfilePath); static const size_t MaxPasswordLength = 128; protected: static void CloseSession(CK_SLOT_ID slotId); static vector <CK_OBJECT_HANDLE> GetObjects(CK_SLOT_ID slotId, CK_ATTRIBUTE_TYPE objectClass); - static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue); + static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue); static list <CK_SLOT_ID> GetTokenSlots(); static void Login(CK_SLOT_ID slotId, const char* pin); static void LoginUserIfRequired(CK_SLOT_ID slotId); static void OpenSession(CK_SLOT_ID slotId); static void CheckLibraryStatus(); static bool Initialized; static unique_ptr <GetPinFunctor> PinCallback; static CK_FUNCTION_LIST_PTR Pkcs11Functions; #ifdef TC_WINDOWS static HMODULE Pkcs11LibraryHandle; #else static void* Pkcs11LibraryHandle; #endif static map <CK_SLOT_ID, Pkcs11Session> Sessions; static unique_ptr <SendExceptionFunctor> WarningCallback; - friend void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const; + friend void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const; }; } #endif // TC_HEADER_Common_SecurityToken diff --git a/src/Common/TLVParser.cpp b/src/Common/TLVParser.cpp index 9a177007..5ddf37e5 100644 --- a/src/Common/TLVParser.cpp +++ b/src/Common/TLVParser.cpp @@ -1,75 +1,75 @@ #include "TLVParser.h" #include <string.h> using namespace std; namespace VeraCrypt { /* TLV node structure creation */ shared_ptr<TLVNode> TLVParser::TLV_CreateNode() { shared_ptr<TLVNode> node = shared_ptr<TLVNode>(new TLVNode()); return node; } /* Check if the bit is correct */ - uint16 TLVParser::CheckBit(byte value, int bit) + uint16 TLVParser::CheckBit(uint8 value, int bit) { unsigned char bitvalue[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80}; if ((bit >= 1) && (bit <= 8)) { if (value & bitvalue[bit-1]) { return (1); } else { return (0); } } else { throw TLVException("FILE:"+string(__FILE__)+"LINE: "+to_string(static_cast<long long>((__LINE__)))+" fonction parameter incorrect! bit=["+to_string(static_cast<long long>(bit))); //return(2); } } /* Parsing one TLV node */ - shared_ptr<TLVNode> TLVParser::TLV_Parse_One(byte* buf, size_t size) + shared_ptr<TLVNode> TLVParser::TLV_Parse_One(uint8* buf, size_t size) { size_t index = 0; size_t i = 0; - byte tag1, tag2, tagsize; - byte len, lensize; - shared_ptr<vector<byte>> value = make_shared<vector<byte>>(); + uint8 tag1, tag2, tagsize; + uint8 len, lensize; + shared_ptr<vector<uint8>> value = make_shared<vector<uint8>>(); shared_ptr<TLVNode> node = TLV_CreateNode(); tag1 = tag2 = 0; tagsize = 1; tag1 = buf[index++]; if ((tag1 & 0x1f) == 0x1f) { tagsize++; tag2 = buf[index++]; //tag2 b8 must be 0! } if (tagsize == 1) { node->Tag = tag1; } else { node->Tag = (tag1 << 8) + tag2; } node->TagSize = tagsize; //SubFlag node->SubFlag = CheckBit(tag1,6); //L zone len = 0; lensize = 1; len = buf[index++]; if (CheckBit(len,8) == 0) { @@ -130,58 +130,58 @@ namespace VeraCrypt shared_ptr<TLVNode> subnode = TLV_Parse_One(parent->Value->data() + sublen, parent->Value->size() - sublen); parent->Subs->push_back(subnode); return subnode->MoreFlag; } else { return 0; } } /* Recursive function to parse all nodes starting from a root parent node */ void TLVParser::TLV_Parse_Sub(shared_ptr<TLVNode> parent) { size_t i; if (parent->SubFlag != 0) { // Parse all sub nodes. while (TLV_Parse_SubNodes(parent) != 0); for (i = 0; i < parent->Subs->size(); i++) { if (parent->Subs->at(i)->SubFlag != 0) { TLV_Parse_Sub(parent->Subs->at(i)); } } } } /* Parsing TLV from a buffer and constructing TLV structure */ - shared_ptr<TLVNode> TLVParser::TLV_Parse(byte* buf, size_t size) + shared_ptr<TLVNode> TLVParser::TLV_Parse(uint8* buf, size_t size) { shared_ptr<TLVNode> node = TLV_Parse_One(buf, size); TLV_Parse_Sub(node); return node; } /* Finding a TLV node with a particular tag */ shared_ptr<TLVNode> TLVParser::TLV_Find(shared_ptr<TLVNode> node, uint16 tag) { size_t i = 0; - shared_ptr<TLVNode> tmpnode = NULL; + shared_ptr<TLVNode> tmpnode; if (node->Tag == tag) { return node; } for (i = 0; i < node->Subs->size(); i++) { tmpnode = TLV_Find(node->Subs->at(i),tag); - if (tmpnode != NULL) + if (tmpnode) { return tmpnode; } } - return NULL; + return shared_ptr<TLVNode>(); } -}
\ No newline at end of file +} diff --git a/src/Common/TLVParser.h b/src/Common/TLVParser.h index b989ca41..2fc4a27c 100644 --- a/src/Common/TLVParser.h +++ b/src/Common/TLVParser.h @@ -1,80 +1,80 @@ #ifndef TC_HEADER_Common_TLVPARSER #define TC_HEADER_Common_TLVPARSER #include "Platform/PlatformBase.h" #include "Tcdefs.h" namespace VeraCrypt { struct TLVNode { uint16 Tag; /* T */ uint16 Length; /* L */ - shared_ptr<vector<byte>> Value; /* V */ - byte TagSize; - byte LengthSize; + shared_ptr<vector<uint8>> Value; /* V */ + uint8 TagSize; + uint8 LengthSize; uint16 MoreFlag; /* Used In Sub */ uint16 SubFlag; /* Does it have sub-nodes? */ shared_ptr<vector<shared_ptr<TLVNode>>> Subs; TLVNode() : Tag(0), Length(0), TagSize(0), LengthSize(0), MoreFlag(0), SubFlag(0) { - Value = make_shared<vector<byte>>(); + Value = make_shared<vector<uint8>>(); Subs = make_shared<vector<shared_ptr<TLVNode>>>(); } ~TLVNode() { burn(Value->data(), Value->size()); } }; class TLVParser { private : /* TLV node structure creation */ static shared_ptr<TLVNode> TLV_CreateNode(); /* Check if the bit is correct */ - static uint16 CheckBit(byte value, int bit); + static uint16 CheckBit(uint8 value, int bit); /* Parsing one TLV node */ - static shared_ptr<TLVNode> TLV_Parse_One(byte* buf, size_t size); + static shared_ptr<TLVNode> TLV_Parse_One(uint8* buf, size_t size); /* Parsing all TLV nodes */ static int TLV_Parse_SubNodes(shared_ptr<TLVNode> parent); /* Parsing all sub-nodes (in width not in depth) of a given parent node */ static int TLV_Parse_All(shared_ptr<TLVNode> parent); /* Recursive function to parse all nodes starting from a root parent node */ static void TLV_Parse_Sub(shared_ptr<TLVNode> parent); public: /* Parsing TLV from a buffer and constructing TLV structure */ - static shared_ptr<TLVNode> TLV_Parse(byte* buf, size_t size); + static shared_ptr<TLVNode> TLV_Parse(uint8* buf, size_t size); /* Finding a TLV node with a particular tag */ static shared_ptr<TLVNode> TLV_Find(shared_ptr<TLVNode> node, uint16 tag); }; /* The definition of the exception class related to the TLV parsing */ class TLVException { public: TLVException(std::string errormessage): m_errormessage(errormessage){} /* Get the error message */ inline std::string ErrorMessage() const { return m_errormessage; } protected: std::string m_errormessage; }; } #endif //TC_HEADER_Common_TLVPARSER diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h index 0ffb4c8d..3fd18358 100644 --- a/src/Common/Tcdefs.h +++ b/src/Common/Tcdefs.h @@ -32,154 +32,160 @@ void VeraCryptMemFree(IN VOID* ptr); #define TRUE 1 #endif #define max(a,b) ((a)>(b))?(a):(b) #define min(a,b) ((a)<(b))?(a):(b) #ifdef __cplusplus extern "C" { #endif extern unsigned __int64 __cdecl _rotl64(unsigned __int64,int); extern unsigned __int64 __cdecl _rotr64(unsigned __int64,int); extern unsigned int __cdecl _rotl(unsigned int,int); extern unsigned int __cdecl _rotr(unsigned int,int); extern unsigned char _rotr8(unsigned char value, unsigned char shift); extern unsigned short _rotr16(unsigned short value, unsigned char shift); extern unsigned char _rotl8(unsigned char value, unsigned char shift); extern unsigned short _rotl16(unsigned short value, unsigned char shift); #ifdef __cplusplus } #endif #endif // defined(_UEFI) #ifdef TC_WINDOWS_BOOT #include <stddef.h> #endif #define TC_APP_NAME "VeraCrypt" // Version displayed to user -#define VERSION_STRING "1.26.4" +#define VERSION_STRING "1.26.15" #ifdef VC_EFI_CUSTOM_MODE #define VERSION_STRING_SUFFIX "-CustomEFI" #elif defined(VC_SKIP_OS_DRIVER_REQ_CHECK) #define VERSION_STRING_SUFFIX "-TESTSIGNING" #else #define VERSION_STRING_SUFFIX "" #endif // Version number to compare against driver #define VERSION_NUM 0x0126 // Release date -#define TC_STR_RELEASE_DATE L"July 24, 2023" -#define TC_RELEASE_DATE_YEAR 2023 -#define TC_RELEASE_DATE_MONTH 07 +#define TC_STR_RELEASE_DATE L"September 2, 2024" +#define TC_RELEASE_DATE_YEAR 2024 +#define TC_RELEASE_DATE_MONTH 9 #define BYTES_PER_KB 1024LL #define BYTES_PER_MB 1048576LL #define BYTES_PER_GB 1073741824LL #define BYTES_PER_TB 1099511627776LL #define BYTES_PER_PB 1125899906842624LL /* GUI/driver errors */ #define WIDE(x) (LPWSTR)L##x #define VC_MAX(a,b) ((a)>(b))?(a):(b) #define VC_MIN(a,b) ((a)<(b))?(a):(b) #ifdef _MSC_VER typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; -typedef unsigned __int8 byte; typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; typedef unsigned __int32 uint32; #ifdef TC_NO_COMPILER_INT64 typedef unsigned __int32 TC_LARGEST_COMPILER_UINT; #else typedef unsigned __int64 TC_LARGEST_COMPILER_UINT; typedef __int64 int64; typedef unsigned __int64 uint64; #define LL(x) x##ui64 #endif +#if _MSC_VER > 1900 +#define VC_CDECL __cdecl // this is needed because Windows driver on VS2019 uses stdcall for build +#else +#define VC_CDECL +#endif + #pragma warning( disable : 4201 ) // disable: 4201 nonstandard extension used : nameless struct/union #pragma warning( disable : 4324 ) // disable: 4324 structure was padded due to __declspec(align()) #else // !_MSC_VER #include <inttypes.h> #include <limits.h> #include <memory.h> typedef int8_t int8; typedef int16_t int16; typedef int32_t int32; typedef int64_t int64; -typedef uint8_t byte; typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; #define LL(x) x##ULL #if UCHAR_MAX != 0xffU #error UCHAR_MAX != 0xff #endif #define __int8 char #if USHRT_MAX != 0xffffU #error USHRT_MAX != 0xffff #endif #define __int16 short #if UINT_MAX != 0xffffffffU #error UINT_MAX != 0xffffffff #endif #define __int32 int typedef uint64 TC_LARGEST_COMPILER_UINT; #define BOOL int #ifndef FALSE #define FALSE 0 #define TRUE 1 #endif +#define VC_CDECL + #endif // !_MSC_VER #define TC_INT_TYPES_DEFINED // Integer types required by Cryptolib typedef unsigned __int8 uint_8t; typedef unsigned __int16 uint_16t; typedef unsigned __int32 uint_32t; #ifndef TC_NO_COMPILER_INT64 typedef uint64 uint_64t; #endif typedef union { struct { unsigned __int32 LowPart; unsigned __int32 HighPart; }; #ifndef TC_NO_COMPILER_INT64 uint64 Value; #endif } UINT64_STRUCT; #ifndef __has_builtin // Optional of course #define __has_builtin(x) 0 // Compatibility with non-clang compilers #endif #if defined(_UEFI) @@ -278,100 +284,114 @@ typedef USHORT WORD; #ifndef BOOLEAN typedef unsigned char BOOLEAN; #endif #ifndef TRUE #define TRUE 1 #endif #ifndef FALSE #define FALSE !TRUE #endif typedef NTSTATUS (NTAPI *KeSaveExtendedProcessorStateFn) ( __in ULONG64 Mask, PXSTATE_SAVE XStateSave ); typedef VOID (NTAPI *KeRestoreExtendedProcessorStateFn) ( PXSTATE_SAVE XStateSave ); typedef NTSTATUS (NTAPI *ExGetFirmwareEnvironmentVariableFn) ( PUNICODE_STRING VariableName, LPGUID VendorGuid, PVOID Value, PULONG ValueLength, PULONG Attributes ); +typedef ULONG64 (NTAPI *KeQueryInterruptTimePreciseFn)( + PULONG64 QpcTimeStamp +); + typedef BOOLEAN (NTAPI *KeAreAllApcsDisabledFn) (); typedef void (NTAPI *KeSetSystemGroupAffinityThreadFn)( PGROUP_AFFINITY Affinity, PGROUP_AFFINITY PreviousAffinity ); typedef USHORT (NTAPI *KeQueryActiveGroupCountFn)(); typedef ULONG (NTAPI *KeQueryActiveProcessorCountExFn)( USHORT GroupNumber ); extern NTSTATUS NTAPI KeSaveExtendedProcessorStateVC ( __in ULONG64 Mask, PXSTATE_SAVE XStateSave ); extern VOID NTAPI KeRestoreExtendedProcessorStateVC ( PXSTATE_SAVE XStateSave ); extern BOOLEAN VC_KeAreAllApcsDisabled (VOID); #else /* !TC_WINDOWS_DRIVER */ #if !defined(_UEFI) #define TCalloc malloc #define TCfree free #else #define TCalloc VeraCryptMemAlloc #define TCfree VeraCryptMemFree #endif //!defined(_UEFI) #ifdef _WIN32 #ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE # undef _WIN32_WINNT -# define _WIN32_WINNT 0x0501 /* Does not apply to the driver */ +#ifdef _M_ARM64 +# define _WIN32_WINNT 0x0A00 +#else +// for Visual Studio 2015 and later, set minimum Windows version to Windows 8 +// for old versions of Visual Studio, set minimum Windows version to Windows 7 +#if _MSC_VER >= 1900 +# define _WIN32_WINNT 0x0602 +#else +# define _WIN32_WINNT 0x0601 +#endif +#endif #endif #include <windows.h> /* Windows header */ #include <commctrl.h> /* The common controls */ #include <process.h> /* Process control */ #include <winioctl.h> #include <stdio.h> /* For sprintf */ #include <tchar.h> #endif /* _WIN32 */ #endif /* !TC_WINDOWS_DRIVER */ #ifndef TC_TO_STRING # define TC_TO_STRING2(n) #n # define TC_TO_STRING(n) TC_TO_STRING2(n) #endif #ifdef DEVICE_DRIVER # if defined (DEBUG) || defined (DEBUG_TRACE) # if 0 // DbgPrintEx is not available on Windows 2000 # define Dump DbgPrint # else # define Dump(...) DbgPrintEx (DPFLTR_IHVDRIVER_ID, DPFLTR_ERROR_LEVEL, __VA_ARGS__) # endif # define DumpMem(...) DumpMemory (__VA_ARGS__) # else # define Dump(...) # define DumpMem(...) # endif @@ -461,34 +481,36 @@ enum ERR_DRIVE_NOT_FOUND = 5, ERR_FILES_OPEN = 6, ERR_VOL_SIZE_WRONG = 7, ERR_COMPRESSION_NOT_SUPPORTED = 8, ERR_PASSWORD_CHANGE_VOL_TYPE = 9, ERR_PASSWORD_CHANGE_VOL_VERSION = 10, ERR_VOL_SEEKING = 11, ERR_VOL_WRITING = 12, ERR_FILES_OPEN_LOCK = 13, ERR_VOL_READING = 14, ERR_DRIVER_VERSION = 15, ERR_NEW_VERSION_REQUIRED = 16, ERR_CIPHER_INIT_FAILURE = 17, ERR_CIPHER_INIT_WEAK_KEY = 18, ERR_SELF_TESTS_FAILED = 19, ERR_SECTOR_SIZE_INCOMPATIBLE = 20, ERR_VOL_ALREADY_MOUNTED = 21, ERR_NO_FREE_DRIVES = 22, ERR_FILE_OPEN_FAILED = 23, ERR_VOL_MOUNT_FAILED = 24, DEPRECATED_ERR_INVALID_DEVICE = 25, ERR_ACCESS_DENIED = 26, ERR_MODE_INIT_FAILED = 27, ERR_DONT_REPORT = 28, ERR_ENCRYPTION_NOT_COMPLETED = 29, ERR_PARAMETER_INCORRECT = 30, ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG = 31, ERR_NONSYS_INPLACE_ENC_INCOMPLETE = 32, ERR_USER_ABORT = 33, ERR_RAND_INIT_FAILED = 34, - ERR_CAPI_INIT_FAILED = 35 + ERR_CAPI_INIT_FAILED = 35, + ERR_XTS_MASTERKEY_VULNERABLE = 36, + ERR_SYSENC_XTS_MASTERKEY_VULNERABLE = 37 }; #endif // #ifndef TCDEFS_H diff --git a/src/Common/Tests.c b/src/Common/Tests.c index 4f53d4ed..530e7577 100644 --- a/src/Common/Tests.c +++ b/src/Common/Tests.c @@ -284,60 +284,63 @@ BOOL XTSAesTest (PCRYPTO_INFO ci) EncryptBufferXTS (p, sizeof (p), &dataUnitNo, XTS_vectors[i].blockNo, (unsigned char *) (ci->ks), (unsigned char *) ci->ks2, AES); if (memcmp (XTS_vectors[i].ciphertext, p, sizeof (p)) != 0) return FALSE; } return TRUE; } // AES ECB test vectors FIPS-197 #define AES_TEST_COUNT 1 typedef struct { unsigned char key[32]; unsigned char plaintext[16]; unsigned char ciphertext[16]; } AES_TEST; AES_TEST aes_ecb_vectors[AES_TEST_COUNT] = { 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, 0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff, 0x8e,0xa2,0xb7,0xca,0x51,0x67,0x45,0xbf,0xea,0xfc,0x49,0x90,0x4b,0x49,0x60,0x89 }; + +#ifndef WOLFCRYPT_BACKEND + // Serpent ECB test vectors #define SERPENT_TEST_COUNT 1 typedef struct { unsigned char key[32]; unsigned char plaintext[16]; unsigned char ciphertext[16]; } SERPENT_TEST; SERPENT_TEST serpent_vectors[SERPENT_TEST_COUNT] = { 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, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8, 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c }; // Twofish ECB test vectors #define TWOFISH_TEST_COUNT 1 typedef struct { unsigned char key[32]; unsigned char plaintext[16]; unsigned char ciphertext[16]; } TWOFISH_TEST; TWOFISH_TEST twofish_vectors[TWOFISH_TEST_COUNT] = { 0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D, @@ -392,60 +395,61 @@ KUZNYECHIK_TEST kuznyechik_vectors[KUZNYECHIK_TEST_COUNT] = { 0x55, 0x66, 0x77, 0x00, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88, 0x7F, 0x67, 0x9D, 0x90, 0xBE, 0xBC, 0x24, 0x30, 0x5A, 0x46, 0x8D, 0x42, 0xB9, 0xD4, 0xED, 0xCD }, { 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xEE, 0xFF, 0x0A, 0xB4, 0x29, 0x91, 0x2C, 0x6E, 0x00, 0x32, 0xF9, 0x28, 0x54, 0x52, 0xD7, 0x67, 0x18, 0xD0, 0x8B }, { 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xEE, 0xFF, 0x0A, 0x00, 0xF0, 0xCA, 0x33, 0x54, 0x9D, 0x24, 0x7C, 0xEE, 0xF3, 0xF5, 0xA5, 0x31, 0x3B, 0xD4, 0xB1, 0x57 }, { 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xEE, 0xFF, 0x0A, 0x00, 0x11, 0xD0, 0xB0, 0x9C, 0xCD, 0xE8, 0x30, 0xB9, 0xEB, 0x3A, 0x02, 0xC4, 0xC5, 0xAA, 0x8A, 0xDA, 0x98 } }; +#endif /* Test vectors from FIPS 198a, RFC 4231, RFC 2104, RFC 2202, and other sources. */ char *hmac_sha256_test_keys[] = { "\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b\x0b", "Jefe", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", "\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa\xaa", }; char *hmac_sha256_test_data[] = { "Hi There", "what do ya want for nothing?", "\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd\xdd", "\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd\xcd", "Test Using Larger Than Block-Size Key - Hash Key First", "This is a test using a larger than block-size key and a larger than block-size data. The key needs to be hashed before being used by the HMAC algorithm.", }; char *hmac_sha256_test_vectors[] = { "\xb0\x34\x4c\x61\xd8\xdb\x38\x53\x5c\xa8\xaf\xce\xaf\x0b\xf1\x2b\x88\x1d\xc2\x00\xc9\x83\x3d\xa7\x26\xe9\x37\x6c\x2e\x32\xcf\xf7", "\x5b\xdc\xc1\x46\xbf\x60\x75\x4e\x6a\x04\x24\x26\x08\x95\x75\xc7\x5a\x00\x3f\x08\x9d\x27\x39\x83\x9d\xec\x58\xb9\x64\xec\x38\x43", "\x77\x3e\xa9\x1e\x36\x80\x0e\x46\x85\x4d\xb8\xeb\xd0\x91\x81\xa7\x29\x59\x09\x8b\x3e\xf8\xc1\x22\xd9\x63\x55\x14\xce\xd5\x65\xfe", "\x82\x55\x8a\x38\x9a\x44\x3c\x0e\xa4\xcc\x81\x98\x99\xf2\x08\x3a\x85\xf0\xfa\xa3\xe5\x78\xf8\x07\x7a\x2e\x3f\xf4\x67\x29\x66\x5b", "\x60\xe4\x31\x59\x1e\xe0\xb6\x7f\x0d\x8a\x26\xaa\xcb\xf5\xb7\x7f\x8e\x0b\xc6\x21\x37\x28\xc5\x14\x05\x46\x04\x0f\x0e\xe3\x7f\x54", @@ -757,60 +761,61 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) ENCRYPTION_DATA_UNIT_SIZE) != 0) { return FALSE; } // CRC of all data units in the buffer for each test case switch (testCase) { case 0: if (crc != 0x888f2990) return FALSE; nTestsPerformed++; break; case 1: if (crc != 0xea28ea34) return FALSE; nTestsPerformed++; break; case 2: if (crc != 0xe058f5a2) return FALSE; nTestsPerformed++; break; case 3: if (crc != 0x10473dc9) return FALSE; nTestsPerformed++; break; } } + #ifndef WOLFCRYPT_BACKEND else if (wcscmp (name, L"Serpent") == 0) { switch (testCase) { case 0: if (crc != 0x7edfecb3) return FALSE; nTestsPerformed++; break; case 1: if (crc != 0x357baaaa) return FALSE; nTestsPerformed++; break; case 2: if (crc != 0xc7b9fca5) return FALSE; nTestsPerformed++; break; case 3: if (crc != 0xb5263e0c) return FALSE; nTestsPerformed++; break; } } else if (wcscmp (name, L"Twofish") == 0) { switch (testCase) { @@ -1121,112 +1126,113 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) nTestsPerformed++; break; } } else if (wcscmp (name, L"Kuznyechik-Serpent-Camellia") == 0) { switch (testCase) { case 0: if (crc != 0x9d8ac7ee) return FALSE; nTestsPerformed++; break; case 1: if (crc != 0x5d7d347f) return FALSE; nTestsPerformed++; break; case 2: if (crc != 0x884b62ee) return FALSE; nTestsPerformed++; break; case 3: if (crc != 0x5c6c3997) return FALSE; nTestsPerformed++; break; } } - + #endif if (crc == 0x9f5edd58) return FALSE; DecryptDataUnits (buf, &unitNo, nbrUnits, ci); if (GetCrc32 (buf, sizeof (buf)) != 0x9f5edd58) return FALSE; nTestsPerformed++; } testCase++; } /* Encryption/decryption of a buffer (typically, a volume header) */ nbrUnits = sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE; // Test all EAs that support this mode of operation for (ci->ea = EAGetFirst (); ci->ea != 0; ci->ea = EAGetNext (ci->ea)) { if (!EAIsModeSupported (ci->ea, ci->mode)) continue; EAGetName (name, ARRAYSIZE(name), ci->ea, 0); if (EAInit (ci->ea, key1, ci->ks) != ERR_SUCCESS) return FALSE; memcpy (key2, XTS_vectors[XTS_TEST_COUNT-1].key2, sizeof (XTS_vectors[XTS_TEST_COUNT-1].key2)); if (!EAInitMode (ci, key2)) return FALSE; // 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, ENCRYPTION_DATA_UNIT_SIZE); } EncryptBuffer (buf, sizeof (buf), ci); crc = GetCrc32 (buf, sizeof (buf)); if (wcscmp (name, L"AES") == 0) { if (crc != 0x33b91fab) return FALSE; nTestsPerformed++; } + #ifndef WOLFCRYPT_BACKEND else if (wcscmp (name, L"Serpent") == 0) { if (crc != 0x3494d480) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Twofish") == 0) { if (crc != 0xc4d65b46) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Camellia") == 0) { if (crc != 0x8176b223) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Kuznyechik") == 0) { if (crc != 0xd6d39cdb) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"AES-Twofish") == 0) { if (crc != 0x14ce7385) return FALSE; nTestsPerformed++; } @@ -1257,133 +1263,134 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) else if (wcscmp (name, L"Camellia-Kuznyechik") == 0) { if (crc != 0xe69d680d) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Kuznyechik-Twofish") == 0) { if (crc != 0xe0aef0d1) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Camellia-Serpent") == 0) { if (crc != 0x58aad727) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Kuznyechik-AES") == 0) { if (crc != 0x4641234a) return FALSE; nTestsPerformed++; } else if (wcscmp (name, L"Kuznyechik-Serpent-Camellia") == 0) { if (crc != 0x755dad72) return FALSE; nTestsPerformed++; } - + #endif if (crc == 0x9f5edd58) return FALSE; DecryptBuffer (buf, sizeof (buf), ci); if (GetCrc32 (buf, sizeof (buf)) != 0x9f5edd58) return FALSE; nTestsPerformed++; } return (nTestsPerformed == 150); } static BOOL DoAutoTestAlgorithms (void) { PCRYPTO_INFO ci; CRYPTOPP_ALIGN_DATA(16) char key[32]; unsigned char tmp[16]; BOOL bFailed = FALSE; int i; ci = crypto_open (); if (!ci) return FALSE; memset (ci, 0, sizeof (*ci)); /* 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); CipherInit(cipher, key, ks_tmp); EncipherBlock(cipher, tmp, ks_tmp); if (memcmp(aes_ecb_vectors[i].ciphertext, tmp, 16) != 0) break; DecipherBlock(cipher, tmp, ks_tmp); if (memcmp(aes_ecb_vectors[i].plaintext, tmp, 16) != 0) break; } if (i != AES_TEST_COUNT) bFailed = TRUE; // AES EncipherBlocks()/DecipherBlocks() { - byte testData[1024]; + uint8 testData[1024]; uint32 origCrc; size_t i; for (i = 0; i < sizeof (testData); ++i) { - testData[i] = (byte) i; + testData[i] = (uint8) i; } origCrc = GetCrc32 (testData, sizeof (testData)); CipherInit (AES, testData, ks_tmp); EncipherBlocks (AES, testData, ks_tmp, sizeof (testData) / CipherGetBlockSize (AES)); if (GetCrc32 (testData, sizeof (testData)) != 0xb5cd5631) bFailed = TRUE; DecipherBlocks (AES, testData, ks_tmp, sizeof (testData) / CipherGetBlockSize (AES)); if (origCrc != GetCrc32 (testData, sizeof (testData))) bFailed = TRUE; } + #ifndef WOLFCRYPT_BACKEND /* 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); CipherInit(cipher, key, ks_tmp); EncipherBlock(cipher, tmp, ks_tmp); if (memcmp(serpent_vectors[i].ciphertext, tmp, 16) != 0) break; DecipherBlock(cipher, tmp, ks_tmp); if (memcmp(serpent_vectors[i].plaintext, tmp, 16) != 0) break; } if (i != SERPENT_TEST_COUNT) bFailed = TRUE; /* 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); CipherInit(cipher, key, ks_tmp); @@ -1410,60 +1417,61 @@ static BOOL DoAutoTestAlgorithms (void) EncipherBlock(cipher, tmp, ks_tmp); if (memcmp(camellia_vectors[i].ciphertext, tmp, 16) != 0) break; DecipherBlock(cipher, tmp, ks_tmp); if (memcmp(camellia_vectors[i].plaintext, tmp, 16) != 0) break; } if (i != CAMELLIA_TEST_COUNT) bFailed = TRUE; /* Kuznyechik */ for (i = 0; i < KUZNYECHIK_TEST_COUNT; i++) { int cipher = KUZNYECHIK; memcpy(key, kuznyechik_vectors[i].key, 32); memcpy(tmp, kuznyechik_vectors[i].plaintext, 16); CipherInit(cipher, key, ks_tmp); EncipherBlock(cipher, tmp, ks_tmp); if (memcmp(kuznyechik_vectors[i].ciphertext, tmp, 16) != 0) break; DecipherBlock(cipher, tmp, ks_tmp); if (memcmp(kuznyechik_vectors[i].plaintext, tmp, 16) != 0) break; } if (i != KUZNYECHIK_TEST_COUNT) bFailed = TRUE; + #endif /* PKCS #5 and HMACs */ if (!test_pkcs5 ()) bFailed = TRUE; /* CRC-32 */ if (!crc32_selftests ()) bFailed = TRUE; /* GF multiplicator */ #if 0 if (!GfMulSelfTest ()) bFailed = TRUE; #endif /* XTS-AES */ if (!XTSAesTest (ci)) bFailed = TRUE; /* Sector and buffer related algorithms */ if (!TestSectorBufEncryption (ci)) bFailed = TRUE; crypto_close (ci); return !bFailed; } BOOL AutoTestAlgorithms (void) { @@ -1538,214 +1546,220 @@ BOOL test_hmac_sha256 () return (nTestsPerformed == 6); } BOOL test_hmac_sha512 () { unsigned int i; int nTestsPerformed = 0; for (i = 0; i < sizeof (hmac_sha512_test_data) / sizeof(char *); i++) { char digest[1024]; /* large enough to hold digets and test vector inputs */ size_t dataLen = strlen (hmac_sha512_test_data[i]); if (dataLen <= sizeof(digest)) { memcpy (digest, hmac_sha512_test_data[i], dataLen ); hmac_sha512 (hmac_sha512_test_keys[i], (int) strlen (hmac_sha512_test_keys[i]), digest, (int) dataLen); if (memcmp (digest, hmac_sha512_test_vectors[i], SHA512_DIGESTSIZE) != 0) return FALSE; else nTestsPerformed++; } else { return FALSE; } } return (nTestsPerformed == 6); } +#ifndef WOLFCRYPT_BACKEND BOOL test_hmac_blake2s () { unsigned int i; int nTestsPerformed = 0; for (i = 0; i < sizeof (hmac_blake2s_test_data) / sizeof(char *); i++) { char digest[1024]; /* large enough to hold digets and test vector inputs */ size_t dataLen = strlen (hmac_blake2s_test_data[i]); if (dataLen <= sizeof(digest)) { memcpy (digest, hmac_blake2s_test_data[i], dataLen); hmac_blake2s (hmac_blake2s_test_keys[i], (int) strlen (hmac_blake2s_test_keys[i]), digest, (int) dataLen); if (memcmp (digest, hmac_blake2s_test_vectors[i], BLAKE2S_DIGESTSIZE) != 0) return FALSE; else nTestsPerformed++; } else { return FALSE; } } return (nTestsPerformed == 6); } int __cdecl Blake2sHash (unsigned char* input, unsigned long inputLen, unsigned char* output) { blake2s(output, input, (size_t) inputLen); return BLAKE2S_DIGESTSIZE; } BOOL test_hmac_whirlpool () { unsigned char digest[1024]; /* large enough to hold digets and test vector inputs */ memcpy (digest, hmac_whirlpool_test_data, strlen (hmac_whirlpool_test_data)); hmac_whirlpool (hmac_whirlpool_test_key, 64, digest, (int) strlen (hmac_whirlpool_test_data)); if (memcmp (digest, hmac_whirlpool_test_vectors, WHIRLPOOL_DIGESTSIZE) != 0) return FALSE; return TRUE; } +#endif /* http://www.tc26.ru/methods/recommendation/%D0%A2%D0%9A26%D0%90%D0%9B%D0%93.pdf */ /* https://tools.ietf.org/html/draft-smyshlyaev-gost-usage-00 */ /* https://datatracker.ietf.org/doc/rfc7836/?include_text=1 */ static const unsigned char gost3411_2012_hmac_k1[] = { 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 }; static const unsigned char gost3411_2012_hmac_m1[] = { 0x01, 0x26, 0xbd, 0xb8, 0x78, 0x00, 0xaf, 0x21, 0x43, 0x41, 0x45, 0x65, 0x63, 0x78, 0x01, 0x00 }; static const unsigned char gost3411_2012_hmac_r1[] = { 0xA5, 0x9B, 0xAB, 0x22, 0xEC, 0xAE, 0x19, 0xC6, 0x5F, 0xBD, 0xE6, 0xE5, 0xF4, 0xE9, 0xF5, 0xD8, 0x54, 0x9D, 0x31, 0xF0, 0x37, 0xF9, 0xDF, 0x9B, 0x90, 0x55, 0x00, 0xE1, 0x71, 0x92, 0x3A, 0x77, 0x3D, 0x5F, 0x15, 0x30, 0xF2, 0xED, 0x7E, 0x96, 0x4C, 0xB2, 0xEE, 0xDC, 0x29, 0xE9, 0xAD, 0x2F, 0x3A, 0xFE, 0x93, 0xB2, 0x81, 0x4F, 0x79, 0xF5, 0x00, 0x0F, 0xFC, 0x03, 0x66, 0xC2, 0x51, 0xE6 }; +#ifndef WOLFCRYPT_BACKEND BOOL test_hmac_streebog () { CRYPTOPP_ALIGN_DATA(16) char digest[64]; /* large enough to hold digets and test vector inputs */ memcpy (digest, gost3411_2012_hmac_m1, sizeof (gost3411_2012_hmac_m1)); hmac_streebog ((char*) gost3411_2012_hmac_k1, sizeof(gost3411_2012_hmac_k1), digest, (int) sizeof (gost3411_2012_hmac_m1)); if (memcmp (digest, gost3411_2012_hmac_r1, STREEBOG_DIGESTSIZE) != 0) return FALSE; return TRUE; } int __cdecl StreebogHash (unsigned char* input, unsigned long inputLen, unsigned char* output) { STREEBOG_CTX ctx; STREEBOG_init (&ctx); STREEBOG_add (&ctx, input, inputLen); STREEBOG_finalize (&ctx, output); return STREEBOG_DIGESTSIZE; } +#endif BOOL test_pkcs5 () { char dk[144]; /* HMAC-SHA-256 tests */ if (!test_hmac_sha256()) return FALSE; /* HMAC-SHA-512 tests */ if (!test_hmac_sha512()) return FALSE; +#ifndef WOLFCRYPT_BACKEND /* HMAC-BLAKE2s tests */ if (test_hmac_blake2s() == FALSE) return FALSE; /* Blake2s hash tests */ if (RunHashTest (Blake2sHash, Blake2sTestVectors, (HasSSE2())? TRUE : FALSE) == FALSE) return FALSE; /* HMAC-Whirlpool tests */ if (test_hmac_whirlpool() == FALSE) return FALSE; /* HMAC-STREEBOG tests */ if (test_hmac_streebog() == FALSE) return FALSE; /* STREEBOG hash tests */ if (RunHashTest (StreebogHash, Streebog512TestVectors, (HasSSE2() || HasSSE41())? TRUE : FALSE) == FALSE) return FALSE; - +#endif /* PKCS-5 test 1 with HMAC-SHA-256 used as the PRF (https://tools.ietf.org/html/draft-josefsson-scrypt-kdf-00) */ derive_key_sha256 ("passwd", 6, "\x73\x61\x6C\x74", 4, 1, dk, 64); if (memcmp (dk, "\x55\xac\x04\x6e\x56\xe3\x08\x9f\xec\x16\x91\xc2\x25\x44\xb6\x05\xf9\x41\x85\x21\x6d\xde\x04\x65\xe6\x8b\x9d\x57\xc2\x0d\xac\xbc\x49\xca\x9c\xcc\xf1\x79\xb6\x45\x99\x16\x64\xb3\x9d\x77\xef\x31\x7c\x71\xb8\x45\xb1\xe3\x0b\xd5\x09\x11\x20\x41\xd3\xa1\x97\x83", 64) != 0) return FALSE; /* PKCS-5 test 2 with HMAC-SHA-256 used as the PRF (https://stackoverflow.com/questions/5130513/pbkdf2-hmac-sha2-test-vectors) */ derive_key_sha256 ("password", 8, "\x73\x61\x6C\x74", 4, 2, dk, 32); if (memcmp (dk, "\xae\x4d\x0c\x95\xaf\x6b\x46\xd3\x2d\x0a\xdf\xf9\x28\xf0\x6d\xd0\x2a\x30\x3f\x8e\xf3\xc2\x51\xdf\xd6\xe2\xd8\x5a\x95\x47\x4c\x43", 32) != 0) return FALSE; /* PKCS-5 test 3 with HMAC-SHA-256 used as the PRF (MS CryptoAPI) */ derive_key_sha256 ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 4); if (memcmp (dk, "\xf2\xa0\x4f\xb2", 4) != 0) return FALSE; /* PKCS-5 test 4 with HMAC-SHA-256 used as the PRF (MS CryptoAPI) */ derive_key_sha256 ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 144); if (memcmp (dk, "\xf2\xa0\x4f\xb2\xd3\xe9\xa5\xd8\x51\x0b\x5c\x06\xdf\x70\x8e\x24\xe9\xc7\xd9\x15\x3d\x22\xcd\xde\xb8\xa6\xdb\xfd\x71\x85\xc6\x99\x32\xc0\xee\x37\x27\xf7\x24\xcf\xea\xa6\xac\x73\xa1\x4c\x4e\x52\x9b\x94\xf3\x54\x06\xfc\x04\x65\xa1\x0a\x24\xfe\xf0\x98\x1d\xa6\x22\x28\xeb\x24\x55\x74\xce\x6a\x3a\x28\xe2\x04\x3a\x59\x13\xec\x3f\xf2\xdb\xcf\x58\xdd\x53\xd9\xf9\x17\xf6\xda\x74\x06\x3c\x0b\x66\xf5\x0f\xf5\x58\xa3\x27\x52\x8c\x5b\x07\x91\xd0\x81\xeb\xb6\xbc\x30\x69\x42\x71\xf2\xd7\x18\x42\xbe\xe8\x02\x93\x70\x66\xad\x35\x65\xbc\xf7\x96\x8e\x64\xf1\xc6\x92\xda\xe0\xdc\x1f\xb5\xf4", 144) != 0) return FALSE; /* PKCS-5 test 1 with HMAC-SHA-512 used as the PRF */ derive_key_sha512 ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 4); if (memcmp (dk, "\x13\x64\xae\xf8", 4) != 0) return FALSE; /* PKCS-5 test 2 with HMAC-SHA-512 used as the PRF (derives a key longer than the underlying hash output size and block size) */ derive_key_sha512 ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 144); if (memcmp (dk, "\x13\x64\xae\xf8\x0d\xf5\x57\x6c\x30\xd5\x71\x4c\xa7\x75\x3f\xfd\x00\xe5\x25\x8b\x39\xc7\x44\x7f\xce\x23\x3d\x08\x75\xe0\x2f\x48\xd6\x30\xd7\x00\xb6\x24\xdb\xe0\x5a\xd7\x47\xef\x52\xca\xa6\x34\x83\x47\xe5\xcb\xe9\x87\xf1\x20\x59\x6a\xe6\xa9\xcf\x51\x78\xc6\xb6\x23\xa6\x74\x0d\xe8\x91\xbe\x1a\xd0\x28\xcc\xce\x16\x98\x9a\xbe\xfb\xdc\x78\xc9\xe1\x7d\x72\x67\xce\xe1\x61\x56\x5f\x96\x68\xe6\xe1\xdd\xf4\xbf\x1b\x80\xe0\x19\x1c\xf4\xc4\xd3\xdd\xd5\xd5\x57\x2d\x83\xc7\xa3\x37\x87\xf4\x4e\xe0\xf6\xd8\x6d\x65\xdc\xa0\x52\xa3\x13\xbe\x81\xfc\x30\xbe\x7d\x69\x58\x34\xb6\xdd\x41\xc6", 144) != 0) return FALSE; +#ifndef WOLFCRYPT_BACKEND /* PKCS-5 test 1 with HMAC-BLAKE2s used as the PRF */ derive_key_blake2s ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 4); if (memcmp (dk, "\x8d\x51\xfa\x31", 4) != 0) return FALSE; /* PKCS-5 test 2 with HMAC-BLAKE2s used as the PRF (derives a key longer than the underlying hash) */ derive_key_blake2s ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 48); if (memcmp (dk, "\x8d\x51\xfa\x31\x46\x25\x37\x67\xa3\x29\x6b\x3c\x6b\xc1\x5d\xb2\xee\xe1\x6c\x28\x00\x26\xea\x08\x65\x9c\x12\xf1\x07\xde\x0d\xb9\x9b\x4f\x39\xfa\xc6\x80\x26\xb1\x8f\x8e\x48\x89\x85\x2d\x24\x2d", 48) != 0) return FALSE; /* PKCS-5 test 1 with HMAC-Whirlpool used as the PRF */ derive_key_whirlpool ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 4); if (memcmp (dk, "\x50\x7c\x36\x6f", 4) != 0) return FALSE; /* PKCS-5 test 2 with HMAC-Whirlpool used as the PRF (derives a key longer than the underlying hash) */ derive_key_whirlpool ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 96); if (memcmp (dk, "\x50\x7c\x36\x6f\xee\x10\x2e\x9a\xe2\x8a\xd5\x82\x72\x7d\x27\x0f\xe8\x4d\x7f\x68\x7a\xcf\xb5\xe7\x43\x67\xaa\x98\x93\x52\x2b\x09\x6e\x42\xdf\x2c\x59\x4a\x91\x6d\x7e\x10\xae\xb2\x1a\x89\x8f\xb9\x8f\xe6\x31\xa9\xd8\x9f\x98\x26\xf4\xda\xcd\x7d\x65\x65\xde\x10\x95\x91\xb4\x84\x26\xae\x43\xa1\x00\x5b\x1e\xb8\x38\x97\xa4\x1e\x4b\xd2\x65\x64\xbc\xfa\x1f\x35\x85\xdb\x4f\x97\x65\x6f\xbd\x24", 96) != 0) return FALSE; /* PKCS-5 test 1 with HMAC-STREEBOG used as the PRF */ derive_key_streebog ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 4); if (memcmp (dk, "\xd0\x53\xa2\x30", 4) != 0) return FALSE; /* PKCS-5 test 2 with HMAC-STREEBOG used as the PRF (derives a key longer than the underlying hash) */ derive_key_streebog ("password", 8, "\x12\x34\x56\x78", 4, 5, dk, 96); if (memcmp (dk, "\xd0\x53\xa2\x30\x6f\x45\x81\xeb\xbc\x06\x81\xc5\xe7\x53\xa8\x5d\xc7\xf1\x23\x33\x1e\xbe\x64\x2c\x3b\x0f\x26\xd7\x00\xe1\x95\xc9\x65\x26\xb1\x85\xbe\x1e\xe2\xf4\x9b\xfc\x6b\x14\x84\xda\x24\x61\xa0\x1b\x9e\x79\x5c\xee\x69\x6e\xf9\x25\xb1\x1d\xca\xa0\x31\xba\x02\x6f\x9e\x99\x0f\xdb\x25\x01\x5b\xf1\xc7\x10\x19\x53\x3b\x29\x3f\x18\x00\xd6\xfc\x85\x03\xdc\xf2\xe5\xe9\x5a\xb1\x1e\x61\xde", 96) != 0) return FALSE; - +#endif return TRUE; } diff --git a/src/Common/Token.h b/src/Common/Token.h index c1dd8ac4..959c7e24 100644 --- a/src/Common/Token.h +++ b/src/Common/Token.h @@ -14,48 +14,48 @@ #include <string> #define UNAVAILABLE_SLOT ~0UL namespace VeraCrypt { struct TokenKeyfilePath { virtual ~TokenKeyfilePath() {}; TokenKeyfilePath(const wstring& path): Path(path) { } operator wstring () const { return Path; } wstring Path; // Complete path }; struct TokenInfo { TokenInfo(): SlotId(0), Label(L"") {} virtual ~TokenInfo() {} virtual BOOL isEditable() const = 0; unsigned long int SlotId; wstring Label; // Card name }; struct TokenKeyfile { virtual ~TokenKeyfile() {} virtual operator TokenKeyfilePath () const = 0; - virtual void GetKeyfileData(vector <byte>& keyfileData) const = 0; + virtual void GetKeyfileData(vector <uint8>& keyfileData) const = 0; shared_ptr<TokenInfo> Token; wstring Id; }; class Token { public: - static vector<shared_ptr<TokenKeyfile>> GetAvailableKeyfiles(bool isEMVSupportEnabled); + static vector< shared_ptr<TokenKeyfile> > GetAvailableKeyfiles(bool isEMVSupportEnabled); static bool IsKeyfilePathValid(const wstring& tokenKeyfilePath, bool isEMVSupportEnabled); - static list <shared_ptr<TokenInfo>> GetAvailableTokens(); + static list < shared_ptr<TokenInfo> > GetAvailableTokens(); static shared_ptr<TokenKeyfile> getTokenKeyfile(const TokenKeyfilePath& path); }; }; #endif //TC_HEADER_Common_Token diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index 5b1d4065..7ee519f6 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -103,73 +103,73 @@ // 84 8 Header creation time // 92 8 Size of hidden volume in bytes (0 = normal volume) // 100 8 Size of the volume in bytes (identical with field 92 for hidden volumes) // 108 8 Start byte offset of the encrypted area of the volume // 116 8 Size of the encrypted area of the volume in bytes // 124 132 Reserved (must contain zeroes) // 256 256 Concatenated primary master key(s) and secondary master key(s) (XTS mode) /* Deprecated/legacy volume header v2 structure (used before TrueCrypt 5.0): */ // // Offset Length Description // ------------------------------------------ // Unencrypted: // 0 64 Salt // Encrypted: // 64 4 ASCII string 'VERA' // 68 2 Header version // 70 2 Required program version // 72 4 CRC-32 checksum of the (decrypted) bytes 256-511 // 76 8 Volume creation time // 84 8 Header creation time // 92 8 Size of hidden volume in bytes (0 = normal volume) // 100 156 Reserved (must contain zeroes) // 256 32 For LRW (deprecated/legacy), secondary key // For CBC (deprecated/legacy), data used to generate IV and whitening values // 288 224 Master key(s) -uint16 GetHeaderField16 (byte *header, int offset) +uint16 GetHeaderField16 (uint8 *header, int offset) { return BE16 (*(uint16 *) (header + offset)); } -uint32 GetHeaderField32 (byte *header, int offset) +uint32 GetHeaderField32 (uint8 *header, int offset) { return BE32 (*(uint32 *) (header + offset)); } -UINT64_STRUCT GetHeaderField64 (byte *header, int offset) +UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset) { UINT64_STRUCT uint64Struct; #ifndef TC_NO_COMPILER_INT64 uint64Struct.Value = BE64 (*(uint64 *) (header + offset)); #else uint64Struct.HighPart = BE32 (*(uint32 *) (header + offset)); uint64Struct.LowPart = BE32 (*(uint32 *) (header + offset + 4)); #endif return uint64Struct; } #ifndef TC_WINDOWS_BOOT typedef struct { char DerivedKey[MASTER_KEYDATA_SIZE]; BOOL Free; LONG KeyReady; int Pkcs5Prf; } KeyDerivationWorkItem; BOOL ReadVolumeHeaderRecoveryMode = FALSE; int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) { char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; unsigned char* keyInfoBuffer = NULL; @@ -342,85 +342,88 @@ int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int { for (i = 0; i < pkcs5PrfCount; ++i) { item = &keyDerivationWorkItems[i]; if (!item->Free && InterlockedExchangeAdd (&item->KeyReady, 0) == TRUE) { pkcs5_prf = item->Pkcs5Prf; keyInfo->noIterations = get_pkcs5_iteration_count (pkcs5_prf, pim, bBoot); memcpy (dk, item->DerivedKey, sizeof (dk)); item->Free = TRUE; --queuedWorkItems; goto KeyReady; } } if (queuedWorkItems > 0) TC_WAIT_EVENT (*keyDerivationCompletedEvent); } continue; KeyReady: ; } else #endif // !defined(_UEFI) { pkcs5_prf = enqPkcs5Prf; keyInfo->noIterations = get_pkcs5_iteration_count (enqPkcs5Prf, pim, bBoot); switch (pkcs5_prf) { - case BLAKE2S: - derive_key_blake2s (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, + case SHA512: + derive_key_sha512 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize()); break; - case SHA512: - derive_key_sha512 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, + case SHA256: + derive_key_sha256 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize()); break; - case WHIRLPOOL: - derive_key_whirlpool (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, + #ifndef WOLFCRYPT_BACKEND + case BLAKE2S: + derive_key_blake2s (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize()); break; - case SHA256: - derive_key_sha256 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, + case WHIRLPOOL: + derive_key_whirlpool (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize()); break; - case STREEBOG: + + case STREEBOG: derive_key_streebog(keyInfo->userKey, keyInfo->keyLength, keyInfo->salt, PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize()); break; - default: + #endif + default: // Unknown/wrong ID TC_THROW_FATAL_EXCEPTION; } } // Test all available modes of operation for (cryptoInfo->mode = FIRST_MODE_OF_OPERATION_ID; cryptoInfo->mode <= LAST_MODE_OF_OPERATION; cryptoInfo->mode++) { switch (cryptoInfo->mode) { default: primaryKeyOffset = 0; } // Test all available encryption algorithms for (cryptoInfo->ea = EAGetFirst (); cryptoInfo->ea != 0; cryptoInfo->ea = EAGetNext (cryptoInfo->ea)) { int blockSize; if (!EAIsModeSupported (cryptoInfo->ea, cryptoInfo->mode)) continue; // This encryption algorithm has never been available with this mode of operation blockSize = CipherGetBlockSize (EAGetFirstCipher (cryptoInfo->ea)); status = EAInit (cryptoInfo->ea, dk + primaryKeyOffset, cryptoInfo->ks); @@ -567,280 +570,309 @@ KeyReady: ; blake2s_update (&ctx, header, sizeof(header)); blake2s_final (&ctx, cryptoInfo->master_keydata_hash); burn(&ctx, sizeof (ctx)); #ifndef _WIN64 if (NT_SUCCESS (saveStatus)) KeRestoreFloatingPointState (&floatingPointState); #endif } #else memcpy (cryptoInfo->master_keydata, keyInfo->master_keydata, MASTER_KEYDATA_SIZE); #endif // PKCS #5 cryptoInfo->pkcs5 = pkcs5_prf; cryptoInfo->noIterations = keyInfo->noIterations; cryptoInfo->volumePim = pim; // Init the cipher with the decrypted master key status = EAInit (cryptoInfo->ea, keyInfo->master_keydata + primaryKeyOffset, cryptoInfo->ks); if (status == ERR_CIPHER_INIT_FAILURE) goto err; #ifndef TC_WINDOWS_DRIVER // The secondary master key (if cascade, multiple concatenated) memcpy (cryptoInfo->k2, keyInfo->master_keydata + EAGetKeySize (cryptoInfo->ea), EAGetKeySize (cryptoInfo->ea)); #endif if (!EAInitMode (cryptoInfo, keyInfo->master_keydata + EAGetKeySize (cryptoInfo->ea))) { status = ERR_MODE_INIT_FAILED; goto err; } + // check that first half of keyInfo.master_keydata is different from the second half. If they are the same return error + if (memcmp (keyInfo->master_keydata, keyInfo->master_keydata + EAGetKeySize (cryptoInfo->ea), EAGetKeySize (cryptoInfo->ea)) == 0) + { + cryptoInfo->bVulnerableMasterKey = TRUE; + if (retHeaderCryptoInfo) + retHeaderCryptoInfo->bVulnerableMasterKey = TRUE; + } + status = ERR_SUCCESS; goto ret; } } } status = ERR_PASSWORD_WRONG; err: if (cryptoInfo != retHeaderCryptoInfo) { crypto_close(cryptoInfo); *retInfo = NULL; } ret: burn (dk, sizeof(dk)); burn (header, sizeof(header)); #if !defined(DEVICE_DRIVER) && !defined(_UEFI) VirtualUnlock (&dk, sizeof (dk)); VirtualUnlock (&header, sizeof (header)); #endif #if !defined(_UEFI) if ((selected_pkcs5_prf == 0) && (encryptionThreadCount > 1)) { EncryptionThreadPoolBeginReadVolumeHeaderFinalization (keyDerivationCompletedEvent, noOutstandingWorkItemEvent, outstandingWorkItemCount, keyInfoBuffer, keyInfoBufferSize, keyDerivationWorkItems, keyDerivationWorkItemsSize); } else #endif { burn (keyInfo, sizeof (KEY_INFO)); #if !defined(DEVICE_DRIVER) && !defined(_UEFI) VirtualUnlock (keyInfoBuffer, keyInfoBufferSize); #endif TCfree(keyInfoBuffer); } return status; } #if defined(_WIN32) && !defined(_UEFI) -void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint) +void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint) { // compute Whirlpool+SHA512 fingerprint of bootloader including MBR // we skip user configuration fields: // TC_BOOT_SECTOR_PIM_VALUE_OFFSET = 400 // TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET = 402 // => TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE = 4 // TC_BOOT_SECTOR_USER_MESSAGE_OFFSET = 406 // => TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH = 24 // TC_BOOT_SECTOR_USER_CONFIG_OFFSET = 438 // // we have: TC_BOOT_SECTOR_USER_MESSAGE_OFFSET = TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE - WHIRLPOOL_CTX whirlpool; +#ifndef WOLFCRYPT_BACKEND + WHIRLPOOL_CTX whirlpool; sha512_ctx sha2; WHIRLPOOL_init (&whirlpool); sha512_begin (&sha2); WHIRLPOOL_add (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &whirlpool); sha512_hash (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &sha2); WHIRLPOOL_add (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &whirlpool); sha512_hash (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &sha2); WHIRLPOOL_add (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &whirlpool); sha512_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2); WHIRLPOOL_finalize (&whirlpool, fingerprint); sha512_end (&fingerprint [WHIRLPOOL_DIGESTSIZE], &sha2); +#else + sha512_ctx sha2_512; + sha256_ctx sha2_256; + + sha512_begin (&sha2_512); + sha256_begin (&sha2_256); + + sha512_hash (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &sha2_512); + sha256_hash (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &sha2_256); + + sha512_hash (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &sha2_512); + sha256_hash (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &sha2_256); + + sha512_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2_512); + sha256_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2_256); + + sha512_end (&fingerprint, &sha2_512); + sha256_end (&fingerprint [SHA512_DIGESTSIZE], &sha2_256); + sha256_end (&fingerprint [SHA512_DIGESTSIZE + SHA256_DIGESTSIZE], &sha2_256); +#endif } #endif #else // TC_WINDOWS_BOOT int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) { #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE char dk[32 * 2]; // 2 * 256-bit key #else char dk[32 * 2 * 3]; // 6 * 256-bit key #endif PCRYPTO_INFO cryptoInfo; int status = ERR_SUCCESS; uint32 iterations = pim; iterations <<= 16; iterations |= bBoot; if (retHeaderCryptoInfo != NULL) cryptoInfo = retHeaderCryptoInfo; else cryptoInfo = *retInfo = crypto_open (); // PKCS5 PRF #ifdef TC_WINDOWS_BOOT_SHA2 derive_key_sha256 (password->Text, (int) password->Length, header + HEADER_SALT_OFFSET, PKCS5_SALT_SIZE, iterations, dk, sizeof (dk)); #else derive_key_blake2s (password->Text, (int) password->Length, header + HEADER_SALT_OFFSET, PKCS5_SALT_SIZE, iterations, dk, sizeof (dk)); #endif // Mode of operation cryptoInfo->mode = FIRST_MODE_OF_OPERATION_ID; #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE cryptoInfo->ea = 1; #else // Test all available encryption algorithms for (cryptoInfo->ea = EAGetFirst (); cryptoInfo->ea != 0; cryptoInfo->ea = EAGetNext (cryptoInfo->ea)) #endif { #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE - #if defined (TC_WINDOWS_BOOT_SERPENT) + #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_set_key (dk, cryptoInfo->ks); - #elif defined (TC_WINDOWS_BOOT_TWOFISH) + #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_set_key ((TwofishInstance *) cryptoInfo->ks, (const u4byte *) dk); - #elif defined (TC_WINDOWS_BOOT_CAMELLIA) + #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_set_key (dk, cryptoInfo->ks); #else status = EAInit (dk, cryptoInfo->ks); if (status == ERR_CIPHER_INIT_FAILURE) goto err; #endif #else status = EAInit (cryptoInfo->ea, dk, cryptoInfo->ks); if (status == ERR_CIPHER_INIT_FAILURE) goto err; #endif // Secondary key schedule #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE - #if defined (TC_WINDOWS_BOOT_SERPENT) + #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_set_key (dk + 32, cryptoInfo->ks2); - #elif defined (TC_WINDOWS_BOOT_TWOFISH) + #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_set_key ((TwofishInstance *)cryptoInfo->ks2, (const u4byte *) (dk + 32)); - #elif defined (TC_WINDOWS_BOOT_CAMELLIA) + #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_set_key (dk + 32, cryptoInfo->ks2); #else EAInit (dk + 32, cryptoInfo->ks2); #endif #else EAInit (cryptoInfo->ea, dk + EAGetKeySize (cryptoInfo->ea), cryptoInfo->ks2); #endif // 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)) || GetHeaderField32 (header, TC_HEADER_OFFSET_KEY_AREA_CRC) != GetCrc32 (header + HEADER_MASTER_KEYDATA_OFFSET, MASTER_KEYDATA_SIZE)) { EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE status = ERR_PASSWORD_WRONG; goto err; #else continue; #endif } // Header decrypted status = 0; // Hidden volume status cryptoInfo->VolumeSize = GetHeaderField64 (header, TC_HEADER_OFFSET_HIDDEN_VOLUME_SIZE); cryptoInfo->hiddenVolume = (cryptoInfo->VolumeSize.LowPart != 0 || cryptoInfo->VolumeSize.HighPart != 0); // 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); // Flags cryptoInfo->HeaderFlags = GetHeaderField32 (header, TC_HEADER_OFFSET_FLAGS); #ifdef TC_WINDOWS_BOOT_SHA2 cryptoInfo->pkcs5 = SHA256; #else cryptoInfo->pkcs5 = BLAKE2S; #endif memcpy (dk, header + HEADER_MASTER_KEYDATA_OFFSET, sizeof (dk)); EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); if (retHeaderCryptoInfo) goto ret; // Init the encryption algorithm with the decrypted master key #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE - #if defined (TC_WINDOWS_BOOT_SERPENT) + #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_set_key (dk, cryptoInfo->ks); - #elif defined (TC_WINDOWS_BOOT_TWOFISH) + #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_set_key ((TwofishInstance *) cryptoInfo->ks, (const u4byte *) dk); - #elif defined (TC_WINDOWS_BOOT_CAMELLIA) + #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_set_key (dk, cryptoInfo->ks); #else status = EAInit (dk, cryptoInfo->ks); if (status == ERR_CIPHER_INIT_FAILURE) goto err; #endif #else status = EAInit (cryptoInfo->ea, dk, cryptoInfo->ks); if (status == ERR_CIPHER_INIT_FAILURE) goto err; #endif // The secondary master key (if cascade, multiple concatenated) #ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE - #if defined (TC_WINDOWS_BOOT_SERPENT) + #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND) serpent_set_key (dk + 32, cryptoInfo->ks2); - #elif defined (TC_WINDOWS_BOOT_TWOFISH) + #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND) twofish_set_key ((TwofishInstance *)cryptoInfo->ks2, (const u4byte *) (dk + 32)); - #elif defined (TC_WINDOWS_BOOT_CAMELLIA) + #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND) camellia_set_key (dk + 32, cryptoInfo->ks2); #else EAInit (dk + 32, cryptoInfo->ks2); #endif #else EAInit (cryptoInfo->ea, dk + EAGetKeySize (cryptoInfo->ea), cryptoInfo->ks2); #endif goto ret; } status = ERR_PASSWORD_WRONG; err: if (cryptoInfo != retHeaderCryptoInfo) { crypto_close(cryptoInfo); *retInfo = NULL; } ret: burn (dk, sizeof(dk)); return status; } #endif // TC_WINDOWS_BOOT #if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) #ifdef VOLFORMAT @@ -949,75 +981,76 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, // Mode of operation cryptoInfo->mode = mode; // Salt for header key derivation #if !defined(_UEFI) if (!RandgetBytes(hwndDlg, keyInfo.salt, PKCS5_SALT_SIZE, !bWipeMode)) #else if (!RandgetBytes(keyInfo.salt, PKCS5_SALT_SIZE, !bWipeMode)) #endif { crypto_close (cryptoInfo); retVal = ERR_CIPHER_INIT_WEAK_KEY; goto err; } if (password) { // PBKDF2 (PKCS5) is used to derive primary header key(s) and secondary header key(s) (XTS) from the password/keyfiles switch (pkcs5_prf) { case SHA512: derive_key_sha512 (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; case SHA256: derive_key_sha256 (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; + #ifndef WOLFCRYPT_BACKEND case BLAKE2S: derive_key_blake2s (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; case WHIRLPOOL: derive_key_whirlpool (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; case STREEBOG: derive_key_streebog(keyInfo.userKey, keyInfo.keyLength, keyInfo.salt, PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize()); break; - + #endif default: // Unknown/wrong ID crypto_close (cryptoInfo); TC_THROW_FATAL_EXCEPTION; } } else { // generate a random key #if !defined(_UEFI) if (!RandgetBytes(hwndDlg, dk, GetMaxPkcs5OutSize(), !bWipeMode)) #else if (!RandgetBytes(dk, GetMaxPkcs5OutSize(), !bWipeMode)) #endif { crypto_close (cryptoInfo); retVal = ERR_CIPHER_INIT_WEAK_KEY; goto err; } } /* Header setup */ // Salt mputBytes (p, keyInfo.salt, PKCS5_SALT_SIZE); // Magic mputLong (p, 0x56455241); // Header version @@ -1162,100 +1195,100 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, StringCchPrintfW (tmp2, ARRAYSIZE(tmp2), L"%02X", (int) (unsigned char) dk[primaryKeyOffset + i]); StringCchCatW (HeaderKeyGUIView, ARRAYSIZE(HeaderKeyGUIView), tmp2); } if (dots3) { DisplayPortionsOfKeys (hHeaderKey, hMasterKey, HeaderKeyGUIView, MasterKeyGUIView, !showKeys); } else { SendMessage (hMasterKey, WM_SETTEXT, 0, (LPARAM) MasterKeyGUIView); SendMessage (hHeaderKey, WM_SETTEXT, 0, (LPARAM) HeaderKeyGUIView); } } #endif // #ifdef VOLFORMAT *retInfo = cryptoInfo; err: burn (dk, sizeof(dk)); burn (&keyInfo, sizeof (keyInfo)); #if !defined(_UEFI) VirtualUnlock (&keyInfo, sizeof (keyInfo)); VirtualUnlock (&dk, sizeof (dk)); #endif // !defined(_UEFI) return 0; } #if !defined(_UEFI) -BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead) +BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead) { #if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #endif - byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; + uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; DISK_GEOMETRY geometry; if (!device) return ReadFile (fileHandle, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE, bytesRead, NULL); if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), bytesRead, NULL)) return FALSE; if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } if (!ReadFile (fileHandle, sectorBuffer, max (TC_VOLUME_HEADER_EFFECTIVE_SIZE, geometry.BytesPerSector), bytesRead, NULL)) 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; return TRUE; } -BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) +BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header) { #if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE #endif - byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; + uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE]; DWORD bytesDone; DISK_GEOMETRY geometry; if (!device) { if (!WriteFile (fileHandle, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE, &bytesDone, NULL)) return FALSE; if (bytesDone != TC_VOLUME_HEADER_EFFECTIVE_SIZE) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } return TRUE; } if (!DeviceIoControl (fileHandle, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry), &bytesDone, NULL)) return FALSE; if (geometry.BytesPerSector > sizeof (sectorBuffer) || geometry.BytesPerSector < TC_MIN_VOLUME_SECTOR_SIZE) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } if (geometry.BytesPerSector != TC_VOLUME_HEADER_EFFECTIVE_SIZE) { LARGE_INTEGER seekOffset; @@ -1270,61 +1303,61 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header) } seekOffset.QuadPart = -(int) bytesDone; if (!SetFilePointerEx (fileHandle, seekOffset, NULL, FILE_CURRENT)) return FALSE; } memcpy (sectorBuffer, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (!WriteFile (fileHandle, sectorBuffer, geometry.BytesPerSector, &bytesDone, NULL)) return FALSE; if (bytesDone != geometry.BytesPerSector) { SetLastError (ERROR_INVALID_PARAMETER); return FALSE; } return TRUE; } // Writes randomly generated data to unused/reserved header areas. // When bPrimaryOnly is TRUE, then only the primary header area (not the backup header area) is filled with random data. // When bBackupOnly is TRUE, only the backup header area (not the primary header area) is filled with random data. int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly) { char temporaryKey[MASTER_KEYDATA_SIZE]; char originalK2[MASTER_KEYDATA_SIZE]; - byte buf[TC_VOLUME_HEADER_GROUP_SIZE]; + uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE]; LARGE_INTEGER offset; int nStatus = ERR_SUCCESS; DWORD dwError; DWORD bytesDone; BOOL backupHeaders = bBackupOnly; if (bPrimaryOnly && bBackupOnly) TC_THROW_FATAL_EXCEPTION; memcpy (originalK2, cryptoInfo->k2, sizeof (cryptoInfo->k2)); while (TRUE) { // Temporary keys if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (cryptoInfo->ea), FALSE) || !RandgetBytes (hwndDlg, cryptoInfo->k2, sizeof (cryptoInfo->k2), FALSE)) { nStatus = ERR_PARAMETER_INCORRECT; goto final_seq; } nStatus = EAInit (cryptoInfo->ea, temporaryKey, cryptoInfo->ks); if (nStatus != ERR_SUCCESS) goto final_seq; if (!EAInitMode (cryptoInfo, cryptoInfo->k2)) { nStatus = ERR_MODE_INIT_FAILED; goto final_seq; diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h index 1c9981c2..daad25e3 100644 --- a/src/Common/Volumes.h +++ b/src/Common/Volumes.h @@ -102,60 +102,60 @@ extern "C" { // Volume header field offsets #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 #define TC_HEADER_OFFSET_KEY_AREA_CRC 72 #define TC_HEADER_OFFSET_VOLUME_CREATION_TIME 76 #define TC_HEADER_OFFSET_MODIFICATION_TIME 84 #define TC_HEADER_OFFSET_HIDDEN_VOLUME_SIZE 92 #define TC_HEADER_OFFSET_VOLUME_SIZE 100 #define TC_HEADER_OFFSET_ENCRYPTED_AREA_START 108 #define TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH 116 #define TC_HEADER_OFFSET_FLAGS 124 #define TC_HEADER_OFFSET_SECTOR_SIZE 128 #define TC_HEADER_OFFSET_HEADER_CRC 252 // Volume header flags #define TC_HEADER_FLAG_ENCRYPTED_SYSTEM 0x1 #define TC_HEADER_FLAG_NONSYS_INPLACE_ENC 0x2 // The volume has been created (or is being encrypted/decrypted) using non-system in-place encryption #ifndef TC_HEADER_Volume_VolumeHeader #include "Password.h" extern BOOL ReadVolumeHeaderRecoveryMode; -uint16 GetHeaderField16 (byte *header, int offset); -uint32 GetHeaderField32 (byte *header, int offset); -UINT64_STRUCT GetHeaderField64 (byte *header, int offset); +uint16 GetHeaderField16 (uint8 *header, int offset); +uint32 GetHeaderField32 (uint8 *header, int offset); +UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset); #if defined(TC_WINDOWS_BOOT) int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); #elif defined(_UEFI) int ReadVolumeHeader(BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); int CreateVolumeHeaderInMemory(BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, int pim, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode); BOOL RandgetBytes(unsigned char *buf, int len, BOOL forceSlowPoll); #else int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); #if defined(_WIN32) && !defined(_UEFI) -void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint); +void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint); #endif #endif #if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) && !defined(_UEFI) int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, int pim, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode); -BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead); -BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header); +BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead); +BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header); int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly); #endif #endif // !TC_HEADER_Volume_VolumeHeader #ifdef __cplusplus } #endif #endif // TC_HEADER_Common_Volumes diff --git a/src/Common/Wipe.c b/src/Common/Wipe.c index 2fe6aa03..d68b517b 100644 --- a/src/Common/Wipe.c +++ b/src/Common/Wipe.c @@ -1,119 +1,119 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Tcdefs.h" #include "Wipe.h" -static BOOL Wipe1PseudoRandom (int pass, byte *buffer, size_t size) +static BOOL Wipe1PseudoRandom (int pass, uint8 *buffer, size_t size) { return FALSE; } // Fill buffer with wipe patterns defined in "National Industrial Security Program Operating Manual", US DoD 5220.22-M. // Return: FALSE = buffer must be filled with random data -static BOOL Wipe3Dod5220 (int pass, byte *buffer, size_t size) +static BOOL Wipe3Dod5220 (int pass, uint8 *buffer, size_t size) { - byte wipeChar; + uint8 wipeChar; switch (pass) { case 1: wipeChar = 0; break; case 2: wipeChar = 0xff; break; default: return FALSE; } memset (buffer, wipeChar, size); return TRUE; } -static BOOL Wipe7Dod5220 (int pass, byte randChars[TC_WIPE_RAND_CHAR_COUNT], byte *buffer, size_t size) +static BOOL Wipe7Dod5220 (int pass, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], uint8 *buffer, size_t size) { - byte wipeChar; + uint8 wipeChar; switch (pass) { case 1: wipeChar = randChars[0]; break; case 2: wipeChar = ~randChars[0]; break; case 4: wipeChar = randChars[1]; break; case 5: wipeChar = randChars[2]; break; case 6: wipeChar = ~randChars[2]; break; default: return FALSE; } memset (buffer, wipeChar, size); return TRUE; } // Fill the buffer with wipe patterns defined in the paper "Secure Deletion of Data from Magnetic and Solid-State Memory" by Peter Gutmann. // Return: FALSE = buffer must be filled with random data -static BOOL Wipe35Gutmann (int pass, byte *buffer, size_t size) +static BOOL Wipe35Gutmann (int pass, uint8 *buffer, size_t size) { - byte wipePat3[] = { 0x92, 0x49, 0x24 }; + uint8 wipePat3[] = { 0x92, 0x49, 0x24 }; int wipePat3Pos; size_t i; switch (pass) { case 5: memset (buffer, 0x55, size); break; case 6: memset (buffer, 0xaa, size); break; case 7: case 26: case 29: wipePat3Pos = 0; goto wipe3; case 8: case 27: case 30: wipePat3Pos = 1; goto wipe3; case 9: case 28: case 31: wipePat3Pos = 2; goto wipe3; @@ -140,59 +140,59 @@ wipe3: } return TRUE; } int GetWipePassCount (WipeAlgorithmId algorithm) { switch (algorithm) { case TC_WIPE_1_RAND: return 1; case TC_WIPE_3_DOD_5220: return 3; case TC_WIPE_7_DOD_5220: return 7; case TC_WIPE_35_GUTMANN: return 35; case TC_WIPE_256: return 256; } return -1; // Prevent compiler warnings } -BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size) +BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size) { switch (algorithm) { case TC_WIPE_1_RAND: case TC_WIPE_256: return Wipe1PseudoRandom (pass, buffer, size); case TC_WIPE_3_DOD_5220: return Wipe3Dod5220 (pass, buffer, size); case TC_WIPE_7_DOD_5220: return Wipe7Dod5220 (pass, randChars, buffer, size); case TC_WIPE_35_GUTMANN: return Wipe35Gutmann (pass, buffer, size); /* we will never reach here because all calls to WipeBuffer are preceeded * by a call to GetWipePassCount that already checks the same algorithm * parameters and in case of unsupported value an error is returned before * calling WipeBuffer */ /* default: TC_THROW_FATAL_EXCEPTION;*/ } return FALSE; // Prevent compiler warnings } diff --git a/src/Common/Wipe.h b/src/Common/Wipe.h index ef27eb06..09b9d71e 100644 --- a/src/Common/Wipe.h +++ b/src/Common/Wipe.h @@ -9,37 +9,37 @@ contained in the file License.txt included in VeraCrypt binary and source code distribution packages. */ #ifndef TC_HEADER_Common_Wipe #define TC_HEADER_Common_Wipe #include "Tcdefs.h" #ifdef __cplusplus extern "C" { #endif typedef enum { /* WARNING: As these values are written to config files, if they or their meanings are changed, incompatiblity with other versions may arise (upgrade, downgrade, etc.). When adding a new constant, verify that the value is unique within this block. */ TC_WIPE_NONE = 0, TC_WIPE_1_RAND = 100, TC_WIPE_3_DOD_5220 = 300, TC_WIPE_7_DOD_5220 = 700, TC_WIPE_35_GUTMANN = 3500, TC_WIPE_256 = 25600 } WipeAlgorithmId; #define TC_WIPE_RAND_CHAR_COUNT 3 int GetWipePassCount (WipeAlgorithmId algorithm); -BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size); +BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size); #ifdef __cplusplus } #endif #endif // TC_HEADER_Common_Wipe diff --git a/src/Common/Xts.c b/src/Common/Xts.c index 390eb31e..4a62aaf3 100644 --- a/src/Common/Xts.c +++ b/src/Common/Xts.c @@ -27,64 +27,68 @@ For big-endian platforms define BYTE_ORDER as BIG_ENDIAN. */ # include <memory.h> #endif #ifndef TC_NO_COMPILER_INT64 #include "cpu.h" #include "misc.h" #endif #include "Xts.h" #ifndef TC_NO_COMPILER_INT64 // length: number of bytes to encrypt; may be larger than one data unit and must be divisible by the cipher block size // ks: the primary key schedule // 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. // 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 // is not aligned, startCipherBlockNo must reflect the misalignment accordingly. void EncryptBufferXTS (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher) { - if (CipherSupportsIntraDataUnitParallelization (cipher)) + #ifndef WOLFCRYPT_BACKEND + if (CipherSupportsIntraDataUnitParallelization (cipher)) EncryptBufferXTSParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher); else EncryptBufferXTSNonParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher); + #else + xts_encrypt(buffer, buffer, length, startDataUnitNo, ks); + #endif } #if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64) #define XorBlocks(result,ptr,len,start,end) \ while (len >= 2) \ { \ __m128i xmm1 = _mm_loadu_si128((const __m128i*) ptr); \ __m128i xmm2 = _mm_loadu_si128((__m128i*)result); \ __m128i xmm3 = _mm_loadu_si128((const __m128i*) (ptr + 2)); \ __m128i xmm4 = _mm_loadu_si128((__m128i*)(result + 2)); \ \ _mm_storeu_si128((__m128i*)result, _mm_xor_si128(xmm1, xmm2)); \ _mm_storeu_si128((__m128i*)(result + 2), _mm_xor_si128(xmm3, xmm4)); \ ptr+= 4; \ result+= 4; \ len -= 2; \ } \ \ if (len) \ { \ __m128i xmm1 = _mm_loadu_si128((const __m128i*)ptr); \ __m128i xmm2 = _mm_loadu_si128((__m128i*)result); \ \ _mm_storeu_si128((__m128i*)result, _mm_xor_si128(xmm1, xmm2)); \ ptr+= 2; \ result+= 2; \ } \ len = end - start; @@ -353,64 +357,68 @@ static void EncryptBufferXTSNonParallel (unsigned __int8 *buffer, whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) *(whiteningValuePtr64 + 1) |= 0x0100000000000000; *whiteningValuePtr64 = LE64 (LE64 (*whiteningValuePtr64) << 1); #endif whiteningValue[0] ^= finalCarry; } blockCount -= endBlock - startBlock; startBlock = 0; dataUnitNo++; *((unsigned __int64 *) byteBufUnitNo) = LE64 (dataUnitNo); } FAST_ERASE64 (whiteningValue, sizeof (whiteningValue)); } // For descriptions of the input parameters, see EncryptBufferXTS(). void DecryptBufferXTS (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher) { + #ifndef WOLFCRYPT_BACKEND if (CipherSupportsIntraDataUnitParallelization (cipher)) DecryptBufferXTSParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher); else DecryptBufferXTSNonParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher); + #else + xts_decrypt(buffer, buffer, length, startDataUnitNo, ks); + #endif } // Optimized for encryption algorithms supporting intra-data-unit parallelization static void DecryptBufferXTSParallel (unsigned __int8 *buffer, TC_LARGEST_COMPILER_UINT length, const UINT64_STRUCT *startDataUnitNo, unsigned int startCipherBlockNo, unsigned __int8 *ks, unsigned __int8 *ks2, int cipher) { unsigned __int8 finalCarry; unsigned __int8 whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; unsigned __int8 whiteningValue [BYTES_PER_XTS_BLOCK]; unsigned __int8 byteBufUnitNo [BYTES_PER_XTS_BLOCK]; unsigned __int64 *whiteningValuesPtr64 = (unsigned __int64 *) whiteningValues; unsigned __int64 *whiteningValuePtr64 = (unsigned __int64 *) whiteningValue; unsigned __int64 *bufPtr = (unsigned __int64 *) buffer; unsigned __int64 *dataUnitBufPtr; unsigned int startBlock = startCipherBlockNo, endBlock, block, countBlock; TC_LARGEST_COMPILER_UINT remainingBlocks, dataUnitNo; // 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); *((unsigned __int64 *) byteBufUnitNo + 1) = 0; if (length % BYTES_PER_XTS_BLOCK) diff --git a/src/Common/Zip_vs2019.vcxproj b/src/Common/Zip_vs2019.vcxproj index 26ab3310..b68dcab8 100644 --- a/src/Common/Zip_vs2019.vcxproj +++ b/src/Common/Zip_vs2019.vcxproj @@ -225,76 +225,82 @@ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> <Lib> <AdditionalDependencies> </AdditionalDependencies> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> </ClCompile> @@ -310,92 +316,95 @@ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level3</WarningLevel> <Optimization>Disabled</Optimization> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> <Lib> <AdditionalDependencies> </AdditionalDependencies> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> <Lib> <AdditionalDependencies> </AdditionalDependencies> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> <Lib> <AdditionalDependencies> </AdditionalDependencies> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> <WarningLevel>Level3</WarningLevel> <PrecompiledHeader> </PrecompiledHeader> <Optimization>MaxSpeed</Optimization> <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>_CRT_NONSTDC_NO_WARNINGS;_LIB;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <AdditionalIncludeDirectories>zlib;libzip</AdditionalIncludeDirectories> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> <Lib> <AdditionalDependencies> </AdditionalDependencies> </Lib> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> </Project>
\ No newline at end of file diff --git a/src/Common/libzip/NEWS.md b/src/Common/libzip/NEWS.md index a8ba5bcf..e117422d 100644 --- a/src/Common/libzip/NEWS.md +++ b/src/Common/libzip/NEWS.md @@ -1,30 +1,35 @@ +# 1.10.1 [2023-08-23] + +* Add `ZIP_LENGTH_TO_END` and `ZIP_LENGTH_UNCHECKED`. Unless `ZIP_LENGTH_UNCHECKED` is used as `length`, it is an error for a file to shrink between the time when the source is created and when its data is read. +* Fix test on Windows. + # 1.10.0 [2023-06-23] * Make support for layered sources public. * Add `zip_source_zip_file` and `zip_source_zip_file_create`, deprecate `zip_source_zip` and `zip_source_zip_create`. * Allow reading changed file data. * Fix handling of files of size 4294967295. * `zipmerge`: copy extra fields. * `zipmerge`: add option to keep files uncompressed. * Switch test framework to use nihtest instead of Perl. * Fix reading/writing compressed data with buffers > 4GiB. * Restore support for torrentzip. * Add warnings when using deprecated functions. * Allow keeping files for empty archives. * Support mbedTLS>=3.3.0. * Support OpenSSL 3. * Use ISO C secure library functions, if available. # 1.9.2 [2022-06-28] * Fix version number in header file. # 1.9.1 [2022-06-28] * Fix `zip_file_is_seekable()`. # 1.9.0 [2022-06-13] diff --git a/src/Common/libzip/config.h b/src/Common/libzip/config.h index 755c29ad..2976249c 100644 --- a/src/Common/libzip/config.h +++ b/src/Common/libzip/config.h @@ -61,33 +61,33 @@ /* #undef HAVE_STRTOLL */ /* #undef HAVE_STRTOULL */ #else #define HAVE_STRTOLL #define HAVE_STRTOULL #endif /* #undef HAVE_STRUCT_TM_TM_ZONE */ #if defined(_MSC_VER) && _MSC_VER < 1800 /* #undef HAVE_STDBOOL_H */ #else #define HAVE_STDBOOL_H #endif /* #undef HAVE_STRINGS_H */ /* #undef HAVE_UNISTD_H */ #define HAVE_WINDOWS_CRYPTO #define SIZEOF_OFF_T 4 #ifdef _WIN64 #define SIZEOF_SIZE_T 8 #else #define SIZEOF_SIZE_T 4 #endif /* #undef HAVE_DIRENT_H */ /* #undef HAVE_FTS_H */ /* #undef HAVE_NDIR_H */ /* #undef HAVE_SYS_DIR_H */ /* #undef HAVE_SYS_NDIR_H */ /* #undef WORDS_BIGENDIAN */ #define HAVE_SHARED /* END DEFINES */ #define PACKAGE "libzip" -#define VERSION "1.10.0" +#define VERSION "1.10.1" #endif /* HAD_CONFIG_H */ diff --git a/src/Common/libzip/zip.h b/src/Common/libzip/zip.h index bfe746fe..dc3751c8 100644 --- a/src/Common/libzip/zip.h +++ b/src/Common/libzip/zip.h @@ -89,60 +89,64 @@ extern "C" { #define ZIP_FL_NOCASE 1u /* ignore case on name lookup */ #define ZIP_FL_NODIR 2u /* ignore directory component */ #define ZIP_FL_COMPRESSED 4u /* read compressed data */ #define ZIP_FL_UNCHANGED 8u /* use original data, ignoring changes */ /* 16u was ZIP_FL_RECOMPRESS, which is deprecated */ #define ZIP_FL_ENCRYPTED 32u /* read encrypted data (implies ZIP_FL_COMPRESSED) */ #define ZIP_FL_ENC_GUESS 0u /* guess string encoding (is default) */ #define ZIP_FL_ENC_RAW 64u /* get unmodified string */ #define ZIP_FL_ENC_STRICT 128u /* follow specification strictly */ #define ZIP_FL_LOCAL 256u /* in local header */ #define ZIP_FL_CENTRAL 512u /* in central directory */ /* 1024u reserved for internal use */ #define ZIP_FL_ENC_UTF_8 2048u /* string is UTF-8 encoded */ #define ZIP_FL_ENC_CP437 4096u /* string is CP437 encoded */ #define ZIP_FL_OVERWRITE 8192u /* zip_file_add: if file with name exists, overwrite (replace) it */ /* archive global flags flags */ #define ZIP_AFL_RDONLY 2u /* read only -- cannot be cleared */ #define ZIP_AFL_IS_TORRENTZIP 4u /* current archive is torrentzipped */ #define ZIP_AFL_WANT_TORRENTZIP 8u /* write archive in torrentzip format */ #define ZIP_AFL_CREATE_OR_KEEP_FILE_FOR_EMPTY_ARCHIVE 16u /* don't remove file if archive is empty */ /* create a new extra field */ #define ZIP_EXTRA_FIELD_ALL ZIP_UINT16_MAX #define ZIP_EXTRA_FIELD_NEW ZIP_UINT16_MAX +/* length parameter to various functions */ + +#define ZIP_LENGTH_TO_END 0 +#define ZIP_LENGTH_UNCHECKED (-2) /* only supported by zip_source_file and its variants */ /* libzip error codes */ #define ZIP_ER_OK 0 /* N No error */ #define ZIP_ER_MULTIDISK 1 /* N Multi-disk zip archives not supported */ #define ZIP_ER_RENAME 2 /* S Renaming temporary file failed */ #define ZIP_ER_CLOSE 3 /* S Closing zip archive failed */ #define ZIP_ER_SEEK 4 /* S Seek error */ #define ZIP_ER_READ 5 /* S Read error */ #define ZIP_ER_WRITE 6 /* S Write error */ #define ZIP_ER_CRC 7 /* N CRC error */ #define ZIP_ER_ZIPCLOSED 8 /* N Containing zip archive was closed */ #define ZIP_ER_NOENT 9 /* N No such file */ #define ZIP_ER_EXISTS 10 /* N File already exists */ #define ZIP_ER_OPEN 11 /* S Can't open file */ #define ZIP_ER_TMPOPEN 12 /* S Failure to create temporary file */ #define ZIP_ER_ZLIB 13 /* Z Zlib error */ #define ZIP_ER_MEMORY 14 /* N Malloc failure */ #define ZIP_ER_CHANGED 15 /* N Entry has been changed */ #define ZIP_ER_COMPNOTSUPP 16 /* N Compression method not supported */ #define ZIP_ER_EOF 17 /* N Premature end of file */ #define ZIP_ER_INVAL 18 /* N Invalid argument */ #define ZIP_ER_NOZIP 19 /* N Not a zip archive */ #define ZIP_ER_INTERNAL 20 /* N Internal error */ #define ZIP_ER_INCONS 21 /* L Zip archive inconsistent */ #define ZIP_ER_REMOVE 22 /* S Can't remove file */ #define ZIP_ER_DELETED 23 /* N Entry has been deleted */ #define ZIP_ER_ENCRNOTSUPP 24 /* N Encryption method not supported */ #define ZIP_ER_RDONLY 25 /* N Read-only archive */ #define ZIP_ER_NOPASSWD 26 /* N No password provided */ diff --git a/src/Common/libzip/zip_close.c b/src/Common/libzip/zip_close.c index 6b33cbf5..ddc2c245 100644 --- a/src/Common/libzip/zip_close.c +++ b/src/Common/libzip/zip_close.c @@ -369,60 +369,65 @@ add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) { else { de->comp_size = st.comp_size; data_length = (zip_int64_t)st.comp_size; } } if ((offstart = zip_source_tell_write(za->src)) < 0) { zip_error_set_from_source(&za->error, za->src); return -1; } /* as long as we don't support non-seekable output, clear data descriptor bit */ de->bitflags &= (zip_uint16_t)~ZIP_GPBF_DATA_DESCRIPTOR; if ((is_zip64 = _zip_dirent_write(za, de, flags)) < 0) { return -1; } needs_recompress = ZIP_WANT_TORRENTZIP(za) || st.comp_method != ZIP_CM_ACTUAL(de->comp_method); needs_decompress = needs_recompress && (st.comp_method != ZIP_CM_STORE); /* in these cases we can compute the CRC ourselves, so we do */ needs_crc = (st.comp_method == ZIP_CM_STORE) || needs_decompress; needs_compress = needs_recompress && (de->comp_method != ZIP_CM_STORE); needs_reencrypt = needs_recompress || (de->changed & ZIP_DIRENT_PASSWORD) || (de->encryption_method != st.encryption_method); needs_decrypt = needs_reencrypt && (st.encryption_method != ZIP_EM_NONE); needs_encrypt = needs_reencrypt && (de->encryption_method != ZIP_EM_NONE); src_final = src; zip_source_keep(src_final); + if (!needs_decrypt && st.encryption_method == ZIP_EM_TRAD_PKWARE && (de->changed & ZIP_DIRENT_LAST_MOD)) { + /* PKWare encryption uses the last modification time for password verification, therefore we can't change it without re-encrypting. Ignoring the requested modification time change seems more sensible than failing to close the archive. */ + de->changed &= ~ZIP_DIRENT_LAST_MOD; + } + if (needs_decrypt) { zip_encryption_implementation impl; if ((impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) { zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); zip_source_free(src_final); return -1; } if ((src_tmp = impl(za, src_final, st.encryption_method, ZIP_CODEC_DECODE, za->default_password)) == NULL) { /* error set by impl */ zip_source_free(src_final); return -1; } src_final = src_tmp; } if (needs_decompress) { if ((src_tmp = zip_source_decompress(za, src_final, st.comp_method)) == NULL) { zip_source_free(src_final); return -1; } src_final = src_tmp; } if (needs_crc) { if ((src_tmp = zip_source_crc_create(src_final, 0, &za->error)) == NULL) { zip_source_free(src_final); return -1; diff --git a/src/Common/libzip/zip_random_unix.c b/src/Common/libzip/zip_random_unix.c index f84a5482..867df790 100644 --- a/src/Common/libzip/zip_random_unix.c +++ b/src/Common/libzip/zip_random_unix.c @@ -56,49 +56,55 @@ zip_random_uint32(void) { } #endif #else /* HAVE_ARC4RANDOM */ #ifndef HAVE_SECURE_RANDOM #include <fcntl.h> #include <unistd.h> ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { int fd; if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { return false; } if (read(fd, buffer, length) != length) { close(fd); return false; } close(fd); return true; } #endif #ifndef HAVE_RANDOM_UINT32 #include <stdlib.h> +#ifndef HAVE_RANDOM +#define srandom srand +#define random rand +#endif + zip_uint32_t zip_random_uint32(void) { static bool seeded = false; zip_uint32_t value; if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { return value; } if (!seeded) { srandom((unsigned int)time(NULL)); + seeded = true; } return (zip_uint32_t)random(); } #endif #endif /* HAVE_ARC4RANDOM */ diff --git a/src/Common/libzip/zip_random_uwp.c b/src/Common/libzip/zip_random_uwp.c index 9f842b99..0883ce45 100644 --- a/src/Common/libzip/zip_random_uwp.c +++ b/src/Common/libzip/zip_random_uwp.c @@ -47,35 +47,36 @@ zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { BCRYPT_ALG_HANDLE hAlg = NULL; NTSTATUS hr = BCryptOpenAlgorithmProvider(&hAlg, BCRYPT_RNG_ALGORITHM, MS_PRIMITIVE_PROVIDER, 0); if (!BCRYPT_SUCCESS(hr) || hAlg == NULL) { return false; } hr = BCryptGenRandom(&hAlg, buffer, length, 0); BCryptCloseAlgorithmProvider(&hAlg, 0); if (!BCRYPT_SUCCESS(hr)) { return false; } return true; } #endif #ifndef HAVE_RANDOM_UINT32 #include <stdlib.h> zip_uint32_t zip_random_uint32(void) { static bool seeded = false; zip_uint32_t value; if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { return value; } if (!seeded) { srand((unsigned int)time(NULL)); + seeded = true; } return (zip_uint32_t)rand(); } #endif diff --git a/src/Common/libzip/zip_random_win32.c b/src/Common/libzip/zip_random_win32.c index 966b9a5e..789b9c20 100644 --- a/src/Common/libzip/zip_random_win32.c +++ b/src/Common/libzip/zip_random_win32.c @@ -47,35 +47,36 @@ ZIP_EXTERN bool zip_secure_random(zip_uint8_t *buffer, zip_uint16_t length) { HCRYPTPROV hprov; if (!CryptAcquireContext(&hprov, NULL, NULL, PROV_RSA_AES, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) { return false; } if (!CryptGenRandom(hprov, length, buffer)) { return false; } if (!CryptReleaseContext(hprov, 0)) { return false; } return true; } #endif #ifndef HAVE_RANDOM_UINT32 #include <stdlib.h> zip_uint32_t zip_random_uint32(void) { static bool seeded = false; zip_uint32_t value; if (zip_secure_random((zip_uint8_t *)&value, sizeof(value))) { return value; } if (!seeded) { srand((unsigned int)time(NULL)); + seeded = true; } return (zip_uint32_t)rand(); } #endif diff --git a/src/Common/libzip/zip_set_archive_flag.c b/src/Common/libzip/zip_set_archive_flag.c index ec6a86d0..834ef5ba 100644 --- a/src/Common/libzip/zip_set_archive_flag.c +++ b/src/Common/libzip/zip_set_archive_flag.c @@ -30,46 +30,47 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "zipint.h" ZIP_EXTERN int zip_set_archive_flag(zip_t *za, zip_flags_t flag, int value) { unsigned int new_flags; if (flag == ZIP_AFL_IS_TORRENTZIP) { zip_error_set(&za->error, ZIP_ER_INVAL, 0); return -1; } /* TODO: when setting ZIP_AFL_WANT_TORRENTZIP, we should error out if any changes have been made that are not allowed for torrentzip. */ if (value) { new_flags = za->ch_flags | flag; } else { new_flags = za->ch_flags & ~flag; } if (new_flags == za->ch_flags) { return 0; } - if (ZIP_IS_RDONLY(za)) { + /* Allow removing ZIP_AFL_RDONLY if manually set, not if archive was opened read-only. */ + if (za->flags & ZIP_AFL_RDONLY) { zip_error_set(&za->error, ZIP_ER_RDONLY, 0); return -1; } if ((flag & ZIP_AFL_RDONLY) && value && (za->ch_flags & ZIP_AFL_RDONLY) == 0) { if (_zip_changed(za, NULL)) { zip_error_set(&za->error, ZIP_ER_CHANGED, 0); return -1; } } za->ch_flags = new_flags; return 0; } diff --git a/src/Common/libzip/zip_source_file_common.c b/src/Common/libzip/zip_source_file_common.c index a2a46a44..6c58320f 100644 --- a/src/Common/libzip/zip_source_file_common.c +++ b/src/Common/libzip/zip_source_file_common.c @@ -27,114 +27,122 @@ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include "zipint.h" #include "zip_source_file.h" static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd); static void zip_source_file_stat_init(zip_source_file_stat_t *st) { st->size = 0; st->mtime = time(NULL); st->exists = false; st->regular_file = false; } zip_source_t * zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error) { zip_source_file_context_t *ctx; zip_source_t *zs; zip_source_file_stat_t sb; + zip_uint64_t length; if (ops == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if (ops->close == NULL || ops->read == NULL || ops->seek == NULL || ops->stat == NULL) { zip_error_set(error, ZIP_ER_INTERNAL, 0); return NULL; } if (ops->write != NULL && (ops->commit_write == NULL || ops->create_temp_output == NULL || ops->remove == NULL || ops->rollback_write == NULL || ops->tell == NULL)) { zip_error_set(error, ZIP_ER_INTERNAL, 0); return NULL; } if (fname != NULL) { if (ops->open == NULL || ops->string_duplicate == NULL) { zip_error_set(error, ZIP_ER_INTERNAL, 0); return NULL; } } else if (file == NULL) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if (len < 0) { - len = 0; + if (len == -1) { + len = ZIP_LENGTH_TO_END; + } + // TODO: return ZIP_ER_INVAL if len != ZIP_LENGTH_UNCHECKED? + length = 0; + } + else { + length = (zip_uint64_t)len; } - if (start > ZIP_INT64_MAX || start + (zip_uint64_t)len < start) { + if (start > ZIP_INT64_MAX || start + length < start) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if ((ctx = (zip_source_file_context_t *)malloc(sizeof(zip_source_file_context_t))) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } ctx->ops = ops; ctx->ops_userdata = ops_userdata; ctx->fname = NULL; if (fname) { if ((ctx->fname = ops->string_duplicate(ctx, fname)) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); free(ctx); return NULL; } } ctx->f = file; ctx->start = start; - ctx->len = (zip_uint64_t)len; + ctx->len = length; if (st) { (void)memcpy_s(&ctx->st, sizeof(ctx->st), st, sizeof(*st)); ctx->st.name = NULL; ctx->st.valid &= ~ZIP_STAT_NAME; } else { zip_stat_init(&ctx->st); } if (ctx->len > 0) { ctx->st.size = ctx->len; ctx->st.valid |= ZIP_STAT_SIZE; } zip_error_init(&ctx->stat_error); ctx->tmpname = NULL; ctx->fout = NULL; zip_error_init(&ctx->error); zip_file_attributes_init(&ctx->attributes); ctx->supports = ZIP_SOURCE_SUPPORTS_READABLE | zip_source_make_command_bitmap(ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, ZIP_SOURCE_SUPPORTS_REOPEN, -1); zip_source_file_stat_init(&sb); if (!ops->stat(ctx, &sb)) { _zip_error_copy(error, &ctx->error); free(ctx->fname); free(ctx); return NULL; @@ -142,63 +150,65 @@ zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zi if (!sb.exists) { if (ctx->fname && ctx->start == 0 && ctx->len == 0 && ops->write != NULL) { ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; /* zip_open_from_source checks for this to detect non-existing files */ zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); } else { zip_error_set(&ctx->stat_error, ZIP_ER_READ, ENOENT); free(ctx->fname); free(ctx); return NULL; } } else { if ((ctx->st.valid & ZIP_STAT_MTIME) == 0) { ctx->st.mtime = sb.mtime; ctx->st.valid |= ZIP_STAT_MTIME; } if (sb.regular_file) { ctx->supports = ZIP_SOURCE_SUPPORTS_SEEKABLE; if (ctx->start + ctx->len > sb.size) { zip_error_set(error, ZIP_ER_INVAL, 0); free(ctx->fname); free(ctx); return NULL; } if (ctx->len == 0) { - ctx->len = sb.size - ctx->start; - ctx->st.size = ctx->len; - ctx->st.valid |= ZIP_STAT_SIZE; + if (len != ZIP_LENGTH_UNCHECKED) { + ctx->len = sb.size - ctx->start; + ctx->st.size = ctx->len; + ctx->st.valid |= ZIP_STAT_SIZE; + } /* when using a partial file, don't allow writing */ if (ctx->fname && start == 0 && ops->write != NULL) { ctx->supports = ZIP_SOURCE_SUPPORTS_WRITABLE; } } } ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_FILE_ATTRIBUTES); } ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_ACCEPT_EMPTY); if (ops->create_temp_output_cloning != NULL) { if (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE)) { ctx->supports |= ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_BEGIN_WRITE_CLONING); } } if ((zs = zip_source_function_create(read_file, ctx, error)) == NULL) { free(ctx->fname); free(ctx); return NULL; } return zs; } static zip_int64_t read_file(void *state, void *data, zip_uint64_t len, zip_source_cmd_t cmd) { diff --git a/src/Common/libzip/zip_source_file_stdio.c b/src/Common/libzip/zip_source_file_stdio.c index 7ed91674..6dcc5639 100644 --- a/src/Common/libzip/zip_source_file_stdio.c +++ b/src/Common/libzip/zip_source_file_stdio.c @@ -51,61 +51,61 @@ static zip_source_file_operations_t ops_stdio_read = { _zip_stdio_op_close, NULL, NULL, NULL, NULL, _zip_stdio_op_read, NULL, NULL, _zip_stdio_op_seek, _zip_stdio_op_stat, NULL, _zip_stdio_op_tell, NULL }; /* clang-format on */ ZIP_EXTERN zip_source_t * zip_source_filep(zip_t *za, FILE *file, zip_uint64_t start, zip_int64_t len) { if (za == NULL) { return NULL; } return zip_source_filep_create(file, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_filep_create(FILE *file, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (file == NULL || length < -1) { + if (file == NULL || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } return zip_source_file_common_new(NULL, file, start, length, NULL, &ops_stdio_read, NULL, error); } void _zip_stdio_op_close(zip_source_file_context_t *ctx) { fclose((FILE *)ctx->f); } zip_int64_t _zip_stdio_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { size_t i; if (len > SIZE_MAX) { len = SIZE_MAX; } if ((i = fread(buf, 1, (size_t)len, ctx->f)) == 0) { if (ferror((FILE *)ctx->f)) { zip_error_set(&ctx->error, ZIP_ER_READ, errno); return -1; } } return (zip_int64_t)i; } diff --git a/src/Common/libzip/zip_source_file_stdio_named.c b/src/Common/libzip/zip_source_file_stdio_named.c index 51e06a91..1495d7dd 100644 --- a/src/Common/libzip/zip_source_file_stdio_named.c +++ b/src/Common/libzip/zip_source_file_stdio_named.c @@ -74,61 +74,61 @@ static zip_source_file_operations_t ops_stdio_named = { _zip_stdio_op_commit_write, _zip_stdio_op_create_temp_output, #ifdef CAN_CLONE _zip_stdio_op_create_temp_output_cloning, #else NULL, #endif _zip_stdio_op_open, _zip_stdio_op_read, _zip_stdio_op_remove, _zip_stdio_op_rollback_write, _zip_stdio_op_seek, _zip_stdio_op_stat, _zip_stdio_op_strdup, _zip_stdio_op_tell, _zip_stdio_op_write }; /* clang-format on */ ZIP_EXTERN zip_source_t * zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { if (za == NULL) return NULL; return zip_source_file_create(fname, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (fname == NULL || length < -1) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } return zip_source_file_common_new(fname, NULL, start, length, NULL, &ops_stdio_named, NULL, error); } static zip_int64_t _zip_stdio_op_commit_write(zip_source_file_context_t *ctx) { if (fclose(ctx->fout) < 0) { zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); return -1; } if (rename(ctx->tmpname, ctx->fname) < 0) { zip_error_set(&ctx->error, ZIP_ER_RENAME, errno); return -1; } return 0; } static zip_int64_t _zip_stdio_op_create_temp_output(zip_source_file_context_t *ctx) { int fd = create_temp_file(ctx, true); if (fd < 0) { return -1; } @@ -264,61 +264,61 @@ _zip_stdio_op_rollback_write(zip_source_file_context_t *ctx) { fclose(ctx->fout); } (void)remove(ctx->tmpname); } static char * _zip_stdio_op_strdup(zip_source_file_context_t *ctx, const char *string) { return strdup(string); } static zip_int64_t _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len) { size_t ret; clearerr((FILE *)ctx->fout); ret = fwrite(data, 1, len, (FILE *)ctx->fout); if (ret != len || ferror((FILE *)ctx->fout)) { zip_error_set(&ctx->error, ZIP_ER_WRITE, errno); return -1; } return (zip_int64_t)ret; } static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) { char *temp; int mode; struct stat st; - int fd; + int fd = 0; char *start, *end; if (stat(ctx->fname, &st) == 0) { mode = st.st_mode; } else { mode = -1; } size_t temp_size = strlen(ctx->fname) + 13; if ((temp = (char *)malloc(temp_size)) == NULL) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } snprintf_s(temp, temp_size, "%s.XXXXXX.part", ctx->fname); end = temp + strlen(temp) - 5; start = end - 6; for (;;) { zip_uint32_t value = zip_random_uint32(); char *xs = start; while (xs < end) { char digit = value % 36; if (digit < 10) { *(xs++) = digit + '0'; } else { *(xs++) = digit - 10 + 'a'; } @@ -332,61 +332,61 @@ static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) { #ifdef HAVE_FCHMOD (void)fchmod(fd, (mode_t)mode); #else (void)chmod(temp, (mode_t)mode); #endif } break; } if (errno != EEXIST) { zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); free(temp); return -1; } } else { if (stat(temp, &st) < 0) { if (errno == ENOENT) { break; } else { zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno); free(temp); return -1; } } } } ctx->tmpname = temp; - return create_file ? fd : 0; + return fd; /* initialized to 0 if !create_file */ } /* * fopen replacement that sets the close-on-exec flag * some implementations support an fopen 'e' flag for that, * but e.g. macOS doesn't. */ static FILE *_zip_fopen_close_on_exec(const char *name, bool writeable) { int fd; int flags; FILE *fp; flags = O_CLOEXEC; if (writeable) { flags |= O_RDWR; } else { flags |= O_RDONLY; } /* mode argument needed on Windows */ if ((fd = open(name, flags, 0666)) < 0) { return NULL; } if ((fp = fdopen(fd, writeable ? "r+b" : "rb")) == NULL) { return NULL; } return fp; } diff --git a/src/Common/libzip/zip_source_file_win32.c b/src/Common/libzip/zip_source_file_win32.c index 4708dc85..624860b1 100644 --- a/src/Common/libzip/zip_source_file_win32.c +++ b/src/Common/libzip/zip_source_file_win32.c @@ -42,61 +42,61 @@ static bool _zip_stat_win32(zip_source_file_context_t *ctx, zip_source_file_stat static zip_source_file_operations_t ops_win32_read = { _zip_win32_op_close, NULL, NULL, NULL, NULL, _zip_win32_op_read, NULL, NULL, _zip_win32_op_seek, _zip_win32_op_stat, NULL, _zip_win32_op_tell, NULL }; /* clang-format on */ ZIP_EXTERN zip_source_t * zip_source_win32handle(zip_t *za, HANDLE h, zip_uint64_t start, zip_int64_t len) { if (za == NULL) { return NULL; } return zip_source_win32handle_create(h, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_win32handle_create(HANDLE h, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (h == INVALID_HANDLE_VALUE || length < -1) { + if (h == INVALID_HANDLE_VALUE || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } return zip_source_file_common_new(NULL, h, start, length, NULL, &ops_win32_read, NULL, error); } void _zip_win32_op_close(zip_source_file_context_t *ctx) { CloseHandle((HANDLE)ctx->f); } zip_int64_t _zip_win32_op_read(zip_source_file_context_t *ctx, void *buf, zip_uint64_t len) { DWORD i; /* TODO: cap len to "DWORD_MAX" */ if (!ReadFile((HANDLE)ctx->f, buf, (DWORD)len, &i, NULL)) { zip_error_set(&ctx->error, ZIP_ER_READ, _zip_win32_error_to_errno(GetLastError())); return -1; } return (zip_int64_t)i; } bool _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset, int whence) { diff --git a/src/Common/libzip/zip_source_file_win32_ansi.c b/src/Common/libzip/zip_source_file_win32_ansi.c index 31ea48a4..58034cc2 100644 --- a/src/Common/libzip/zip_source_file_win32_ansi.c +++ b/src/Common/libzip/zip_source_file_win32_ansi.c @@ -38,50 +38,50 @@ static void ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint /* clang-format off */ DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN zip_win32_file_operations_t ops_ansi = { ansi_allocate_tempname, CreateFileA, DeleteFileA, GetFileAttributesA, GetFileAttributesExA, ansi_make_tempname, MoveFileExA, SetFileAttributesA, strdup }; DONT_WARN_INCOMPATIBLE_FN_PTR_END /* clang-format on */ ZIP_EXTERN zip_source_t * zip_source_win32a(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { if (za == NULL) return NULL; return zip_source_win32a_create(fname, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_win32a_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (fname == NULL || length < -1) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } return zip_source_file_common_new(fname, NULL, start, length, NULL, &_zip_source_file_win32_named_ops, &ops_ansi, error); } static char * ansi_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) { *lengthp = strlen(name) + extra_chars; return (char *)malloc(*lengthp); } static void ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) { snprintf_s(buf, len, "%s.%08x", name, i); } diff --git a/src/Common/libzip/zip_source_file_win32_utf16.c b/src/Common/libzip/zip_source_file_win32_utf16.c index b2f23419..8f07d021 100644 --- a/src/Common/libzip/zip_source_file_win32_utf16.c +++ b/src/Common/libzip/zip_source_file_win32_utf16.c @@ -40,61 +40,61 @@ static char *utf16_strdup(const char *string); /* clang-format off */ DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN zip_win32_file_operations_t ops_utf16 = { utf16_allocate_tempname, utf16_create_file, DeleteFileW, GetFileAttributesW, GetFileAttributesExW, utf16_make_tempname, MoveFileExW, SetFileAttributesW, utf16_strdup }; DONT_WARN_INCOMPATIBLE_FN_PTR_END /* clang-format on */ ZIP_EXTERN zip_source_t * zip_source_win32w(zip_t *za, const wchar_t *fname, zip_uint64_t start, zip_int64_t len) { if (za == NULL) return NULL; return zip_source_win32w_create(fname, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_win32w_create(const wchar_t *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { - if (fname == NULL || length < -1) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } return zip_source_file_common_new((const char *)fname, NULL, start, length, NULL, &_zip_source_file_win32_named_ops, &ops_utf16, error); } static char * utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) { *lengthp = wcslen((const wchar_t *)name) + extra_chars; return (char *)malloc(*lengthp * sizeof(wchar_t)); } static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) { #ifdef MS_UWP CREATEFILE2_EXTENDED_PARAMETERS extParams = {0}; extParams.dwFileAttributes = file_attributes; extParams.dwFileFlags = FILE_FLAG_RANDOM_ACCESS; extParams.dwSecurityQosFlags = SECURITY_ANONYMOUS; extParams.dwSize = sizeof(extParams); extParams.hTemplateFile = template_file; extParams.lpSecurityAttributes = security_attributes; return CreateFile2((const wchar_t *)name, access, share_mode, creation_disposition, &extParams); #else return CreateFileW((const wchar_t *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file); #endif diff --git a/src/Common/libzip/zip_source_file_win32_utf8.c b/src/Common/libzip/zip_source_file_win32_utf8.c index 687c30f9..d154f97a 100644 --- a/src/Common/libzip/zip_source_file_win32_utf8.c +++ b/src/Common/libzip/zip_source_file_win32_utf8.c @@ -22,52 +22,52 @@ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "zip_source_file_win32.h" ZIP_EXTERN zip_source_t * zip_source_file(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) { if (za == NULL) { return NULL; } return zip_source_file_create(fname, start, len, &za->error); } ZIP_EXTERN zip_source_t * zip_source_file_create(const char *fname, zip_uint64_t start, zip_int64_t length, zip_error_t *error) { int size; wchar_t *wfname; zip_source_t *source; - if (fname == NULL || length < -1) { + if (fname == NULL || length < ZIP_LENGTH_UNCHECKED) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } /* Convert fname from UTF-8 to Windows-friendly UTF-16. */ size = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, NULL, 0); if (size == 0) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if ((wfname = (wchar_t *)malloc(sizeof(wchar_t) * size)) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, fname, -1, wfname, size); source = zip_source_win32w_create(wfname, start, length, error); free(wfname); return source; } diff --git a/src/Common/libzip/zip_source_pkware_encode.c b/src/Common/libzip/zip_source_pkware_encode.c index cf2d34c9..d89b9f4e 100644 --- a/src/Common/libzip/zip_source_pkware_encode.c +++ b/src/Common/libzip/zip_source_pkware_encode.c @@ -15,109 +15,114 @@ the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include <string.h> #include "zipint.h" struct trad_pkware { char *password; zip_pkware_keys_t keys; zip_buffer_t *buffer; bool eof; + bool mtime_set; + time_t mtime; zip_error_t error; }; static int encrypt_header(zip_source_t *, struct trad_pkware *); static zip_int64_t pkware_encrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t); static void trad_pkware_free(struct trad_pkware *); static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error); - +static void set_mtime(struct trad_pkware* ctx, zip_stat_t* st); zip_source_t * zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) { struct trad_pkware *ctx; zip_source_t *s2; if (password == NULL || src == NULL || em != ZIP_EM_TRAD_PKWARE) { zip_error_set(&za->error, ZIP_ER_INVAL, 0); return NULL; } if (!(flags & ZIP_CODEC_ENCODE)) { zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0); return NULL; } if ((ctx = trad_pkware_new(password, &za->error)) == NULL) { return NULL; } if ((s2 = zip_source_layered(za, src, pkware_encrypt, ctx)) == NULL) { trad_pkware_free(ctx); return NULL; } return s2; } static int encrypt_header(zip_source_t *src, struct trad_pkware *ctx) { - struct zip_stat st; unsigned short dostime, dosdate; zip_uint8_t *header; - if (zip_source_stat(src, &st) != 0) { - zip_error_set_from_source(&ctx->error, src); - return -1; + if (!ctx->mtime_set) { + struct zip_stat st; + if (zip_source_stat(src, &st) != 0) { + zip_error_set_from_source(&ctx->error, src); + return -1; + } + set_mtime(ctx, &st); } - _zip_u2d_time(st.mtime, &dostime, &dosdate); + _zip_u2d_time(ctx->mtime, &dostime, &dosdate); if ((ctx->buffer = _zip_buffer_new(NULL, ZIP_CRYPTO_PKWARE_HEADERLEN)) == NULL) { zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0); return -1; } header = _zip_buffer_data(ctx->buffer); /* generate header from random bytes and mtime see appnote.iz, XIII. Decryption, Step 2, last paragraph */ if (!zip_secure_random(header, ZIP_CRYPTO_PKWARE_HEADERLEN - 1)) { zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0); _zip_buffer_free(ctx->buffer); ctx->buffer = NULL; return -1; } header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] = (zip_uint8_t)((dostime >> 8) & 0xff); _zip_pkware_encrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN); return 0; } static zip_int64_t pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip_source_cmd_t cmd) { struct trad_pkware *ctx; zip_int64_t n; zip_uint64_t buffer_n; @@ -155,94 +160,112 @@ pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip return (zip_int64_t)buffer_n; } if ((n = zip_source_read(src, data, length)) < 0) { zip_error_set_from_source(&ctx->error, src); return -1; } _zip_pkware_encrypt(&ctx->keys, (zip_uint8_t *)data, (zip_uint8_t *)data, (zip_uint64_t)n); if ((zip_uint64_t)n < length) { ctx->eof = true; } return (zip_int64_t)buffer_n + n; case ZIP_SOURCE_CLOSE: _zip_buffer_free(ctx->buffer); ctx->buffer = NULL; return 0; case ZIP_SOURCE_STAT: { zip_stat_t *st; st = (zip_stat_t *)data; st->encryption_method = ZIP_EM_TRAD_PKWARE; st->valid |= ZIP_STAT_ENCRYPTION_METHOD; if (st->valid & ZIP_STAT_COMP_SIZE) { st->comp_size += ZIP_CRYPTO_PKWARE_HEADERLEN; } + set_mtime(ctx, st); + st->mtime = ctx->mtime; + st->valid |= ZIP_STAT_MTIME; return 0; } case ZIP_SOURCE_GET_FILE_ATTRIBUTES: { zip_file_attributes_t *attributes = (zip_file_attributes_t *)data; if (length < sizeof(*attributes)) { zip_error_set(&ctx->error, ZIP_ER_INVAL, 0); return -1; } attributes->valid |= ZIP_FILE_ATTRIBUTES_VERSION_NEEDED; attributes->version_needed = 20; return 0; } case ZIP_SOURCE_SUPPORTS: return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1); case ZIP_SOURCE_ERROR: return zip_error_to_data(&ctx->error, data, length); case ZIP_SOURCE_FREE: trad_pkware_free(ctx); return 0; default: return zip_source_pass_to_lower_layer(src, data, length, cmd); } } static struct trad_pkware * trad_pkware_new(const char *password, zip_error_t *error) { struct trad_pkware *ctx; if ((ctx = (struct trad_pkware *)malloc(sizeof(*ctx))) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); return NULL; } if ((ctx->password = strdup(password)) == NULL) { zip_error_set(error, ZIP_ER_MEMORY, 0); free(ctx); return NULL; } ctx->buffer = NULL; + ctx->mtime_set = false; + ctx->mtime = 0; zip_error_init(&ctx->error); return ctx; } static void trad_pkware_free(struct trad_pkware *ctx) { if (ctx == NULL) { return; } free(ctx->password); _zip_buffer_free(ctx->buffer); zip_error_fini(&ctx->error); free(ctx); } + + +static void set_mtime(struct trad_pkware* ctx, zip_stat_t* st) { + if (!ctx->mtime_set) { + if (st->valid & ZIP_STAT_MTIME) { + ctx->mtime = st->mtime; + } + else { + time(&ctx->mtime); + } + ctx->mtime_set = true; + } +} diff --git a/src/Common/libzip/zip_source_zip_new.c b/src/Common/libzip/zip_source_zip_new.c index d2d66d4c..ecccdd68 100644 --- a/src/Common/libzip/zip_source_zip_new.c +++ b/src/Common/libzip/zip_source_zip_new.c @@ -26,60 +26,61 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include <stdlib.h> #include "zipint.h" static void _zip_file_attributes_from_dirent(zip_file_attributes_t *attributes, zip_dirent_t *de); ZIP_EXTERN zip_source_t *zip_source_zip_file(zip_t* za, zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, const char *password) { return zip_source_zip_file_create(srcza, srcidx, flags, start, len, password, &za->error); } ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t srcidx, zip_flags_t flags, zip_uint64_t start, zip_int64_t len, const char *password, zip_error_t *error) { /* TODO: We need to make sure that the returned source is invalidated when srcza is closed. */ zip_source_t *src, *s2; zip_stat_t st; zip_file_attributes_t attributes; zip_dirent_t *de; bool partial_data, needs_crc, encrypted, needs_decrypt, compressed, needs_decompress, changed_data, have_size, have_comp_size; zip_flags_t stat_flags; zip_int64_t data_len; bool take_ownership = false; + bool empty_data = false; if (srcza == NULL || srcidx >= srcza->nentry || len < -1) { zip_error_set(error, ZIP_ER_INVAL, 0); return NULL; } if (flags & ZIP_FL_ENCRYPTED) { flags |= ZIP_FL_COMPRESSED; } changed_data = false; if ((flags & ZIP_FL_UNCHANGED) == 0) { zip_entry_t *entry = srcza->entry + srcidx; if (ZIP_ENTRY_DATA_CHANGED(entry)) { if ((flags & ZIP_FL_COMPRESSED) || !zip_source_supports_reopen(entry->source)) { zip_error_set(error, ZIP_ER_CHANGED, 0); return NULL; } changed_data = true; } else if (entry->deleted) { zip_error_set(error, ZIP_ER_CHANGED, 0); return NULL; } } stat_flags = flags; if (!changed_data) { stat_flags |= ZIP_FL_UNCHANGED; @@ -120,69 +121,67 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s if (have_size) { partial_data = (zip_uint64_t)(data_len) < st.size; } else { partial_data = true; } encrypted = (st.valid & ZIP_STAT_ENCRYPTION_METHOD) && (st.encryption_method != ZIP_EM_NONE); needs_decrypt = ((flags & ZIP_FL_ENCRYPTED) == 0) && encrypted; compressed = (st.valid & ZIP_STAT_COMP_METHOD) && (st.comp_method != ZIP_CM_STORE); needs_decompress = ((flags & ZIP_FL_COMPRESSED) == 0) && compressed; /* when reading the whole file, check for CRC errors */ needs_crc = ((flags & ZIP_FL_COMPRESSED) == 0 || !compressed) && !partial_data && (st.valid & ZIP_STAT_CRC) != 0; if (needs_decrypt) { if (password == NULL) { password = srcza->default_password; } if (password == NULL) { zip_error_set(error, ZIP_ER_NOPASSWD, 0); return NULL; } } if ((de = _zip_get_dirent(srcza, srcidx, flags, error)) == NULL) { return NULL; } _zip_file_attributes_from_dirent(&attributes, de); have_comp_size = (st.valid & ZIP_STAT_COMP_SIZE) != 0; - if (compressed) { - if (have_comp_size && st.comp_size == 0) { - src = zip_source_buffer_with_attributes_create(NULL, 0, 0, &attributes, error); - } - else { - src = NULL; - } + if (needs_decrypt || needs_decompress) { + empty_data = (have_comp_size && st.comp_size == 0); + } + else { + empty_data = (have_size && st.size == 0); } - else if (have_size && st.size == 0) { + if (empty_data) { src = zip_source_buffer_with_attributes_create(NULL, 0, 0, &attributes, error); } else { src = NULL; } /* If we created source buffer above, we want the window source to take ownership of it. */ take_ownership = src != NULL; /* if we created a buffer source above, then treat it as if reading the changed data - that way we don't need add another special case to the code below that wraps it in the window source */ changed_data = changed_data || (src != NULL); if (partial_data && !needs_decrypt && !needs_decompress) { struct zip_stat st2; zip_t *source_archive; zip_uint64_t source_index; if (changed_data) { if (src == NULL) { src = srcza->entry[srcidx].source; } source_archive = NULL; source_index = 0; } else { src = srcza->src; source_archive = srcza; diff --git a/src/Common/libzip/zipconf.h b/src/Common/libzip/zipconf.h index 2f8106a4..472e06c1 100644 --- a/src/Common/libzip/zipconf.h +++ b/src/Common/libzip/zipconf.h @@ -1,44 +1,44 @@ #ifndef _HAD_ZIPCONF_H #define _HAD_ZIPCONF_H /* zipconf.h -- platform specific include file This file was generated automatically by CMake based on ../cmake-zipconf.h.in. */ -#define LIBZIP_VERSION "1.10.0" +#define LIBZIP_VERSION "1.10.1" #define LIBZIP_VERSION_MAJOR 1 #define LIBZIP_VERSION_MINOR 10 -#define LIBZIP_VERSION_MICRO 0 +#define LIBZIP_VERSION_MICRO 1 /* #undef ZIP_STATIC */ #define _Nullable #define _Nonnull #if !defined(__STDC_FORMAT_MACROS) #define __STDC_FORMAT_MACROS 1 #endif #if defined(_MSC_VER) && _MSC_VER < 1700 #include <stdint.h> #define PRIu32 "lu" #define PRIu64 "llu" #else #include <inttypes.h> #endif typedef int8_t zip_int8_t; typedef uint8_t zip_uint8_t; typedef int16_t zip_int16_t; typedef uint16_t zip_uint16_t; typedef int32_t zip_int32_t; typedef uint32_t zip_uint32_t; typedef int64_t zip_int64_t; typedef uint64_t zip_uint64_t; #define ZIP_INT8_MIN (-ZIP_INT8_MAX-1) #define ZIP_INT8_MAX 0x7f #define ZIP_UINT8_MAX 0xff diff --git a/src/Common/zlib/ChangeLog b/src/Common/zlib/ChangeLog new file mode 100644 index 00000000..b801a103 --- /dev/null +++ b/src/Common/zlib/ChangeLog @@ -0,0 +1,1618 @@ + + ChangeLog file for zlib + +Changes in 1.3.1 (22 Jan 2024) +- Reject overflows of zip header fields in minizip +- Fix bug in inflateSync() for data held in bit buffer +- Add LIT_MEM define to use more memory for a small deflate speedup +- Fix decision on the emission of Zip64 end records in minizip +- Add bounds checking to ERR_MSG() macro, used by zError() +- Neutralize zip file traversal attacks in miniunz +- Fix a bug in ZLIB_DEBUG compiles in check_match() +- Various portability and appearance improvements + +Changes in 1.3 (18 Aug 2023) +- Remove K&R function definitions and zlib2ansi +- Fix bug in deflateBound() for level 0 and memLevel 9 +- Fix bug when gzungetc() is used immediately after gzopen() +- Fix bug when using gzflush() with a very small buffer +- Fix crash when gzsetparams() attempted for transparent write +- Fix test/example.c to work with FORCE_STORED +- Rewrite of zran in examples (see zran.c version history) +- Fix minizip to allow it to open an empty zip file +- Fix reading disk number start on zip64 files in minizip +- Fix logic error in minizip argument processing +- Add minizip testing to Makefile +- Read multiple bytes instead of byte-by-byte in minizip unzip.c +- Add memory sanitizer to configure (--memory) +- Various portability improvements +- Various documentation improvements +- Various spelling and typo corrections + +Changes in 1.2.13 (13 Oct 2022) +- Fix configure issue that discarded provided CC definition +- Correct incorrect inputs provided to the CRC functions +- Repair prototypes and exporting of new CRC functions +- Fix inflateBack to detect invalid input with distances too far +- Have infback() deliver all of the available output up to any error +- Fix a bug when getting a gzip header extra field with inflate() +- Fix bug in block type selection when Z_FIXED used +- Tighten deflateBound bounds +- Remove deleted assembler code references +- Various portability and appearance improvements + +Changes in 1.2.12 (27 Mar 2022) +- Cygwin does not have _wopen(), so do not create gzopen_w() there +- Permit a deflateParams() parameter change as soon as possible +- Limit hash table inserts after switch from stored deflate +- Fix bug when window full in deflate_stored() +- Fix CLEAR_HASH macro to be usable as a single statement +- Avoid a conversion error in gzseek when off_t type too small +- Have Makefile return non-zero error code on test failure +- Avoid some conversion warnings in gzread.c and gzwrite.c +- Update use of errno for newer Windows CE versions +- Small speedup to inflate [psumbera] +- Return an error if the gzputs string length can't fit in an int +- Add address checking in clang to -w option of configure +- Don't compute check value for raw inflate if asked to validate +- Handle case where inflateSync used when header never processed +- Avoid the use of ptrdiff_t +- Avoid an undefined behavior of memcpy() in gzappend() +- Avoid undefined behaviors of memcpy() in gz*printf() +- Avoid an undefined behavior of memcpy() in _tr_stored_block() +- Make the names in functions declarations identical to definitions +- Remove old assembler code in which bugs have manifested +- Fix deflateEnd() to not report an error at start of raw deflate +- Add legal disclaimer to README +- Emphasize the need to continue decompressing gzip members +- Correct the initialization requirements for deflateInit2() +- Fix a bug that can crash deflate on some input when using Z_FIXED +- Assure that the number of bits for deflatePrime() is valid +- Use a structure to make globals in enough.c evident +- Use a macro for the printf format of big_t in enough.c +- Clean up code style in enough.c, update version +- Use inline function instead of macro for index in enough.c +- Clarify that prefix codes are counted in enough.c +- Show all the codes for the maximum tables size in enough.c +- Add gznorm.c example, which normalizes gzip files +- Fix the zran.c example to work on a multiple-member gzip file +- Add tables for crc32_combine(), to speed it up by a factor of 200 +- Add crc32_combine_gen() and crc32_combine_op() for fast combines +- Speed up software CRC-32 computation by a factor of 1.5 to 3 +- Use atomic test and set, if available, for dynamic CRC tables +- Don't bother computing check value after successful inflateSync() +- Correct comment in crc32.c +- Add use of the ARMv8 crc32 instructions when requested +- Use ARM crc32 instructions if the ARM architecture has them +- Explicitly note that the 32-bit check values are 32 bits +- Avoid adding empty gzip member after gzflush with Z_FINISH +- Fix memory leak on error in gzlog.c +- Fix error in comment on the polynomial representation of a byte +- Clarify gz* function interfaces, referring to parameter names +- Change macro name in inflate.c to avoid collision in VxWorks +- Correct typo in blast.c +- Improve portability of contrib/minizip +- Fix indentation in minizip's zip.c +- Replace black/white with allow/block. (theresa-m) +- minizip warning fix if MAXU32 already defined. (gvollant) +- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner) +- Clean up minizip to reduce warnings for testing +- Add fallthrough comments for gcc +- Eliminate use of ULL constants +- Separate out address sanitizing from warnings in configure +- Remove destructive aspects of make distclean +- Check for cc masquerading as gcc or clang in configure +- Fix crc32.c to compile local functions only if used + +Changes in 1.2.11 (15 Jan 2017) +- Fix deflate stored bug when pulling last block from window +- Permit immediate deflateParams changes before any deflate input + +Changes in 1.2.10 (2 Jan 2017) +- Avoid warnings on snprintf() return value +- Fix bug in deflate_stored() for zero-length input +- Fix bug in gzwrite.c that produced corrupt gzip files +- Remove files to be installed before copying them in Makefile.in +- Add warnings when compiling with assembler code + +Changes in 1.2.9 (31 Dec 2016) +- Fix contrib/minizip to permit unzipping with desktop API [Zouzou] +- Improve contrib/blast to return unused bytes +- Assure that gzoffset() is correct when appending +- Improve compress() and uncompress() to support large lengths +- Fix bug in test/example.c where error code not saved +- Remedy Coverity warning [Randers-Pehrson] +- Improve speed of gzprintf() in transparent mode +- Fix inflateInit2() bug when windowBits is 16 or 32 +- Change DEBUG macro to ZLIB_DEBUG +- Avoid uninitialized access by gzclose_w() +- Allow building zlib outside of the source directory +- Fix bug that accepted invalid zlib header when windowBits is zero +- Fix gzseek() problem on MinGW due to buggy _lseeki64 there +- Loop on write() calls in gzwrite.c in case of non-blocking I/O +- Add --warn (-w) option to ./configure for more compiler warnings +- Reject a window size of 256 bytes if not using the zlib wrapper +- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE +- Add --debug (-d) option to ./configure to define ZLIB_DEBUG +- Fix bugs in creating a very large gzip header +- Add uncompress2() function, which returns the input size used +- Assure that deflateParams() will not switch functions mid-block +- Dramatically speed up deflation for level 0 (storing) +- Add gzfread(), duplicating the interface of fread() +- Add gzfwrite(), duplicating the interface of fwrite() +- Add deflateGetDictionary() function +- Use snprintf() for later versions of Microsoft C +- Fix *Init macros to use z_ prefix when requested +- Replace as400 with os400 for OS/400 support [Monnerat] +- Add crc32_z() and adler32_z() functions with size_t lengths +- Update Visual Studio project files [AraHaan] + +Changes in 1.2.8 (28 Apr 2013) +- Update contrib/minizip/iowin32.c for Windows RT [Vollant] +- Do not force Z_CONST for C++ +- Clean up contrib/vstudio [Roß] +- Correct spelling error in zlib.h +- Fix mixed line endings in contrib/vstudio + +Changes in 1.2.7.3 (13 Apr 2013) +- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc + +Changes in 1.2.7.2 (13 Apr 2013) +- Change check for a four-byte type back to hexadecimal +- Fix typo in win32/Makefile.msc +- Add casts in gzwrite.c for pointer differences + +Changes in 1.2.7.1 (24 Mar 2013) +- Replace use of unsafe string functions with snprintf if available +- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink] +- Fix gzgetc undefine when Z_PREFIX set [Turk] +- Eliminate use of mktemp in Makefile (not always available) +- Fix bug in 'F' mode for gzopen() +- Add inflateGetDictionary() function +- Correct comment in deflate.h +- Use _snprintf for snprintf in Microsoft C +- On Darwin, only use /usr/bin/libtool if libtool is not Apple +- Delete "--version" file if created by "ar --version" [Richard G.] +- Fix configure check for veracity of compiler error return codes +- Fix CMake compilation of static lib for MSVC2010 x64 +- Remove unused variable in infback9.c +- Fix argument checks in gzlog_compress() and gzlog_write() +- Clean up the usage of z_const and respect const usage within zlib +- Clean up examples/gzlog.[ch] comparisons of different types +- Avoid shift equal to bits in type (caused endless loop) +- Fix uninitialized value bug in gzputc() introduced by const patches +- Fix memory allocation error in examples/zran.c [Nor] +- Fix bug where gzopen(), gzclose() would write an empty file +- Fix bug in gzclose() when gzwrite() runs out of memory +- Check for input buffer malloc failure in examples/gzappend.c +- Add note to contrib/blast to use binary mode in stdio +- Fix comparisons of differently signed integers in contrib/blast +- Check for invalid code length codes in contrib/puff +- Fix serious but very rare decompression bug in inftrees.c +- Update inflateBack() comments, since inflate() can be faster +- Use underscored I/O function names for WINAPI_FAMILY +- Add _tr_flush_bits to the external symbols prefixed by --zprefix +- Add contrib/vstudio/vc10 pre-build step for static only +- Quote --version-script argument in CMakeLists.txt +- Don't specify --version-script on Apple platforms in CMakeLists.txt +- Fix casting error in contrib/testzlib/testzlib.c +- Fix types in contrib/minizip to match result of get_crc_table() +- Simplify contrib/vstudio/vc10 with 'd' suffix +- Add TOP support to win32/Makefile.msc +- Support i686 and amd64 assembler builds in CMakeLists.txt +- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h +- Add vc11 and vc12 build files to contrib/vstudio +- Add gzvprintf() as an undocumented function in zlib +- Fix configure for Sun shell +- Remove runtime check in configure for four-byte integer type +- Add casts and consts to ease user conversion to C++ +- Add man pages for minizip and miniunzip +- In Makefile uninstall, don't rm if preceding cd fails +- Do not return Z_BUF_ERROR if deflateParam() has nothing to write + +Changes in 1.2.7 (2 May 2012) +- Replace use of memmove() with a simple copy for portability +- Test for existence of strerror +- Restore gzgetc_ for backward compatibility with 1.2.6 +- Fix build with non-GNU make on Solaris +- Require gcc 4.0 or later on Mac OS X to use the hidden attribute +- Include unistd.h for Watcom C +- Use __WATCOMC__ instead of __WATCOM__ +- Do not use the visibility attribute if NO_VIZ defined +- Improve the detection of no hidden visibility attribute +- Avoid using __int64 for gcc or solo compilation +- Cast to char * in gzprintf to avoid warnings [Zinser] +- Fix make_vms.com for VAX [Zinser] +- Don't use library or built-in byte swaps +- Simplify test and use of gcc hidden attribute +- Fix bug in gzclose_w() when gzwrite() fails to allocate memory +- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen() +- Fix bug in test/minigzip.c for configure --solo +- Fix contrib/vstudio project link errors [Mohanathas] +- Add ability to choose the builder in make_vms.com [Schweda] +- Add DESTDIR support to mingw32 win32/Makefile.gcc +- Fix comments in win32/Makefile.gcc for proper usage +- Allow overriding the default install locations for cmake +- Generate and install the pkg-config file with cmake +- Build both a static and a shared version of zlib with cmake +- Include version symbols for cmake builds +- If using cmake with MSVC, add the source directory to the includes +- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta] +- Move obsolete emx makefile to old [Truta] +- Allow the use of -Wundef when compiling or using zlib +- Avoid the use of the -u option with mktemp +- Improve inflate() documentation on the use of Z_FINISH +- Recognize clang as gcc +- Add gzopen_w() in Windows for wide character path names +- Rename zconf.h in CMakeLists.txt to move it out of the way +- Add source directory in CMakeLists.txt for building examples +- Look in build directory for zlib.pc in CMakeLists.txt +- Remove gzflags from zlibvc.def in vc9 and vc10 +- Fix contrib/minizip compilation in the MinGW environment +- Update ./configure for Solaris, support --64 [Mooney] +- Remove -R. from Solaris shared build (possible security issue) +- Avoid race condition for parallel make (-j) running example +- Fix type mismatch between get_crc_table() and crc_table +- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler] +- Fix the path to zlib.map in CMakeLists.txt +- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe] +- Add instructions to win32/Makefile.gcc for shared install [Torri] + +Changes in 1.2.6.1 (12 Feb 2012) +- Avoid the use of the Objective-C reserved name "id" +- Include io.h in gzguts.h for Microsoft compilers +- Fix problem with ./configure --prefix and gzgetc macro +- Include gz_header definition when compiling zlib solo +- Put gzflags() functionality back in zutil.c +- Avoid library header include in crc32.c for Z_SOLO +- Use name in GCC_CLASSIC as C compiler for coverage testing, if set +- Minor cleanup in contrib/minizip/zip.c [Vollant] +- Update make_vms.com [Zinser] +- Remove unnecessary gzgetc_ function +- Use optimized byte swap operations for Microsoft and GNU [Snyder] +- Fix minor typo in zlib.h comments [Rzesniowiecki] + +Changes in 1.2.6 (29 Jan 2012) +- Update the Pascal interface in contrib/pascal +- Fix function numbers for gzgetc_ in zlibvc.def files +- Fix configure.ac for contrib/minizip [Schiffer] +- Fix large-entry detection in minizip on 64-bit systems [Schiffer] +- Have ./configure use the compiler return code for error indication +- Fix CMakeLists.txt for cross compilation [McClure] +- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes] +- Fix compilation of contrib/minizip on FreeBSD [Marquez] +- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath] +- Include io.h for Turbo C / Borland C on all platforms [Truta] +- Make version explicit in contrib/minizip/configure.ac [Bosmans] +- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant] +- Minor cleanup up contrib/minizip/unzip.c [Vollant] +- Fix bug when compiling minizip with C++ [Vollant] +- Protect for long name and extra fields in contrib/minizip [Vollant] +- Avoid some warnings in contrib/minizip [Vollant] +- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip +- Add missing libs to minizip linker command +- Add support for VPATH builds in contrib/minizip +- Add an --enable-demos option to contrib/minizip/configure +- Add the generation of configure.log by ./configure +- Exit when required parameters not provided to win32/Makefile.gcc +- Have gzputc return the character written instead of the argument +- Use the -m option on ldconfig for BSD systems [Tobias] +- Correct in zlib.map when deflateResetKeep was added + +Changes in 1.2.5.3 (15 Jan 2012) +- Restore gzgetc function for binary compatibility +- Do not use _lseeki64 under Borland C++ [Truta] +- Update win32/Makefile.msc to build test/*.c [Truta] +- Remove old/visualc6 given CMakefile and other alternatives +- Update AS400 build files and documentation [Monnerat] +- Update win32/Makefile.gcc to build test/*.c [Truta] +- Permit stronger flushes after Z_BLOCK flushes +- Avoid extraneous empty blocks when doing empty flushes +- Permit Z_NULL arguments to deflatePending +- Allow deflatePrime() to insert bits in the middle of a stream +- Remove second empty static block for Z_PARTIAL_FLUSH +- Write out all of the available bits when using Z_BLOCK +- Insert the first two strings in the hash table after a flush + +Changes in 1.2.5.2 (17 Dec 2011) +- fix ld error: unable to find version dependency 'ZLIB_1.2.5' +- use relative symlinks for shared libs +- Avoid searching past window for Z_RLE strategy +- Assure that high-water mark initialization is always applied in deflate +- Add assertions to fill_window() in deflate.c to match comments +- Update python link in README +- Correct spelling error in gzread.c +- Fix bug in gzgets() for a concatenated empty gzip stream +- Correct error in comment for gz_make() +- Change gzread() and related to ignore junk after gzip streams +- Allow gzread() and related to continue after gzclearerr() +- Allow gzrewind() and gzseek() after a premature end-of-file +- Simplify gzseek() now that raw after gzip is ignored +- Change gzgetc() to a macro for speed (~40% speedup in testing) +- Fix gzclose() to return the actual error last encountered +- Always add large file support for windows +- Include zconf.h for windows large file support +- Include zconf.h.cmakein for windows large file support +- Update zconf.h.cmakein on make distclean +- Merge vestigial vsnprintf determination from zutil.h to gzguts.h +- Clarify how gzopen() appends in zlib.h comments +- Correct documentation of gzdirect() since junk at end now ignored +- Add a transparent write mode to gzopen() when 'T' is in the mode +- Update python link in zlib man page +- Get inffixed.h and MAKEFIXED result to match +- Add a ./config --solo option to make zlib subset with no library use +- Add undocumented inflateResetKeep() function for CAB file decoding +- Add --cover option to ./configure for gcc coverage testing +- Add #define ZLIB_CONST option to use const in the z_stream interface +- Add comment to gzdopen() in zlib.h to use dup() when using fileno() +- Note behavior of uncompress() to provide as much data as it can +- Add files in contrib/minizip to aid in building libminizip +- Split off AR options in Makefile.in and configure +- Change ON macro to Z_ARG to avoid application conflicts +- Facilitate compilation with Borland C++ for pragmas and vsnprintf +- Include io.h for Turbo C / Borland C++ +- Move example.c and minigzip.c to test/ +- Simplify incomplete code table filling in inflate_table() +- Remove code from inflate.c and infback.c that is impossible to execute +- Test the inflate code with full coverage +- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw) +- Add deflateResetKeep and fix inflateResetKeep to retain dictionary +- Fix gzwrite.c to accommodate reduced memory zlib compilation +- Have inflate() with Z_FINISH avoid the allocation of a window +- Do not set strm->adler when doing raw inflate +- Fix gzeof() to behave just like feof() when read is not past end of file +- Fix bug in gzread.c when end-of-file is reached +- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF +- Document gzread() capability to read concurrently written files +- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo] + +Changes in 1.2.5.1 (10 Sep 2011) +- Update FAQ entry on shared builds (#13) +- Avoid symbolic argument to chmod in Makefile.in +- Fix bug and add consts in contrib/puff [Oberhumer] +- Update contrib/puff/zeros.raw test file to have all block types +- Add full coverage test for puff in contrib/puff/Makefile +- Fix static-only-build install in Makefile.in +- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno] +- Add libz.a dependency to shared in Makefile.in for parallel builds +- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out +- Replace $(...) with `...` in configure for non-bash sh [Bowler] +- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen] +- Add solaris* to Linux* in configure to allow gcc use [Groffen] +- Add *bsd* to Linux* case in configure [Bar-Lev] +- Add inffast.obj to dependencies in win32/Makefile.msc +- Correct spelling error in deflate.h [Kohler] +- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc +- Add test to configure for GNU C looking for gcc in output of $cc -v +- Add zlib.pc generation to win32/Makefile.gcc [Weigelt] +- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not +- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense +- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser) +- Make stronger test in zconf.h to include unistd.h for LFS +- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack] +- Fix zlib.h LFS support when Z_PREFIX used +- Add updated as400 support (removed from old) [Monnerat] +- Avoid deflate sensitivity to volatile input data +- Avoid division in adler32_combine for NO_DIVIDE +- Clarify the use of Z_FINISH with deflateBound() amount of space +- Set binary for output file in puff.c +- Use u4 type for crc_table to avoid conversion warnings +- Apply casts in zlib.h to avoid conversion warnings +- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller] +- Improve inflateSync() documentation to note indeterminacy +- Add deflatePending() function to return the amount of pending output +- Correct the spelling of "specification" in FAQ [Randers-Pehrson] +- Add a check in configure for stdarg.h, use for gzprintf() +- Check that pointers fit in ints when gzprint() compiled old style +- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler] +- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt] +- Add debug records in assembler code [Londer] +- Update RFC references to use http://tools.ietf.org/html/... [Li] +- Add --archs option, use of libtool to configure for Mac OS X [Borstel] + +Changes in 1.2.5 (19 Apr 2010) +- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev] +- Default to libdir as sharedlibdir in configure [Nieder] +- Update copyright dates on modified source files +- Update trees.c to be able to generate modified trees.h +- Exit configure for MinGW, suggesting win32/Makefile.gcc +- Check for NULL path in gz_open [Homurlu] + +Changes in 1.2.4.5 (18 Apr 2010) +- Set sharedlibdir in configure [Torok] +- Set LDFLAGS in Makefile.in [Bar-Lev] +- Avoid mkdir objs race condition in Makefile.in [Bowler] +- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays +- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C +- Don't use hidden attribute when it is a warning generator (e.g. Solaris) + +Changes in 1.2.4.4 (18 Apr 2010) +- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok] +- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty +- Try to use bash or ksh regardless of functionality of /bin/sh +- Fix configure incompatibility with NetBSD sh +- Remove attempt to run under bash or ksh since have better NetBSD fix +- Fix win32/Makefile.gcc for MinGW [Bar-Lev] +- Add diagnostic messages when using CROSS_PREFIX in configure +- Added --sharedlibdir option to configure [Weigelt] +- Use hidden visibility attribute when available [Frysinger] + +Changes in 1.2.4.3 (10 Apr 2010) +- Only use CROSS_PREFIX in configure for ar and ranlib if they exist +- Use CROSS_PREFIX for nm [Bar-Lev] +- Assume _LARGEFILE64_SOURCE defined is equivalent to true +- Avoid use of undefined symbols in #if with && and || +- Make *64 prototypes in gzguts.h consistent with functions +- Add -shared load option for MinGW in configure [Bowler] +- Move z_off64_t to public interface, use instead of off64_t +- Remove ! from shell test in configure (not portable to Solaris) +- Change +0 macro tests to -0 for possibly increased portability + +Changes in 1.2.4.2 (9 Apr 2010) +- Add consistent carriage returns to readme.txt's in masmx86 and masmx64 +- Really provide prototypes for *64 functions when building without LFS +- Only define unlink() in minigzip.c if unistd.h not included +- Update README to point to contrib/vstudio project files +- Move projects/vc6 to old/ and remove projects/ +- Include stdlib.h in minigzip.c for setmode() definition under WinCE +- Clean up assembler builds in win32/Makefile.msc [Rowe] +- Include sys/types.h for Microsoft for off_t definition +- Fix memory leak on error in gz_open() +- Symbolize nm as $NM in configure [Weigelt] +- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt] +- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined +- Fix bug in gzeof() to take into account unused input data +- Avoid initialization of structures with variables in puff.c +- Updated win32/README-WIN32.txt [Rowe] + +Changes in 1.2.4.1 (28 Mar 2010) +- Remove the use of [a-z] constructs for sed in configure [gentoo 310225] +- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech] +- Restore "for debugging" comment on sprintf() in gzlib.c +- Remove fdopen for MVS from gzguts.h +- Put new README-WIN32.txt in win32 [Rowe] +- Add check for shell to configure and invoke another shell if needed +- Fix big fat stinking bug in gzseek() on uncompressed files +- Remove vestigial F_OPEN64 define in zutil.h +- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE +- Avoid errors on non-LFS systems when applications define LFS macros +- Set EXE to ".exe" in configure for MINGW [Kahle] +- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill] +- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev] +- Add DLL install in win32/makefile.gcc [Bar-Lev] +- Allow Linux* or linux* from uname in configure [Bar-Lev] +- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev] +- Add cross-compilation prefixes to configure [Bar-Lev] +- Match type exactly in gz_load() invocation in gzread.c +- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func +- Provide prototypes for *64 functions when building zlib without LFS +- Don't use -lc when linking shared library on MinGW +- Remove errno.h check in configure and vestigial errno code in zutil.h + +Changes in 1.2.4 (14 Mar 2010) +- Fix VER3 extraction in configure for no fourth subversion +- Update zlib.3, add docs to Makefile.in to make .pdf out of it +- Add zlib.3.pdf to distribution +- Don't set error code in gzerror() if passed pointer is NULL +- Apply destination directory fixes to CMakeLists.txt [Lowman] +- Move #cmakedefine's to a new zconf.in.cmakein +- Restore zconf.h for builds that don't use configure or cmake +- Add distclean to dummy Makefile for convenience +- Update and improve INDEX, README, and FAQ +- Update CMakeLists.txt for the return of zconf.h [Lowman] +- Update contrib/vstudio/vc9 and vc10 [Vollant] +- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc +- Apply license and readme changes to contrib/asm686 [Raiter] +- Check file name lengths and add -c option in minigzip.c [Li] +- Update contrib/amd64 and contrib/masmx86/ [Vollant] +- Avoid use of "eof" parameter in trees.c to not shadow library variable +- Update make_vms.com for removal of zlibdefs.h [Zinser] +- Update assembler code and vstudio projects in contrib [Vollant] +- Remove outdated assembler code contrib/masm686 and contrib/asm586 +- Remove old vc7 and vc8 from contrib/vstudio +- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe] +- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open() +- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant] +- Remove *64 functions from win32/zlib.def (they're not 64-bit yet) +- Fix bug in void-returning vsprintf() case in gzwrite.c +- Fix name change from inflate.h in contrib/inflate86/inffas86.c +- Check if temporary file exists before removing in make_vms.com [Zinser] +- Fix make install and uninstall for --static option +- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta] +- Update readme.txt in contrib/masmx64 and masmx86 to assemble + +Changes in 1.2.3.9 (21 Feb 2010) +- Expunge gzio.c +- Move as400 build information to old +- Fix updates in contrib/minizip and contrib/vstudio +- Add const to vsnprintf test in configure to avoid warnings [Weigelt] +- Delete zconf.h (made by configure) [Weigelt] +- Change zconf.in.h to zconf.h.in per convention [Weigelt] +- Check for NULL buf in gzgets() +- Return empty string for gzgets() with len == 1 (like fgets()) +- Fix description of gzgets() in zlib.h for end-of-file, NULL return +- Update minizip to 1.1 [Vollant] +- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c +- Note in zlib.h that gzerror() should be used to distinguish from EOF +- Remove use of snprintf() from gzlib.c +- Fix bug in gzseek() +- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant] +- Fix zconf.h generation in CMakeLists.txt [Lowman] +- Improve comments in zconf.h where modified by configure + +Changes in 1.2.3.8 (13 Feb 2010) +- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer] +- Use z_off64_t in gz_zero() and gz_skip() to match state->skip +- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t) +- Revert to Makefile.in from 1.2.3.6 (live with the clutter) +- Fix missing error return in gzflush(), add zlib.h note +- Add *64 functions to zlib.map [Levin] +- Fix signed/unsigned comparison in gz_comp() +- Use SFLAGS when testing shared linking in configure +- Add --64 option to ./configure to use -m64 with gcc +- Fix ./configure --help to correctly name options +- Have make fail if a test fails [Levin] +- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson] +- Remove assembler object files from contrib + +Changes in 1.2.3.7 (24 Jan 2010) +- Always gzopen() with O_LARGEFILE if available +- Fix gzdirect() to work immediately after gzopen() or gzdopen() +- Make gzdirect() more precise when the state changes while reading +- Improve zlib.h documentation in many places +- Catch memory allocation failure in gz_open() +- Complete close operation if seek forward in gzclose_w() fails +- Return Z_ERRNO from gzclose_r() if close() fails +- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL +- Return zero for gzwrite() errors to match zlib.h description +- Return -1 on gzputs() error to match zlib.h description +- Add zconf.in.h to allow recovery from configure modification [Weigelt] +- Fix static library permissions in Makefile.in [Weigelt] +- Avoid warnings in configure tests that hide functionality [Weigelt] +- Add *BSD and DragonFly to Linux case in configure [gentoo 123571] +- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212] +- Avoid access of uninitialized data for first inflateReset2 call [Gomes] +- Keep object files in subdirectories to reduce the clutter somewhat +- Remove default Makefile and zlibdefs.h, add dummy Makefile +- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_ +- Remove zlibdefs.h completely -- modify zconf.h instead + +Changes in 1.2.3.6 (17 Jan 2010) +- Avoid void * arithmetic in gzread.c and gzwrite.c +- Make compilers happier with const char * for gz_error message +- Avoid unused parameter warning in inflate.c +- Avoid signed-unsigned comparison warning in inflate.c +- Indent #pragma's for traditional C +- Fix usage of strwinerror() in glib.c, change to gz_strwinerror() +- Correct email address in configure for system options +- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser] +- Update zlib.map [Brown] +- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok] +- Apply various fixes to CMakeLists.txt [Lowman] +- Add checks on len in gzread() and gzwrite() +- Add error message for no more room for gzungetc() +- Remove zlib version check in gzwrite() +- Defer compression of gzprintf() result until need to +- Use snprintf() in gzdopen() if available +- Remove USE_MMAP configuration determination (only used by minigzip) +- Remove examples/pigz.c (available separately) +- Update examples/gun.c to 1.6 + +Changes in 1.2.3.5 (8 Jan 2010) +- Add space after #if in zutil.h for some compilers +- Fix relatively harmless bug in deflate_fast() [Exarevsky] +- Fix same problem in deflate_slow() +- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown] +- Add deflate_rle() for faster Z_RLE strategy run-length encoding +- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding +- Change name of "write" variable in inffast.c to avoid library collisions +- Fix premature EOF from gzread() in gzio.c [Brown] +- Use zlib header window size if windowBits is 0 in inflateInit2() +- Remove compressBound() call in deflate.c to avoid linking compress.o +- Replace use of errno in gz* with functions, support WinCE [Alves] +- Provide alternative to perror() in minigzip.c for WinCE [Alves] +- Don't use _vsnprintf on later versions of MSVC [Lowman] +- Add CMake build script and input file [Lowman] +- Update contrib/minizip to 1.1 [Svensson, Vollant] +- Moved nintendods directory from contrib to root +- Replace gzio.c with a new set of routines with the same functionality +- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above +- Update contrib/minizip to 1.1b +- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h + +Changes in 1.2.3.4 (21 Dec 2009) +- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility +- Update comments in configure and Makefile.in for default --shared +- Fix test -z's in configure [Marquess] +- Build examplesh and minigzipsh when not testing +- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h +- Import LDFLAGS from the environment in configure +- Fix configure to populate SFLAGS with discovered CFLAGS options +- Adapt make_vms.com to the new Makefile.in [Zinser] +- Add zlib2ansi script for C++ compilation [Marquess] +- Add _FILE_OFFSET_BITS=64 test to make test (when applicable) +- Add AMD64 assembler code for longest match to contrib [Teterin] +- Include options from $SFLAGS when doing $LDSHARED +- Simplify 64-bit file support by introducing z_off64_t type +- Make shared object files in objs directory to work around old Sun cc +- Use only three-part version number for Darwin shared compiles +- Add rc option to ar in Makefile.in for when ./configure not run +- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4* +- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile +- Protect against _FILE_OFFSET_BITS being defined when compiling zlib +- Rename Makefile.in targets allstatic to static and allshared to shared +- Fix static and shared Makefile.in targets to be independent +- Correct error return bug in gz_open() by setting state [Brown] +- Put spaces before ;;'s in configure for better sh compatibility +- Add pigz.c (parallel implementation of gzip) to examples/ +- Correct constant in crc32.c to UL [Leventhal] +- Reject negative lengths in crc32_combine() +- Add inflateReset2() function to work like inflateEnd()/inflateInit2() +- Include sys/types.h for _LARGEFILE64_SOURCE [Brown] +- Correct typo in doc/algorithm.txt [Janik] +- Fix bug in adler32_combine() [Zhu] +- Catch missing-end-of-block-code error in all inflates and in puff + Assures that random input to inflate eventually results in an error +- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/ +- Update ENOUGH and its usage to reflect discovered bounds +- Fix gzerror() error report on empty input file [Brown] +- Add ush casts in trees.c to avoid pedantic runtime errors +- Fix typo in zlib.h uncompress() description [Reiss] +- Correct inflate() comments with regard to automatic header detection +- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays) +- Put new version of gzlog (2.0) in examples with interruption recovery +- Add puff compile option to permit invalid distance-too-far streams +- Add puff TEST command options, ability to read piped input +- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but + _LARGEFILE64_SOURCE not defined +- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart +- Fix deflateSetDictionary() to use all 32K for output consistency +- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h) +- Clear bytes after deflate lookahead to avoid use of uninitialized data +- Change a limit in inftrees.c to be more transparent to Coverity Prevent +- Update win32/zlib.def with exported symbols from zlib.h +- Correct spelling errors in zlib.h [Willem, Sobrado] +- Allow Z_BLOCK for deflate() to force a new block +- Allow negative bits in inflatePrime() to delete existing bit buffer +- Add Z_TREES flush option to inflate() to return at end of trees +- Add inflateMark() to return current state information for random access +- Add Makefile for NintendoDS to contrib [Costa] +- Add -w in configure compile tests to avoid spurious warnings [Beucler] +- Fix typos in zlib.h comments for deflateSetDictionary() +- Fix EOF detection in transparent gzread() [Maier] + +Changes in 1.2.3.3 (2 October 2006) +- Make --shared the default for configure, add a --static option +- Add compile option to permit invalid distance-too-far streams +- Add inflateUndermine() function which is required to enable above +- Remove use of "this" variable name for C++ compatibility [Marquess] +- Add testing of shared library in make test, if shared library built +- Use ftello() and fseeko() if available instead of ftell() and fseek() +- Provide two versions of all functions that use the z_off_t type for + binary compatibility -- a normal version and a 64-bit offset version, + per the Large File Support Extension when _LARGEFILE64_SOURCE is + defined; use the 64-bit versions by default when _FILE_OFFSET_BITS + is defined to be 64 +- Add a --uname= option to configure to perhaps help with cross-compiling + +Changes in 1.2.3.2 (3 September 2006) +- Turn off silly Borland warnings [Hay] +- Use off64_t and define _LARGEFILE64_SOURCE when present +- Fix missing dependency on inffixed.h in Makefile.in +- Rig configure --shared to build both shared and static [Teredesai, Truta] +- Remove zconf.in.h and instead create a new zlibdefs.h file +- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant] +- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt] + +Changes in 1.2.3.1 (16 August 2006) +- Add watcom directory with OpenWatcom make files [Daniel] +- Remove #undef of FAR in zconf.in.h for MVS [Fedtke] +- Update make_vms.com [Zinser] +- Use -fPIC for shared build in configure [Teredesai, Nicholson] +- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen] +- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck] +- Add some FAQ entries about the contrib directory +- Update the MVS question in the FAQ +- Avoid extraneous reads after EOF in gzio.c [Brown] +- Correct spelling of "successfully" in gzio.c [Randers-Pehrson] +- Add comments to zlib.h about gzerror() usage [Brown] +- Set extra flags in gzip header in gzopen() like deflate() does +- Make configure options more compatible with double-dash conventions + [Weigelt] +- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen] +- Fix uninstall target in Makefile.in [Truta] +- Add pkgconfig support [Weigelt] +- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt] +- Replace set_data_type() with a more accurate detect_data_type() in + trees.c, according to the txtvsbin.txt document [Truta] +- Swap the order of #include <stdio.h> and #include "zlib.h" in + gzio.c, example.c and minigzip.c [Truta] +- Shut up annoying VS2005 warnings about standard C deprecation [Rowe, + Truta] (where?) +- Fix target "clean" from win32/Makefile.bor [Truta] +- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe] +- Update zlib www home address in win32/DLL_FAQ.txt [Truta] +- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove] +- Enable browse info in the "Debug" and "ASM Debug" configurations in + the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta] +- Add pkgconfig support [Weigelt] +- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h, + for use in win32/zlib1.rc [Polushin, Rowe, Truta] +- Add a document that explains the new text detection scheme to + doc/txtvsbin.txt [Truta] +- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta] +- Move algorithm.txt into doc/ [Truta] +- Synchronize FAQ with website +- Fix compressBound(), was low for some pathological cases [Fearnley] +- Take into account wrapper variations in deflateBound() +- Set examples/zpipe.c input and output to binary mode for Windows +- Update examples/zlib_how.html with new zpipe.c (also web site) +- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems + that gcc became pickier in 4.0) +- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain + un-versioned, the patch adds versioning only for symbols introduced in + zlib-1.2.0 or later. It also declares as local those symbols which are + not designed to be exported." [Levin] +- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure +- Do not initialize global static by default in trees.c, add a response + NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess] +- Don't use strerror() in gzio.c under WinCE [Yakimov] +- Don't use errno.h in zutil.h under WinCE [Yakimov] +- Move arguments for AR to its usage to allow replacing ar [Marot] +- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson] +- Improve inflateInit() and inflateInit2() documentation +- Fix structure size comment in inflate.h +- Change configure help option from --h* to --help [Santos] + +Changes in 1.2.3 (18 July 2005) +- Apply security vulnerability fixes to contrib/infback9 as well +- Clean up some text files (carriage returns, trailing space) +- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant] + +Changes in 1.2.2.4 (11 July 2005) +- Add inflatePrime() function for starting inflation at bit boundary +- Avoid some Visual C warnings in deflate.c +- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit + compile +- Fix some spelling errors in comments [Betts] +- Correct inflateInit2() error return documentation in zlib.h +- Add zran.c example of compressed data random access to examples + directory, shows use of inflatePrime() +- Fix cast for assignments to strm->state in inflate.c and infback.c +- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer] +- Move declarations of gf2 functions to right place in crc32.c [Oberhumer] +- Add cast in trees.c t avoid a warning [Oberhumer] +- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer] +- Update make_vms.com [Zinser] +- Initialize state->write in inflateReset() since copied in inflate_fast() +- Be more strict on incomplete code sets in inflate_table() and increase + ENOUGH and MAXD -- this repairs a possible security vulnerability for + invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for + discovering the vulnerability and providing test cases +- Add ia64 support to configure for HP-UX [Smith] +- Add error return to gzread() for format or i/o error [Levin] +- Use malloc.h for OS/2 [Necasek] + +Changes in 1.2.2.3 (27 May 2005) +- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile +- Typecast fread() return values in gzio.c [Vollant] +- Remove trailing space in minigzip.c outmode (VC++ can't deal with it) +- Fix crc check bug in gzread() after gzungetc() [Heiner] +- Add the deflateTune() function to adjust internal compression parameters +- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack) +- Remove an incorrect assertion in examples/zpipe.c +- Add C++ wrapper in infback9.h [Donais] +- Fix bug in inflateCopy() when decoding fixed codes +- Note in zlib.h how much deflateSetDictionary() actually uses +- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used) +- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer] +- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer] +- Add gzdirect() function to indicate transparent reads +- Update contrib/minizip [Vollant] +- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer] +- Add casts in crc32.c to avoid warnings [Oberhumer] +- Add contrib/masmx64 [Vollant] +- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant] + +Changes in 1.2.2.2 (30 December 2004) +- Replace structure assignments in deflate.c and inflate.c with zmemcpy to + avoid implicit memcpy calls (portability for no-library compilation) +- Increase sprintf() buffer size in gzdopen() to allow for large numbers +- Add INFLATE_STRICT to check distances against zlib header +- Improve WinCE errno handling and comments [Chang] +- Remove comment about no gzip header processing in FAQ +- Add Z_FIXED strategy option to deflateInit2() to force fixed trees +- Add updated make_vms.com [Coghlan], update README +- Create a new "examples" directory, move gzappend.c there, add zpipe.c, + fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html +- Add FAQ entry and comments in deflate.c on uninitialized memory access +- Add Solaris 9 make options in configure [Gilbert] +- Allow strerror() usage in gzio.c for STDC +- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer] +- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant] +- Use z_off_t for adler32_combine() and crc32_combine() lengths +- Make adler32() much faster for small len +- Use OS_CODE in deflate() default gzip header + +Changes in 1.2.2.1 (31 October 2004) +- Allow inflateSetDictionary() call for raw inflate +- Fix inflate header crc check bug for file names and comments +- Add deflateSetHeader() and gz_header structure for custom gzip headers +- Add inflateGetheader() to retrieve gzip headers +- Add crc32_combine() and adler32_combine() functions +- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list +- Use zstreamp consistently in zlib.h (inflate_back functions) +- Remove GUNZIP condition from definition of inflate_mode in inflate.h + and in contrib/inflate86/inffast.S [Truta, Anderson] +- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson] +- Update projects/README.projects and projects/visualc6 [Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta] +- Deprecate Z_ASCII; use Z_TEXT instead [Truta] +- Use a new algorithm for setting strm->data_type in trees.c [Truta] +- Do not define an exit() prototype in zutil.c unless DEBUG defined +- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta] +- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate() +- Fix Darwin build version identification [Peterson] + +Changes in 1.2.2 (3 October 2004) +- Update zlib.h comments on gzip in-memory processing +- Set adler to 1 in inflateReset() to support Java test suite [Walles] +- Add contrib/dotzlib [Ravn] +- Update win32/DLL_FAQ.txt [Truta] +- Update contrib/minizip [Vollant] +- Move contrib/visual-basic.txt to old/ [Truta] +- Fix assembler builds in projects/visualc6/ [Truta] + +Changes in 1.2.1.2 (9 September 2004) +- Update INDEX file +- Fix trees.c to update strm->data_type (no one ever noticed!) +- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown] +- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE) +- Add limited multitasking protection to DYNAMIC_CRC_TABLE +- Add NO_vsnprintf for VMS in zutil.h [Mozilla] +- Don't declare strerror() under VMS [Mozilla] +- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize +- Update contrib/ada [Anisimkov] +- Update contrib/minizip [Vollant] +- Fix configure to not hardcode directories for Darwin [Peterson] +- Fix gzio.c to not return error on empty files [Brown] +- Fix indentation; update version in contrib/delphi/ZLib.pas and + contrib/pascal/zlibpas.pas [Truta] +- Update mkasm.bat in contrib/masmx86 [Truta] +- Update contrib/untgz [Truta] +- Add projects/README.projects [Truta] +- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta] +- Update win32/DLL_FAQ.txt [Truta] +- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta] +- Remove an unnecessary assignment to curr in inftrees.c [Truta] +- Add OS/2 to exe builds in configure [Poltorak] +- Remove err dummy parameter in zlib.h [Kientzle] + +Changes in 1.2.1.1 (9 January 2004) +- Update email address in README +- Several FAQ updates +- Fix a big fat bug in inftrees.c that prevented decoding valid + dynamic blocks with only literals and no distance codes -- + Thanks to "Hot Emu" for the bug report and sample file +- Add a note to puff.c on no distance codes case + +Changes in 1.2.1 (17 November 2003) +- Remove a tab in contrib/gzappend/gzappend.c +- Update some interfaces in contrib for new zlib functions +- Update zlib version number in some contrib entries +- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta] +- Support shared libraries on Hurd and KFreeBSD [Brown] +- Fix error in NO_DIVIDE option of adler32.c + +Changes in 1.2.0.8 (4 November 2003) +- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas +- Add experimental NO_DIVIDE #define in adler32.c + - Possibly faster on some processors (let me know if it is) +- Correct Z_BLOCK to not return on first inflate call if no wrap +- Fix strm->data_type on inflate() return to correctly indicate EOB +- Add deflatePrime() function for appending in the middle of a byte +- Add contrib/gzappend for an example of appending to a stream +- Update win32/DLL_FAQ.txt [Truta] +- Delete Turbo C comment in README [Truta] +- Improve some indentation in zconf.h [Truta] +- Fix infinite loop on bad input in configure script [Church] +- Fix gzeof() for concatenated gzip files [Johnson] +- Add example to contrib/visual-basic.txt [Michael B.] +- Add -p to mkdir's in Makefile.in [vda] +- Fix configure to properly detect presence or lack of printf functions +- Add AS400 support [Monnerat] +- Add a little Cygwin support [Wilson] + +Changes in 1.2.0.7 (21 September 2003) +- Correct some debug formats in contrib/infback9 +- Cast a type in a debug statement in trees.c +- Change search and replace delimiter in configure from % to # [Beebe] +- Update contrib/untgz to 0.2 with various fixes [Truta] +- Add build support for Amiga [Nikl] +- Remove some directories in old that have been updated to 1.2 +- Add dylib building for Mac OS X in configure and Makefile.in +- Remove old distribution stuff from Makefile +- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X +- Update links in README + +Changes in 1.2.0.6 (13 September 2003) +- Minor FAQ updates +- Update contrib/minizip to 1.00 [Vollant] +- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta] +- Update POSTINC comment for 68060 [Nikl] +- Add contrib/infback9 with deflate64 decoding (unsupported) +- For MVS define NO_vsnprintf and undefine FAR [van Burik] +- Add pragma for fdopen on MVS [van Burik] + +Changes in 1.2.0.5 (8 September 2003) +- Add OF to inflateBackEnd() declaration in zlib.h +- Remember start when using gzdopen in the middle of a file +- Use internal off_t counters in gz* functions to properly handle seeks +- Perform more rigorous check for distance-too-far in inffast.c +- Add Z_BLOCK flush option to return from inflate at block boundary +- Set strm->data_type on return from inflate + - Indicate bits unused, if at block boundary, and if in last block +- Replace size_t with ptrdiff_t in crc32.c, and check for correct size +- Add condition so old NO_DEFLATE define still works for compatibility +- FAQ update regarding the Windows DLL [Truta] +- INDEX update: add qnx entry, remove aix entry [Truta] +- Install zlib.3 into mandir [Wilson] +- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta] +- Adapt the zlib interface to the new DLL convention guidelines [Truta] +- Introduce ZLIB_WINAPI macro to allow the export of functions using + the WINAPI calling convention, for Visual Basic [Vollant, Truta] +- Update msdos and win32 scripts and makefiles [Truta] +- Export symbols by name, not by ordinal, in win32/zlib.def [Truta] +- Add contrib/ada [Anisimkov] +- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta] +- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant] +- Add contrib/masm686 [Truta] +- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm + [Truta, Vollant] +- Update contrib/delphi; rename to contrib/pascal; add example [Truta] +- Remove contrib/delphi2; add a new contrib/delphi [Truta] +- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream, + and fix some method prototypes [Truta] +- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip + [Truta] +- Avoid the use of backslash (\) in contrib/minizip [Vollant] +- Fix file time handling in contrib/untgz; update makefiles [Truta] +- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines + [Vollant] +- Remove contrib/vstudio/vc15_16 [Vollant] +- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta] +- Update README.contrib [Truta] +- Invert the assignment order of match_head and s->prev[...] in + INSERT_STRING [Truta] +- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings + [Truta] +- Compare function pointers with 0, not with NULL or Z_NULL [Truta] +- Fix prototype of syncsearch in inflate.c [Truta] +- Introduce ASMINF macro to be enabled when using an ASM implementation + of inflate_fast [Truta] +- Change NO_DEFLATE to NO_GZCOMPRESS [Truta] +- Modify test_gzio in example.c to take a single file name as a + parameter [Truta] +- Exit the example.c program if gzopen fails [Truta] +- Add type casts around strlen in example.c [Truta] +- Remove casting to sizeof in minigzip.c; give a proper type + to the variable compared with SUFFIX_LEN [Truta] +- Update definitions of STDC and STDC99 in zconf.h [Truta] +- Synchronize zconf.h with the new Windows DLL interface [Truta] +- Use SYS16BIT instead of __32BIT__ to distinguish between + 16- and 32-bit platforms [Truta] +- Use far memory allocators in small 16-bit memory models for + Turbo C [Truta] +- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in + zlibCompileFlags [Truta] +- Cygwin has vsnprintf [Wilson] +- In Windows16, OS_CODE is 0, as in MSDOS [Truta] +- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson] + +Changes in 1.2.0.4 (10 August 2003) +- Minor FAQ updates +- Be more strict when checking inflateInit2's windowBits parameter +- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well +- Add gzip wrapper option to deflateInit2 using windowBits +- Add updated QNX rule in configure and qnx directory [Bonnefoy] +- Make inflate distance-too-far checks more rigorous +- Clean up FAR usage in inflate +- Add casting to sizeof() in gzio.c and minigzip.c + +Changes in 1.2.0.3 (19 July 2003) +- Fix silly error in gzungetc() implementation [Vollant] +- Update contrib/minizip and contrib/vstudio [Vollant] +- Fix printf format in example.c +- Correct cdecl support in zconf.in.h [Anisimkov] +- Minor FAQ updates + +Changes in 1.2.0.2 (13 July 2003) +- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons +- Attempt to avoid warnings in crc32.c for pointer-int conversion +- Add AIX to configure, remove aix directory [Bakker] +- Add some casts to minigzip.c +- Improve checking after insecure sprintf() or vsprintf() calls +- Remove #elif's from crc32.c +- Change leave label to inf_leave in inflate.c and infback.c to avoid + library conflicts +- Remove inflate gzip decoding by default--only enable gzip decoding by + special request for stricter backward compatibility +- Add zlibCompileFlags() function to return compilation information +- More typecasting in deflate.c to avoid warnings +- Remove leading underscore from _Capital #defines [Truta] +- Fix configure to link shared library when testing +- Add some Windows CE target adjustments [Mai] +- Remove #define ZLIB_DLL in zconf.h [Vollant] +- Add zlib.3 [Rodgers] +- Update RFC URL in deflate.c and algorithm.txt [Mai] +- Add zlib_dll_FAQ.txt to contrib [Truta] +- Add UL to some constants [Truta] +- Update minizip and vstudio [Vollant] +- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h +- Expand use of NO_DUMMY_DECL to avoid all dummy structures +- Added iostream3 to contrib [Schwardt] +- Replace rewind() with fseek() for WinCE [Truta] +- Improve setting of zlib format compression level flags + - Report 0 for huffman and rle strategies and for level == 0 or 1 + - Report 2 only for level == 6 +- Only deal with 64K limit when necessary at compile time [Truta] +- Allow TOO_FAR check to be turned off at compile time [Truta] +- Add gzclearerr() function [Souza] +- Add gzungetc() function + +Changes in 1.2.0.1 (17 March 2003) +- Add Z_RLE strategy for run-length encoding [Truta] + - When Z_RLE requested, restrict matches to distance one + - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE +- Correct FASTEST compilation to allow level == 0 +- Clean up what gets compiled for FASTEST +- Incorporate changes to zconf.in.h [Vollant] + - Refine detection of Turbo C need for dummy returns + - Refine ZLIB_DLL compilation + - Include additional header file on VMS for off_t typedef +- Try to use _vsnprintf where it supplants vsprintf [Vollant] +- Add some casts in inffast.c +- Enhance comments in zlib.h on what happens if gzprintf() tries to + write more than 4095 bytes before compression +- Remove unused state from inflateBackEnd() +- Remove exit(0) from minigzip.c, example.c +- Get rid of all those darn tabs +- Add "check" target to Makefile.in that does the same thing as "test" +- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in +- Update contrib/inflate86 [Anderson] +- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant] +- Add msdos and win32 directories with makefiles [Truta] +- More additions and improvements to the FAQ + +Changes in 1.2.0 (9 March 2003) +- New and improved inflate code + - About 20% faster + - Does not allocate 32K window unless and until needed + - Automatically detects and decompresses gzip streams + - Raw inflate no longer needs an extra dummy byte at end + - Added inflateBack functions using a callback interface--even faster + than inflate, useful for file utilities (gzip, zip) + - Added inflateCopy() function to record state for random access on + externally generated deflate streams (e.g. in gzip files) + - More readable code (I hope) +- New and improved crc32() + - About 50% faster, thanks to suggestions from Rodney Brown +- Add deflateBound() and compressBound() functions +- Fix memory leak in deflateInit2() +- Permit setting dictionary for raw deflate (for parallel deflate) +- Fix const declaration for gzwrite() +- Check for some malloc() failures in gzio.c +- Fix bug in gzopen() on single-byte file 0x1f +- Fix bug in gzread() on concatenated file with 0x1f at end of buffer + and next buffer doesn't start with 0x8b +- Fix uncompress() to return Z_DATA_ERROR on truncated input +- Free memory at end of example.c +- Remove MAX #define in trees.c (conflicted with some libraries) +- Fix static const's in deflate.c, gzio.c, and zutil.[ch] +- Declare malloc() and free() in gzio.c if STDC not defined +- Use malloc() instead of calloc() in zutil.c if int big enough +- Define STDC for AIX +- Add aix/ with approach for compiling shared library on AIX +- Add HP-UX support for shared libraries in configure +- Add OpenUNIX support for shared libraries in configure +- Use $cc instead of gcc to build shared library +- Make prefix directory if needed when installing +- Correct Macintosh avoidance of typedef Byte in zconf.h +- Correct Turbo C memory allocation when under Linux +- Use libz.a instead of -lz in Makefile (assure use of compiled library) +- Update configure to check for snprintf or vsnprintf functions and their + return value, warn during make if using an insecure function +- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that + is lost when library is used--resolution is to build new zconf.h +- Documentation improvements (in zlib.h): + - Document raw deflate and inflate + - Update RFCs URL + - Point out that zlib and gzip formats are different + - Note that Z_BUF_ERROR is not fatal + - Document string limit for gzprintf() and possible buffer overflow + - Note requirement on avail_out when flushing + - Note permitted values of flush parameter of inflate() +- Add some FAQs (and even answers) to the FAQ +- Add contrib/inflate86/ for x86 faster inflate +- Add contrib/blast/ for PKWare Data Compression Library decompression +- Add contrib/puff/ simple inflate for deflate format description + +Changes in 1.1.4 (11 March 2002) +- ZFREE was repeated on same allocation on some error conditions + This creates a security problem described in + http://www.zlib.org/advisory-2002-03-11.txt +- Returned incorrect error (Z_MEM_ERROR) on some invalid data +- Avoid accesses before window for invalid distances with inflate window + less than 32K +- force windowBits > 8 to avoid a bug in the encoder for a window size + of 256 bytes. (A complete fix will be available in 1.1.5) + +Changes in 1.1.3 (9 July 1998) +- fix "an inflate input buffer bug that shows up on rare but persistent + occasions" (Mark) +- fix gzread and gztell for concatenated .gz files (Didier Le Botlan) +- fix gzseek(..., SEEK_SET) in write mode +- fix crc check after a gzeek (Frank Faubert) +- fix miniunzip when the last entry in a zip file is itself a zip file + (J Lillge) +- add contrib/asm586 and contrib/asm686 (Brian Raiter) + See http://www.muppetlabs.com/~breadbox/software/assembly.html +- add support for Delphi 3 in contrib/delphi (Bob Dellaca) +- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti) +- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren) +- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks) +- added a FAQ file + +- Support gzdopen on Mac with Metrowerks (Jason Linhart) +- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart) +- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young) +- avoid some warnings with Borland C (Tom Tanner) +- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant) +- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant) +- allow several arguments to configure (Tim Mooney, Frodo Looijaard) +- use libdir and includedir in Makefile.in (Tim Mooney) +- support shared libraries on OSF1 V4 (Tim Mooney) +- remove so_locations in "make clean" (Tim Mooney) +- fix maketree.c compilation error (Glenn, Mark) +- Python interface to zlib now in Python 1.5 (Jeremy Hylton) +- new Makefile.riscos (Rich Walker) +- initialize static descriptors in trees.c for embedded targets (Nick Smith) +- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith) +- add the OS/2 files in Makefile.in too (Andrew Zabolotny) +- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane) +- fix maketree.c to allow clean compilation of inffixed.h (Mark) +- fix parameter check in deflateCopy (Gunther Nikl) +- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler) +- Many portability patches by Christian Spieler: + . zutil.c, zutil.h: added "const" for zmem* + . Make_vms.com: fixed some typos + . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists + . msdos/Makefile.msc: remove "default rtl link library" info from obj files + . msdos/Makefile.*: use model-dependent name for the built zlib library + . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc: + new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT) +- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane) +- replace __far with _far for better portability (Christian Spieler, Tom Lane) +- fix test for errno.h in configure (Tim Newsham) + +Changes in 1.1.2 (19 March 98) +- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant) + See http://www.winimage.com/zLibDll/unzip.html +- preinitialize the inflate tables for fixed codes, to make the code + completely thread safe (Mark) +- some simplifications and slight speed-up to the inflate code (Mark) +- fix gzeof on non-compressed files (Allan Schrum) +- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs) +- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn) +- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny) +- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori) +- do not wrap extern "C" around system includes (Tom Lane) +- mention zlib binding for TCL in README (Andreas Kupries) +- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert) +- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson) +- allow "configure --prefix $HOME" (Tim Mooney) +- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson) +- move Makefile.sas to amiga/Makefile.sas + +Changes in 1.1.1 (27 Feb 98) +- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson) +- remove block truncation heuristic which had very marginal effect for zlib + (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the + compression ratio on some files. This also allows inlining _tr_tally for + matches in deflate_slow +- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier) + +Changes in 1.1.0 (24 Feb 98) +- do not return STREAM_END prematurely in inflate (John Bowler) +- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler) +- compile with -DFASTEST to get compression code optimized for speed only +- in minigzip, try mmap'ing the input file first (Miguel Albrecht) +- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain + on Sun but significant on HP) + +- add a pointer to experimental unzip library in README (Gilles Vollant) +- initialize variable gcc in configure (Chris Herborth) + +Changes in 1.0.9 (17 Feb 1998) +- added gzputs and gzgets functions +- do not clear eof flag in gzseek (Mark Diekhans) +- fix gzseek for files in transparent mode (Mark Diekhans) +- do not assume that vsprintf returns the number of bytes written (Jens Krinke) +- replace EXPORT with ZEXPORT to avoid conflict with other programs +- added compress2 in zconf.h, zlib.def, zlib.dnt +- new asm code from Gilles Vollant in contrib/asm386 +- simplify the inflate code (Mark): + . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new() + . ZALLOC the length list in inflate_trees_fixed() instead of using stack + . ZALLOC the value area for huft_build() instead of using stack + . Simplify Z_FINISH check in inflate() + +- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8 +- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi) +- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with + the declaration of FAR (Gilles Vollant) +- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann) +- read_buf buf parameter of type Bytef* instead of charf* +- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout) +- do not redeclare unlink in minigzip.c for WIN32 (John Bowler) +- fix check for presence of directories in "make install" (Ian Willis) + +Changes in 1.0.8 (27 Jan 1998) +- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant) +- fix gzgetc and gzputc for big endian systems (Markus Oberhumer) +- added compress2() to allow setting the compression level +- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong) +- use constant arrays for the static trees in trees.c instead of computing + them at run time (thanks to Ken Raeburn for this suggestion). To create + trees.h, compile with GEN_TREES_H and run "make test" +- check return code of example in "make test" and display result +- pass minigzip command line options to file_compress +- simplifying code of inflateSync to avoid gcc 2.8 bug + +- support CC="gcc -Wall" in configure -s (QingLong) +- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn) +- fix test for shared library support to avoid compiler warnings +- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant) +- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit) +- do not use fdopen for Metrowerks on Mac (Brad Pettit)) +- add checks for gzputc and gzputc in example.c +- avoid warnings in gzio.c and deflate.c (Andreas Kleinert) +- use const for the CRC table (Ken Raeburn) +- fixed "make uninstall" for shared libraries +- use Tracev instead of Trace in infblock.c +- in example.c use correct compressed length for test_sync +- suppress +vnocompatwarnings in configure for HPUX (not always supported) + +Changes in 1.0.7 (20 Jan 1998) +- fix gzseek which was broken in write mode +- return error for gzseek to negative absolute position +- fix configure for Linux (Chun-Chung Chen) +- increase stack space for MSC (Tim Wegner) +- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant) +- define EXPORTVA for gzprintf (Gilles Vollant) +- added man page zlib.3 (Rick Rodgers) +- for contrib/untgz, fix makedir() and improve Makefile + +- check gzseek in write mode in example.c +- allocate extra buffer for seeks only if gzseek is actually called +- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant) +- add inflateSyncPoint in zconf.h +- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def + +Changes in 1.0.6 (19 Jan 1998) +- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and + gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code) +- Fix a deflate bug occurring only with compression level 0 (thanks to + Andy Buckler for finding this one) +- In minigzip, pass transparently also the first byte for .Z files +- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress() +- check Z_FINISH in inflate (thanks to Marc Schluper) +- Implement deflateCopy (thanks to Adam Costello) +- make static libraries by default in configure, add --shared option +- move MSDOS or Windows specific files to directory msdos +- suppress the notion of partial flush to simplify the interface + (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4) +- suppress history buffer provided by application to simplify the interface + (this feature was not implemented anyway in 1.0.4) +- next_in and avail_in must be initialized before calling inflateInit or + inflateInit2 +- add EXPORT in all exported functions (for Windows DLL) +- added Makefile.nt (thanks to Stephen Williams) +- added the unsupported "contrib" directory: + contrib/asm386/ by Gilles Vollant <info@winimage.com> + 386 asm code replacing longest_match() + contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu> + A C++ I/O streams interface to the zlib gz* functions + contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no> + Another C++ I/O streams interface + contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es> + A very simple tar.gz file extractor using zlib + contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl> + How to use compress(), uncompress() and the gz* functions from VB +- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression + level) in minigzip (thanks to Tom Lane) + +- use const for rommable constants in deflate +- added test for gzseek and gztell in example.c +- add undocumented function inflateSyncPoint() (hack for Paul Mackerras) +- add undocumented function zError to convert error code to string + (for Tim Smithers) +- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code +- Use default memcpy for Symantec MSDOS compiler +- Add EXPORT keyword for check_func (needed for Windows DLL) +- add current directory to LD_LIBRARY_PATH for "make test" +- create also a link for libz.so.1 +- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura) +- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX) +- added -soname for Linux in configure (Chun-Chung Chen, +- assign numbers to the exported functions in zlib.def (for Windows DLL) +- add advice in zlib.h for best usage of deflateSetDictionary +- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn) +- allow compilation with ANSI keywords only enabled for TurboC in large model +- avoid "versionString"[0] (Borland bug) +- add NEED_DUMMY_RETURN for Borland +- use variable z_verbose for tracing in debug mode (L. Peter Deutsch) +- allow compilation with CC +- defined STDC for OS/2 (David Charlap) +- limit external names to 8 chars for MVS (Thomas Lund) +- in minigzip.c, use static buffers only for 16-bit systems +- fix suffix check for "minigzip -d foo.gz" +- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee) +- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau) +- added makelcc.bat for lcc-win32 (Tom St Denis) +- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe) +- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion +- check for unistd.h in configure (for off_t) +- remove useless check parameter in inflate_blocks_free +- avoid useless assignment of s->check to itself in inflate_blocks_new +- do not flush twice in gzclose (thanks to Ken Raeburn) +- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h +- use NO_ERRNO_H instead of enumeration of operating systems with errno.h +- work around buggy fclose on pipes for HP/UX +- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson) +- fix configure if CC is already equal to gcc + +Changes in 1.0.5 (3 Jan 98) +- Fix inflate to terminate gracefully when fed corrupted or invalid data +- Use const for rommable constants in inflate +- Eliminate memory leaks on error conditions in inflate +- Removed some vestigial code in inflate +- Update web address in README + +Changes in 1.0.4 (24 Jul 96) +- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF + bit, so the decompressor could decompress all the correct data but went + on to attempt decompressing extra garbage data. This affected minigzip too +- zlibVersion and gzerror return const char* (needed for DLL) +- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno) +- use z_error only for DEBUG (avoid problem with DLLs) + +Changes in 1.0.3 (2 Jul 96) +- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS + small and medium models; this makes the library incompatible with previous + versions for these models. (No effect in large model or on other systems.) +- return OK instead of BUF_ERROR if previous deflate call returned with + avail_out as zero but there is nothing to do +- added memcmp for non STDC compilers +- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly) +- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO) +- better check for 16-bit mode MSC (avoids problem with Symantec) + +Changes in 1.0.2 (23 May 96) +- added Windows DLL support +- added a function zlibVersion (for the DLL support) +- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model) +- Bytef is define's instead of typedef'd only for Borland C +- avoid reading uninitialized memory in example.c +- mention in README that the zlib format is now RFC1950 +- updated Makefile.dj2 +- added algorithm.doc + +Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion] +- fix array overlay in deflate.c which sometimes caused bad compressed data +- fix inflate bug with empty stored block +- fix MSDOS medium model which was broken in 0.99 +- fix deflateParams() which could generate bad compressed data +- Bytef is define'd instead of typedef'ed (work around Borland bug) +- added an INDEX file +- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32), + Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas) +- speed up adler32 for modern machines without auto-increment +- added -ansi for IRIX in configure +- static_init_done in trees.c is an int +- define unlink as delete for VMS +- fix configure for QNX +- add configure branch for SCO and HPUX +- avoid many warnings (unused variables, dead assignments, etc...) +- no fdopen for BeOS +- fix the Watcom fix for 32 bit mode (define FAR as empty) +- removed redefinition of Byte for MKWERKS +- work around an MWKERKS bug (incorrect merge of all .h files) + +Changes in 0.99 (27 Jan 96) +- allow preset dictionary shared between compressor and decompressor +- allow compression level 0 (no compression) +- add deflateParams in zlib.h: allow dynamic change of compression level + and compression strategy +- test large buffers and deflateParams in example.c +- add optional "configure" to build zlib as a shared library +- suppress Makefile.qnx, use configure instead +- fixed deflate for 64-bit systems (detected on Cray) +- fixed inflate_blocks for 64-bit systems (detected on Alpha) +- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2) +- always return Z_BUF_ERROR when deflate() has nothing to do +- deflateInit and inflateInit are now macros to allow version checking +- prefix all global functions and types with z_ with -DZ_PREFIX +- make falloc completely reentrant (inftrees.c) +- fixed very unlikely race condition in ct_static_init +- free in reverse order of allocation to help memory manager +- use zlib-1.0/* instead of zlib/* inside the tar.gz +- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith + -Wconversion -Wstrict-prototypes -Wmissing-prototypes" +- allow gzread on concatenated .gz files +- deflateEnd now returns Z_DATA_ERROR if it was premature +- deflate is finally (?) fully deterministic (no matches beyond end of input) +- Document Z_SYNC_FLUSH +- add uninstall in Makefile +- Check for __cpluplus in zlib.h +- Better test in ct_align for partial flush +- avoid harmless warnings for Borland C++ +- initialize hash_head in deflate.c +- avoid warning on fdopen (gzio.c) for HP cc -Aa +- include stdlib.h for STDC compilers +- include errno.h for Cray +- ignore error if ranlib doesn't exist +- call ranlib twice for NeXTSTEP +- use exec_prefix instead of prefix for libz.a +- renamed ct_* as _tr_* to avoid conflict with applications +- clear z->msg in inflateInit2 before any error return +- initialize opaque in example.c, gzio.c, deflate.c and inflate.c +- fixed typo in zconf.h (_GNUC__ => __GNUC__) +- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode) +- fix typo in Make_vms.com (f$trnlnm -> f$getsyi) +- in fcalloc, normalize pointer if size > 65520 bytes +- don't use special fcalloc for 32 bit Borland C++ +- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc. +- use Z_BINARY instead of BINARY +- document that gzclose after gzdopen will close the file +- allow "a" as mode in gzopen +- fix error checking in gzread +- allow skipping .gz extra-field on pipes +- added reference to Perl interface in README +- put the crc table in FAR data (I dislike more and more the medium model :) +- added get_crc_table +- added a dimension to all arrays (Borland C can't count) +- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast +- guard against multiple inclusion of *.h (for precompiled header on Mac) +- Watcom C pretends to be Microsoft C small model even in 32 bit mode +- don't use unsized arrays to avoid silly warnings by Visual C++: + warning C4746: 'inflate_mask' : unsized array treated as '__far' + (what's wrong with far data in far model?) +- define enum out of inflate_blocks_state to allow compilation with C++ + +Changes in 0.95 (16 Aug 95) +- fix MSDOS small and medium model (now easier to adapt to any compiler) +- inlined send_bits +- fix the final (:-) bug for deflate with flush (output was correct but + not completely flushed in rare occasions) +- default window size is same for compression and decompression + (it's now sufficient to set MAX_WBITS in zconf.h) +- voidp -> voidpf and voidnp -> voidp (for consistency with other + typedefs and because voidnp was not near in large model) + +Changes in 0.94 (13 Aug 95) +- support MSDOS medium model +- fix deflate with flush (could sometimes generate bad output) +- fix deflateReset (zlib header was incorrectly suppressed) +- added support for VMS +- allow a compression level in gzopen() +- gzflush now calls fflush +- For deflate with flush, flush even if no more input is provided +- rename libgz.a as libz.a +- avoid complex expression in infcodes.c triggering Turbo C bug +- work around a problem with gcc on Alpha (in INSERT_STRING) +- don't use inline functions (problem with some gcc versions) +- allow renaming of Byte, uInt, etc... with #define +- avoid warning about (unused) pointer before start of array in deflate.c +- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c +- avoid reserved word 'new' in trees.c + +Changes in 0.93 (25 June 95) +- temporarily disable inline functions +- make deflate deterministic +- give enough lookahead for PARTIAL_FLUSH +- Set binary mode for stdin/stdout in minigzip.c for OS/2 +- don't even use signed char in inflate (not portable enough) +- fix inflate memory leak for segmented architectures + +Changes in 0.92 (3 May 95) +- don't assume that char is signed (problem on SGI) +- Clear bit buffer when starting a stored block +- no memcpy on Pyramid +- suppressed inftest.c +- optimized fill_window, put longest_match inline for gcc +- optimized inflate on stored blocks +- untabify all sources to simplify patches + +Changes in 0.91 (2 May 95) +- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h +- Document the memory requirements in zconf.h +- added "make install" +- fix sync search logic in inflateSync +- deflate(Z_FULL_FLUSH) now works even if output buffer too short +- after inflateSync, don't scare people with just "lo world" +- added support for DJGPP + +Changes in 0.9 (1 May 95) +- don't assume that zalloc clears the allocated memory (the TurboC bug + was Mark's bug after all :) +- let again gzread copy uncompressed data unchanged (was working in 0.71) +- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented +- added a test of inflateSync in example.c +- moved MAX_WBITS to zconf.h because users might want to change that +- document explicitly that zalloc(64K) on MSDOS must return a normalized + pointer (zero offset) +- added Makefiles for Microsoft C, Turbo C, Borland C++ +- faster crc32() + +Changes in 0.8 (29 April 95) +- added fast inflate (inffast.c) +- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this + is incompatible with previous versions of zlib which returned Z_OK +- work around a TurboC compiler bug (bad code for b << 0, see infutil.h) + (actually that was not a compiler bug, see 0.81 above) +- gzread no longer reads one extra byte in certain cases +- In gzio destroy(), don't reference a freed structure +- avoid many warnings for MSDOS +- avoid the ERROR symbol which is used by MS Windows + +Changes in 0.71 (14 April 95) +- Fixed more MSDOS compilation problems :( There is still a bug with + TurboC large model + +Changes in 0.7 (14 April 95) +- Added full inflate support +- Simplified the crc32() interface. The pre- and post-conditioning + (one's complement) is now done inside crc32(). WARNING: this is + incompatible with previous versions; see zlib.h for the new usage + +Changes in 0.61 (12 April 95) +- workaround for a bug in TurboC. example and minigzip now work on MSDOS + +Changes in 0.6 (11 April 95) +- added minigzip.c +- added gzdopen to reopen a file descriptor as gzFile +- added transparent reading of non-gziped files in gzread +- fixed bug in gzread (don't read crc as data) +- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose) +- don't allocate big arrays in the stack (for MSDOS) +- fix some MSDOS compilation problems + +Changes in 0.5: +- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but + not yet Z_FULL_FLUSH +- support decompression but only in a single step (forced Z_FINISH) +- added opaque object for zalloc and zfree +- added deflateReset and inflateReset +- added a variable zlib_version for consistency checking +- renamed the 'filter' parameter of deflateInit2 as 'strategy' + Added Z_FILTERED and Z_HUFFMAN_ONLY constants + +Changes in 0.4: +- avoid "zip" everywhere, use zlib instead of ziplib +- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush + if compression method == 8 +- added adler32 and crc32 +- renamed deflateOptions as deflateInit2, call one or the other but not both +- added the method parameter for deflateInit2 +- added inflateInit2 +- simplified considerably deflateInit and inflateInit by not supporting + user-provided history buffer. This is supported only in deflateInit2 + and inflateInit2 + +Changes in 0.3: +- prefix all macro names with Z_ +- use Z_FINISH instead of deflateEnd to finish compression +- added Z_HUFFMAN_ONLY +- added gzerror() diff --git a/src/Common/zlib/README b/src/Common/zlib/README index ba34d189..c5f91754 100644 --- a/src/Common/zlib/README +++ b/src/Common/zlib/README @@ -1,117 +1,116 @@ ZLIB DATA COMPRESSION LIBRARY -zlib 1.2.13 is a general purpose data compression library. All the code is +zlib 1.3.1 is a general purpose data compression library. All the code is thread safe. The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). All functions of the compression library are documented in the file zlib.h (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example of the library is given in the file test/example.c which also tests that the library is working correctly. Another example is given in the file test/minigzip.c. The compression library itself is composed of all source files in the root directory. To compile all files and run the test program, follow the instructions given at the top of Makefile.in. In short "./configure; make test", and if that goes well, "make install" should work for most flavors of Unix. For Windows, use one of the special makefiles in win32/ or contrib/vstudio/ . For VMS, use make_vms.com. Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant <info@winimage.com> for the Windows DLL version. The zlib home page is http://zlib.net/ . Before reporting a problem, please check this site to verify that you have the latest version of zlib; otherwise get the latest version and check whether the problem still exists or not. PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help. Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997 issue of Dr. Dobb's Journal; a copy of the article is available at -http://marknelson.us/1997/01/01/zlib-engine/ . +https://marknelson.us/posts/1997/01/01/zlib-engine.html . -The changes made in version 1.2.13 are documented in the file ChangeLog. +The changes made in version 1.3.1 are documented in the file ChangeLog. Unsupported third party contributions are provided in directory contrib/ . -zlib is available in Java using the java.util.zip package, documented at -http://java.sun.com/developer/technicalArticles/Programming/compression/ . +zlib is available in Java using the java.util.zip package. Follow the API +Documentation link at: https://docs.oracle.com/search/?q=java.util.zip . -A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available -at CPAN (Comprehensive Perl Archive Network) sites, including -http://search.cpan.org/~pmqs/IO-Compress-Zlib/ . +A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org> +can be found at https://github.com/pmqs/IO-Compress . A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is available in Python 1.5 and later versions, see http://docs.python.org/library/zlib.html . zlib is built into tcl: http://wiki.tcl.tk/4610 . An experimental package to read and write files in .zip format, written on top of zlib by Gilles Vollant <info@winimage.com>, is available in the contrib/minizip directory of zlib. Notes for some targets: - For Windows DLL versions, please see win32/DLL_FAQ.txt - For 64-bit Irix, deflate.c must be compiled without any optimization. With -O, one libpng test fails. The test works in 32 bit mode (with the -n32 compiler flag). The compiler bug has been reported to SGI. - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works when compiled with cc. -- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is +- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is necessary to get gzprintf working correctly. This is done by configure. - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with other compilers. Use "make test" to check your compiler. - gzdopen is not supported on RISCOS or BEOS. - For PalmOs, see http://palmzlib.sourceforge.net/ Acknowledgments: The deflate format used by zlib was defined by Phil Katz. The deflate and zlib specifications were written by L. Peter Deutsch. Thanks to all the people who reported problems and suggested various improvements in zlib; they are too numerous to cite here. Copyright notice: - (C) 1995-2022 Jean-loup Gailly and Mark Adler + (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu If you use the zlib library in a product, we would appreciate *not* receiving lengthy legal documents to sign. The sources are provided for free but without warranty of any kind. The library has been entirely written by Jean-loup Gailly and Mark Adler; it does not include third-party code. We make all contributions to and distributions of this project solely in our personal capacity, and are not conveying any rights to any intellectual property of any third parties. If you redistribute modified sources, we would appreciate that you include in the file ChangeLog history information documenting your changes. Please read diff --git a/src/Common/zlib/adler32.c b/src/Common/zlib/adler32.c index d0be4380..04b81d29 100644 --- a/src/Common/zlib/adler32.c +++ b/src/Common/zlib/adler32.c @@ -1,97 +1,91 @@ /* adler32.c -- compute the Adler-32 checksum of a data stream * Copyright (C) 1995-2011, 2016 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" -local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2)); - #define BASE 65521U /* largest prime smaller than 65536 */ #define NMAX 5552 /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ #define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;} #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); #define DO16(buf) DO8(buf,0); DO8(buf,8); /* use NO_DIVIDE if your processor does not do division in hardware -- try it both ways to see which is faster */ #ifdef NO_DIVIDE /* note that this assumes BASE is 65521, where 65536 % 65521 == 15 (thank you to John Reiser for pointing this out) */ # define CHOP(a) \ do { \ unsigned long tmp = a >> 16; \ a &= 0xffffUL; \ a += (tmp << 4) - tmp; \ } while (0) # define MOD28(a) \ do { \ CHOP(a); \ if (a >= BASE) a -= BASE; \ } while (0) # define MOD(a) \ do { \ CHOP(a); \ MOD28(a); \ } while (0) # define MOD63(a) \ do { /* this assumes a is not negative */ \ z_off64_t tmp = a >> 32; \ a &= 0xffffffffL; \ a += (tmp << 8) - (tmp << 5) + tmp; \ tmp = a >> 16; \ a &= 0xffffL; \ a += (tmp << 4) - tmp; \ tmp = a >> 16; \ a &= 0xffffL; \ a += (tmp << 4) - tmp; \ if (a >= BASE) a -= BASE; \ } while (0) #else # define MOD(a) a %= BASE # define MOD28(a) a %= BASE # define MOD63(a) a %= BASE #endif /* ========================================================================= */ -uLong ZEXPORT adler32_z(adler, buf, len) - uLong adler; - const Bytef *buf; - z_size_t len; -{ +uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) { unsigned long sum2; unsigned n; /* split Adler-32 into component sums */ sum2 = (adler >> 16) & 0xffff; adler &= 0xffff; /* in case user likes doing a byte at a time, keep it fast */ if (len == 1) { adler += buf[0]; if (adler >= BASE) adler -= BASE; sum2 += adler; if (sum2 >= BASE) sum2 -= BASE; return adler | (sum2 << 16); } /* initial Adler-32 value (deferred check for len == 1 speed) */ if (buf == Z_NULL) return 1L; /* in case short lengths are provided, keep it somewhat fast */ if (len < 16) { while (len--) { adler += *buf++; sum2 += adler; } if (adler >= BASE) adler -= BASE; @@ -104,83 +98,67 @@ uLong ZEXPORT adler32_z(adler, buf, len) len -= NMAX; n = NMAX / 16; /* NMAX is divisible by 16 */ do { DO16(buf); /* 16 sums unrolled */ buf += 16; } while (--n); MOD(adler); MOD(sum2); } /* do remaining bytes (less than NMAX, still just one modulo) */ if (len) { /* avoid modulos if none remaining */ while (len >= 16) { len -= 16; DO16(buf); buf += 16; } while (len--) { adler += *buf++; sum2 += adler; } MOD(adler); MOD(sum2); } /* return recombined sums */ return adler | (sum2 << 16); } /* ========================================================================= */ -uLong ZEXPORT adler32(adler, buf, len) - uLong adler; - const Bytef *buf; - uInt len; -{ +uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) { return adler32_z(adler, buf, len); } /* ========================================================================= */ -local uLong adler32_combine_(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) { unsigned long sum1; unsigned long sum2; unsigned rem; /* for negative len, return invalid adler32 as a clue for debugging */ if (len2 < 0) return 0xffffffffUL; /* the derivation of this formula is left as an exercise for the reader */ MOD63(len2); /* assumes len2 >= 0 */ rem = (unsigned)len2; sum1 = adler1 & 0xffff; sum2 = rem * sum1; MOD(sum2); sum1 += (adler2 & 0xffff) + BASE - 1; sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem; if (sum1 >= BASE) sum1 -= BASE; if (sum1 >= BASE) sum1 -= BASE; if (sum2 >= ((unsigned long)BASE << 1)) sum2 -= ((unsigned long)BASE << 1); if (sum2 >= BASE) sum2 -= BASE; return sum1 | (sum2 << 16); } /* ========================================================================= */ -uLong ZEXPORT adler32_combine(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off_t len2; -{ +uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) { return adler32_combine_(adler1, adler2, len2); } -uLong ZEXPORT adler32_combine64(adler1, adler2, len2) - uLong adler1; - uLong adler2; - z_off64_t len2; -{ +uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) { return adler32_combine_(adler1, adler2, len2); } diff --git a/src/Common/zlib/compress.c b/src/Common/zlib/compress.c index 2ad5326c..f43bacf7 100644 --- a/src/Common/zlib/compress.c +++ b/src/Common/zlib/compress.c @@ -1,86 +1,75 @@ /* compress.c -- compress a memory buffer * Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" /* =========================================================================== Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least 0.1% larger than sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -int ZEXPORT compress2(dest, destLen, source, sourceLen, level) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; - int level; -{ +int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen, int level) { z_stream stream; int err; const uInt max = (uInt)-1; uLong left; left = *destLen; *destLen = 0; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; stream.opaque = (voidpf)0; err = deflateInit(&stream, level); if (err != Z_OK) return err; stream.next_out = dest; stream.avail_out = 0; stream.next_in = (z_const Bytef *)source; stream.avail_in = 0; do { if (stream.avail_out == 0) { stream.avail_out = left > (uLong)max ? max : (uInt)left; left -= stream.avail_out; } if (stream.avail_in == 0) { stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen; sourceLen -= stream.avail_in; } err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH); } while (err == Z_OK); *destLen = stream.total_out; deflateEnd(&stream); return err == Z_STREAM_END ? Z_OK : err; } /* =========================================================================== */ -int ZEXPORT compress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); } /* =========================================================================== If the default memLevel or windowBits for deflateInit() is changed, then this function needs to be updated. */ -uLong ZEXPORT compressBound(sourceLen) - uLong sourceLen; -{ +uLong ZEXPORT compressBound(uLong sourceLen) { return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13; } diff --git a/src/Common/zlib/crc32.c b/src/Common/zlib/crc32.c index f8357b08..6c38f5c0 100644 --- a/src/Common/zlib/crc32.c +++ b/src/Common/zlib/crc32.c @@ -76,238 +76,265 @@ # define W Z_TESTW # endif #else # ifdef MAKECRCH # define W 8 /* required for MAKECRCH */ # else # if defined(__x86_64__) || defined(__aarch64__) # define W 8 # else # define W 4 # endif # endif #endif #ifdef W # if W == 8 && defined(Z_U8) typedef Z_U8 z_word_t; # elif defined(Z_U4) # undef W # define W 4 typedef Z_U4 z_word_t; # else # undef W # endif #endif /* If available, use the ARM processor CRC32 instruction. */ #if defined(__aarch64__) && defined(__ARM_FEATURE_CRC32) && W == 8 # define ARMCRC32 #endif -/* Local functions. */ -local z_crc_t multmodp OF((z_crc_t a, z_crc_t b)); -local z_crc_t x2nmodp OF((z_off64_t n, unsigned k)); - -#if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) - local z_word_t byte_swap OF((z_word_t word)); -#endif - -#if defined(W) && !defined(ARMCRC32) - local z_crc_t crc_word OF((z_word_t data)); - local z_word_t crc_word_big OF((z_word_t data)); -#endif - #if defined(W) && (!defined(ARMCRC32) || defined(DYNAMIC_CRC_TABLE)) /* Swap the bytes in a z_word_t to convert between little and big endian. Any self-respecting compiler will optimize this to a single machine byte-swap instruction, if one is available. This assumes that word_t is either 32 bits or 64 bits. */ -local z_word_t byte_swap(word) - z_word_t word; -{ +local z_word_t byte_swap(z_word_t word) { # if W == 8 return (word & 0xff00000000000000) >> 56 | (word & 0xff000000000000) >> 40 | (word & 0xff0000000000) >> 24 | (word & 0xff00000000) >> 8 | (word & 0xff000000) << 8 | (word & 0xff0000) << 24 | (word & 0xff00) << 40 | (word & 0xff) << 56; # else /* W == 4 */ return (word & 0xff000000) >> 24 | (word & 0xff0000) >> 8 | (word & 0xff00) << 8 | (word & 0xff) << 24; # endif } #endif +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Table of powers of x for combining CRC-32s, filled in by make_crc_table() + * below. + */ + local z_crc_t FAR x2n_table[32]; +#else +/* ========================================================================= + * Tables for byte-wise and braided CRC-32 calculations, and a table of powers + * of x for combining CRC-32s, all made by make_crc_table(). + */ +# include "crc32.h" +#endif + /* CRC polynomial. */ #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ -#ifdef DYNAMIC_CRC_TABLE +/* + Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, + reflected. For speed, this requires that a not be zero. + */ +local z_crc_t multmodp(z_crc_t a, z_crc_t b) { + z_crc_t m, p; + + m = (z_crc_t)1 << 31; + p = 0; + for (;;) { + if (a & m) { + p ^= b; + if ((a & (m - 1)) == 0) + break; + } + m >>= 1; + b = b & 1 ? (b >> 1) ^ POLY : b >> 1; + } + return p; +} +/* + Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been + initialized. + */ +local z_crc_t x2nmodp(z_off64_t n, unsigned k) { + z_crc_t p; + + p = (z_crc_t)1 << 31; /* x^0 == 1 */ + while (n) { + if (n & 1) + p = multmodp(x2n_table[k & 31], p); + n >>= 1; + k++; + } + return p; +} + +#ifdef DYNAMIC_CRC_TABLE +/* ========================================================================= + * Build the tables for byte-wise and braided CRC-32 calculations, and a table + * of powers of x for combining CRC-32s. + */ local z_crc_t FAR crc_table[256]; -local z_crc_t FAR x2n_table[32]; -local void make_crc_table OF((void)); #ifdef W local z_word_t FAR crc_big_table[256]; local z_crc_t FAR crc_braid_table[W][256]; local z_word_t FAR crc_braid_big_table[W][256]; - local void braid OF((z_crc_t [][256], z_word_t [][256], int, int)); + local void braid(z_crc_t [][256], z_word_t [][256], int, int); #endif #ifdef MAKECRCH - local void write_table OF((FILE *, const z_crc_t FAR *, int)); - local void write_table32hi OF((FILE *, const z_word_t FAR *, int)); - local void write_table64 OF((FILE *, const z_word_t FAR *, int)); + local void write_table(FILE *, const z_crc_t FAR *, int); + local void write_table32hi(FILE *, const z_word_t FAR *, int); + local void write_table64(FILE *, const z_word_t FAR *, int); #endif /* MAKECRCH */ /* Define a once() function depending on the availability of atomics. If this is compiled with DYNAMIC_CRC_TABLE defined, and if CRCs will be computed in multiple threads, and if atomics are not available, then get_crc_table() must be called to initialize the tables and must return before any threads are allowed to compute or combine CRCs. */ /* Definition of once functionality. */ typedef struct once_s once_t; -local void once OF((once_t *, void (*)(void))); /* Check for the availability of atomics. */ #if defined(__STDC__) && __STDC_VERSION__ >= 201112L && \ !defined(__STDC_NO_ATOMICS__) #include <stdatomic.h> /* Structure for once(), which must be initialized with ONCE_INIT. */ struct once_s { atomic_flag begun; atomic_int done; }; #define ONCE_INIT {ATOMIC_FLAG_INIT, 0} /* Run the provided init() function exactly once, even if multiple threads invoke once() at the same time. The state must be a once_t initialized with ONCE_INIT. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!atomic_load(&state->done)) { if (atomic_flag_test_and_set(&state->begun)) while (!atomic_load(&state->done)) ; else { init(); atomic_store(&state->done, 1); } } } #else /* no atomics */ /* Structure for once(), which must be initialized with ONCE_INIT. */ struct once_s { volatile int begun; volatile int done; }; #define ONCE_INIT {0, 0} /* Test and set. Alas, not atomic, but tries to minimize the period of vulnerability. */ -local int test_and_set OF((int volatile *)); -local int test_and_set(flag) - int volatile *flag; -{ +local int test_and_set(int volatile *flag) { int was; was = *flag; *flag = 1; return was; } /* Run the provided init() function once. This is not thread-safe. */ -local void once(state, init) - once_t *state; - void (*init)(void); -{ +local void once(once_t *state, void (*init)(void)) { if (!state->done) { if (test_and_set(&state->begun)) while (!state->done) ; else { init(); state->done = 1; } } } #endif /* State for once(). */ local once_t made = ONCE_INIT; /* Generate tables for a byte-wise 32-bit CRC calculation on the polynomial: x^32+x^26+x^23+x^22+x^16+x^12+x^11+x^10+x^8+x^7+x^5+x^4+x^2+x+1. Polynomials over GF(2) are represented in binary, one bit per coefficient, with the lowest powers in the most significant bit. Then adding polynomials is just exclusive-or, and multiplying a polynomial by x is a right shift by one. If we call the above polynomial p, and represent a byte as the polynomial q, also with the lowest power in the most significant bit (so the byte 0xb1 is the polynomial x^7+x^3+x^2+1), then the CRC is (q*x^32) mod p, where a mod b means the remainder after dividing a by b. This calculation is done using the shift-register method of multiplying and taking the remainder. The register is initialized to zero, and for each incoming bit, x^32 is added mod p to the register if the bit is a one (where x^32 mod p is p+x^32 = x^26+...+1), and the register is multiplied mod p by x (which is shifting right by one and adding x^32 mod p if the bit shifted out is a one). We start with the highest power (least significant bit) of q and repeat for all eight bits of q. The table is simply the CRC of all possible eight bit values. This is all the information needed to generate CRCs on data a byte at a time for all combinations of CRC register values and incoming bytes. */ -local void make_crc_table() -{ +local void make_crc_table(void) { unsigned i, j, n; z_crc_t p; /* initialize the CRC of bytes tables */ for (i = 0; i < 256; i++) { p = i; for (j = 0; j < 8; j++) p = p & 1 ? (p >> 1) ^ POLY : p >> 1; crc_table[i] = p; #ifdef W crc_big_table[i] = byte_swap(p); #endif } /* initialize the x^2^n mod p(x) table */ p = (z_crc_t)1 << 30; /* x^1 */ x2n_table[0] = p; for (n = 1; n < 32; n++) x2n_table[n] = p = multmodp(p, p); #ifdef W /* initialize the braiding tables -- needs x2n_table[] */ braid(crc_braid_table, crc_braid_big_table, N, W); #endif #ifdef MAKECRCH { /* The crc32.h header file contains tables for both 32-bit and 64-bit z_word_t's, and so requires a 64-bit type be available. In that case, @@ -420,237 +447,160 @@ local void make_crc_table() fprintf(out, "};\n" "\n" "#endif\n" "\n" "#endif\n"); } fprintf(out, "\n" "#endif\n"); /* write out zeros operator table to crc32.h */ fprintf(out, "\n" "local const z_crc_t FAR x2n_table[] = {\n" " "); write_table(out, x2n_table, 32); fprintf(out, "};\n"); fclose(out); } #endif /* MAKECRCH */ } #ifdef MAKECRCH /* Write the 32-bit values in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table(out, table, k) - FILE *out; - const z_crc_t FAR *table; - int k; -{ +local void write_table(FILE *out, const z_crc_t FAR *table, int k) { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", (unsigned long)(table[n]), n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); } /* Write the high 32-bits of each value in table[0..k-1] to out, five per line in hexadecimal separated by commas. */ -local void write_table32hi(out, table, k) -FILE *out; -const z_word_t FAR *table; -int k; -{ +local void write_table32hi(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%08lx%s", n == 0 || n % 5 ? "" : " ", (unsigned long)(table[n] >> 32), n == k - 1 ? "" : (n % 5 == 4 ? ",\n" : ", ")); } /* Write the 64-bit values in table[0..k-1] to out, three per line in hexadecimal separated by commas. This assumes that if there is a 64-bit type, then there is also a long long integer type, and it is at least 64 bits. If not, then the type cast and format string can be adjusted accordingly. */ -local void write_table64(out, table, k) - FILE *out; - const z_word_t FAR *table; - int k; -{ +local void write_table64(FILE *out, const z_word_t FAR *table, int k) { int n; for (n = 0; n < k; n++) fprintf(out, "%s0x%016llx%s", n == 0 || n % 3 ? "" : " ", (unsigned long long)(table[n]), n == k - 1 ? "" : (n % 3 == 2 ? ",\n" : ", ")); } /* Actually do the deed. */ -int main() -{ +int main(void) { make_crc_table(); return 0; } #endif /* MAKECRCH */ #ifdef W /* Generate the little and big-endian braid tables for the given n and z_word_t size w. Each array must have room for w blocks of 256 elements. */ -local void braid(ltl, big, n, w) - z_crc_t ltl[][256]; - z_word_t big[][256]; - int n; - int w; -{ +local void braid(z_crc_t ltl[][256], z_word_t big[][256], int n, int w) { int k; z_crc_t i, p, q; for (k = 0; k < w; k++) { p = x2nmodp((n * w + 3 - k) << 3, 0); ltl[k][0] = 0; big[w - 1 - k][0] = 0; for (i = 1; i < 256; i++) { ltl[k][i] = q = multmodp(i << 24, p); big[w - 1 - k][i] = byte_swap(q); } } } #endif -#else /* !DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Tables for byte-wise and braided CRC-32 calculations, and a table of powers - * of x for combining CRC-32s, all made by make_crc_table(). - */ -#include "crc32.h" #endif /* DYNAMIC_CRC_TABLE */ -/* ======================================================================== - * Routines used for CRC calculation. Some are also required for the table - * generation above. - */ - -/* - Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, - reflected. For speed, this requires that a not be zero. - */ -local z_crc_t multmodp(a, b) - z_crc_t a; - z_crc_t b; -{ - z_crc_t m, p; - - m = (z_crc_t)1 << 31; - p = 0; - for (;;) { - if (a & m) { - p ^= b; - if ((a & (m - 1)) == 0) - break; - } - m >>= 1; - b = b & 1 ? (b >> 1) ^ POLY : b >> 1; - } - return p; -} - -/* - Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been - initialized. - */ -local z_crc_t x2nmodp(n, k) - z_off64_t n; - unsigned k; -{ - z_crc_t p; - - p = (z_crc_t)1 << 31; /* x^0 == 1 */ - while (n) { - if (n & 1) - p = multmodp(x2n_table[k & 31], p); - n >>= 1; - k++; - } - return p; -} - /* ========================================================================= * This function can be used by asm versions of crc32(), and to force the * generation of the CRC tables in a threaded application. */ -const z_crc_t FAR * ZEXPORT get_crc_table() -{ +const z_crc_t FAR * ZEXPORT get_crc_table(void) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return (const z_crc_t FAR *)crc_table; } /* ========================================================================= * Use ARM machine instructions if available. This will compute the CRC about * ten times faster than the braided calculation. This code does not check for * the presence of the CRC instruction at run time. __ARM_FEATURE_CRC32 will * only be defined if the compilation specifies an ARM processor architecture * that has the instructions. For example, compiling with -march=armv8.1-a or * -march=armv8-a+crc, or -march=native if the compile machine has the crc32 * instructions. */ #ifdef ARMCRC32 /* Constants empirically determined to maximize speed. These values are from measurements on a Cortex-A57. Your mileage may vary. */ #define Z_BATCH 3990 /* number of words in a batch */ #define Z_BATCH_ZEROS 0xa10d3d0c /* computed from Z_BATCH = 3990 */ #define Z_BATCH_MIN 800 /* fewest words in a final batch */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { z_crc_t val; z_word_t crc1, crc2; const z_word_t *word; z_word_t val0, val1, val2; z_size_t last, last2, i; z_size_t num; /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ /* Pre-condition the CRC */ crc = (~crc) & 0xffffffff; /* Compute the CRC up to a word boundary. */ while (len && ((z_size_t)buf & 7) != 0) { len--; val = *buf++; __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); } /* Prepare to compute the CRC on full 64-bit words word[0..num-1]. */ word = (z_word_t const *)buf; num = len >> 3; len &= 7; /* Do three interleaved CRCs to realize the throughput of one crc32x @@ -696,120 +646,113 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) } /* Compute the CRC on any remaining words. */ for (i = 0; i < num; i++) { val0 = word[i]; __asm__ volatile("crc32x %w0, %w0, %x1" : "+r"(crc) : "r"(val0)); } word += num; /* Complete the CRC on any remaining bytes. */ buf = (const unsigned char FAR *)word; while (len) { len--; val = *buf++; __asm__ volatile("crc32b %w0, %w0, %w1" : "+r"(crc) : "r"(val)); } /* Return the CRC, post-conditioned. */ return crc ^ 0xffffffff; } #else #ifdef W /* Return the CRC of the W bytes in the word_t data, taking the least-significant byte of the word as the first byte of data, without any pre or post conditioning. This is used to combine the CRCs of each braid. */ -local z_crc_t crc_word(data) - z_word_t data; -{ +local z_crc_t crc_word(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data >> 8) ^ crc_table[data & 0xff]; return (z_crc_t)data; } -local z_word_t crc_word_big(data) - z_word_t data; -{ +local z_word_t crc_word_big(z_word_t data) { int k; for (k = 0; k < W; k++) data = (data << 8) ^ crc_big_table[(data >> ((W - 1) << 3)) & 0xff]; return data; } #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32_z(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - z_size_t len; -{ +unsigned long ZEXPORT crc32_z(unsigned long crc, const unsigned char FAR *buf, + z_size_t len) { /* Return initial CRC, if requested. */ if (buf == Z_NULL) return 0; #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ /* Pre-condition the CRC */ crc = (~crc) & 0xffffffff; #ifdef W /* If provided enough bytes, do a braided CRC calculation. */ if (len >= N * W + W - 1) { z_size_t blks; z_word_t const *words; unsigned endian; int k; /* Compute the CRC up to a z_word_t boundary. */ while (len && ((z_size_t)buf & (W - 1)) != 0) { len--; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } /* Compute the CRC on as many N z_word_t blocks as are available. */ blks = len / (N * W); len -= blks * N * W; words = (z_word_t const *)buf; /* Do endian check at execution time instead of compile time, since ARM - processors can change the endianess at execution time. If the - compiler knows what the endianess will be, it can optimize out the + processors can change the endianness at execution time. If the + compiler knows what the endianness will be, it can optimize out the check and the unused branch. */ endian = 1; if (*(unsigned char *)&endian) { /* Little endian. */ z_crc_t crc0; z_word_t word0; #if N > 1 z_crc_t crc1; z_word_t word1; #if N > 2 z_crc_t crc2; z_word_t word2; #if N > 3 z_crc_t crc3; z_word_t word3; #if N > 4 z_crc_t crc4; z_word_t word4; #if N > 5 z_crc_t crc5; z_word_t word5; #endif #endif #endif #endif #endif /* Initialize the CRC for each braid. */ crc0 = crc; @@ -1042,84 +985,65 @@ unsigned long ZEXPORT crc32_z(crc, buf, len) */ buf = (unsigned char const *)words; } #endif /* W */ /* Complete the computation of the CRC on any remaining bytes. */ while (len >= 8) { len -= 8; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } while (len) { len--; crc = (crc >> 8) ^ crc_table[(crc ^ *buf++) & 0xff]; } /* Return the CRC, post-conditioned. */ return crc ^ 0xffffffff; } #endif /* ========================================================================= */ -unsigned long ZEXPORT crc32(crc, buf, len) - unsigned long crc; - const unsigned char FAR *buf; - uInt len; -{ +unsigned long ZEXPORT crc32(unsigned long crc, const unsigned char FAR *buf, + uInt len) { return crc32_z(crc, buf, len); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine64(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine64(uLong crc1, uLong crc2, z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return multmodp(x2nmodp(len2, 3), crc1) ^ (crc2 & 0xffffffff); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine(crc1, crc2, len2) - uLong crc1; - uLong crc2; - z_off_t len2; -{ +uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2) { return crc32_combine64(crc1, crc2, (z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen64(len2) - z_off64_t len2; -{ +uLong ZEXPORT crc32_combine_gen64(z_off64_t len2) { #ifdef DYNAMIC_CRC_TABLE once(&made, make_crc_table); #endif /* DYNAMIC_CRC_TABLE */ return x2nmodp(len2, 3); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_gen(len2) - z_off_t len2; -{ +uLong ZEXPORT crc32_combine_gen(z_off_t len2) { return crc32_combine_gen64((z_off64_t)len2); } /* ========================================================================= */ -uLong ZEXPORT crc32_combine_op(crc1, crc2, op) - uLong crc1; - uLong crc2; - uLong op; -{ +uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op) { return multmodp(op, crc1) ^ (crc2 & 0xffffffff); } diff --git a/src/Common/zlib/deflate.c b/src/Common/zlib/deflate.c index 4a689db3..012ea814 100644 --- a/src/Common/zlib/deflate.c +++ b/src/Common/zlib/deflate.c @@ -1,125 +1,109 @@ /* deflate.c -- compress data using the deflation algorithm - * Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process depends on being able to identify portions * of the input text which are identical to earlier input (within a * sliding window trailing behind the input currently being processed). * * The most straightforward technique turns out to be the fastest for * most input files: try all possible matches and select the longest. * The key feature of this algorithm is that insertions into the string * dictionary are very simple and thus fast, and deletions are avoided * completely. Insertions are performed at each input character, whereas * string matches are performed only when the previous match ends. So it * is preferable to spend more time in matches to allow very fast string * insertions and avoid deletions. The matching algorithm for small * strings is inspired from that of Rabin & Karp. A brute force approach * is used to find longer strings when a small match has been found. * A similar algorithm is used in comic (by Jan-Mark Wams) and freeze * (by Leonid Broukhis). * A previous version of this file used a more sophisticated algorithm * (by Fiala and Greene) which is guaranteed to run in linear amortized * time, but has a larger average cost, uses more memory and is patented. * However the F&G algorithm may be faster for some highly redundant * files if the parameter max_chain_length (described below) is too large. * * ACKNOWLEDGEMENTS * * The idea of lazy evaluation of matches is due to Jan-Mark Wams, and * I found it in 'freeze' written by Leonid Broukhis. * Thanks to many people for bug reports and testing. * * REFERENCES * * Deutsch, L.P.,"DEFLATE Compressed Data Format Specification". * Available in http://tools.ietf.org/html/rfc1951 * * A description of the Rabin and Karp algorithm is given in the book * "Algorithms" by R. Sedgewick, Addison-Wesley, p252. * * Fiala,E.R., and Greene,D.H. * Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595 * */ /* @(#) $Id$ */ #include "deflate.h" const char deflate_copyright[] = - " deflate 1.2.13 Copyright 1995-2022 Jean-loup Gailly and Mark Adler "; + " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ -/* =========================================================================== - * Function prototypes. - */ typedef enum { need_more, /* block not completed, need more input or more output */ block_done, /* block flush performed */ finish_started, /* finish started, need only more output at next deflate */ finish_done /* finish done, accept no more input or output */ } block_state; -typedef block_state (*compress_func) OF((deflate_state *s, int flush)); +typedef block_state (*compress_func)(deflate_state *s, int flush); /* Compression function. Returns the block state after the call. */ -local int deflateStateCheck OF((z_streamp strm)); -local void slide_hash OF((deflate_state *s)); -local void fill_window OF((deflate_state *s)); -local block_state deflate_stored OF((deflate_state *s, int flush)); -local block_state deflate_fast OF((deflate_state *s, int flush)); +local block_state deflate_stored(deflate_state *s, int flush); +local block_state deflate_fast(deflate_state *s, int flush); #ifndef FASTEST -local block_state deflate_slow OF((deflate_state *s, int flush)); -#endif -local block_state deflate_rle OF((deflate_state *s, int flush)); -local block_state deflate_huff OF((deflate_state *s, int flush)); -local void lm_init OF((deflate_state *s)); -local void putShortMSB OF((deflate_state *s, uInt b)); -local void flush_pending OF((z_streamp strm)); -local unsigned read_buf OF((z_streamp strm, Bytef *buf, unsigned size)); -local uInt longest_match OF((deflate_state *s, IPos cur_match)); - -#ifdef ZLIB_DEBUG -local void check_match OF((deflate_state *s, IPos start, IPos match, - int length)); +local block_state deflate_slow(deflate_state *s, int flush); #endif +local block_state deflate_rle(deflate_state *s, int flush); +local block_state deflate_huff(deflate_state *s, int flush); /* =========================================================================== * Local data */ #define NIL 0 /* Tail of hash chains */ #ifndef TOO_FAR # define TOO_FAR 4096 #endif /* Matches of length 3 are discarded if their distance exceeds TOO_FAR */ /* Values for max_lazy_match, good_match and max_chain_length, depending on * the desired pack level (0..9). The values given below have been tuned to * exclude worst case performance for pathological files. Better values may be * found for specific files. */ typedef struct config_s { ush good_length; /* reduce lazy search above this match length */ ush max_lazy; /* do not perform lazy search above this match length */ ush nice_length; /* quit search above this match length */ ush max_chain; compress_func func; } config; #ifdef FASTEST local const config configuration_table[2] = { /* good lazy nice chain */ /* 0 */ {0, 0, 0, 0, deflate_stored}, /* store only */ @@ -168,110 +152,260 @@ local const config configuration_table[10] = { * the last MIN_MATCH-1 bytes of the input file). */ #ifdef FASTEST #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #else #define INSERT_STRING(s, str, match_head) \ (UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]), \ match_head = s->prev[(str) & s->w_mask] = s->head[s->ins_h], \ s->head[s->ins_h] = (Pos)(str)) #endif /* =========================================================================== * Initialize the hash table (avoiding 64K overflow for 16 bit systems). * prev[] will be initialized on the fly. */ #define CLEAR_HASH(s) \ do { \ s->head[s->hash_size - 1] = NIL; \ zmemzero((Bytef *)s->head, \ (unsigned)(s->hash_size - 1)*sizeof(*s->head)); \ } while (0) /* =========================================================================== * Slide the hash table when sliding the window down (could be avoided with 32 * bit values at the expense of memory usage). We slide even when level == 0 to * keep the hash table consistent if we switch back to level > 0 later. */ -local void slide_hash(s) - deflate_state *s; -{ +#if defined(__has_feature) +# if __has_feature(memory_sanitizer) + __attribute__((no_sanitize("memory"))) +# endif +#endif +local void slide_hash(deflate_state *s) { unsigned n, m; Posf *p; uInt wsize = s->w_size; n = s->hash_size; p = &s->head[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m - wsize : NIL); } while (--n); n = wsize; #ifndef FASTEST p = &s->prev[n]; do { m = *--p; *p = (Pos)(m >= wsize ? m - wsize : NIL); /* If n is not on any hash chain, prev[n] is garbage but * its value will never be used. */ } while (--n); #endif } +/* =========================================================================== + * Read a new buffer from the current input stream, update the adler32 + * and total number of bytes read. All deflate() input goes through + * this function so some applications may wish to modify it to avoid + * allocating a large strm->next_in buffer and copying from it. + * (See also flush_pending()). + */ +local unsigned read_buf(z_streamp strm, Bytef *buf, unsigned size) { + unsigned len = strm->avail_in; + + if (len > size) len = size; + if (len == 0) return 0; + + strm->avail_in -= len; + + zmemcpy(buf, strm->next_in, len); + if (strm->state->wrap == 1) { + strm->adler = adler32(strm->adler, buf, len); + } +#ifdef GZIP + else if (strm->state->wrap == 2) { + strm->adler = crc32(strm->adler, buf, len); + } +#endif + strm->next_in += len; + strm->total_in += len; + + return len; +} + +/* =========================================================================== + * Fill the window when the lookahead becomes insufficient. + * Updates strstart and lookahead. + * + * IN assertion: lookahead < MIN_LOOKAHEAD + * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD + * At least one byte has been read, or avail_in == 0; reads are + * performed for at least two bytes (required for the zip translate_eol + * option -- not supported here). + */ +local void fill_window(deflate_state *s) { + unsigned n; + unsigned more; /* Amount of free space at the end of the window. */ + uInt wsize = s->w_size; + + Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); + + do { + more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); + + /* Deal with !@#$% 64K limit: */ + if (sizeof(int) <= 2) { + if (more == 0 && s->strstart == 0 && s->lookahead == 0) { + more = wsize; + + } else if (more == (unsigned)(-1)) { + /* Very unlikely, but possible on 16 bit machine if + * strstart == 0 && lookahead == 1 (input done a byte at time) + */ + more--; + } + } + + /* If the window is almost full and there is insufficient lookahead, + * move the upper half to the lower one to make room in the upper half. + */ + if (s->strstart >= wsize + MAX_DIST(s)) { + + zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); + s->match_start -= wsize; + s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ + s->block_start -= (long) wsize; + if (s->insert > s->strstart) + s->insert = s->strstart; + slide_hash(s); + more += wsize; + } + if (s->strm->avail_in == 0) break; + + /* If there was no sliding: + * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && + * more == window_size - lookahead - strstart + * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) + * => more >= window_size - 2*WSIZE + 2 + * In the BIG_MEM or MMAP case (not yet supported), + * window_size == input_size + MIN_LOOKAHEAD && + * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. + * Otherwise, window_size == 2*WSIZE so more >= 2. + * If there was sliding, more >= WSIZE. So in all cases, more >= 2. + */ + Assert(more >= 2, "more < 2"); + + n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); + s->lookahead += n; + + /* Initialize the hash value now that we have some input: */ + if (s->lookahead + s->insert >= MIN_MATCH) { + uInt str = s->strstart - s->insert; + s->ins_h = s->window[str]; + UPDATE_HASH(s, s->ins_h, s->window[str + 1]); +#if MIN_MATCH != 3 + Call UPDATE_HASH() MIN_MATCH-3 more times +#endif + while (s->insert) { + UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); +#ifndef FASTEST + s->prev[str & s->w_mask] = s->head[s->ins_h]; +#endif + s->head[s->ins_h] = (Pos)str; + str++; + s->insert--; + if (s->lookahead + s->insert < MIN_MATCH) + break; + } + } + /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, + * but this is not important since only literal bytes will be emitted. + */ + + } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); + + /* If the WIN_INIT bytes after the end of the current data have never been + * written, then zero those bytes in order to avoid memory check reports of + * the use of uninitialized (or uninitialised as Julian writes) bytes by + * the longest match routines. Update the high water mark for the next + * time through here. WIN_INIT is set to MAX_MATCH since the longest match + * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. + */ + if (s->high_water < s->window_size) { + ulg curr = s->strstart + (ulg)(s->lookahead); + ulg init; + + if (s->high_water < curr) { + /* Previous high water mark below current data -- zero WIN_INIT + * bytes or up to end of window, whichever is less. + */ + init = s->window_size - curr; + if (init > WIN_INIT) + init = WIN_INIT; + zmemzero(s->window + curr, (unsigned)init); + s->high_water = curr + init; + } + else if (s->high_water < (ulg)curr + WIN_INIT) { + /* High water mark at or above current data, but below current data + * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up + * to end of window, whichever is less. + */ + init = (ulg)curr + WIN_INIT - s->high_water; + if (init > s->window_size - s->high_water) + init = s->window_size - s->high_water; + zmemzero(s->window + s->high_water, (unsigned)init); + s->high_water += init; + } + } + + Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, + "not enough room for search"); +} + /* ========================================================================= */ -int ZEXPORT deflateInit_(strm, level, version, stream_size) - z_streamp strm; - int level; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit_(z_streamp strm, int level, const char *version, + int stream_size) { return deflateInit2_(strm, level, Z_DEFLATED, MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY, version, stream_size); /* To do: ignore strm->next_in if we use it as window */ } /* ========================================================================= */ -int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, - version, stream_size) - z_streamp strm; - int level; - int method; - int windowBits; - int memLevel; - int strategy; - const char *version; - int stream_size; -{ +int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size) { deflate_state *s; int wrap = 1; static const char my_version[] = ZLIB_VERSION; if (version == Z_NULL || version[0] != my_version[0] || stream_size != sizeof(z_stream)) { return Z_VERSION_ERROR; } if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; if (strm->zalloc == (alloc_func)0) { #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; #endif } if (strm->zfree == (free_func)0) #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zfree = zcfree; #endif #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; @@ -332,115 +466,116 @@ int ZEXPORT deflateInit2_(strm, level, method, windowBits, memLevel, strategy, * sym_buf starts one-fourth of the way into pending_buf. So there are * three bytes in sym_buf for every four bytes in pending_buf. Each symbol * in sym_buf is three bytes -- two for the distance and one for the * literal/length. As each symbol is consumed, the pointer to the next * sym_buf value to read moves forward three bytes. From that symbol, up to * 31 bits are written to pending_buf. The closest the written pending_buf * bits gets to the next sym_buf symbol to read is just before the last * code is written. At that time, 31*(n - 2) bits have been written, just * after 24*(n - 2) bits have been consumed from sym_buf. sym_buf starts at * 8*n bits into pending_buf. (Note that the symbol buffer fills when n - 1 * symbols are written.) The closest the writing gets to what is unread is * then n + 14 bits. Here n is lit_bufsize, which is 16384 by default, and * can range from 128 to 32768. * * Therefore, at a minimum, there are 142 bits of space between what is * written and what is read in the overlain buffers, so the symbols cannot * be overwritten by the compressed data. That space is actually 139 bits, * due to the three-bit fixed-code block header. * * That covers the case where either Z_FIXED is specified, forcing fixed * codes, or when the use of fixed codes is chosen, because that choice * results in a smaller compressed block than dynamic codes. That latter * condition then assures that the above analysis also covers all dynamic * blocks. A dynamic-code block will only be chosen to be emitted if it has * fewer bits than a fixed-code block would for the same set of symbols. * Therefore its average symbol length is assured to be less than 31. So * the compressed data for a dynamic block also cannot overwrite the * symbols from which it is being constructed. */ - s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4); + s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS); s->pending_buf_size = (ulg)s->lit_bufsize * 4; if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL || s->pending_buf == Z_NULL) { s->status = FINISH_STATE; strm->msg = ERR_MSG(Z_MEM_ERROR); deflateEnd (strm); return Z_MEM_ERROR; } +#ifdef LIT_MEM + s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1)); + s->l_buf = s->pending_buf + (s->lit_bufsize << 2); + s->sym_end = s->lit_bufsize - 1; +#else s->sym_buf = s->pending_buf + s->lit_bufsize; s->sym_end = (s->lit_bufsize - 1) * 3; +#endif /* We avoid equality with lit_bufsize*3 because of wraparound at 64K * on 16 bit machines and because stored blocks are restricted to * 64K-1 bytes. */ s->level = level; s->strategy = strategy; s->method = (Byte)method; return deflateReset(strm); } /* ========================================================================= * Check for a valid deflate stream state. Return 0 if ok, 1 if not. */ -local int deflateStateCheck(strm) - z_streamp strm; -{ +local int deflateStateCheck(z_streamp strm) { deflate_state *s; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) return 1; s = strm->state; if (s == Z_NULL || s->strm != strm || (s->status != INIT_STATE && #ifdef GZIP s->status != GZIP_STATE && #endif s->status != EXTRA_STATE && s->status != NAME_STATE && s->status != COMMENT_STATE && s->status != HCRC_STATE && s->status != BUSY_STATE && s->status != FINISH_STATE)) return 1; return 0; } /* ========================================================================= */ -int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) - z_streamp strm; - const Bytef *dictionary; - uInt dictLength; -{ +int ZEXPORT deflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { deflate_state *s; uInt str, n; int wrap; unsigned avail; z_const unsigned char *next; if (deflateStateCheck(strm) || dictionary == Z_NULL) return Z_STREAM_ERROR; s = strm->state; wrap = s->wrap; if (wrap == 2 || (wrap == 1 && s->status != INIT_STATE) || s->lookahead) return Z_STREAM_ERROR; /* when using zlib wrappers, compute Adler-32 for provided dictionary */ if (wrap == 1) strm->adler = adler32(strm->adler, dictionary, dictLength); s->wrap = 0; /* avoid computing Adler-32 in read_buf */ /* if dictionary would fill window, just replace the history */ if (dictLength >= s->w_size) { if (wrap == 0) { /* already empty otherwise */ CLEAR_HASH(s); s->strstart = 0; s->block_start = 0L; s->insert = 0; } dictionary += dictLength - s->w_size; /* use the tail */ dictLength = s->w_size; } @@ -451,398 +586,391 @@ int ZEXPORT deflateSetDictionary(strm, dictionary, dictLength) strm->next_in = (z_const Bytef *)dictionary; fill_window(s); while (s->lookahead >= MIN_MATCH) { str = s->strstart; n = s->lookahead - (MIN_MATCH-1); do { UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); #ifndef FASTEST s->prev[str & s->w_mask] = s->head[s->ins_h]; #endif s->head[s->ins_h] = (Pos)str; str++; } while (--n); s->strstart = str; s->lookahead = MIN_MATCH-1; fill_window(s); } s->strstart += s->lookahead; s->block_start = (long)s->strstart; s->insert = s->lookahead; s->lookahead = 0; s->match_length = s->prev_length = MIN_MATCH-1; s->match_available = 0; strm->next_in = next; strm->avail_in = avail; s->wrap = wrap; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateGetDictionary(strm, dictionary, dictLength) - z_streamp strm; - Bytef *dictionary; - uInt *dictLength; -{ +int ZEXPORT deflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { deflate_state *s; uInt len; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; len = s->strstart + s->lookahead; if (len > s->w_size) len = s->w_size; if (dictionary != Z_NULL && len) zmemcpy(dictionary, s->window + s->strstart + s->lookahead - len, len); if (dictLength != Z_NULL) *dictLength = len; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateResetKeep(strm) - z_streamp strm; -{ +int ZEXPORT deflateResetKeep(z_streamp strm) { deflate_state *s; if (deflateStateCheck(strm)) { return Z_STREAM_ERROR; } strm->total_in = strm->total_out = 0; strm->msg = Z_NULL; /* use zfree if we ever allocate msg dynamically */ strm->data_type = Z_UNKNOWN; s = (deflate_state *)strm->state; s->pending = 0; s->pending_out = s->pending_buf; if (s->wrap < 0) { s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */ } s->status = #ifdef GZIP s->wrap == 2 ? GZIP_STATE : #endif INIT_STATE; strm->adler = #ifdef GZIP s->wrap == 2 ? crc32(0L, Z_NULL, 0) : #endif adler32(0L, Z_NULL, 0); s->last_flush = -2; _tr_init(s); return Z_OK; } +/* =========================================================================== + * Initialize the "longest match" routines for a new zlib stream + */ +local void lm_init(deflate_state *s) { + s->window_size = (ulg)2L*s->w_size; + + CLEAR_HASH(s); + + /* Set the default configuration parameters: + */ + s->max_lazy_match = configuration_table[s->level].max_lazy; + s->good_match = configuration_table[s->level].good_length; + s->nice_match = configuration_table[s->level].nice_length; + s->max_chain_length = configuration_table[s->level].max_chain; + + s->strstart = 0; + s->block_start = 0L; + s->lookahead = 0; + s->insert = 0; + s->match_length = s->prev_length = MIN_MATCH-1; + s->match_available = 0; + s->ins_h = 0; +} + /* ========================================================================= */ -int ZEXPORT deflateReset(strm) - z_streamp strm; -{ +int ZEXPORT deflateReset(z_streamp strm) { int ret; ret = deflateResetKeep(strm); if (ret == Z_OK) lm_init(strm->state); return ret; } /* ========================================================================= */ -int ZEXPORT deflateSetHeader(strm, head) - z_streamp strm; - gz_headerp head; -{ +int ZEXPORT deflateSetHeader(z_streamp strm, gz_headerp head) { if (deflateStateCheck(strm) || strm->state->wrap != 2) return Z_STREAM_ERROR; strm->state->gzhead = head; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflatePending(strm, pending, bits) - unsigned *pending; - int *bits; - z_streamp strm; -{ +int ZEXPORT deflatePending(z_streamp strm, unsigned *pending, int *bits) { if (deflateStateCheck(strm)) return Z_STREAM_ERROR; if (pending != Z_NULL) *pending = strm->state->pending; if (bits != Z_NULL) *bits = strm->state->bi_valid; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflatePrime(strm, bits, value) - z_streamp strm; - int bits; - int value; -{ +int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) { deflate_state *s; int put; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; +#ifdef LIT_MEM + if (bits < 0 || bits > 16 || + (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3)) + return Z_BUF_ERROR; +#else if (bits < 0 || bits > 16 || s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3)) return Z_BUF_ERROR; +#endif do { put = Buf_size - s->bi_valid; if (put > bits) put = bits; s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid); s->bi_valid += put; _tr_flush_bits(s); value >>= put; bits -= put; } while (bits); return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateParams(strm, level, strategy) - z_streamp strm; - int level; - int strategy; -{ +int ZEXPORT deflateParams(z_streamp strm, int level, int strategy) { deflate_state *s; compress_func func; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; #ifdef FASTEST if (level != 0) level = 1; #else if (level == Z_DEFAULT_COMPRESSION) level = 6; #endif if (level < 0 || level > 9 || strategy < 0 || strategy > Z_FIXED) { return Z_STREAM_ERROR; } func = configuration_table[s->level].func; if ((strategy != s->strategy || func != configuration_table[level].func) && s->last_flush != -2) { /* Flush the last buffer: */ int err = deflate(strm, Z_BLOCK); if (err == Z_STREAM_ERROR) return err; if (strm->avail_in || (s->strstart - s->block_start) + s->lookahead) return Z_BUF_ERROR; } if (s->level != level) { if (s->level == 0 && s->matches != 0) { if (s->matches == 1) slide_hash(s); else CLEAR_HASH(s); s->matches = 0; } s->level = level; s->max_lazy_match = configuration_table[level].max_lazy; s->good_match = configuration_table[level].good_length; s->nice_match = configuration_table[level].nice_length; s->max_chain_length = configuration_table[level].max_chain; } s->strategy = strategy; return Z_OK; } /* ========================================================================= */ -int ZEXPORT deflateTune(strm, good_length, max_lazy, nice_length, max_chain) - z_streamp strm; - int good_length; - int max_lazy; - int nice_length; - int max_chain; -{ +int ZEXPORT deflateTune(z_streamp strm, int good_length, int max_lazy, + int nice_length, int max_chain) { deflate_state *s; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; s = strm->state; s->good_match = (uInt)good_length; s->max_lazy_match = (uInt)max_lazy; s->nice_match = nice_length; s->max_chain_length = (uInt)max_chain; return Z_OK; } /* ========================================================================= * For the default windowBits of 15 and memLevel of 8, this function returns a * close to exact, as well as small, upper bound on the compressed size. This * is an expansion of ~0.03%, plus a small constant. * * For any setting other than those defaults for windowBits and memLevel, one * of two worst case bounds is returned. This is at most an expansion of ~4% or * ~13%, plus a small constant. * * Both the 0.03% and 4% derive from the overhead of stored blocks. The first * one is for stored blocks of 16383 bytes (memLevel == 8), whereas the second * is for stored blocks of 127 bytes (the worst case memLevel == 1). The * expansion results from five bytes of header for each stored block. * * The larger expansion of 13% results from a window size less than or equal to * the symbols buffer size (windowBits <= memLevel + 7). In that case some of * the data being compressed may have slid out of the sliding window, impeding * a stored block from being emitted. Then the only choice is a fixed or * dynamic block, where a fixed block limits the maximum expansion to 9 bits * per 8-bit byte, plus 10 bits for every block. The smallest block size for * which this can occur is 255 (memLevel == 2). * * Shifts are used to approximate divisions, for speed. */ -uLong ZEXPORT deflateBound(strm, sourceLen) - z_streamp strm; - uLong sourceLen; -{ +uLong ZEXPORT deflateBound(z_streamp strm, uLong sourceLen) { deflate_state *s; uLong fixedlen, storelen, wraplen; /* upper bound for fixed blocks with 9-bit literals and length 255 (memLevel == 2, which is the lowest that may not use stored blocks) -- ~13% overhead plus a small constant */ fixedlen = sourceLen + (sourceLen >> 3) + (sourceLen >> 8) + (sourceLen >> 9) + 4; /* upper bound for stored blocks with length 127 (memLevel == 1) -- ~4% overhead plus a small constant */ storelen = sourceLen + (sourceLen >> 5) + (sourceLen >> 7) + (sourceLen >> 11) + 7; /* if can't get parameters, return larger bound plus a zlib wrapper */ if (deflateStateCheck(strm)) return (fixedlen > storelen ? fixedlen : storelen) + 6; /* compute wrapper length */ s = strm->state; switch (s->wrap) { case 0: /* raw deflate */ wraplen = 0; break; case 1: /* zlib wrapper */ wraplen = 6 + (s->strstart ? 4 : 0); break; #ifdef GZIP case 2: /* gzip wrapper */ wraplen = 18; if (s->gzhead != Z_NULL) { /* user-supplied gzip header */ Bytef *str; if (s->gzhead->extra != Z_NULL) wraplen += 2 + s->gzhead->extra_len; str = s->gzhead->name; if (str != Z_NULL) do { wraplen++; } while (*str++); str = s->gzhead->comment; if (str != Z_NULL) do { wraplen++; } while (*str++); if (s->gzhead->hcrc) wraplen += 2; } break; #endif default: /* for compiler happiness */ wraplen = 6; } /* if not default parameters, return one of the conservative bounds */ if (s->w_bits != 15 || s->hash_bits != 8 + 7) - return (s->w_bits <= s->hash_bits ? fixedlen : storelen) + wraplen; + return (s->w_bits <= s->hash_bits && s->level ? fixedlen : storelen) + + wraplen; /* default settings: return tight bound for that case -- ~0.03% overhead plus a small constant */ return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + (sourceLen >> 25) + 13 - 6 + wraplen; } /* ========================================================================= * Put a short in the pending buffer. The 16-bit value is put in MSB order. * IN assertion: the stream state is correct and there is enough room in * pending_buf. */ -local void putShortMSB(s, b) - deflate_state *s; - uInt b; -{ +local void putShortMSB(deflate_state *s, uInt b) { put_byte(s, (Byte)(b >> 8)); put_byte(s, (Byte)(b & 0xff)); } /* ========================================================================= * Flush as much pending output as possible. All deflate() output, except for * some deflate_stored() output, goes through this function so some * applications may wish to modify it to avoid allocating a large * strm->next_out buffer and copying into it. (See also read_buf()). */ -local void flush_pending(strm) - z_streamp strm; -{ +local void flush_pending(z_streamp strm) { unsigned len; deflate_state *s = strm->state; _tr_flush_bits(s); len = s->pending; if (len > strm->avail_out) len = strm->avail_out; if (len == 0) return; zmemcpy(strm->next_out, s->pending_out, len); strm->next_out += len; s->pending_out += len; strm->total_out += len; strm->avail_out -= len; s->pending -= len; if (s->pending == 0) { s->pending_out = s->pending_buf; } } /* =========================================================================== * Update the header CRC with the bytes s->pending_buf[beg..s->pending - 1]. */ #define HCRC_UPDATE(beg) \ do { \ if (s->gzhead->hcrc && s->pending > (beg)) \ strm->adler = crc32(strm->adler, s->pending_buf + (beg), \ s->pending - (beg)); \ } while (0) /* ========================================================================= */ -int ZEXPORT deflate(strm, flush) - z_streamp strm; - int flush; -{ +int ZEXPORT deflate(z_streamp strm, int flush) { int old_flush; /* value of flush param for previous deflate call */ deflate_state *s; if (deflateStateCheck(strm) || flush > Z_BLOCK || flush < 0) { return Z_STREAM_ERROR; } s = strm->state; if (strm->next_out == Z_NULL || (strm->avail_in != 0 && strm->next_in == Z_NULL) || (s->status == FINISH_STATE && flush != Z_FINISH)) { ERR_RETURN(strm, Z_STREAM_ERROR); } if (strm->avail_out == 0) ERR_RETURN(strm, Z_BUF_ERROR); old_flush = s->last_flush; s->last_flush = flush; /* Flush as much pending output as possible */ if (s->pending != 0) { flush_pending(strm); if (strm->avail_out == 0) { /* Since avail_out is 0, deflate will be called again with * more output space, but possibly with both pending and * avail_in equal to zero. There won't be anything to do, * but this is not an error situation so make sure we * return OK instead of BUF_ERROR at next call of deflate: */ s->last_flush = -1; return Z_OK; @@ -1100,212 +1228,151 @@ int ZEXPORT deflate(strm, flush) if (flush != Z_FINISH) return Z_OK; if (s->wrap <= 0) return Z_STREAM_END; /* Write the trailer */ #ifdef GZIP if (s->wrap == 2) { put_byte(s, (Byte)(strm->adler & 0xff)); put_byte(s, (Byte)((strm->adler >> 8) & 0xff)); put_byte(s, (Byte)((strm->adler >> 16) & 0xff)); put_byte(s, (Byte)((strm->adler >> 24) & 0xff)); put_byte(s, (Byte)(strm->total_in & 0xff)); put_byte(s, (Byte)((strm->total_in >> 8) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 16) & 0xff)); put_byte(s, (Byte)((strm->total_in >> 24) & 0xff)); } else #endif { putShortMSB(s, (uInt)(strm->adler >> 16)); putShortMSB(s, (uInt)(strm->adler & 0xffff)); } flush_pending(strm); /* If avail_out is zero, the application will call deflate again * to flush the rest. */ if (s->wrap > 0) s->wrap = -s->wrap; /* write the trailer only once! */ return s->pending != 0 ? Z_OK : Z_STREAM_END; } /* ========================================================================= */ -int ZEXPORT deflateEnd(strm) - z_streamp strm; -{ +int ZEXPORT deflateEnd(z_streamp strm) { int status; if (deflateStateCheck(strm)) return Z_STREAM_ERROR; status = strm->state->status; /* Deallocate in reverse order of allocations: */ TRY_FREE(strm, strm->state->pending_buf); TRY_FREE(strm, strm->state->head); TRY_FREE(strm, strm->state->prev); TRY_FREE(strm, strm->state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; return status == BUSY_STATE ? Z_DATA_ERROR : Z_OK; } /* ========================================================================= * Copy the source state to the destination state. * To simplify the source, this is not supported for 16-bit MSDOS (which * doesn't have enough memory anyway to duplicate compression states). */ -int ZEXPORT deflateCopy(dest, source) - z_streamp dest; - z_streamp source; -{ +int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) { #ifdef MAXSEG_64K + (void)dest; + (void)source; return Z_STREAM_ERROR; #else deflate_state *ds; deflate_state *ss; if (deflateStateCheck(source) || dest == Z_NULL) { return Z_STREAM_ERROR; } ss = source->state; zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); ds = (deflate_state *) ZALLOC(dest, 1, sizeof(deflate_state)); if (ds == Z_NULL) return Z_MEM_ERROR; dest->state = (struct internal_state FAR *) ds; zmemcpy((voidpf)ds, (voidpf)ss, sizeof(deflate_state)); ds->strm = dest; ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte)); ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos)); ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos)); - ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4); + ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS); if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL || ds->pending_buf == Z_NULL) { deflateEnd (dest); return Z_MEM_ERROR; } /* following zmemcpy do not work for 16-bit MSDOS */ zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte)); zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos)); zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos)); - zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size); + zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS); ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf); +#ifdef LIT_MEM + ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1)); + ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2); +#else ds->sym_buf = ds->pending_buf + ds->lit_bufsize; +#endif ds->l_desc.dyn_tree = ds->dyn_ltree; ds->d_desc.dyn_tree = ds->dyn_dtree; ds->bl_desc.dyn_tree = ds->bl_tree; return Z_OK; #endif /* MAXSEG_64K */ } -/* =========================================================================== - * Read a new buffer from the current input stream, update the adler32 - * and total number of bytes read. All deflate() input goes through - * this function so some applications may wish to modify it to avoid - * allocating a large strm->next_in buffer and copying from it. - * (See also flush_pending()). - */ -local unsigned read_buf(strm, buf, size) - z_streamp strm; - Bytef *buf; - unsigned size; -{ - unsigned len = strm->avail_in; - - if (len > size) len = size; - if (len == 0) return 0; - - strm->avail_in -= len; - - zmemcpy(buf, strm->next_in, len); - if (strm->state->wrap == 1) { - strm->adler = adler32(strm->adler, buf, len); - } -#ifdef GZIP - else if (strm->state->wrap == 2) { - strm->adler = crc32(strm->adler, buf, len); - } -#endif - strm->next_in += len; - strm->total_in += len; - - return len; -} - -/* =========================================================================== - * Initialize the "longest match" routines for a new zlib stream - */ -local void lm_init(s) - deflate_state *s; -{ - s->window_size = (ulg)2L*s->w_size; - - CLEAR_HASH(s); - - /* Set the default configuration parameters: - */ - s->max_lazy_match = configuration_table[s->level].max_lazy; - s->good_match = configuration_table[s->level].good_length; - s->nice_match = configuration_table[s->level].nice_length; - s->max_chain_length = configuration_table[s->level].max_chain; - - s->strstart = 0; - s->block_start = 0L; - s->lookahead = 0; - s->insert = 0; - s->match_length = s->prev_length = MIN_MATCH-1; - s->match_available = 0; - s->ins_h = 0; -} - #ifndef FASTEST /* =========================================================================== * Set match_start to the longest match starting at the given string and * return its length. Matches shorter or equal to prev_length are discarded, * in which case the result is equal to prev_length and match_start is * garbage. * IN assertions: cur_match is the head of the hash chain for the current * string (strstart) and its distance is <= MAX_DIST, and prev_length >= 1 * OUT assertion: the match length is not greater than s->lookahead. */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { unsigned chain_length = s->max_chain_length;/* max hash chain length */ register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ int best_len = (int)s->prev_length; /* best match length so far */ int nice_match = s->nice_match; /* stop if match long enough */ IPos limit = s->strstart > (IPos)MAX_DIST(s) ? s->strstart - (IPos)MAX_DIST(s) : NIL; /* Stop when cur_match becomes <= limit. To simplify the code, * we prevent matches with the string of window index 0. */ Posf *prev = s->prev; uInt wmask = s->w_mask; #ifdef UNALIGNED_OK /* Compare two bytes at a time. Note: this is not always beneficial. * Try with and without -DUNALIGNED_OK to check. */ register Bytef *strend = s->window + s->strstart + MAX_MATCH - 1; register ush scan_start = *(ushf*)scan; register ush scan_end = *(ushf*)(scan + best_len - 1); #else register Bytef *strend = s->window + s->strstart + MAX_MATCH; register Byte scan_end1 = scan[best_len - 1]; register Byte scan_end = scan[best_len]; #endif /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ @@ -1399,325 +1466,192 @@ local uInt longest_match(s, cur_match) "wild scan"); len = MAX_MATCH - (int)(strend - scan); scan = strend - MAX_MATCH; #endif /* UNALIGNED_OK */ if (len > best_len) { s->match_start = cur_match; best_len = len; if (len >= nice_match) break; #ifdef UNALIGNED_OK scan_end = *(ushf*)(scan + best_len - 1); #else scan_end1 = scan[best_len - 1]; scan_end = scan[best_len]; #endif } } while ((cur_match = prev[cur_match & wmask]) > limit && --chain_length != 0); if ((uInt)best_len <= s->lookahead) return (uInt)best_len; return s->lookahead; } #else /* FASTEST */ /* --------------------------------------------------------------------------- * Optimized version for FASTEST only */ -local uInt longest_match(s, cur_match) - deflate_state *s; - IPos cur_match; /* current match */ -{ +local uInt longest_match(deflate_state *s, IPos cur_match) { register Bytef *scan = s->window + s->strstart; /* current string */ register Bytef *match; /* matched string */ register int len; /* length of current match */ register Bytef *strend = s->window + s->strstart + MAX_MATCH; /* The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16. * It is easy to get rid of this optimization if necessary. */ Assert(s->hash_bits >= 8 && MAX_MATCH == 258, "Code too clever"); Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead"); Assert(cur_match < s->strstart, "no future"); match = s->window + cur_match; /* Return failure if the match length is less than 2: */ if (match[0] != scan[0] || match[1] != scan[1]) return MIN_MATCH-1; /* The check at best_len - 1 can be removed because it will be made * again later. (This heuristic is not always a win.) * It is not necessary to compare scan[2] and match[2] since they * are always equal when the other bytes match, given that * the hash keys are equal and that HASH_BITS >= 8. */ scan += 2, match += 2; Assert(*scan == *match, "match[2]?"); /* We check for insufficient lookahead only every 8th comparison; * the 256th check will be made at strstart + 258. */ do { } while (*++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && *++scan == *++match && scan < strend); Assert(scan <= s->window + (unsigned)(s->window_size - 1), "wild scan"); len = MAX_MATCH - (int)(strend - scan); if (len < MIN_MATCH) return MIN_MATCH - 1; s->match_start = cur_match; return (uInt)len <= s->lookahead ? (uInt)len : s->lookahead; } #endif /* FASTEST */ #ifdef ZLIB_DEBUG #define EQUAL 0 /* result of memcmp for equal strings */ /* =========================================================================== * Check that the match at match_start is indeed a match. */ -local void check_match(s, start, match, length) - deflate_state *s; - IPos start, match; - int length; -{ +local void check_match(deflate_state *s, IPos start, IPos match, int length) { /* check that the match is indeed a match */ - if (zmemcmp(s->window + match, - s->window + start, length) != EQUAL) { - fprintf(stderr, " start %u, match %u, length %d\n", - start, match, length); + Bytef *back = s->window + (int)match, *here = s->window + start; + IPos len = length; + if (match == (IPos)-1) { + /* match starts one byte before the current window -- just compare the + subsequent length-1 bytes */ + back++; + here++; + len--; + } + if (zmemcmp(back, here, len) != EQUAL) { + fprintf(stderr, " start %u, match %d, length %d\n", + start, (int)match, length); do { - fprintf(stderr, "%c%c", s->window[match++], s->window[start++]); - } while (--length != 0); + fprintf(stderr, "(%02x %02x)", *back++, *here++); + } while (--len != 0); z_error("invalid match"); } if (z_verbose > 1) { fprintf(stderr,"\\[%d,%d]", start - match, length); do { putc(s->window[start++], stderr); } while (--length != 0); } } #else # define check_match(s, start, match, length) #endif /* ZLIB_DEBUG */ /* =========================================================================== - * Fill the window when the lookahead becomes insufficient. - * Updates strstart and lookahead. - * - * IN assertion: lookahead < MIN_LOOKAHEAD - * OUT assertions: strstart <= window_size-MIN_LOOKAHEAD - * At least one byte has been read, or avail_in == 0; reads are - * performed for at least two bytes (required for the zip translate_eol - * option -- not supported here). - */ -local void fill_window(s) - deflate_state *s; -{ - unsigned n; - unsigned more; /* Amount of free space at the end of the window. */ - uInt wsize = s->w_size; - - Assert(s->lookahead < MIN_LOOKAHEAD, "already enough lookahead"); - - do { - more = (unsigned)(s->window_size -(ulg)s->lookahead -(ulg)s->strstart); - - /* Deal with !@#$% 64K limit: */ - if (sizeof(int) <= 2) { - if (more == 0 && s->strstart == 0 && s->lookahead == 0) { - more = wsize; - - } else if (more == (unsigned)(-1)) { - /* Very unlikely, but possible on 16 bit machine if - * strstart == 0 && lookahead == 1 (input done a byte at time) - */ - more--; - } - } - - /* If the window is almost full and there is insufficient lookahead, - * move the upper half to the lower one to make room in the upper half. - */ - if (s->strstart >= wsize + MAX_DIST(s)) { - - zmemcpy(s->window, s->window + wsize, (unsigned)wsize - more); - s->match_start -= wsize; - s->strstart -= wsize; /* we now have strstart >= MAX_DIST */ - s->block_start -= (long) wsize; - if (s->insert > s->strstart) - s->insert = s->strstart; - slide_hash(s); - more += wsize; - } - if (s->strm->avail_in == 0) break; - - /* If there was no sliding: - * strstart <= WSIZE+MAX_DIST-1 && lookahead <= MIN_LOOKAHEAD - 1 && - * more == window_size - lookahead - strstart - * => more >= window_size - (MIN_LOOKAHEAD-1 + WSIZE + MAX_DIST-1) - * => more >= window_size - 2*WSIZE + 2 - * In the BIG_MEM or MMAP case (not yet supported), - * window_size == input_size + MIN_LOOKAHEAD && - * strstart + s->lookahead <= input_size => more >= MIN_LOOKAHEAD. - * Otherwise, window_size == 2*WSIZE so more >= 2. - * If there was sliding, more >= WSIZE. So in all cases, more >= 2. - */ - Assert(more >= 2, "more < 2"); - - n = read_buf(s->strm, s->window + s->strstart + s->lookahead, more); - s->lookahead += n; - - /* Initialize the hash value now that we have some input: */ - if (s->lookahead + s->insert >= MIN_MATCH) { - uInt str = s->strstart - s->insert; - s->ins_h = s->window[str]; - UPDATE_HASH(s, s->ins_h, s->window[str + 1]); -#if MIN_MATCH != 3 - Call UPDATE_HASH() MIN_MATCH-3 more times -#endif - while (s->insert) { - UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); -#ifndef FASTEST - s->prev[str & s->w_mask] = s->head[s->ins_h]; -#endif - s->head[s->ins_h] = (Pos)str; - str++; - s->insert--; - if (s->lookahead + s->insert < MIN_MATCH) - break; - } - } - /* If the whole input has less than MIN_MATCH bytes, ins_h is garbage, - * but this is not important since only literal bytes will be emitted. - */ - - } while (s->lookahead < MIN_LOOKAHEAD && s->strm->avail_in != 0); - - /* If the WIN_INIT bytes after the end of the current data have never been - * written, then zero those bytes in order to avoid memory check reports of - * the use of uninitialized (or uninitialised as Julian writes) bytes by - * the longest match routines. Update the high water mark for the next - * time through here. WIN_INIT is set to MAX_MATCH since the longest match - * routines allow scanning to strstart + MAX_MATCH, ignoring lookahead. - */ - if (s->high_water < s->window_size) { - ulg curr = s->strstart + (ulg)(s->lookahead); - ulg init; - - if (s->high_water < curr) { - /* Previous high water mark below current data -- zero WIN_INIT - * bytes or up to end of window, whichever is less. - */ - init = s->window_size - curr; - if (init > WIN_INIT) - init = WIN_INIT; - zmemzero(s->window + curr, (unsigned)init); - s->high_water = curr + init; - } - else if (s->high_water < (ulg)curr + WIN_INIT) { - /* High water mark at or above current data, but below current data - * plus WIN_INIT -- zero out to current data plus WIN_INIT, or up - * to end of window, whichever is less. - */ - init = (ulg)curr + WIN_INIT - s->high_water; - if (init > s->window_size - s->high_water) - init = s->window_size - s->high_water; - zmemzero(s->window + s->high_water, (unsigned)init); - s->high_water += init; - } - } - - Assert((ulg)s->strstart <= s->window_size - MIN_LOOKAHEAD, - "not enough room for search"); -} - -/* =========================================================================== * Flush the current block, with given end-of-file flag. * IN assertion: strstart is set to the end of the current match. */ #define FLUSH_BLOCK_ONLY(s, last) { \ _tr_flush_block(s, (s->block_start >= 0L ? \ (charf *)&s->window[(unsigned)s->block_start] : \ (charf *)Z_NULL), \ (ulg)((long)s->strstart - s->block_start), \ (last)); \ s->block_start = s->strstart; \ flush_pending(s->strm); \ Tracev((stderr,"[FLUSH]")); \ } /* Same but force premature exit if necessary. */ #define FLUSH_BLOCK(s, last) { \ FLUSH_BLOCK_ONLY(s, last); \ if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \ } /* Maximum stored block length in deflate format (not including header). */ #define MAX_STORED 65535 /* Minimum of a and b. */ #define MIN(a, b) ((a) > (b) ? (b) : (a)) /* =========================================================================== * Copy without compression as much as possible from the input stream, return * the current block state. * * In case deflateParams() is used to later switch to a non-zero compression * level, s->matches (otherwise unused when storing) keeps track of the number * of hash table slides to perform. If s->matches is 1, then one hash table * slide will be done when switching. If s->matches is 2, the maximum value * allowed here, then the hash table will be cleared, since two or more slides * is the same as a clear. * * deflate_stored() is written to minimize the number of times an input byte is * copied. It is most efficient with large input and output buffers, which * maximizes the opportunities to have a single copy from next_in to next_out. */ -local block_state deflate_stored(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_stored(deflate_state *s, int flush) { /* Smallest worthy block size when not flushing or finishing. By default * this is 32K. This can be as small as 507 bytes for memLevel == 1. For * large input and output buffers, the stored block size will be larger. */ unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size); /* Copy as many min_block or larger stored blocks directly to next_out as * possible. If flushing, copy the remaining available input to next_out as * stored blocks, if there is enough space. */ unsigned len, left, have, last = 0; unsigned used = s->strm->avail_in; do { /* Set len to the maximum size block that we can copy directly with the * available input data and output space. Set left to how much of that * would be copied from what's left in the window. */ len = MAX_STORED; /* maximum deflate stored block length */ have = (s->bi_valid + 42) >> 3; /* number of header bytes */ if (s->strm->avail_out < have) /* need room for header */ break; /* maximum stored block length that will fit in avail_out: */ have = s->strm->avail_out - have; left = s->strstart - s->block_start; /* bytes left in window */ if (len > (ulg)left + s->strm->avail_in) len = left + s->strm->avail_in; /* limit len to the input */ if (len > have) len = have; /* limit len to the output */ /* If the stored block would be less than min_block in length, or if @@ -1847,64 +1781,61 @@ local block_state deflate_stored(s, flush) * have enough input for a worthy block, or if flushing and there is enough * room for the remaining input as a stored block in the pending buffer. */ have = (s->bi_valid + 42) >> 3; /* number of header bytes */ /* maximum stored block length that will fit in pending: */ have = MIN(s->pending_buf_size - have, MAX_STORED); min_block = MIN(have, s->w_size); left = s->strstart - s->block_start; if (left >= min_block || ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && s->strm->avail_in == 0 && left <= have)) { len = MIN(left, have); last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0; _tr_stored_block(s, (charf *)s->window + s->block_start, len, last); s->block_start += len; flush_pending(s->strm); } /* We've done all we can with the available input and output. */ return last ? finish_started : need_more; } /* =========================================================================== * Compress as much as possible from the input stream, return the current * block state. * This function does not perform lazy evaluation of matches and inserts * new strings in the dictionary only for unmatched strings or for short * matches. It is used only for the fast compression options. */ -local block_state deflate_fast(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_fast(deflate_state *s, int flush) { IPos hash_head; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart + 2] in the * dictionary, and set hash_head to the head of the hash chain: */ hash_head = NIL; if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. * At this point we have always match_length < MIN_MATCH */ if (hash_head != NIL && s->strstart - hash_head <= MAX_DIST(s)) { /* To simplify the code, we prevent matches with the string @@ -1949,64 +1880,61 @@ local block_state deflate_fast(s, flush) #endif /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not * matter since it will be recomputed at next deflate call. */ } } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } #ifndef FASTEST /* =========================================================================== * Same as above, but achieves better compression. We use a lazy * evaluation for matches: a match is finally adopted only if there is * no better match at the next window position. */ -local block_state deflate_slow(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_slow(deflate_state *s, int flush) { IPos hash_head; /* head of hash chain */ int bflush; /* set if current block must be flushed */ /* Process the input block. */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the * string following the next match. */ if (s->lookahead < MIN_LOOKAHEAD) { fill_window(s); if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* Insert the string window[strstart .. strstart + 2] in the * dictionary, and set hash_head to the head of the hash chain: */ hash_head = NIL; if (s->lookahead >= MIN_MATCH) { INSERT_STRING(s, s->strstart, hash_head); } /* Find the longest match, discarding those <= prev_length. */ s->prev_length = s->match_length, s->prev_match = s->match_start; s->match_length = MIN_MATCH-1; @@ -2080,64 +2008,61 @@ local block_state deflate_slow(s, flush) /* There is no previous match to compare with, wait for * the next step to decide. */ s->match_available = 1; s->strstart++; s->lookahead--; } } Assert (flush != Z_NO_FLUSH, "no flush?"); if (s->match_available) { Tracevv((stderr,"%c", s->window[s->strstart - 1])); _tr_tally_lit(s, s->window[s->strstart - 1], bflush); s->match_available = 0; } s->insert = s->strstart < MIN_MATCH-1 ? s->strstart : MIN_MATCH-1; if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } #endif /* FASTEST */ /* =========================================================================== * For Z_RLE, simply look for runs of bytes, generate matches only of distance * one. Do not maintain a hash table. (It will be regenerated if this run of * deflate switches away from Z_RLE.) */ -local block_state deflate_rle(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_rle(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ uInt prev; /* byte at distance one to match */ Bytef *scan, *strend; /* scan goes up to strend for length of run */ for (;;) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the longest run, plus one for the unrolled loop. */ if (s->lookahead <= MAX_MATCH) { fill_window(s); if (s->lookahead <= MAX_MATCH && flush == Z_NO_FLUSH) { return need_more; } if (s->lookahead == 0) break; /* flush the current block */ } /* See how many times the previous byte repeats */ s->match_length = 0; if (s->lookahead >= MIN_MATCH && s->strstart > 0) { scan = s->window + s->strstart - 1; prev = *scan; if (prev == *++scan && prev == *++scan && prev == *++scan) { strend = s->window + s->strstart + MAX_MATCH; do { } while (prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && prev == *++scan && scan < strend); @@ -2154,64 +2079,61 @@ local block_state deflate_rle(s, flush) check_match(s, s->strstart, s->strstart - 1, s->match_length); _tr_tally_dist(s, 1, s->match_length - MIN_MATCH, bflush); s->lookahead -= s->match_length; s->strstart += s->match_length; s->match_length = 0; } else { /* No match, output a literal byte */ Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; } if (bflush) FLUSH_BLOCK(s, 0); } s->insert = 0; if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } /* =========================================================================== * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. * (It will be regenerated if this run of deflate switches away from Huffman.) */ -local block_state deflate_huff(s, flush) - deflate_state *s; - int flush; -{ +local block_state deflate_huff(deflate_state *s, int flush) { int bflush; /* set if current block must be flushed */ for (;;) { /* Make sure that we have a literal to write. */ if (s->lookahead == 0) { fill_window(s); if (s->lookahead == 0) { if (flush == Z_NO_FLUSH) return need_more; break; /* flush the current block */ } } /* Output a literal byte */ s->match_length = 0; Tracevv((stderr,"%c", s->window[s->strstart])); _tr_tally_lit(s, s->window[s->strstart], bflush); s->lookahead--; s->strstart++; if (bflush) FLUSH_BLOCK(s, 0); } s->insert = 0; if (flush == Z_FINISH) { FLUSH_BLOCK(s, 1); return finish_done; } if (s->sym_next) FLUSH_BLOCK(s, 0); return block_done; } diff --git a/src/Common/zlib/deflate.h b/src/Common/zlib/deflate.h index 1a06cd5f..300c6ada 100644 --- a/src/Common/zlib/deflate.h +++ b/src/Common/zlib/deflate.h @@ -1,55 +1,59 @@ /* deflate.h -- internal compression state - * Copyright (C) 1995-2018 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef DEFLATE_H #define DEFLATE_H #include "zutil.h" /* define NO_GZIP when compiling if you want to disable gzip header and trailer creation by deflate(). NO_GZIP would be used to avoid linking in the crc code when it is not needed. For shared libraries, gzip encoding should be left enabled. */ #ifndef NO_GZIP # define GZIP #endif +/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at + the cost of a larger memory footprint */ +/* #define LIT_MEM */ + /* =========================================================================== * Internal compression state. */ #define LENGTH_CODES 29 /* number of length codes, not counting the special END_BLOCK code */ #define LITERALS 256 /* number of literal bytes 0..255 */ #define L_CODES (LITERALS+1+LENGTH_CODES) /* number of Literal or Length codes, including the END_BLOCK code */ #define D_CODES 30 /* number of distance codes */ #define BL_CODES 19 /* number of codes used to transfer the bit lengths */ #define HEAP_SIZE (2*L_CODES+1) /* maximum heap size */ #define MAX_BITS 15 /* All codes must not exceed MAX_BITS bits */ #define Buf_size 16 /* size of bit buffer in bi_buf */ #define INIT_STATE 42 /* zlib header -> BUSY_STATE */ #ifdef GZIP @@ -190,157 +194,184 @@ typedef struct internal_state { uInt good_match; /* Use a faster search when the previous match is longer than this */ int nice_match; /* Stop searching when current match exceeds this */ /* used by trees.c: */ /* Didn't use ct_data typedef below to suppress compiler warning */ struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */ struct ct_data_s dyn_dtree[2*D_CODES+1]; /* distance tree */ struct ct_data_s bl_tree[2*BL_CODES+1]; /* Huffman tree for bit lengths */ struct tree_desc_s l_desc; /* desc. for literal tree */ struct tree_desc_s d_desc; /* desc. for distance tree */ struct tree_desc_s bl_desc; /* desc. for bit length tree */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */ int heap_len; /* number of elements in the heap */ int heap_max; /* element of largest frequency */ /* The sons of heap[n] are heap[2*n] and heap[2*n+1]. heap[0] is not used. * The same heap array is used to build all trees. */ uch depth[2*L_CODES+1]; /* Depth of each subtree used as tie breaker for trees of equal frequency */ +#ifdef LIT_MEM +# define LIT_BUFS 5 + ushf *d_buf; /* buffer for distances */ + uchf *l_buf; /* buffer for literals/lengths */ +#else +# define LIT_BUFS 4 uchf *sym_buf; /* buffer for distances and literals/lengths */ +#endif uInt lit_bufsize; /* Size of match buffer for literals/lengths. There are 4 reasons for * limiting lit_bufsize to 64K: * - frequencies can be kept in 16 bit counters * - if compression is not successful for the first block, all input * data is still in the window so we can still emit a stored block even * when input comes from standard input. (This can also be done for * all blocks if lit_bufsize is not greater than 32K.) * - if compression is not successful for a file smaller than 64K, we can * even emit a stored file instead of a stored block (saving 5 bytes). * This is applicable only for zip (not gzip or zlib). * - creating new Huffman trees less frequently may not provide fast * adaptation to changes in the input data statistics. (Take for * example a binary file with poorly compressible code followed by * a highly compressible string table.) Smaller buffer sizes give * fast adaptation but have of course the overhead of transmitting * trees more frequently. * - I can't count above 4 */ - uInt sym_next; /* running index in sym_buf */ + uInt sym_next; /* running index in symbol buffer */ uInt sym_end; /* symbol table full when sym_next reaches this */ ulg opt_len; /* bit length of current block with optimal trees */ ulg static_len; /* bit length of current block with static trees */ uInt matches; /* number of string matches in current block */ uInt insert; /* bytes at end of window left to insert */ #ifdef ZLIB_DEBUG ulg compressed_len; /* total bit length of compressed file mod 2^32 */ ulg bits_sent; /* bit length of compressed data sent mod 2^32 */ #endif ush bi_buf; /* Output buffer. bits are inserted starting at the bottom (least * significant bits). */ int bi_valid; /* Number of valid bits in bi_buf. All bits above the last valid bit * are always zero. */ ulg high_water; /* High water mark offset in window for initialized bytes -- bytes above * this are set to zero in order to avoid memory check warnings when * longest match routines access bytes past the input. This is then * updated to the new high water mark. */ } FAR deflate_state; /* Output a byte on the stream. * IN assertion: there is enough room in pending_buf. */ #define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);} #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. */ #define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD) /* In order to simplify the code, particularly on 16 bit machines, match * distances are limited to MAX_DIST instead of WSIZE. */ #define WIN_INIT MAX_MATCH /* Number of bytes after end of data in window to initialize in order to avoid memory checker errors from longest match routines */ /* in trees.c */ -void ZLIB_INTERNAL _tr_init OF((deflate_state *s)); -int ZLIB_INTERNAL _tr_tally OF((deflate_state *s, unsigned dist, unsigned lc)); -void ZLIB_INTERNAL _tr_flush_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); -void ZLIB_INTERNAL _tr_flush_bits OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_align OF((deflate_state *s)); -void ZLIB_INTERNAL _tr_stored_block OF((deflate_state *s, charf *buf, - ulg stored_len, int last)); +void ZLIB_INTERNAL _tr_init(deflate_state *s); +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc); +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last); +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s); +void ZLIB_INTERNAL _tr_align(deflate_state *s); +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last); #define d_code(dist) \ ((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)]) /* Mapping from a distance to a distance code. dist is the distance - 1 and * must not have side effects. _dist_code[256] and _dist_code[257] are never * used. */ #ifndef ZLIB_DEBUG /* Inline versions of _tr_tally for speed: */ #if defined(GEN_TREES_H) || !defined(STDC) extern uch ZLIB_INTERNAL _length_code[]; extern uch ZLIB_INTERNAL _dist_code[]; #else extern const uch ZLIB_INTERNAL _length_code[]; extern const uch ZLIB_INTERNAL _dist_code[]; #endif +#ifdef LIT_MEM +# define _tr_tally_lit(s, c, flush) \ + { uch cc = (c); \ + s->d_buf[s->sym_next] = 0; \ + s->l_buf[s->sym_next++] = cc; \ + s->dyn_ltree[cc].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +# define _tr_tally_dist(s, distance, length, flush) \ + { uch len = (uch)(length); \ + ush dist = (ush)(distance); \ + s->d_buf[s->sym_next] = dist; \ + s->l_buf[s->sym_next++] = len; \ + dist--; \ + s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ + s->dyn_dtree[d_code(dist)].Freq++; \ + flush = (s->sym_next == s->sym_end); \ + } +#else # define _tr_tally_lit(s, c, flush) \ { uch cc = (c); \ s->sym_buf[s->sym_next++] = 0; \ s->sym_buf[s->sym_next++] = 0; \ s->sym_buf[s->sym_next++] = cc; \ s->dyn_ltree[cc].Freq++; \ flush = (s->sym_next == s->sym_end); \ } # define _tr_tally_dist(s, distance, length, flush) \ { uch len = (uch)(length); \ ush dist = (ush)(distance); \ s->sym_buf[s->sym_next++] = (uch)dist; \ s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \ s->sym_buf[s->sym_next++] = len; \ dist--; \ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \ s->dyn_dtree[d_code(dist)].Freq++; \ flush = (s->sym_next == s->sym_end); \ } +#endif #else # define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c) # define _tr_tally_dist(s, distance, length, flush) \ flush = _tr_tally(s, distance, length) #endif #endif /* DEFLATE_H */ diff --git a/src/Common/zlib/gzclose.c b/src/Common/zlib/gzclose.c index caeb99a3..48d6a86f 100644 --- a/src/Common/zlib/gzclose.c +++ b/src/Common/zlib/gzclose.c @@ -1,25 +1,23 @@ /* gzclose.c -- zlib gzclose() function * Copyright (C) 2004, 2010 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" /* gzclose() is in a separate file so that it is linked in only if it is used. That way the other gzclose functions can be used instead to avoid linking in unneeded compression or decompression routines. */ -int ZEXPORT gzclose(file) - gzFile file; -{ +int ZEXPORT gzclose(gzFile file) { #ifndef NO_GZCOMPRESS gz_statep state; if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); #else return gzclose_r(file); #endif } diff --git a/src/Common/zlib/gzguts.h b/src/Common/zlib/gzguts.h index 57faf371..eba72085 100644 --- a/src/Common/zlib/gzguts.h +++ b/src/Common/zlib/gzguts.h @@ -1,42 +1,41 @@ /* gzguts.h -- zlib internal header definitions for gz* operations - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #ifdef _LARGEFILE64_SOURCE # ifndef _LARGEFILE_SOURCE # define _LARGEFILE_SOURCE 1 # endif -# ifdef _FILE_OFFSET_BITS -# undef _FILE_OFFSET_BITS -# endif +# undef _FILE_OFFSET_BITS +# undef _TIME_BITS #endif #ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL #endif #include <stdio.h> #include "zlib.h" #ifdef STDC # include <string.h> # include <stdlib.h> # include <limits.h> #endif #ifndef _POSIX_SOURCE # define _POSIX_SOURCE #endif #include <fcntl.h> #ifdef _WIN32 # include <stddef.h> #endif #if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32) # include <io.h> #endif #if defined(_WIN32) @@ -92,83 +91,83 @@ # ifdef __SASC # define NO_vsnprintf # endif # ifdef VMS # define NO_vsnprintf # endif # ifdef __OS400__ # define NO_vsnprintf # endif # ifdef __MVS__ # define NO_vsnprintf # endif #endif /* unlike snprintf (which is required in C99), _snprintf does not guarantee null termination of the result -- however this is only used in gzlib.c where the result is assured to fit in the space provided */ #if defined(_MSC_VER) && _MSC_VER < 1900 # define snprintf _snprintf #endif #ifndef local # define local static #endif /* since "static" is used to mean two completely different things in C, we define "local" for the non-static meaning of "static", for readability (compile with -Dlocal if your debugger can't find static symbols) */ /* gz* functions always use library allocation functions */ #ifndef STDC - extern voidp malloc OF((uInt size)); - extern void free OF((voidpf ptr)); + extern voidp malloc(uInt size); + extern void free(voidpf ptr); #endif /* get errno and strerror definition */ #if defined UNDER_CE # include <windows.h> # define zstrerror() gz_strwinerror((DWORD)GetLastError()) #else # ifndef NO_STRERROR # include <errno.h> # define zstrerror() strerror(errno) # else # define zstrerror() "stdio error (consult errno)" # endif #endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); #endif /* default memLevel */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default i/o buffer size -- double this for output when reading (this and twice this must be able to fit in an unsigned type) */ #define GZBUFSIZE 8192 /* gzip modes, also provide a little integrity check on the passed structure */ #define GZ_NONE 0 #define GZ_READ 7247 #define GZ_WRITE 31153 #define GZ_APPEND 1 /* mode set to GZ_WRITE after the file is opened */ /* values for gz_state how */ #define LOOK 0 /* look for a gzip header */ #define COPY 1 /* copy input directly */ #define GZIP 2 /* decompress a gzip stream */ /* internal gzip file state data structure */ typedef struct { /* exposed contents for gzgetc() macro */ struct gzFile_s x; /* "x" for exposed */ /* x.have: number of bytes available at x.next */ /* x.next: next output data to deliver or write */ @@ -176,44 +175,40 @@ typedef struct { /* used for both reading and writing */ int mode; /* see gzip modes above */ int fd; /* file descriptor */ char *path; /* path or fd for error messages */ unsigned size; /* buffer size, zero if not allocated yet */ unsigned want; /* requested buffer size, default is GZBUFSIZE */ unsigned char *in; /* input buffer (double-sized when writing) */ unsigned char *out; /* output buffer (double-sized when reading) */ int direct; /* 0 if processing gzip, 1 if transparent */ /* just for reading */ int how; /* 0: get header, 1: copy, 2: decompress */ z_off64_t start; /* where the gzip data started, for rewinding */ int eof; /* true if end of input file reached */ int past; /* true if read requested past end */ /* just for writing */ int level; /* compression level */ int strategy; /* compression strategy */ int reset; /* true if a reset is pending after a Z_FINISH */ /* seek request */ z_off64_t skip; /* amount to skip (already rewound if backwards) */ int seek; /* true if seek request pending */ /* error information */ int err; /* error code */ char *msg; /* error message */ /* zlib inflate or deflate stream */ z_stream strm; /* stream structure in-place (not a pointer) */ } gz_state; typedef gz_state FAR *gz_statep; /* shared functions */ -void ZLIB_INTERNAL gz_error OF((gz_statep, int, const char *)); +void ZLIB_INTERNAL gz_error(gz_statep, int, const char *); #if defined UNDER_CE -char ZLIB_INTERNAL *gz_strwinerror OF((DWORD error)); +char ZLIB_INTERNAL *gz_strwinerror(DWORD error); #endif /* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t value -- needed when comparing unsigned to z_off64_t, which is signed (possible z_off64_t types off_t, off64_t, and long are all signed) */ -#ifdef INT_MAX -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX) -#else -unsigned ZLIB_INTERNAL gz_intmax OF((void)); -# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) -#endif +unsigned ZLIB_INTERNAL gz_intmax(void); +#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax()) diff --git a/src/Common/zlib/gzlib.c b/src/Common/zlib/gzlib.c index 55da46a4..983153cc 100644 --- a/src/Common/zlib/gzlib.c +++ b/src/Common/zlib/gzlib.c @@ -1,127 +1,115 @@ /* gzlib.c -- zlib functions common to reading and writing gzip files - * Copyright (C) 2004-2019 Mark Adler + * Copyright (C) 2004-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" #if defined(_WIN32) && !defined(__BORLANDC__) # define LSEEK _lseeki64 #else #if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 # define LSEEK lseek64 #else # define LSEEK lseek #endif #endif -/* Local functions */ -local void gz_reset OF((gz_statep)); -local gzFile gz_open OF((const void *, int, const char *)); - #if defined UNDER_CE /* Map the Windows error number in ERROR to a locale-dependent error message string and return a pointer to it. Typically, the values for ERROR come from GetLastError. The string pointed to shall not be modified by the application, but may be overwritten by a subsequent call to gz_strwinerror The gz_strwinerror function does not change the current setting of GetLastError. */ -char ZLIB_INTERNAL *gz_strwinerror(error) - DWORD error; -{ +char ZLIB_INTERNAL *gz_strwinerror(DWORD error) { static char buf[1024]; wchar_t *msgbuf; DWORD lasterr = GetLastError(); DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, error, 0, /* Default language */ (LPVOID)&msgbuf, 0, NULL); if (chars != 0) { /* If there is an \r\n appended, zap it. */ if (chars >= 2 && msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') { chars -= 2; msgbuf[chars] = 0; } if (chars > sizeof (buf) - 1) { chars = sizeof (buf) - 1; msgbuf[chars] = 0; } wcstombs(buf, msgbuf, chars + 1); LocalFree(msgbuf); } else { sprintf(buf, "unknown win32 error (%ld)", error); } SetLastError(lasterr); return buf; } #endif /* UNDER_CE */ /* Reset gzip file state */ -local void gz_reset(state) - gz_statep state; -{ +local void gz_reset(gz_statep state) { state->x.have = 0; /* no output data available */ if (state->mode == GZ_READ) { /* for reading ... */ state->eof = 0; /* not at end of file */ state->past = 0; /* have not read past end yet */ state->how = LOOK; /* look for gzip header */ } else /* for writing ... */ state->reset = 0; /* no deflateReset pending */ state->seek = 0; /* no seek request pending */ gz_error(state, Z_OK, NULL); /* clear error */ state->x.pos = 0; /* no uncompressed data yet */ state->strm.avail_in = 0; /* no input data yet */ } /* Open a gzip file either by name or file descriptor. */ -local gzFile gz_open(path, fd, mode) - const void *path; - int fd; - const char *mode; -{ +local gzFile gz_open(const void *path, int fd, const char *mode) { gz_statep state; z_size_t len; int oflag; #ifdef O_CLOEXEC int cloexec = 0; #endif #ifdef O_EXCL int exclusive = 0; #endif /* check input */ if (path == NULL) return NULL; /* allocate gzFile structure to return */ state = (gz_statep)malloc(sizeof(gz_state)); if (state == NULL) return NULL; state->size = 0; /* no buffers allocated yet */ state->want = GZBUFSIZE; /* requested buffer size */ state->msg = NULL; /* no error message yet */ /* interpret mode */ state->mode = GZ_NONE; state->level = Z_DEFAULT_COMPRESSION; state->strategy = Z_DEFAULT_STRATEGY; state->direct = 0; while (*mode) { if (*mode >= '0' && *mode <= '9') state->level = *mode - '0'; @@ -242,161 +230,140 @@ local gzFile gz_open(path, fd, mode) /* open the file with the appropriate flags (or just use fd) */ state->fd = fd > -1 ? fd : ( #ifdef WIDECHAR fd == -2 ? _wopen(path, oflag, 0666) : #endif open((const char *)path, oflag, 0666)); if (state->fd == -1) { free(state->path); free(state); return NULL; } if (state->mode == GZ_APPEND) { LSEEK(state->fd, 0, SEEK_END); /* so gzoffset() is correct */ state->mode = GZ_WRITE; /* simplify later checks */ } /* save the current position for rewinding (only if reading) */ if (state->mode == GZ_READ) { state->start = LSEEK(state->fd, 0, SEEK_CUR); if (state->start == -1) state->start = 0; } /* initialize stream */ gz_reset(state); /* return stream */ return (gzFile)state; } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzopen64(path, mode) - const char *path; - const char *mode; -{ +gzFile ZEXPORT gzopen64(const char *path, const char *mode) { return gz_open(path, -1, mode); } /* -- see zlib.h -- */ -gzFile ZEXPORT gzdopen(fd, mode) - int fd; - const char *mode; -{ +gzFile ZEXPORT gzdopen(int fd, const char *mode) { char *path; /* identifier for error messages */ gzFile gz; if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL) return NULL; #if !defined(NO_snprintf) && !defined(NO_vsnprintf) (void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); #else sprintf(path, "<fd:%d>", fd); /* for debugging */ #endif gz = gz_open(path, fd, mode); free(path); return gz; } /* -- see zlib.h -- */ #ifdef WIDECHAR -gzFile ZEXPORT gzopen_w(path, mode) - const wchar_t *path; - const char *mode; -{ +gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) { return gz_open(path, -2, mode); } #endif /* -- see zlib.h -- */ -int ZEXPORT gzbuffer(file, size) - gzFile file; - unsigned size; -{ +int ZEXPORT gzbuffer(gzFile file, unsigned size) { gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return -1; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return -1; /* make sure we haven't already allocated memory */ if (state->size != 0) return -1; /* check and set requested size */ if ((size << 1) < size) return -1; /* need to be able to double it */ - if (size < 2) - size = 2; /* need two bytes to check magic header */ + if (size < 8) + size = 8; /* needed to behave well with flushing */ state->want = size; return 0; } /* -- see zlib.h -- */ -int ZEXPORT gzrewind(file) - gzFile file; -{ +int ZEXPORT gzrewind(gzFile file) { gz_statep state; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; /* check that we're reading and that there's no error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* back up and start over */ if (LSEEK(state->fd, state->start, SEEK_SET) == -1) return -1; gz_reset(state); return 0; } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzseek64(file, offset, whence) - gzFile file; - z_off64_t offset; - int whence; -{ +z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) { unsigned n; z_off64_t ret; gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return -1; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return -1; /* check that there's no error */ if (state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; /* can only seek from start or relative to current position */ if (whence != SEEK_SET && whence != SEEK_CUR) return -1; /* normalize offset to a SEEK_CUR specification */ if (whence == SEEK_SET) offset -= state->x.pos; else if (state->seek) offset += state->skip; state->seek = 0; /* if within raw area while reading, just go there */ if (state->mode == GZ_READ && state->how == COPY && state->x.pos + offset >= 0) { ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR); @@ -415,225 +382,201 @@ z_off64_t ZEXPORT gzseek64(file, offset, whence) /* calculate skip amount, rewinding if needed for back seek when reading */ if (offset < 0) { if (state->mode != GZ_READ) /* writing -- can't go backwards */ return -1; offset += state->x.pos; if (offset < 0) /* before start of file! */ return -1; if (gzrewind(file) == -1) /* rewind, then skip to offset */ return -1; } /* if reading, skip what's in output buffer (one less gzgetc() check) */ if (state->mode == GZ_READ) { n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? (unsigned)offset : state->x.have; state->x.have -= n; state->x.next += n; state->x.pos += n; offset -= n; } /* request skip (if not zero) */ if (offset) { state->seek = 1; state->skip = offset; } return state->x.pos + offset; } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzseek(file, offset, whence) - gzFile file; - z_off_t offset; - int whence; -{ +z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) { z_off64_t ret; ret = gzseek64(file, (z_off64_t)offset, whence); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gztell64(file) - gzFile file; -{ +z_off64_t ZEXPORT gztell64(gzFile file) { gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return -1; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return -1; /* return position */ return state->x.pos + (state->seek ? state->skip : 0); } /* -- see zlib.h -- */ -z_off_t ZEXPORT gztell(file) - gzFile file; -{ +z_off_t ZEXPORT gztell(gzFile file) { z_off64_t ret; ret = gztell64(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } /* -- see zlib.h -- */ -z_off64_t ZEXPORT gzoffset64(file) - gzFile file; -{ +z_off64_t ZEXPORT gzoffset64(gzFile file) { z_off64_t offset; gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return -1; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return -1; /* compute and return effective offset in file */ offset = LSEEK(state->fd, 0, SEEK_CUR); if (offset == -1) return -1; if (state->mode == GZ_READ) /* reading */ offset -= state->strm.avail_in; /* don't count buffered input */ return offset; } /* -- see zlib.h -- */ -z_off_t ZEXPORT gzoffset(file) - gzFile file; -{ +z_off_t ZEXPORT gzoffset(gzFile file) { z_off64_t ret; ret = gzoffset64(file); return ret == (z_off_t)ret ? (z_off_t)ret : -1; } /* -- see zlib.h -- */ -int ZEXPORT gzeof(file) - gzFile file; -{ +int ZEXPORT gzeof(gzFile file) { gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return 0; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return 0; /* return end-of-file state */ return state->mode == GZ_READ ? state->past : 0; } /* -- see zlib.h -- */ -const char * ZEXPORT gzerror(file, errnum) - gzFile file; - int *errnum; -{ +const char * ZEXPORT gzerror(gzFile file, int *errnum) { gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return NULL; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return NULL; /* return error information */ if (errnum != NULL) *errnum = state->err; return state->err == Z_MEM_ERROR ? "out of memory" : (state->msg == NULL ? "" : state->msg); } /* -- see zlib.h -- */ -void ZEXPORT gzclearerr(file) - gzFile file; -{ +void ZEXPORT gzclearerr(gzFile file) { gz_statep state; /* get internal structure and check integrity */ if (file == NULL) return; state = (gz_statep)file; if (state->mode != GZ_READ && state->mode != GZ_WRITE) return; /* clear error and end-of-file */ if (state->mode == GZ_READ) { state->eof = 0; state->past = 0; } gz_error(state, Z_OK, NULL); } /* Create an error message in allocated memory and set state->err and state->msg accordingly. Free any previous error message already there. Do not try to free or allocate space if the error is Z_MEM_ERROR (out of memory). Simply save the error message as a static string. If there is an allocation failure constructing the error message, then convert the error to out of memory. */ -void ZLIB_INTERNAL gz_error(state, err, msg) - gz_statep state; - int err; - const char *msg; -{ +void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) { /* free previously allocated message and clear */ if (state->msg != NULL) { if (state->err != Z_MEM_ERROR) free(state->msg); state->msg = NULL; } /* if fatal, set state->x.have to 0 so that the gzgetc() macro fails */ if (err != Z_OK && err != Z_BUF_ERROR) state->x.have = 0; /* set error code, and if no message, then done */ state->err = err; if (msg == NULL) return; /* for an out of memory error, return literal string when requested */ if (err == Z_MEM_ERROR) return; /* construct error message with path */ if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) { state->err = Z_MEM_ERROR; return; } #if !defined(NO_snprintf) && !defined(NO_vsnprintf) (void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, "%s%s%s", state->path, ": ", msg); #else strcpy(state->msg, state->path); strcat(state->msg, ": "); strcat(state->msg, msg); #endif } -#ifndef INT_MAX /* portably return maximum value for an int (when limits.h presumed not available) -- we need to do this to cover cases where 2's complement not used, since C standard permits 1's complement and sign-bit representations, otherwise we could just use ((unsigned)-1) >> 1 */ -unsigned ZLIB_INTERNAL gz_intmax() -{ - unsigned p, q; - - p = 1; +unsigned ZLIB_INTERNAL gz_intmax(void) { +#ifdef INT_MAX + return INT_MAX; +#else + unsigned p = 1, q; do { q = p; p <<= 1; p++; } while (p > q); return q >> 1; -} #endif +} diff --git a/src/Common/zlib/gzread.c b/src/Common/zlib/gzread.c index dd773815..4168cbc8 100644 --- a/src/Common/zlib/gzread.c +++ b/src/Common/zlib/gzread.c @@ -1,123 +1,106 @@ /* gzread.c -- zlib functions for reading gzip files * Copyright (C) 2004-2017 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -/* Local functions */ -local int gz_load OF((gz_statep, unsigned char *, unsigned, unsigned *)); -local int gz_avail OF((gz_statep)); -local int gz_look OF((gz_statep)); -local int gz_decomp OF((gz_statep)); -local int gz_fetch OF((gz_statep)); -local int gz_skip OF((gz_statep, z_off64_t)); -local z_size_t gz_read OF((gz_statep, voidp, z_size_t)); - /* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from state->fd, and update state->eof, state->err, and state->msg as appropriate. This function needs to loop on read(), since read() is not guaranteed to read the number of bytes requested, depending on the type of descriptor. */ -local int gz_load(state, buf, len, have) - gz_statep state; - unsigned char *buf; - unsigned len; - unsigned *have; -{ +local int gz_load(gz_statep state, unsigned char *buf, unsigned len, + unsigned *have) { int ret; unsigned get, max = ((unsigned)-1 >> 2) + 1; *have = 0; do { get = len - *have; if (get > max) get = max; ret = read(state->fd, buf + *have, get); if (ret <= 0) break; *have += (unsigned)ret; } while (*have < len); if (ret < 0) { gz_error(state, Z_ERRNO, zstrerror()); return -1; } if (ret == 0) state->eof = 1; return 0; } /* Load up input buffer and set eof flag if last data loaded -- return -1 on error, 0 otherwise. Note that the eof flag is set when the end of the input file is reached, even though there may be unused data in the buffer. Once that data has been used, no more attempts will be made to read the file. If strm->avail_in != 0, then the current data is moved to the beginning of the input buffer, and then the remainder of the buffer is loaded with the available data from the input file. */ -local int gz_avail(state) - gz_statep state; -{ +local int gz_avail(gz_statep state) { unsigned got; z_streamp strm = &(state->strm); if (state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; if (state->eof == 0) { if (strm->avail_in) { /* copy what's there to the start */ unsigned char *p = state->in; unsigned const char *q = strm->next_in; unsigned n = strm->avail_in; do { *p++ = *q++; } while (--n); } if (gz_load(state, state->in + strm->avail_in, state->size - strm->avail_in, &got) == -1) return -1; strm->avail_in += got; strm->next_in = state->in; } return 0; } /* Look for gzip header, set up for inflate or copy. state->x.have must be 0. If this is the first time in, allocate required memory. state->how will be left unchanged if there is no more input data available, will be set to COPY if there is no gzip header and direct copying will be performed, or it will be set to GZIP for decompression. If direct copying, then leftover input data from the input buffer will be copied to the output buffer. In that case, all further file reads will be directly to either the output buffer or a user buffer. If decompressing, the inflate state will be initialized. gz_look() will return 0 on success or -1 on failure. */ -local int gz_look(state) - gz_statep state; -{ +local int gz_look(gz_statep state) { z_streamp strm = &(state->strm); /* allocate read buffers and inflate memory */ if (state->size == 0) { /* allocate buffers */ state->in = (unsigned char *)malloc(state->want); state->out = (unsigned char *)malloc(state->want << 1); if (state->in == NULL || state->out == NULL) { free(state->out); free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } state->size = state->want; /* allocate inflate memory */ state->strm.zalloc = Z_NULL; state->strm.zfree = Z_NULL; state->strm.opaque = Z_NULL; state->strm.avail_in = 0; state->strm.next_in = Z_NULL; if (inflateInit2(&(state->strm), 15 + 16) != Z_OK) { /* gunzip */ free(state->out); free(state->in); state->size = 0; gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } } @@ -143,184 +126,173 @@ local int gz_look(state) state->direct = 0; return 0; } /* no gzip header -- if we were decoding gzip before, then this is trailing garbage. Ignore the trailing garbage and finish. */ if (state->direct == 0) { strm->avail_in = 0; state->eof = 1; state->x.have = 0; return 0; } /* doing raw i/o, copy any leftover input to output -- this assumes that the output buffer is larger than the input buffer, which also assures space for gzungetc() */ state->x.next = state->out; memcpy(state->x.next, strm->next_in, strm->avail_in); state->x.have = strm->avail_in; strm->avail_in = 0; state->how = COPY; state->direct = 1; return 0; } /* Decompress from input to the provided next_out and avail_out in the state. On return, state->x.have and state->x.next point to the just decompressed data. If the gzip stream completes, state->how is reset to LOOK to look for the next gzip stream or raw data, once state->x.have is depleted. Returns 0 on success, -1 on failure. */ -local int gz_decomp(state) - gz_statep state; -{ +local int gz_decomp(gz_statep state) { int ret = Z_OK; unsigned had; z_streamp strm = &(state->strm); /* fill output buffer up to end of deflate stream */ had = strm->avail_out; do { /* get more input for inflate() */ if (strm->avail_in == 0 && gz_avail(state) == -1) return -1; if (strm->avail_in == 0) { gz_error(state, Z_BUF_ERROR, "unexpected end of file"); break; } /* decompress and handle errors */ ret = inflate(strm, Z_NO_FLUSH); if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) { gz_error(state, Z_STREAM_ERROR, "internal error: inflate stream corrupt"); return -1; } if (ret == Z_MEM_ERROR) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } if (ret == Z_DATA_ERROR) { /* deflate stream invalid */ gz_error(state, Z_DATA_ERROR, strm->msg == NULL ? "compressed data error" : strm->msg); return -1; } } while (strm->avail_out && ret != Z_STREAM_END); /* update available output */ state->x.have = had - strm->avail_out; state->x.next = strm->next_out - state->x.have; /* if the gzip stream completed successfully, look for another */ if (ret == Z_STREAM_END) state->how = LOOK; /* good decompression */ return 0; } /* Fetch data and put it in the output buffer. Assumes state->x.have is 0. Data is either copied from the input file or decompressed from the input file depending on state->how. If state->how is LOOK, then a gzip header is looked for to determine whether to copy or decompress. Returns -1 on error, otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the end of the input file has been reached and all data has been processed. */ -local int gz_fetch(state) - gz_statep state; -{ +local int gz_fetch(gz_statep state) { z_streamp strm = &(state->strm); do { switch(state->how) { case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */ if (gz_look(state) == -1) return -1; if (state->how == LOOK) return 0; break; case COPY: /* -> COPY */ if (gz_load(state, state->out, state->size << 1, &(state->x.have)) == -1) return -1; state->x.next = state->out; return 0; case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */ strm->avail_out = state->size << 1; strm->next_out = state->out; if (gz_decomp(state) == -1) return -1; } } while (state->x.have == 0 && (!state->eof || strm->avail_in)); return 0; } /* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */ -local int gz_skip(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_skip(gz_statep state, z_off64_t len) { unsigned n; /* skip over len bytes or reach end-of-file, whichever comes first */ while (len) /* skip over whatever is in output buffer */ if (state->x.have) { n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ? (unsigned)len : state->x.have; state->x.have -= n; state->x.next += n; state->x.pos += n; len -= n; } /* output buffer empty -- return if we're at the end of the input */ else if (state->eof && state->strm.avail_in == 0) break; /* need more data to skip -- load up output buffer */ else { /* get more output, looking for header if required */ if (gz_fetch(state) == -1) return -1; } return 0; } /* Read len bytes into buf from file, or less than len up to the end of the input. Return the number of bytes read. If zero is returned, either the end of file was reached, or there was an error. state->err must be consulted in that case to determine which. */ -local z_size_t gz_read(state, buf, len) - gz_statep state; - voidp buf; - z_size_t len; -{ +local z_size_t gz_read(gz_statep state, voidp buf, z_size_t len) { z_size_t got; unsigned n; /* if len is zero, avoid unnecessary operations */ if (len == 0) return 0; /* process a skip request */ if (state->seek) { state->seek = 0; if (gz_skip(state, state->skip) == -1) return 0; } /* get len bytes to buf, or less than len if at the end */ got = 0; do { /* set n to the maximum amount of len that fits in an unsigned int */ n = (unsigned)-1; if (n > len) n = (unsigned)len; /* first just try copying data from the output buffer */ if (state->x.have) { if (state->x.have < n) n = state->x.have; memcpy(buf, state->x.next, n); state->x.next += n; state->x.have -= n; } @@ -343,308 +315,288 @@ local z_size_t gz_read(state, buf, len) } /* large len -- read directly into user buffer */ else if (state->how == COPY) { /* read directly */ if (gz_load(state, (unsigned char *)buf, n, &n) == -1) return 0; } /* large len -- decompress directly into user buffer */ else { /* state->how == GZIP */ state->strm.avail_out = n; state->strm.next_out = (unsigned char *)buf; if (gz_decomp(state) == -1) return 0; n = state->x.have; state->x.have = 0; } /* update progress */ len -= n; buf = (char *)buf + n; got += n; state->x.pos += n; } while (len); /* return number of bytes read into user buffer */ return got; } /* -- see zlib.h -- */ -int ZEXPORT gzread(file, buf, len) - gzFile file; - voidp buf; - unsigned len; -{ +int ZEXPORT gzread(gzFile file, voidp buf, unsigned len) { gz_statep state; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* since an int is returned, make sure len fits in one, otherwise return with an error (this avoids a flaw in the interface) */ if ((int)len < 0) { gz_error(state, Z_STREAM_ERROR, "request does not fit in an int"); return -1; } /* read len or fewer bytes to buf */ len = (unsigned)gz_read(state, buf, len); /* check for an error */ if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR) return -1; /* return the number of bytes read (this is assured to fit in an int) */ return (int)len; } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfread(buf, size, nitems, file) - voidp buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, gzFile file) { z_size_t len; gz_statep state; /* get internal structure */ if (file == NULL) return 0; state = (gz_statep)file; /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return 0; /* compute bytes to read -- error on overflow */ len = nitems * size; if (size && len / size != nitems) { gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); return 0; } /* read len or fewer bytes to buf, return the number of full items read */ return len ? gz_read(state, buf, len) / size : 0; } /* -- see zlib.h -- */ #ifdef Z_PREFIX_SET # undef z_gzgetc #else # undef gzgetc #endif -int ZEXPORT gzgetc(file) - gzFile file; -{ +int ZEXPORT gzgetc(gzFile file) { unsigned char buf[1]; gz_statep state; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* try output buffer (no need to check for skip request) */ if (state->x.have) { state->x.have--; state->x.pos++; return *(state->x.next)++; } /* nothing there -- try gz_read() */ return gz_read(state, buf, 1) < 1 ? -1 : buf[0]; } -int ZEXPORT gzgetc_(file) -gzFile file; -{ +int ZEXPORT gzgetc_(gzFile file) { return gzgetc(file); } /* -- see zlib.h -- */ -int ZEXPORT gzungetc(c, file) - int c; - gzFile file; -{ +int ZEXPORT gzungetc(int c, gzFile file) { gz_statep state; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; + /* in case this was just opened, set up the input buffer */ + if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) + (void)gz_look(state); + /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return -1; /* process a skip request */ if (state->seek) { state->seek = 0; if (gz_skip(state, state->skip) == -1) return -1; } /* can't push EOF */ if (c < 0) return -1; /* if output buffer empty, put byte at end (allows more pushing) */ if (state->x.have == 0) { state->x.have = 1; state->x.next = state->out + (state->size << 1) - 1; state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; } /* if no room, give up (must have already done a gzungetc()) */ if (state->x.have == (state->size << 1)) { gz_error(state, Z_DATA_ERROR, "out of room to push characters"); return -1; } /* slide output data if needed and insert byte before existing data */ if (state->x.next == state->out) { unsigned char *src = state->out + state->x.have; unsigned char *dest = state->out + (state->size << 1); while (src > state->out) *--dest = *--src; state->x.next = dest; } state->x.have++; state->x.next--; state->x.next[0] = (unsigned char)c; state->x.pos--; state->past = 0; return c; } /* -- see zlib.h -- */ -char * ZEXPORT gzgets(file, buf, len) - gzFile file; - char *buf; - int len; -{ +char * ZEXPORT gzgets(gzFile file, char *buf, int len) { unsigned left, n; char *str; unsigned char *eol; gz_statep state; /* check parameters and get internal structure */ if (file == NULL || buf == NULL || len < 1) return NULL; state = (gz_statep)file; /* check that we're reading and that there's no (serious) error */ if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR)) return NULL; /* process a skip request */ if (state->seek) { state->seek = 0; if (gz_skip(state, state->skip) == -1) return NULL; } /* copy output bytes up to new line or len - 1, whichever comes first -- append a terminating zero to the string (we don't check for a zero in the contents, let the user worry about that) */ str = buf; left = (unsigned)len - 1; if (left) do { /* assure that something is in the output buffer */ if (state->x.have == 0 && gz_fetch(state) == -1) return NULL; /* error */ if (state->x.have == 0) { /* end of file */ state->past = 1; /* read past end */ break; /* return what we have */ } /* look for end-of-line in current output buffer */ n = state->x.have > left ? left : state->x.have; eol = (unsigned char *)memchr(state->x.next, '\n', n); if (eol != NULL) n = (unsigned)(eol - state->x.next) + 1; /* copy through end-of-line, or remainder if not found */ memcpy(buf, state->x.next, n); state->x.have -= n; state->x.next += n; state->x.pos += n; left -= n; buf += n; } while (left && eol == NULL); /* return terminated string, or if nothing, end of file */ if (buf == str) return NULL; buf[0] = 0; return str; } /* -- see zlib.h -- */ -int ZEXPORT gzdirect(file) - gzFile file; -{ +int ZEXPORT gzdirect(gzFile file) { gz_statep state; /* get internal structure */ if (file == NULL) return 0; state = (gz_statep)file; /* if the state is not known, but we can find out, then do so (this is mainly for right after a gzopen() or gzdopen()) */ if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0) (void)gz_look(state); /* return 1 if transparent, 0 if processing a gzip stream */ return state->direct; } /* -- see zlib.h -- */ -int ZEXPORT gzclose_r(file) - gzFile file; -{ +int ZEXPORT gzclose_r(gzFile file) { int ret, err; gz_statep state; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; /* check that we're reading */ if (state->mode != GZ_READ) return Z_STREAM_ERROR; /* free memory and close file */ if (state->size) { inflateEnd(&(state->strm)); free(state->out); free(state->in); } err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK; gz_error(state, Z_OK, NULL); free(state->path); ret = close(state->fd); free(state); return ret ? Z_ERRNO : err; } diff --git a/src/Common/zlib/gzwrite.c b/src/Common/zlib/gzwrite.c index eb8a0e58..435b4621 100644 --- a/src/Common/zlib/gzwrite.c +++ b/src/Common/zlib/gzwrite.c @@ -1,106 +1,95 @@ /* gzwrite.c -- zlib functions for writing gzip files * Copyright (C) 2004-2019 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "gzguts.h" -/* Local functions */ -local int gz_init OF((gz_statep)); -local int gz_comp OF((gz_statep, int)); -local int gz_zero OF((gz_statep, z_off64_t)); -local z_size_t gz_write OF((gz_statep, voidpc, z_size_t)); - /* Initialize state for writing a gzip file. Mark initialization by setting state->size to non-zero. Return -1 on a memory allocation failure, or 0 on success. */ -local int gz_init(state) - gz_statep state; -{ +local int gz_init(gz_statep state) { int ret; z_streamp strm = &(state->strm); /* allocate input buffer (double size for gzprintf) */ state->in = (unsigned char *)malloc(state->want << 1); if (state->in == NULL) { gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } /* only need output buffer and deflate state if compressing */ if (!state->direct) { /* allocate output buffer */ state->out = (unsigned char *)malloc(state->want); if (state->out == NULL) { free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } /* allocate deflate memory, set up for gzip compression */ strm->zalloc = Z_NULL; strm->zfree = Z_NULL; strm->opaque = Z_NULL; ret = deflateInit2(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy); if (ret != Z_OK) { free(state->out); free(state->in); gz_error(state, Z_MEM_ERROR, "out of memory"); return -1; } strm->next_in = NULL; } /* mark state as initialized */ state->size = state->want; /* initialize write buffer if compressing */ if (!state->direct) { strm->avail_out = state->size; strm->next_out = state->out; state->x.next = strm->next_out; } return 0; } /* Compress whatever is at avail_in and next_in and write to the output file. Return -1 if there is an error writing to the output file or if gz_init() fails to allocate memory, otherwise 0. flush is assumed to be a valid deflate() flush value. If flush is Z_FINISH, then the deflate() state is reset to start a new gzip stream. If gz->direct is true, then simply write to the output file without compressing, and ignore flush. */ -local int gz_comp(state, flush) - gz_statep state; - int flush; -{ +local int gz_comp(gz_statep state, int flush) { int ret, writ; unsigned have, put, max = ((unsigned)-1 >> 2) + 1; z_streamp strm = &(state->strm); /* allocate memory if this is the first time through */ if (state->size == 0 && gz_init(state) == -1) return -1; /* write directly if requested */ if (state->direct) { while (strm->avail_in) { put = strm->avail_in > max ? max : strm->avail_in; writ = write(state->fd, strm->next_in, put); if (writ < 0) { gz_error(state, Z_ERRNO, zstrerror()); return -1; } strm->avail_in -= (unsigned)writ; strm->next_in += writ; } return 0; } /* check for a pending reset */ if (state->reset) { /* don't start a new gzip member unless there is data to write */ if (strm->avail_in == 0) return 0; deflateReset(strm); state->reset = 0; @@ -124,98 +113,91 @@ local int gz_comp(state, flush) state->x.next += writ; } if (strm->avail_out == 0) { strm->avail_out = state->size; strm->next_out = state->out; state->x.next = state->out; } } /* compress */ have = strm->avail_out; ret = deflate(strm, flush); if (ret == Z_STREAM_ERROR) { gz_error(state, Z_STREAM_ERROR, "internal error: deflate stream corrupt"); return -1; } have -= strm->avail_out; } while (have); /* if that completed a deflate stream, allow another to start */ if (flush == Z_FINISH) state->reset = 1; /* all done, no errors */ return 0; } /* Compress len zeros to output. Return -1 on a write error or memory allocation failure by gz_comp(), or 0 on success. */ -local int gz_zero(state, len) - gz_statep state; - z_off64_t len; -{ +local int gz_zero(gz_statep state, z_off64_t len) { int first; unsigned n; z_streamp strm = &(state->strm); /* consume whatever's left in the input buffer */ if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1) return -1; /* compress len zeros (len guaranteed > 0) */ first = 1; while (len) { n = GT_OFF(state->size) || (z_off64_t)state->size > len ? (unsigned)len : state->size; if (first) { memset(state->in, 0, n); first = 0; } strm->avail_in = n; strm->next_in = state->in; state->x.pos += n; if (gz_comp(state, Z_NO_FLUSH) == -1) return -1; len -= n; } return 0; } /* Write len bytes from buf to file. Return the number of bytes written. If the returned value is less than len, then there was an error. */ -local z_size_t gz_write(state, buf, len) - gz_statep state; - voidpc buf; - z_size_t len; -{ +local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) { z_size_t put = len; /* if len is zero, avoid unnecessary operations */ if (len == 0) return 0; /* allocate memory if this is the first time through */ if (state->size == 0 && gz_init(state) == -1) return 0; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return 0; } /* for small len, copy to input buffer, otherwise compress directly */ if (len < state->size) { /* copy to input buffer, compress when full */ do { unsigned have, copy; if (state->strm.avail_in == 0) state->strm.next_in = state->in; have = (unsigned)((state->strm.next_in + state->strm.avail_in) - state->in); copy = state->size - have; if (copy > len) copy = (unsigned)len; @@ -225,198 +207,183 @@ local z_size_t gz_write(state, buf, len) buf = (const char *)buf + copy; len -= copy; if (len && gz_comp(state, Z_NO_FLUSH) == -1) return 0; } while (len); } else { /* consume whatever's left in the input buffer */ if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1) return 0; /* directly compress user buffer to file */ state->strm.next_in = (z_const Bytef *)buf; do { unsigned n = (unsigned)-1; if (n > len) n = (unsigned)len; state->strm.avail_in = n; state->x.pos += n; if (gz_comp(state, Z_NO_FLUSH) == -1) return 0; len -= n; } while (len); } /* input was all buffered or compressed */ return put; } /* -- see zlib.h -- */ -int ZEXPORT gzwrite(file, buf, len) - gzFile file; - voidpc buf; - unsigned len; -{ +int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) { gz_statep state; /* get internal structure */ if (file == NULL) return 0; state = (gz_statep)file; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return 0; /* since an int is returned, make sure len fits in one, otherwise return with an error (this avoids a flaw in the interface) */ if ((int)len < 0) { gz_error(state, Z_DATA_ERROR, "requested length does not fit in int"); return 0; } /* write len bytes from buf (the return value will fit in an int) */ return (int)gz_write(state, buf, len); } /* -- see zlib.h -- */ -z_size_t ZEXPORT gzfwrite(buf, size, nitems, file) - voidpc buf; - z_size_t size; - z_size_t nitems; - gzFile file; -{ +z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems, + gzFile file) { z_size_t len; gz_statep state; /* get internal structure */ if (file == NULL) return 0; state = (gz_statep)file; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return 0; /* compute bytes to read -- error on overflow */ len = nitems * size; if (size && len / size != nitems) { gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t"); return 0; } /* write len bytes to buf, return the number of full items written */ return len ? gz_write(state, buf, len) / size : 0; } /* -- see zlib.h -- */ -int ZEXPORT gzputc(file, c) - gzFile file; - int c; -{ +int ZEXPORT gzputc(gzFile file, int c) { unsigned have; unsigned char buf[1]; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; strm = &(state->strm); /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return -1; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return -1; } /* try writing to input buffer for speed (state->size == 0 if buffer not initialized) */ if (state->size) { if (strm->avail_in == 0) strm->next_in = state->in; have = (unsigned)((strm->next_in + strm->avail_in) - state->in); if (have < state->size) { state->in[have] = (unsigned char)c; strm->avail_in++; state->x.pos++; return c & 0xff; } } /* no room in buffer or not initialized, use gz_write() */ buf[0] = (unsigned char)c; if (gz_write(state, buf, 1) != 1) return -1; return c & 0xff; } /* -- see zlib.h -- */ -int ZEXPORT gzputs(file, s) - gzFile file; - const char *s; -{ +int ZEXPORT gzputs(gzFile file, const char *s) { z_size_t len, put; gz_statep state; /* get internal structure */ if (file == NULL) return -1; state = (gz_statep)file; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return -1; /* write string */ len = strlen(s); if ((int)len < 0 || (unsigned)len != len) { gz_error(state, Z_STREAM_ERROR, "string length does not fit in int"); return -1; } put = gz_write(state, s, len); return put < len ? -1 : (int)len; } #if defined(STDC) || defined(Z_HAVE_STDARG_H) #include <stdarg.h> /* -- see zlib.h -- */ -int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) -{ +int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) { int len; unsigned left; char *next; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) return state->err; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return state->err; } /* do the printf() into the input buffer, put length in len -- the input buffer is double-sized just for this function, so there is guaranteed to be state->size bytes available after the current contents */ @@ -433,81 +400,77 @@ int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) len = vsprintf(next, format, va); # endif #else # ifdef HAS_vsnprintf_void (void)vsnprintf(next, state->size, format, va); len = strlen(next); # else len = vsnprintf(next, state->size, format, va); # endif #endif /* check that printf() results fit in buffer */ if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0) return 0; /* update buffer and position, compress first half if past that */ strm->avail_in += (unsigned)len; state->x.pos += len; if (strm->avail_in >= state->size) { left = strm->avail_in - state->size; strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; } return len; } -int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) { va_list va; int ret; va_start(va, format); ret = gzvprintf(file, format, va); va_end(va); return ret; } #else /* !STDC && !Z_HAVE_STDARG_H */ /* -- see zlib.h -- */ -int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) - gzFile file; - const char *format; - int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; -{ +int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3, + int a4, int a5, int a6, int a7, int a8, int a9, int a10, + int a11, int a12, int a13, int a14, int a15, int a16, + int a17, int a18, int a19, int a20) { unsigned len, left; char *next; gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that can really pass pointer in ints */ if (sizeof(int) != sizeof(void *)) return Z_STREAM_ERROR; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return Z_STREAM_ERROR; /* make sure we have some buffer space */ if (state->size == 0 && gz_init(state) == -1) return state->error; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return state->error; } @@ -535,137 +498,128 @@ int ZEXPORTVA gzprintf(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); len = strlen(next); # else len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20); # endif #endif /* check that printf() results fit in buffer */ if (len == 0 || len >= state->size || next[state->size - 1] != 0) return 0; /* update buffer and position, compress first half if past that */ strm->avail_in += len; state->x.pos += len; if (strm->avail_in >= state->size) { left = strm->avail_in - state->size; strm->avail_in = state->size; if (gz_comp(state, Z_NO_FLUSH) == -1) return state->err; memmove(state->in, state->in + state->size, left); strm->next_in = state->in; strm->avail_in = left; } return (int)len; } #endif /* -- see zlib.h -- */ -int ZEXPORT gzflush(file, flush) - gzFile file; - int flush; -{ +int ZEXPORT gzflush(gzFile file, int flush) { gz_statep state; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; /* check that we're writing and that there's no error */ if (state->mode != GZ_WRITE || state->err != Z_OK) return Z_STREAM_ERROR; /* check flush parameter */ if (flush < 0 || flush > Z_FINISH) return Z_STREAM_ERROR; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return state->err; } /* compress remaining data with requested flush */ (void)gz_comp(state, flush); return state->err; } /* -- see zlib.h -- */ -int ZEXPORT gzsetparams(file, level, strategy) - gzFile file; - int level; - int strategy; -{ +int ZEXPORT gzsetparams(gzFile file, int level, int strategy) { gz_statep state; z_streamp strm; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; strm = &(state->strm); /* check that we're writing and that there's no error */ - if (state->mode != GZ_WRITE || state->err != Z_OK) + if (state->mode != GZ_WRITE || state->err != Z_OK || state->direct) return Z_STREAM_ERROR; /* if no change is requested, then do nothing */ if (level == state->level && strategy == state->strategy) return Z_OK; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) return state->err; } /* change compression parameters for subsequent input */ if (state->size) { /* flush previous input with previous parameters before changing */ if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1) return state->err; deflateParams(strm, level, strategy); } state->level = level; state->strategy = strategy; return Z_OK; } /* -- see zlib.h -- */ -int ZEXPORT gzclose_w(file) - gzFile file; -{ +int ZEXPORT gzclose_w(gzFile file) { int ret = Z_OK; gz_statep state; /* get internal structure */ if (file == NULL) return Z_STREAM_ERROR; state = (gz_statep)file; /* check that we're writing */ if (state->mode != GZ_WRITE) return Z_STREAM_ERROR; /* check for seek request */ if (state->seek) { state->seek = 0; if (gz_zero(state, state->skip) == -1) ret = state->err; } /* flush, free memory, and close file */ if (gz_comp(state, Z_FINISH) == -1) ret = state->err; if (state->size) { if (!state->direct) { (void)deflateEnd(&(state->strm)); free(state->out); } free(state->in); } gz_error(state, Z_OK, NULL); diff --git a/src/Common/zlib/infback.c b/src/Common/zlib/infback.c index babeaf18..e7b25b30 100644 --- a/src/Common/zlib/infback.c +++ b/src/Common/zlib/infback.c @@ -1,115 +1,106 @@ /* infback.c -- inflate using a call-back interface * Copyright (C) 1995-2022 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* This code is largely copied from inflate.c. Normally either infback.o or inflate.o would be linked into an application--not both. The interface with inffast.c is retained so that optimized assembler-coded versions of inflate_fast() can be used with either inflate.c or infback.c. */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" -/* function prototypes */ -local void fixedtables OF((struct inflate_state FAR *state)); - /* strm provides memory allocation functions in zalloc and zfree, or Z_NULL to use the library memory allocation functions. windowBits is in the range 8..15, and window is a user-supplied window and output buffer that is 2**windowBits bytes. */ -int ZEXPORT inflateBackInit_(strm, windowBits, window, version, stream_size) -z_streamp strm; -int windowBits; -unsigned char FAR *window; -const char *version; -int stream_size; -{ +int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, const char *version, + int stream_size) { struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL || window == Z_NULL || windowBits < 8 || windowBits > 15) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; #endif } if (strm->zfree == (free_func)0) #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zfree = zcfree; #endif state = (struct inflate_state FAR *)ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->dmax = 32768U; state->wbits = (uInt)windowBits; state->wsize = 1U << windowBits; state->window = window; state->wnext = 0; state->whave = 0; state->sane = 1; return Z_OK; } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; @@ -221,67 +212,62 @@ struct inflate_state FAR *state; } \ } while (0) /* strm provides the memory allocation functions and window buffer on input, and provides information on the unused input on return. For Z_DATA_ERROR returns, strm will also provide an error message. in() and out() are the call-back input and output functions. When inflateBack() needs more input, it calls in(). When inflateBack() has filled the window with output, or when it completes with data in the window, it calls out() to write out the data. The application must not change the provided input until in() is called again or inflateBack() returns. The application must not change the window/output buffer until inflateBack() returns. in() and out() are called with a descriptor parameter provided in the inflateBack() call. This parameter can be a structure that provides the information required to do the read or write, as well as accumulated information on the input and output such as totals and check values. in() should return zero on failure. out() should return non-zero on failure. If either in() or out() fails, than inflateBack() returns a Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it was in() or out() that caused in the error. Otherwise, inflateBack() returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format error, or Z_MEM_ERROR if it could not allocate memory for the state. inflateBack() can also return Z_STREAM_ERROR if the input parameters are not correct, i.e. strm is Z_NULL or the state was not initialized. */ -int ZEXPORT inflateBack(strm, in, in_desc, out, out_desc) -z_streamp strm; -in_func in; -void FAR *in_desc; -out_func out; -void FAR *out_desc; -{ +int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code here; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; /* Check that the strm exists and that the state was initialized */ if (strm == Z_NULL || strm->state == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* Reset the state */ strm->msg = Z_NULL; state->mode = TYPE; state->last = 0; state->whave = 0; next = strm->next_in; have = next != Z_NULL ? strm->avail_in : 0; hold = 0; bits = 0; put = state->window; @@ -605,40 +591,38 @@ void FAR *out_desc; } while (state->length != 0); break; case DONE: /* inflate stream terminated properly */ ret = Z_STREAM_END; goto inf_leave; case BAD: ret = Z_DATA_ERROR; goto inf_leave; default: /* can't happen, but makes compilers happy */ ret = Z_STREAM_ERROR; goto inf_leave; } /* Write leftover output and return unused input */ inf_leave: if (left < state->wsize) { if (out(out_desc, state->window, state->wsize - left) && ret == Z_STREAM_END) ret = Z_BUF_ERROR; } strm->next_in = next; strm->avail_in = have; return ret; } -int ZEXPORT inflateBackEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateBackEnd(z_streamp strm) { if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0) return Z_STREAM_ERROR; ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } diff --git a/src/Common/zlib/inffast.c b/src/Common/zlib/inffast.c index 1fec7f36..9354676e 100644 --- a/src/Common/zlib/inffast.c +++ b/src/Common/zlib/inffast.c @@ -20,64 +20,61 @@ example, a 16K input buffer and a 64K output buffer, more than 95% of the inflate execution time is spent in this routine. Entry assumptions: state->mode == LEN strm->avail_in >= 6 strm->avail_out >= 258 start >= strm->avail_out state->bits < 8 On return, state->mode is one of: LEN -- ran out of enough output space or enough available input TYPE -- reached end of block code, inflate() to interpret next block BAD -- error in block data Notes: - The maximum input bits used by a length/distance pair is 15 bits for the length code, 5 bits for the length extra, 15 bits for the distance code, and 13 bits for the distance extra. This totals 48 bits, or six bytes. Therefore if strm->avail_in >= 6, then there is enough input to avoid checking for available input while decoding. - The maximum bytes that a single length/distance pair can output is 258 bytes, which is the maximum length that can be coded. inflate_fast() requires strm->avail_out >= 258 for each loop to avoid checking for output space. */ -void ZLIB_INTERNAL inflate_fast(strm, start) -z_streamp strm; -unsigned start; /* inflate()'s starting value for strm->avail_out */ -{ +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start) { struct inflate_state FAR *state; z_const unsigned char FAR *in; /* local strm->next_in */ z_const unsigned char FAR *last; /* have enough input while in < last */ unsigned char FAR *out; /* local strm->next_out */ unsigned char FAR *beg; /* inflate()'s initial strm->next_out */ unsigned char FAR *end; /* while out < end, enough space available */ #ifdef INFLATE_STRICT unsigned dmax; /* maximum distance from zlib header */ #endif unsigned wsize; /* window size or zero if not using window */ unsigned whave; /* valid bytes in the window */ unsigned wnext; /* window write index */ unsigned char FAR *window; /* allocated sliding window, if wsize != 0 */ unsigned long hold; /* local strm->hold */ unsigned bits; /* local strm->bits */ code const FAR *lcode; /* local strm->lencode */ code const FAR *dcode; /* local strm->distcode */ unsigned lmask; /* mask for first level of length codes */ unsigned dmask; /* mask for first level of distance codes */ code const *here; /* retrieved table entry */ unsigned op; /* code bits, operation, extra bits, or */ /* window position, window bytes to copy */ unsigned len; /* match length, unused bytes */ unsigned dist; /* match distance */ unsigned char FAR *from; /* where to copy match from */ /* copy state to local variables */ state = (struct inflate_state FAR *)strm->state; in = strm->next_in; last = in + (strm->avail_in - 5); diff --git a/src/Common/zlib/inffast.h b/src/Common/zlib/inffast.h index e5c1aa4c..49c6d156 100644 --- a/src/Common/zlib/inffast.h +++ b/src/Common/zlib/inffast.h @@ -1,11 +1,11 @@ /* inffast.h -- header to use inffast.c * Copyright (C) 1995-2003, 2010 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ -void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); +void ZLIB_INTERNAL inflate_fast(z_streamp strm, unsigned start); diff --git a/src/Common/zlib/inflate.c b/src/Common/zlib/inflate.c index 8acbef44..94ecff01 100644 --- a/src/Common/zlib/inflate.c +++ b/src/Common/zlib/inflate.c @@ -64,250 +64,219 @@ * - Typecasting all around to reduce compiler warnings * - Changed loops from while (1) or do {} while (1) to for (;;), again to * make compilers happy * - Changed type of window in inflateBackInit() to unsigned char * * * 1.2.beta7 27 Jan 2003 * - Changed many types to unsigned or unsigned short to avoid warnings * - Added inflateCopy() function * * 1.2.0 9 Mar 2003 * - Changed inflateBack() interface to provide separate opaque descriptors * for the in() and out() functions * - Changed inflateBack() argument and in_func typedef to swap the length * and buffer address return values for the input function * - Check next_in and next_out for Z_NULL on entry to inflate() * * The history for versions after 1.2.0 are in ChangeLog in zlib distribution. */ #include "zutil.h" #include "inftrees.h" #include "inflate.h" #include "inffast.h" #ifdef MAKEFIXED # ifndef BUILDFIXED # define BUILDFIXED # endif #endif -/* function prototypes */ -local int inflateStateCheck OF((z_streamp strm)); -local void fixedtables OF((struct inflate_state FAR *state)); -local int updatewindow OF((z_streamp strm, const unsigned char FAR *end, - unsigned copy)); -#ifdef BUILDFIXED - void makefixed OF((void)); -#endif -local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf, - unsigned len)); - -local int inflateStateCheck(strm) -z_streamp strm; -{ +local int inflateStateCheck(z_streamp strm) { struct inflate_state FAR *state; if (strm == Z_NULL || strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0) return 1; state = (struct inflate_state FAR *)strm->state; if (state == Z_NULL || state->strm != strm || state->mode < HEAD || state->mode > SYNC) return 1; return 0; } -int ZEXPORT inflateResetKeep(strm) -z_streamp strm; -{ +int ZEXPORT inflateResetKeep(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; strm->total_in = strm->total_out = state->total = 0; strm->msg = Z_NULL; if (state->wrap) /* to support ill-conceived Java test suite */ strm->adler = state->wrap & 1; state->mode = HEAD; state->last = 0; state->havedict = 0; state->flags = -1; state->dmax = 32768U; state->head = Z_NULL; state->hold = 0; state->bits = 0; state->lencode = state->distcode = state->next = state->codes; state->sane = 1; state->back = -1; Tracev((stderr, "inflate: reset\n")); return Z_OK; } -int ZEXPORT inflateReset(strm) -z_streamp strm; -{ +int ZEXPORT inflateReset(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; state->wsize = 0; state->whave = 0; state->wnext = 0; return inflateResetKeep(strm); } -int ZEXPORT inflateReset2(strm, windowBits) -z_streamp strm; -int windowBits; -{ +int ZEXPORT inflateReset2(z_streamp strm, int windowBits) { int wrap; struct inflate_state FAR *state; /* get the state */ if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* extract wrap request from windowBits parameter */ if (windowBits < 0) { if (windowBits < -15) return Z_STREAM_ERROR; wrap = 0; windowBits = -windowBits; } else { wrap = (windowBits >> 4) + 5; #ifdef GUNZIP if (windowBits < 48) windowBits &= 15; #endif } /* set number of window bits, free window if different */ if (windowBits && (windowBits < 8 || windowBits > 15)) return Z_STREAM_ERROR; if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) { ZFREE(strm, state->window); state->window = Z_NULL; } /* update state and reset the rest of it */ state->wrap = wrap; state->wbits = (unsigned)windowBits; return inflateReset(strm); } -int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size) -z_streamp strm; -int windowBits; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size) { int ret; struct inflate_state FAR *state; if (version == Z_NULL || version[0] != ZLIB_VERSION[0] || stream_size != (int)(sizeof(z_stream))) return Z_VERSION_ERROR; if (strm == Z_NULL) return Z_STREAM_ERROR; strm->msg = Z_NULL; /* in case we return an error */ if (strm->zalloc == (alloc_func)0) { #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zalloc = zcalloc; strm->opaque = (voidpf)0; #endif } if (strm->zfree == (free_func)0) #ifdef Z_SOLO return Z_STREAM_ERROR; #else strm->zfree = zcfree; #endif state = (struct inflate_state FAR *) ZALLOC(strm, 1, sizeof(struct inflate_state)); if (state == Z_NULL) return Z_MEM_ERROR; Tracev((stderr, "inflate: allocated\n")); strm->state = (struct internal_state FAR *)state; state->strm = strm; state->window = Z_NULL; state->mode = HEAD; /* to pass state test in inflateReset2() */ ret = inflateReset2(strm, windowBits); if (ret != Z_OK) { ZFREE(strm, state); strm->state = Z_NULL; } return ret; } -int ZEXPORT inflateInit_(strm, version, stream_size) -z_streamp strm; -const char *version; -int stream_size; -{ +int ZEXPORT inflateInit_(z_streamp strm, const char *version, + int stream_size) { return inflateInit2_(strm, DEF_WBITS, version, stream_size); } -int ZEXPORT inflatePrime(strm, bits, value) -z_streamp strm; -int bits; -int value; -{ +int ZEXPORT inflatePrime(z_streamp strm, int bits, int value) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; + if (bits == 0) + return Z_OK; state = (struct inflate_state FAR *)strm->state; if (bits < 0) { state->hold = 0; state->bits = 0; return Z_OK; } if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR; value &= (1L << bits) - 1; state->hold += (unsigned)value << state->bits; state->bits += (uInt)bits; return Z_OK; } /* Return state with length and distance decoding tables and index sizes set to fixed code decoding. Normally this returns fixed tables from inffixed.h. If BUILDFIXED is defined, then instead this routine builds the tables the first time it's called, and returns those tables the first time and thereafter. This reduces the size of the code by about 2K bytes, in exchange for a little execution time. However, BUILDFIXED should not be used for threaded applications, since the rewriting of the tables and virgin may not be thread-safe. */ -local void fixedtables(state) -struct inflate_state FAR *state; -{ +local void fixedtables(struct inflate_state FAR *state) { #ifdef BUILDFIXED static int virgin = 1; static code *lenfix, *distfix; static code fixed[544]; /* build fixed huffman tables if first call (may not be thread safe) */ if (virgin) { unsigned sym, bits; static code *next; /* literal/length table */ sym = 0; while (sym < 144) state->lens[sym++] = 8; while (sym < 256) state->lens[sym++] = 9; while (sym < 280) state->lens[sym++] = 7; while (sym < 288) state->lens[sym++] = 8; next = fixed; lenfix = next; bits = 9; inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work); /* distance table */ sym = 0; while (sym < 32) state->lens[sym++] = 5; distfix = next; bits = 5; inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work); /* do this just once */ virgin = 0; @@ -315,119 +284,115 @@ struct inflate_state FAR *state; #else /* !BUILDFIXED */ # include "inffixed.h" #endif /* BUILDFIXED */ state->lencode = lenfix; state->lenbits = 9; state->distcode = distfix; state->distbits = 5; } #ifdef MAKEFIXED #include <stdio.h> /* Write out the inffixed.h that is #include'd above. Defining MAKEFIXED also defines BUILDFIXED, so the tables are built on the fly. makefixed() writes those tables to stdout, which would be piped to inffixed.h. A small program can simply call makefixed to do this: void makefixed(void); int main(void) { makefixed(); return 0; } Then that can be linked with zlib built with MAKEFIXED defined and run: a.out > inffixed.h */ -void makefixed() +void makefixed(void) { unsigned low, size; struct inflate_state state; fixedtables(&state); puts(" /* inffixed.h -- table for decoding fixed codes"); puts(" * Generated automatically by makefixed()."); puts(" */"); puts(""); puts(" /* WARNING: this file should *not* be used by applications."); puts(" It is part of the implementation of this library and is"); puts(" subject to change. Applications should only use zlib.h."); puts(" */"); puts(""); size = 1U << 9; printf(" static const code lenfix[%u] = {", size); low = 0; for (;;) { if ((low % 7) == 0) printf("\n "); printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op, state.lencode[low].bits, state.lencode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); size = 1U << 5; printf("\n static const code distfix[%u] = {", size); low = 0; for (;;) { if ((low % 6) == 0) printf("\n "); printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); if (++low == size) break; putchar(','); } puts("\n };"); } #endif /* MAKEFIXED */ /* Update the window with the last wsize (normally 32K) bytes written before returning. If window does not exist yet, create it. This is only called when a window is already in use, or when output has been written during this inflate call, but the end of the deflate stream has not been reached yet. It is also called to create a window for dictionary data when a dictionary is loaded. Providing output buffers larger than 32K to inflate() should provide a speed advantage, since only the last 32K of output is copied to the sliding window upon return from inflate(), and since all distances after the first 32K of output will fall in the output data, making match copies simpler and faster. The advantage may be dependent on the size of the processor's data caches. */ -local int updatewindow(strm, end, copy) -z_streamp strm; -const Bytef *end; -unsigned copy; -{ +local int updatewindow(z_streamp strm, const Bytef *end, unsigned copy) { struct inflate_state FAR *state; unsigned dist; state = (struct inflate_state FAR *)strm->state; /* if it hasn't been done already, allocate space for the window */ if (state->window == Z_NULL) { state->window = (unsigned char FAR *) ZALLOC(strm, 1U << state->wbits, sizeof(unsigned char)); if (state->window == Z_NULL) return 1; } /* if window not in use yet, initialize */ if (state->wsize == 0) { state->wsize = 1U << state->wbits; state->wnext = 0; state->whave = 0; } /* copy state->wsize or less output bytes into the circular window */ if (copy >= state->wsize) { zmemcpy(state->window, end - state->wsize, state->wsize); state->wnext = 0; state->whave = state->wsize; } else { dist = state->wsize - state->wnext; if (dist > copy) dist = copy; zmemcpy(state->window + state->wnext, end - copy, dist); @@ -595,64 +560,61 @@ unsigned copy; state = STATEx; case STATEx: As shown above, if the next state is also the next case, then the break is omitted. A state may also return if there is not enough output space available to complete that state. Those states are copying stored data, writing a literal byte, and copying a matching string. When returning, a "goto inf_leave" is used to update the total counters, update the check value, and determine whether any progress has been made during that inflate() call in order to return the proper return code. Progress is defined as a change in either strm->avail_in or strm->avail_out. When there is a window, goto inf_leave will update the window with the last output written. If a goto inf_leave occurs in the middle of decompression and there is no window currently, goto inf_leave will create one and copy output to the window for the next call of inflate(). In this implementation, the flush parameter of inflate() only affects the return code (per zlib.h). inflate() always writes as much as possible to strm->next_out, given the space available and the provided input--the effect documented in zlib.h of Z_SYNC_FLUSH. Furthermore, inflate() always defers the allocation of and copying into a sliding window until necessary, which provides the effect documented in zlib.h for Z_FINISH when the entire input stream available. So the only thing the flush parameter actually does is: when flush is set to Z_FINISH, inflate() cannot return Z_OK. Instead it will return Z_BUF_ERROR if it has not reached the end of the stream. */ -int ZEXPORT inflate(strm, flush) -z_streamp strm; -int flush; -{ +int ZEXPORT inflate(z_streamp strm, int flush) { struct inflate_state FAR *state; z_const unsigned char FAR *next; /* next input */ unsigned char FAR *put; /* next output */ unsigned have, left; /* available input and output */ unsigned long hold; /* bit buffer */ unsigned bits; /* bits in bit buffer */ unsigned in, out; /* save starting available input and output */ unsigned copy; /* number of stored or match bytes to copy */ unsigned char FAR *from; /* where to copy match bytes from */ code here; /* current decoding table entry */ code last; /* parent table entry */ unsigned len; /* length to copy for repeats, bits to drop */ int ret; /* return code */ #ifdef GUNZIP unsigned char hbuf[4]; /* buffer for gzip header crc calculation */ #endif static const unsigned short order[19] = /* permutation of code lengths */ {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; if (inflateStateCheck(strm) || strm->next_out == Z_NULL || (strm->next_in == Z_NULL && strm->avail_in != 0)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->mode == TYPE) state->mode = TYPEDO; /* skip check */ LOAD(); in = have; out = left; ret = Z_OK; for (;;) @@ -1274,322 +1236,291 @@ int flush; /* Return from inflate(), updating the total counts and the check value. If there was no progress during the inflate() call, return a buffer error. Call updatewindow() to create and/or update the window state. Note: a memory error from inflate() is non-recoverable. */ inf_leave: RESTORE(); if (state->wsize || (out != strm->avail_out && state->mode < BAD && (state->mode < CHECK || flush != Z_FINISH))) if (updatewindow(strm, strm->next_out, out - strm->avail_out)) { state->mode = MEM; return Z_MEM_ERROR; } in -= strm->avail_in; out -= strm->avail_out; strm->total_in += in; strm->total_out += out; state->total += out; if ((state->wrap & 4) && out) strm->adler = state->check = UPDATE_CHECK(state->check, strm->next_out - out, out); strm->data_type = (int)state->bits + (state->last ? 64 : 0) + (state->mode == TYPE ? 128 : 0) + (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0); if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK) ret = Z_BUF_ERROR; return ret; } -int ZEXPORT inflateEnd(strm) -z_streamp strm; -{ +int ZEXPORT inflateEnd(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->window != Z_NULL) ZFREE(strm, state->window); ZFREE(strm, strm->state); strm->state = Z_NULL; Tracev((stderr, "inflate: end\n")); return Z_OK; } -int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength) -z_streamp strm; -Bytef *dictionary; -uInt *dictLength; -{ +int ZEXPORT inflateGetDictionary(z_streamp strm, Bytef *dictionary, + uInt *dictLength) { struct inflate_state FAR *state; /* check state */ if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; /* copy dictionary */ if (state->whave && dictionary != Z_NULL) { zmemcpy(dictionary, state->window + state->wnext, state->whave - state->wnext); zmemcpy(dictionary + state->whave - state->wnext, state->window, state->wnext); } if (dictLength != Z_NULL) *dictLength = state->whave; return Z_OK; } -int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength) -z_streamp strm; -const Bytef *dictionary; -uInt dictLength; -{ +int ZEXPORT inflateSetDictionary(z_streamp strm, const Bytef *dictionary, + uInt dictLength) { struct inflate_state FAR *state; unsigned long dictid; int ret; /* check state */ if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (state->wrap != 0 && state->mode != DICT) return Z_STREAM_ERROR; /* check for correct dictionary identifier */ if (state->mode == DICT) { dictid = adler32(0L, Z_NULL, 0); dictid = adler32(dictid, dictionary, dictLength); if (dictid != state->check) return Z_DATA_ERROR; } /* copy dictionary to window using updatewindow(), which will amend the existing dictionary if appropriate */ ret = updatewindow(strm, dictionary + dictLength, dictLength); if (ret) { state->mode = MEM; return Z_MEM_ERROR; } state->havedict = 1; Tracev((stderr, "inflate: dictionary set\n")); return Z_OK; } -int ZEXPORT inflateGetHeader(strm, head) -z_streamp strm; -gz_headerp head; -{ +int ZEXPORT inflateGetHeader(z_streamp strm, gz_headerp head) { struct inflate_state FAR *state; /* check state */ if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if ((state->wrap & 2) == 0) return Z_STREAM_ERROR; /* save header structure */ state->head = head; head->done = 0; return Z_OK; } /* Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff. Return when found or when out of input. When called, *have is the number of pattern bytes found in order so far, in 0..3. On return *have is updated to the new state. If on return *have equals four, then the pattern was found and the return value is how many bytes were read including the last byte of the pattern. If *have is less than four, then the pattern has not been found yet and the return value is len. In the latter case, syncsearch() can be called again with more data and the *have state. *have is initialized to zero for the first call. */ -local unsigned syncsearch(have, buf, len) -unsigned FAR *have; -const unsigned char FAR *buf; -unsigned len; -{ +local unsigned syncsearch(unsigned FAR *have, const unsigned char FAR *buf, + unsigned len) { unsigned got; unsigned next; got = *have; next = 0; while (next < len && got < 4) { if ((int)(buf[next]) == (got < 2 ? 0 : 0xff)) got++; else if (buf[next]) got = 0; else got = 4 - got; next++; } *have = got; return next; } -int ZEXPORT inflateSync(strm) -z_streamp strm; -{ +int ZEXPORT inflateSync(z_streamp strm) { unsigned len; /* number of bytes to look at or looked at */ int flags; /* temporary to save header status */ unsigned long in, out; /* temporary to save total_in and total_out */ unsigned char buf[4]; /* to restore bit buffer to byte string */ struct inflate_state FAR *state; /* check parameters */ if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR; /* if first time, start search in bit buffer */ if (state->mode != SYNC) { state->mode = SYNC; - state->hold <<= state->bits & 7; + state->hold >>= state->bits & 7; state->bits -= state->bits & 7; len = 0; while (state->bits >= 8) { buf[len++] = (unsigned char)(state->hold); state->hold >>= 8; state->bits -= 8; } state->have = 0; syncsearch(&(state->have), buf, len); } /* search available input */ len = syncsearch(&(state->have), strm->next_in, strm->avail_in); strm->avail_in -= len; strm->next_in += len; strm->total_in += len; /* return no joy or set up to restart inflate() on a new block */ if (state->have != 4) return Z_DATA_ERROR; if (state->flags == -1) state->wrap = 0; /* if no header yet, treat as raw */ else state->wrap &= ~4; /* no point in computing a check value now */ flags = state->flags; in = strm->total_in; out = strm->total_out; inflateReset(strm); strm->total_in = in; strm->total_out = out; state->flags = flags; state->mode = TYPE; return Z_OK; } /* Returns true if inflate is currently at the end of a block generated by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored block. When decompressing, PPP checks that at the end of input packet, inflate is waiting for these length bytes. */ -int ZEXPORT inflateSyncPoint(strm) -z_streamp strm; -{ +int ZEXPORT inflateSyncPoint(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; return state->mode == STORED && state->bits == 0; } -int ZEXPORT inflateCopy(dest, source) -z_streamp dest; -z_streamp source; -{ +int ZEXPORT inflateCopy(z_streamp dest, z_streamp source) { struct inflate_state FAR *state; struct inflate_state FAR *copy; unsigned char FAR *window; unsigned wsize; /* check input */ if (inflateStateCheck(source) || dest == Z_NULL) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)source->state; /* allocate space */ copy = (struct inflate_state FAR *) ZALLOC(source, 1, sizeof(struct inflate_state)); if (copy == Z_NULL) return Z_MEM_ERROR; window = Z_NULL; if (state->window != Z_NULL) { window = (unsigned char FAR *) ZALLOC(source, 1U << state->wbits, sizeof(unsigned char)); if (window == Z_NULL) { ZFREE(source, copy); return Z_MEM_ERROR; } } /* copy state */ zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream)); zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state)); copy->strm = dest; if (state->lencode >= state->codes && state->lencode <= state->codes + ENOUGH - 1) { copy->lencode = copy->codes + (state->lencode - state->codes); copy->distcode = copy->codes + (state->distcode - state->codes); } copy->next = copy->codes + (state->next - state->codes); if (window != Z_NULL) { wsize = 1U << state->wbits; zmemcpy(window, state->window, wsize); } copy->window = window; dest->state = (struct internal_state FAR *)copy; return Z_OK; } -int ZEXPORT inflateUndermine(strm, subvert) -z_streamp strm; -int subvert; -{ +int ZEXPORT inflateUndermine(z_streamp strm, int subvert) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; #ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR state->sane = !subvert; return Z_OK; #else (void)subvert; state->sane = 1; return Z_DATA_ERROR; #endif } -int ZEXPORT inflateValidate(strm, check) -z_streamp strm; -int check; -{ +int ZEXPORT inflateValidate(z_streamp strm, int check) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return Z_STREAM_ERROR; state = (struct inflate_state FAR *)strm->state; if (check && state->wrap) state->wrap |= 4; else state->wrap &= ~4; return Z_OK; } -long ZEXPORT inflateMark(strm) -z_streamp strm; -{ +long ZEXPORT inflateMark(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return -(1L << 16); state = (struct inflate_state FAR *)strm->state; return (long)(((unsigned long)((long)state->back)) << 16) + (state->mode == COPY ? state->length : (state->mode == MATCH ? state->was - state->length : 0)); } -unsigned long ZEXPORT inflateCodesUsed(strm) -z_streamp strm; -{ +unsigned long ZEXPORT inflateCodesUsed(z_streamp strm) { struct inflate_state FAR *state; if (inflateStateCheck(strm)) return (unsigned long)-1; state = (struct inflate_state FAR *)strm->state; return (unsigned long)(state->next - state->codes); } diff --git a/src/Common/zlib/inftrees.c b/src/Common/zlib/inftrees.c index 57d2793b..98cfe164 100644 --- a/src/Common/zlib/inftrees.c +++ b/src/Common/zlib/inftrees.c @@ -1,95 +1,90 @@ /* inftrees.c -- generate Huffman trees for efficient decoding - * Copyright (C) 1995-2022 Mark Adler + * Copyright (C) 1995-2024 Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ #include "zutil.h" #include "inftrees.h" #define MAXBITS 15 const char inflate_copyright[] = - " inflate 1.2.13 Copyright 1995-2022 Mark Adler "; + " inflate 1.3.1 Copyright 1995-2024 Mark Adler "; /* If you use the zlib library in a product, an acknowledgment is welcome in the documentation of your product. If for some reason you cannot include such an acknowledgment, I would appreciate that you keep this copyright string in the executable of your product. */ /* Build a set of tables to decode the provided canonical Huffman code. The code lengths are lens[0..codes-1]. The result starts at *table, whose indices are 0..2^bits-1. work is a writable array of at least lens shorts, which is used as a work area. type is the type of code to be generated, CODES, LENS, or DISTS. On return, zero is success, -1 is an invalid code, and +1 means that ENOUGH isn't enough. table on return points to the next available entry's address. bits is the requested root table index bits, and on return it is the actual root table index bits. It will differ if the request is greater than the longest code or if it is less than the shortest code. */ -int ZLIB_INTERNAL inflate_table(type, lens, codes, table, bits, work) -codetype type; -unsigned short FAR *lens; -unsigned codes; -code FAR * FAR *table; -unsigned FAR *bits; -unsigned short FAR *work; -{ +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work) { unsigned len; /* a code's length in bits */ unsigned sym; /* index of code symbols */ unsigned min, max; /* minimum and maximum code lengths */ unsigned root; /* number of index bits for root table */ unsigned curr; /* number of index bits for current table */ unsigned drop; /* code bits to drop for sub-table */ int left; /* number of prefix codes available */ unsigned used; /* code entries in table used */ unsigned huff; /* Huffman code */ unsigned incr; /* for incrementing code, index */ unsigned fill; /* index for replicating entries */ unsigned low; /* low bits for current root entry */ unsigned mask; /* mask for low root bits */ code here; /* table entry for duplication */ code FAR *next; /* next available space in table */ const unsigned short FAR *base; /* base value table to use */ const unsigned short FAR *extra; /* extra bits table to use */ unsigned match; /* use base and extra for symbol >= match */ unsigned short count[MAXBITS+1]; /* number of codes of each length */ unsigned short offs[MAXBITS+1]; /* offsets in table for each length */ static const unsigned short lbase[31] = { /* Length codes 257..285 base */ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0}; static const unsigned short lext[31] = { /* Length codes 257..285 extra */ 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18, - 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 194, 65}; + 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77}; static const unsigned short dbase[32] = { /* Distance codes 0..29 base */ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577, 0, 0}; static const unsigned short dext[32] = { /* Distance codes 0..29 extra */ 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22, 23, 23, 24, 24, 25, 25, 26, 26, 27, 27, 28, 28, 29, 29, 64, 64}; /* Process a set of code lengths to create a canonical Huffman code. The code lengths are lens[0..codes-1]. Each length corresponds to the symbols 0..codes-1. The Huffman code is generated by first sorting the symbols by length from short to long, and retaining the symbol order for codes with equal lengths. Then the code starts with all zero bits for the first code of the shortest length, and the codes are integer increments for the same length, and zeros are appended as the length increases. For the deflate format, these bits are stored backwards from their more natural integer increment ordering, and so when the decoding tables are built in the large loop below, the integer codes are incremented backwards. This routine assumes, but does not check, that all of the entries in lens[] are in the range 0..MAXBITS. The caller must assure this. 1..MAXBITS is interpreted as that code length. zero means that that symbol does not occur in this code. The codes are sorted by computing a count of codes for each length, creating from that a table of starting indices for each length in the sorted table, and then entering the symbols in order in the sorted diff --git a/src/Common/zlib/inftrees.h b/src/Common/zlib/inftrees.h index f5366531..396f74b5 100644 --- a/src/Common/zlib/inftrees.h +++ b/src/Common/zlib/inftrees.h @@ -14,49 +14,49 @@ table that indexes more bits of the code. op indicates whether the entry is a pointer to another table, a literal, a length or distance, an end-of-block, or an invalid code. For a table pointer, the low four bits of op is the number of index bits of that table. For a length or distance, the low four bits of op is the number of extra bits to get after the code. bits is the number of bits in this code or part of the code to drop off of the bit buffer. val is the actual byte to output in the case of a literal, the base length or distance, or the offset from the current table to the next table. Each entry is four bytes. */ typedef struct { unsigned char op; /* operation, extra bits, table bits */ unsigned char bits; /* bits in this part of the code */ unsigned short val; /* offset in table or code value */ } code; /* op values as set by inflate_table(): 00000000 - literal 0000tttt - table link, tttt != 0 is the number of table index bits 0001eeee - length or distance, eeee is the number of extra bits 01100000 - end of block 01000000 - invalid code */ /* Maximum size of the dynamic table. The maximum number of code structures is 1444, which is the sum of 852 for literal/length codes and 592 for distance codes. These values were found by exhaustive searches using the program examples/enough.c found in the zlib distribution. The arguments to that program are the number of symbols, the initial root table size, and the maximum bit length of a code. "enough 286 9 15" for literal/length codes - returns returns 852, and "enough 30 6 15" for distance codes returns 592. - The initial root table size (9 or 6) is found in the fifth argument of the + returns 852, and "enough 30 6 15" for distance codes returns 592. The + initial root table size (9 or 6) is found in the fifth argument of the inflate_table() calls in inflate.c and infback.c. If the root table size is changed, then these maximum sizes would be need to be recalculated and updated. */ #define ENOUGH_LENS 852 #define ENOUGH_DISTS 592 #define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS) /* Type of code to build for inflate_table() */ typedef enum { CODES, LENS, DISTS } codetype; -int ZLIB_INTERNAL inflate_table OF((codetype type, unsigned short FAR *lens, - unsigned codes, code FAR * FAR *table, - unsigned FAR *bits, unsigned short FAR *work)); +int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens, + unsigned codes, code FAR * FAR *table, + unsigned FAR *bits, unsigned short FAR *work); diff --git a/src/Common/zlib/trees.c b/src/Common/zlib/trees.c index 5f305c47..6a523ef3 100644 --- a/src/Common/zlib/trees.c +++ b/src/Common/zlib/trees.c @@ -1,32 +1,32 @@ /* trees.c -- output deflated data using Huffman coding - * Copyright (C) 1995-2021 Jean-loup Gailly + * Copyright (C) 1995-2024 Jean-loup Gailly * detect_data_type() function provided freely by Cosmin Truta, 2006 * For conditions of distribution and use, see copyright notice in zlib.h */ /* * ALGORITHM * * The "deflation" process uses several Huffman trees. The more * common source values are represented by shorter bit sequences. * * Each code tree is stored in a compressed form which is itself * a Huffman encoding of the lengths of all the code strings (in * ascending order by source values). The actual code strings are * reconstructed from the lengths in the inflate process, as described * in the deflate specification. * * REFERENCES * * Deutsch, L.P.,"'Deflate' Compressed Data Format Specification". * Available in ftp.uu.net:/pub/archiving/zip/doc/deflate-1.1.doc * * Storer, James A. * Data Compression: Methods and Theory, pp. 49-50. * Computer Science Press, 1988. ISBN 0-7167-8156-5. * * Sedgewick, R. * Algorithms, p290. * Addison-Wesley, 1983. ISBN 0-201-06672-6. */ @@ -95,169 +95,230 @@ local ct_data static_dtree[D_CODES]; * 5 bits.) */ uch _dist_code[DIST_CODE_LEN]; /* Distance codes. The first 256 values correspond to the distances * 3 .. 258, the last 256 values correspond to the top 8 bits of * the 15 bit distances. */ uch _length_code[MAX_MATCH-MIN_MATCH+1]; /* length code for each normalized match length (0 == MIN_MATCH) */ local int base_length[LENGTH_CODES]; /* First normalized length for each code (0 = MIN_MATCH) */ local int base_dist[D_CODES]; /* First normalized distance for each code (0 = distance of 1) */ #else # include "trees.h" #endif /* GEN_TREES_H */ struct static_tree_desc_s { const ct_data *static_tree; /* static tree or NULL */ const intf *extra_bits; /* extra bits for each code or NULL */ int extra_base; /* base index for extra_bits */ int elems; /* max number of elements in the tree */ int max_length; /* max bit length for the codes */ }; -local const static_tree_desc static_l_desc = +#ifdef NO_INIT_GLOBAL_POINTERS +# define TCONST +#else +# define TCONST const +#endif + +local TCONST static_tree_desc static_l_desc = {static_ltree, extra_lbits, LITERALS+1, L_CODES, MAX_BITS}; -local const static_tree_desc static_d_desc = +local TCONST static_tree_desc static_d_desc = {static_dtree, extra_dbits, 0, D_CODES, MAX_BITS}; -local const static_tree_desc static_bl_desc = +local TCONST static_tree_desc static_bl_desc = {(const ct_data *)0, extra_blbits, 0, BL_CODES, MAX_BL_BITS}; /* =========================================================================== - * Local (static) routines in this file. + * Output a short LSB first on the stream. + * IN assertion: there is enough room in pendingBuf. + */ +#define put_short(s, w) { \ + put_byte(s, (uch)((w) & 0xff)); \ + put_byte(s, (uch)((ush)(w) >> 8)); \ +} + +/* =========================================================================== + * Reverse the first len bits of a code, using straightforward code (a faster + * method would use a table) + * IN assertion: 1 <= len <= 15 */ +local unsigned bi_reverse(unsigned code, int len) { + register unsigned res = 0; + do { + res |= code & 1; + code >>= 1, res <<= 1; + } while (--len > 0); + return res >> 1; +} -local void tr_static_init OF((void)); -local void init_block OF((deflate_state *s)); -local void pqdownheap OF((deflate_state *s, ct_data *tree, int k)); -local void gen_bitlen OF((deflate_state *s, tree_desc *desc)); -local void gen_codes OF((ct_data *tree, int max_code, ushf *bl_count)); -local void build_tree OF((deflate_state *s, tree_desc *desc)); -local void scan_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local void send_tree OF((deflate_state *s, ct_data *tree, int max_code)); -local int build_bl_tree OF((deflate_state *s)); -local void send_all_trees OF((deflate_state *s, int lcodes, int dcodes, - int blcodes)); -local void compress_block OF((deflate_state *s, const ct_data *ltree, - const ct_data *dtree)); -local int detect_data_type OF((deflate_state *s)); -local unsigned bi_reverse OF((unsigned code, int len)); -local void bi_windup OF((deflate_state *s)); -local void bi_flush OF((deflate_state *s)); +/* =========================================================================== + * Flush the bit buffer, keeping at most 7 bits in it. + */ +local void bi_flush(deflate_state *s) { + if (s->bi_valid == 16) { + put_short(s, s->bi_buf); + s->bi_buf = 0; + s->bi_valid = 0; + } else if (s->bi_valid >= 8) { + put_byte(s, (Byte)s->bi_buf); + s->bi_buf >>= 8; + s->bi_valid -= 8; + } +} + +/* =========================================================================== + * Flush the bit buffer and align the output on a byte boundary + */ +local void bi_windup(deflate_state *s) { + if (s->bi_valid > 8) { + put_short(s, s->bi_buf); + } else if (s->bi_valid > 0) { + put_byte(s, (Byte)s->bi_buf); + } + s->bi_buf = 0; + s->bi_valid = 0; +#ifdef ZLIB_DEBUG + s->bits_sent = (s->bits_sent + 7) & ~7; +#endif +} + +/* =========================================================================== + * Generate the codes for a given tree and bit counts (which need not be + * optimal). + * IN assertion: the array bl_count contains the bit length statistics for + * the given tree and the field len is set for all tree elements. + * OUT assertion: the field code is set for all tree elements of non + * zero code length. + */ +local void gen_codes(ct_data *tree, int max_code, ushf *bl_count) { + ush next_code[MAX_BITS+1]; /* next code value for each bit length */ + unsigned code = 0; /* running code value */ + int bits; /* bit index */ + int n; /* code index */ + + /* The distribution counts are first used to generate the code values + * without bit reversal. + */ + for (bits = 1; bits <= MAX_BITS; bits++) { + code = (code + bl_count[bits - 1]) << 1; + next_code[bits] = (ush)code; + } + /* Check that the bit counts in bl_count are consistent. The last code + * must be all ones. + */ + Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, + "inconsistent bit counts"); + Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); + + for (n = 0; n <= max_code; n++) { + int len = tree[n].Len; + if (len == 0) continue; + /* Now reverse the bits */ + tree[n].Code = (ush)bi_reverse(next_code[len]++, len); + + Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", + n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); + } +} #ifdef GEN_TREES_H -local void gen_trees_header OF((void)); +local void gen_trees_header(void); #endif #ifndef ZLIB_DEBUG # define send_code(s, c, tree) send_bits(s, tree[c].Code, tree[c].Len) /* Send a code of the given tree. c and tree must not have side effects */ #else /* !ZLIB_DEBUG */ # define send_code(s, c, tree) \ { if (z_verbose>2) fprintf(stderr,"\ncd %3d ",(c)); \ send_bits(s, tree[c].Code, tree[c].Len); } #endif /* =========================================================================== - * Output a short LSB first on the stream. - * IN assertion: there is enough room in pendingBuf. - */ -#define put_short(s, w) { \ - put_byte(s, (uch)((w) & 0xff)); \ - put_byte(s, (uch)((ush)(w) >> 8)); \ -} - -/* =========================================================================== * Send a value on a given number of bits. * IN assertion: length <= 16 and value fits in length bits. */ #ifdef ZLIB_DEBUG -local void send_bits OF((deflate_state *s, int value, int length)); - -local void send_bits(s, value, length) - deflate_state *s; - int value; /* value to send */ - int length; /* number of bits */ -{ +local void send_bits(deflate_state *s, int value, int length) { Tracevv((stderr," l %2d v %4x ", length, value)); Assert(length > 0 && length <= 15, "invalid length"); s->bits_sent += (ulg)length; /* If not enough room in bi_buf, use (valid) bits from bi_buf and * (16 - bi_valid) bits from value, leaving (width - (16 - bi_valid)) * unused bits in value. */ if (s->bi_valid > (int)Buf_size - length) { s->bi_buf |= (ush)value << s->bi_valid; put_short(s, s->bi_buf); s->bi_buf = (ush)value >> (Buf_size - s->bi_valid); s->bi_valid += length - Buf_size; } else { s->bi_buf |= (ush)value << s->bi_valid; s->bi_valid += length; } } #else /* !ZLIB_DEBUG */ #define send_bits(s, value, length) \ { int len = length;\ if (s->bi_valid > (int)Buf_size - len) {\ int val = (int)value;\ s->bi_buf |= (ush)val << s->bi_valid;\ put_short(s, s->bi_buf);\ s->bi_buf = (ush)val >> (Buf_size - s->bi_valid);\ s->bi_valid += len - Buf_size;\ } else {\ s->bi_buf |= (ush)(value) << s->bi_valid;\ s->bi_valid += len;\ }\ } #endif /* ZLIB_DEBUG */ /* the arguments must not have side effects */ /* =========================================================================== * Initialize the various 'constant' tables. */ -local void tr_static_init() -{ +local void tr_static_init(void) { #if defined(GEN_TREES_H) || !defined(STDC) static int static_init_done = 0; int n; /* iterates over tree elements */ int bits; /* bit counter */ int length; /* length value */ int code; /* code value */ int dist; /* distance index */ ush bl_count[MAX_BITS+1]; /* number of codes at each bit length for an optimal tree */ if (static_init_done) return; /* For some embedded targets, global variables are not initialized: */ #ifdef NO_INIT_GLOBAL_POINTERS static_l_desc.static_tree = static_ltree; static_l_desc.extra_bits = extra_lbits; static_d_desc.static_tree = static_dtree; static_d_desc.extra_bits = extra_dbits; static_bl_desc.extra_bits = extra_blbits; #endif /* Initialize the mapping length (0..255) -> length code (0..28) */ length = 0; for (code = 0; code < LENGTH_CODES-1; code++) { base_length[code] = length; for (n = 0; n < (1 << extra_lbits[code]); n++) { _length_code[length++] = (uch)code; } } Assert (length == 256, "tr_static_init: length != 256"); @@ -296,224 +357,212 @@ local void tr_static_init() * tree construction to get a canonical Huffman tree (longest code * all ones) */ gen_codes((ct_data *)static_ltree, L_CODES+1, bl_count); /* The static distance tree is trivial: */ for (n = 0; n < D_CODES; n++) { static_dtree[n].Len = 5; static_dtree[n].Code = bi_reverse((unsigned)n, 5); } static_init_done = 1; # ifdef GEN_TREES_H gen_trees_header(); # endif #endif /* defined(GEN_TREES_H) || !defined(STDC) */ } /* =========================================================================== * Generate the file trees.h describing the static trees. */ #ifdef GEN_TREES_H # ifndef ZLIB_DEBUG # include <stdio.h> # endif # define SEPARATOR(i, last, width) \ ((i) == (last)? "\n};\n\n" : \ ((i) % (width) == (width) - 1 ? ",\n" : ", ")) -void gen_trees_header() -{ +void gen_trees_header(void) { FILE *header = fopen("trees.h", "w"); int i; Assert (header != NULL, "Can't open trees.h"); fprintf(header, "/* header created automatically with -DGEN_TREES_H */\n\n"); fprintf(header, "local const ct_data static_ltree[L_CODES+2] = {\n"); for (i = 0; i < L_CODES+2; i++) { fprintf(header, "{{%3u},{%3u}}%s", static_ltree[i].Code, static_ltree[i].Len, SEPARATOR(i, L_CODES+1, 5)); } fprintf(header, "local const ct_data static_dtree[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "{{%2u},{%2u}}%s", static_dtree[i].Code, static_dtree[i].Len, SEPARATOR(i, D_CODES-1, 5)); } fprintf(header, "const uch ZLIB_INTERNAL _dist_code[DIST_CODE_LEN] = {\n"); for (i = 0; i < DIST_CODE_LEN; i++) { fprintf(header, "%2u%s", _dist_code[i], SEPARATOR(i, DIST_CODE_LEN-1, 20)); } fprintf(header, "const uch ZLIB_INTERNAL _length_code[MAX_MATCH-MIN_MATCH+1]= {\n"); for (i = 0; i < MAX_MATCH-MIN_MATCH+1; i++) { fprintf(header, "%2u%s", _length_code[i], SEPARATOR(i, MAX_MATCH-MIN_MATCH, 20)); } fprintf(header, "local const int base_length[LENGTH_CODES] = {\n"); for (i = 0; i < LENGTH_CODES; i++) { fprintf(header, "%1u%s", base_length[i], SEPARATOR(i, LENGTH_CODES-1, 20)); } fprintf(header, "local const int base_dist[D_CODES] = {\n"); for (i = 0; i < D_CODES; i++) { fprintf(header, "%5u%s", base_dist[i], SEPARATOR(i, D_CODES-1, 10)); } fclose(header); } #endif /* GEN_TREES_H */ /* =========================================================================== + * Initialize a new block. + */ +local void init_block(deflate_state *s) { + int n; /* iterates over tree elements */ + + /* Initialize the trees. */ + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; + + s->dyn_ltree[END_BLOCK].Freq = 1; + s->opt_len = s->static_len = 0L; + s->sym_next = s->matches = 0; +} + +/* =========================================================================== * Initialize the tree data structures for a new zlib stream. */ -void ZLIB_INTERNAL _tr_init(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_init(deflate_state *s) { tr_static_init(); s->l_desc.dyn_tree = s->dyn_ltree; s->l_desc.stat_desc = &static_l_desc; s->d_desc.dyn_tree = s->dyn_dtree; s->d_desc.stat_desc = &static_d_desc; s->bl_desc.dyn_tree = s->bl_tree; s->bl_desc.stat_desc = &static_bl_desc; s->bi_buf = 0; s->bi_valid = 0; #ifdef ZLIB_DEBUG s->compressed_len = 0L; s->bits_sent = 0L; #endif /* Initialize the first block of the first file: */ init_block(s); } -/* =========================================================================== - * Initialize a new block. - */ -local void init_block(s) - deflate_state *s; -{ - int n; /* iterates over tree elements */ - - /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; - for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; - - s->dyn_ltree[END_BLOCK].Freq = 1; - s->opt_len = s->static_len = 0L; - s->sym_next = s->matches = 0; -} - #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. */ #define pqremove(s, tree, top) \ {\ top = s->heap[SMALLEST]; \ s->heap[SMALLEST] = s->heap[s->heap_len--]; \ pqdownheap(s, tree, SMALLEST); \ } /* =========================================================================== * Compares to subtrees, using the tree depth as tie breaker when * the subtrees have equal frequency. This minimizes the worst case length. */ #define smaller(tree, n, m, depth) \ (tree[n].Freq < tree[m].Freq || \ (tree[n].Freq == tree[m].Freq && depth[n] <= depth[m])) /* =========================================================================== * Restore the heap property by moving down the tree starting at node k, * exchanging a node with the smallest of its two sons if necessary, stopping * when the heap property is re-established (each father smaller than its * two sons). */ -local void pqdownheap(s, tree, k) - deflate_state *s; - ct_data *tree; /* the tree to restore */ - int k; /* node to move down */ -{ +local void pqdownheap(deflate_state *s, ct_data *tree, int k) { int v = s->heap[k]; int j = k << 1; /* left son of k */ while (j <= s->heap_len) { /* Set j to the smallest of the two sons: */ if (j < s->heap_len && smaller(tree, s->heap[j + 1], s->heap[j], s->depth)) { j++; } /* Exit if v is smaller than both sons */ if (smaller(tree, v, s->heap[j], s->depth)) break; /* Exchange v with the smallest son */ s->heap[k] = s->heap[j]; k = j; /* And continue down the tree, setting j to the left son of k */ j <<= 1; } s->heap[k] = v; } /* =========================================================================== * Compute the optimal bit lengths for a tree and update the total bit length * for the current block. * IN assertion: the fields freq and dad are set, heap[heap_max] and * above are the tree nodes sorted by increasing frequency. * OUT assertions: the field len is set to the optimal bit length, the * array bl_count contains the frequencies for each bit length. * The length opt_len is updated; static_len is also updated if stree is * not null. */ -local void gen_bitlen(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void gen_bitlen(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; int max_code = desc->max_code; const ct_data *stree = desc->stat_desc->static_tree; const intf *extra = desc->stat_desc->extra_bits; int base = desc->stat_desc->extra_base; int max_length = desc->stat_desc->max_length; int h; /* heap index */ int n, m; /* iterate over the tree elements */ int bits; /* bit length */ int xbits; /* extra bits */ ush f; /* frequency */ int overflow = 0; /* number of elements with bit length too large */ for (bits = 0; bits <= MAX_BITS; bits++) s->bl_count[bits] = 0; /* In a first pass, compute the optimal bit lengths (which may * overflow in the case of the bit length tree). */ tree[s->heap[s->heap_max]].Len = 0; /* root of the heap */ for (h = s->heap_max + 1; h < HEAP_SIZE; h++) { n = s->heap[h]; bits = tree[tree[n].Dad].Len + 1; if (bits > max_length) bits = max_length, overflow++; tree[n].Len = (ush)bits; /* We overwrite tree[n].Dad which is no longer needed */ if (n > max_code) continue; /* not a leaf node */ s->bl_count[bits]++; @@ -534,115 +583,73 @@ local void gen_bitlen(s, desc) while (s->bl_count[bits] == 0) bits--; s->bl_count[bits]--; /* move one leaf down the tree */ s->bl_count[bits + 1] += 2; /* move one overflow item as its brother */ s->bl_count[max_length]--; /* The brother of the overflow item also moves one step up, * but this does not affect bl_count[max_length] */ overflow -= 2; } while (overflow > 0); /* Now recompute all bit lengths, scanning in increasing frequency. * h is still equal to HEAP_SIZE. (It is simpler to reconstruct all * lengths instead of fixing only the wrong ones. This idea is taken * from 'ar' written by Haruhiko Okumura.) */ for (bits = max_length; bits != 0; bits--) { n = s->bl_count[bits]; while (n != 0) { m = s->heap[--h]; if (m > max_code) continue; if ((unsigned) tree[m].Len != (unsigned) bits) { Tracev((stderr,"code %d bits %d->%d\n", m, tree[m].Len, bits)); s->opt_len += ((ulg)bits - tree[m].Len) * tree[m].Freq; tree[m].Len = (ush)bits; } n--; } } } -/* =========================================================================== - * Generate the codes for a given tree and bit counts (which need not be - * optimal). - * IN assertion: the array bl_count contains the bit length statistics for - * the given tree and the field len is set for all tree elements. - * OUT assertion: the field code is set for all tree elements of non - * zero code length. - */ -local void gen_codes(tree, max_code, bl_count) - ct_data *tree; /* the tree to decorate */ - int max_code; /* largest code with non zero frequency */ - ushf *bl_count; /* number of codes at each bit length */ -{ - ush next_code[MAX_BITS+1]; /* next code value for each bit length */ - unsigned code = 0; /* running code value */ - int bits; /* bit index */ - int n; /* code index */ - - /* The distribution counts are first used to generate the code values - * without bit reversal. - */ - for (bits = 1; bits <= MAX_BITS; bits++) { - code = (code + bl_count[bits - 1]) << 1; - next_code[bits] = (ush)code; - } - /* Check that the bit counts in bl_count are consistent. The last code - * must be all ones. - */ - Assert (code + bl_count[MAX_BITS] - 1 == (1 << MAX_BITS) - 1, - "inconsistent bit counts"); - Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); - - for (n = 0; n <= max_code; n++) { - int len = tree[n].Len; - if (len == 0) continue; - /* Now reverse the bits */ - tree[n].Code = (ush)bi_reverse(next_code[len]++, len); - - Tracecv(tree != static_ltree, (stderr,"\nn %3d %c l %2d c %4x (%x) ", - n, (isgraph(n) ? n : ' '), len, tree[n].Code, next_code[len] - 1)); - } -} +#ifdef DUMP_BL_TREE +# include <stdio.h> +#endif /* =========================================================================== * Construct one Huffman tree and assigns the code bit strings and lengths. * Update the total bit length for the current block. * IN assertion: the field freq is set for all tree elements. * OUT assertions: the fields len and code are set to the optimal bit length * and corresponding code. The length opt_len is updated; static_len is * also updated if stree is not null. The field max_code is set. */ -local void build_tree(s, desc) - deflate_state *s; - tree_desc *desc; /* the tree descriptor */ -{ +local void build_tree(deflate_state *s, tree_desc *desc) { ct_data *tree = desc->dyn_tree; const ct_data *stree = desc->stat_desc->static_tree; int elems = desc->stat_desc->elems; int n, m; /* iterate over heap elements */ int max_code = -1; /* largest code with non zero frequency */ int node; /* new node being created */ /* Construct the initial heap, with least frequent element in * heap[SMALLEST]. The sons of heap[n] are heap[2*n] and heap[2*n + 1]. * heap[0] is not used. */ s->heap_len = 0, s->heap_max = HEAP_SIZE; for (n = 0; n < elems; n++) { if (tree[n].Freq != 0) { s->heap[++(s->heap_len)] = max_code = n; s->depth[n] = 0; } else { tree[n].Len = 0; } } /* The pkzip format requires that at least one distance code exists, * and that at least one bit should be sent even if there is only one * possible code. So to avoid special checks later on we force at least * two codes of non zero frequency. */ while (s->heap_len < 2) { node = s->heap[++(s->heap_len)] = (max_code < 2 ? ++max_code : 0); tree[node].Freq = 1; @@ -673,275 +680,347 @@ local void build_tree(s, desc) s->depth[node] = (uch)((s->depth[n] >= s->depth[m] ? s->depth[n] : s->depth[m]) + 1); tree[n].Dad = tree[m].Dad = (ush)node; #ifdef DUMP_BL_TREE if (tree == s->bl_tree) { fprintf(stderr,"\nnode %d(%d), sons %d(%d) %d(%d)", node, tree[node].Freq, n, tree[n].Freq, m, tree[m].Freq); } #endif /* and insert the new node in the heap */ s->heap[SMALLEST] = node++; pqdownheap(s, tree, SMALLEST); } while (s->heap_len >= 2); s->heap[--(s->heap_max)] = s->heap[SMALLEST]; /* At this point, the fields freq and dad are set. We can now * generate the bit lengths. */ gen_bitlen(s, (tree_desc *)desc); /* The field len is now set, we can generate the bit codes */ gen_codes ((ct_data *)tree, max_code, s->bl_count); } /* =========================================================================== * Scan a literal or distance tree to determine the frequencies of the codes * in the bit length tree. */ -local void scan_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void scan_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ if (nextlen == 0) max_count = 138, min_count = 3; tree[max_code + 1].Len = (ush)0xffff; /* guard */ for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n + 1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { s->bl_tree[curlen].Freq += count; } else if (curlen != 0) { if (curlen != prevlen) s->bl_tree[curlen].Freq++; s->bl_tree[REP_3_6].Freq++; } else if (count <= 10) { s->bl_tree[REPZ_3_10].Freq++; } else { s->bl_tree[REPZ_11_138].Freq++; } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Send a literal or distance tree in compressed form, using the codes in * bl_tree. */ -local void send_tree(s, tree, max_code) - deflate_state *s; - ct_data *tree; /* the tree to be scanned */ - int max_code; /* and its largest code of non zero frequency */ -{ +local void send_tree(deflate_state *s, ct_data *tree, int max_code) { int n; /* iterates over all tree elements */ int prevlen = -1; /* last emitted length */ int curlen; /* length of current code */ int nextlen = tree[0].Len; /* length of next code */ int count = 0; /* repeat count of the current code */ int max_count = 7; /* max repeat count */ int min_count = 4; /* min repeat count */ /* tree[max_code + 1].Len = -1; */ /* guard already set */ if (nextlen == 0) max_count = 138, min_count = 3; for (n = 0; n <= max_code; n++) { curlen = nextlen; nextlen = tree[n + 1].Len; if (++count < max_count && curlen == nextlen) { continue; } else if (count < min_count) { do { send_code(s, curlen, s->bl_tree); } while (--count != 0); } else if (curlen != 0) { if (curlen != prevlen) { send_code(s, curlen, s->bl_tree); count--; } Assert(count >= 3 && count <= 6, " 3_6?"); send_code(s, REP_3_6, s->bl_tree); send_bits(s, count - 3, 2); } else if (count <= 10) { send_code(s, REPZ_3_10, s->bl_tree); send_bits(s, count - 3, 3); } else { send_code(s, REPZ_11_138, s->bl_tree); send_bits(s, count - 11, 7); } count = 0; prevlen = curlen; if (nextlen == 0) { max_count = 138, min_count = 3; } else if (curlen == nextlen) { max_count = 6, min_count = 3; } else { max_count = 7, min_count = 4; } } } /* =========================================================================== * Construct the Huffman tree for the bit lengths and return the index in * bl_order of the last bit length code to send. */ -local int build_bl_tree(s) - deflate_state *s; -{ +local int build_bl_tree(deflate_state *s) { int max_blindex; /* index of last bit length code of non zero freq */ /* Determine the bit length frequencies for literal and distance trees */ scan_tree(s, (ct_data *)s->dyn_ltree, s->l_desc.max_code); scan_tree(s, (ct_data *)s->dyn_dtree, s->d_desc.max_code); /* Build the bit length tree: */ build_tree(s, (tree_desc *)(&(s->bl_desc))); /* opt_len now includes the length of the tree representations, except the * lengths of the bit lengths codes and the 5 + 5 + 4 bits for the counts. */ /* Determine the number of bit length codes to send. The pkzip format * requires that at least 4 bit length codes be sent. (appnote.txt says * 3 but the actual value used is 4.) */ for (max_blindex = BL_CODES-1; max_blindex >= 3; max_blindex--) { if (s->bl_tree[bl_order[max_blindex]].Len != 0) break; } /* Update opt_len to include the bit length tree and counts */ s->opt_len += 3*((ulg)max_blindex + 1) + 5 + 5 + 4; Tracev((stderr, "\ndyn trees: dyn %ld, stat %ld", s->opt_len, s->static_len)); return max_blindex; } /* =========================================================================== * Send the header for a block using dynamic Huffman trees: the counts, the * lengths of the bit length codes, the literal tree and the distance tree. * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */ -local void send_all_trees(s, lcodes, dcodes, blcodes) - deflate_state *s; - int lcodes, dcodes, blcodes; /* number of codes for each tree */ -{ +local void send_all_trees(deflate_state *s, int lcodes, int dcodes, + int blcodes) { int rank; /* index in bl_order */ Assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes"); Assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES, "too many codes"); Tracev((stderr, "\nbl counts: ")); send_bits(s, lcodes - 257, 5); /* not +255 as stated in appnote.txt */ send_bits(s, dcodes - 1, 5); send_bits(s, blcodes - 4, 4); /* not -3 as stated in appnote.txt */ for (rank = 0; rank < blcodes; rank++) { Tracev((stderr, "\nbl code %2d ", bl_order[rank])); send_bits(s, s->bl_tree[bl_order[rank]].Len, 3); } Tracev((stderr, "\nbl tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_ltree, lcodes - 1); /* literal tree */ Tracev((stderr, "\nlit tree: sent %ld", s->bits_sent)); send_tree(s, (ct_data *)s->dyn_dtree, dcodes - 1); /* distance tree */ Tracev((stderr, "\ndist tree: sent %ld", s->bits_sent)); } /* =========================================================================== * Send a stored block */ -void ZLIB_INTERNAL _tr_stored_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { send_bits(s, (STORED_BLOCK<<1) + last, 3); /* send block type */ bi_windup(s); /* align on byte boundary */ put_short(s, (ush)stored_len); put_short(s, (ush)~stored_len); if (stored_len) zmemcpy(s->pending_buf + s->pending, (Bytef *)buf, stored_len); s->pending += stored_len; #ifdef ZLIB_DEBUG s->compressed_len = (s->compressed_len + 3 + 7) & (ulg)~7L; s->compressed_len += (stored_len + 4) << 3; s->bits_sent += 2*16; s->bits_sent += stored_len << 3; #endif } /* =========================================================================== * Flush the bits in the bit buffer to pending output (leaves at most 7 bits) */ -void ZLIB_INTERNAL _tr_flush_bits(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s) { bi_flush(s); } /* =========================================================================== * Send one empty static block to give enough lookahead for inflate. * This takes 10 bits, of which 7 may remain in the bit buffer. */ -void ZLIB_INTERNAL _tr_align(s) - deflate_state *s; -{ +void ZLIB_INTERNAL _tr_align(deflate_state *s) { send_bits(s, STATIC_TREES<<1, 3); send_code(s, END_BLOCK, static_ltree); #ifdef ZLIB_DEBUG s->compressed_len += 10L; /* 3 for block type, 7 for EOB */ #endif bi_flush(s); } /* =========================================================================== + * Send the block data compressed using the given Huffman trees + */ +local void compress_block(deflate_state *s, const ct_data *ltree, + const ct_data *dtree) { + unsigned dist; /* distance of matched string */ + int lc; /* match length or unmatched char (if dist == 0) */ + unsigned sx = 0; /* running index in symbol buffers */ + unsigned code; /* the code to send */ + int extra; /* number of extra bits to send */ + + if (s->sym_next != 0) do { +#ifdef LIT_MEM + dist = s->d_buf[sx]; + lc = s->l_buf[sx++]; +#else + dist = s->sym_buf[sx++] & 0xff; + dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; + lc = s->sym_buf[sx++]; +#endif + if (dist == 0) { + send_code(s, lc, ltree); /* send a literal byte */ + Tracecv(isgraph(lc), (stderr," '%c' ", lc)); + } else { + /* Here, lc is the match length - MIN_MATCH */ + code = _length_code[lc]; + send_code(s, code + LITERALS + 1, ltree); /* send length code */ + extra = extra_lbits[code]; + if (extra != 0) { + lc -= base_length[code]; + send_bits(s, lc, extra); /* send the extra length bits */ + } + dist--; /* dist is now the match distance - 1 */ + code = d_code(dist); + Assert (code < D_CODES, "bad d_code"); + + send_code(s, code, dtree); /* send the distance code */ + extra = extra_dbits[code]; + if (extra != 0) { + dist -= (unsigned)base_dist[code]; + send_bits(s, dist, extra); /* send the extra distance bits */ + } + } /* literal or match pair ? */ + + /* Check for no overlay of pending_buf on needed symbols */ +#ifdef LIT_MEM + Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow"); +#else + Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); +#endif + + } while (sx < s->sym_next); + + send_code(s, END_BLOCK, ltree); +} + +/* =========================================================================== + * Check if the data type is TEXT or BINARY, using the following algorithm: + * - TEXT if the two conditions below are satisfied: + * a) There are no non-portable control characters belonging to the + * "block list" (0..6, 14..25, 28..31). + * b) There is at least one printable character belonging to the + * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). + * - BINARY otherwise. + * - The following partially-portable control characters form a + * "gray list" that is ignored in this detection algorithm: + * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). + * IN assertion: the fields Freq of dyn_ltree are set. + */ +local int detect_data_type(deflate_state *s) { + /* block_mask is the bit mask of block-listed bytes + * set bits 0..6, 14..25, and 28..31 + * 0xf3ffc07f = binary 11110011111111111100000001111111 + */ + unsigned long block_mask = 0xf3ffc07fUL; + int n; + + /* Check for non-textual ("block-listed") bytes. */ + for (n = 0; n <= 31; n++, block_mask >>= 1) + if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) + return Z_BINARY; + + /* Check for textual ("allow-listed") bytes. */ + if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 + || s->dyn_ltree[13].Freq != 0) + return Z_TEXT; + for (n = 32; n < LITERALS; n++) + if (s->dyn_ltree[n].Freq != 0) + return Z_TEXT; + + /* There are no "block-listed" or "allow-listed" bytes: + * this stream either is empty or has tolerated ("gray-listed") bytes only. + */ + return Z_BINARY; +} + +/* =========================================================================== * Determine the best encoding for the current block: dynamic trees, static * trees or store, and write out the encoded block. */ -void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) - deflate_state *s; - charf *buf; /* input block, or NULL if too old */ - ulg stored_len; /* length of input block */ - int last; /* one if this is the last block for a file */ -{ +void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf, + ulg stored_len, int last) { ulg opt_lenb, static_lenb; /* opt_len and static_len in bytes */ int max_blindex = 0; /* index of last bit length code of non zero freq */ /* Build the Huffman trees unless a stored block is forced */ if (s->level > 0) { /* Check if the file is binary or text */ if (s->strm->data_type == Z_UNKNOWN) s->strm->data_type = detect_data_type(s); /* Construct the literal and distance trees */ build_tree(s, (tree_desc *)(&(s->l_desc))); Tracev((stderr, "\nlit data: dyn %ld, stat %ld", s->opt_len, s->static_len)); build_tree(s, (tree_desc *)(&(s->d_desc))); Tracev((stderr, "\ndist data: dyn %ld, stat %ld", s->opt_len, s->static_len)); /* At this point, opt_len and static_len are the total bit lengths of * the compressed block data, excluding the tree representations. */ /* Build the bit length tree for the above two trees, and get the index * in bl_order of the last bit length code to send. */ max_blindex = build_bl_tree(s); /* Determine the best encoding. Compute the block lengths in bytes. */ opt_lenb = (s->opt_len + 3 + 7) >> 3; static_lenb = (s->static_len + 3 + 7) >> 3; @@ -984,198 +1063,55 @@ void ZLIB_INTERNAL _tr_flush_block(s, buf, stored_len, last) } else { send_bits(s, (DYN_TREES<<1) + last, 3); send_all_trees(s, s->l_desc.max_code + 1, s->d_desc.max_code + 1, max_blindex + 1); compress_block(s, (const ct_data *)s->dyn_ltree, (const ct_data *)s->dyn_dtree); #ifdef ZLIB_DEBUG s->compressed_len += 3 + s->opt_len; #endif } Assert (s->compressed_len == s->bits_sent, "bad compressed size"); /* The above check is made mod 2^32, for files larger than 512 MB * and uLong implemented on 32 bits. */ init_block(s); if (last) { bi_windup(s); #ifdef ZLIB_DEBUG s->compressed_len += 7; /* align on byte boundary */ #endif } Tracev((stderr,"\ncomprlen %lu(%lu) ", s->compressed_len >> 3, s->compressed_len - 7*last)); } /* =========================================================================== * Save the match info and tally the frequency counts. Return true if * the current block must be flushed. */ -int ZLIB_INTERNAL _tr_tally(s, dist, lc) - deflate_state *s; - unsigned dist; /* distance of matched string */ - unsigned lc; /* match length - MIN_MATCH or unmatched char (dist==0) */ -{ +int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) { +#ifdef LIT_MEM + s->d_buf[s->sym_next] = (ush)dist; + s->l_buf[s->sym_next++] = (uch)lc; +#else s->sym_buf[s->sym_next++] = (uch)dist; s->sym_buf[s->sym_next++] = (uch)(dist >> 8); s->sym_buf[s->sym_next++] = (uch)lc; +#endif if (dist == 0) { /* lc is the unmatched char */ s->dyn_ltree[lc].Freq++; } else { s->matches++; /* Here, lc is the match length - MIN_MATCH */ dist--; /* dist = match distance - 1 */ Assert((ush)dist < (ush)MAX_DIST(s) && (ush)lc <= (ush)(MAX_MATCH-MIN_MATCH) && (ush)d_code(dist) < (ush)D_CODES, "_tr_tally: bad match"); s->dyn_ltree[_length_code[lc] + LITERALS + 1].Freq++; s->dyn_dtree[d_code(dist)].Freq++; } return (s->sym_next == s->sym_end); } - -/* =========================================================================== - * Send the block data compressed using the given Huffman trees - */ -local void compress_block(s, ltree, dtree) - deflate_state *s; - const ct_data *ltree; /* literal tree */ - const ct_data *dtree; /* distance tree */ -{ - unsigned dist; /* distance of matched string */ - int lc; /* match length or unmatched char (if dist == 0) */ - unsigned sx = 0; /* running index in sym_buf */ - unsigned code; /* the code to send */ - int extra; /* number of extra bits to send */ - - if (s->sym_next != 0) do { - dist = s->sym_buf[sx++] & 0xff; - dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8; - lc = s->sym_buf[sx++]; - if (dist == 0) { - send_code(s, lc, ltree); /* send a literal byte */ - Tracecv(isgraph(lc), (stderr," '%c' ", lc)); - } else { - /* Here, lc is the match length - MIN_MATCH */ - code = _length_code[lc]; - send_code(s, code + LITERALS + 1, ltree); /* send length code */ - extra = extra_lbits[code]; - if (extra != 0) { - lc -= base_length[code]; - send_bits(s, lc, extra); /* send the extra length bits */ - } - dist--; /* dist is now the match distance - 1 */ - code = d_code(dist); - Assert (code < D_CODES, "bad d_code"); - - send_code(s, code, dtree); /* send the distance code */ - extra = extra_dbits[code]; - if (extra != 0) { - dist -= (unsigned)base_dist[code]; - send_bits(s, dist, extra); /* send the extra distance bits */ - } - } /* literal or match pair ? */ - - /* Check that the overlay between pending_buf and sym_buf is ok: */ - Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow"); - - } while (sx < s->sym_next); - - send_code(s, END_BLOCK, ltree); -} - -/* =========================================================================== - * Check if the data type is TEXT or BINARY, using the following algorithm: - * - TEXT if the two conditions below are satisfied: - * a) There are no non-portable control characters belonging to the - * "block list" (0..6, 14..25, 28..31). - * b) There is at least one printable character belonging to the - * "allow list" (9 {TAB}, 10 {LF}, 13 {CR}, 32..255). - * - BINARY otherwise. - * - The following partially-portable control characters form a - * "gray list" that is ignored in this detection algorithm: - * (7 {BEL}, 8 {BS}, 11 {VT}, 12 {FF}, 26 {SUB}, 27 {ESC}). - * IN assertion: the fields Freq of dyn_ltree are set. - */ -local int detect_data_type(s) - deflate_state *s; -{ - /* block_mask is the bit mask of block-listed bytes - * set bits 0..6, 14..25, and 28..31 - * 0xf3ffc07f = binary 11110011111111111100000001111111 - */ - unsigned long block_mask = 0xf3ffc07fUL; - int n; - - /* Check for non-textual ("block-listed") bytes. */ - for (n = 0; n <= 31; n++, block_mask >>= 1) - if ((block_mask & 1) && (s->dyn_ltree[n].Freq != 0)) - return Z_BINARY; - - /* Check for textual ("allow-listed") bytes. */ - if (s->dyn_ltree[9].Freq != 0 || s->dyn_ltree[10].Freq != 0 - || s->dyn_ltree[13].Freq != 0) - return Z_TEXT; - for (n = 32; n < LITERALS; n++) - if (s->dyn_ltree[n].Freq != 0) - return Z_TEXT; - - /* There are no "block-listed" or "allow-listed" bytes: - * this stream either is empty or has tolerated ("gray-listed") bytes only. - */ - return Z_BINARY; -} - -/* =========================================================================== - * Reverse the first len bits of a code, using straightforward code (a faster - * method would use a table) - * IN assertion: 1 <= len <= 15 - */ -local unsigned bi_reverse(code, len) - unsigned code; /* the value to invert */ - int len; /* its bit length */ -{ - register unsigned res = 0; - do { - res |= code & 1; - code >>= 1, res <<= 1; - } while (--len > 0); - return res >> 1; -} - -/* =========================================================================== - * Flush the bit buffer, keeping at most 7 bits in it. - */ -local void bi_flush(s) - deflate_state *s; -{ - if (s->bi_valid == 16) { - put_short(s, s->bi_buf); - s->bi_buf = 0; - s->bi_valid = 0; - } else if (s->bi_valid >= 8) { - put_byte(s, (Byte)s->bi_buf); - s->bi_buf >>= 8; - s->bi_valid -= 8; - } -} - -/* =========================================================================== - * Flush the bit buffer and align the output on a byte boundary - */ -local void bi_windup(s) - deflate_state *s; -{ - if (s->bi_valid > 8) { - put_short(s, s->bi_buf); - } else if (s->bi_valid > 0) { - put_byte(s, (Byte)s->bi_buf); - } - s->bi_buf = 0; - s->bi_valid = 0; -#ifdef ZLIB_DEBUG - s->bits_sent = (s->bits_sent + 7) & ~7; -#endif -} diff --git a/src/Common/zlib/uncompr.c b/src/Common/zlib/uncompr.c index f9532f46..5e256663 100644 --- a/src/Common/zlib/uncompr.c +++ b/src/Common/zlib/uncompr.c @@ -1,93 +1,85 @@ /* uncompr.c -- decompress a memory buffer * Copyright (C) 1995-2003, 2010, 2014, 2016 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #define ZLIB_INTERNAL #include "zlib.h" /* =========================================================================== Decompresses the source buffer into the destination buffer. *sourceLen is the byte length of the source buffer. Upon entry, *destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, *destLen is the size of the decompressed data and *sourceLen is the number of source bytes consumed. Upon return, source + *sourceLen points to the first unused input byte. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted, including if the input data is an incomplete zlib stream. */ -int ZEXPORT uncompress2(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong *sourceLen; -{ +int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong *sourceLen) { z_stream stream; int err; const uInt max = (uInt)-1; uLong len, left; Byte buf[1]; /* for detection of incomplete stream when *destLen == 0 */ len = *sourceLen; if (*destLen) { left = *destLen; *destLen = 0; } else { left = 1; dest = buf; } stream.next_in = (z_const Bytef *)source; stream.avail_in = 0; stream.zalloc = (alloc_func)0; stream.zfree = (free_func)0; stream.opaque = (voidpf)0; err = inflateInit(&stream); if (err != Z_OK) return err; stream.next_out = dest; stream.avail_out = 0; do { if (stream.avail_out == 0) { stream.avail_out = left > (uLong)max ? max : (uInt)left; left -= stream.avail_out; } if (stream.avail_in == 0) { stream.avail_in = len > (uLong)max ? max : (uInt)len; len -= stream.avail_in; } err = inflate(&stream, Z_NO_FLUSH); } while (err == Z_OK); *sourceLen -= len + stream.avail_in; if (dest != buf) *destLen = stream.total_out; else if (stream.total_out && err == Z_BUF_ERROR) left = 1; inflateEnd(&stream); return err == Z_STREAM_END ? Z_OK : err == Z_NEED_DICT ? Z_DATA_ERROR : err == Z_BUF_ERROR && left + stream.avail_out ? Z_DATA_ERROR : err; } -int ZEXPORT uncompress(dest, destLen, source, sourceLen) - Bytef *dest; - uLongf *destLen; - const Bytef *source; - uLong sourceLen; -{ +int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, const Bytef *source, + uLong sourceLen) { return uncompress2(dest, destLen, source, &sourceLen); } diff --git a/src/Common/zlib/zconf.h b/src/Common/zlib/zconf.h index bf977d3e..62adc8d8 100644 --- a/src/Common/zlib/zconf.h +++ b/src/Common/zlib/zconf.h @@ -1,32 +1,32 @@ /* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #ifndef ZCONF_H #define ZCONF_H /* * If you *really* need a unique prefix for all types and library functions, * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. * Even better than compiling with -DZ_PREFIX would be to use configure to set * this permanently in zconf.h using "./configure --zprefix". */ #ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ # define Z_PREFIX_SET /* all linked symbols and init macros */ # define _dist_code z__dist_code # define _length_code z__length_code # define _tr_align z__tr_align # define _tr_flush_bits z__tr_flush_bits # define _tr_flush_block z__tr_flush_block # define _tr_init z__tr_init # define _tr_stored_block z__tr_stored_block # define _tr_tally z__tr_tally # define adler32 z_adler32 # define adler32_combine z_adler32_combine # define adler32_combine64 z_adler32_combine64 # define adler32_z z_adler32_z @@ -214,123 +214,119 @@ #if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) # define STDC #endif #if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) # define STDC #endif #if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) # define STDC #endif #if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) # define STDC #endif #if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ # define STDC #endif #ifndef STDC # ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ # define const /* note: need a more gentle solution here */ # endif #endif #if defined(ZLIB_CONST) && !defined(z_const) # define z_const const #else # define z_const #endif #ifdef Z_SOLO - typedef unsigned long z_size_t; +# ifdef _WIN64 + typedef unsigned long long z_size_t; +# else + typedef unsigned long z_size_t; +# endif #else # define z_longlong long long # if defined(NO_SIZE_T) typedef unsigned NO_SIZE_T z_size_t; # elif defined(STDC) # include <stddef.h> typedef size_t z_size_t; # else typedef unsigned long z_size_t; # endif # undef z_longlong #endif /* Maximum value for memLevel in deflateInit2 */ #ifndef MAX_MEM_LEVEL # ifdef MAXSEG_64K # define MAX_MEM_LEVEL 8 # else # define MAX_MEM_LEVEL 9 # endif #endif /* Maximum value for windowBits in deflateInit2 and inflateInit2. * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files * created by gzip. (Files created by minigzip can still be extracted by * gzip.) */ #ifndef MAX_WBITS # define MAX_WBITS 15 /* 32K LZ77 window */ #endif /* The memory requirements for deflate are (in bytes): (1 << (windowBits+2)) + (1 << (memLevel+9)) that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) plus a few kilobytes for small objects. For example, if you want to reduce the default memory requirements from 256K to 128K, compile with make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" Of course this will generally degrade compression (there's no free lunch). The memory requirements for inflate are (in bytes) 1 << windowBits that is, 32K for windowBits=15 (default value) plus about 7 kilobytes for small objects. */ /* Type declarations */ #ifndef OF /* function prototypes */ # ifdef STDC # define OF(args) args # else # define OF(args) () # endif #endif -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - /* The following definitions for FAR are needed only for MSDOS mixed * model programming (small or medium model with some far allocations). * This was tested only with MSC; for other MSDOS compilers you may have * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, * just define FAR to be empty. */ #ifdef SYS16BIT # if defined(M_I86SM) || defined(M_I86MM) /* MSC small or medium model */ # define SMALL_MEDIUM # ifdef _MSC_VER # define FAR _far # else # define FAR far # endif # endif # if (defined(__SMALL__) || defined(__MEDIUM__)) /* Turbo C small or medium model */ # define SMALL_MEDIUM # ifdef __BORLANDC__ # define FAR _far # else # define FAR far # endif # endif #endif #if defined(WINDOWS) || defined(WIN32) /* If building or using zlib as a DLL, define ZLIB_DLL. * This is not mandatory, but it offers a little performance increase. @@ -493,55 +489,55 @@ typedef uLong FAR uLongf; # define z_off_t off_t # endif # endif #endif #if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 # define Z_LFS64 #endif #if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) # define Z_LARGE64 #endif #if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) # define Z_WANT64 #endif #if !defined(SEEK_SET) && !defined(Z_SOLO) # define SEEK_SET 0 /* Seek from beginning of file. */ # define SEEK_CUR 1 /* Seek from current position. */ # define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ #endif #ifndef z_off_t # define z_off_t long #endif #if !defined(_WIN32) && defined(Z_LARGE64) # define z_off64_t off64_t #else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) +# if defined(_WIN32) && !defined(__GNUC__) # define z_off64_t __int64 # else # define z_off64_t z_off_t # endif #endif /* MVS linker does not support external names larger than 8 bytes */ #if defined(__MVS__) #pragma map(deflateInit_,"DEIN") #pragma map(deflateInit2_,"DEIN2") #pragma map(deflateEnd,"DEEND") #pragma map(deflateBound,"DEBND") #pragma map(inflateInit_,"ININ") #pragma map(inflateInit2_,"ININ2") #pragma map(inflateEnd,"INEND") #pragma map(inflateSync,"INSY") #pragma map(inflateSetDictionary,"INSEDI") #pragma map(compressBound,"CMBND") #pragma map(inflate_table,"INTABL") #pragma map(inflate_fast,"INFA") #pragma map(inflate_copyright,"INCOPY") #endif #endif /* ZCONF_H */ diff --git a/src/Common/zlib/zlib.h b/src/Common/zlib/zlib.h index 953cb501..8d4b932e 100644 --- a/src/Common/zlib/zlib.h +++ b/src/Common/zlib/zlib.h @@ -1,112 +1,112 @@ /* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.13, October 13th, 2022 + version 1.3.1, January 22nd, 2024 - Copyright (C) 1995-2022 Jean-loup Gailly and Mark Adler + Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). */ #ifndef ZLIB_H #define ZLIB_H #include "zconf.h" #ifdef __cplusplus extern "C" { #endif -#define ZLIB_VERSION "1.2.13" -#define ZLIB_VERNUM 0x12d0 +#define ZLIB_VERSION "1.3.1" +#define ZLIB_VERNUM 0x1310 #define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 13 +#define ZLIB_VER_MINOR 3 +#define ZLIB_VER_REVISION 1 #define ZLIB_VER_SUBREVISION 0 /* The 'zlib' compression library provides in-memory compression and decompression functions, including integrity checks of the uncompressed data. This version of the library supports only one compression method (deflation) but other algorithms will be added later and will have the same stream interface. Compression can be done in a single step if the buffers are large enough, or can be done by repeated calls of the compression function. In the latter case, the application must provide more input and/or consume the output (providing more output space) before each call. The compressed data format used by default by the in-memory functions is the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped around a deflate stream, which is itself documented in RFC 1951. The library also supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. This library can optionally read and write gzip and raw deflate streams in memory as well. The zlib format was designed to be compact and fast for use in memory and on communications channels. The gzip format was designed for single- file compression on file systems, has a larger header than zlib to maintain directory information, and uses a different, slower check method than zlib. The library does not install any signal handler. The decoder checks the consistency of the compressed data, so the library should never crash even in the case of corrupted input. */ -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); +typedef voidpf (*alloc_func)(voidpf opaque, uInt items, uInt size); +typedef void (*free_func)(voidpf opaque, voidpf address); struct internal_state; typedef struct z_stream_s { z_const Bytef *next_in; /* next input byte */ uInt avail_in; /* number of bytes available at next_in */ uLong total_in; /* total number of input bytes read so far */ Bytef *next_out; /* next output byte will go here */ uInt avail_out; /* remaining free space at next_out */ uLong total_out; /* total number of bytes output so far */ z_const char *msg; /* last error message, NULL if no error */ struct internal_state FAR *state; /* not visible by applications */ alloc_func zalloc; /* used to allocate the internal state */ free_func zfree; /* used to free the internal state */ voidpf opaque; /* private data object passed to zalloc and zfree */ int data_type; /* best guess about the data type: binary or text for deflate, or the decoding state for inflate */ uLong adler; /* Adler-32 or CRC-32 value of the uncompressed data */ uLong reserved; /* reserved for future use */ } z_stream; typedef z_stream FAR *z_streamp; /* gzip header information passed to and from zlib routines. See RFC 1952 for more details on the meanings of these fields. @@ -190,91 +190,91 @@ typedef gz_header FAR *gz_headerp; #define Z_NO_COMPRESSION 0 #define Z_BEST_SPEED 1 #define Z_BEST_COMPRESSION 9 #define Z_DEFAULT_COMPRESSION (-1) /* compression levels */ #define Z_FILTERED 1 #define Z_HUFFMAN_ONLY 2 #define Z_RLE 3 #define Z_FIXED 4 #define Z_DEFAULT_STRATEGY 0 /* compression strategy; see deflateInit2() below for details */ #define Z_BINARY 0 #define Z_TEXT 1 #define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ #define Z_UNKNOWN 2 /* Possible values of the data_type field for deflate() */ #define Z_DEFLATED 8 /* The deflate compression method (the only one supported in this version) */ #define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ #define zlib_version zlibVersion() /* for compatibility with versions < 1.0.2 */ /* basic functions */ -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); +ZEXTERN const char * ZEXPORT zlibVersion(void); /* The application can compare zlibVersion and ZLIB_VERSION for consistency. If the first character differs, the library code actually used is not compatible with the zlib.h header file used by the application. This check is automatically made by deflateInit and inflateInit. */ /* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); +ZEXTERN int ZEXPORT deflateInit(z_streamp strm, int level); Initializes the internal stream state for compression. The fields zalloc, zfree and opaque must be initialized before by the caller. If zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. + allocation functions. total_in, total_out, adler, and msg are initialized. The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: 1 gives best speed, 9 gives best compression, 0 gives no compression at all (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION requests a default compromise between speed and compression (currently equivalent to level 6). deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if level is not a valid compression level, or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit does not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT deflate(z_streamp strm, int flush); /* deflate compresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. deflate performs one or both of the following actions: - Compress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), next_in and avail_in are updated and processing will resume at this point for the next call of deflate(). - Generate more output starting at next_out and update next_out and avail_out accordingly. This action is forced if the parameter flush is non zero. Forcing flush frequently degrades the compression ratio, so this parameter should be set only when necessary. Some output may be provided even if flush is zero. Before the call of deflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating avail_in or avail_out accordingly; avail_out should never be zero before the call. The application can consume the compressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. See deflatePending(), which can be used if desired to determine whether or not there is more output in that case. @@ -293,138 +293,139 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); that is three bits plus filler bits to the next byte, followed by four bytes (00 00 ff ff). If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the output buffer, but the output is not aligned to a byte boundary. All of the input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. This completes the current deflate block and follows it with an empty fixed codes block that is 10 bits long. This assures that enough bytes are output in order for the decompressor to finish the block before the empty fixed codes block. If flush is set to Z_BLOCK, a deflate block is completed and emitted, as for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to seven bits of the current block are held to be written as the next byte after the next deflate block is completed. In this case, the decompressor may not be provided enough bits at this point in order to complete decompression of the data provided so far to the compressor. It may need to wait for the next block to be emitted. This is for advanced applications that need to control the emission of deflate blocks. If flush is set to Z_FULL_FLUSH, all output is flushed as with Z_SYNC_FLUSH, and the compression state is reset so that decompression can restart from this point if previous compressed data has been damaged or if random access is desired. Using Z_FULL_FLUSH too often can seriously degrade compression. If deflate returns with avail_out == 0, this function must be called again with the same value of the flush parameter and more output space (updated avail_out), until the flush is complete (deflate returns with non-zero avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. + avail_out is greater than six when the flush marker begins, in order to avoid + repeated flush markers upon calling deflate() again when avail_out == 0. If the parameter flush is set to Z_FINISH, pending input is processed, pending output is flushed and deflate returns with Z_STREAM_END if there was enough output space. If deflate returns with Z_OK or Z_BUF_ERROR, this function must be called again with Z_FINISH and more output space (updated avail_out) but no more input data, until it returns with Z_STREAM_END or an error. After deflate has returned Z_STREAM_END, the only possible operations on the stream are deflateReset or deflateEnd. Z_FINISH can be used in the first deflate call after deflateInit if all the compression is to be done in a single step. In order to complete in one call, avail_out must be at least the value returned by deflateBound (see below). Then deflate is guaranteed to return Z_STREAM_END. If not enough output space is provided, deflate will not return Z_STREAM_END, and it must be called again as described above. deflate() sets strm->adler to the Adler-32 checksum of all input read so far (that is, total_in bytes). If a gzip stream is being generated, then strm->adler will be the CRC-32 checksum of the input read so far. (See deflateInit2 below.) deflate() may update strm->data_type if it can make a good guess about the input data type (Z_BINARY or Z_TEXT). If in doubt, the data is considered binary. This field is only for information purposes and does not affect the compression algorithm in any manner. deflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if all input has been consumed and all output has been produced (only when flush is set to Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example if next_in or next_out was Z_NULL or the state was inadvertently written over by the application), or Z_BUF_ERROR if no progress is possible (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not fatal, and deflate() can be called again with more input and more output space to continue compressing. */ -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state was inconsistent, Z_DATA_ERROR if the stream was freed prematurely (some input or output was discarded). In the error case, msg may be set but then points to a static string (which must not be deallocated). */ /* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateInit(z_streamp strm); Initializes the internal stream state for decompression. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. In the current version of inflate, the provided input is not read or consumed. The allocation of a sliding window will be deferred to the first call of inflate (if the decompression does not complete on the first call). If zalloc and zfree are set to Z_NULL, inflateInit updates - them to use default allocation functions. + them to use default allocation functions. total_in, total_out, adler, and + msg are initialized. inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit does not perform any decompression. Actual decompression will be done by inflate(). So next_in, and avail_in, next_out, and avail_out are unused and unchanged. The current implementation of inflateInit() does not process any header information -- that is deferred until inflate() is called. */ -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); +ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); /* inflate decompresses as much data as possible, and stops when the input buffer becomes empty or the output buffer becomes full. It may introduce some output latency (reading input without producing any output) except when forced to flush. The detailed semantics are as follows. inflate performs one or both of the following actions: - Decompress more input starting at next_in and update next_in and avail_in accordingly. If not all input can be processed (because there is not enough room in the output buffer), then next_in and avail_in are updated accordingly, and processing will resume at this point for the next call of inflate(). - Generate more output starting at next_out and update next_out and avail_out accordingly. inflate() provides as much output as possible, until there is no more input data or no more space in the output buffer (see below about the flush parameter). Before the call of inflate(), the application should ensure that at least one of the actions is possible, by providing more input and/or consuming more output, and updating the next_* and avail_* values accordingly. If the caller of inflate() does not provide both available input and available output space, it is possible that there will be no progress made. The application can consume the uncompressed output when it wants, for example when the output buffer is full (avail_out == 0), or after each call of inflate(). If inflate returns Z_OK and with zero avail_out, it must be called again after making room in the output buffer because there might be more output pending. @@ -490,84 +491,84 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); below. At the end of the stream, inflate() checks that its computed Adler-32 checksum is equal to that saved by the compressor and returns Z_STREAM_END only if the checksum is correct. inflate() can decompress and check either zlib-wrapped or gzip-wrapped deflate data. The header type is detected automatically, if requested when initializing with inflateInit2(). Any information contained in the gzip header is not retained unless inflateGetHeader() is used. When processing gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output produced so far. The CRC-32 is checked against the gzip trailer, as is the uncompressed length, modulo 2^32. inflate() returns Z_OK if some progress has been made (more input processed or more output produced), Z_STREAM_END if the end of the compressed data has been reached and all uncompressed output has been produced, Z_NEED_DICT if a preset dictionary is needed at this point, Z_DATA_ERROR if the input data was corrupted (input stream not conforming to the zlib format or incorrect check value, in which case strm->msg points to a string with a more specific error), Z_STREAM_ERROR if the stream structure was inconsistent (for example next_in or next_out was Z_NULL, or the state was inadvertently written over by the application), Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if no progress was possible or if there was not enough room in the output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and inflate() can be called again with more input and more output space to continue decompressing. If Z_DATA_ERROR is returned, the application may then call inflateSync() to look for a good compression block if a partial recovery of the data is to be attempted. */ -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateEnd(z_streamp strm); /* All dynamically allocated data structures for this stream are freed. This function discards any unprocessed input and does not flush any pending output. inflateEnd returns Z_OK if success, or Z_STREAM_ERROR if the stream state was inconsistent. */ /* Advanced functions */ /* The following functions are needed only in some special applications. */ /* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); +ZEXTERN int ZEXPORT deflateInit2(z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy); This is another version of deflateInit with more compression options. The fields zalloc, zfree and opaque must be initialized before by the caller. The method parameter is the compression method. It must be Z_DEFLATED in this version of the library. The windowBits parameter is the base two logarithm of the window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. Larger values of this parameter result in better compression at the expense of memory usage. The default value is 15 if deflateInit is used instead. For the current implementation of deflate(), a windowBits value of 8 (a window size of 256 bytes) is not supported. As a result, a request for 8 will result in 9 (a 512-byte window). In that case, providing 8 to inflateInit2() will result in an error when the zlib header with 9 is checked against the initialization of inflate(). The remedy is to not use 8 with deflateInit2() with this initialization, or at least in that case use 9 with inflateInit2(). windowBits can also be -8..-15 for raw deflate. In this case, -windowBits determines the window size. deflate() will then generate raw deflate data with no zlib header or trailer, and will not compute a check value. windowBits can also be greater than 15 for optional gzip encoding. Add 16 to windowBits to write a simple gzip header and trailer around the compressed data instead of a zlib wrapper. The gzip header will have no file name, no extra data, no comment, no modification time (set to zero), no header crc, and the operating system will be set to the appropriate value, @@ -580,551 +581,553 @@ ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, The memLevel parameter specifies how much memory should be allocated for the internal compression state. memLevel=1 uses minimum memory but is slow and reduces compression ratio; memLevel=9 uses maximum memory for optimal speed. The default value is 8. See zconf.h for total memory usage as a function of windowBits and memLevel. The strategy parameter is used to tune the compression algorithm. Use the value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no string match), or Z_RLE to limit match distances to one (run-length encoding). Filtered data consists mostly of small values with a somewhat random distribution. In this case, the compression algorithm is tuned to compress them better. The effect of Z_FILTERED is to force more Huffman coding and less string matching; it is somewhat intermediate between Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The strategy parameter only affects the compression ratio but not the correctness of the compressed output even if it is not set appropriately. Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler decoder for special applications. deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible with the version assumed by the caller (ZLIB_VERSION). msg is set to null if there is no error message. deflateInit2 does not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT deflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the compression dictionary from the given byte sequence without producing any compressed output. When using the zlib format, this function must be called immediately after deflateInit, deflateInit2 or deflateReset, and before any call of deflate. When doing raw deflate, this function must be called either before any call of deflate, or immediately after the completion of a deflate block, i.e. after all input has been consumed and all output has been delivered when using any of the flush options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The compressor and decompressor must use exactly the same dictionary (see inflateSetDictionary). The dictionary should consist of strings (byte sequences) that are likely to be encountered later in the data to be compressed, with the most commonly used strings preferably put towards the end of the dictionary. Using a dictionary is most useful when the data to be compressed is short and can be predicted with good accuracy; the data can then be compressed better than with the default empty dictionary. Depending on the size of the compression data structures selected by deflateInit or deflateInit2, a part of the dictionary may in effect be discarded, for example if the dictionary is larger than the window size provided in deflateInit or deflateInit2. Thus the strings most likely to be useful should be put at the end of the dictionary, not at the front. In addition, the current implementation of deflate will use at most the window size minus 262 bytes of the provided dictionary. Upon return of this function, strm->adler is set to the Adler-32 value of the dictionary; the decompressor may later use this value to determine which dictionary has been used by the compressor. (The Adler-32 value applies to the whole dictionary even if only a subset of the dictionary is actually used by the compressor.) If a raw deflate was requested, then the Adler-32 value is not computed and strm->adler is not set. deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent (for example if deflate has already been called for this stream or if not at a block boundary for raw deflate). deflateSetDictionary does not perform any compression: this will be done by deflate(). */ -ZEXTERN int ZEXPORT deflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT deflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by deflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If deflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set. deflateGetDictionary() may return a length less than the window size, even when more than the window size in input has been provided. It may return up to 258 bytes less in that case, due to how zlib's implementation of deflate manages the sliding window and lookahead for matches, where matches can be up to 258 bytes long. If the application needs the last window-size bytes of input, then that would need to be saved by the application outside of zlib. deflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. */ -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT deflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when several compression strategies will be tried, for example when there are several ways of pre-processing the input data with a filter. The streams that will be discarded should then be freed by calling deflateEnd. Note that deflateCopy duplicates the internal compression state which can be quite large, so this strategy is slow and can consume lots of memory. deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT deflateReset(z_streamp strm); /* This function is equivalent to deflateEnd followed by deflateInit, but does not free and reallocate the internal compression state. The stream will leave the compression level and any other attributes that may have been - set unchanged. + set unchanged. total_in, total_out, adler, and msg are initialized. deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); +ZEXTERN int ZEXPORT deflateParams(z_streamp strm, + int level, + int strategy); /* Dynamically update the compression level and compression strategy. The interpretation of level and strategy is as in deflateInit2(). This can be used to switch between compression and straight copy of the input data, or to switch to a different kind of input data requiring a different strategy. If the compression approach (which is a function of the level) or the strategy is changed, and if there have been any deflate() calls since the state was initialized or reset, then the input available so far is compressed with the old level and strategy using deflate(strm, Z_BLOCK). There are three approaches for the compression levels 0, 1..3, and 4..9 respectively. The new level and strategy will take effect at the next call of deflate(). If a deflate(strm, Z_BLOCK) is performed by deflateParams(), and it does not have enough output space to complete, then the parameter change will not take effect. In this case, deflateParams() can be called again with the same parameters and more output space to try again. In order to assure a change in the parameters on the first try, the deflate stream should be flushed using deflate() with Z_BLOCK or other flush request until strm.avail_out is not zero, before calling deflateParams(). Then no more input data should be provided before the deflateParams() call. If this is done, the old level and strategy will be applied to the data compressed before deflateParams(), and the new level and strategy will be - applied to the the data compressed after deflateParams(). + applied to the data compressed after deflateParams(). deflateParams returns Z_OK on success, Z_STREAM_ERROR if the source stream state was inconsistent or if a parameter was invalid, or Z_BUF_ERROR if there was not enough output space to complete the compression of the available input data before a change in the strategy or approach. Note that in the case of a Z_BUF_ERROR, the parameters are not changed. A return value of Z_BUF_ERROR is not fatal, in which case deflateParams() can be retried with more output space. */ -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); +ZEXTERN int ZEXPORT deflateTune(z_streamp strm, + int good_length, + int max_lazy, + int nice_length, + int max_chain); /* Fine tune deflate's internal compression parameters. This should only be used by someone who understands the algorithm used by zlib's deflate for searching for the best matching string, and even then only by the most fanatic optimizer trying to squeeze out the last compressed bit for their specific input data. Read the deflate.c source code for the meaning of the max_lazy, good_length, nice_length, and max_chain parameters. deflateTune() can be called after deflateInit() or deflateInit2(), and returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. */ -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); +ZEXTERN uLong ZEXPORT deflateBound(z_streamp strm, + uLong sourceLen); /* deflateBound() returns an upper bound on the compressed size after deflation of sourceLen bytes. It must be called after deflateInit() or deflateInit2(), and after deflateSetHeader(), if used. This would be used to allocate an output buffer for deflation in a single pass, and so would be called before deflate(). If that first deflate() call is provided the sourceLen input bytes, an output buffer allocated to the size returned by deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed to return Z_STREAM_END. Note that it is possible for the compressed size to be larger than the value returned by deflateBound() if flush options other than Z_FINISH or Z_NO_FLUSH are used. */ -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); +ZEXTERN int ZEXPORT deflatePending(z_streamp strm, + unsigned *pending, + int *bits); /* deflatePending() returns the number of bytes and bits of output that have been generated, but not yet provided in the available output. The bytes not provided would be due to the available output space having being consumed. The number of bits of output not provided are between 0 and 7, where they await more bits to join them in order to fill out a full byte. If pending or bits are Z_NULL, then those values are not set. deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT deflatePrime(z_streamp strm, + int bits, + int value); /* deflatePrime() inserts bits in the deflate output stream. The intent is that this function is used to start off the deflate output with the bits leftover from a previous deflate stream when appending to it. As such, this function can only be used for raw deflate, and must be used before the first deflate() call after a deflateInit2() or deflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the output. deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the source stream state was inconsistent. */ -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT deflateSetHeader(z_streamp strm, + gz_headerp head); /* deflateSetHeader() provides gzip header information for when a gzip stream is requested by deflateInit2(). deflateSetHeader() may be called after deflateInit2() or deflateReset() and before the first call of deflate(). The text, time, os, extra field, name, and comment information in the provided gz_header structure are written to the gzip header (xflag is ignored -- the extra flags are set according to the compression level). The caller must assure that, if not Z_NULL, name and comment are terminated with a zero byte, and that if extra is not Z_NULL, that extra_len bytes are available there. If hcrc is true, a gzip header crc is included. Note that the current versions of the command-line version of gzip (up through version 1.3.x) do not support header crc's, and will report that it is a "multi-part gzip file" and give up. If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). + the time set to zero, and os set to the current operating system, with no + extra, name, or comment fields. The gzip header is returned to the default + state by deflateReset(). deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateInit2(z_streamp strm, + int windowBits); This is another version of inflateInit with an extra parameter. The fields next_in, avail_in, zalloc, zfree and opaque must be initialized before by the caller. The windowBits parameter is the base two logarithm of the maximum window size (the size of the history buffer). It should be in the range 8..15 for this version of the library. The default value is 15 if inflateInit is used instead. windowBits must be greater than or equal to the windowBits value provided to deflateInit2() while compressing, or it must be equal to 15 if deflateInit2() was not used. If a compressed stream with a larger window size is given as input, inflate() will return with the error code Z_DATA_ERROR instead of trying to allocate a larger window. windowBits can also be zero to request that inflate use the window size in the zlib header of the compressed stream. windowBits can also be -8..-15 for raw inflate. In this case, -windowBits determines the window size. inflate() will then process raw deflate data, not looking for a zlib or gzip header, not generating a check value, and not looking for any check values for comparison at the end of the stream. This is for use with other formats that use the deflate compressed data format such as zip. Those formats provide their own check values. If a custom format is developed using the raw deflate format for compressed data, it is recommended that a check value such as an Adler-32 or a CRC-32 be applied to the uncompressed data as is done in the zlib, gzip, and zip formats. For most applications, the zlib format should be used as is. Note that comments above on the use in deflateInit2() applies to the magnitude of windowBits. windowBits can also be greater than 15 for optional gzip decoding. Add 32 to windowBits to enable zlib and gzip decoding with automatic header detection, or add 16 to decode only the gzip format (the zlib format will return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a CRC-32 instead of an Adler-32. Unlike the gunzip utility and gzread() (see below), inflate() will *not* automatically decode concatenated gzip members. inflate() will return Z_STREAM_END at the end of the gzip member. The state would need to be reset to continue decoding a subsequent gzip member. This *must* be done if there is more data after a gzip member, in order for the decompression to be compliant with the gzip standard (RFC 1952). inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_VERSION_ERROR if the zlib library version is incompatible with the version assumed by the caller, or Z_STREAM_ERROR if the parameters are invalid, such as a null pointer to the structure. msg is set to null if there is no error message. inflateInit2 does not perform any decompression apart from possibly reading the zlib header if present: actual decompression will be done by inflate(). (So next_in and avail_in may be modified, but next_out and avail_out are unused and unchanged.) The current implementation of inflateInit2() does not process any header information -- that is deferred until inflate() is called. */ -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); +ZEXTERN int ZEXPORT inflateSetDictionary(z_streamp strm, + const Bytef *dictionary, + uInt dictLength); /* Initializes the decompression dictionary from the given uncompressed byte sequence. This function must be called immediately after a call of inflate, if that call returned Z_NEED_DICT. The dictionary chosen by the compressor can be determined from the Adler-32 value returned by that call of inflate. The compressor and decompressor must use exactly the same dictionary (see deflateSetDictionary). For raw inflate, this function can be called at any time to set the dictionary. If the provided dictionary is smaller than the window and there is already data in the window, then the provided dictionary will amend what's there. The application must insure that the dictionary that was used for compression is provided. inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the expected one (incorrect Adler-32 value). inflateSetDictionary does not perform any decompression: this will be done by subsequent calls of inflate(). */ -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); +ZEXTERN int ZEXPORT inflateGetDictionary(z_streamp strm, + Bytef *dictionary, + uInt *dictLength); /* Returns the sliding dictionary being maintained by inflate. dictLength is set to the number of bytes in the dictionary, and that many bytes are copied to dictionary. dictionary must have enough space, where 32768 bytes is always enough. If inflateGetDictionary() is called with dictionary equal to Z_NULL, then only the dictionary length is returned, and nothing is copied. Similarly, if dictLength is Z_NULL, then it is not set. inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the stream state is inconsistent. */ -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateSync(z_streamp strm); /* Skips invalid compressed data until a possible full flush point (see above for the description of deflate with Z_FULL_FLUSH) can be found, or until all available input is skipped. No output is provided. inflateSync searches for a 00 00 FF FF pattern in the compressed data. All full flush points have this pattern, but not all occurrences of this pattern are full flush points. inflateSync returns Z_OK if a possible full flush point has been found, Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. + In the success case, the application may save the current value of total_in + which indicates where valid compressed data was found. In the error case, + the application may repeatedly call inflateSync, providing more input each + time, until success or end of the input data. */ -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); +ZEXTERN int ZEXPORT inflateCopy(z_streamp dest, + z_streamp source); /* Sets the destination stream as a complete copy of the source stream. This function can be useful when randomly accessing a large stream. The first pass through the stream can periodically record the inflate state, allowing restarting inflate at those points when randomly accessing the stream. inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc being Z_NULL). msg is left unchanged in both source and destination. */ -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateReset(z_streamp strm); /* This function is equivalent to inflateEnd followed by inflateInit, but does not free and reallocate the internal decompression state. The stream will keep attributes that may have been set by inflateInit2. + total_in, total_out, adler, and msg are initialized. inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL). */ -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); +ZEXTERN int ZEXPORT inflateReset2(z_streamp strm, + int windowBits); /* This function is the same as inflateReset, but it also permits changing the wrap and window size requests. The windowBits parameter is interpreted the same as it is for inflateInit2. If the window size is changed, then the memory allocated for the window is freed, and the window will be reallocated by inflate() if needed. inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent (such as zalloc or state being Z_NULL), or if the windowBits parameter is invalid. */ -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); +ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, + int bits, + int value); /* This function inserts bits in the inflate input stream. The intent is that this function is used to start inflating at a bit position in the middle of a byte. The provided bits will be used before any bytes are used from next_in. This function should only be used with raw inflate, and should be used before the first inflate() call after inflateInit2() or inflateReset(). bits must be less than or equal to 16, and that many of the least significant bits of value will be inserted in the input. If bits is negative, then the input stream bit buffer is emptied. Then inflatePrime() can be called again to put bits in the buffer. This is used to clear out bits leftover after feeding inflate a block description prior to feeding inflate codes. inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); +ZEXTERN long ZEXPORT inflateMark(z_streamp strm); /* This function returns two values, one in the lower 16 bits of the return value, and the other in the remaining upper bits, obtained by shifting the return value down 16 bits. If the upper value is -1 and the lower value is zero, then inflate() is currently decoding information outside of a block. If the upper value is -1 and the lower value is non-zero, then inflate is in the middle of a stored block, with the lower value equaling the number of bytes from the input remaining to copy. If the upper value is not -1, then it is the number of bits back from the current bit position in the input of the code (literal or length/distance pair) currently being processed. In that case the lower value is the number of bytes already emitted for that code. A code is being processed if inflate is waiting for more input to complete decoding of the code, or if it has completed decoding but is waiting for more output space to write the literal or match data. inflateMark() is used to mark locations in the input data for random access, which may be at bit positions, and to note those cases where the output of a code may span boundaries of random access blocks. The current location in the input stream can be determined from avail_in and data_type as noted in the description for the Z_BLOCK flush parameter for inflate. inflateMark returns the value noted above, or -65536 if the provided source stream state was inconsistent. */ -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); +ZEXTERN int ZEXPORT inflateGetHeader(z_streamp strm, + gz_headerp head); /* inflateGetHeader() requests that gzip header information be stored in the provided gz_header structure. inflateGetHeader() may be called after inflateInit2() or inflateReset(), and before the first call of inflate(). As inflate() processes the gzip stream, head->done is zero until the header is completed, at which time head->done is set to one. If a zlib stream is being decoded, then head->done is set to -1 to indicate that there will be no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be used to force inflate() to return immediately after header processing is complete and before any actual data is decompressed. The text, time, xflags, and os fields are filled in with the gzip header contents. hcrc is set to true if there is a header CRC. (The header CRC was valid if done is set to one.) If extra is not Z_NULL, then extra_max contains the maximum number of bytes to write to extra. Once done is true, extra_len contains the actual extra field length, and extra contains the extra field, or that field truncated if extra_max is less than extra_len. If name is not Z_NULL, then up to name_max characters are written there, terminated with a zero unless the length is greater than name_max. If comment is not Z_NULL, then up to comm_max characters are written there, terminated with a zero unless the length is greater than comm_max. When any of extra, name, or comment are not Z_NULL and the respective field is not present in the header, then that field is set to Z_NULL to signal its absence. This allows the use of deflateSetHeader() with the returned structure to duplicate the header. However if those fields are set to allocated memory, then the application will need to save those pointers elsewhere so that they can be eventually freed. If inflateGetHeader is not used, then the header information is simply discarded. The header is always checked for validity, including the header CRC if present. inflateReset() will reset the process to discard the header information. The application would need to call inflateGetHeader() again to retrieve the header from the next gzip stream. inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source stream state was inconsistent. */ /* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); +ZEXTERN int ZEXPORT inflateBackInit(z_streamp strm, int windowBits, + unsigned char FAR *window); Initialize the internal stream state for decompression using inflateBack() calls. The fields zalloc, zfree and opaque in strm must be initialized before the call. If zalloc and zfree are Z_NULL, then the default library- derived memory allocation routines are used. windowBits is the base two logarithm of the window size, in the range 8..15. window is a caller supplied buffer of that size. Except for special applications where it is assured that deflate was used with small window sizes, windowBits must be 15 and a 32K byte window must be supplied to be able to decompress general deflate streams. See inflateBack() for the usage of these routines. inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of the parameters are invalid, Z_MEM_ERROR if the internal state could not be allocated, or Z_VERSION_ERROR if the version of the library does not match the version of the header file. */ -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); +typedef unsigned (*in_func)(void FAR *, + z_const unsigned char FAR * FAR *); +typedef int (*out_func)(void FAR *, unsigned char FAR *, unsigned); -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); +ZEXTERN int ZEXPORT inflateBack(z_streamp strm, + in_func in, void FAR *in_desc, + out_func out, void FAR *out_desc); /* inflateBack() does a raw inflate with a single call using a call-back interface for input and output. This is potentially more efficient than inflate() for file i/o applications, in that it avoids copying between the output and the sliding window by simply making the window itself the output buffer. inflate() can be faster on modern CPUs when used with large buffers. inflateBack() trusts the application to not change the output buffer passed by the output function, at least until inflateBack() returns. inflateBackInit() must be called first to allocate the internal state and to initialize the state with the user-provided window buffer. inflateBack() may then be used multiple times to inflate a complete, raw deflate stream with each call. inflateBackEnd() is then called to free the allocated state. A raw deflate stream is one with no zlib or gzip header or trailer. This routine would normally be used in a utility that reads zip or gzip files and writes out uncompressed files. The utility would decode the header and process the trailer on its own, hence this routine expects only the raw deflate stream to decompress. This is different from the default behavior of inflate(), which expects a zlib header and trailer around the deflate stream. inflateBack() uses two subroutines supplied by the caller that are then called by inflateBack() for input and output. inflateBack() calls those routines until it reads a complete deflate stream and writes out all of the uncompressed data, or until it encounters an error. The function's parameters and return types are defined above in the in_func and out_func typedefs. inflateBack() will call in(in_desc, &buf) which should return the number of bytes of provided input, and a pointer to that input in buf. If @@ -1138,798 +1141,798 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, The length written by out() will be at most the window size. Any non-zero amount of input may be provided by in(). For convenience, inflateBack() can be provided input on the first call by setting strm->next_in and strm->avail_in. If that input is exhausted, then in() will be called. Therefore strm->next_in must be initialized before calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in must also be initialized, and then if strm->avail_in is not zero, input will initially be taken from strm->next_in[0 .. strm->avail_in - 1]. The in_desc and out_desc parameters of inflateBack() is passed as the first parameter of in() and out() respectively when they are called. These descriptors can be optionally used to pass any information that the caller- supplied in() and out() functions need to do their job. On return, inflateBack() will set strm->next_in and strm->avail_in to pass back any unused input that was provided by the last in() call. The return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR if in() or out() returned an error, Z_DATA_ERROR if there was a format error in the deflate stream (in which case strm->msg is set to indicate the nature of the error), or Z_STREAM_ERROR if the stream was not properly initialized. In the case of Z_BUF_ERROR, an input or output error can be distinguished using strm->next_in which will be Z_NULL only if in() returned an error. If strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning non-zero. (in() will always be called before out(), so strm->next_in is assured to be defined if out() returns non-zero.) Note that inflateBack() cannot return Z_OK. */ -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); +ZEXTERN int ZEXPORT inflateBackEnd(z_streamp strm); /* All memory allocated by inflateBackInit() is freed. inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream state was inconsistent. */ -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); +ZEXTERN uLong ZEXPORT zlibCompileFlags(void); /* Return flags indicating compile-time options. Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: 1.0: size of uInt 3.2: size of uLong 5.4: size of voidpf (pointer) 7.6: size of z_off_t Compiler, assembler, and debug options: 8: ZLIB_DEBUG 9: ASMV or ASMINF -- use ASM code 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention 11: 0 (reserved) One-time table building (smaller code, but not thread-safe if true): 12: BUILDFIXED -- build static block decoding tables when needed 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed 14,15: 0 (reserved) Library content (indicates missing functionality): 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking deflate code when not needed) 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect and decode gzip streams (to avoid linking crc code) 18-19: 0 (reserved) Operation variations (changes in library functionality): 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate 21: FASTEST -- deflate algorithm with only one, lowest compression level 22,23: 0 (reserved) The sprintf variant used by gzprintf (zero is best): 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! 26: 0 = returns value, 1 = void -- 1 means inferred string length returned Remainder: 27-31: 0 (reserved) */ #ifndef Z_SOLO /* utility functions */ /* The following utility functions are implemented on top of the basic stream-oriented functions. To simplify the interface, some default options are assumed (compression level and memory usage, standard memory allocation functions). The source code of these utility functions can be modified if you need special options. */ -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT compress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Compresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data. compress() is equivalent to compress2() with a level parameter of Z_DEFAULT_COMPRESSION. compress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer. */ -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); +ZEXTERN int ZEXPORT compress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level); /* Compresses the source buffer into the destination buffer. The level parameter has the same meaning as in deflateInit. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be at least the value returned by compressBound(sourceLen). Upon exit, destLen is the actual size of the compressed data. compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, Z_STREAM_ERROR if the level parameter is invalid. */ -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); +ZEXTERN uLong ZEXPORT compressBound(uLong sourceLen); /* compressBound() returns an upper bound on the compressed size after compress() or compress2() on sourceLen bytes. It would be used before a compress() or compress2() call to allocate the destination buffer. */ -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); +ZEXTERN int ZEXPORT uncompress(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen); /* Decompresses the source buffer into the destination buffer. sourceLen is the byte length of the source buffer. Upon entry, destLen is the total size of the destination buffer, which must be large enough to hold the entire uncompressed data. (The size of the uncompressed data must have been saved previously by the compressor and transmitted to the decompressor by some mechanism outside the scope of this compression library.) Upon exit, destLen is the actual size of the uncompressed data. uncompress returns Z_OK if success, Z_MEM_ERROR if there was not enough memory, Z_BUF_ERROR if there was not enough room in the output buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In the case where there is not enough room, uncompress() will fill the output buffer with the uncompressed data up to that point. */ -ZEXTERN int ZEXPORT uncompress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong *sourceLen)); +ZEXTERN int ZEXPORT uncompress2(Bytef *dest, uLongf *destLen, + const Bytef *source, uLong *sourceLen); /* Same as uncompress, except that sourceLen is a pointer, where the length of the source is *sourceLen. On return, *sourceLen is the number of source bytes consumed. */ /* gzip file access functions */ /* This library supports reading and writing files in gzip (.gz) format with an interface similar to that of stdio, using the functions that start with "gz". The gzip format is different from the zlib format. gzip is a gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. */ typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ /* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen(const char *path, const char *mode); Open the gzip (.gz) file at path for reading and decompressing, or compressing and writing. The mode parameter is as in fopen ("rb" or "wb") but can also include a compression level ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' for fixed code compression as in "wb9F". (See the description of deflateInit2 for more information about the strategy parameter.) 'T' will request transparent writing or appending with no compression and not using the gzip format. "a" can be used instead of "w" to request that the gzip stream that will be written be appended to the file. "+" will result in an error, since reading and writing to the same gzip file is not supported. The addition of "x" when writing will create the file exclusively, which fails if the file already exists. On systems that support it, the addition of "e" when reading or writing will set the flag to close the file on an execve() call. These functions, as well as gzip, will read and decode a sequence of gzip streams in a file. The append function of gzopen() can be used to create such a file. (Also see gzflush() for another way to do this.) When appending, gzopen does not test whether the file begins with a gzip stream, nor does it look for the end of the gzip streams to begin appending. gzopen will simply append a gzip stream to the existing file. gzopen can be used to read a file which is not in gzip format; in this case gzread will directly read from the file without decompression. When reading, this will be detected automatically by looking for the magic two- byte gzip header. gzopen returns NULL if the file could not be opened, if there was insufficient memory to allocate the gzFile state, or if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). errno can be checked to determine if the reason gzopen failed was that the file could not be opened. */ -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); +ZEXTERN gzFile ZEXPORT gzdopen(int fd, const char *mode); /* Associate a gzFile with the file descriptor fd. File descriptors are obtained from calls like open, dup, creat, pipe or fileno (if the file has been previously opened with fopen). The mode parameter is as in gzopen. The next call of gzclose on the returned gzFile will also close the file descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, mode);. The duplicated descriptor should be saved to avoid a leak, since gzdopen does not close fd if it fails. If you are using fileno() to get the file descriptor from a FILE *, then you will have to use dup() to avoid double-close()ing the file descriptor. Both gzclose() and fclose() will close the associated file descriptor, so they need to have different file descriptors. gzdopen returns NULL if there was insufficient memory to allocate the gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not provided, or '+' was provided), or if fd is -1. The file descriptor is not used until the next gz* read, write, seek, or close operation, so gzdopen will not detect if fd is invalid (unless fd is -1). */ -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); +ZEXTERN int ZEXPORT gzbuffer(gzFile file, unsigned size); /* Set the internal buffer size used by this library's functions for file to size. The default buffer size is 8192 bytes. This function must be called after gzopen() or gzdopen(), and before any other calls that read or write the file. The buffer memory allocation is always deferred to the first read or write. Three times that size in buffer space is allocated. A larger buffer size of, for example, 64K or 128K bytes will noticeably increase the speed of decompression (reading). The new buffer size also affects the maximum length for gzprintf(). gzbuffer() returns 0 on success, or -1 on failure, such as being called too late. */ -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); +ZEXTERN int ZEXPORT gzsetparams(gzFile file, int level, int strategy); /* Dynamically update the compression level and strategy for file. See the description of deflateInit2 for the meaning of these parameters. Previously provided data is flushed before applying the parameter changes. gzsetparams returns Z_OK if success, Z_STREAM_ERROR if the file was not opened for writing, Z_ERRNO if there is an error writing the flushed data, or Z_MEM_ERROR if there is a memory allocation error. */ -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +ZEXTERN int ZEXPORT gzread(gzFile file, voidp buf, unsigned len); /* Read and decompress up to len uncompressed bytes from file into buf. If the input file is not in gzip format, gzread copies the given number of bytes into the buffer directly from the file. After reaching the end of a gzip stream in the input, gzread will continue to read, looking for another gzip stream. Any number of gzip streams may be concatenated in the input file, and will all be decompressed by gzread(). If something other than a gzip stream is encountered after a gzip stream, that remaining trailing garbage is ignored (and no error is returned). gzread can be used to read a gzip file that is being concurrently written. Upon reaching the end of the input, gzread will return with the available data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then gzclearerr can be used to clear the end of file indicator in order to permit gzread to be tried again. Z_OK indicates that a gzip stream was completed on the last gzread. Z_BUF_ERROR indicates that the input file ended in the middle of a gzip stream. Note that gzread does not return -1 in the event of an incomplete gzip stream. This error is deferred until gzclose(), which will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip stream. Alternatively, gzerror can be used before gzclose to detect this case. gzread returns the number of uncompressed bytes actually read, less than len for end of file, or -1 for error. If len is too large to fit in an int, then nothing is read, -1 is returned, and the error state is set to Z_STREAM_ERROR. */ -ZEXTERN z_size_t ZEXPORT gzfread OF((voidp buf, z_size_t size, z_size_t nitems, - gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfread(voidp buf, z_size_t size, z_size_t nitems, + gzFile file); /* Read and decompress up to nitems items of size size from file into buf, otherwise operating as gzread() does. This duplicates the interface of stdio's fread(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. gzfread() returns the number of full items read of size size, or zero if the end of the file was reached and a full item could not be read, or if there was an error. gzerror() must be consulted if zero is returned in order to determine if there was an error. If the multiplication of size and nitems overflows, i.e. the product does not fit in a z_size_t, then nothing is read, zero is returned, and the error state is set to Z_STREAM_ERROR. In the event that the end of file is reached and only a partial item is available at the end, i.e. the remaining uncompressed data length is not a multiple of size, then the final partial item is nevertheless read into buf and the end-of-file flag is set. The length of the partial item read is not provided, but could be inferred from the result of gztell(). This behavior is the same as the behavior of fread() implementations in common libraries, but it prevents the direct use of gzfread() to read a concurrently written file, resetting and retrying on end-of-file, when size is not 1. */ -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, voidpc buf, unsigned len)); +ZEXTERN int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len); /* Compress and write the len uncompressed bytes at buf to file. gzwrite returns the number of uncompressed bytes written or 0 in case of error. */ -ZEXTERN z_size_t ZEXPORT gzfwrite OF((voidpc buf, z_size_t size, - z_size_t nitems, gzFile file)); +ZEXTERN z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, + z_size_t nitems, gzFile file); /* Compress and write nitems items of size size from buf to file, duplicating the interface of stdio's fwrite(), with size_t request and return types. If the library defines size_t, then z_size_t is identical to size_t. If not, then z_size_t is an unsigned integer type that can contain a pointer. gzfwrite() returns the number of full items written of size size, or zero if there was an error. If the multiplication of size and nitems overflows, i.e. the product does not fit in a z_size_t, then nothing is written, zero is returned, and the error state is set to Z_STREAM_ERROR. */ -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); +ZEXTERN int ZEXPORTVA gzprintf(gzFile file, const char *format, ...); /* Convert, format, compress, and write the arguments (...) to file under control of the string format, as in fprintf. gzprintf returns the number of uncompressed bytes actually written, or a negative zlib error code in case of error. The number of uncompressed bytes written is limited to 8191, or one less than the buffer size given to gzbuffer(). The caller should assure that this limit is not exceeded. If it is exceeded, then gzprintf() will return an error (0) with nothing written. In this case, there may also be a buffer overflow with unpredictable consequences, which is possible only if zlib was compiled with the insecure functions sprintf() or vsprintf(), because the secure snprintf() or vsnprintf() functions were not available. This can be determined using zlibCompileFlags(). */ -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); +ZEXTERN int ZEXPORT gzputs(gzFile file, const char *s); /* Compress and write the given null-terminated string s to file, excluding the terminating null character. gzputs returns the number of characters written, or -1 in case of error. */ -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); +ZEXTERN char * ZEXPORT gzgets(gzFile file, char *buf, int len); /* Read and decompress bytes from file into buf, until len-1 characters are read, or until a newline character is read and transferred to buf, or an end-of-file condition is encountered. If any characters are read or if len is one, the string is terminated with a null character. If no characters are read due to an end-of-file or len is less than one, then the buffer is left untouched. gzgets returns buf which is a null-terminated string, or it returns NULL for end-of-file or in case of error. If there was an error, the contents at buf are indeterminate. */ -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); +ZEXTERN int ZEXPORT gzputc(gzFile file, int c); /* Compress and write c, converted to an unsigned char, into file. gzputc returns the value that was written, or -1 in case of error. */ -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); +ZEXTERN int ZEXPORT gzgetc(gzFile file); /* Read and decompress one byte from file. gzgetc returns this byte or -1 in case of end of file or error. This is implemented as a macro for speed. As such, it does not do all of the checking the other functions do. I.e. it does not check to see if file is NULL, nor whether the structure file points to has been clobbered or not. */ -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); +ZEXTERN int ZEXPORT gzungetc(int c, gzFile file); /* Push c back onto the stream for file to be read as the first character on the next read. At least one character of push-back is always allowed. gzungetc() returns the character pushed, or -1 on failure. gzungetc() will fail if c is -1, and may fail if a character has been pushed but not read yet. If gzungetc is used immediately after gzopen or gzdopen, at least the output buffer size of pushed characters is allowed. (See gzbuffer above.) The pushed character will be discarded if the stream is repositioned with gzseek() or gzrewind(). */ -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); +ZEXTERN int ZEXPORT gzflush(gzFile file, int flush); /* Flush all pending output to file. The parameter flush is as in the deflate() function. The return value is the zlib error number (see function gzerror below). gzflush is only permitted when writing. If the flush parameter is Z_FINISH, the remaining data is written and the gzip stream is completed in the output. If gzwrite() is called again, a new gzip stream will be started in the output. gzread() is able to read such concatenated gzip streams. gzflush should be called only when strictly necessary because it will degrade compression if called too often. */ /* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); +ZEXTERN z_off_t ZEXPORT gzseek(gzFile file, + z_off_t offset, int whence); Set the starting position to offset relative to whence for the next gzread or gzwrite on file. The offset represents a number of bytes in the uncompressed data stream. The whence parameter is defined as in lseek(2); the value SEEK_END is not supported. If the file is opened for reading, this function is emulated but can be extremely slow. If the file is opened for writing, only forward seeks are supported; gzseek then compresses a sequence of zeroes up to the new starting position. gzseek returns the resulting offset location as measured in bytes from the beginning of the uncompressed stream, or -1 in case of error, in particular if the file is opened for writing and the new starting position would be before the current position. */ -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); +ZEXTERN int ZEXPORT gzrewind(gzFile file); /* Rewind file. This function is supported only for reading. gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET). */ /* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gztell(gzFile file); Return the starting position for the next gzread or gzwrite on file. This position represents a number of bytes in the uncompressed data stream, and is zero when starting, even if appending or reading a gzip stream from the middle of a file using gzdopen(). gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) */ /* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); +ZEXTERN z_off_t ZEXPORT gzoffset(gzFile file); Return the current compressed (actual) read or write offset of file. This offset includes the count of bytes that precede the gzip stream, for example when appending or when using gzdopen() for reading. When reading, the offset does not include as yet unused buffered input. This information can be used for a progress indicator. On error, gzoffset() returns -1. */ -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); +ZEXTERN int ZEXPORT gzeof(gzFile file); /* Return true (1) if the end-of-file indicator for file has been set while reading, false (0) otherwise. Note that the end-of-file indicator is set only if the read tried to go past the end of the input, but came up short. Therefore, just like feof(), gzeof() may return false even if there is no more data to read, in the event that the last read request was for the exact number of bytes remaining in the input file. This will happen if the input file size is an exact multiple of the buffer size. If gzeof() returns true, then the read functions will return no more data, unless the end-of-file indicator is reset by gzclearerr() and the input file has grown since the previous end of file was detected. */ -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); +ZEXTERN int ZEXPORT gzdirect(gzFile file); /* Return true (1) if file is being copied directly while reading, or false (0) if file is a gzip stream being decompressed. If the input file is empty, gzdirect() will return true, since the input does not contain a gzip stream. If gzdirect() is used immediately after gzopen() or gzdopen() it will cause buffers to be allocated to allow reading the file to determine if it is a gzip file. Therefore if gzbuffer() is used, it should be called before gzdirect(). When writing, gzdirect() returns true (1) if transparent writing was requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: gzdirect() is not needed when writing. Transparent writing must be explicitly requested, so the application already knows the answer. When linking statically, using gzdirect() will include all of the zlib code for gzip file reading and decompression, which may not be desired.) */ -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose(gzFile file); /* Flush all pending output for file, if necessary, close file and deallocate the (de)compression state. Note that once file is closed, you cannot call gzerror with file, since its structures have been deallocated. gzclose must not be called more than once on the same file, just as free must not be called more than once on the same allocation. gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the last read ended in the middle of a gzip stream, or Z_OK on success. */ -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); +ZEXTERN int ZEXPORT gzclose_r(gzFile file); +ZEXTERN int ZEXPORT gzclose_w(gzFile file); /* Same as gzclose(), but gzclose_r() is only for use when reading, and gzclose_w() is only for use when writing or appending. The advantage to using these instead of gzclose() is that they avoid linking in zlib compression or decompression code that is not used when only reading or only writing respectively. If gzclose() is used, then both compression and decompression code will be included the application when linking to a static zlib library. */ -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); +ZEXTERN const char * ZEXPORT gzerror(gzFile file, int *errnum); /* Return the error message for the last error which occurred on file. errnum is set to zlib error number. If an error occurred in the file system and not in the compression library, errnum is set to Z_ERRNO and the application may consult errno to get the exact error code. The application must not modify the returned string. Future calls to this function may invalidate the previously returned string. If file is closed, then the string previously returned by gzerror will no longer be available. gzerror() should be used to distinguish errors from end-of-file for those functions above that do not distinguish those cases in their return values. */ -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); +ZEXTERN void ZEXPORT gzclearerr(gzFile file); /* Clear the error and end-of-file flags for file. This is analogous to the clearerr() function in stdio. This is useful for continuing to read a gzip file that is being written concurrently. */ #endif /* !Z_SOLO */ /* checksum functions */ /* These functions are not related to compression but are exported anyway because they might be useful in applications using the compression library. */ -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len); /* Update a running Adler-32 checksum with the bytes buf[0..len-1] and return the updated checksum. An Adler-32 value is in the range of a 32-bit unsigned integer. If buf is Z_NULL, this function returns the required initial value for the checksum. An Adler-32 checksum is almost as reliable as a CRC-32 but can be computed much faster. Usage example: uLong adler = adler32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { adler = adler32(adler, buffer, length); } if (adler != original_adler) error(); */ -ZEXTERN uLong ZEXPORT adler32_z OF((uLong adler, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, + z_size_t len); /* Same as adler32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); +ZEXTERN uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, + z_off_t len2); Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note that the z_off_t type (like off_t) is a signed integer. If len2 is negative, the result has no meaning or utility. */ -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +ZEXTERN uLong ZEXPORT crc32(uLong crc, const Bytef *buf, uInt len); /* Update a running CRC-32 with the bytes buf[0..len-1] and return the updated CRC-32. A CRC-32 value is in the range of a 32-bit unsigned integer. If buf is Z_NULL, this function returns the required initial value for the crc. Pre- and post-conditioning (one's complement) is performed within this function so it shouldn't be done by the application. Usage example: uLong crc = crc32(0L, Z_NULL, 0); while (read_buffer(buffer, length) != EOF) { crc = crc32(crc, buffer, length); } if (crc != original_crc) error(); */ -ZEXTERN uLong ZEXPORT crc32_z OF((uLong crc, const Bytef *buf, - z_size_t len)); +ZEXTERN uLong ZEXPORT crc32_z(uLong crc, const Bytef *buf, + z_size_t len); /* Same as crc32(), but with a size_t length. */ /* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2); Combine two CRC-32 check values into one. For two sequences of bytes, seq1 and seq2 with lengths len1 and len2, CRC-32 check values were calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. + len2. len2 must be non-negative. */ /* -ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t len2)); +ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2); Return the operator corresponding to length len2, to be used with - crc32_combine_op(). + crc32_combine_op(). len2 must be non-negative. */ -ZEXTERN uLong ZEXPORT crc32_combine_op OF((uLong crc1, uLong crc2, uLong op)); +ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op); /* Give the same result as crc32_combine(), using op in place of len2. op is is generated from len2 by crc32_combine_gen(). This will be faster than crc32_combine() if the generated op is used more than once. */ /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version * and the compiler's view of z_stream: */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); +ZEXTERN int ZEXPORT deflateInit_(z_streamp strm, int level, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateInit_(z_streamp strm, + const char *version, int stream_size); +ZEXTERN int ZEXPORT deflateInit2_(z_streamp strm, int level, int method, + int windowBits, int memLevel, + int strategy, const char *version, + int stream_size); +ZEXTERN int ZEXPORT inflateInit2_(z_streamp strm, int windowBits, + const char *version, int stream_size); +ZEXTERN int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits, + unsigned char FAR *window, + const char *version, + int stream_size); #ifdef Z_PREFIX_SET # define z_deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) # define z_inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ (int)sizeof(z_stream)) # define z_inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, (int)sizeof(z_stream)) #else # define deflateInit(strm, level) \ deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) # define inflateInit(strm) \ inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) # define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) # define inflateInit2(strm, windowBits) \ inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ (int)sizeof(z_stream)) # define inflateBackInit(strm, windowBits, window) \ inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, (int)sizeof(z_stream)) #endif #ifndef Z_SOLO /* gzgetc() macro and its supporting function and exposed data structure. Note * that the real internal state is much larger than the exposed structure. * This abbreviated structure exposes just enough for the gzgetc() macro. The * user should not mess with these exposed elements, since their names or * behavior could change in the future, perhaps even capriciously. They can * only be used by the gzgetc() macro. You have been warned. */ struct gzFile_s { unsigned have; unsigned char *next; z_off64_t pos; }; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ +ZEXTERN int ZEXPORT gzgetc_(gzFile file); /* backward compatibility */ #ifdef Z_PREFIX_SET # undef z_gzgetc # define z_gzgetc(g) \ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #else # define gzgetc(g) \ ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : (gzgetc)(g)) #endif /* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if * both are true, the application gets the *64 functions, and the regular * functions are changed to 64 bits) -- in case these are set on systems * without large file support, _LFS64_LARGEFILE must also be true */ #ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off64_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int); + ZEXTERN z_off64_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off64_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off64_t); #endif #if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) # ifdef Z_PREFIX_SET # define z_gzopen z_gzopen64 # define z_gzseek z_gzseek64 # define z_gztell z_gztell64 # define z_gzoffset z_gzoffset64 # define z_adler32_combine z_adler32_combine64 # define z_crc32_combine z_crc32_combine64 # define z_crc32_combine_gen z_crc32_combine_gen64 # else # define gzopen gzopen64 # define gzseek gzseek64 # define gztell gztell64 # define gzoffset gzoffset64 # define adler32_combine adler32_combine64 # define crc32_combine crc32_combine64 # define crc32_combine_gen crc32_combine_gen64 # endif # ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek64(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell64(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset64(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); # endif #else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN gzFile ZEXPORT gzopen(const char *, const char *); + ZEXTERN z_off_t ZEXPORT gzseek(gzFile, z_off_t, int); + ZEXTERN z_off_t ZEXPORT gztell(gzFile); + ZEXTERN z_off_t ZEXPORT gzoffset(gzFile); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif #else /* Z_SOLO */ - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t); #endif /* !Z_SOLO */ /* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateValidate OF((z_streamp, int)); -ZEXTERN unsigned long ZEXPORT inflateCodesUsed OF((z_streamp)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); +ZEXTERN const char * ZEXPORT zError(int); +ZEXTERN int ZEXPORT inflateSyncPoint(z_streamp); +ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table(void); +ZEXTERN int ZEXPORT inflateUndermine(z_streamp, int); +ZEXTERN int ZEXPORT inflateValidate(z_streamp, int); +ZEXTERN unsigned long ZEXPORT inflateCodesUsed(z_streamp); +ZEXTERN int ZEXPORT inflateResetKeep(z_streamp); +ZEXTERN int ZEXPORT deflateResetKeep(z_streamp); #if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); +ZEXTERN gzFile ZEXPORT gzopen_w(const wchar_t *path, + const char *mode); #endif #if defined(STDC) || defined(Z_HAVE_STDARG_H) # ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); +ZEXTERN int ZEXPORTVA gzvprintf(gzFile file, + const char *format, + va_list va); # endif #endif #ifdef __cplusplus } #endif #endif /* ZLIB_H */ diff --git a/src/Common/zlib/zutil.c b/src/Common/zlib/zutil.c index 9543ae82..b1c5d2d3 100644 --- a/src/Common/zlib/zutil.c +++ b/src/Common/zlib/zutil.c @@ -1,63 +1,61 @@ /* zutil.c -- target dependent utility functions for the compression library * Copyright (C) 1995-2017 Jean-loup Gailly * For conditions of distribution and use, see copyright notice in zlib.h */ /* @(#) $Id$ */ #include "zutil.h" #ifndef Z_SOLO # include "gzguts.h" #endif z_const char * const z_errmsg[10] = { (z_const char *)"need dictionary", /* Z_NEED_DICT 2 */ (z_const char *)"stream end", /* Z_STREAM_END 1 */ (z_const char *)"", /* Z_OK 0 */ (z_const char *)"file error", /* Z_ERRNO (-1) */ (z_const char *)"stream error", /* Z_STREAM_ERROR (-2) */ (z_const char *)"data error", /* Z_DATA_ERROR (-3) */ (z_const char *)"insufficient memory", /* Z_MEM_ERROR (-4) */ (z_const char *)"buffer error", /* Z_BUF_ERROR (-5) */ (z_const char *)"incompatible version",/* Z_VERSION_ERROR (-6) */ (z_const char *)"" }; -const char * ZEXPORT zlibVersion() -{ +const char * ZEXPORT zlibVersion(void) { return ZLIB_VERSION; } -uLong ZEXPORT zlibCompileFlags() -{ +uLong ZEXPORT zlibCompileFlags(void) { uLong flags; flags = 0; switch ((int)(sizeof(uInt))) { case 2: break; case 4: flags += 1; break; case 8: flags += 2; break; default: flags += 3; } switch ((int)(sizeof(uLong))) { case 2: break; case 4: flags += 1 << 2; break; case 8: flags += 2 << 2; break; default: flags += 3 << 2; } switch ((int)(sizeof(voidpf))) { case 2: break; case 4: flags += 1 << 4; break; case 8: flags += 2 << 4; break; default: flags += 3 << 4; } switch ((int)(sizeof(z_off_t))) { case 2: break; case 4: flags += 1 << 6; break; case 8: flags += 2 << 6; break; default: flags += 3 << 6; } #ifdef ZLIB_DEBUG flags += 1 << 8; #endif @@ -94,234 +92,208 @@ uLong ZEXPORT zlibCompileFlags() flags += 1L << 26; # endif # else # ifdef HAS_vsnprintf_void flags += 1L << 26; # endif # endif #else flags += 1L << 24; # ifdef NO_snprintf flags += 1L << 25; # ifdef HAS_sprintf_void flags += 1L << 26; # endif # else # ifdef HAS_snprintf_void flags += 1L << 26; # endif # endif #endif return flags; } #ifdef ZLIB_DEBUG #include <stdlib.h> # ifndef verbose # define verbose 0 # endif int ZLIB_INTERNAL z_verbose = verbose; -void ZLIB_INTERNAL z_error(m) - char *m; -{ +void ZLIB_INTERNAL z_error(char *m) { fprintf(stderr, "%s\n", m); exit(1); } #endif /* exported to allow conversion of error code to string for compress() and * uncompress() */ -const char * ZEXPORT zError(err) - int err; -{ +const char * ZEXPORT zError(int err) { return ERR_MSG(err); } #if defined(_WIN32_WCE) && _WIN32_WCE < 0x800 /* The older Microsoft C Run-Time Library for Windows CE doesn't have * errno. We define it as a global variable to simplify porting. * Its value is always 0 and should not be used. */ int errno = 0; #endif #ifndef HAVE_MEMCPY -void ZLIB_INTERNAL zmemcpy(dest, source, len) - Bytef* dest; - const Bytef* source; - uInt len; -{ +void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len) { if (len == 0) return; do { *dest++ = *source++; /* ??? to be unrolled */ } while (--len != 0); } -int ZLIB_INTERNAL zmemcmp(s1, s2, len) - const Bytef* s1; - const Bytef* s2; - uInt len; -{ +int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len) { uInt j; for (j = 0; j < len; j++) { if (s1[j] != s2[j]) return 2*(s1[j] > s2[j])-1; } return 0; } -void ZLIB_INTERNAL zmemzero(dest, len) - Bytef* dest; - uInt len; -{ +void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len) { if (len == 0) return; do { *dest++ = 0; /* ??? to be unrolled */ } while (--len != 0); } #endif #ifndef Z_SOLO #ifdef SYS16BIT #ifdef __TURBOC__ /* Turbo C in 16-bit mode */ # define MY_ZCALLOC /* Turbo C malloc() does not allow dynamic allocation of 64K bytes * and farmalloc(64K) returns a pointer with an offset of 8, so we * must fix the pointer. Warning: the pointer must be put back to its * original form in order to free it, use zcfree(). */ #define MAX_PTR 10 /* 10*64K = 640K */ local int next_ptr = 0; typedef struct ptr_table_s { voidpf org_ptr; voidpf new_ptr; } ptr_table; local ptr_table table[MAX_PTR]; /* This table is used to remember the original form of pointers * to large buffers (64K). Such pointers are normalized with a zero offset. * Since MSDOS is not a preemptive multitasking OS, this table is not * protected from concurrent access. This hack doesn't work anyway on * a protected system like OS/2. Use Microsoft C instead. */ -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { voidpf buf; ulg bsize = (ulg)items*size; (void)opaque; /* If we allocate less than 65520 bytes, we assume that farmalloc * will return a usable pointer which doesn't have to be normalized. */ if (bsize < 65520L) { buf = farmalloc(bsize); if (*(ush*)&buf != 0) return buf; } else { buf = farmalloc(bsize + 16L); } if (buf == NULL || next_ptr >= MAX_PTR) return NULL; table[next_ptr].org_ptr = buf; /* Normalize the pointer to seg:0 */ *((ush*)&buf+1) += ((ush)((uch*)buf-0) + 15) >> 4; *(ush*)&buf = 0; table[next_ptr++].new_ptr = buf; return buf; } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { int n; (void)opaque; if (*(ush*)&ptr != 0) { /* object < 64K */ farfree(ptr); return; } /* Find the original pointer */ for (n = 0; n < next_ptr; n++) { if (ptr != table[n].new_ptr) continue; farfree(table[n].org_ptr); while (++n < next_ptr) { table[n-1] = table[n]; } next_ptr--; return; } Assert(0, "zcfree: ptr not found"); } #endif /* __TURBOC__ */ #ifdef M_I86 /* Microsoft C in 16-bit mode */ # define MY_ZCALLOC #if (!defined(_MSC_VER) || (_MSC_VER <= 600)) # define _halloc halloc # define _hfree hfree #endif -voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, uInt items, uInt size) { (void)opaque; return _halloc((long)items, size); } -void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; _hfree(ptr); } #endif /* M_I86 */ #endif /* SYS16BIT */ #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC -extern voidp malloc OF((uInt size)); -extern voidp calloc OF((uInt items, uInt size)); -extern void free OF((voidpf ptr)); +extern voidp malloc(uInt size); +extern voidp calloc(uInt items, uInt size); +extern void free(voidpf ptr); #endif -voidpf ZLIB_INTERNAL zcalloc(opaque, items, size) - voidpf opaque; - unsigned items; - unsigned size; -{ +voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, unsigned size) { (void)opaque; return sizeof(uInt) > 2 ? (voidpf)malloc(items * size) : (voidpf)calloc(items, size); } -void ZLIB_INTERNAL zcfree(opaque, ptr) - voidpf opaque; - voidpf ptr; -{ +void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr) { (void)opaque; free(ptr); } #endif /* MY_ZCALLOC */ #endif /* !Z_SOLO */ diff --git a/src/Common/zlib/zutil.h b/src/Common/zlib/zutil.h index 0bc7f4ec..48dd7feb 100644 --- a/src/Common/zlib/zutil.h +++ b/src/Common/zlib/zutil.h @@ -1,89 +1,89 @@ /* zutil.h -- internal interface and configuration of the compression library - * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler + * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler * For conditions of distribution and use, see copyright notice in zlib.h */ /* WARNING: this file should *not* be used by applications. It is part of the implementation of the compression library and is subject to change. Applications should only use zlib.h. */ /* @(#) $Id$ */ #ifndef ZUTIL_H #define ZUTIL_H #ifdef HAVE_HIDDEN # define ZLIB_INTERNAL __attribute__((visibility ("hidden"))) #else # define ZLIB_INTERNAL #endif #include "zlib.h" #if defined(STDC) && !defined(Z_SOLO) # if !(defined(_WIN32_WCE) && defined(_MSC_VER)) # include <stddef.h> # endif # include <string.h> # include <stdlib.h> #endif #ifndef local # define local static #endif /* since "static" is used to mean two completely different things in C, we define "local" for the non-static meaning of "static", for readability (compile with -Dlocal if your debugger can't find static symbols) */ typedef unsigned char uch; typedef uch FAR uchf; typedef unsigned short ush; typedef ush FAR ushf; typedef unsigned long ulg; #if !defined(Z_U8) && !defined(Z_SOLO) && defined(STDC) # include <limits.h> # if (ULONG_MAX == 0xffffffffffffffff) # define Z_U8 unsigned long # elif (ULLONG_MAX == 0xffffffffffffffff) # define Z_U8 unsigned long long # elif (UINT_MAX == 0xffffffffffffffff) # define Z_U8 unsigned # endif #endif extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ /* (size given to avoid silly warnings with Visual C++) */ -#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] +#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)] #define ERR_RETURN(strm,err) \ return (strm->msg = ERR_MSG(err), (err)) /* To be used only when the state is known to be valid */ /* common constants */ #ifndef DEF_WBITS # define DEF_WBITS MAX_WBITS #endif /* default windowBits for decompression. MAX_WBITS is for compression only */ #if MAX_MEM_LEVEL >= 8 # define DEF_MEM_LEVEL 8 #else # define DEF_MEM_LEVEL MAX_MEM_LEVEL #endif /* default memLevel */ #define STORED_BLOCK 0 #define STATIC_TREES 1 #define DYN_TREES 2 /* The three kinds of block type */ #define MIN_MATCH 3 #define MAX_MATCH 258 /* The minimum and maximum match lengths */ #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ @@ -110,166 +110,145 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define OS_CODE 1 #endif #if defined(VAXC) || defined(VMS) # define OS_CODE 2 # define F_OPEN(name, mode) \ fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") #endif #ifdef __370__ # if __TARGET_LIB__ < 0x20000000 # define OS_CODE 4 # elif __TARGET_LIB__ < 0x40000000 # define OS_CODE 11 # else # define OS_CODE 8 # endif #endif #if defined(ATARI) || defined(atarist) # define OS_CODE 5 #endif #ifdef OS2 # define OS_CODE 6 # if defined(M_I86) && !defined(Z_SOLO) # include <malloc.h> # endif #endif -#if defined(MACOS) || defined(TARGET_OS_MAC) +#if defined(MACOS) # define OS_CODE 7 -# ifndef Z_SOLO -# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os -# include <unix.h> /* for fdopen */ -# else -# ifndef fdopen -# define fdopen(fd,mode) NULL /* No fdopen() */ -# endif -# endif -# endif #endif #ifdef __acorn # define OS_CODE 13 #endif #if defined(WIN32) && !defined(__CYGWIN__) # define OS_CODE 10 #endif #ifdef _BEOS_ # define OS_CODE 16 #endif #ifdef __TOS_OS400__ # define OS_CODE 18 #endif #ifdef __APPLE__ # define OS_CODE 19 #endif -#if defined(_BEOS_) || defined(RISCOS) -# define fdopen(fd,mode) NULL /* No fdopen() */ -#endif - -#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX -# if defined(_WIN32_WCE) -# define fdopen(fd,mode) NULL /* No fdopen() */ -# else -# define fdopen(fd,type) _fdopen(fd,type) -# endif -#endif - #if defined(__BORLANDC__) && !defined(MSDOS) #pragma warn -8004 #pragma warn -8008 #pragma warn -8066 #endif /* provide prototypes for these when building zlib without LFS */ #if !defined(_WIN32) && \ (!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0) - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine_gen64 OF((z_off_t)); + ZEXTERN uLong ZEXPORT adler32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine64(uLong, uLong, z_off_t); + ZEXTERN uLong ZEXPORT crc32_combine_gen64(z_off_t); #endif /* common defaults */ #ifndef OS_CODE # define OS_CODE 3 /* assume Unix */ #endif #ifndef F_OPEN # define F_OPEN(name, mode) fopen((name), (mode)) #endif /* functions */ #if defined(pyr) || defined(Z_SOLO) # define NO_MEMCPY #endif #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) /* Use our own functions for small and medium model with MSC <= 5.0. * You may have to use the same strategy for Borland C (untested). * The __SC__ check is for Symantec. */ # define NO_MEMCPY #endif #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) # define HAVE_MEMCPY #endif #ifdef HAVE_MEMCPY # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ # define zmemcpy _fmemcpy # define zmemcmp _fmemcmp # define zmemzero(dest, len) _fmemset(dest, 0, len) # else # define zmemcpy memcpy # define zmemcmp memcmp # define zmemzero(dest, len) memset(dest, 0, len) # endif #else - void ZLIB_INTERNAL zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); - int ZLIB_INTERNAL zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); - void ZLIB_INTERNAL zmemzero OF((Bytef* dest, uInt len)); + void ZLIB_INTERNAL zmemcpy(Bytef* dest, const Bytef* source, uInt len); + int ZLIB_INTERNAL zmemcmp(const Bytef* s1, const Bytef* s2, uInt len); + void ZLIB_INTERNAL zmemzero(Bytef* dest, uInt len); #endif /* Diagnostic functions */ #ifdef ZLIB_DEBUG # include <stdio.h> extern int ZLIB_INTERNAL z_verbose; - extern void ZLIB_INTERNAL z_error OF((char *m)); + extern void ZLIB_INTERNAL z_error(char *m); # define Assert(cond,msg) {if(!(cond)) z_error(msg);} # define Trace(x) {if (z_verbose>=0) fprintf x ;} # define Tracev(x) {if (z_verbose>0) fprintf x ;} # define Tracevv(x) {if (z_verbose>1) fprintf x ;} # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} #else # define Assert(cond,msg) # define Trace(x) # define Tracev(x) # define Tracevv(x) # define Tracec(c,x) # define Tracecv(c,x) #endif #ifndef Z_SOLO - voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items, - unsigned size)); - void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr)); + voidpf ZLIB_INTERNAL zcalloc(voidpf opaque, unsigned items, + unsigned size); + void ZLIB_INTERNAL zcfree(voidpf opaque, voidpf ptr); #endif #define ZALLOC(strm, items, size) \ (*((strm)->zalloc))((strm)->opaque, (items), (size)) #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} /* Reverse the bytes in a 32-bit value */ #define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \ (((q) & 0xff00) << 8) + (((q) & 0xff) << 24)) #endif /* ZUTIL_H */ diff --git a/src/Core/Core.h b/src/Core/Core.h index 65ea5bee..b9e53021 100644 --- a/src/Core/Core.h +++ b/src/Core/Core.h @@ -55,63 +55,67 @@ namespace VeraCrypt virtual ~MountThreadRoutine() { } virtual void ExecutionCode(void) { m_pVolume = Core->MountVolume(m_options); } }; class VolumeCreatorThreadRoutine : public WaitThreadRoutine { public: shared_ptr <VolumeCreationOptions> m_options; shared_ptr <VolumeCreator> m_pCreator; VolumeCreatorThreadRoutine(shared_ptr <VolumeCreationOptions> options, shared_ptr <VolumeCreator> pCreator) : m_options(options), m_pCreator(pCreator) {} virtual ~VolumeCreatorThreadRoutine() { } virtual void ExecutionCode(void) { m_pCreator->CreateVolume (m_options); } }; class ChangePasswordThreadRoutine : public WaitThreadRoutine { public: shared_ptr <VolumePath> m_volumePath; bool m_preserveTimestamps; shared_ptr <VolumePassword> m_password; int m_pim; shared_ptr <Pkcs5Kdf> m_kdf; shared_ptr <KeyfileList> m_keyfiles; shared_ptr <VolumePassword> m_newPassword; int m_newPim; shared_ptr <KeyfileList> m_newKeyfiles; shared_ptr <Pkcs5Kdf> m_newPkcs5Kdf; int m_wipeCount; bool m_emvSupportEnabled; - ChangePasswordThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount, bool emvSupportEnabled) : m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_pim(pim), m_kdf(kdf), m_keyfiles(keyfiles), m_newPassword(newPassword), m_newPim(newPim), m_newKeyfiles(newKeyfiles), m_newPkcs5Kdf(newPkcs5Kdf), m_wipeCount(wipeCount), m_emvSupportEnabled(emvSupportEnabled) {} + bool m_masterKeyVulnerable; + ChangePasswordThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount, bool emvSupportEnabled) : m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_pim(pim), m_kdf(kdf), m_keyfiles(keyfiles), m_newPassword(newPassword), m_newPim(newPim), m_newKeyfiles(newKeyfiles), m_newPkcs5Kdf(newPkcs5Kdf), m_wipeCount(wipeCount), m_emvSupportEnabled(emvSupportEnabled), m_masterKeyVulnerable(false) {} virtual ~ChangePasswordThreadRoutine() { } - virtual void ExecutionCode(void) { Core->ChangePassword(m_volumePath, m_preserveTimestamps, m_password, m_pim, m_kdf, m_keyfiles, m_newPassword, m_newPim, m_newKeyfiles, m_emvSupportEnabled, m_newPkcs5Kdf, m_wipeCount); } + virtual void ExecutionCode(void) { + shared_ptr <Volume> openVolume = Core->ChangePassword(m_volumePath, m_preserveTimestamps, m_password, m_pim, m_kdf, m_keyfiles, m_newPassword, m_newPim, m_newKeyfiles, m_emvSupportEnabled, m_newPkcs5Kdf, m_wipeCount); + m_masterKeyVulnerable = openVolume->IsMasterKeyVulnerable(); + } }; class OpenVolumeThreadRoutine : public WaitThreadRoutine { public: shared_ptr <VolumePath> m_volumePath; bool m_preserveTimestamps; shared_ptr <VolumePassword> m_password; int m_pim; shared_ptr<Pkcs5Kdf> m_Kdf; shared_ptr <KeyfileList> m_keyfiles; VolumeProtection::Enum m_protection; shared_ptr <VolumePassword> m_protectionPassword; int m_protectionPim; shared_ptr<Pkcs5Kdf> m_protectionKdf; shared_ptr <KeyfileList> m_protectionKeyfiles; bool m_sharedAccessAllowed; VolumeType::Enum m_volumeType; bool m_useBackupHeaders; bool m_partitionInSystemEncryptionScope; shared_ptr <Volume> m_pVolume; bool m_emvSupportEnabled; OpenVolumeThreadRoutine(shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr<Pkcs5Kdf> Kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr<Pkcs5Kdf> protectionKdf = shared_ptr<Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false): m_volumePath(volumePath), m_preserveTimestamps(preserveTimestamps), m_password(password), m_pim(pim), m_Kdf(Kdf), m_keyfiles(keyfiles), m_protection(protection), m_protectionPassword(protectionPassword), m_protectionPim(protectionPim), m_protectionKdf(protectionKdf), m_protectionKeyfiles(protectionKeyfiles), m_sharedAccessAllowed(sharedAccessAllowed), m_volumeType(volumeType),m_useBackupHeaders(useBackupHeaders), m_partitionInSystemEncryptionScope(partitionInSystemEncryptionScope), m_emvSupportEnabled(emvSupportEnabled) {} ~OpenVolumeThreadRoutine() {} diff --git a/src/Core/CoreBase.cpp b/src/Core/CoreBase.cpp index c1016726..0c6d5c9e 100644 --- a/src/Core/CoreBase.cpp +++ b/src/Core/CoreBase.cpp @@ -50,64 +50,65 @@ namespace VeraCrypt RandomNumberGenerator::SetHash (newPkcs5Kdf->GetHash()); SecureBuffer newSalt (openVolume->GetSaltSize()); SecureBuffer newHeaderKey (VolumeHeader::GetLargestSerializedKeySize()); shared_ptr <VolumePassword> password (Keyfile::ApplyListToPassword (newKeyfiles, newPassword, emvSupportEnabled)); bool backupHeader = false; while (true) { for (int i = 1; i <= wipeCount; i++) { if (i == wipeCount) RandomNumberGenerator::GetData (newSalt); else RandomNumberGenerator::GetDataFast (newSalt); newPkcs5Kdf->DeriveKey (newHeaderKey, *password, newPim, newSalt); openVolume->ReEncryptHeader (backupHeader, newSalt, newHeaderKey, newPkcs5Kdf); openVolume->GetFile()->Flush(); } if (!openVolume->GetLayout()->HasBackupHeader() || backupHeader) break; backupHeader = true; } } - void CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, bool emvSupportEnabled, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const + shared_ptr <Volume> CoreBase::ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, bool emvSupportEnabled, shared_ptr <Pkcs5Kdf> newPkcs5Kdf, int wipeCount) const { shared_ptr <Volume> volume = OpenVolume (volumePath, preserveTimestamps, password, pim, kdf, keyfiles, emvSupportEnabled); ChangePassword (volume, newPassword, newPim, newKeyfiles, emvSupportEnabled, newPkcs5Kdf, wipeCount); + return volume; } void CoreBase::CoalesceSlotNumberAndMountPoint (MountOptions &options) const { if (options.SlotNumber < GetFirstSlotNumber()) { if (options.MountPoint && !options.MountPoint->IsEmpty()) options.SlotNumber = MountPointToSlotNumber (*options.MountPoint); else options.SlotNumber = GetFirstFreeSlotNumber(); } if (!IsSlotNumberAvailable (options.SlotNumber)) #ifdef TC_WINDOWS throw DriveLetterUnavailable (SRC_POS); #else throw VolumeSlotUnavailable (SRC_POS); #endif if (!options.NoFilesystem && (!options.MountPoint || options.MountPoint->IsEmpty())) options.MountPoint.reset (new DirectoryPath (SlotNumberToMountPoint (options.SlotNumber))); } void CoreBase::CreateKeyfile (const FilePath &keyfilePath) const { SecureBuffer keyfileBuffer (VolumePassword::MaxSize); RandomNumberGenerator::GetData (keyfileBuffer); File keyfile; keyfile.Open (keyfilePath, File::CreateWrite); keyfile.Write (keyfileBuffer); @@ -117,61 +118,61 @@ namespace VeraCrypt { if (startFrom < GetFirstSlotNumber()) startFrom = GetFirstSlotNumber(); set <VolumeSlotNumber> usedSlotNumbers; foreach_ref (const VolumeInfo &volume, GetMountedVolumes()) usedSlotNumbers.insert (volume.SlotNumber); for (VolumeSlotNumber slotNumber = startFrom; slotNumber <= GetLastSlotNumber(); ++slotNumber) { if (usedSlotNumbers.find (slotNumber) == usedSlotNumbers.end() && IsMountPointAvailable (SlotNumberToMountPoint (slotNumber))) return slotNumber; } #ifdef TC_WINDOWS throw DriveLetterUnavailable (SRC_POS); #else throw VolumeSlotUnavailable (SRC_POS); #endif } uint64 CoreBase::GetMaxHiddenVolumeSize (shared_ptr <Volume> outerVolume) const { uint32 sectorSize = outerVolume->GetSectorSize(); SecureBuffer bootSectorBuffer (sectorSize); outerVolume->ReadSectors (bootSectorBuffer, 0); int fatType; - byte *bootSector = bootSectorBuffer.Ptr(); + uint8 *bootSector = bootSectorBuffer.Ptr(); if (memcmp (bootSector + 54, "FAT12", 5) == 0) fatType = 12; else if (memcmp (bootSector + 54, "FAT16", 5) == 0) fatType = 16; else if (memcmp (bootSector + 82, "FAT32", 5) == 0) fatType = 32; else throw ParameterIncorrect (SRC_POS); uint32 clusterSize = bootSector[13] * sectorSize; uint32 reservedSectorCount = Endian::Little (*(uint16 *) (bootSector + 14)); uint32 fatCount = bootSector[16]; uint64 fatSectorCount; if (fatType == 32) fatSectorCount = Endian::Little (*(uint32 *) (bootSector + 36)); else fatSectorCount = Endian::Little (*(uint16 *) (bootSector + 22)); uint64 fatSize = fatSectorCount * sectorSize; uint64 fatStartOffset = reservedSectorCount * sectorSize; uint64 dataAreaOffset = reservedSectorCount * sectorSize + fatSize * fatCount; if (fatType < 32) dataAreaOffset += Endian::Little (*(uint16 *) (bootSector + 17)) * 32; SecureBuffer sector (sectorSize); // Find last used cluster diff --git a/src/Core/CoreBase.h b/src/Core/CoreBase.h index 03aa922a..e646fce3 100644 --- a/src/Core/CoreBase.h +++ b/src/Core/CoreBase.h @@ -7,61 +7,61 @@ and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Core_CoreBase #define TC_HEADER_Core_CoreBase #include "Platform/Platform.h" #include "Platform/Functor.h" #include "Platform/User.h" #include "Common/Crypto.h" #include "Volume/Keyfile.h" #include "Volume/VolumeInfo.h" #include "Volume/Volume.h" #include "Volume/VolumePassword.h" #include "CoreException.h" #include "HostDevice.h" #include "MountOptions.h" #include "VolumeCreator.h" namespace VeraCrypt { class CoreBase { public: virtual ~CoreBase (); virtual void ChangePassword (shared_ptr <Volume> openVolume, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, bool emvSupportEnabled, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; - virtual void ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, bool emvSupportEnabled, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; + virtual shared_ptr <Volume> ChangePassword (shared_ptr <VolumePath> volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, bool emvSupportEnabled, shared_ptr <Pkcs5Kdf> newPkcs5Kdf = shared_ptr <Pkcs5Kdf> (), int wipeCount = PRAND_HEADER_WIPE_PASSES) const; virtual void CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair = false) const = 0; virtual void CoalesceSlotNumberAndMountPoint (MountOptions &options) const; virtual void CreateKeyfile (const FilePath &keyfilePath) const; virtual void DismountFilesystem (const DirectoryPath &mountPoint, bool force) const = 0; virtual shared_ptr <VolumeInfo> DismountVolume (shared_ptr <VolumeInfo> mountedVolume, bool ignoreOpenFiles = false, bool syncVolumeInfo = false) = 0; virtual bool FilesystemSupportsLargeFiles (const FilePath &filePath) const = 0; virtual DirectoryPath GetDeviceMountPoint (const DevicePath &devicePath) const = 0; virtual uint32 GetDeviceSectorSize (const DevicePath &devicePath) const = 0; virtual uint64 GetDeviceSize (const DevicePath &devicePath) const = 0; virtual VolumeSlotNumber GetFirstFreeSlotNumber (VolumeSlotNumber startFrom = 0) const; virtual VolumeSlotNumber GetFirstSlotNumber () const { return 1; } virtual VolumeSlotNumber GetLastSlotNumber () const { return 64; } virtual HostDeviceList GetHostDevices (bool pathListOnly = false) const = 0; virtual FilePath GetApplicationExecutablePath () const { return ApplicationExecutablePath; } virtual uint64 GetMaxHiddenVolumeSize (shared_ptr <Volume> outerVolume) const; virtual int GetOSMajorVersion () const = 0; virtual int GetOSMinorVersion () const = 0; virtual shared_ptr <VolumeInfo> GetMountedVolume (const VolumePath &volumePath) const; virtual shared_ptr <VolumeInfo> GetMountedVolume (VolumeSlotNumber slot) const; virtual VolumeInfoList GetMountedVolumes (const VolumePath &volumePath = VolumePath()) const = 0; virtual bool HasAdminPrivileges () const = 0; virtual void Init () { } virtual bool IsDeviceChangeInProgress () const { return DeviceChangeInProgress; } virtual bool IsDevicePresent (const DevicePath &device) const = 0; virtual bool IsInPortableMode () const = 0; virtual bool IsMountPointAvailable (const DirectoryPath &mountPoint) const = 0; virtual bool IsOSVersion (int major, int minor) const = 0; virtual bool IsOSVersionLower (int major, int minor) const = 0; virtual bool IsPasswordCacheEmpty () const = 0; virtual bool IsSlotNumberAvailable (VolumeSlotNumber slotNumber) const; diff --git a/src/Core/FatFormatter.cpp b/src/Core/FatFormatter.cpp index fa327837..c8115f9b 100644 --- a/src/Core/FatFormatter.cpp +++ b/src/Core/FatFormatter.cpp @@ -122,61 +122,61 @@ namespace VeraCrypt do { ft->reserved++; fatsecs = ft->num_sectors - ft->reserved; ft->size_root_dir = ft->cluster_size * ft->sector_size; ft->cluster_count = (int) (((int64) fatsecs * ft->sector_size) / (ft->cluster_size * ft->sector_size)); ft->fat_length = (ft->cluster_count * 4 + ft->sector_size - 1) / ft->sector_size; // Align data area on TC_MAX_VOLUME_SECTOR_SIZE } while (ft->sector_size == TC_SECTOR_SIZE_LEGACY && (ft->reserved * ft->sector_size + ft->fat_length * ft->fats * ft->sector_size) % TC_MAX_VOLUME_SECTOR_SIZE != 0); } ft->cluster_count -= ft->fat_length * ft->fats / ft->cluster_size; if (ft->num_sectors >= 65536 || ft->size_fat == 32) { ft->sectors = 0; ft->total_sect = ft->num_sectors; } else { ft->sectors = (uint16) ft->num_sectors; ft->total_sect = 0; } } - static void PutBoot (fatparams * ft, byte *boot, uint32 volumeId) + static void PutBoot (fatparams * ft, uint8 *boot, uint32 volumeId) { int cnt = 0; boot[cnt++] = 0xeb; /* boot jump */ boot[cnt++] = (ft->size_fat == 32)? 0x58: 0x3c; boot[cnt++] = 0x90; memcpy (boot + cnt, "MSDOS5.0", 8); /* system id */ cnt += 8; *(int16 *)(boot + cnt) = Endian::Little (ft->sector_size); /* bytes per sector */ cnt += 2; boot[cnt++] = (int8) ft->cluster_size; /* sectors per cluster */ *(int16 *)(boot + cnt) = Endian::Little (ft->reserved); /* reserved sectors */ cnt += 2; boot[cnt++] = (int8) ft->fats; /* 2 fats */ if(ft->size_fat == 32) { boot[cnt++] = 0x00; boot[cnt++] = 0x00; } else { *(int16 *)(boot + cnt) = Endian::Little (ft->dir_entries); /* 512 root entries */ cnt += 2; } *(int16 *)(boot + cnt) = Endian::Little (ft->sectors); /* # sectors */ cnt += 2; boot[cnt++] = (int8) ft->media; /* media byte */ @@ -217,170 +217,170 @@ namespace VeraCrypt boot[cnt++] = 0x00; memset(boot+cnt, 0, 12); cnt+=12; /* Reserved */ } boot[cnt++] = 0x00; /* drive number */ // FIXED 80 > 00 boot[cnt++] = 0x00; /* reserved */ boot[cnt++] = 0x29; /* boot sig */ *(int32 *)(boot + cnt) = volumeId; cnt += 4; memcpy (boot + cnt, ft->volume_name, 11); /* vol title */ cnt += 11; switch(ft->size_fat) /* filesystem type */ { case 12: memcpy (boot + cnt, "FAT12 ", 8); break; case 16: memcpy (boot + cnt, "FAT16 ", 8); break; case 32: memcpy (boot + cnt, "FAT32 ", 8); break; } cnt += 8; memset (boot + cnt, 0, ft->size_fat==32 ? 420:448); /* boot code */ cnt += ft->size_fat==32 ? 420:448; boot[cnt++] = 0x55; boot[cnt++] = 0xaa; /* boot sig */ } /* FAT32 FSInfo */ - static void PutFSInfo (byte *sector, fatparams *ft) + static void PutFSInfo (uint8 *sector, fatparams *ft) { memset (sector, 0, ft->sector_size); sector[3] = 0x41; /* LeadSig */ 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; // Free cluster count *(uint32 *)(sector + 488) = Endian::Little (ft->cluster_count - ft->size_root_dir / ft->sector_size / ft->cluster_size); // Next free cluster *(uint32 *)(sector + 492) = Endian::Little ((uint32) 2); sector[508+3] = 0xaa; /* TrailSig */ sector[508+2] = 0x55; sector[508+1] = 0x00; sector[508+0] = 0x00; } void FatFormatter::Format (WriteSectorCallback &writeSector, uint64 deviceSize, uint32 clusterSize, uint32 sectorSize) { fatparams fatParams; #if TC_MAX_VOLUME_SECTOR_SIZE > 0xFFFF #error TC_MAX_VOLUME_SECTOR_SIZE > 0xFFFF #endif fatParams.sector_size = (uint16) sectorSize; if (deviceSize / fatParams.sector_size > 0xffffFFFF) throw ParameterIncorrect (SRC_POS); fatParams.num_sectors = (uint32) (deviceSize / fatParams.sector_size); fatParams.cluster_size = clusterSize / fatParams.sector_size; memcpy (fatParams.volume_name, "NO NAME ", 11); GetFatParams (&fatParams); fatparams *ft = &fatParams; SecureBuffer sector (ft->sector_size); uint32 sectorNumber = 0; /* Write the data area */ sector.Zero(); uint32 volumeId; - RandomNumberGenerator::GetDataFast (BufferPtr ((byte *) &volumeId, sizeof (volumeId))); + RandomNumberGenerator::GetDataFast (BufferPtr ((uint8 *) &volumeId, sizeof (volumeId))); - PutBoot (ft, (byte *) sector, volumeId); + PutBoot (ft, (uint8 *) sector, volumeId); writeSector (sector); ++sectorNumber; /* fat32 boot area */ if (ft->size_fat == 32) { /* fsinfo */ - PutFSInfo((byte *) sector, ft); + PutFSInfo((uint8 *) sector, ft); writeSector (sector); ++sectorNumber; /* reserved */ while (sectorNumber < 6) { sector.Zero(); sector[508+3] = 0xaa; /* TrailSig */ sector[508+2] = 0x55; writeSector (sector); ++sectorNumber; } /* bootsector backup */ sector.Zero(); - PutBoot (ft, (byte *) sector, volumeId); + PutBoot (ft, (uint8 *) sector, volumeId); writeSector (sector); ++sectorNumber; - PutFSInfo((byte *) sector, ft); + PutFSInfo((uint8 *) sector, ft); writeSector (sector); ++sectorNumber; } /* reserved */ while (sectorNumber < (uint32)ft->reserved) { sector.Zero(); writeSector (sector); ++sectorNumber; } /* write fat */ for (uint32 x = 1; x <= ft->fats; x++) { for (uint32 n = 0; n < ft->fat_length; n++) { sector.Zero(); if (n == 0) { - byte fat_sig[12]; + uint8 fat_sig[12]; if (ft->size_fat == 32) { - fat_sig[0] = (byte) ft->media; + fat_sig[0] = (uint8) ft->media; fat_sig[1] = fat_sig[2] = 0xff; fat_sig[3] = 0x0f; fat_sig[4] = fat_sig[5] = fat_sig[6] = 0xff; fat_sig[7] = 0x0f; 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] = (byte) ft->media; + fat_sig[0] = (uint8) ft->media; fat_sig[1] = 0xff; fat_sig[2] = 0xff; fat_sig[3] = 0xff; memcpy (sector, fat_sig, 4); } else if (ft->size_fat == 12) { - fat_sig[0] = (byte) ft->media; + fat_sig[0] = (uint8) ft->media; fat_sig[1] = 0xff; fat_sig[2] = 0xff; fat_sig[3] = 0x00; memcpy (sector, fat_sig, 4); } } if (!writeSector (sector)) return; } } /* write rootdir */ for (uint32 x = 0; x < ft->size_root_dir / ft->sector_size; x++) { sector.Zero(); if (!writeSector (sector)) return; } } } diff --git a/src/Core/RandomNumberGenerator.cpp b/src/Core/RandomNumberGenerator.cpp index 4451348e..b60b4eed 100644 --- a/src/Core/RandomNumberGenerator.cpp +++ b/src/Core/RandomNumberGenerator.cpp @@ -27,123 +27,121 @@ namespace VeraCrypt { void RandomNumberGenerator::AddSystemDataToPool (bool fast) { SecureBuffer buffer (PoolSize); #ifdef TC_WINDOWS #ifndef DEBUG throw NotImplemented (SRC_POS); #endif #else int urandom = open ("/dev/urandom", O_RDONLY); throw_sys_sub_if (urandom == -1, L"/dev/urandom"); finally_do_arg (int, urandom, { close (finally_arg); }); throw_sys_sub_if (read (urandom, buffer, buffer.Size()) == -1, L"/dev/urandom"); AddToPool (buffer); if (!fast) { // Read all bytes available in /dev/random up to buffer size int random = open ("/dev/random", O_RDONLY | O_NONBLOCK); throw_sys_sub_if (random == -1, L"/dev/random"); finally_do_arg (int, random, { close (finally_arg); }); // ensure that we have read at least 32 bytes from /dev/random before allowing it to fail gracefully while (true) { int rndCount = read (random, buffer, buffer.Size()); throw_sys_sub_if ((rndCount == -1) && errno != EAGAIN && errno != ERESTART && errno != EINTR, L"/dev/random"); - if (rndCount == -1 && (!DevRandomSucceeded || (DevRandomBytesCount < 32))) - { - // wait 250ms before querying /dev/random again - ::usleep (250 * 1000); + if (rndCount != -1) { + // We count returned bytes until 32-bytes threshold reached + if (DevRandomBytesCount < 32) + DevRandomBytesCount += rndCount; + break; } - else - { - if (rndCount != -1) - { - // We count returned bytes untill 32-bytes treshold reached - if (DevRandomBytesCount < 32) - DevRandomBytesCount += rndCount; - DevRandomSucceeded = true; - } + else if (DevRandomBytesCount >= 32) { + // allow /dev/random to fail gracefully since we have enough bytes break; } + else { + // wait 250ms before querying /dev/random again + ::usleep (250 * 1000); + } } AddToPool (buffer); /* use JitterEntropy library to get good quality random bytes based on CPU timing jitter */ if (JitterRngCtx) { ssize_t rndLen = jent_read_entropy (JitterRngCtx, (char*) buffer.Ptr(), buffer.Size()); if (rndLen > 0) { AddToPool (buffer); } } } #endif } void RandomNumberGenerator::AddToPool (const ConstBufferPtr &data) { if (!Running) throw NotInitialized (SRC_POS); ScopeLock lock (AccessMutex); for (size_t i = 0; i < data.Size(); ++i) { Pool[WriteOffset++] += data[i]; if (WriteOffset >= PoolSize) WriteOffset = 0; if (++BytesAddedSincePoolHashMix >= MaxBytesAddedBeforePoolHashMix) HashMixPool(); } } void RandomNumberGenerator::GetData (const BufferPtr &buffer, bool fast, bool allowAnyLength) { if (!Running) throw NotInitialized (SRC_POS); if (!allowAnyLength && (buffer.Size() > PoolSize)) throw ParameterIncorrect (SRC_POS); ScopeLock lock (AccessMutex); size_t bufferLen = buffer.Size(), loopLen; - byte* pbBuffer = buffer.Get(); + uint8* pbBuffer = buffer.Get(); // Initialize JitterEntropy RNG for this call if (0 == jent_entropy_init ()) { JitterRngCtx = jent_entropy_collector_alloc (1, 0); } // Poll system for data AddSystemDataToPool (fast); HashMixPool(); while (bufferLen > 0) { if (bufferLen > PoolSize) { loopLen = PoolSize; bufferLen -= PoolSize; } else { loopLen = bufferLen; bufferLen = 0; } // Transfer bytes from pool to output buffer for (size_t i = 0; i < loopLen; ++i) { pbBuffer[i] += Pool[ReadOffset++]; if (ReadOffset >= PoolSize) @@ -226,72 +224,82 @@ namespace VeraCrypt BytesAddedSincePoolHashMix = 0; ReadOffset = 0; WriteOffset = 0; Running = true; EnrichedByUser = false; Pool.Allocate (PoolSize, 16); Test(); if (!PoolHash) { // First hash algorithm is the default one PoolHash = Hash::GetAvailableAlgorithms().front(); } AddSystemDataToPool (true); } void RandomNumberGenerator::Stop () { ScopeLock lock (AccessMutex); if (Pool.IsAllocated()) Pool.Free (); PoolHash.reset(); EnrichedByUser = false; Running = false; - DevRandomSucceeded = false; DevRandomBytesCount = 0; } void RandomNumberGenerator::Test () { shared_ptr <Hash> origPoolHash = PoolHash; - PoolHash.reset (new Blake2s()); + #ifndef WOLFCRYPT_BACKEND + PoolHash.reset (new Blake2s()); + #else + PoolHash.reset (new Sha256()); + #endif Pool.Zero(); Buffer buffer (1); for (size_t i = 0; i < PoolSize * 10; ++i) { - buffer[0] = (byte) i; + buffer[0] = (uint8) i; AddToPool (buffer); } + #ifndef WOLFCRYPT_BACKEND if (Crc32::ProcessBuffer (Pool) != 0x9c743238) - throw TestFailed (SRC_POS); + #else + if (Crc32::ProcessBuffer (Pool) != 0xac95ac1a) + #endif + throw TestFailed (SRC_POS); buffer.Allocate (PoolSize); buffer.CopyFrom (PeekPool()); AddToPool (buffer); - if (Crc32::ProcessBuffer (Pool) != 0xd2d09c8d) - throw TestFailed (SRC_POS); + #ifndef WOLFCRYPT_BACKEND + if (Crc32::ProcessBuffer (Pool) != 0xd2d09c8d) + #else + if (Crc32::ProcessBuffer (Pool) != 0xb79f3c12) + #endif + throw TestFailed (SRC_POS); PoolHash = origPoolHash; } Mutex RandomNumberGenerator::AccessMutex; size_t RandomNumberGenerator::BytesAddedSincePoolHashMix; bool RandomNumberGenerator::EnrichedByUser; SecureBuffer RandomNumberGenerator::Pool; shared_ptr <Hash> RandomNumberGenerator::PoolHash; size_t RandomNumberGenerator::ReadOffset; bool RandomNumberGenerator::Running = false; size_t RandomNumberGenerator::WriteOffset; struct rand_data *RandomNumberGenerator::JitterRngCtx = NULL; - bool RandomNumberGenerator::DevRandomSucceeded = false; int RandomNumberGenerator::DevRandomBytesCount = 0; } diff --git a/src/Core/RandomNumberGenerator.h b/src/Core/RandomNumberGenerator.h index 8f440630..333a8e36 100644 --- a/src/Core/RandomNumberGenerator.h +++ b/src/Core/RandomNumberGenerator.h @@ -28,36 +28,35 @@ namespace VeraCrypt static void GetDataFast (const BufferPtr &buffer, bool allowAnyLength = false) { GetData (buffer, true, allowAnyLength); } static shared_ptr <Hash> GetHash (); static bool IsEnrichedByUser () { return EnrichedByUser; } static bool IsRunning () { return Running; } static ConstBufferPtr PeekPool () { return Pool; } static void SetEnrichedByUserStatus (bool enriched) { EnrichedByUser = enriched; } static void SetHash (shared_ptr <Hash> hash); static void Start (); static void Stop (); static const size_t PoolSize = RNG_POOL_SIZE; protected: static void AddSystemDataToPool (bool fast); static void GetData (const BufferPtr &buffer, bool fast, bool allowAnyLength); static void HashMixPool (); static void Test (); RandomNumberGenerator (); static const size_t MaxBytesAddedBeforePoolHashMix = RANDMIX_BYTE_INTERVAL; static Mutex AccessMutex; static size_t BytesAddedSincePoolHashMix; static bool EnrichedByUser; static SecureBuffer Pool; static shared_ptr <Hash> PoolHash; static size_t ReadOffset; static bool Running; static size_t WriteOffset; static struct rand_data *JitterRngCtx; - static bool DevRandomSucceeded; static int DevRandomBytesCount; }; } #endif // TC_HEADER_Core_RandomNumberGenerator diff --git a/src/Core/Unix/CoreService.cpp b/src/Core/Unix/CoreService.cpp index e543652a..6d0f05e5 100644 --- a/src/Core/Unix/CoreService.cpp +++ b/src/Core/Unix/CoreService.cpp @@ -30,61 +30,61 @@ namespace VeraCrypt template <class T> unique_ptr <T> CoreService::GetResponse () { unique_ptr <Serializable> deserializedObject (Serializable::DeserializeNew (ServiceOutputStream)); Exception *deserializedException = dynamic_cast <Exception*> (deserializedObject.get()); if (deserializedException) deserializedException->Throw(); if (dynamic_cast <T *> (deserializedObject.get()) == nullptr) throw ParameterIncorrect (SRC_POS); return unique_ptr <T> (dynamic_cast <T *> (deserializedObject.release())); } void CoreService::ProcessElevatedRequests () { int pid = fork(); throw_sys_if (pid == -1); if (pid == 0) { try { int f = open ("/dev/null", 0); throw_sys_sub_if (f == -1, "/dev/null"); throw_sys_if (dup2 (f, STDERR_FILENO) == -1); // Wait for sync code while (true) { - byte b; + uint8 b; throw_sys_if (read (STDIN_FILENO, &b, 1) != 1); if (b != 0x00) continue; throw_sys_if (read (STDIN_FILENO, &b, 1) != 1); if (b != 0x11) continue; throw_sys_if (read (STDIN_FILENO, &b, 1) != 1); if (b == 0x22) break; } ElevatedPrivileges = true; ProcessRequests (STDIN_FILENO, STDOUT_FILENO); _exit (0); } catch (exception &e) { #ifdef DEBUG SystemLog::WriteException (e); #endif } catch (...) { } _exit (1); } } void CoreService::ProcessRequests (int inputFD, int outputFD) { @@ -282,61 +282,61 @@ namespace VeraCrypt { static Mutex mutex; ScopeLock lock (mutex); if (request.RequiresElevation()) { request.ElevateUserPrivileges = true; request.FastElevation = !ElevatedServiceAvailable; request.ApplicationExecutablePath = Core->GetApplicationExecutablePath(); while (!ElevatedServiceAvailable) { // Test if the user has an active "sudo" session. // This is only done under Linux / FreeBSD by executing the command 'sudo -n uptime'. // In case a "sudo" session is active, the result of the command contains the string 'load average'. // Otherwise, the result contains "sudo: a password is required". // This may not work on all OSX versions because of a bug in sudo in its version 1.7.10, // therefore we keep the old behaviour of sending a 'dummy' password under OSX. // See : https://superuser.com/questions/902826/why-does-sudo-n-on-mac-os-x-always-return-0 // // If for some reason we are getting empty output from pipe, we revert to old behavior // We also use the old way if the user is forcing the use of dummy password for sudo #if defined(TC_LINUX ) || defined (TC_FREEBSD) bool authCheckDone = false; if (!Core->GetUseDummySudoPassword ()) { std::vector<char> buffer(128, 0); std::string result; - FILE* pipe = popen("sudo -n uptime 2>&1 | grep 'load average' | wc -l", "r"); // We redirect stderr to stdout (2>&1) to be able to catch the result of the command + FILE* pipe = popen("sudo -n uptime 2>&1 | grep 'load average' | wc -l | tr -d '[:blank:]'", "r"); // We redirect stderr to stdout (2>&1) to be able to catch the result of the command if (pipe) { while (!feof(pipe)) { if (fgets(buffer.data(), 128, pipe) != nullptr) result += buffer.data(); } fflush(pipe); pclose(pipe); pipe = NULL; if (!result.empty() && strlen(result.c_str()) != 0) { authCheckDone = true; if (result[0] == '0') // no line found with "load average" text, rerquest admin password (*AdminPasswordCallback) (request.AdminPassword); } } if (authCheckDone) { // Set to false to force the 'WarningEvent' to be raised in case of and elevation exception. request.FastElevation = false; } } #endif try { request.Serialize (ServiceInputStream); @@ -516,88 +516,88 @@ namespace VeraCrypt { // Prevent defunct process struct WaitFunctor : public Functor { WaitFunctor (int pid) : Pid (pid) { } virtual void operator() () { int status; for (int t = 0; t < 10 && waitpid (Pid, &status, WNOHANG) == 0; t++) Thread::Sleep (1000); } int Pid; }; Thread thread; thread.Start (new WaitFunctor (forkedPid)); throw ElevationFailed (SRC_POS, "sudo", 1, ""); } waitRes = waitpid (forkedPid, &status, 0); } } if (!errOutput.empty()) { unique_ptr <Serializable> deserializedObject; Exception *deserializedException = nullptr; try { - shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((byte *) &errOutput[0], errOutput.size()))); + shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((uint8 *) &errOutput[0], errOutput.size()))); deserializedObject.reset (Serializable::DeserializeNew (stream)); deserializedException = dynamic_cast <Exception*> (deserializedObject.get()); } catch (...) { } if (deserializedException) deserializedException->Throw(); } throw_sys_if (waitRes == -1); exitCode = (WIFEXITED (status) ? WEXITSTATUS (status) : 1); if (exitCode != 0) { string strErrOutput; if (!errOutput.empty()) strErrOutput.insert (strErrOutput.begin(), errOutput.begin(), errOutput.end()); // sudo may require a tty even if -S is used if (strErrOutput.find (" tty") != string::npos) strErrOutput += "\nTo enable use of 'sudo' by applications without a terminal window, please disable 'requiretty' option in '/etc/sudoers'. Newer versions of sudo automatically determine whether a terminal is required ('requiretty' option is obsolete)."; throw ElevationFailed (SRC_POS, "sudo", exitCode, strErrOutput); } throw_sys_if (fcntl (outPipe->GetReadFD(), F_SETFL, 0) == -1); ServiceInputStream = shared_ptr <Stream> (new FileStream (inPipe->GetWriteFD())); ServiceOutputStream = shared_ptr <Stream> (new FileStream (outPipe->GetReadFD())); // Send sync code - byte sync[] = { 0, 0x11, 0x22 }; + uint8 sync[] = { 0, 0x11, 0x22 }; ServiceInputStream->Write (ConstBufferPtr (sync, array_capacity (sync))); AdminInputPipe = move_ptr(inPipe); AdminOutputPipe = move_ptr(outPipe); } void CoreService::Stop () { ExitRequest exitRequest; exitRequest.Serialize (ServiceInputStream); } shared_ptr <GetStringFunctor> CoreService::AdminPasswordCallback; unique_ptr <Pipe> CoreService::AdminInputPipe; unique_ptr <Pipe> CoreService::AdminOutputPipe; unique_ptr <Pipe> CoreService::InputPipe; unique_ptr <Pipe> CoreService::OutputPipe; shared_ptr <Stream> CoreService::ServiceInputStream; shared_ptr <Stream> CoreService::ServiceOutputStream; bool CoreService::ElevatedPrivileges = false; bool CoreService::ElevatedServiceAvailable = false; } diff --git a/src/Core/Unix/CoreUnix.cpp b/src/Core/Unix/CoreUnix.cpp index 0b248fb9..1868eb6d 100644 --- a/src/Core/Unix/CoreUnix.cpp +++ b/src/Core/Unix/CoreUnix.cpp @@ -1,57 +1,54 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "CoreUnix.h" #include <errno.h> #include <iostream> #include <signal.h> #include <sys/stat.h> #include <sys/types.h> #include <stdio.h> #include <unistd.h> #include "Platform/FileStream.h" #include "Driver/Fuse/FuseService.h" #include "Volume/VolumePasswordCache.h" -template<typename T> -inline void ignore_result(const T & /* unused result */) {} - namespace VeraCrypt { #ifdef TC_LINUX static string GetTmpUser (); static bool SamePath (const string& path1, const string& path2); #endif CoreUnix::CoreUnix () { signal (SIGPIPE, SIG_IGN); char *loc = setlocale (LC_ALL, ""); if (!loc || string (loc) == "C") setlocale (LC_ALL, "en_US.UTF-8"); } CoreUnix::~CoreUnix () { } void CoreUnix::CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair) const { if (!mountedVolume->MountPoint.IsEmpty()) DismountFilesystem (mountedVolume->MountPoint, false); list <string> args; args.push_back ("-T"); args.push_back ("fsck"); @@ -217,61 +214,61 @@ namespace VeraCrypt || fs.Type == "fatfs" || fs.Type == "msdos" || fs.Type == "msdosfs" || fs.Type == "umsdos" || fs.Type == "dos" || fs.Type == "dosfs" || fs.Type == "pcfs" ) { return false; } return true; } } catch (...) { } } return true; // Prevent errors if the filesystem cannot be identified } bool CoreUnix::FilesystemSupportsUnixPermissions (const DevicePath &devicePath) const { File device; device.Open (devicePath); Buffer bootSector (device.GetDeviceSectorSize()); device.SeekAt (0); device.ReadCompleteBuffer (bootSector); - byte *b = bootSector.Ptr(); + uint8 *b = bootSector.Ptr(); return memcmp (b + 3, "NTFS", 4) != 0 && memcmp (b + 54, "FAT", 3) != 0 && memcmp (b + 82, "FAT32", 5) != 0 && memcmp (b + 3, "EXFAT", 5) != 0; } string CoreUnix::GetDefaultMountPointPrefix () const { const char *envPrefix = getenv ("VERACRYPT_MOUNT_PREFIX"); if (envPrefix && !string (envPrefix).empty()) return envPrefix; if (FilesystemPath ("/media").IsDirectory()) return "/media/veracrypt"; if (FilesystemPath ("/mnt").IsDirectory()) return "/mnt/veracrypt"; return GetTempDirectory() + "/veracrypt_mnt"; } uint32 CoreUnix::GetDeviceSectorSize (const DevicePath &devicePath) const { File dev; dev.Open (devicePath); return dev.GetDeviceSectorSize(); } uint64 CoreUnix::GetDeviceSize (const DevicePath &devicePath) const @@ -279,71 +276,99 @@ namespace VeraCrypt File dev; dev.Open (devicePath); return dev.Length(); } DirectoryPath CoreUnix::GetDeviceMountPoint (const DevicePath &devicePath) const { DevicePath devPath = devicePath; #ifdef TC_MACOSX if (string (devPath).find ("/dev/rdisk") != string::npos) devPath = string ("/dev/") + string (devicePath).substr (6); #endif MountedFilesystemList mountedFilesystems = GetMountedFilesystems (devPath); if (mountedFilesystems.size() < 1) return DirectoryPath(); return mountedFilesystems.front()->MountPoint; } VolumeInfoList CoreUnix::GetMountedVolumes (const VolumePath &volumePath) const { VolumeInfoList volumes; foreach_ref (const MountedFilesystem &mf, GetMountedFilesystems ()) { if (string (mf.MountPoint).find (GetFuseMountDirPrefix()) == string::npos) continue; shared_ptr <VolumeInfo> mountedVol; - try + // Introduce a retry mechanism with a timeout for control file access + // This workaround is limited to FUSE-T mounted volume under macOS for + // which md.Device starts with "fuse-t:" +#ifdef VC_MACOSX_FUSET + bool isFuseT = wstring(mf.Device).find(L"fuse-t:") == 0; + int controlFileRetries = 10; // 10 retries with 500ms sleep each, total 5 seconds + while (!mountedVol && (controlFileRetries-- > 0)) +#endif { - shared_ptr <File> controlFile (new File); - controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath()); + try + { + shared_ptr <File> controlFile (new File); + controlFile->Open (string (mf.MountPoint) + FuseService::GetControlPath()); - shared_ptr <Stream> controlFileStream (new FileStream (controlFile)); - mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream); + shared_ptr <Stream> controlFileStream (new FileStream (controlFile)); + mountedVol = Serializable::DeserializeNew <VolumeInfo> (controlFileStream); + } + catch (const std::exception& e) + { +#ifdef VC_MACOSX_FUSET + // if exception starts with "VeraCrypt::Serializer::ValidateName", then + // serialization is not ready yet and we need to wait before retrying + // this happens when FUSE-T is used under macOS and if it is the first time + // the volume is mounted + if (isFuseT && string (e.what()).find ("VeraCrypt::Serializer::ValidateName") != string::npos) + { + Thread::Sleep(500); // Wait before retrying + } + else + { + break; // Control file not found or other error + } +#endif + } } - catch (...) + + if (!mountedVol) { - continue; + continue; // Skip to the next mounted filesystem } if (!volumePath.IsEmpty() && wstring (mountedVol->Path).compare (volumePath) != 0) continue; mountedVol->AuxMountPoint = mf.MountPoint; if (!mountedVol->VirtualDevice.IsEmpty()) { MountedFilesystemList mpl = GetMountedFilesystems (mountedVol->VirtualDevice); if (mpl.size() > 0) mountedVol->MountPoint = mpl.front()->MountPoint; } volumes.push_back (mountedVol); if (!volumePath.IsEmpty()) break; } return volumes; } gid_t CoreUnix::GetRealGroupId () const { const char *env = getenv ("SUDO_GID"); if (env) { try @@ -667,61 +692,61 @@ namespace VeraCrypt } try { try { MountVolumeNative (volume, options, fuseMountPoint); } catch (NotApplicable&) { MountAuxVolumeImage (fuseMountPoint, options); } } catch (...) { if (mountDirCreated) remove (mountPoint.c_str()); throw; } #ifndef TC_MACOSX // set again correct ownership of the mount point to avoid any issues if (!options.NoFilesystem && options.MountPoint) { mountPoint = *options.MountPoint; if (mountPoint.find (GetDefaultMountPointPrefix()) == 0) { try { - ignore_result(chown (mountPoint.c_str(), GetRealUserId(), GetRealGroupId())); + throw_sys_sub_if (chown (mountPoint.c_str(), GetRealUserId(), GetRealGroupId()) == -1, mountPoint); } catch (...) { } } } #endif } catch (...) { try { VolumeInfoList mountedVolumes = GetMountedVolumes (*options.Path); if (mountedVolumes.size() > 0) { shared_ptr <VolumeInfo> mountedVolume (mountedVolumes.front()); DismountVolume (mountedVolume); } } catch (...) { } throw; } VolumeInfoList mountedVolumes = GetMountedVolumes (*options.Path); if (mountedVolumes.size() != 1) throw ParameterIncorrect (SRC_POS); VolumeEventArgs eventArgs (mountedVolumes.front()); VolumeMountedEvent.Raise (eventArgs); return mountedVolumes.front(); } diff --git a/src/Core/Unix/FreeBSD/CoreFreeBSD.cpp b/src/Core/Unix/FreeBSD/CoreFreeBSD.cpp index 01463c35..05520274 100644 --- a/src/Core/Unix/FreeBSD/CoreFreeBSD.cpp +++ b/src/Core/Unix/FreeBSD/CoreFreeBSD.cpp @@ -56,61 +56,61 @@ namespace VeraCrypt void CoreFreeBSD::DetachLoopDevice (const DevicePath &devicePath) const { list <string> args; args.push_back ("-d"); args.push_back ("-u"); args.push_back (StringConverter::GetTrailingNumber (devicePath)); for (int t = 0; true; t++) { try { Process::Execute ("mdconfig", args); break; } catch (ExecutedProcessFailed&) { if (t > 5) throw; Thread::Sleep (200); } } } HostDeviceList CoreFreeBSD::GetHostDevices (bool pathListOnly) const { HostDeviceList devices; #ifdef TC_MACOSX const string busType = "rdisk"; #else - foreach (const string &busType, StringConverter::Split ("ad da")) + foreach (const string &busType, StringConverter::Split ("ad da vtbd")) #endif { for (int devNumber = 0; devNumber < 64; devNumber++) { stringstream devPath; devPath << "/dev/" << busType << devNumber; if (FilesystemPath (devPath.str()).IsBlockDevice() || FilesystemPath (devPath.str()).IsCharacterDevice()) { make_shared_auto (HostDevice, device); device->Path = devPath.str(); if (!pathListOnly) { try { device->Size = GetDeviceSize (device->Path); } catch (...) { device->Size = 0; } device->MountPoint = GetDeviceMountPoint (device->Path); device->SystemNumber = 0; } devices.push_back (device); for (int partNumber = 1; partNumber < 32; partNumber++) { #ifdef TC_MACOSX const string partLetter = ""; @@ -158,49 +158,90 @@ namespace VeraCrypt struct statfs *sysMountList; int count = getmntinfo (&sysMountList, MNT_NOWAIT); throw_sys_if (count == 0); MountedFilesystemList mountedFilesystems; for (int i = 0; i < count; i++) { make_shared_auto (MountedFilesystem, mf); if (sysMountList[i].f_mntfromname[0]) mf->Device = DevicePath (sysMountList[i].f_mntfromname); else continue; if (sysMountList[i].f_mntonname[0]) mf->MountPoint = DirectoryPath (sysMountList[i].f_mntonname); mf->Type = sysMountList[i].f_fstypename; if ((devicePath.IsEmpty() || devicePath == mf->Device) && (mountPoint.IsEmpty() || mountPoint == mf->MountPoint)) mountedFilesystems.push_back (mf); } return mountedFilesystems; } void CoreFreeBSD::MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions) const { + std::string chosenFilesystem = "msdos"; + std::string modifiedMountOptions = systemMountOptions; + + if (filesystemType.empty() && modifiedMountOptions.find("mountprog") == string::npos) { + // No filesystem type specified through CLI, attempt to identify with blkid + // as mount is unable to probe filesystem type on BSD + // Make sure we don't override user defined mountprog + std::vector<char> buffer(128,0); + std::string cmd = "blkid -o value -s TYPE " + static_cast<std::string>(devicePath) + " 2>/dev/null"; + std::string result; + + FILE* pipe = popen(cmd.c_str(), "r"); + if (pipe) { + while (!feof(pipe)) { + if (fgets(buffer.data(), 128, pipe) != nullptr) + result += buffer.data(); + } + fflush(pipe); + pclose(pipe); + pipe = nullptr; + } + + if (result.find("ext") == 0 || StringConverter::ToLower(filesystemType).find("ext") == 0) { + chosenFilesystem = "ext2fs"; + } + else if (result.find("exfat") == 0 || StringConverter::ToLower(filesystemType) == "exfat") { + chosenFilesystem = "exfat"; + modifiedMountOptions += string(!systemMountOptions.empty() ? "," : "") + + "mountprog=/usr/local/sbin/mount.exfat"; + } + else if (result.find("ntfs") == 0 || StringConverter::ToLower(filesystemType) == "ntfs") { + chosenFilesystem = "ntfs"; + modifiedMountOptions += string(!systemMountOptions.empty() ? "," : "") + + "mountprog=/usr/local/bin/ntfs-3g"; + } + else if (!filesystemType.empty()) { + // Filesystem is specified but is none of the above, then supply as is + chosenFilesystem = filesystemType; + } + } else + chosenFilesystem = filesystemType; + try { - // Try to mount FAT by default as mount is unable to probe filesystem type on BSD - CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType.empty() ? "msdos" : filesystemType, readOnly, systemMountOptions); + CoreUnix::MountFilesystem (devicePath, mountPoint, chosenFilesystem, readOnly, modifiedMountOptions); } catch (ExecutedProcessFailed&) { if (!filesystemType.empty()) throw; CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, systemMountOptions); } } #ifdef TC_FREEBSD unique_ptr <CoreBase> Core (new CoreServiceProxy <CoreFreeBSD>); unique_ptr <CoreBase> CoreDirect (new CoreFreeBSD); #endif } diff --git a/src/Core/Unix/Linux/CoreLinux.cpp b/src/Core/Unix/Linux/CoreLinux.cpp index e1da6dff..cd4be80f 100644 --- a/src/Core/Unix/Linux/CoreLinux.cpp +++ b/src/Core/Unix/Linux/CoreLinux.cpp @@ -1,54 +1,57 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include <fstream> #include <iomanip> #include <mntent.h> #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/mount.h> #include <sys/wait.h> #include "CoreLinux.h" #include "Platform/SystemInfo.h" #include "Platform/TextReader.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "Driver/Fuse/FuseService.h" #include "Core/Unix/CoreServiceProxy.h" namespace VeraCrypt { CoreLinux::CoreLinux () { } CoreLinux::~CoreLinux () { } DevicePath CoreLinux::AttachFileToLoopDevice (const FilePath &filePath, bool readOnly) const { list <string> loopPaths; loopPaths.push_back ("/dev/loop"); loopPaths.push_back ("/dev/loop/"); loopPaths.push_back ("/dev/.static/dev/loop"); // On Fedora 23,"losetup -f" must be called first to create a default loop device list <string> args; args.push_back ("-f"); try { Process::Execute ("losetup", args); } catch (...) { } @@ -275,62 +278,67 @@ namespace VeraCrypt if ((devicePath.IsEmpty() || devicePath == mf->Device || realDevicePath == mf->Device) && (mountPoint.IsEmpty() || mountPoint == mf->MountPoint)) mountedFilesystems.push_back (mf); } return mountedFilesystems; } void CoreLinux::MountFilesystem (const DevicePath &devicePath, const DirectoryPath &mountPoint, const string &filesystemType, bool readOnly, const string &systemMountOptions) const { bool fsMounted = false; try { if (!FilesystemSupportsUnixPermissions (devicePath)) { stringstream userMountOptions; userMountOptions << "uid=" << GetRealUserId() << ",gid=" << GetRealGroupId() << ",umask=077" << (!systemMountOptions.empty() ? "," : ""); CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, userMountOptions.str() + systemMountOptions); fsMounted = true; } } catch (...) { } if (!fsMounted) CoreUnix::MountFilesystem (devicePath, mountPoint, filesystemType, readOnly, systemMountOptions); } void CoreLinux::MountVolumeNative (shared_ptr <Volume> volume, MountOptions &options, const DirectoryPath &auxMountPoint) const { - bool xts = (typeid (*volume->GetEncryptionMode()) == typeid (EncryptionModeXTS)); - bool algoNotSupported = (typeid (*volume->GetEncryptionAlgorithm()) == typeid (Kuznyechik)) + bool xts = (typeid (*volume->GetEncryptionMode()) == + #ifdef WOLFCRYPT_BACKEND + typeid (EncryptionModeWolfCryptXTS)); + #else + typeid (EncryptionModeXTS)); + #endif + bool algoNotSupported = (typeid (*volume->GetEncryptionAlgorithm()) == typeid (Kuznyechik)) || (typeid (*volume->GetEncryptionAlgorithm()) == typeid (CamelliaKuznyechik)) || (typeid (*volume->GetEncryptionAlgorithm()) == typeid (KuznyechikTwofish)) || (typeid (*volume->GetEncryptionAlgorithm()) == typeid (KuznyechikAES)) || (typeid (*volume->GetEncryptionAlgorithm()) == typeid (KuznyechikSerpentCamellia)); if (options.NoKernelCrypto || !xts || algoNotSupported || volume->IsEncryptionNotCompleted () || volume->GetProtectionType() == VolumeProtection::HiddenVolumeReadOnly) { throw NotApplicable (SRC_POS); } if (!SystemInfo::IsVersionAtLeast (2, 6, xts ? 24 : 20)) throw NotApplicable (SRC_POS); // Load device mapper kernel module list <string> execArgs; foreach (const string &dmModule, StringConverter::Split ("dm_mod dm-mod dm")) { execArgs.clear(); execArgs.push_back (dmModule); try { Process::Execute ("modprobe", execArgs); break; } catch (...) { } @@ -351,61 +359,61 @@ namespace VeraCrypt string nativeDevPath; try { // Create virtual device using device mapper size_t nativeDevCount = 0; size_t secondaryKeyOffset = volume->GetEncryptionMode()->GetKey().Size(); size_t cipherCount = volume->GetEncryptionAlgorithm()->GetCiphers().size(); foreach_reverse_ref (const Cipher &cipher, volume->GetEncryptionAlgorithm()->GetCiphers()) { stringstream dmCreateArgs; dmCreateArgs << "0 " << volume->GetSize() / ENCRYPTION_DATA_UNIT_SIZE << " crypt "; // Mode dmCreateArgs << StringConverter::ToLower (StringConverter::ToSingle (cipher.GetName())) << (xts ? (SystemInfo::IsVersionAtLeast (2, 6, 33) ? "-xts-plain64 " : "-xts-plain ") : "-lrw-benbi "); size_t keyArgOffset = dmCreateArgs.str().size(); dmCreateArgs << setw (cipher.GetKeySize() * (xts ? 4 : 2) + (xts ? 0 : 16 * 2)) << 0 << setw (0); // Sector and data unit offset uint64 startSector = volume->GetLayout()->GetDataOffset (volume->GetHostSize()) / ENCRYPTION_DATA_UNIT_SIZE; dmCreateArgs << ' ' << (xts ? startSector + volume->GetEncryptionMode()->GetSectorOffset() : 0) << ' '; if (nativeDevCount == 0) dmCreateArgs << string (volumePath) << ' ' << startSector; else dmCreateArgs << nativeDevPath << " 0"; SecureBuffer dmCreateArgsBuf (dmCreateArgs.str().size()); - dmCreateArgsBuf.CopyFrom (ConstBufferPtr ((byte *) dmCreateArgs.str().c_str(), dmCreateArgs.str().size())); + dmCreateArgsBuf.CopyFrom (ConstBufferPtr ((uint8 *) dmCreateArgs.str().c_str(), dmCreateArgs.str().size())); // Keys const SecureBuffer &cipherKey = cipher.GetKey(); secondaryKeyOffset -= cipherKey.Size(); ConstBufferPtr secondaryKey = volume->GetEncryptionMode()->GetKey().GetRange (xts ? secondaryKeyOffset : 0, xts ? cipherKey.Size() : 16); SecureBuffer hexStr (3); for (size_t i = 0; i < cipherKey.Size(); ++i) { sprintf ((char *) hexStr.Ptr(), "%02x", (int) cipherKey[i]); dmCreateArgsBuf.GetRange (keyArgOffset + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2)); sprintf ((char *) hexStr.Ptr(), "%02x", (int) secondaryKey[i]); dmCreateArgsBuf.GetRange (keyArgOffset + cipherKey.Size() * 2 + i * 2, 2).CopyFrom (hexStr.GetRange (0, 2)); } stringstream nativeDevName; nativeDevName << "veracrypt" << options.SlotNumber; if (nativeDevCount != cipherCount - 1) nativeDevName << "_" << cipherCount - nativeDevCount - 2; nativeDevPath = "/dev/mapper/" + nativeDevName.str(); execArgs.clear(); execArgs.push_back ("create"); execArgs.push_back (nativeDevName.str()); Process::Execute ("dmsetup", execArgs, -1, nullptr, &dmCreateArgsBuf); diff --git a/src/Core/Unix/MacOSX/CoreMacOSX.cpp b/src/Core/Unix/MacOSX/CoreMacOSX.cpp index b596e6e8..cfd34072 100644 --- a/src/Core/Unix/MacOSX/CoreMacOSX.cpp +++ b/src/Core/Unix/MacOSX/CoreMacOSX.cpp @@ -80,101 +80,108 @@ namespace VeraCrypt args.push_back ("--"); args.push_back (mountedVolume->AuxMountPoint); for (int t = 0; true; t++) { try { Process::Execute ("umount", args); break; } catch (ExecutedProcessFailed&) { if (t > 10) throw; Thread::Sleep (200); } } try { mountedVolume->AuxMountPoint.Delete(); } catch (...) { } return mountedVolume; } void CoreMacOSX::CheckFilesystem (shared_ptr <VolumeInfo> mountedVolume, bool repair) const { list <string> args; - args.push_back ("/Applications/Utilities/Disk Utility.app"); + struct stat sb; + + if (stat("/Applications/Utilities/Disk Utility.app", &sb) == 0) + args.push_back ("/Applications/Utilities/Disk Utility.app"); + else + args.push_back ("/System/Applications/Utilities/Disk Utility.app"); + Process::Execute ("open", args); } void CoreMacOSX::MountAuxVolumeImage (const DirectoryPath &auxMountPoint, const MountOptions &options) const { +#ifndef VC_MACOSX_FUSET // Check FUSE version char fuseVersionString[MAXHOSTNAMELEN + 1] = { 0 }; size_t fuseVersionStringLength = MAXHOSTNAMELEN; int status; if ((status = sysctlbyname ("osxfuse.version.number", fuseVersionString, &fuseVersionStringLength, NULL, 0)) != 0) { fuseVersionStringLength = MAXHOSTNAMELEN; if ((status = sysctlbyname ("vfs.generic.osxfuse.version.number", fuseVersionString, &fuseVersionStringLength, NULL, 0)) != 0) { fuseVersionStringLength = MAXHOSTNAMELEN; if ((status = sysctlbyname ("vfs.generic.macfuse.version.number", fuseVersionString, &fuseVersionStringLength, NULL, 0)) != 0) { throw HigherFuseVersionRequired (SRC_POS); } } } // look for OSXFuse dynamic library struct stat sb; if (0 != stat("/usr/local/lib/libosxfuse_i64.2.dylib", &sb) && 0 != stat("/usr/local/lib/libfuse.dylib", &sb)) { throw HigherFuseVersionRequired (SRC_POS); } vector <string> fuseVersion = StringConverter::Split (string (fuseVersionString), "."); if (fuseVersion.size() < 2) throw HigherFuseVersionRequired (SRC_POS); uint32 fuseVersionMajor = StringConverter::ToUInt32 (fuseVersion[0]); uint32 fuseVersionMinor = StringConverter::ToUInt32 (fuseVersion[1]); if (fuseVersionMajor < 2 || (fuseVersionMajor == 2 && fuseVersionMinor < 5)) throw HigherFuseVersionRequired (SRC_POS); - +#endif // Mount volume image string volImage = string (auxMountPoint) + FuseService::GetVolumeImagePath(); list <string> args; args.push_back ("attach"); args.push_back (volImage); args.push_back ("-plist"); args.push_back ("-noautofsck"); args.push_back ("-imagekey"); args.push_back ("diskimage-class=CRawDiskImage"); if (!options.NoFilesystem && options.MountPoint && !options.MountPoint->IsEmpty()) { args.push_back ("-mount"); args.push_back ("required"); // Let the system specify mount point except when the user specified a non-default one if (string (*options.MountPoint).find (GetDefaultMountPointPrefix()) != 0) { args.push_back ("-mountpoint"); args.push_back (*options.MountPoint); } } else args.push_back ("-nomount"); if (options.Protection == VolumeProtection::ReadOnly) args.push_back ("-readonly"); string xml; diff --git a/src/Core/VolumeCreator.cpp b/src/Core/VolumeCreator.cpp index 5f19a66d..fefbddde 100644 --- a/src/Core/VolumeCreator.cpp +++ b/src/Core/VolumeCreator.cpp @@ -1,44 +1,47 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Volume/EncryptionTest.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "Core.h" #ifdef TC_UNIX #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #endif #include "VolumeCreator.h" #include "FatFormatter.h" namespace VeraCrypt { VolumeCreator::VolumeCreator () : SizeDone (0) { } VolumeCreator::~VolumeCreator () { } void VolumeCreator::Abort () { AbortRequested = true; } void VolumeCreator::CheckResult () { if (ThreadException) @@ -333,62 +336,67 @@ namespace VeraCrypt shared_ptr <VolumeHeader> hiddenHeader (hiddenLayout.GetHeader()); SecureBuffer hiddenHeaderBuffer (hiddenLayout.GetHeaderSize()); headerOptions.Type = VolumeType::Hidden; headerOptions.VolumeDataStart = HostSize - hiddenLayout.GetHeaderSize() * 2 - options->Size; headerOptions.VolumeDataSize = hiddenLayout.GetMaxDataSize (options->Size); // Master data key SecureBuffer hiddenMasterKey(options->EA->GetKeySize() * 2); RandomNumberGenerator::GetData (hiddenMasterKey); headerOptions.DataKey = hiddenMasterKey; // PKCS5 salt SecureBuffer hiddenSalt (VolumeHeader::GetSaltSize()); RandomNumberGenerator::GetData (hiddenSalt); headerOptions.Salt = hiddenSalt; // Header key SecureBuffer hiddenHeaderKey (VolumeHeader::GetLargestSerializedKeySize()); RandomNumberGenerator::GetData (hiddenHeaderKey); headerOptions.HeaderKey = hiddenHeaderKey; hiddenHeader->Create (headerBuffer, headerOptions); VolumeFile->Write (headerBuffer); } // Data area keys options->EA->SetKey (MasterKey.GetRange (0, options->EA->GetKeySize())); - shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ()); - mode->SetKey (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize())); + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> mode (new EncryptionModeWolfCryptXTS ()); + options->EA->SetKeyXTS (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize())); + #else + shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ()); + #endif + mode->SetKey (MasterKey.GetRange (options->EA->GetKeySize(), options->EA->GetKeySize())); options->EA->SetMode (mode); Options = options; AbortRequested = false; mProgressInfo.CreationInProgress = true; struct ThreadFunctor : public Functor { ThreadFunctor (VolumeCreator *creator) : Creator (creator) { } virtual void operator() () { Creator->CreationThread (); } VolumeCreator *Creator; }; Thread thread; thread.Start (new ThreadFunctor (this)); } catch (...) { VolumeFile.reset(); throw; } } VolumeCreator::KeyInfo VolumeCreator::GetKeyInfo () const { KeyInfo info; diff --git a/src/Crypto/Aes.h b/src/Crypto/Aes.h index e12c6fc8..dcadfc2b 100644 --- a/src/Crypto/Aes.h +++ b/src/Crypto/Aes.h @@ -8,175 +8,195 @@ changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. --------------------------------------------------------------------------- Issue Date: 20/12/2007 This file contains the definitions required to use AES in C. See aesopt.h for optimisation details. */ /* Adapted for TrueCrypt */ #ifndef _AES_H #define _AES_H #include "Common/Tcdefs.h" +#ifdef WOLFCRYPT_BACKEND + #include <wolfssl/options.h> + #include <wolfssl/wolfcrypt/aes.h> +#endif + #ifndef EXIT_SUCCESS #define EXIT_SUCCESS 0 #define EXIT_FAILURE 1 #endif #define INT_RETURN int #if defined(__cplusplus) extern "C" { #endif // #define AES_128 /* define if AES with 128 bit keys is needed */ // #define AES_192 /* define if AES with 192 bit keys is needed */ #define AES_256 /* define if AES with 256 bit keys is needed */ // #define AES_VAR /* define if a variable key size is needed */ // #define AES_MODES /* define if support is needed for modes */ /* The following must also be set in assembler files if being used */ #define AES_ENCRYPT /* if support for encryption is needed */ #define AES_DECRYPT /* if support for decryption is needed */ #define AES_ERR_CHK /* for parameter checks & error return codes */ #define AES_REV_DKS /* define to reverse decryption key schedule */ #define AES_BLOCK_SIZE 16 /* the AES block size in bytes */ #define N_COLS 4 /* the number of columns in the state */ /* The key schedule length is 11, 13 or 15 16-byte blocks for 128, */ /* 192 or 256-bit keys respectively. That is 176, 208 or 240 bytes */ /* or 44, 52 or 60 32-bit words. */ #if defined( AES_VAR ) || defined( AES_256 ) #define KS_LENGTH 60 #elif defined( AES_192 ) #define KS_LENGTH 52 #else #define KS_LENGTH 44 #endif #if defined( AES_ERR_CHK ) #define AES_RETURN INT_RETURN #else #define AES_RETURN VOID_RETURN #endif /* the character array 'inf' in the following structures is used */ /* to hold AES context information. This AES code uses cx->inf.b[0] */ /* to hold the number of rounds multiplied by 16. The other three */ /* elements can be used by code that implements additional modes */ typedef union { uint_32t l; uint_8t b[4]; } aes_inf; typedef struct { uint_32t ks[KS_LENGTH]; aes_inf inf; +#ifdef WOLFCRYPT_BACKEND + XtsAes wc_enc_xts; + Aes wc_enc_aes; +#endif } aes_encrypt_ctx; typedef struct { uint_32t ks[KS_LENGTH]; aes_inf inf; +#ifdef WOLFCRYPT_BACKEND + XtsAes wc_dec_xts; + Aes wc_dec_aes; +#endif } aes_decrypt_ctx; /* This routine must be called before first use if non-static */ /* tables are being used */ AES_RETURN aes_init(void); /* Key lengths in the range 16 <= key_len <= 32 are given in bytes, */ /* those in the range 128 <= key_len <= 256 are given in bits */ #if defined( AES_ENCRYPT ) #if defined(AES_128) || defined(AES_VAR) AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined(AES_192) || defined(AES_VAR) AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined(AES_256) || defined(AES_VAR) AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); #endif #if defined(AES_VAR) AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]); #endif -AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); +AES_RETURN VC_CDECL aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]); #endif #if defined( AES_DECRYPT ) #if defined(AES_128) || defined(AES_VAR) AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined(AES_192) || defined(AES_VAR) AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined(AES_256) || defined(AES_VAR) AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); #endif #if defined(AES_VAR) AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]); #endif -AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); +AES_RETURN VC_CDECL aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]); + +#endif +#ifdef WOLFCRYPT_BACKEND +AES_RETURN xts_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]); +AES_RETURN xts_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]); +AES_RETURN xts_encrypt(const unsigned char *in, unsigned char *out, word64 length, word64 sector, const aes_encrypt_ctx cx[1]); +AES_RETURN xts_decrypt(const unsigned char *in, unsigned char *out, word64 length, word64 sector, const aes_decrypt_ctx cx[1]); #endif #if defined(AES_MODES) /* Multiple calls to the following subroutines for multiple block */ /* ECB, CBC, CFB, OFB and CTR mode encryption can be used to handle */ /* long messages incremantally provided that the context AND the iv */ /* are preserved between all such calls. For the ECB and CBC modes */ /* each individual call within a series of incremental calls must */ /* process only full blocks (i.e. len must be a multiple of 16) but */ /* the CFB, OFB and CTR mode calls can handle multiple incremental */ /* calls of any length. Each mode is reset when a new AES key is */ /* set but ECB and CBC operations can be reset without setting a */ /* new key by setting a new IV value. To reset CFB, OFB and CTR */ /* without setting the key, aes_mode_reset() must be called and the */ /* IV must be set. NOTE: All these calls update the IV on exit so */ /* this has to be reset if a new operation with the same IV as the */ /* previous one is required (or decryption follows encryption with */ /* the same IV array). */ AES_RETURN aes_test_alignment_detection(unsigned int n); AES_RETURN aes_ecb_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_encrypt_ctx cx[1]); AES_RETURN aes_ecb_decrypt(const unsigned char *ibuf, unsigned char *obuf, int len, const aes_decrypt_ctx cx[1]); AES_RETURN aes_cbc_encrypt(const unsigned char *ibuf, unsigned char *obuf, int len, unsigned char *iv, const aes_encrypt_ctx cx[1]); diff --git a/src/Crypto/Aes_hw_cpu.h b/src/Crypto/Aes_hw_cpu.h index b294e2ee..face0a0c 100644 --- a/src/Crypto/Aes_hw_cpu.h +++ b/src/Crypto/Aes_hw_cpu.h @@ -1,36 +1,36 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Crypto_Aes_Hw_Cpu #define TC_HEADER_Crypto_Aes_Hw_Cpu #include "Common/Tcdefs.h" #if defined(__cplusplus) extern "C" { #endif #if defined (TC_WINDOWS_BOOT) -byte is_aes_hw_cpu_supported (); +uint8 is_aes_hw_cpu_supported (); #endif void aes_hw_cpu_enable_sse (); -void aes_hw_cpu_decrypt (const byte *ks, byte *data); -void aes_hw_cpu_decrypt_32_blocks (const byte *ks, byte *data); -void aes_hw_cpu_encrypt (const byte *ks, byte *data); -void aes_hw_cpu_encrypt_32_blocks (const byte *ks, byte *data); +void aes_hw_cpu_decrypt (const uint8 *ks, uint8 *data); +void VC_CDECL aes_hw_cpu_decrypt_32_blocks (const uint8 *ks, uint8 *data); +void aes_hw_cpu_encrypt (const uint8 *ks, uint8 *data); +void VC_CDECL aes_hw_cpu_encrypt_32_blocks (const uint8 *ks, uint8 *data); #if defined(__cplusplus) } #endif #endif // TC_HEADER_Crypto_Aes_Hw_Cpu diff --git a/src/Crypto/Aescrypt.c b/src/Crypto/Aescrypt.c index 46175981..7348e2cf 100644 --- a/src/Crypto/Aescrypt.c +++ b/src/Crypto/Aescrypt.c @@ -67,61 +67,61 @@ extern "C" used for dynamically variable block sizes is designed to expand to a compile time constant whenever possible but will expand to conditional clauses on some branches (I am grateful to Frank Yellin for this construction) */ #define fwd_var(x,r,c)\ ( r == 0 ? ( c == 0 ? s(x,0) : c == 1 ? s(x,1) : c == 2 ? s(x,2) : s(x,3))\ : r == 1 ? ( c == 0 ? s(x,1) : c == 1 ? s(x,2) : c == 2 ? s(x,3) : s(x,0))\ : r == 2 ? ( c == 0 ? s(x,2) : c == 1 ? s(x,3) : c == 2 ? s(x,0) : s(x,1))\ : ( c == 0 ? s(x,3) : c == 1 ? s(x,0) : c == 2 ? s(x,1) : s(x,2))) #if defined(FT4_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,n),fwd_var,rf1,c)) #elif defined(FT1_SET) #undef dec_fmvars #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(f,n),fwd_var,rf1,c)) #else #define fwd_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ fwd_mcol(no_table(x,t_use(s,box),fwd_var,rf1,c))) #endif #if defined(FL4_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(f,l),fwd_var,rf1,c)) #elif defined(FL1_SET) #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(f,l),fwd_var,rf1,c)) #else #define fwd_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(s,box),fwd_var,rf1,c)) #endif -AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) +AES_RETURN VC_CDECL aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) { uint_32t locals(b0, b1); const uint_32t *kp; #if defined( dec_fmvars ) dec_fmvars; /* declare variables for fwd_mcol() if needed */ #endif #if defined( AES_ERR_CHK ) if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 ) return EXIT_FAILURE; #endif kp = cx->ks; state_in(b0, in, kp); #if (ENC_UNROLL == FULL) switch(cx->inf.b[0]) { case 14 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 12 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); kp += 2 * N_COLS; case 10 * 16: round(fwd_rnd, b1, b0, kp + 1 * N_COLS); round(fwd_rnd, b0, b1, kp + 2 * N_COLS); round(fwd_rnd, b1, b0, kp + 3 * N_COLS); @@ -204,61 +204,61 @@ AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_en #elif defined(IT1_SET) #undef dec_imvars #define inv_rnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,upr,t_use(i,n),inv_var,rf1,c)) #else #define inv_rnd(y,x,k,c) (s(y,c) = inv_mcol((k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c))) #endif #if defined(IL4_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ four_tables(x,t_use(i,l),inv_var,rf1,c)) #elif defined(IL1_SET) #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ one_table(x,ups,t_use(i,l),inv_var,rf1,c)) #else #define inv_lrnd(y,x,k,c) (s(y,c) = (k)[c] ^ no_table(x,t_use(i,box),inv_var,rf1,c)) #endif /* This code can work with the decryption key schedule in the */ /* order that is used for encrytpion (where the 1st decryption */ /* round key is at the high end ot the schedule) or with a key */ /* schedule that has been reversed to put the 1st decryption */ /* round key at the low end of the schedule in memory (when */ /* AES_REV_DKS is defined) */ #ifdef AES_REV_DKS #define key_ofs 0 #define rnd_key(n) (kp + n * N_COLS) #else #define key_ofs 1 #define rnd_key(n) (kp - n * N_COLS) #endif -AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) +AES_RETURN VC_CDECL aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) { uint_32t locals(b0, b1); #if defined( dec_imvars ) dec_imvars; /* declare variables for inv_mcol() if needed */ #endif const uint_32t *kp; #if defined( AES_ERR_CHK ) if( cx->inf.b[0] != 10 * 16 && cx->inf.b[0] != 12 * 16 && cx->inf.b[0] != 14 * 16 ) return EXIT_FAILURE; #endif kp = cx->ks + (key_ofs ? (cx->inf.b[0] >> 2) : 0); state_in(b0, in, kp); #if (DEC_UNROLL == FULL) kp = cx->ks + (key_ofs ? 0 : (cx->inf.b[0] >> 2)); switch(cx->inf.b[0]) { case 14 * 16: round(inv_rnd, b1, b0, rnd_key(-13)); round(inv_rnd, b0, b1, rnd_key(-12)); case 12 * 16: round(inv_rnd, b1, b0, rnd_key(-11)); round(inv_rnd, b0, b1, rnd_key(-10)); case 10 * 16: round(inv_rnd, b1, b0, rnd_key(-9)); round(inv_rnd, b0, b1, rnd_key(-8)); round(inv_rnd, b1, b0, rnd_key(-7)); round(inv_rnd, b0, b1, rnd_key(-6)); diff --git a/src/Crypto/Camellia.c b/src/Crypto/Camellia.c index f4fde8aa..675fc0bd 100644 --- a/src/Crypto/Camellia.c +++ b/src/Crypto/Camellia.c @@ -1,89 +1,89 @@ #include "Camellia.h" #include "Common/Endian.h" #include "Crypto/cpu.h" #include "Crypto/misc.h" #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) /* camellia.c ver 1.2.0-x86_64_asm1.1 * * Copyright (c) 2006,2007 * NTT (Nippon Telegraph and Telephone Corporation) . All rights reserved. * * SuperCop integration: - * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> + * Copyright © 2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> * * VeraCrypt integration: - * Copyright © 2017 Mounir IDRASSI <mounir.idrassi@idrix.fr> + * Copyright © 2017 Mounir IDRASSI <mounir.idrassi@idrix.fr> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer as * the first lines of this file unmodified. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY NTT ``AS IS'' AND ANY EXPRESS OR * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL NTT BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /* * Algorithm Specification * http://info.isl.ntt.co.jp/crypt/eng/camellia/specifications.html */ /* Adapted for VeraCrypt */ #include "Common/Crypto.h" #ifndef _WIN32 extern int IsAesHwCpuSupported (); #endif -void camellia_encrypt_asm(const byte *ctx, void *dst, const void *src); -void camellia_decrypt_asm(const byte *ctx, void *dst, const void *src); -void camellia_enc_blk2(const byte *ctx, byte *dst, const byte *src); -void camellia_dec_blk2(const byte *ctx, byte *dst, const byte *src); -void camellia_ecb_enc_16way(const byte *ctx, byte *dst, const byte *src); -void camellia_ecb_dec_16way(const byte *ctx, byte *dst, const byte *src); +void camellia_encrypt_asm(const uint8 *ctx, void *dst, const void *src); +void camellia_decrypt_asm(const uint8 *ctx, void *dst, const void *src); +void camellia_enc_blk2(const uint8 *ctx, uint8 *dst, const uint8 *src); +void camellia_dec_blk2(const uint8 *ctx, uint8 *dst, const uint8 *src); +void camellia_ecb_enc_16way(const uint8 *ctx, uint8 *dst, const uint8 *src); +void camellia_ecb_dec_16way(const uint8 *ctx, uint8 *dst, const uint8 *src); /* key constants */ #define CAMELLIA_SIGMA1L (0xA09E667FL) #define CAMELLIA_SIGMA1R (0x3BCC908BL) #define CAMELLIA_SIGMA2L (0xB67AE858L) #define CAMELLIA_SIGMA2R (0x4CAA73B2L) #define CAMELLIA_SIGMA3L (0xC6EF372FL) #define CAMELLIA_SIGMA3R (0xE94F82BEL) #define CAMELLIA_SIGMA4L (0x54FF53A5L) #define CAMELLIA_SIGMA4R (0xF1D36F1CL) #define CAMELLIA_SIGMA5L (0x10E527FAL) #define CAMELLIA_SIGMA5R (0xDE682D1DL) #define CAMELLIA_SIGMA6L (0xB05688C2L) #define CAMELLIA_SIGMA6R (0xB3E6C1FDL) /* * macros */ # define GETU32(p) bswap_32(*((uint32 *)(p))) # define PUTU32(ct, st) {*((uint32 *)(ct)) = bswap_32((st));} #define CamelliaSubkeyL(INDEX) (subkey[(INDEX)*2]) #define CamelliaSubkeyR(INDEX) (subkey[(INDEX)*2 + 1]) /* rotation right shift 1byte */ #define CAMELLIA_RR8(x) (((x) >> 8) + ((x) << 24)) /* rotation left shift 1bit */ @@ -1066,97 +1066,97 @@ void camellia_set_key(const unsigned __int8 key[], unsigned __int8 *ks) CamelliaSubkeyR(25) = subr(25); tl = subl(23) ^ (subr(23) & ~subr(25)); dw = tl & subl(25), tr = subr(23) ^ CAMELLIA_RL1(dw); CamelliaSubkeyL(26) = tl ^ subl(27); CamelliaSubkeyR(26) = tr ^ subr(27); CamelliaSubkeyL(27) = subl(26) ^ subl(28); CamelliaSubkeyR(27) = subr(26) ^ subr(28); CamelliaSubkeyL(28) = subl(27) ^ subl(29); CamelliaSubkeyR(28) = subr(27) ^ subr(29); CamelliaSubkeyL(29) = subl(28) ^ subl(30); CamelliaSubkeyR(29) = subr(28) ^ subr(30); CamelliaSubkeyL(30) = subl(29) ^ subl(31); CamelliaSubkeyR(30) = subr(29) ^ subr(31); CamelliaSubkeyL(31) = subl(30); CamelliaSubkeyR(31) = subr(30); CamelliaSubkeyL(32) = subl(32) ^ subl(31); CamelliaSubkeyR(32) = subr(32) ^ subr(31); return; } void camellia_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks) { camellia_encrypt_asm (ks, outBlock, inBlock); } void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks) { camellia_decrypt_asm (ks, outBlock, inBlock); } -void camellia_encrypt_blocks(unsigned __int8 *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) +void camellia_encrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount) { #if !defined (_UEFI) if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */ { #if defined (TC_WINDOWS_DRIVER) XSTATE_SAVE SaveState; if (NT_SUCCESS (KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState))) { #endif while (blockCount >= 16) { camellia_ecb_enc_16way (instance, out_blk, in_blk); out_blk += 16 * 16; in_blk += 16 * 16; blockCount -= 16; } #if defined (TC_WINDOWS_DRIVER) KeRestoreExtendedProcessorStateVC(&SaveState); } #endif } #endif while (blockCount >= 2) { camellia_enc_blk2 (instance, out_blk, in_blk); out_blk += 2 * 16; in_blk += 2 * 16; blockCount -= 2; } if (blockCount) camellia_encrypt (in_blk, out_blk, instance); } -void camellia_decrypt_blocks(unsigned __int8 *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) +void camellia_decrypt_blocks(unsigned __int8 *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount) { #if !defined (_UEFI) if ((blockCount >= 16) && IsCpuIntel() && IsAesHwCpuSupported () && HasSAVX()) /* on AMD cpu, AVX is too slow */ { #if defined (TC_WINDOWS_DRIVER) XSTATE_SAVE SaveState; if (NT_SUCCESS (KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState))) { #endif while (blockCount >= 16) { camellia_ecb_dec_16way (instance, out_blk, in_blk); out_blk += 16 * 16; in_blk += 16 * 16; blockCount -= 16; } #if defined (TC_WINDOWS_DRIVER) KeRestoreExtendedProcessorStateVC(&SaveState); } #endif } #endif while (blockCount >= 2) { camellia_dec_blk2 (instance, out_blk, in_blk); out_blk += 2 * 16; in_blk += 2 * 16; blockCount -= 2; } diff --git a/src/Crypto/Camellia.h b/src/Crypto/Camellia.h index a1cb832e..63c97476 100644 --- a/src/Crypto/Camellia.h +++ b/src/Crypto/Camellia.h @@ -1,29 +1,29 @@ #ifndef HEADER_Crypto_Camellia #define HEADER_Crypto_Camellia #include "Common/Tcdefs.h" #include "config.h" #ifdef __cplusplus extern "C" { #endif #define CAMELLIA_KS 34 * 8 /* userKey is always 32-bytes long */ /* size of ks is 34*8 bytes */ void camellia_set_key(const unsigned __int8 userKey[], unsigned __int8 *ks); void camellia_encrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks); void camellia_decrypt(const unsigned __int8 *inBlock, unsigned __int8 *outBlock, unsigned __int8 *ks); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) -void camellia_encrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); -void camellia_decrypt_blocks(unsigned __int8 *ks, const byte* in_blk, byte* out_blk, uint32 blockCount); +void camellia_encrypt_blocks(unsigned __int8 *ks, const uint8* in_blk, uint8* out_blk, uint32 blockCount); +void camellia_decrypt_blocks(unsigned __int8 *ks, const uint8* in_blk, uint8* out_blk, uint32 blockCount); #endif #ifdef __cplusplus } #endif #endif // HEADER_Crypto_Camellia diff --git a/src/Crypto/Crypto_vs2019.vcxproj b/src/Crypto/Crypto_vs2019.vcxproj index ccd512b9..ab3d5f3b 100644 --- a/src/Crypto/Crypto_vs2019.vcxproj +++ b/src/Crypto/Crypto_vs2019.vcxproj @@ -11,128 +11,131 @@ </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}</ProjectGuid> <RootNamespace>Crypto</RootNamespace> <Keyword>Win32Proj</Keyword> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <ProjectName>Crypto</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</IntDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(ConfigurationName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(ConfigurationName)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;DEBUG;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>Default</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>false</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4100;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Lib> <OutputFile>$(OutDir)Crypto.lib</OutputFile> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;DEBUG;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>Default</BasicRuntimeChecks> @@ -155,104 +158,107 @@ <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;DEBUG;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>Default</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>false</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4100;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Lib> <OutputFile>$(OutDir)Crypto.lib</OutputFile> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4100;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Lib> <OutputFile>$(OutDir)Crypto.lib</OutputFile> <AdditionalLibraryDirectories>$(TargetDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> </Midl> <ClCompile> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4100;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Lib> <OutputFile>$(OutDir)Crypto.lib</OutputFile> <AdditionalLibraryDirectories>$(TargetDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <Midl /> <ClCompile> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>$(ProjectDir)\..;$(ProjectDir)\..\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4100;4127;4201;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Lib> <OutputFile>$(OutDir)Crypto.lib</OutputFile> <AdditionalLibraryDirectories>$(TargetDir);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> </Lib> </ItemDefinitionGroup> <ItemGroup> <CustomBuild Include="Aes_hw_cpu.asm"> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox --prefix _ -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)" </Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)" </Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> </CustomBuild> <CustomBuild Include="Aes_x64.asm"> diff --git a/src/Crypto/Sha2.c b/src/Crypto/Sha2.c index 31cba7f5..3cce21d7 100644 --- a/src/Crypto/Sha2.c +++ b/src/Crypto/Sha2.c @@ -1,60 +1,60 @@ /* This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) and released into public domain. */ /* Modified for VeraCrypt with speed optimization for C implementation */ #include "Sha2.h" #include "Common/Endian.h" #include "Crypto/cpu.h" #include "Crypto/misc.h" #if defined(_UEFI) || defined(CRYPTOPP_DISABLE_ASM) #define NO_OPTIMIZED_VERSIONS #endif #ifndef NO_OPTIMIZED_VERSIONS #if defined(__cplusplus) extern "C" { #endif #if CRYPTOPP_BOOL_X64 void sha512_rorx(const void* M, void* D, uint_64t l); void sha512_sse4(const void* M, uint_64t D[8], uint_64t l); void sha512_avx(const void* M, void* D, uint_64t l); #endif #if CRYPTOPP_BOOL_X64 || ((CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32) && !defined (TC_MACOSX)) - void sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]); + void VC_CDECL sha512_compress_nayuki(uint_64t state[8], const uint_8t block[128]); #endif #if defined(__cplusplus) } #endif #endif typedef void (*transformFn)(sha512_ctx* ctx, void* m, uint_64t num_blks); transformFn transfunc = NULL; static const uint_64t K[80] = { LL(0x428a2f98d728ae22), LL(0x7137449123ef65cd), LL(0xb5c0fbcfec4d3b2f), LL(0xe9b5dba58189dbbc), LL(0x3956c25bf348b538), LL(0x59f111f1b605d019), LL(0x923f82a4af194f9b), LL(0xab1c5ed5da6d8118), LL(0xd807aa98a3030242), LL(0x12835b0145706fbe), LL(0x243185be4ee4b28c), LL(0x550c7dc3d5ffb4e2), LL(0x72be5d74f27b896f), LL(0x80deb1fe3b1696b1), LL(0x9bdc06a725c71235), LL(0xc19bf174cf692694), LL(0xe49b69c19ef14ad2), LL(0xefbe4786384f25e3), LL(0x0fc19dc68b8cd5b5), LL(0x240ca1cc77ac9c65), LL(0x2de92c6f592b0275), LL(0x4a7484aa6ea6e483), LL(0x5cb0a9dcbd41fbd4), LL(0x76f988da831153b5), LL(0x983e5152ee66dfab), LL(0xa831c66d2db43210), LL(0xb00327c898fb213f), LL(0xbf597fc7beef0ee4), LL(0xc6e00bf33da88fc2), LL(0xd5a79147930aa725), LL(0x06ca6351e003826f), LL(0x142929670a0e6e70), LL(0x27b70a8546d22ffc), LL(0x2e1b21385c26c926), LL(0x4d2c6dfc5ac42aed), LL(0x53380d139d95b3df), LL(0x650a73548baf63de), LL(0x766a0abb3c77b2a8), LL(0x81c2c92e47edaee6), LL(0x92722c851482353b), LL(0xa2bfe8a14cf10364), LL(0xa81a664bbc423001), LL(0xc24b8b70d0f89791), LL(0xc76c51a30654be30), LL(0xd192e819d6ef5218), LL(0xd69906245565a910), LL(0xf40e35855771202a), LL(0x106aa07032bbd1b8), LL(0x19a4c116b8d2d0c8), LL(0x1e376c085141ab53), LL(0x2748774cdf8eeb99), LL(0x34b0bcb5e19b48a8), LL(0x391c0cb3c5c95a63), LL(0x4ed8aa4ae3418acb), LL(0x5b9cca4f7763e373), LL(0x682e6ff3d6b2b8a3), LL(0x748f82ee5defb2fc), LL(0x78a5636f43172f60), LL(0x84c87814a1f0ab72), LL(0x8cc702081a6439ec), LL(0x90befffa23631e28), LL(0xa4506cebde82bde9), LL(0xbef9a3f7b2c67915), LL(0xc67178f2e372532b), LL(0xca273eceea26619c), LL(0xd186b8c721c0c207), LL(0xeada7dd6cde0eb1e), LL(0xf57d4f7fee6ed178), LL(0x06f067aa72176fba), LL(0x0a637dc5a2c898a6), LL(0x113f9804bef90dae), LL(0x1b710b35131c471b), @@ -282,61 +282,61 @@ void sha512_hash(const unsigned char * data, uint_64t len, sha512_ctx *ctx) total += len * 8; ctx->count[0] = pos; ctx->count[1] = total; } void sha512(unsigned char * result, const unsigned char* source, uint_64t sourceLen) { sha512_ctx ctx; sha512_begin(&ctx); sha512_hash(source, sourceLen, &ctx); sha512_end(result, &ctx); } ///////////////////////////// #ifndef NO_OPTIMIZED_VERSIONS #if defined(__cplusplus) extern "C" { #endif #if CRYPTOPP_BOOL_X64 void sha256_sse4(void *input_data, uint_32t digest[8], uint_64t num_blks); void sha256_rorx(void *input_data, uint_32t digest[8], uint_64t num_blks); void sha256_avx(void *input_data, uint_32t digest[8], uint_64t num_blks); #endif #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 - void sha256_compress_nayuki(uint_32t state[8], const uint_8t block[64]); + void VC_CDECL sha256_compress_nayuki(uint_32t state[8], const uint_8t block[64]); #endif #if defined(__cplusplus) } #endif #endif CRYPTOPP_ALIGN_DATA(16) static const uint_32t SHA256_K[64] CRYPTOPP_SECTION_ALIGN16 = { 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 }; #if (defined(CRYPTOPP_X86_ASM_AVAILABLE) || defined(CRYPTOPP_X32_ASM_AVAILABLE)) #ifdef _MSC_VER # pragma warning(disable: 4100 4731) #endif static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(uint_32t *state, const uint_32t *data, size_t len) { #define LOCALS_SIZE 8*4 + 16*4 + 4*WORD_SZ #define H(i) [BASE+ASM_MOD(1024+7-(i),8)*4] #define G(i) H(i+1) @@ -420,61 +420,61 @@ static void CRYPTOPP_FASTCALL X86_SHA256_HashBlocks(uint_32t *state, const uint_ AS2( and eax, ecx )\ AS2( xor eax, B(i) )/* Maj(A,B,C) = B^((A^B)&(B^C) */\ AS2( mov AS_REG_7d, ebx )\ AS2( ror ebx, 2 )\ AS2( add eax, edx )/* T1 + Maj(A,B,C) */\ AS2( add edx, D(i) )\ AS2( mov D(i), edx )\ AS2( ror AS_REG_7d, 22 )\ AS2( xor AS_REG_7d, ebx )\ AS2( ror ebx, 11 )\ AS2( xor AS_REG_7d, ebx )\ AS2( add eax, AS_REG_7d )/* T1 + S0(A) + Maj(A,B,C) */\ AS2( mov H(i), eax )\ // Unroll the use of CRYPTOPP_BOOL_X64 in assembler math. The GAS assembler on X32 (version 2.25) // complains "Error: invalid operands (*ABS* and *UND* sections) for `*` and `-`" #if CRYPTOPP_BOOL_X64 #define SWAP_COPY(i) \ AS2( mov WORD_REG(bx), [WORD_REG(dx)+i*WORD_SZ])\ AS1( bswap WORD_REG(bx))\ AS2( mov [Wt(i*2+1)], WORD_REG(bx)) #else // X86 and X32 #define SWAP_COPY(i) \ AS2( mov WORD_REG(bx), [WORD_REG(dx)+i*WORD_SZ])\ AS1( bswap WORD_REG(bx))\ AS2( mov [Wt(i)], WORD_REG(bx)) #endif #if defined(__GNUC__) #if CRYPTOPP_BOOL_X64 - CRYPTOPP_ALIGN_DATA(16) byte workspace[LOCALS_SIZE] ; + CRYPTOPP_ALIGN_DATA(16) uint8 workspace[LOCALS_SIZE] ; #endif __asm__ __volatile__ ( #if CRYPTOPP_BOOL_X64 "lea %4, %%r8;" #endif INTEL_NOPREFIX #endif #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 #ifndef __GNUC__ AS2( mov edi, [len]) AS2( lea WORD_REG(si), [SHA256_K+48*4]) #endif #if !defined(_MSC_VER) || (_MSC_VER < 1400) AS_PUSH_IF86(bx) #endif AS_PUSH_IF86(bp) AS2( mov ebx, esp) AS2( and esp, -16) AS2( sub WORD_REG(sp), LOCALS_SIZE) AS_PUSH_IF86(bx) #endif AS2( mov STATE_SAVE, WORD_REG(cx)) AS2( mov DATA_SAVE, WORD_REG(dx)) AS2( lea WORD_REG(ax), [WORD_REG(di) + WORD_REG(dx)]) AS2( mov DATA_END, WORD_REG(ax)) AS2( mov K_END, WORD_REG(si)) diff --git a/src/Crypto/Sha2.h b/src/Crypto/Sha2.h index 7e90abff..1fbcb8d1 100644 --- a/src/Crypto/Sha2.h +++ b/src/Crypto/Sha2.h @@ -1,60 +1,72 @@ /* * Copyright (c) 2013-2017 IDRIX * 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. */ #ifndef _SHA2_H #define _SHA2_H #include "Common/Tcdefs.h" #include "Common/Endian.h" #include "Crypto/config.h" +#ifdef WOLFCRYPT_BACKEND + #include <wolfssl/options.h> + #include <wolfssl/wolfcrypt/sha256.h> + #include <wolfssl/wolfcrypt/sha512.h> + #include <wolfssl/wolfcrypt/hash.h> +#endif + #if defined(__cplusplus) extern "C" { #endif #define SHA256_DIGEST_SIZE 32 #define SHA256_BLOCK_SIZE 64 #define SHA512_DIGEST_SIZE 64 #define SHA512_BLOCK_SIZE 128 #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) #define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(32) #else #define SHA2_ALIGN CRYPTOPP_ALIGN_DATA(16) #endif +#ifdef WOLFCRYPT_BACKEND +typedef struct wc_Sha512 sha512_ctx; +typedef struct wc_Sha256 sha256_ctx; +#else typedef struct { uint_64t count[2]; SHA2_ALIGN uint_64t hash[8]; SHA2_ALIGN uint_64t wbuf[16]; } sha512_ctx; typedef struct { uint_32t count[2]; SHA2_ALIGN uint_32t hash[8]; SHA2_ALIGN uint_32t wbuf[16]; } sha256_ctx; +#endif void sha512_begin(sha512_ctx* ctx); void sha512_hash(const unsigned char * source, uint_64t sourceLen, sha512_ctx *ctx); void sha512_end(unsigned char * result, sha512_ctx* ctx); void sha512(unsigned char * result, const unsigned char* source, uint_64t sourceLen); void sha256_begin(sha256_ctx* ctx); void sha256_hash(const unsigned char * source, uint_32t sourceLen, sha256_ctx *ctx); void sha256_end(unsigned char * result, sha256_ctx* ctx); void sha256(unsigned char * result, const unsigned char* source, uint_32t sourceLen); #if defined(__cplusplus) } #endif #endif diff --git a/src/Crypto/Sha2Small.c b/src/Crypto/Sha2Small.c index 08318833..572dd612 100644 --- a/src/Crypto/Sha2Small.c +++ b/src/Crypto/Sha2Small.c @@ -1,53 +1,53 @@ /* LibTomCrypt, modular cryptographic library -- Tom St Denis * * LibTomCrypt is a library that provides various cryptographic * algorithms in a highly modular and flexible manner. * * The library is free for all purposes without any express * guarantee it works. * * Tom St Denis, tomstdenis@gmail.com, http://libtom.org * */ /* Adapted for VeraCrypt */ #include <memory.h> #include "Common/Tcdefs.h" #include "Common/Endian.h" #include "Sha2Small.h" #pragma optimize ("tl", on) typedef unsigned __int32 uint32; -typedef unsigned __int8 byte; +typedef unsigned __int8 uint8; #include <stdlib.h> #pragma intrinsic(_lrotr) #define RORc(x,n) _lrotr(x,n) /******************************************************************************/ /* The K array */ static const uint32 K[64] = { 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL }; /* Various logical functions */ diff --git a/src/Crypto/Streebog.c b/src/Crypto/Streebog.c index 84991021..d223eef8 100644 --- a/src/Crypto/Streebog.c +++ b/src/Crypto/Streebog.c @@ -2226,74 +2226,74 @@ stage2(STREEBOG_CTX *CTX, const unsigned char *data) static void stage3(STREEBOG_CTX *CTX) { STREEBOG_ALIGN(16) unsigned long long buf[8]; memset(buf, 0x00, sizeof buf); memcpy(buf, (CTX->buffer), CTX->bufsize); memcpy((CTX->buffer), buf, 8 * sizeof (unsigned long long)); memset(buf, 0x00, sizeof buf); #ifndef __GOST3411_BIG_ENDIAN__ buf[0] = ((unsigned long long) CTX->bufsize) << 3; #else buf[0] = BSWAP64(((unsigned long long) CTX->bufsize) << 3); #endif pad(CTX); g((CTX->h), (CTX->N), (const unsigned char *) (CTX->buffer)); add512((CTX->N), buf, (CTX->N)); add512((CTX->Sigma), (const unsigned long long *) CTX->buffer, (CTX->Sigma)); g((CTX->h), buffer0, (const unsigned char *) (CTX->N)); g((CTX->h), buffer0, (const unsigned char *) (CTX->Sigma)); memcpy((CTX->hash), (CTX->h), 8 * sizeof(unsigned long long)); } -void STREEBOG_add(STREEBOG_CTX *CTX, const byte *data, size_t len) +void STREEBOG_add(STREEBOG_CTX *CTX, const uint8 *data, size_t len) { size_t chunksize; while (len > 63 && CTX->bufsize == 0) { stage2(CTX, data); data += 64; len -= 64; } while (len) { chunksize = 64 - CTX->bufsize; if (chunksize > len) chunksize = len; memcpy(&CTX->buffer[CTX->bufsize], data, chunksize); CTX->bufsize += chunksize; len -= chunksize; data += chunksize; if (CTX->bufsize == 64) { stage2(CTX, CTX->buffer); CTX->bufsize = 0; } } } -void STREEBOG_finalize(STREEBOG_CTX *CTX, byte *digest) +void STREEBOG_finalize(STREEBOG_CTX *CTX, uint8 *digest) { stage3(CTX); CTX->bufsize = 0; if (CTX->digest_size == 256) memcpy(digest, &(CTX->hash[4]), 32); else memcpy(digest, CTX->hash, 64); } diff --git a/src/Crypto/Streebog.h b/src/Crypto/Streebog.h index d5691e70..29571d73 100644 --- a/src/Crypto/Streebog.h +++ b/src/Crypto/Streebog.h @@ -4,38 +4,38 @@ * All rights reserved. */ /* Adapted to VeraCrypt */ #ifndef STREEBOG_H #define STREEBOG_H #include "Common/Tcdefs.h" #include "config.h" #ifdef __cplusplus extern "C" { #endif #define STREEBOG_ALIGN(a) CRYPTOPP_ALIGN_DATA(a) typedef STREEBOG_ALIGN(16) struct _STREEBOG_CTX { STREEBOG_ALIGN(16) unsigned char buffer[64]; STREEBOG_ALIGN(16) unsigned long long hash[8]; STREEBOG_ALIGN(16) unsigned long long h[8]; STREEBOG_ALIGN(16) unsigned long long N[8]; STREEBOG_ALIGN(16) unsigned long long Sigma[8]; size_t bufsize; unsigned int digest_size; } STREEBOG_CTX; void STREEBOG_init(STREEBOG_CTX *ctx); void STREEBOG_init256(STREEBOG_CTX *ctx); -void STREEBOG_add(STREEBOG_CTX *ctx, const byte *msg, size_t len); -void STREEBOG_finalize(STREEBOG_CTX *ctx, byte *out); +void STREEBOG_add(STREEBOG_CTX *ctx, const uint8 *msg, size_t len); +void STREEBOG_finalize(STREEBOG_CTX *ctx, uint8 *out); #ifdef __cplusplus } #endif #endif diff --git a/src/Crypto/Twofish.c b/src/Crypto/Twofish.c index ad93b66f..ff46bc99 100644 --- a/src/Crypto/Twofish.c +++ b/src/Crypto/Twofish.c @@ -30,124 +30,124 @@ */ /* Adapted for TrueCrypt */ /* Adapted for VeraCrypt */ #ifdef TC_WINDOWS_BOOT #pragma optimize ("tl", on) #endif #include "Twofish.h" #include "Common/Endian.h" #ifndef TC_MINIMIZE_CODE_SIZE #include "misc.h" /* C implementation based on code written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) and released into public domain. With ideas from Botan library (C) 1999-2007 Jack Lloyd Botan is released under the Simplified BSD License (see license.txt) */ #if !defined (_MSC_VER) || defined(_M_X64) #define UNROLL_TWOFISH #endif #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) /* these are 64-bit assembly implementation taken from https://github.com/jkivilin/supercop-blockciphers - Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> + Copyright © 2011-2013 Jussi Kivilinna <jussi.kivilinna@iki.fi> */ #if defined(__cplusplus) extern "C" { #endif -void twofish_enc_blk(TwofishInstance *ks, byte *dst, const byte *src); -void twofish_dec_blk(TwofishInstance *ks, byte *dst, const byte *src); -void twofish_enc_blk2(TwofishInstance *ks, byte *dst, const byte *src); -void twofish_dec_blk2(TwofishInstance *ks, byte *dst, const byte *src); -void twofish_enc_blk3(TwofishInstance *ks, byte *dst, const byte *src); -void twofish_dec_blk3(TwofishInstance *ks, byte *dst, const byte *src); +void twofish_enc_blk(TwofishInstance *ks, uint8 *dst, const uint8 *src); +void twofish_dec_blk(TwofishInstance *ks, uint8 *dst, const uint8 *src); +void twofish_enc_blk2(TwofishInstance *ks, uint8 *dst, const uint8 *src); +void twofish_dec_blk2(TwofishInstance *ks, uint8 *dst, const uint8 *src); +void twofish_enc_blk3(TwofishInstance *ks, uint8 *dst, const uint8 *src); +void twofish_dec_blk3(TwofishInstance *ks, uint8 *dst, const uint8 *src); #if defined(__cplusplus) } #endif -void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) +void twofish_encrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount) { while (blockCount >= 3) { twofish_enc_blk3 (instance, out_blk, in_blk); out_blk += 3 * 16; in_blk += 3 * 16; blockCount -= 3; } if (blockCount == 2) { twofish_enc_blk2 (instance, out_blk, in_blk); } else { twofish_enc_blk (instance, out_blk, in_blk); } } -void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount) +void twofish_decrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount) { while (blockCount >= 3) { twofish_dec_blk3 (instance, out_blk, in_blk); out_blk += 3 * 16; in_blk += 3 * 16; blockCount -= 3; } if (blockCount == 2) { twofish_dec_blk2 (instance, out_blk, in_blk); } else { twofish_dec_blk (instance, out_blk, in_blk); } } #endif -static const byte Q[2][256] = { +static const uint8 Q[2][256] = { { 0xa9, 0x67, 0xb3, 0xe8, 0x04, 0xfd, 0xa3, 0x76, 0x9a, 0x92, 0x80, 0x78, 0xe4, 0xdd, 0xd1, 0x38, 0x0d, 0xc6, 0x35, 0x98, 0x18, 0xf7, 0xec, 0x6c, 0x43, 0x75, 0x37, 0x26, 0xfa, 0x13, 0x94, 0x48, 0xf2, 0xd0, 0x8b, 0x30, 0x84, 0x54, 0xdf, 0x23, 0x19, 0x5b, 0x3d, 0x59, 0xf3, 0xae, 0xa2, 0x82, 0x63, 0x01, 0x83, 0x2e, 0xd9, 0x51, 0x9b, 0x7c, 0xa6, 0xeb, 0xa5, 0xbe, 0x16, 0x0c, 0xe3, 0x61, 0xc0, 0x8c, 0x3a, 0xf5, 0x73, 0x2c, 0x25, 0x0b, 0xbb, 0x4e, 0x89, 0x6b, 0x53, 0x6a, 0xb4, 0xf1, 0xe1, 0xe6, 0xbd, 0x45, 0xe2, 0xf4, 0xb6, 0x66, 0xcc, 0x95, 0x03, 0x56, 0xd4, 0x1c, 0x1e, 0xd7, 0xfb, 0xc3, 0x8e, 0xb5, 0xe9, 0xcf, 0xbf, 0xba, 0xea, 0x77, 0x39, 0xaf, 0x33, 0xc9, 0x62, 0x71, 0x81, 0x79, 0x09, 0xad, 0x24, 0xcd, 0xf9, 0xd8, 0xe5, 0xc5, 0xb9, 0x4d, 0x44, 0x08, 0x86, 0xe7, 0xa1, 0x1d, 0xaa, 0xed, 0x06, 0x70, 0xb2, 0xd2, 0x41, 0x7b, 0xa0, 0x11, 0x31, 0xc2, 0x27, 0x90, 0x20, 0xf6, 0x60, 0xff, 0x96, 0x5c, 0xb1, 0xab, 0x9e, 0x9c, 0x52, 0x1b, 0x5f, 0x93, 0x0a, 0xef, 0x91, 0x85, 0x49, 0xee, 0x2d, 0x4f, 0x8f, 0x3b, 0x47, 0x87, 0x6d, 0x46, 0xd6, 0x3e, 0x69, 0x64, 0x2a, 0xce, 0xcb, 0x2f, 0xfc, 0x97, 0x05, 0x7a, 0xac, 0x7f, 0xd5, 0x1a, 0x4b, 0x0e, 0xa7, 0x5a, 0x28, 0x14, 0x3f, 0x29, 0x88, 0x3c, 0x4c, 0x02, 0xb8, 0xda, 0xb0, 0x17, 0x55, 0x1f, 0x8a, 0x7d, 0x57, 0xc7, 0x8d, 0x74, 0xb7, 0xc4, 0x9f, 0x72, 0x7e, 0x15, 0x22, 0x12, 0x58, 0x07, 0x99, 0x34, 0x6e, 0x50, 0xde, 0x68, 0x65, 0xbc, 0xdb, 0xf8, 0xc8, 0xa8, 0x2b, 0x40, 0xdc, 0xfe, 0x32, 0xa4, 0xca, 0x10, 0x21, 0xf0, 0xd3, 0x5d, 0x0f, 0x00, 0x6f, 0x9d, 0x36, 0x42, 0x4a, 0x5e, 0xc1, 0xe0 }, { 0x75, 0xf3, 0xc6, 0xf4, 0xdb, 0x7b, 0xfb, 0xc8, 0x4a, 0xd3, 0xe6, 0x6b, 0x45, 0x7d, 0xe8, 0x4b, 0xd6, 0x32, 0xd8, 0xfd, 0x37, 0x71, 0xf1, 0xe1, 0x30, 0x0f, 0xf8, 0x1b, 0x87, 0xfa, 0x06, 0x3f, 0x5e, 0xba, 0xae, 0x5b, 0x8a, 0x00, 0xbc, 0x9d, 0x6d, 0xc1, 0xb1, 0x0e, 0x80, 0x5d, 0xd2, 0xd5, 0xa0, 0x84, 0x07, 0x14, 0xb5, 0x90, 0x2c, 0xa3, 0xb2, 0x73, 0x4c, 0x54, 0x92, 0x74, 0x36, 0x51, 0x38, 0xb0, 0xbd, 0x5a, 0xfc, 0x60, 0x62, 0x96, 0x6c, 0x42, 0xf7, 0x10, 0x7c, 0x28, 0x27, 0x8c, 0x13, 0x95, 0x9c, 0xc7, 0x24, 0x46, 0x3b, 0x70, 0xca, 0xe3, 0x85, 0xcb, 0x11, 0xd0, 0x93, 0xb8, 0xa6, 0x83, 0x20, 0xff, 0x9f, 0x77, 0xc3, 0xcc, 0x03, 0x6f, 0x08, 0xbf, 0x40, 0xe7, 0x2b, 0xe2, 0x79, 0x0c, 0xaa, 0x82, 0x41, 0x3a, 0xea, 0xb9, 0xe4, 0x9a, 0xa4, 0x97, 0x7e, 0xda, 0x7a, 0x17, 0x66, 0x94, 0xa1, 0x1d, 0x3d, 0xf0, 0xde, 0xb3, 0x0b, 0x72, 0xa7, 0x1c, 0xef, 0xd1, 0x53, 0x3e, 0x8f, 0x33, 0x26, 0x5f, 0xec, 0x76, 0x2a, 0x49, 0x81, 0x88, 0xee, 0x21, 0xc4, 0x1a, 0xeb, 0xd9, 0xc5, 0x39, 0x99, 0xcd, 0xad, 0x31, 0x8b, 0x01, 0x18, 0x23, 0xdd, 0x1f, 0x4e, 0x2d, 0xf9, 0x48, @@ -577,65 +577,65 @@ static const uint32 RS[8][256] = { f0 = ks->mk_tab[0][x0 & 0xFF] ^ ks->mk_tab[1][(x0 >> 8) & 0xFF] ^ ks->mk_tab[2][(x0 >> 16) & 0xFF] ^ ks->mk_tab[3][(x0 >> 24) & 0xFF]; \ f1 = ks->mk_tab[0][(x1 >> 24) & 0xFF] ^ ks->mk_tab[1][x1 & 0xFF] ^ ks->mk_tab[2][(x1 >> 8) & 0xFF] ^ ks->mk_tab[3][(x1 >> 16) & 0xFF]; \ f0 += f1; \ f1 += f0 + rk[2 * (r) + 9]; \ f0 += rk[2 * (r) + 8]; #define ROUNDA(r) \ ROUNDT(x0, x1, r) \ x2 = rotr32(x2 ^ f0, 1); \ x3 = rotl32(x3, 1) ^ f1; #define ROUNDB(r) \ ROUNDT(x2, x3, r) \ x0 = rotr32(x0 ^ f0, 1); \ x1 = rotl32(x1, 1) ^ f1; #define RROUNDA(r) \ ROUNDT(x0, x1, r) \ x2 = rotl32(x2, 1) ^ f0; \ x3 = rotr32(x3 ^ f1, 1); #define RROUNDB(r) \ ROUNDT(x2, x3, r) \ x0 = rotl32(x0, 1) ^ f0; \ x1 = rotr32(x1 ^ f1, 1); void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]) { union { - byte S8[16]; + uint8 S8[16]; uint32 S32[4]; } us; unsigned int i; - const byte* key = (const byte*) in_key; + const uint8* key = (const uint8*) in_key; us.S32[0] = RS[0][key[0]] ^ RS[1][key[1]] ^ RS[2][key[2]] ^ RS[3][key[3]] ^ RS[4][key[4]] ^ RS[5][key[5]] ^ RS[6][key[6]] ^ RS[7][key[7]]; us.S32[1] = RS[0][key[8]] ^ RS[1][key[9]] ^ RS[2][key[10]] ^ RS[3][key[11]] ^ RS[4][key[12]] ^ RS[5][key[13]] ^ RS[6][key[14]] ^ RS[7][key[15]]; us.S32[2] = RS[0][key[16]] ^ RS[1][key[17]] ^ RS[2][key[18]] ^ RS[3][key[19]] ^ RS[4][key[20]] ^ RS[5][key[21]] ^ RS[6][key[22]] ^ RS[7][key[23]]; us.S32[3] = RS[0][key[24]] ^ RS[1][key[25]] ^ RS[2][key[26]] ^ RS[3][key[27]] ^ RS[4][key[28]] ^ RS[5][key[29]] ^ RS[6][key[30]] ^ RS[7][key[31]]; for (i = 0; i < 256; ++i) { instance->mk_tab[0][i] = MDSQ[0][Q[0][Q[0][Q[1][Q[1][i] ^ us.S8[0]] ^ us.S8[4]] ^ us.S8[8]] ^ us.S8[12]]; instance->mk_tab[1][i] = MDSQ[1][Q[0][Q[1][Q[1][Q[0][i] ^ us.S8[1]] ^ us.S8[5]] ^ us.S8[9]] ^ us.S8[13]]; instance->mk_tab[2][i] = MDSQ[2][Q[1][Q[0][Q[0][Q[0][i] ^ us.S8[2]] ^ us.S8[6]] ^ us.S8[10]] ^ us.S8[14]]; instance->mk_tab[3][i] = MDSQ[3][Q[1][Q[1][Q[0][Q[1][i] ^ us.S8[3]] ^ us.S8[7]] ^ us.S8[11]] ^ us.S8[15]]; } for (i = 0; i != 40; i += 2) { uint32 a = MDSQ[0][Q[0][Q[0][Q[1][Q[1][i] ^ key[24]] ^ key[16]] ^ key[8]] ^ key[0]] ^ MDSQ[1][Q[0][Q[1][Q[1][Q[0][i] ^ key[25]] ^ key[17]] ^ key[9]] ^ key[1]] ^ MDSQ[2][Q[1][Q[0][Q[0][Q[0][i] ^ key[26]] ^ key[18]] ^ key[10]] ^ key[2]] ^ MDSQ[3][Q[1][Q[1][Q[0][Q[1][i] ^ key[27]] ^ key[19]] ^ key[11]] ^ key[3]]; uint32 b = rotl32(MDSQ[0][Q[0][Q[0][Q[1][Q[1][i + 1] ^ key[28]] ^ key[20]] ^ key[12]] ^ key[4]] ^ MDSQ[1][Q[0][Q[1][Q[1][Q[0][i + 1] ^ key[29]] ^ key[21]] ^ key[13]] ^ key[5]] ^ MDSQ[2][Q[1][Q[0][Q[0][Q[0][i + 1] ^ key[30]] ^ key[22]] ^ key[14]] ^ key[6]] ^ MDSQ[3][Q[1][Q[1][Q[0][Q[1][i + 1] ^ key[31]] ^ key[23]] ^ key[15]] ^ key[7]], 8); a += b; #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) if (i < 8) { instance->w[i] = a; instance->w[i + 1] = rotl32(a + b, 9); } else { instance->k[i - 8] = a; diff --git a/src/Crypto/Twofish.h b/src/Crypto/Twofish.h index e74826eb..3b530cbd 100644 --- a/src/Crypto/Twofish.h +++ b/src/Crypto/Twofish.h @@ -28,44 +28,44 @@ extern "C" #define rotr(x,n) _lrotr(x,n) #define rotl(x,n) _lrotl(x,n) #else #define rotr(x,n) (((x)>>(n))|((x)<<(32-(n)))) #define rotl(x,n) (((x)<<(n))|((x)>>(32-(n)))) #endif #endif typedef struct { #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) u4byte mk_tab[4][256], w[8], k[32]; #else u4byte l_key[40]; #ifdef TC_MINIMIZE_CODE_SIZE u4byte s_key[4]; #ifdef TC_WINDOWS_BOOT_TWOFISH u4byte mk_tab[4 * 256]; #endif #else u4byte mk_tab[4][256]; #endif #endif } TwofishInstance; #define TWOFISH_KS sizeof(TwofishInstance) /* in_key must be 32-bytes long */ void twofish_set_key(TwofishInstance *instance, const u4byte in_key[]); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) -void twofish_encrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); -void twofish_decrypt_blocks(TwofishInstance *instance, const byte* in_blk, byte* out_blk, uint32 blockCount); -#define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1) -#define twofish_decrypt(instance,in_blk,out_blk) twofish_decrypt_blocks(instance, (const byte*) in_blk, (byte*) out_blk, 1) +void twofish_encrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount); +void twofish_decrypt_blocks(TwofishInstance *instance, const uint8* in_blk, uint8* out_blk, uint32 blockCount); +#define twofish_encrypt(instance,in_blk,out_blk) twofish_encrypt_blocks(instance, (const uint8*) in_blk, (uint8*) out_blk, 1) +#define twofish_decrypt(instance,in_blk,out_blk) twofish_decrypt_blocks(instance, (const uint8*) in_blk, (uint8*) out_blk, 1) #else void twofish_encrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]); void twofish_decrypt(TwofishInstance *instance, const u4byte in_blk[4], u4byte out_blk[4]); #endif #if defined(__cplusplus) } #endif #endif // TWOFISH_H diff --git a/src/Crypto/Whirlpool.c b/src/Crypto/Whirlpool.c index 98ba318d..6a1fe8b4 100644 --- a/src/Crypto/Whirlpool.c +++ b/src/Crypto/Whirlpool.c @@ -867,158 +867,158 @@ void WhirlpoolTransform(uint64 *digest, const uint64 *block) L[3] = Whirlpool_C[0*256 + K.ch[3 * 8 + 7]] ^ Whirlpool_C[1*256 + K.ch[2 * 8 + 6]] ^ Whirlpool_C[2*256 + K.ch[1 * 8 + 5]] ^ Whirlpool_C[3*256 + K.ch[0 * 8 + 4]] ^ Whirlpool_C[4*256 + K.ch[7 * 8 + 3]] ^ Whirlpool_C[5*256 + K.ch[6 * 8 + 2]] ^ Whirlpool_C[6*256 + K.ch[5 * 8 + 1]] ^ Whirlpool_C[7*256 + K.ch[4 * 8 + 0]]; L[4] = Whirlpool_C[0*256 + K.ch[4 * 8 + 7]] ^ Whirlpool_C[1*256 + K.ch[3 * 8 + 6]] ^ Whirlpool_C[2*256 + K.ch[2 * 8 + 5]] ^ Whirlpool_C[3*256 + K.ch[1 * 8 + 4]] ^ Whirlpool_C[4*256 + K.ch[0 * 8 + 3]] ^ Whirlpool_C[5*256 + K.ch[7 * 8 + 2]] ^ Whirlpool_C[6*256 + K.ch[6 * 8 + 1]] ^ Whirlpool_C[7*256 + K.ch[5 * 8 + 0]]; L[5] = Whirlpool_C[0*256 + K.ch[5 * 8 + 7]] ^ Whirlpool_C[1*256 + K.ch[4 * 8 + 6]] ^ Whirlpool_C[2*256 + K.ch[3 * 8 + 5]] ^ Whirlpool_C[3*256 + K.ch[2 * 8 + 4]] ^ Whirlpool_C[4*256 + K.ch[1 * 8 + 3]] ^ Whirlpool_C[5*256 + K.ch[0 * 8 + 2]] ^ Whirlpool_C[6*256 + K.ch[7 * 8 + 1]] ^ Whirlpool_C[7*256 + K.ch[6 * 8 + 0]]; L[6] = Whirlpool_C[0*256 + K.ch[6 * 8 + 7]] ^ Whirlpool_C[1*256 + K.ch[5 * 8 + 6]] ^ Whirlpool_C[2*256 + K.ch[4 * 8 + 5]] ^ Whirlpool_C[3*256 + K.ch[3 * 8 + 4]] ^ Whirlpool_C[4*256 + K.ch[2 * 8 + 3]] ^ Whirlpool_C[5*256 + K.ch[1 * 8 + 2]] ^ Whirlpool_C[6*256 + K.ch[0 * 8 + 1]] ^ Whirlpool_C[7*256 + K.ch[7 * 8 + 0]]; L[7] = Whirlpool_C[0*256 + K.ch[7 * 8 + 7]] ^ Whirlpool_C[1*256 + K.ch[6 * 8 + 6]] ^ Whirlpool_C[2*256 + K.ch[5 * 8 + 5]] ^ Whirlpool_C[3*256 + K.ch[4 * 8 + 4]] ^ Whirlpool_C[4*256 + K.ch[3 * 8 + 3]] ^ Whirlpool_C[5*256 + K.ch[2 * 8 + 2]] ^ Whirlpool_C[6*256 + K.ch[1 * 8 + 1]] ^ Whirlpool_C[7*256 + K.ch[0 * 8 + 0]]; L[0] = (K.ll[0] = L[0]) ^ Whirlpool_C[0*256 + state.ch[0 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[7 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[6 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[5 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[4 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[3 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[2 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[1 * 8 + 0]]; L[1] = (K.ll[1] = L[1]) ^ Whirlpool_C[0*256 + state.ch[1 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[0 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[7 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[6 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[5 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[4 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[3 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[2 * 8 + 0]]; L[2] = (K.ll[2] = L[2]) ^ Whirlpool_C[0*256 + state.ch[2 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[1 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[0 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[7 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[6 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[5 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[4 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[3 * 8 + 0]]; L[3] = (K.ll[3] = L[3]) ^ Whirlpool_C[0*256 + state.ch[3 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[2 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[1 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[0 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[7 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[6 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[5 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[4 * 8 + 0]]; L[4] = (K.ll[4] = L[4]) ^ Whirlpool_C[0*256 + state.ch[4 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[3 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[2 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[1 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[0 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[7 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[6 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[5 * 8 + 0]]; L[5] = (K.ll[5] = L[5]) ^ Whirlpool_C[0*256 + state.ch[5 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[4 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[3 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[2 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[1 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[0 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[7 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[6 * 8 + 0]]; L[6] = (K.ll[6] = L[6]) ^ Whirlpool_C[0*256 + state.ch[6 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[5 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[4 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[3 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[2 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[1 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[0 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[7 * 8 + 0]]; L[7] = (K.ll[7] = L[7]) ^ Whirlpool_C[0*256 + state.ch[7 * 8 + 7]] ^ Whirlpool_C[1*256 + state.ch[6 * 8 + 6]] ^ Whirlpool_C[2*256 + state.ch[5 * 8 + 5]] ^ Whirlpool_C[3*256 + state.ch[4 * 8 + 4]] ^ Whirlpool_C[4*256 + state.ch[3 * 8 + 3]] ^ Whirlpool_C[5*256 + state.ch[2 * 8 + 2]] ^ Whirlpool_C[6*256 + state.ch[1 * 8 + 1]] ^ Whirlpool_C[7*256 + state.ch[0 * 8 + 0]]; memcpy(state.ll, L, sizeof(L)); } while (++r < 10); i = 0; do digest[i] ^= L[i] ^ (block)[i]; while (++i < 8); } } static uint64 HashMultipleBlocks(WHIRLPOOL_CTX * const ctx, const uint64 *input, uint64 length) { uint64* dataBuf = ctx->data; do { #if BYTE_ORDER == BIG_ENDIAN WhirlpoolTransform(ctx->state, input); #else - CorrectEndianess(dataBuf, input, 64); + CorrectEndianness(dataBuf, input, 64); WhirlpoolTransform(ctx->state, dataBuf); #endif input += 8; length -= 64; } while (length >= 64); return length; } /** * Initialize the hashing state. */ void WHIRLPOOL_init(WHIRLPOOL_CTX * const ctx) { ctx->countHi = 0; ctx->countLo = 0; memset (ctx->data, 0, 8 * sizeof (uint64)); memset (ctx->state, 0, 8 * sizeof (uint64)); } /** * Delivers input data to the hashing algorithm. * * @param source plaintext data to hash. * @param sourceBits how many bits of plaintext to process. * * This method maintains the invariant: bufferBits < DIGESTBITS */ void WHIRLPOOL_add(const unsigned char * input, unsigned __int32 sourceBytes, WHIRLPOOL_CTX * const ctx) { uint64 num, oldCountLo = ctx->countLo, oldCountHi = ctx->countHi; uint64 len = sourceBytes; if ((ctx->countLo = oldCountLo + (uint64)len) < oldCountLo) ctx->countHi++; // carry from low to high if (ctx->countHi < oldCountHi) return; else { uint64* dataBuf = ctx->data; - byte* data = (byte *)dataBuf; + uint8* data = (uint8 *)dataBuf; num = oldCountLo & 63; if (num != 0) // process left over data { if (num+len >= 64) { memcpy(data+num, input, (size_t) (64-num)); HashMultipleBlocks(ctx, dataBuf, 64); input += (64-num); len -= (64-num); // drop through and do the rest } else { memcpy(data+num, input, (size_t) len); return; } } // now process the input data in blocks of 64 bytes and save the leftovers to ctx->data if (len >= 64) { if (input == data) { HashMultipleBlocks(ctx, dataBuf, 64); return; } else if (IsAligned16(input)) { uint64 leftOver = HashMultipleBlocks(ctx, (uint64 *)input, len); input += (len - leftOver); len = leftOver; } else do { // copy input first if it's not aligned correctly memcpy(data, input, 64); HashMultipleBlocks(ctx, dataBuf, 64); input+=64; len-=64; } while (len >= 64); } if (len && data != input) memcpy(data, input, (size_t) len); } } /** * Get the hash value from the hashing state. * * This method uses the invariant: bufferBits < DIGESTBITS */ void WHIRLPOOL_finalize(WHIRLPOOL_CTX * const ctx, unsigned char * result) { unsigned int num = ctx->countLo & 63; uint64* dataBuf = ctx->data; uint64* stateBuf = ctx->state; - byte* data = (byte *)dataBuf; + uint8* data = (uint8 *)dataBuf; data[num++] = 0x80; if (num <= 32) memset(data+num, 0, 32-num); else { memset(data+num, 0, 64-num); HashMultipleBlocks(ctx, dataBuf, 64); memset(data, 0, 32); } #if BYTE_ORDER == LITTLE_ENDIAN - CorrectEndianess(dataBuf, dataBuf, 32); + CorrectEndianness(dataBuf, dataBuf, 32); #endif dataBuf[4] = 0; dataBuf[5] = 0; dataBuf[6] = (ctx->countLo >> (8*sizeof(uint64)-3)) + (ctx->countHi << 3); dataBuf[7] = ctx->countLo << 3; WhirlpoolTransform(stateBuf, dataBuf); #if BYTE_ORDER == LITTLE_ENDIAN - CorrectEndianess(stateBuf, stateBuf, 64); + CorrectEndianness(stateBuf, stateBuf, 64); #endif memcpy(result, stateBuf, 64); } diff --git a/src/Crypto/chacha-xmm.c b/src/Crypto/chacha-xmm.c index 478de594..54c3680c 100644 --- a/src/Crypto/chacha-xmm.c +++ b/src/Crypto/chacha-xmm.c @@ -16,61 +16,60 @@ Public domain. #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE #ifndef _M_X64 #ifdef _MSC_VER #if _MSC_VER < 1900 __inline __m128i _mm_set_epi64x(int64 i0, int64 i1) { union { int64 q[2]; int32 r[4]; } u; u.q[0] = i1; u.q[1] = i0; // this is inefficient, but other solutions are worse return _mm_setr_epi32(u.r[0], u.r[1], u.r[2], u.r[3]); } #pragma warning(disable:4799) __inline __m128i _mm_set1_epi64x(int64 a) { union { __m64 m; long long ii; } u; u.ii = a; return _mm_set1_epi64(u.m); } #pragma warning(default:4799) #endif #endif #endif -#define uint8 byte #define U32V(v) (v) #define ROTL32(x,n) rotl32(x, n) #define U32TO8_LITTLE(p, v) (((uint32*)(p))[0] = (v)) #define U8TO32_LITTLE(v) *((uint32*)(v)) #define ROTATE(v,c) (ROTL32(v,c)) #define XOR(v,w) ((v) ^ (w)) #define PLUS(v,w) (U32V((v) + (w))) #define PLUSONE(v) (PLUS((v),1)) #define QUARTERROUND(a,b,c,d) \ x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]),16); \ x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]),12); \ x[a] = PLUS(x[a],x[b]); x[d] = ROTATE(XOR(x[d],x[a]), 8); \ x[c] = PLUS(x[c],x[d]); x[b] = ROTATE(XOR(x[b],x[c]), 7); static void salsa20_wordtobyte(uint8 output[64],const uint32 input[16], unsigned int r) { uint32 x[16]; int i; for (i = 0;i < 16;++i) x[i] = input[i]; for (i = r;i > 0;--i) { QUARTERROUND( 0, 4, 8,12) QUARTERROUND( 1, 5, 9,13) QUARTERROUND( 2, 6,10,14) QUARTERROUND( 3, 7,11,15) QUARTERROUND( 0, 5,10,15) diff --git a/src/Crypto/config.h b/src/Crypto/config.h index 867c13dd..d2a9cfea 100644 --- a/src/Crypto/config.h +++ b/src/Crypto/config.h @@ -182,35 +182,35 @@ // see http://predef.sourceforge.net/prearch.html #if (defined(_M_IX86) || defined(__i386__) || defined(__i386) || defined(_X86_) || defined(__I86__) || defined(__INTEL__)) && !CRYPTOPP_BOOL_X32 #define CRYPTOPP_BOOL_X86 1 #else #define CRYPTOPP_BOOL_X86 0 #endif #if (defined(_M_X64) || defined(__x86_64__)) && !CRYPTOPP_BOOL_X32 #define CRYPTOPP_BOOL_X64 1 #else #define CRYPTOPP_BOOL_X64 0 #endif // Undo the ASM and Intrinsic related defines due to X32. #if CRYPTOPP_BOOL_X32 # undef CRYPTOPP_BOOL_X64 # undef CRYPTOPP_X64_ASM_AVAILABLE # undef CRYPTOPP_X64_MASM_AVAILABLE #endif #if !defined(CRYPTOPP_NO_UNALIGNED_DATA_ACCESS) && !defined(CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS) #if (CRYPTOPP_BOOL_X64 || CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || defined(__powerpc__) || (__ARM_FEATURE_UNALIGNED >= 1)) #define CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS #endif #endif // this version of the macro is fastest on Pentium 3 and Pentium 4 with MSVC 6 SP5 w/ Processor Pack #define GETBYTE(x, y) (unsigned int)((unsigned char)((x)>>(8*(y)))) // these may be faster on other CPUs/compilers // #define GETBYTE(x, y) (unsigned int)(((x)>>(8*(y)))&255) -// #define GETBYTE(x, y) (((byte *)&(x))[y]) +// #define GETBYTE(x, y) (((uint8 *)&(x))[y]) -#define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ((byte)((x)>>(8*(y)))) +#define CRYPTOPP_GET_BYTE_AS_BYTE(x, y) ((uint8)((x)>>(8*(y)))) #endif diff --git a/src/Crypto/cpu.h b/src/Crypto/cpu.h index a9806b92..2661bf1c 100644 --- a/src/Crypto/cpu.h +++ b/src/Crypto/cpu.h @@ -187,61 +187,61 @@ extern __m128i _mm_insert_epi64(__m128i dst, __int64 s, const int ndx); #endif #if (defined(__AES__) && defined(__PCLMUL__)) || defined(__INTEL_COMPILER) || CRYPTOPP_BOOL_AESNI_INTRINSICS_AVAILABLE #if defined(TC_WINDOWS_DRIVER) || defined (_UEFI) #if defined(__cplusplus) extern "C" { #endif extern __m128i _mm_clmulepi64_si128(__m128i v1, __m128i v2, const int imm8); extern __m128i _mm_aeskeygenassist_si128(__m128i ckey, const int rcon); extern __m128i _mm_aesimc_si128(__m128i v); extern __m128i _mm_aesenc_si128(__m128i v, __m128i rkey); extern __m128i _mm_aesenclast_si128(__m128i v, __m128i rkey); extern __m128i _mm_aesdec_si128(__m128i v, __m128i rkey); extern __m128i _mm_aesdeclast_si128(__m128i v, __m128i rkey); #if defined(__cplusplus) } #endif #else #include <wmmintrin.h> #endif #endif #if CRYPTOPP_BOOL_X86 || CRYPTOPP_BOOL_X32 || CRYPTOPP_BOOL_X64 #if defined(__cplusplus) extern "C" { #endif #define CRYPTOPP_CPUID_AVAILABLE -#ifndef CRYPTOPP_DISABLE_AESNI +#if !defined(CRYPTOPP_DISABLE_AESNI) && !defined(WOLFCRYPT_BACKEND) #define TC_AES_HW_CPU #endif // these should not be used directly extern volatile int g_x86DetectionDone; extern volatile int g_hasSSE2; extern volatile int g_hasISSE; extern volatile int g_hasMMX; extern volatile int g_hasAVX; extern volatile int g_hasAVX2; extern volatile int g_hasBMI2; extern volatile int g_hasSSE42; extern volatile int g_hasSSE41; extern volatile int g_hasSSSE3; extern volatile int g_hasAESNI; extern volatile int g_hasCLMUL; extern volatile int g_isP4; extern volatile int g_hasRDRAND; extern volatile int g_hasRDSEED; extern volatile int g_isIntel; extern volatile int g_isAMD; extern volatile uint32 g_cacheLineSize; void DetectX86Features(); // must be called at the start of the program/driver int CpuId(uint32 input, uint32 output[4]); // disable all CPU extended features (e.g. SSE, AVX, AES) that may have // been enabled by DetectX86Features. void DisableCPUExtendedFeatures (); #ifdef CRYPTOPP_BOOL_X64 #define HasSSE2() 1 diff --git a/src/Crypto/kuznyechik.c b/src/Crypto/kuznyechik.c index 65685d09..fb76142b 100644 --- a/src/Crypto/kuznyechik.c +++ b/src/Crypto/kuznyechik.c @@ -1,65 +1,65 @@ /* This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) and released into public domain. */ #include "kuznyechik.h" #include "cpu.h" #include "misc.h" #ifdef _MSC_VER #define inline __forceinline #endif #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE -void kuznyechik_set_key_simd(const byte* key, kuznyechik_kds *kds); -void kuznyechik_encrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds); -void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); -void kuznyechik_decrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds); -void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); +void kuznyechik_set_key_simd(const uint8* key, kuznyechik_kds *kds); +void kuznyechik_encrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds); +void kuznyechik_encrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds); +void kuznyechik_decrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds); +void kuznyechik_decrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds); #endif //#define CPPCRYPTO_DEBUG - static const byte S[256] = { + static const uint8 S[256] = { 252, 238, 221, 17, 207, 110, 49, 22, 251, 196, 250, 218, 35, 197, 4, 77, 233, 119, 240, 219, 147, 46, 153, 186, 23, 54, 241, 187, 20, 205, 95, 193, 249, 24, 101, 90, 226, 92, 239, 33, 129, 28, 60, 66, 139, 1, 142, 79, 5, 132, 2, 174, 227, 106, 143, 160, 6, 11, 237, 152, 127, 212, 211, 31, 235, 52, 44, 81, 234, 200, 72, 171, 242, 42, 104, 162, 253, 58, 206, 204, 181, 112, 14, 86, 8, 12, 118, 18, 191, 114, 19, 71, 156, 183, 93, 135, 21, 161, 150, 41, 16, 123, 154, 199, 243, 145, 120, 111, 157, 158, 178, 177, 50, 117, 25, 61, 255, 53, 138, 126, 109, 84, 198, 128, 195, 189, 13, 87, 223, 245, 36, 169, 62, 168, 67, 201, 215, 121, 214, 246, 124, 34, 185, 3, 224, 15, 236, 222, 122, 148, 176, 188, 220, 232, 40, 80, 78, 51, 10, 74, 167, 151, 96, 115, 30, 0, 98, 68, 26, 184, 56, 130, 100, 159, 38, 65, 173, 69, 70, 146, 39, 94, 85, 47, 140, 163, 165, 125, 105, 213, 149, 59, 7, 88, 179, 64, 134, 172, 29, 247, 48, 55, 107, 228, 136, 217, 231, 137, 225, 27, 131, 73, 76, 63, 248, 254, 141, 83, 170, 144, 202, 216, 133, 97, 32, 113, 103, 164, 45, 43, 9, 91, 203, 155, 37, 208, 190, 229, 108, 82, 89, 166, 116, 210, 230, 244, 180, 192, 209, 102, 175, 194, 57, 75, 99, 182 }; - static const byte IS[256] = { + static const uint8 IS[256] = { 165, 45, 50, 143, 14, 48, 56, 192, 84, 230, 158, 57, 85, 126, 82, 145, 100, 3, 87, 90, 28, 96, 7, 24, 33, 114, 168, 209, 41, 198, 164, 63, 224, 39, 141, 12, 130, 234, 174, 180, 154, 99, 73, 229, 66, 228, 21, 183, 200, 6, 112, 157, 65, 117, 25, 201, 170, 252, 77, 191, 42, 115, 132, 213, 195, 175, 43, 134, 167, 177, 178, 91, 70, 211, 159, 253, 212, 15, 156, 47, 155, 67, 239, 217, 121, 182, 83, 127, 193, 240, 35, 231, 37, 94, 181, 30, 162, 223, 166, 254, 172, 34, 249, 226, 74, 188, 53, 202, 238, 120, 5, 107, 81, 225, 89, 163, 242, 113, 86, 17, 106, 137, 148, 101, 140, 187, 119, 60, 123, 40, 171, 210, 49, 222, 196, 95, 204, 207, 118, 44, 184, 216, 46, 54, 219, 105, 179, 20, 149, 190, 98, 161, 59, 22, 102, 233, 92, 108, 109, 173, 55, 97, 75, 185, 227, 186, 241, 160, 133, 131, 218, 71, 197, 176, 51, 250, 150, 111, 110, 194, 246, 80, 255, 93, 169, 142, 23, 27, 151, 125, 236, 88, 247, 31, 251, 124, 9, 13, 122, 103, 69, 135, 220, 232, 79, 29, 78, 4, 235, 248, 243, 62, 61, 189, 138, 136, 221, 205, 11, 19, 152, 2, 147, 128, 144, 208, 36, 52, 203, 237, 244, 206, 153, 16, 68, 64, 146, 58, 1, 38, 18, 26, 72, 104, 245, 129, 139, 199, 214, 32, 10, 8, 0, 76, 215, 116 }; static const uint64 T[16][256][2] = { { {LL(0x9680c07a0cd5fbe9), LL(0xb5aec91b93871119)}, {LL(0xce1a17b28ce00819), LL(0x0af2fef8abfc327b)}, {LL(0x77dcb250a2d0cbbf), LL(0x89c7884eefcabdc0)}, {LL(0xd642635e1a104162), LL(0xc01393d33c12c469)}, {LL(0x2f46659822e5384f), LL(0x369bbfadd7b19ea2)}, {LL(0xe74a6f116a39b338), LL(0xefc0cb2f2997703c)}, {LL(0x4d567d06c2b71ffb), LL(0x68fe0f96fd783508)}, {LL(0x7379a4c39bf8884a), LL(0xaa09c5a389e794c7)}, {LL(0x33bb07e78d3d32c1), LL(0xdfb49f6b267241b7)}, {LL(0xf79b37188e997c6a), LL(0x637e3c1d7223d420)}, {LL(0x49f36b95fb9f5c0e), LL(0x4b30427b9b551c0f)}, {LL(0xd2e775cd23380297), LL(0xe3ddde3e5a3fed6e)}, {LL(0x15ccaace4282ec0b), LL(0xd7a23875c503166a)}, {LL(0x8dd35b6af83b12a5), LL(0xf7fae10dcf048998)}, {LL(0x2be3730b1bcd7bba), LL(0x1555f240b19cb7a5)}, {LL(0xf286c5df28bb5f33), LL(0x3862f35aec946656)}, {LL(0x6b21d02f0d08c131), LL(0x60e8a8881e0962d5)}, {LL(0x670dea59467004ed), LL(0x05797f7cb47e19dc)}, {LL(0xeb665567214176e4), LL(0x8a511cdb83e00b35)}, {LL(0xa8af19bf559a6c58), LL(0x7759032ee718b0d6)}, {LL(0x0b82c319104e261e), LL(0xceeadf2407373c9d)}, {LL(0x126253a119b40fc9), LL(0x7cd930a5684351fe)}, {LL(0xa917fdebca900cf4), LL(0x0f8b81841f822ba7)}, {LL(0xbcdb57258812e0ff), LL(0xd829b9f1da813dcd)}, {LL(0x0931c8b1ed5ae685), LL(0x3e8d18b334c0c97f)}, {LL(0xe86dba9b435fd6d3), LL(0x02e459e6488d65a6)}, {LL(0x912e391557e3182b), LL(0x1ed5c1cb3ec7568d)}, {LL(0xc6933b57feb08e30), LL(0x4cad64e167a66075)}, {LL(0x87e97c27777f5417), LL(0x41c2bc8330a92e74)}, {LL(0xdbd6bd7cce62e412), LL(0xdd50c68d6eff2411)}, {LL(0xaa1c1217a88eacc3), LL(0x873ec4b9d4ef4534)}, {LL(0xa6302861e3f6691f), LL(0xe2af134d7e983e3d)}, {LL(0xc72bdf0361baee9c), LL(0x347fe64b9f3cfb04)}, {LL(0xfa0fe93a5aebd91a), LL(0x7e3d694320ce3458)}, {LL(0x3f973d91c645f71d), LL(0xba25489f8c053abe)}, {LL(0xfbb70d6ec5e1b9b6), LL(0x06efebe9d854af29)}, {LL(0xb3fc82afa1748514), LL(0x350d2b38bb9b2857)}, {LL(0x24c4a68132ab1e51), LL(0xf8716089d086a23f)}, {LL(0xb4527bc0fa4266d6), LL(0x9e7623e816db6fc3)}, {LL(0xe15c722aae053056), LL(0x3c6941557c4dacd9)}, {LL(0x531814d1907bd5ee), LL(0x71b6e8c73f4c1fff)}, {LL(0xd1ec9a314126a2a0), LL(0x6b689b03915283fd)}, {LL(0x4af884699981fc39), LL(0xc38507465038729c)}, {LL(0x01b8e4549f0a60ac), LL(0x78d282aaf89a9b71)}, {LL(0xf18d2a234aa5ff04), LL(0xb0d7b66727f908c5)}, {LL(0x7a486c7276a26ecf), LL(0x9484dd10bd275db8)}, {LL(0xa026355a27caea71), LL(0x310699372b42e2d8)}, {LL(0x06161d3bc43c836e), LL(0xd3a98a7a55dadce5)}, {LL(0x51ab1f796d6f1575), LL(0x81d12f500cbbea1d)}, {LL(0x02b30ba8fd14c09b), LL(0xf067c79733f7f5e2)}, {LL(0xf490d8e4ec87dc5d), LL(0xebcb7920b94ebab3)}, {LL(0x3b322b02ff6db4e8), LL(0x99eb0572ea2813b9)}, {LL(0xc9b4eeddd7d6ebdb), LL(0xa189f62806bc75ef)}, {LL(0xcca91c1a71f4c882), LL(0xfa95396f980bc799)}, {LL(0xda6e5928516884be), LL(0xa58244279665bf60)}, {LL(0xb24466fb3e7ee5b8), LL(0x4ddfa9924301b326)}, {LL(0xdf73abeff74aa7e7), LL(0xfe9e8b6008d20d16)}, {LL(0xd8dd5280ac7c4425), LL(0x55e583b0a5924a82)}, {LL(0x40c2a32416c5ba8b), LL(0x75bd5ac8af95d570)}, {LL(0xd35f9199bc32623b), LL(0x9b0f5c94a2a5761f)}, {LL(0x31080c4f7029f25a), LL(0x2fd358fc1585b455)}, {LL(0x5b913834e22b53c7), LL(0x37e972def3164df1)}, {LL(0xfeaaffa963c39aef), LL(0x5df324ae46e31d5f)}, {LL(0x5f342ea7db031032), LL(0x14273f33953b64f6)}, {LL(0x9fb108cbe18f1d6c), LL(0x8b23d1a8a747d866)}, {LL(0x1cfd627fafd80a8e), LL(0xe92f20c6f1c3df15)}, {LL(0xe6f28b45f533d394), LL(0x97124985d10deb4d)}, {LL(0x236a5fee699dfd93), LL(0x530a68597dc6e5ab)}, {LL(0xe5f964b9972d73a3), LL(0x1fa70cb81a6085de)}, {LL(0x8a7da205a30df167), LL(0x5c81e9dd6244ce0c)}, {LL(0xa32ddaa645d44a46), LL(0xb9b3dc0ae02f8c4b)}, {LL(0x6a99347b9202a19d), LL(0x183a2a22e693f9a4)}, @@ -2117,292 +2117,292 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku {LL(0x31f0dc1c90fa2ebe), LL(0x7898fb40648a4d2c)}, {LL(0x944740add0087bab), LL(0xc2e3365b6ff9ae07)}, {LL(0x485e3e19ac7702ae), LL(0x2fe7461d3613a360)}, {LL(0x0d804b35bf31ee51), LL(0x402bc22a75e507cb)}, {LL(0xdfcb6f4ddad4c812), LL(0x84a9e21ec92383a4)}, {LL(0xe9129e37a763288f), LL(0x097231673ebf6b8c)}, {LL(0x78e0ed525e55431d), LL(0x70a572d422de940d)}, {LL(0x6d3f2ea398756cf4), LL(0xfeafaa7b5dbc6911)}, {LL(0xe5dcda557a8aa9d3), LL(0x6e833cc43b1d1606)}, {LL(0x45de752c1346ecff), LL(0x6fcc843743f6a4ab)}, {LL(0x5d81fde86a572d47), LL(0xa1ed9eb249715e7c)}, {LL(0xa5b79cb140f25515), LL(0xba7bcd1b0b73e32b)}, {LL(0x66d847a7a8d1238b), LL(0x6c1d8fe1cb08b19f)}, {LL(0xbca61b225b3bfba0), LL(0x5380181771b363bd)}, {LL(0x3eec8987ebb81ef5), LL(0x76c464bbf1e1be65)}, {LL(0x2fc876e9667e4e28), LL(0x642006758d5c68be)}, {LL(0x242f1fed56da0157), LL(0xf69223ef1be8b030)}, {LL(0x636d746f81ef33b2), LL(0xd729fa09b890e019)}, {LL(0x7d55de9a776b5324), LL(0xcb91073c5146c58b)}, {LL(0xceef9023571298cf), LL(0x964d80d0b59e557f)}, {LL(0xc0bdcaef4e88c789), LL(0xbfcbd0a250b2dc77)}, {LL(0x1124ff6e8dc650dd), LL(0x12e462ce7cbdd6db)}, {LL(0x824a92a5b083e555), LL(0x25447cac8052ddd8)}, {LL(0xda7e5c85f3ead82b), LL(0x3f9d97f6babbd222)}, {LL(0x1f76a5a2945c0f9b), LL(0x3b6232bc99915fd3)}, {LL(0xb3ba4eb92079cbeb), LL(0x5ddc87ece4d890f4)}, {LL(0x9d3c370724dfeace), LL(0x1e264e1019c3820b)}, {LL(0x47426b82d73532e5), LL(0x21bbd9e6a3785029)}, {LL(0x96db5e03147ba5b1), LL(0x8c946b8a8f775a85)}, {LL(0x54fa8a429e80bc22), LL(0x7d28e6f93f4b7270)}, {LL(0xc446f670056eb8bd), LL(0x23256ac3536df7b0)}, {LL(0x15dfc3f1c6202fe9), LL(0x8e0ad8af7f62fd1c)}, {LL(0x07292d66ed4dce23), LL(0xf54328399316a504)}, {LL(0x70d595afc85abd75), LL(0x8bbac51624a3c240)}, {LL(0x90bc7c329bee049f), LL(0x5e0d8c3a6c2685c0)}, {LL(0x1ac3966abd621fa2), LL(0x80564754ea090e55)}, {LL(0xa72b821f84818b0f), LL(0xf40c90caebfd17a9)}, {LL(0xd1993581c34e9754), LL(0xad2fb26c2c0f0aac)}, {LL(0x679648f0ca094c86), LL(0x4bc74068bb4fcbde)}, {LL(0xc221d4418afb1993), LL(0xf1bc8d73b03c28f5)}, {LL(0x256110ba34026e5a), LL(0xd148ec666bafca71)}, {LL(0x8a7fea58268c1b3d), LL(0xde5bcb6e862f8b95)}, {LL(0xb85d27bd10dd8494), LL(0xcf6ea276726c487a)}, {LL(0x77fcb8c925177356), LL(0x7ef9ed2fb7b56744)}, {LL(0x62237b38e3375cbf), LL(0xf0f33580c8d79a58)}, {LL(0xeb8e80996310f695), LL(0x47056cb6de319f0e)}, {LL(0x4b8c2fe00adcb3b9), LL(0x464ad445a6da2da3)}, {LL(0x2a7d45214f405e11), LL(0xdf14739dfec43938)}, {LL(0x28e15b8f8b33800b), LL(0x91632e4c1e4acdba)}, {LL(0xff1f4c3fc7e8b671), LL(0xeed57b90d1141853)}, {LL(0xc508f92767b6d7b0), LL(0x04ffa54a232a8df1)}, {LL(0x2b334a762d98311c), LL(0xf8cebc148e834379)}, {LL(0x42f7584afe0b22dc), LL(0x9a8fac0ed0e001af)}, {LL(0x61f16ac1459ceda8), LL(0x995ea7d8581e149b)}, {LL(0x3a17b518a05e61c1), LL(0xea2adedaf23e95a2)}, {LL(0x89adfba18027aa2a), LL(0xb7f6593616e60556)}, {LL(0x0000000000000000), LL(0x0000000000000000)}, {LL(0xee3bb3514a2ee6ac), LL(0xfc31195eada9ce88)}, {LL(0xfaaa7ff7eed6a648), LL(0x55e10e78a28c49d5)}, {LL(0xd7fe17b04cdb367a), LL(0x7fb655dccf5ed5e9)} } }; static const uint64 C[32][2] = { {LL(0xb87a486c7276a26e), LL(0x019484dd10bd275d)}, {LL(0xb3f490d8e4ec87dc), LL(0x02ebcb7920b94eba)}, {LL(0x0b8ed8b4969a25b2), LL(0x037f4fa4300469e7)}, {LL(0xa52be3730b1bcd7b), LL(0x041555f240b19cb7)}, {LL(0x1d51ab1f796d6f15), LL(0x0581d12f500cbbea)}, {LL(0x16df73abeff74aa7), LL(0x06fe9e8b6008d20d)}, {LL(0xaea53bc79d81e8c9), LL(0x076a1a5670b5f550)}, {LL(0x895605e6163659f6), LL(0x082aaa2780a1fbad)}, {LL(0x312c4d8a6440fb98), LL(0x09be2efa901cdcf0)}, {LL(0x3aa2953ef2dade2a), LL(0x0ac1615ea018b517)}, {LL(0x82d8dd5280ac7c44), LL(0x0b55e583b0a5924a)}, {LL(0x2c7de6951d2d948d), LL(0x0c3fffd5c010671a)}, {LL(0x9407aef96f5b36e3), LL(0x0dab7b08d0ad4047)}, {LL(0x9f89764df9c11351), LL(0x0ed434ace0a929a0)}, {LL(0x27f33e218bb7b13f), LL(0x0f40b071f0140efd)}, {LL(0xd1ac0a0f2c6cb22f), LL(0x1054974ec3813599)}, {LL(0x69d642635e1a1041), LL(0x11c01393d33c12c4)}, {LL(0x62589ad7c88035f3), LL(0x12bf5c37e3387b23)}, {LL(0xda22d2bbbaf6979d), LL(0x132bd8eaf3855c7e)}, {LL(0x7487e97c27777f54), LL(0x1441c2bc8330a92e)}, {LL(0xccfda1105501dd3a), LL(0x15d54661938d8e73)}, {LL(0xc77379a4c39bf888), LL(0x16aa09c5a389e794)}, {LL(0x7f0931c8b1ed5ae6), LL(0x173e8d18b334c0c9)}, {LL(0x58fa0fe93a5aebd9), LL(0x187e3d694320ce34)}, {LL(0xe0804785482c49b7), LL(0x19eab9b4539de969)}, {LL(0xeb0e9f31deb66c05), LL(0x1a95f6106399808e)}, {LL(0x5374d75dacc0ce6b), LL(0x1b0172cd7324a7d3)}, {LL(0xfdd1ec9a314126a2), LL(0x1c6b689b03915283)}, {LL(0x45aba4f6433784cc), LL(0x1dffec46132c75de)}, {LL(0x4e257c42d5ada17e), LL(0x1e80a3e223281c39)}, {LL(0xf65f342ea7db0310), LL(0x1f14273f33953b64)}, {LL(0x619b141e58d8a75e), LL(0x20a8ed9c45c16af1)} }; #define LS(x1,x2,t1,t2) { \ - t1 = T[0][(byte)(x1)][0] ^ T[1][(byte)(x1 >> 8)][0] ^ T[2][(byte)(x1 >> 16)][0] ^ T[3][(byte)(x1 >> 24)][0] ^ T[4][(byte)(x1 >> 32)][0] ^ T[5][(byte)(x1 >> 40)][0] ^ \ - T[6][(byte)(x1 >> 48)][0] ^ T[7][(byte)(x1 >> 56)][0] ^ T[8][(byte)(x2)][0] ^ T[9][(byte)(x2 >> 8)][0] ^ T[10][(byte)(x2 >> 16)][0] ^ T[11][(byte)(x2 >> 24)][0] ^ \ - T[12][(byte)(x2 >> 32)][0] ^ T[13][(byte)(x2 >> 40)][0] ^ T[14][(byte)(x2 >> 48)][0] ^ T[15][(byte)(x2 >> 56)][0]; \ - t2 = T[0][(byte)(x1)][1] ^ T[1][(byte)(x1 >> 8)][1] ^ T[2][(byte)(x1 >> 16)][1] ^ T[3][(byte)(x1 >> 24)][1] ^ T[4][(byte)(x1 >> 32)][1] ^ T[5][(byte)(x1 >> 40)][1] ^ \ - T[6][(byte)(x1 >> 48)][1] ^ T[7][(byte)(x1 >> 56)][1] ^ T[8][(byte)(x2)][1] ^ T[9][(byte)(x2 >> 8)][1] ^ T[10][(byte)(x2 >> 16)][1] ^ T[11][(byte)(x2 >> 24)][1] ^ \ - T[12][(byte)(x2 >> 32)][1] ^ T[13][(byte)(x2 >> 40)][1] ^ T[14][(byte)(x2 >> 48)][1] ^ T[15][(byte)(x2 >> 56)][1]; \ + t1 = T[0][(uint8)(x1)][0] ^ T[1][(uint8)(x1 >> 8)][0] ^ T[2][(uint8)(x1 >> 16)][0] ^ T[3][(uint8)(x1 >> 24)][0] ^ T[4][(uint8)(x1 >> 32)][0] ^ T[5][(uint8)(x1 >> 40)][0] ^ \ + T[6][(uint8)(x1 >> 48)][0] ^ T[7][(uint8)(x1 >> 56)][0] ^ T[8][(uint8)(x2)][0] ^ T[9][(uint8)(x2 >> 8)][0] ^ T[10][(uint8)(x2 >> 16)][0] ^ T[11][(uint8)(x2 >> 24)][0] ^ \ + T[12][(uint8)(x2 >> 32)][0] ^ T[13][(uint8)(x2 >> 40)][0] ^ T[14][(uint8)(x2 >> 48)][0] ^ T[15][(uint8)(x2 >> 56)][0]; \ + t2 = T[0][(uint8)(x1)][1] ^ T[1][(uint8)(x1 >> 8)][1] ^ T[2][(uint8)(x1 >> 16)][1] ^ T[3][(uint8)(x1 >> 24)][1] ^ T[4][(uint8)(x1 >> 32)][1] ^ T[5][(uint8)(x1 >> 40)][1] ^ \ + T[6][(uint8)(x1 >> 48)][1] ^ T[7][(uint8)(x1 >> 56)][1] ^ T[8][(uint8)(x2)][1] ^ T[9][(uint8)(x2 >> 8)][1] ^ T[10][(uint8)(x2 >> 16)][1] ^ T[11][(uint8)(x2 >> 24)][1] ^ \ + T[12][(uint8)(x2 >> 32)][1] ^ T[13][(uint8)(x2 >> 40)][1] ^ T[14][(uint8)(x2 >> 48)][1] ^ T[15][(uint8)(x2 >> 56)][1]; \ } #define ILS(x1,x2,t1,t2) { \ - t1 = IT[0][(byte)(x1)][0] ^ IT[1][(byte)(x1 >> 8)][0] ^ IT[2][(byte)(x1 >> 16)][0] ^ IT[3][(byte)(x1 >> 24)][0] ^ IT[4][(byte)(x1 >> 32)][0] ^ IT[5][(byte)(x1 >> 40)][0] ^ \ - IT[6][(byte)(x1 >> 48)][0] ^ IT[7][(byte)(x1 >> 56)][0] ^ IT[8][(byte)(x2)][0] ^ IT[9][(byte)(x2 >> 8)][0] ^ IT[10][(byte)(x2 >> 16)][0] ^ IT[11][(byte)(x2 >> 24)][0] ^ \ - IT[12][(byte)(x2 >> 32)][0] ^ IT[13][(byte)(x2 >> 40)][0] ^ IT[14][(byte)(x2 >> 48)][0] ^ IT[15][(byte)(x2 >> 56)][0]; \ - t2 = IT[0][(byte)(x1)][1] ^ IT[1][(byte)(x1 >> 8)][1] ^ IT[2][(byte)(x1 >> 16)][1] ^ IT[3][(byte)(x1 >> 24)][1] ^ IT[4][(byte)(x1 >> 32)][1] ^ IT[5][(byte)(x1 >> 40)][1] ^ \ - IT[6][(byte)(x1 >> 48)][1] ^ IT[7][(byte)(x1 >> 56)][1] ^ IT[8][(byte)(x2)][1] ^ IT[9][(byte)(x2 >> 8)][1] ^ IT[10][(byte)(x2 >> 16)][1] ^ IT[11][(byte)(x2 >> 24)][1] ^ \ - IT[12][(byte)(x2 >> 32)][1] ^ IT[13][(byte)(x2 >> 40)][1] ^ IT[14][(byte)(x2 >> 48)][1] ^ IT[15][(byte)(x2 >> 56)][1]; \ + t1 = IT[0][(uint8)(x1)][0] ^ IT[1][(uint8)(x1 >> 8)][0] ^ IT[2][(uint8)(x1 >> 16)][0] ^ IT[3][(uint8)(x1 >> 24)][0] ^ IT[4][(uint8)(x1 >> 32)][0] ^ IT[5][(uint8)(x1 >> 40)][0] ^ \ + IT[6][(uint8)(x1 >> 48)][0] ^ IT[7][(uint8)(x1 >> 56)][0] ^ IT[8][(uint8)(x2)][0] ^ IT[9][(uint8)(x2 >> 8)][0] ^ IT[10][(uint8)(x2 >> 16)][0] ^ IT[11][(uint8)(x2 >> 24)][0] ^ \ + IT[12][(uint8)(x2 >> 32)][0] ^ IT[13][(uint8)(x2 >> 40)][0] ^ IT[14][(uint8)(x2 >> 48)][0] ^ IT[15][(uint8)(x2 >> 56)][0]; \ + t2 = IT[0][(uint8)(x1)][1] ^ IT[1][(uint8)(x1 >> 8)][1] ^ IT[2][(uint8)(x1 >> 16)][1] ^ IT[3][(uint8)(x1 >> 24)][1] ^ IT[4][(uint8)(x1 >> 32)][1] ^ IT[5][(uint8)(x1 >> 40)][1] ^ \ + IT[6][(uint8)(x1 >> 48)][1] ^ IT[7][(uint8)(x1 >> 56)][1] ^ IT[8][(uint8)(x2)][1] ^ IT[9][(uint8)(x2 >> 8)][1] ^ IT[10][(uint8)(x2 >> 16)][1] ^ IT[11][(uint8)(x2 >> 24)][1] ^ \ + IT[12][(uint8)(x2 >> 32)][1] ^ IT[13][(uint8)(x2 >> 40)][1] ^ IT[14][(uint8)(x2 >> 48)][1] ^ IT[15][(uint8)(x2 >> 56)][1]; \ } #define ILSS(x1,x2,t1,t2) { \ - t1 = IT[0][S[(byte)(x1)]][0] ^ IT[1][S[(byte)(x1 >> 8)]][0] ^ IT[2][S[(byte)(x1 >> 16)]][0] ^ IT[3][S[(byte)(x1 >> 24)]][0] ^ IT[4][S[(byte)(x1 >> 32)]][0] ^ IT[5][S[(byte)(x1 >> 40)]][0] ^ \ - IT[6][S[(byte)(x1 >> 48)]][0] ^ IT[7][S[(byte)(x1 >> 56)]][0] ^ IT[8][S[(byte)(x2)]][0] ^ IT[9][S[(byte)(x2 >> 8)]][0] ^ IT[10][S[(byte)(x2 >> 16)]][0] ^ IT[11][S[(byte)(x2 >> 24)]][0] ^ \ - IT[12][S[(byte)(x2 >> 32)]][0] ^ IT[13][S[(byte)(x2 >> 40)]][0] ^ IT[14][S[(byte)(x2 >> 48)]][0] ^ IT[15][S[(byte)(x2 >> 56)]][0]; \ - t2 = IT[0][S[(byte)(x1)]][1] ^ IT[1][S[(byte)(x1 >> 8)]][1] ^ IT[2][S[(byte)(x1 >> 16)]][1] ^ IT[3][S[(byte)(x1 >> 24)]][1] ^ IT[4][S[(byte)(x1 >> 32)]][1] ^ IT[5][S[(byte)(x1 >> 40)]][1] ^ \ - IT[6][S[(byte)(x1 >> 48)]][1] ^ IT[7][S[(byte)(x1 >> 56)]][1] ^ IT[8][S[(byte)(x2)]][1] ^ IT[9][S[(byte)(x2 >> 8)]][1] ^ IT[10][S[(byte)(x2 >> 16)]][1] ^ IT[11][S[(byte)(x2 >> 24)]][1] ^ \ - IT[12][S[(byte)(x2 >> 32)]][1] ^ IT[13][S[(byte)(x2 >> 40)]][1] ^ IT[14][S[(byte)(x2 >> 48)]][1] ^ IT[15][S[(byte)(x2 >> 56)]][1]; \ + t1 = IT[0][S[(uint8)(x1)]][0] ^ IT[1][S[(uint8)(x1 >> 8)]][0] ^ IT[2][S[(uint8)(x1 >> 16)]][0] ^ IT[3][S[(uint8)(x1 >> 24)]][0] ^ IT[4][S[(uint8)(x1 >> 32)]][0] ^ IT[5][S[(uint8)(x1 >> 40)]][0] ^ \ + IT[6][S[(uint8)(x1 >> 48)]][0] ^ IT[7][S[(uint8)(x1 >> 56)]][0] ^ IT[8][S[(uint8)(x2)]][0] ^ IT[9][S[(uint8)(x2 >> 8)]][0] ^ IT[10][S[(uint8)(x2 >> 16)]][0] ^ IT[11][S[(uint8)(x2 >> 24)]][0] ^ \ + IT[12][S[(uint8)(x2 >> 32)]][0] ^ IT[13][S[(uint8)(x2 >> 40)]][0] ^ IT[14][S[(uint8)(x2 >> 48)]][0] ^ IT[15][S[(uint8)(x2 >> 56)]][0]; \ + t2 = IT[0][S[(uint8)(x1)]][1] ^ IT[1][S[(uint8)(x1 >> 8)]][1] ^ IT[2][S[(uint8)(x1 >> 16)]][1] ^ IT[3][S[(uint8)(x1 >> 24)]][1] ^ IT[4][S[(uint8)(x1 >> 32)]][1] ^ IT[5][S[(uint8)(x1 >> 40)]][1] ^ \ + IT[6][S[(uint8)(x1 >> 48)]][1] ^ IT[7][S[(uint8)(x1 >> 56)]][1] ^ IT[8][S[(uint8)(x2)]][1] ^ IT[9][S[(uint8)(x2 >> 8)]][1] ^ IT[10][S[(uint8)(x2 >> 16)]][1] ^ IT[11][S[(uint8)(x2 >> 24)]][1] ^ \ + IT[12][S[(uint8)(x2 >> 32)]][1] ^ IT[13][S[(uint8)(x2 >> 40)]][1] ^ IT[14][S[(uint8)(x2 >> 48)]][1] ^ IT[15][S[(uint8)(x2 >> 56)]][1]; \ } #define ISI(val) { \ (val)[0] = IS[(val)[0]]; \ (val)[1] = IS[(val)[1]]; \ (val)[2] = IS[(val)[2]]; \ (val)[3] = IS[(val)[3]]; \ (val)[4] = IS[(val)[4]]; \ (val)[5] = IS[(val)[5]]; \ (val)[6] = IS[(val)[6]]; \ (val)[7] = IS[(val)[7]]; \ } #define F(k00,k01,k10,k11,i,o00,o01,o10,o11) { \ o10 = k00; \ o11 = k01; \ k00 ^= C[i][0]; \ k01 ^= C[i][1]; \ LS(k00, k01, o00, o01); \ o00 ^= k10; \ o01 ^= k11; \ } #define FK(k00,k01,k10,k11,ist) { \ for (i = 0; i < 8; i += 2) \ { \ F(k00, k01, k10, k11, i + ist, t00, t01, t10, t11); \ F(t00, t01, t10, t11, i + 1 + ist, k00, k01, k10, k11); \ } \ } - void kuznyechik_set_key(const byte* key, kuznyechik_kds* kds) + void kuznyechik_set_key(const uint8* key, kuznyechik_kds* kds) { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) if(HasSSE2()) { kuznyechik_set_key_simd (key, kds); } else #endif { int i; uint64 k00 = *(const uint64*)key; uint64 k01 = *(((const uint64*)key) + 1); uint64 k10 = *(((const uint64*)key) + 2); uint64 k11 = *(((const uint64*)key) + 3); uint64 t00, t01, t10, t11; kds->rke[0] = k00; kds->rke[1] = k01; kds->rke[2] = k10; kds->rke[3] = k11; FK(k00, k01, k10, k11, 0); kds->rke[4] = k00; kds->rke[5] = k01; kds->rke[6] = k10; kds->rke[7] = k11; FK(k00, k01, k10, k11, 8); kds->rke[8] = k00; kds->rke[9] = k01; kds->rke[10] = k10; kds->rke[11] = k11; FK(k00, k01, k10, k11, 16); kds->rke[12] = k00; kds->rke[13] = k01; kds->rke[14] = k10; kds->rke[15] = k11; FK(k00, k01, k10, k11, 24); kds->rke[16] = k00; kds->rke[17] = k01; kds->rke[18] = k10; kds->rke[19] = k11; kds->rkd[0] = kds->rke[0]; kds->rkd[1] = kds->rke[1]; for (i = 1; i < 10; i++) { uint64 t1 = kds->rke[2*i], t2 = kds->rke[2*i+1]; kds->rkd[2*i] = t1; kds->rkd[2*i + 1] = t2; ILSS(t1, t2, kds->rkd[2*i], kds->rkd[2*i+1]); } } #ifdef CPPCRYPTO_DEBUG for(int i = 0; i < 10; i++) printf("key[%d]: { 0x%016I64X, 0x%016I64X }\n", i, kds->rke[2*i], kds->rke[2*i+1]); #endif } - void kuznyechik_encrypt_block(byte* out, const byte* in, kuznyechik_kds* kds) + void kuznyechik_encrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds) { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) if(HasSSE2()) { kuznyechik_encrypt_block_simd (out, in, kds); } else #endif { uint64 x1 = *(const uint64*)in; uint64 x2 = *(((const uint64*)in)+1); uint64 t1, t2; x1 ^= kds->rke[0]; x2 ^= kds->rke[1]; LS(x1, x2, t1, t2); t1 ^= kds->rke[2]; t2 ^= kds->rke[3]; LS(t1, t2, x1, x2); x1 ^= kds->rke[4]; x2 ^= kds->rke[5]; LS(x1, x2, t1, t2); t1 ^= kds->rke[6]; t2 ^= kds->rke[7]; LS(t1, t2, x1, x2); x1 ^= kds->rke[8]; x2 ^= kds->rke[9]; LS(x1, x2, t1, t2); t1 ^= kds->rke[10]; t2 ^= kds->rke[11]; LS(t1, t2, x1, x2); x1 ^= kds->rke[12]; x2 ^= kds->rke[13]; LS(x1, x2, t1, t2); t1 ^= kds->rke[14]; t2 ^= kds->rke[15]; LS(t1, t2, x1, x2); x1 ^= kds->rke[16]; x2 ^= kds->rke[17]; LS(x1, x2, t1, t2); t1 ^= kds->rke[18]; t2 ^= kds->rke[19]; *(uint64*)out = t1; *(((uint64*)out) + 1) = t2; } } - void kuznyechik_encrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) + void kuznyechik_encrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds) { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER)) if(HasSSE2()) { kuznyechik_encrypt_blocks_simd (out, in, blocks, kds); } else #endif { while (blocks) { kuznyechik_encrypt_block (out, in, kds); in += 16; out += 16; blocks--; } } } - void kuznyechik_decrypt_block(byte* out, const byte* in, kuznyechik_kds* kds) + void kuznyechik_decrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds) { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (TC_WINDOWS_DRIVER) || (!defined (DEBUG) && defined (_WIN64))) if(HasSSE2()) { kuznyechik_decrypt_block_simd (out, in, kds); } else #endif { uint64 x1 = *(const uint64*)in; uint64 x2 = *(((const uint64*)in) + 1); uint64 t1, t2; ILSS(x1, x2, t1, t2); t1 ^= kds->rkd[18]; t2 ^= kds->rkd[19]; ILS(t1, t2, x1, x2); x1 ^= kds->rkd[16]; x2 ^= kds->rkd[17]; ILS(x1, x2, t1, t2); t1 ^= kds->rkd[14]; t2 ^= kds->rkd[15]; ILS(t1, t2, x1, x2); x1 ^= kds->rkd[12]; x2 ^= kds->rkd[13]; ILS(x1, x2, t1, t2); t1 ^= kds->rkd[10]; t2 ^= kds->rkd[11]; ILS(t1, t2, x1, x2); x1 ^= kds->rkd[8]; x2 ^= kds->rkd[9]; ILS(x1, x2, t1, t2); t1 ^= kds->rkd[6]; t2 ^= kds->rkd[7]; ILS(t1, t2, x1, x2); x1 ^= kds->rkd[4]; x2 ^= kds->rkd[5]; ILS(x1, x2, t1, t2); t1 ^= kds->rkd[2]; t2 ^= kds->rkd[3]; - ISI((byte*)&t1); - ISI((byte*)&t2); + ISI((uint8*)&t1); + ISI((uint8*)&t2); t1 ^= kds->rkd[0]; t2 ^= kds->rkd[1]; *(uint64*)out = t1; *(((uint64*)out) + 1) = t2; } } - void kuznyechik_decrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) + void kuznyechik_decrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds) { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(_UEFI) && (!defined (DEBUG) || !defined (TC_WINDOWS_DRIVER)) if(HasSSE2()) { kuznyechik_decrypt_blocks_simd (out, in, blocks, kds); } else #endif { while (blocks) { kuznyechik_decrypt_block (out, in, kds); in += 16; out += 16; blocks--; } } } #if 0 static inline uint8_t mul_gf(uint8_t x, uint8_t y, uint16_t p) { uint8_t r = 0; uint8_t hbit = 0; while (y) { if (y & 1) r ^= x; hbit = x & 0x80; x <<= 1; if (hbit == 0x80) x ^= p; diff --git a/src/Crypto/kuznyechik.h b/src/Crypto/kuznyechik.h index f0b45b64..05dc6e0e 100644 --- a/src/Crypto/kuznyechik.h +++ b/src/Crypto/kuznyechik.h @@ -1,35 +1,35 @@ /* This code is written by kerukuro for cppcrypto library (http://cppcrypto.sourceforge.net/) and released into public domain. */ /* Adapted to VeraCrypt */ #ifndef CPPCRYPTO_KUZNYECHIK_H #define CPPCRYPTO_KUZNYECHIK_H #include "Common/Tcdefs.h" #ifdef __cplusplus extern "C" { #endif typedef struct _kuznyechik_kds { uint64 rke[20]; uint64 rkd[20]; } kuznyechik_kds; #define KUZNYECHIK_KS (sizeof(kuznyechik_kds)) -void kuznyechik_encrypt_block(byte* out, const byte* in, kuznyechik_kds* kds); -void kuznyechik_encrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); -void kuznyechik_decrypt_block(byte* out, const byte* in, kuznyechik_kds* kds); -void kuznyechik_decrypt_blocks(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds); -void kuznyechik_set_key(const byte* key, kuznyechik_kds *kds); +void kuznyechik_encrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds); +void kuznyechik_encrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds); +void kuznyechik_decrypt_block(uint8* out, const uint8* in, kuznyechik_kds* kds); +void kuznyechik_decrypt_blocks(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds); +void kuznyechik_set_key(const uint8* key, kuznyechik_kds *kds); #ifdef __cplusplus } #endif #endif diff --git a/src/Crypto/kuznyechik_simd.c b/src/Crypto/kuznyechik_simd.c index 1c505db1..a7391908 100644 --- a/src/Crypto/kuznyechik_simd.c +++ b/src/Crypto/kuznyechik_simd.c @@ -9142,92 +9142,92 @@ VC_INLINE void scheduleDecryptionRoundKeysForGost15( #define ROUND_ENC_1x(round_) { \ temporary1_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data_ = _mm_xor_si128(data_, temporary1_); \ applyLSTransformation(data_); \ } #define ROUND_ENC_2x(round_) { \ temporary11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, temporary11_); \ data2_ = _mm_xor_si128(data2_, temporary11_); \ applyLSTransformation_2(data1_, data2_); \ } #define ROUND_ENC_3x(round_) { \ temporary11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, temporary11_); \ data2_ = _mm_xor_si128(data2_, temporary11_); \ data3_ = _mm_xor_si128(data3_, temporary11_); \ applyLSTransformation_3(data1_, data2_, data3_); \ } #define ROUND_ENC_4x(round_) { \ temporary11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, temporary11_); \ data2_ = _mm_xor_si128(data2_, temporary11_); \ data3_ = _mm_xor_si128(data3_, temporary11_); \ data4_ = _mm_xor_si128(data4_, temporary11_); \ applyLSTransformation_4(data1_, data2_, data3_,data4_); \ } -void kuznyechik_encrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds) +void kuznyechik_encrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds) { const uint_64t *roundKeys_ = (const uint_64t *) kds->rke; __m128i data_; __m128i temporary1_, temporary2_; __m128i addresses1_, addresses2_; int round_; data_ = _mm_loadu_si128((const __m128i*) in); #ifdef UNROLL_LOOPS ROUND_ENC_1x (0); ROUND_ENC_1x (1); ROUND_ENC_1x (2); ROUND_ENC_1x (3); ROUND_ENC_1x (4); ROUND_ENC_1x (5); ROUND_ENC_1x (6); ROUND_ENC_1x (7); ROUND_ENC_1x (8); round_ = 9; #else for (round_ = 0; round_ < 9; round_++) ROUND_ENC_1x (round_); #endif temporary1_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); data_ = _mm_xor_si128(data_, temporary1_); _mm_storeu_si128((__m128i*) out, data_); } -void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) +void kuznyechik_encrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds) { const uint_64t *roundKeys_ = (const uint_64t *) kds->rke; __m128i data1_, data2_, data3_, data4_; __m128i temporary11_, temporary12_; __m128i addresses11_, addresses12_; __m128i temporary21_, temporary22_; __m128i addresses21_, addresses22_; __m128i temporary31_, temporary32_; __m128i addresses31_, addresses32_; __m128i temporary41_, temporary42_; __m128i addresses41_, addresses42_; int round_; while (blocks >= 4) { data1_ = _mm_loadu_si128((const __m128i*) in); data2_ = _mm_loadu_si128((const __m128i*) (in + 16)); data3_ = _mm_loadu_si128((const __m128i*) (in + 32)); data4_ = _mm_loadu_si128((const __m128i*) (in + 48)); #ifdef UNROLL_LOOPS ROUND_ENC_4x (0); ROUND_ENC_4x (1); ROUND_ENC_4x (2); ROUND_ENC_4x (3); ROUND_ENC_4x (4); ROUND_ENC_4x (5); ROUND_ENC_4x (6); ROUND_ENC_4x (7); @@ -9320,97 +9320,97 @@ void kuznyechik_encrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku #define ROUND_DEC_1X(round_) { \ applyInversedLSTransformation(data_); \ cache1_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data_ = _mm_xor_si128(data_, cache1_); \ } #define ROUND_DEC_2X(round_) { \ applyInversedLSTransformation_2(data1_, data2_); \ cache11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, cache11_); \ data2_ = _mm_xor_si128(data2_, cache11_); \ } #define ROUND_DEC_3X(round_) { \ applyInversedLSTransformation_3(data1_, data2_,data3_); \ cache11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, cache11_); \ data2_ = _mm_xor_si128(data2_, cache11_); \ data3_ = _mm_xor_si128(data3_, cache11_); \ } #define ROUND_DEC_4X(round_) { \ applyInversedLSTransformation_4(data1_, data2_,data3_,data4_); \ cache11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[2 * round_]); \ data1_ = _mm_xor_si128(data1_, cache11_); \ data2_ = _mm_xor_si128(data2_, cache11_); \ data3_ = _mm_xor_si128(data3_, cache11_); \ data4_ = _mm_xor_si128(data4_, cache11_); \ } -void kuznyechik_decrypt_block_simd(byte* out, const byte* in, kuznyechik_kds* kds) +void kuznyechik_decrypt_block_simd(uint8* out, const uint8* in, kuznyechik_kds* kds) { const uint_64t *roundKeys_ = kds->rkd; __m128i data_; #ifndef UNROLL_LOOPS int round_; #endif block_t temporary_; int byteIndex_; __m128i cache1_, cache2_; __m128i addresses1_, addresses2_; data_ = _mm_loadu_si128((const __m128i*) in); applySTransformation(data_); #ifdef UNROLL_LOOPS ROUND_DEC_1X (9); ROUND_DEC_1X (8); ROUND_DEC_1X (7); ROUND_DEC_1X (6); ROUND_DEC_1X (5); ROUND_DEC_1X (4); ROUND_DEC_1X (3); ROUND_DEC_1X (2); ROUND_DEC_1X (1); #else for (round_ = NumberOfRounds - 1; round_ > 0; --round_) ROUND_DEC_1X(round_); #endif applyInversedSTransformation(data_); cache1_ = _mm_loadu_si128((const __m128i *) &roundKeys_[0]); data_ = _mm_xor_si128(data_, cache1_); _mm_storeu_si128((__m128i*) out, data_); } -void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, kuznyechik_kds* kds) +void kuznyechik_decrypt_blocks_simd(uint8* out, const uint8* in, size_t blocks, kuznyechik_kds* kds) { const uint_64t *roundKeys_ = kds->rkd; __m128i data1_, data2_,data3_,data4_; #ifndef UNROLL_LOOPS int round_; #endif block_t temporary1_; block_t temporary2_; block_t temporary3_; block_t temporary4_; int byteIndex_; __m128i cache11_, cache12_; __m128i cache21_, cache22_; __m128i cache31_, cache32_; __m128i cache41_, cache42_; __m128i addresses11_, addresses12_; __m128i addresses21_, addresses22_; __m128i addresses31_, addresses32_; __m128i addresses41_, addresses42_; while (blocks >= 4) { data1_ = _mm_loadu_si128((const __m128i*) in); data2_ = _mm_loadu_si128((const __m128i*) (in + 16)); data3_ = _mm_loadu_si128((const __m128i*) (in + 32)); data4_ = _mm_loadu_si128((const __m128i*) (in + 48)); applySTransformation_4(data1_, data2_,data3_,data4_); #ifdef UNROLL_LOOPS @@ -9481,37 +9481,37 @@ void kuznyechik_decrypt_blocks_simd(byte* out, const byte* in, size_t blocks, ku data2_ = _mm_loadu_si128((const __m128i*) (in + 16)); applySTransformation_2(data1_, data2_); #ifdef UNROLL_LOOPS ROUND_DEC_2X (9); ROUND_DEC_2X (8); ROUND_DEC_2X (7); ROUND_DEC_2X (6); ROUND_DEC_2X (5); ROUND_DEC_2X (4); ROUND_DEC_2X (3); ROUND_DEC_2X (2); ROUND_DEC_2X (1); #else for (round_ = NumberOfRounds - 1; round_ > 0; --round_) ROUND_DEC_2X(round_); #endif applyInversedSTransformation_2(data1_,data2_); cache11_ = _mm_loadu_si128((const __m128i *) &roundKeys_[0]); data1_ = _mm_xor_si128(data1_, cache11_); data2_ = _mm_xor_si128(data2_, cache11_); _mm_storeu_si128((__m128i*) out, data1_); _mm_storeu_si128((__m128i*) (out + 16), data2_); } else if (blocks) kuznyechik_decrypt_block_simd (out, in, kds); } -void kuznyechik_set_key_simd(const byte* key, kuznyechik_kds *kds) +void kuznyechik_set_key_simd(const uint8* key, kuznyechik_kds *kds) { scheduleEncryptionRoundKeysForGost15 (kds->rke, key); scheduleDecryptionRoundKeysForGost15 (kds->rkd, key); } #endif diff --git a/src/Crypto/misc.h b/src/Crypto/misc.h index 47d0288a..25313d1d 100644 --- a/src/Crypto/misc.h +++ b/src/Crypto/misc.h @@ -124,61 +124,61 @@ VC_INLINE uint32 ByteReverseWord32 (uint32 value) #elif _MSC_VER >= 1400 || (_MSC_VER >= 1300 && !defined(_DLL)) return _byteswap_ulong(value); #elif CRYPTOPP_FAST_ROTATE(32) // 5 instructions with rotate instruction, 9 without return (rotr32(value, 8U) & 0xff00ff00) | (rotl32(value, 8U) & 0x00ff00ff); #else // 6 instructions with rotate instruction, 8 without value = ((value & 0xFF00FF00) >> 8) | ((value & 0x00FF00FF) << 8); return rotl32(value, 16U); #endif } #ifndef TC_NO_COMPILER_INT64 VC_INLINE uint64 ByteReverseWord64(uint64 value) { #if defined(__GNUC__) && defined(CRYPTOPP_X86_ASM_AVAILABLE) && defined(__x86_64__) __asm__ ("bswap %0" : "=r" (value) : "0" (value)); return value; #elif defined(CRYPTOPP_BYTESWAP_AVAILABLE) return bswap_64(value); #elif defined(_MSC_VER) && _MSC_VER >= 1300 return _byteswap_uint64(value); #else value = ((value & LL(0xFF00FF00FF00FF00)) >> 8) | ((value & LL(0x00FF00FF00FF00FF)) << 8); value = ((value & LL(0xFFFF0000FFFF0000)) >> 16) | ((value & LL(0x0000FFFF0000FFFF)) << 16); return rotl64(value, 32U); #endif } -VC_INLINE void CorrectEndianess(uint64 *out, const uint64 *in, size_t byteCount) +VC_INLINE void CorrectEndianness(uint64 *out, const uint64 *in, size_t byteCount) { size_t i, count = byteCount/sizeof(uint64); for (i=0; i<count; i++) out[i] = ByteReverseWord64(in[i]); } #endif #ifdef CRYPTOPP_ALLOW_UNALIGNED_DATA_ACCESS #define GetAlignmentOf(T) 1 #elif (_MSC_VER >= 1300) #define GetAlignmentOf(T) __alignof(T) #elif defined(__GNUC__) #define GetAlignmentOf(T) __alignof__(T) #else #define GetAlignmentOf(T) sizeof(T) #endif #define IsPowerOf2(n) (((n) > 0) && (((n) & ((n)-1)) == 0)) #define ModPowerOf2(a,b) ((a) & ((b)-1)) #define IsAlignedOn(p,alignment) ((alignment==1) || (IsPowerOf2(alignment) ? ModPowerOf2((size_t)p, alignment) == 0 : (size_t)p % alignment == 0)) #define IsAligned16(p) IsAlignedOn(p, GetAlignmentOf(uint64)) #ifdef __cplusplus } #endif diff --git a/src/Crypto/rdrand.c b/src/Crypto/rdrand.c index afed7cd1..52f7f98e 100644 --- a/src/Crypto/rdrand.c +++ b/src/Crypto/rdrand.c @@ -1,32 +1,32 @@ // rdrand.cpp - written and placed in public domain by Jeffrey Walton and Uri Blumenthal. /* modified for VeraCrypt */ #include "chacha256.h" #include "cpu.h" #include "misc.h" -void CRYPTOPP_FASTCALL MASM_RDRAND_GenerateBlock(byte*, size_t); -void CRYPTOPP_FASTCALL MASM_RDSEED_GenerateBlock(byte*, size_t); +void CRYPTOPP_FASTCALL MASM_RDRAND_GenerateBlock(uint8*, size_t); +void CRYPTOPP_FASTCALL MASM_RDSEED_GenerateBlock(uint8*, size_t); int RDRAND_getBytes(unsigned char* buf, size_t bufLen) { if (!buf || !HasRDRAND()) return 0; if (bufLen) MASM_RDRAND_GenerateBlock(buf, bufLen); return 1; } int RDSEED_getBytes(unsigned char* buf, size_t bufLen) { if (!buf || !HasRDSEED()) return 0; if (bufLen) MASM_RDSEED_GenerateBlock(buf, bufLen); return 1; } diff --git a/src/Crypto/t1ha.h b/src/Crypto/t1ha.h index 97615b51..c32d07b5 100644 --- a/src/Crypto/t1ha.h +++ b/src/Crypto/t1ha.h @@ -156,61 +156,61 @@ * or just the one. So, this definitions allows disable corresponding parts * of t1ha library. * * // To disable t1ha0(), t1ha0_32le(), t1ha0_32be() and all AES-NI. * #define T1HA0_DISABLED * * // To disable t1ha1_le() and t1ha1_be(). * #define T1HA1_DISABLED * * // To disable t1ha2_atonce(), t1ha2_atonce128() and so on. * #define T1HA2_DISABLED * *****************************************************************************/ #define T1HA_VERSION_MAJOR 2 #define T1HA_VERSION_MINOR 1 #define T1HA_VERSION_RELEASE 0 #include "Common/Tcdefs.h" #include "config.h" #include "misc.h" #ifdef __cplusplus extern "C" { #endif #define T1HA_ALIGN_PREFIX CRYPTOPP_ALIGN_DATA(32) #define T1HA_ALIGN_SUFFIX #ifdef _MSC_VER -#define uint8_t byte +#define uint8_t uint8 #define uint16_t uint16 #define uint32_t uint32 #define uint64_t uint64 #endif typedef union T1HA_ALIGN_PREFIX t1ha_state256 { uint8_t bytes[32]; uint32_t u32[8]; uint64_t u64[4]; struct { uint64_t a, b, c, d; } n; } t1ha_state256_t T1HA_ALIGN_SUFFIX; typedef struct t1ha_context { t1ha_state256_t state; t1ha_state256_t buffer; size_t partial; uint64_t total; } t1ha_context_t; /****************************************************************************** * * t1ha2 = 64 and 128-bit, SLIGHTLY MORE ATTENTION FOR QUALITY AND STRENGTH. * * - The recommended version of "Fast Positive Hash" with good quality * for checksum, hash tables and fingerprinting. * - Portable and extremely efficiency on modern 64-bit CPUs. * Designed for 64-bit little-endian platforms, * in other cases will runs slowly. diff --git a/src/Crypto/wolfCrypt.c b/src/Crypto/wolfCrypt.c new file mode 100644 index 00000000..4a4946a6 --- /dev/null +++ b/src/Crypto/wolfCrypt.c @@ -0,0 +1,243 @@ +/* See src/Crypto/wolfCrypt.md */ + +#include "Aes.h" +#include "Sha2.h" +#include "../Common/Crypto.h" +#include <wolfssl/wolfcrypt/hmac.h> + + +AES_RETURN aes_init() +{ +#if defined( AES_ERR_CHK ) + return EXIT_SUCCESS; +#else + return; +#endif +} + +AES_RETURN aes_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) +{ + int ret = 0; + + ret = wc_AesInit(&cx->wc_enc_aes, NULL, INVALID_DEVID); + + if (key_len == 128 || key_len == 192 || key_len == 256) + key_len = key_len/8; + + if (ret == 0) { + ret = wc_AesSetKey(&cx->wc_enc_aes, key, key_len, NULL, AES_ENCRYPTION); + } + +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif +} + +AES_RETURN aes_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) +{ + int ret = 0; + + ret = wc_AesInit(&cx->wc_dec_aes, NULL, INVALID_DEVID); + + if (key_len == 128 || key_len == 192 || key_len == 256) + key_len = key_len/8; + + if (ret == 0) { + ret = wc_AesSetKey(&cx->wc_dec_aes, key, key_len, NULL, AES_DECRYPTION); + } + +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif +} + +AES_RETURN aes_encrypt_key128(const unsigned char *key, aes_encrypt_ctx cx[1]) +{ + return aes_encrypt_key(key, 128, cx); +} + +AES_RETURN aes_encrypt_key192(const unsigned char *key, aes_encrypt_ctx cx[1]) +{ + return aes_encrypt_key(key, 192, cx); +} + +AES_RETURN aes_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]) +{ + return aes_encrypt_key(key, 256, cx); +} + +AES_RETURN aes_decrypt_key128(const unsigned char *key, aes_decrypt_ctx cx[1]) +{ + return aes_decrypt_key(key, 128, cx); +} + +AES_RETURN aes_decrypt_key192(const unsigned char *key, aes_decrypt_ctx cx[1]) +{ + return aes_decrypt_key(key, 192, cx); +} + +AES_RETURN aes_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]) +{ + return aes_decrypt_key(key, 256, cx); +} + +AES_RETURN aes_encrypt(const unsigned char *in, unsigned char *out, const aes_encrypt_ctx cx[1]) +{ + int ret = wc_AesEncryptDirect(&cx->wc_enc_aes, out, in); +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif + +} + +AES_RETURN aes_decrypt(const unsigned char *in, unsigned char *out, const aes_decrypt_ctx cx[1]) +{ + int ret = wc_AesDecryptDirect(&cx->wc_dec_aes, out, in); +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif + +} + +AES_RETURN xts_encrypt_key(const unsigned char *key, int key_len, aes_encrypt_ctx cx[1]) +{ + int ret = 0; + + cx->wc_enc_xts.aes = cx->wc_enc_aes; + + ret = wc_AesInit(&cx->wc_enc_xts.tweak, NULL, INVALID_DEVID); + + if (key_len == 128 || key_len == 192 || key_len == 256) + key_len = key_len/8; + + if (ret == 0) { + ret = wc_AesSetKey(&cx->wc_enc_xts.tweak, key, key_len, NULL, AES_ENCRYPTION); + } +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif +} + +AES_RETURN xts_decrypt_key(const unsigned char *key, int key_len, aes_decrypt_ctx cx[1]) +{ + int ret = 0; + + cx->wc_dec_xts.aes = cx->wc_dec_aes; + + ret = wc_AesInit(&cx->wc_dec_xts.tweak, NULL, INVALID_DEVID); + + if (key_len == 128 || key_len == 192 || key_len == 256) + key_len = key_len/8; + + if (ret == 0) { + ret = wc_AesSetKey(&cx->wc_dec_xts.tweak, key, key_len, NULL, AES_ENCRYPTION); + } + +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif +} + +AES_RETURN xts_encrypt_key256(const unsigned char *key, aes_encrypt_ctx cx[1]) +{ + return xts_encrypt_key(key, 256, cx); +} + +AES_RETURN xts_decrypt_key256(const unsigned char *key, aes_decrypt_ctx cx[1]) +{ + return xts_decrypt_key(key, 256, cx); +} + +AES_RETURN xts_encrypt(const unsigned char *in, unsigned char *out, word64 length, word64 sector, const aes_encrypt_ctx cx[1]) +{ + int ret = wc_AesXtsEncryptConsecutiveSectors(&cx->wc_enc_xts, out, in, length, sector, ENCRYPTION_DATA_UNIT_SIZE); + +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif + +} + +AES_RETURN xts_decrypt(const unsigned char *in, unsigned char *out, word64 length, word64 sector, const aes_decrypt_ctx cx[1]) +{ + int ret = wc_AesXtsDecryptConsecutiveSectors(&cx->wc_dec_xts, out, in, length, sector, ENCRYPTION_DATA_UNIT_SIZE); + +#if defined( AES_ERR_CHK ) + return ret ? EXIT_FAILURE : EXIT_SUCCESS; +#else + return; +#endif +} + + +void sha256_begin(sha256_ctx* ctx) +{ + wc_InitSha256(ctx); +} + +void sha256_hash(const unsigned char * source, uint_32t sourceLen, sha256_ctx *ctx) +{ + wc_Sha256Update(ctx, source, sourceLen); +} + +void sha256_end(unsigned char * result, sha256_ctx* ctx) +{ + wc_Sha256Final(ctx, result); +} + +void sha256(unsigned char * result, const unsigned char* source, uint_32t sourceLen) +{ + wc_Sha256 sha256; + wc_InitSha256(&sha256); + wc_Sha256Update(&sha256, source, sourceLen); + wc_Sha256Final(&sha256, result); + wc_Sha256Free(&sha256); +} + +void sha512_begin(sha512_ctx* ctx) +{ + wc_InitSha512(ctx); +} + +void sha512_hash(const unsigned char * source, uint_64t sourceLen, sha512_ctx *ctx) +{ + wc_Sha512Update(ctx, source, sourceLen); +} + +void sha512_end(unsigned char * result, sha512_ctx* ctx) +{ + wc_Sha512Final(ctx, result); +} + +void sha512(unsigned char * result, const unsigned char* source, uint_64t sourceLen) +{ + wc_Sha512 sha512; + wc_InitSha512(&sha512); + wc_Sha512Update(&sha512, source, sourceLen); + wc_Sha512Final(&sha512, result); + wc_Sha512Free(&sha512); +} + +void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { + (void) iterations; + wc_HKDF(WC_SHA512, (uint8*)pwd, (word32)pwd_len, (uint8*)salt, (word32)salt_len, NULL, 0, (uint8*)dk, (word32)dklen); +} + +void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) { + (void) iterations; + wc_HKDF(WC_SHA256, (uint8*)pwd, (word32)pwd_len, (uint8*)salt, (word32)salt_len, NULL, 0, (uint8*)dk, (word32)dklen); +} diff --git a/src/Crypto/wolfCrypt.md b/src/Crypto/wolfCrypt.md new file mode 100644 index 00000000..32ccf242 --- /dev/null +++ b/src/Crypto/wolfCrypt.md @@ -0,0 +1,25 @@ +# wolfSSL as crypto provider for VeraCrypt + +[wolfCrypt](https://www.wolfssl.com/products/wolfcrypt/) is wolfSSL's cutting edge crypto engine and a +potential FIPS solution for users of VeraCrypt. Follow the steps below to setup VeraCrypt with wolfCrypt. + +## Building wolfSSL + +Clone wolfSSL and build it as shown below. + +``` +git clone https://github.com/wolfssl/wolfssl && cd wolfssl +./autogen.sh +./configure --enable-xts CFLAGS="-DNO_OLD_WC_NAMES" +make +sudo make install +``` + +## Building VeraCrypt with wolfSSL + +Build VeraCrypt with the `WOLFCRYPT` command line option. + +``` +make WXSTATIC=1 wxbuild && make WXSTATIC=1 clean && make WXSTATIC=1 WOLFCRYPT=1 && make WXSTATIC=1 WOLFCRYPT=1 package +``` + diff --git a/src/Driver/DriveFilter.c b/src/Driver/DriveFilter.c index 49d62126..6fda3c37 100644 --- a/src/Driver/DriveFilter.c +++ b/src/Driver/DriveFilter.c @@ -8,198 +8,198 @@ 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. */ #include "TCdefs.h" #include <ntddk.h> #include <ntddvol.h> #include <Ntstrsafe.h> #include "Cache.h" #include "Crc.h" #include "Crypto.h" #include "Apidrvr.h" #include "EncryptedIoQueue.h" #include "Common/Endian.h" #include "Ntdriver.h" #include "Ntvol.h" #include "Volumes.h" #include "VolumeFilter.h" #include "Wipe.h" #include "DriveFilter.h" #include "Boot/Windows/BootCommon.h" #include "cpu.h" #include "rdrand.h" #include "chachaRng.h" static BOOL DeviceFilterActive = FALSE; BOOL BootArgsValid = FALSE; BootArguments BootArgs; -byte* BootSecRegionData = NULL; +uint8* BootSecRegionData = NULL; uint32 BootSecRegionSize = 0; uint32 BootPkcs5 = 0; static uint64 BootLoaderArgsPtr; static BOOL BootDriveSignatureValid = FALSE; static KMUTEX MountMutex; static volatile BOOL BootDriveFound = FALSE; static DriveFilterExtension *BootDriveFilterExtension = NULL; static LARGE_INTEGER BootDriveLength; -static byte BootLoaderFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; +static uint8 BootLoaderFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]; static BOOL CrashDumpEnabled = FALSE; static BOOL HibernationEnabled = FALSE; static BOOL LegacyHibernationDriverFilterActive = FALSE; -static byte *HibernationWriteBuffer = NULL; +static uint8 *HibernationWriteBuffer = NULL; static MDL *HibernationWriteBufferMdl = NULL; static uint32 HibernationPreventionCount = 0; static BootEncryptionSetupRequest SetupRequest; static volatile BOOL SetupInProgress = FALSE; PKTHREAD EncryptionSetupThread = NULL; static volatile BOOL EncryptionSetupThreadAbortRequested; static KSPIN_LOCK SetupStatusSpinLock; static int64 SetupStatusEncryptedAreaEnd; static BOOL TransformWaitingForIdle; static NTSTATUS SetupResult; static WipeDecoySystemRequest WipeDecoyRequest; static volatile BOOL DecoySystemWipeInProgress = FALSE; static volatile BOOL DecoySystemWipeThreadAbortRequested; static KSPIN_LOCK DecoySystemWipeStatusSpinLock; static int64 DecoySystemWipedAreaEnd; PKTHREAD DecoySystemWipeThread = NULL; static NTSTATUS DecoySystemWipeResult; static uint64 BootArgsRegionsDefault[] = { EFI_BOOTARGS_REGIONS_DEFAULT }; static uint64 BootArgsRegionsEFI[] = { EFI_BOOTARGS_REGIONS_EFI }; NTSTATUS LoadBootArguments (BOOL bIsEfi) { NTSTATUS status = STATUS_UNSUCCESSFUL; PHYSICAL_ADDRESS bootArgsAddr; - byte *mappedBootArgs; - byte *mappedCryptoInfo = NULL; + uint8 *mappedBootArgs; + uint8 *mappedCryptoInfo = NULL; uint16 bootLoaderArgsIndex; uint64* BootArgsRegionsPtr = bIsEfi? BootArgsRegionsEFI : BootArgsRegionsDefault; size_t BootArgsRegionsCount = bIsEfi? sizeof(BootArgsRegionsEFI)/ sizeof(BootArgsRegionsEFI[0]) : sizeof(BootArgsRegionsDefault)/ sizeof(BootArgsRegionsDefault[0]); KeInitializeMutex (&MountMutex, 0); // __debugbreak(); for (bootLoaderArgsIndex = 0; bootLoaderArgsIndex < BootArgsRegionsCount && status != STATUS_SUCCESS; ++bootLoaderArgsIndex) { bootArgsAddr.QuadPart = BootArgsRegionsPtr[bootLoaderArgsIndex] + TC_BOOT_LOADER_ARGS_OFFSET; Dump ("Checking BootArguments at 0x%x\n", bootArgsAddr.LowPart); mappedBootArgs = MmMapIoSpace (bootArgsAddr, sizeof (BootArguments), MmCached); if (!mappedBootArgs) return STATUS_INSUFFICIENT_RESOURCES; if (TC_IS_BOOT_ARGUMENTS_SIGNATURE (mappedBootArgs)) { BootArguments *bootArguments = (BootArguments *) mappedBootArgs; Dump ("BootArguments found at 0x%x\n", bootArgsAddr.LowPart); DumpMem (mappedBootArgs, sizeof (BootArguments)); if (bootArguments->BootLoaderVersion == VERSION_NUM - && bootArguments->BootArgumentsCrc32 != GetCrc32 ((byte *) bootArguments, (int) ((byte *) &bootArguments->BootArgumentsCrc32 - (byte *) bootArguments))) + && bootArguments->BootArgumentsCrc32 != GetCrc32 ((uint8 *) bootArguments, (int) ((uint8 *) &bootArguments->BootArgumentsCrc32 - (uint8 *) bootArguments))) { Dump ("BootArguments CRC incorrect\n"); burn (mappedBootArgs, sizeof (BootArguments)); MmUnmapIoSpace (mappedBootArgs, sizeof (BootArguments)); mappedBootArgs = NULL; TC_BUG_CHECK (STATUS_CRC_ERROR); } // Sanity check: for valid boot argument, the password is less than 64 bytes long if (bootArguments->BootPassword.Length <= MAX_LEGACY_PASSWORD) { BootLoaderArgsPtr = BootArgsRegionsPtr[bootLoaderArgsIndex]; BootArgs = *bootArguments; BootArgsValid = TRUE; burn (bootArguments, sizeof (*bootArguments)); BootDriveSignatureValid = TRUE; Dump ("BootLoaderVersion = %x\n", (int) BootArgs.BootLoaderVersion); Dump ("HeaderSaltCrc32 = %x\n", (int) BootArgs.HeaderSaltCrc32); Dump ("CryptoInfoOffset = %x\n", (int) BootArgs.CryptoInfoOffset); Dump ("CryptoInfoLength = %d\n", (int) BootArgs.CryptoInfoLength); Dump ("HiddenSystemPartitionStart = %I64u\n", BootArgs.HiddenSystemPartitionStart); Dump ("DecoySystemPartitionStart = %I64u\n", BootArgs.DecoySystemPartitionStart); Dump ("Flags = %x\n", BootArgs.Flags); Dump ("BootDriveSignature = %x\n", BootArgs.BootDriveSignature); Dump ("BootArgumentsCrc32 = %x\n", BootArgs.BootArgumentsCrc32); // clear fingerprint burn (BootLoaderFingerprint, sizeof (BootLoaderFingerprint)); MmUnmapIoSpace (mappedBootArgs, sizeof (BootArguments)); mappedBootArgs = NULL; // Extra parameters? (pkcs5, hash) if (BootArgs.CryptoInfoLength > 0) { PHYSICAL_ADDRESS cryptoInfoAddress; cryptoInfoAddress.QuadPart = BootLoaderArgsPtr + BootArgs.CryptoInfoOffset; Dump ("CryptoInfo memory %x %d\n", cryptoInfoAddress.LowPart, BootArgs.CryptoInfoLength); mappedCryptoInfo = MmMapIoSpace (cryptoInfoAddress, BootArgs.CryptoInfoLength, MmCached); if (mappedCryptoInfo) { /* Get the parameters used for booting to speed up driver startup and avoid testing irrelevant PRFs */ BOOT_CRYPTO_HEADER* pBootCryptoInfo = (BOOT_CRYPTO_HEADER*) mappedCryptoInfo; BootPkcs5 = pBootCryptoInfo->pkcs5; // save hash to speed up boot. BootSecRegionData = NULL; BootSecRegionSize = 0; // SecRegion data? if(BootArgs.CryptoInfoLength > (sizeof(BOOT_CRYPTO_HEADER) + sizeof(SECREGION_BOOT_PARAMS)) ) { uint32 crc; PHYSICAL_ADDRESS SecRegionAddress; SECREGION_BOOT_PARAMS* SecRegionParams = (SECREGION_BOOT_PARAMS*) (mappedCryptoInfo + sizeof(BOOT_CRYPTO_HEADER) + 2); - byte *secRegionData = NULL; + uint8 *secRegionData = NULL; SecRegionAddress.QuadPart = SecRegionParams->Ptr; Dump ("SecRegion memory 0x%x %d\n", SecRegionAddress.LowPart, SecRegionParams->Size); // SecRegion correct? if( (SecRegionParams->Ptr != 0) && (SecRegionParams->Size > 0)) { - crc = GetCrc32((byte*)SecRegionParams, 12); + crc = GetCrc32((uint8*)SecRegionParams, 12); if(crc == SecRegionParams->Crc) { Dump ("SecRegion crc ok\n"); secRegionData = MmMapIoSpace (SecRegionAddress, SecRegionParams->Size, MmCached); if(secRegionData) { BootSecRegionData = TCalloc (SecRegionParams->Size); if(BootSecRegionData != NULL) { BootSecRegionSize = SecRegionParams->Size; memcpy(BootSecRegionData, secRegionData, SecRegionParams->Size); } burn (secRegionData, SecRegionParams->Size); MmUnmapIoSpace (secRegionData, SecRegionParams->Size); } } } } // Erase boot loader scheduled keys burn (mappedCryptoInfo, BootArgs.CryptoInfoLength); MmUnmapIoSpace (mappedCryptoInfo, BootArgs.CryptoInfoLength); BootArgs.CryptoInfoLength = 0; } else { BootArgs.CryptoInfoLength = 0; } } status = STATUS_SUCCESS; } else { Dump ("BootArguments contains a password larger than maximum limit\n"); @@ -302,61 +302,61 @@ static void DismountDrive (DriveFilterExtension *Extension, BOOL stopIoQueue) Extension->DriveMounted = FALSE; Dump ("Drive dismount done!\n"); } static void InvalidateVolumeKeys (EXTENSION *Extension) { Dump ("Invalidating volume encryption keys\n"); Extension->Queue.ThreadBlockReadWrite = TRUE; crypto_eraseKeys ((PCRYPTO_INFO) Extension->Queue.CryptoInfo); crypto_eraseKeys ((PCRYPTO_INFO) Extension->cryptoInfo); Dump ("Volume encryption keys invalidated!\n"); } static void InvalidateDriveFilterKeys (DriveFilterExtension *Extension) { Dump ("Invalidating drive filter encryption keys\n"); ASSERT (Extension->DriveMounted); Extension->Queue.ThreadBlockReadWrite = TRUE; crypto_eraseKeys ((PCRYPTO_INFO) Extension->Queue.CryptoInfo); crypto_eraseKeys ((PCRYPTO_INFO) Extension->HeaderCryptoInfo); Dump ("Drive filter encryption keys invalidated!\n"); } -static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, byte* ioBuffer /* ioBuffer must be at least 512 bytes long */) +static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, uint8* ioBuffer /* ioBuffer must be at least 512 bytes long */) { NTSTATUS status; LARGE_INTEGER offset; WHIRLPOOL_CTX whirlpool; sha512_ctx sha2; ULONG bytesToRead, remainingBytes, bootloaderTotalSize = TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE; // clear fingerprint burn (BootLoaderFingerprint, sizeof (BootLoaderFingerprint)); // compute Whirlpool+SHA512 fingerprint of bootloader including MBR // we skip user configuration fields: // TC_BOOT_SECTOR_PIM_VALUE_OFFSET = 400 // TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET = 402 // => TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE = 4 // TC_BOOT_SECTOR_USER_MESSAGE_OFFSET = 406 // => TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH = 24 // TC_BOOT_SECTOR_USER_CONFIG_OFFSET = 438 // // we have: TC_BOOT_SECTOR_USER_MESSAGE_OFFSET = TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE WHIRLPOOL_init (&whirlpool); sha512_begin (&sha2); // read the first 512 bytes offset.QuadPart = 0; status = TCReadDevice (LowerDeviceObject, ioBuffer, offset, TC_SECTOR_SIZE_BIOS); if (NT_SUCCESS (status)) { NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; @@ -406,87 +406,87 @@ static void ComputeBootLoaderFingerprint(PDEVICE_OBJECT LowerDeviceObject, byte* if (NT_SUCCESS (saveStatus)) #ifdef _WIN64 KeRestoreExtendedProcessorStateVC(&SaveState); #else KeRestoreFloatingPointState (&floatingPointState); #endif } else { Dump ("TCReadDevice error %x during ComputeBootLoaderFingerprint call\n", status); } } static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, uint32 *headerSaltCrc32) { BOOL hiddenVolume = (BootArgs.HiddenSystemPartitionStart != 0); int64 hiddenHeaderOffset = BootArgs.HiddenSystemPartitionStart + TC_HIDDEN_VOLUME_HEADER_OFFSET; NTSTATUS status; LARGE_INTEGER offset; char *header; int pkcs5_prf = 0, pim = 0; PARTITION_INFORMATION_EX pi; BOOL bIsGPT = FALSE; Dump ("MountDrive pdo=%p\n", Extension->Pdo); ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL); // Check disk MBR id and GPT ID if BootSecRegion is available to detect boot drive if (BootSecRegionData != NULL && BootSecRegionSize >= 1024) { - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; DCS_DISK_ENTRY_LIST* DeList = (DCS_DISK_ENTRY_LIST*)(BootSecRegionData + 512); offset.QuadPart = 0; status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS); if (NT_SUCCESS (status) && DeList->DE[DE_IDX_DISKID].DiskId.MbrID != *(uint32 *) (mbr + 0x1b8)) return STATUS_UNSUCCESSFUL; offset.QuadPart = 512; status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS); if (NT_SUCCESS (status) && memcmp(&DeList->DE[DE_IDX_DISKID].DiskId.GptID, mbr + 0x38, sizeof(DCS_GUID)) != 0) return STATUS_UNSUCCESSFUL; header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); if (!header) return STATUS_INSUFFICIENT_RESOURCES; // Copy header from SecRegion instead of read from disk memcpy(header, BootSecRegionData, 512); // Set SecRegion data for the disk (sectors to substitute to hide GPT table) Extension->Queue.SecRegionData = BootSecRegionData; Extension->Queue.SecRegionSize = BootSecRegionSize; } else { // Check boot drive signature first (header CRC search could fail if a user restored the header to a non-boot drive) if (BootDriveSignatureValid) { - byte mbr[TC_SECTOR_SIZE_BIOS]; + uint8 mbr[TC_SECTOR_SIZE_BIOS]; offset.QuadPart = 0; status = TCReadDevice (Extension->LowerDeviceObject, mbr, offset, TC_SECTOR_SIZE_BIOS); if (NT_SUCCESS (status) && BootArgs.BootDriveSignature != *(uint32 *) (mbr + 0x1b8)) return STATUS_UNSUCCESSFUL; } header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); if (!header) return STATUS_INSUFFICIENT_RESOURCES; offset.QuadPart = hiddenVolume ? hiddenHeaderOffset : TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET; Dump ("Reading volume header at %I64u\n", offset.QuadPart); status = TCReadDevice (Extension->LowerDeviceObject, header, offset, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); if (!NT_SUCCESS (status)) { Dump ("TCReadDevice error %x\n", status); goto ret; } Extension->Queue.SecRegionData = NULL; Extension->Queue.SecRegionSize = 0; } if (headerSaltCrc32) { uint32 saltCrc = GetCrc32 (header, PKCS5_SALT_SIZE); if (saltCrc != *headerSaltCrc32) @@ -495,124 +495,130 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, goto ret; } Extension->VolumeHeaderSaltCrc32 = saltCrc; } Extension->HeaderCryptoInfo = crypto_open(); if (!Extension->HeaderCryptoInfo) { status = STATUS_INSUFFICIENT_RESOURCES; goto ret; } if (NT_SUCCESS(SendDeviceIoControlRequest (Extension->LowerDeviceObject, IOCTL_DISK_GET_PARTITION_INFO_EX, NULL, 0, &pi, sizeof (pi)))) { bIsGPT = (pi.PartitionStyle == PARTITION_STYLE_GPT)? TRUE : FALSE; } if (BootPkcs5 > 0) { /* Get the parameters used for booting to speed up driver startup and avoid testing irrelevant PRFs */ Hash* pHash = HashGet(BootPkcs5); if (pHash && (bIsGPT || pHash->SystemEncryption)) pkcs5_prf = BootPkcs5; } pim = (int) (BootArgs.Flags >> 16); if (ReadVolumeHeader (!hiddenVolume, header, password, pkcs5_prf, pim, &Extension->Queue.CryptoInfo, Extension->HeaderCryptoInfo) == 0) { - // Header decrypted + // Header decrypted status = STATUS_SUCCESS; Dump ("Header decrypted\n"); + if (Extension->HeaderCryptoInfo->bVulnerableMasterKey) + { + // The volume header master key is vulnerable + Dump ("The volume header master key is vulnerable\n"); + } + // calculate Fingerprint ComputeBootLoaderFingerprint (Extension->LowerDeviceObject, header); if (Extension->Queue.CryptoInfo->hiddenVolume) { int64 hiddenPartitionOffset = BootArgs.HiddenSystemPartitionStart; Dump ("Hidden volume start offset = %I64d\n", Extension->Queue.CryptoInfo->EncryptedAreaStart.Value + hiddenPartitionOffset); Extension->HiddenSystem = TRUE; Extension->Queue.RemapEncryptedArea = TRUE; Extension->Queue.RemappedAreaOffset = hiddenPartitionOffset + Extension->Queue.CryptoInfo->EncryptedAreaStart.Value - BootArgs.DecoySystemPartitionStart; Extension->Queue.RemappedAreaDataUnitOffset = Extension->Queue.CryptoInfo->EncryptedAreaStart.Value / ENCRYPTION_DATA_UNIT_SIZE - BootArgs.DecoySystemPartitionStart / ENCRYPTION_DATA_UNIT_SIZE; Extension->Queue.CryptoInfo->EncryptedAreaStart.Value = BootArgs.DecoySystemPartitionStart; if (Extension->Queue.CryptoInfo->VolumeSize.Value > hiddenPartitionOffset - BootArgs.DecoySystemPartitionStart) { // we have already erased boot loader scheduled keys TC_THROW_FATAL_EXCEPTION; } Dump ("RemappedAreaOffset = %I64d\n", Extension->Queue.RemappedAreaOffset); Dump ("RemappedAreaDataUnitOffset = %I64d\n", Extension->Queue.RemappedAreaDataUnitOffset); } else { Extension->HiddenSystem = FALSE; Extension->Queue.RemapEncryptedArea = FALSE; } Extension->ConfiguredEncryptedAreaStart = Extension->Queue.CryptoInfo->EncryptedAreaStart.Value; Extension->ConfiguredEncryptedAreaEnd = Extension->Queue.CryptoInfo->EncryptedAreaStart.Value + Extension->Queue.CryptoInfo->VolumeSize.Value - 1; Extension->Queue.EncryptedAreaStart = Extension->Queue.CryptoInfo->EncryptedAreaStart.Value; Extension->Queue.EncryptedAreaEnd = Extension->Queue.CryptoInfo->EncryptedAreaStart.Value + Extension->Queue.CryptoInfo->EncryptedAreaLength.Value - 1; if (Extension->Queue.CryptoInfo->EncryptedAreaLength.Value == 0) { Extension->Queue.EncryptedAreaStart = -1; Extension->Queue.EncryptedAreaEnd = -1; } Dump ("Loaded: ConfiguredEncryptedAreaStart=%I64d (%I64d) ConfiguredEncryptedAreaEnd=%I64d (%I64d)\n", Extension->ConfiguredEncryptedAreaStart / 1024 / 1024, Extension->ConfiguredEncryptedAreaStart, Extension->ConfiguredEncryptedAreaEnd / 1024 / 1024, Extension->ConfiguredEncryptedAreaEnd); Dump ("Loaded: EncryptedAreaStart=%I64d (%I64d) EncryptedAreaEnd=%I64d (%I64d)\n", Extension->Queue.EncryptedAreaStart / 1024 / 1024, Extension->Queue.EncryptedAreaStart, Extension->Queue.EncryptedAreaEnd / 1024 / 1024, Extension->Queue.EncryptedAreaEnd); // at this stage, we have already erased boot loader scheduled keys BootDriveFilterExtension = Extension; BootDriveFound = Extension->BootDrive = Extension->DriveMounted = Extension->VolumeHeaderPresent = TRUE; BootDriveFilterExtension->MagicNumber = TC_BOOT_DRIVE_FILTER_EXTENSION_MAGIC_NUMBER; // Try to load password cached if saved in SecRegion if (BootSecRegionData != NULL && BootSecRegionSize > 1024) { DCS_DISK_ENTRY_LIST* DeList = (DCS_DISK_ENTRY_LIST*)(BootSecRegionData + 512); uint32 crc; uint32 crcSaved; crcSaved = DeList->CRC32; DeList->CRC32 = 0; - crc = GetCrc32((byte*)DeList, 512); + crc = GetCrc32((uint8*)DeList, 512); if(crc == crcSaved){ if(DeList->DE[DE_IDX_PWDCACHE].Type == DE_PwdCache) { uint64 sector = 0; DCS_DEP_PWD_CACHE* pwdCache = (DCS_DEP_PWD_CACHE*)(BootSecRegionData + DeList->DE[DE_IDX_PWDCACHE].Sectors.Offset); DecryptDataUnits((unsigned char*)pwdCache, (UINT64_STRUCT*)§or, 1, Extension->Queue.CryptoInfo); crcSaved = pwdCache->CRC; pwdCache->CRC = 0; crc = GetCrc32((unsigned char*)pwdCache, 512); if(crcSaved == crc && pwdCache->Count < CACHE_SIZE){ uint32 i; for(i = 0; i<pwdCache->Count; ++i){ if (CacheBootPassword && pwdCache->Pwd[i].Length > 0) { int cachedPim = CacheBootPim? (int) (pwdCache->Pim[i]) : 0; AddLegacyPasswordToCache (&pwdCache->Pwd[i], cachedPim); } } burn(pwdCache, sizeof(*pwdCache)); } } } } if (CacheBootPassword && BootArgs.BootPassword.Length > 0) { int cachedPim = CacheBootPim? pim : 0; AddLegacyPasswordToCache (&BootArgs.BootPassword, cachedPim); } burn (&BootArgs.BootPassword, sizeof (BootArgs.BootPassword)); @@ -669,92 +675,92 @@ static NTSTATUS MountDrive (DriveFilterExtension *Extension, Password *password, } else if (!LegacyHibernationDriverFilterActive) StartLegacyHibernationDriverFilter(); // Hidden system hibernation is not supported if an extra boot partition is present as the system is not allowed to update the boot partition if (IsHiddenSystemRunning() && (BootArgs.Flags & TC_BOOT_ARGS_FLAG_EXTRA_BOOT_PARTITION)) { CrashDumpEnabled = FALSE; HibernationEnabled = FALSE; } } else { Dump ("Header not decrypted\n"); crypto_close (Extension->HeaderCryptoInfo); Extension->HeaderCryptoInfo = NULL; status = STATUS_UNSUCCESSFUL; } ret: TCfree (header); return status; } static NTSTATUS SaveDriveVolumeHeader (DriveFilterExtension *Extension) { NTSTATUS status = STATUS_SUCCESS; LARGE_INTEGER offset; - byte *header; + uint8 *header; header = TCalloc (TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); if (!header) return STATUS_INSUFFICIENT_RESOURCES; offset.QuadPart = TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET; status = TCReadDevice (Extension->LowerDeviceObject, header, offset, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); if (!NT_SUCCESS (status)) { Dump ("TCReadDevice error %x", status); goto ret; } Dump ("Saving: ConfiguredEncryptedAreaStart=%I64d (%I64d) ConfiguredEncryptedAreaEnd=%I64d (%I64d)\n", Extension->ConfiguredEncryptedAreaStart / 1024 / 1024, Extension->ConfiguredEncryptedAreaStart, Extension->ConfiguredEncryptedAreaEnd / 1024 / 1024, Extension->ConfiguredEncryptedAreaEnd); Dump ("Saving: EncryptedAreaStart=%I64d (%I64d) EncryptedAreaEnd=%I64d (%I64d)\n", Extension->Queue.EncryptedAreaStart / 1024 / 1024, Extension->Queue.EncryptedAreaStart, Extension->Queue.EncryptedAreaEnd / 1024 / 1024, Extension->Queue.EncryptedAreaEnd); if (Extension->Queue.EncryptedAreaStart == -1 || Extension->Queue.EncryptedAreaEnd == -1 || Extension->Queue.EncryptedAreaEnd <= Extension->Queue.EncryptedAreaStart) { if (SetupRequest.SetupMode == SetupDecryption) { memset (header, 0, TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE); Extension->VolumeHeaderPresent = FALSE; } } else { uint32 headerCrc32; uint64 encryptedAreaLength = Extension->Queue.EncryptedAreaEnd + 1 - Extension->Queue.EncryptedAreaStart; - byte *fieldPos = header + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH; + uint8 *fieldPos = header + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH; PCRYPTO_INFO pCryptoInfo = Extension->HeaderCryptoInfo; #ifdef _WIN64 CRYPTO_INFO tmpCI; if (IsRamEncryptionEnabled()) { memcpy (&tmpCI, pCryptoInfo, sizeof (CRYPTO_INFO)); VcUnprotectKeys (&tmpCI, VcGetEncryptionID (pCryptoInfo)); pCryptoInfo = &tmpCI; } #endif DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); if (GetHeaderField32 (header, TC_HEADER_OFFSET_MAGIC) != 0x56455241) { Dump ("Header not decrypted"); status = STATUS_UNKNOWN_REVISION; goto ret; } mputInt64 (fieldPos, encryptedAreaLength); headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); fieldPos = header + TC_HEADER_OFFSET_HEADER_CRC; mputLong (fieldPos, headerCrc32); EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); #ifdef _WIN64 if (IsRamEncryptionEnabled()) { @@ -1207,89 +1213,89 @@ void ReopenBootVolumeHeader (PIRP irp, PIO_STACK_LOCATION irpSp) BootDriveFilterExtension->Queue.CryptoInfo->pkcs5 = BootDriveFilterExtension->HeaderCryptoInfo->pkcs5; BootDriveFilterExtension->Queue.CryptoInfo->noIterations = BootDriveFilterExtension->HeaderCryptoInfo->noIterations; BootDriveFilterExtension->Queue.CryptoInfo->volumePim = BootDriveFilterExtension->HeaderCryptoInfo->volumePim; irp->IoStatus.Status = STATUS_SUCCESS; } else { crypto_close (BootDriveFilterExtension->HeaderCryptoInfo); BootDriveFilterExtension->HeaderCryptoInfo = NULL; Dump ("Header not reopened\n"); irp->IoStatus.Status = STATUS_INVALID_PARAMETER; } ret: TCfree (header); wipe: burn (request, sizeof (*request)); } // Legacy Windows XP/2003 hibernation dump filter typedef NTSTATUS (*HiberDriverWriteFunctionA) (ULONG arg0, PLARGE_INTEGER writeOffset, PMDL dataMdl, PVOID arg3); typedef NTSTATUS (*HiberDriverWriteFunctionB) (PLARGE_INTEGER writeOffset, PMDL dataMdl); typedef struct { #ifdef _WIN64 - byte FieldPad1[64]; + uint8 FieldPad1[64]; HiberDriverWriteFunctionB WriteFunctionB; - byte FieldPad2[56]; + uint8 FieldPad2[56]; #else - byte FieldPad1[48]; + uint8 FieldPad1[48]; HiberDriverWriteFunctionB WriteFunctionB; - byte FieldPad2[32]; + uint8 FieldPad2[32]; #endif HiberDriverWriteFunctionA WriteFunctionA; - byte FieldPad3[24]; + uint8 FieldPad3[24]; LARGE_INTEGER PartitionStartOffset; } HiberDriverContext; typedef NTSTATUS (*HiberDriverEntry) (PVOID arg0, HiberDriverContext *hiberDriverContext); typedef struct { LIST_ENTRY ModuleList; #ifdef _WIN64 - byte FieldPad1[32]; + uint8 FieldPad1[32]; #else - byte FieldPad1[16]; + uint8 FieldPad1[16]; #endif PVOID ModuleBaseAddress; HiberDriverEntry ModuleEntryAddress; #ifdef _WIN64 - byte FieldPad2[24]; + uint8 FieldPad2[24]; #else - byte FieldPad2[12]; + uint8 FieldPad2[12]; #endif UNICODE_STRING ModuleName; } ModuleTableItem; #define TC_MAX_HIBER_FILTER_COUNT 3 static int LastHiberFilterNumber = 0; static HiberDriverEntry OriginalHiberDriverEntries[TC_MAX_HIBER_FILTER_COUNT]; static HiberDriverWriteFunctionA OriginalHiberDriverWriteFunctionsA[TC_MAX_HIBER_FILTER_COUNT]; static HiberDriverWriteFunctionB OriginalHiberDriverWriteFunctionsB[TC_MAX_HIBER_FILTER_COUNT]; static LARGE_INTEGER HiberPartitionOffset; static NTSTATUS HiberDriverWriteFunctionFilter (int filterNumber, PLARGE_INTEGER writeOffset, PMDL dataMdl, BOOL writeB, ULONG arg0WriteA, PVOID arg3WriteA) { MDL *encryptedDataMdl = dataMdl; if (writeOffset && dataMdl && BootDriveFilterExtension && BootDriveFilterExtension->DriveMounted) { ULONG dataLength = MmGetMdlByteCount (dataMdl); if (dataMdl->MappedSystemVa && dataLength > 0) { uint64 offset = HiberPartitionOffset.QuadPart + writeOffset->QuadPart; uint64 intersectStart; uint32 intersectLength; if (dataLength > TC_HIBERNATION_WRITE_BUFFER_SIZE) @@ -1545,72 +1551,72 @@ void StartLegacyHibernationDriverFilter () err: LegacyHibernationDriverFilterActive = FALSE; CrashDumpEnabled = FALSE; HibernationEnabled = FALSE; if (HibernationWriteBufferMdl) { IoFreeMdl (HibernationWriteBufferMdl); HibernationWriteBufferMdl = NULL; } if (HibernationWriteBuffer) { MmFreeContiguousMemory (HibernationWriteBuffer); HibernationWriteBuffer = NULL; } } static VOID SetupThreadProc (PVOID threadArg) { DriveFilterExtension *Extension = BootDriveFilterExtension; LARGE_INTEGER offset; UINT64_STRUCT dataUnit; ULONG setupBlockSize = TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE; BOOL headerUpdateRequired = FALSE; int64 bytesWrittenSinceHeaderUpdate = 0; - byte *buffer = NULL; - byte *wipeBuffer = NULL; - byte wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; - byte wipeRandCharsUpdate[TC_WIPE_RAND_CHAR_COUNT]; + uint8 *buffer = NULL; + uint8 *wipeBuffer = NULL; + uint8 wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; + uint8 wipeRandCharsUpdate[TC_WIPE_RAND_CHAR_COUNT]; KIRQL irql; NTSTATUS status; // generate real random values for wipeRandChars and // wipeRandCharsUpdate instead of relying on uninitialized stack memory ChaCha20RngCtx rngCtx; - byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; + uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ]; GetDriverRandomSeed (pbSeed, sizeof (pbSeed)); ChaCha20RngInit (&rngCtx, pbSeed, GetDriverRandomSeed, 0); ChaCha20RngGetBytes (&rngCtx, wipeRandChars, TC_WIPE_RAND_CHAR_COUNT); ChaCha20RngGetBytes (&rngCtx, wipeRandCharsUpdate, TC_WIPE_RAND_CHAR_COUNT); burn (&rngCtx, sizeof (rngCtx)); FAST_ERASE64 (pbSeed, sizeof (pbSeed)); SetupResult = STATUS_UNSUCCESSFUL; // Make sure volume header can be updated if (Extension->HeaderCryptoInfo == NULL) { SetupResult = STATUS_INVALID_PARAMETER; goto ret; } buffer = TCalloc (TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE); if (!buffer) { SetupResult = STATUS_INSUFFICIENT_RESOURCES; goto ret; } if (SetupRequest.SetupMode == SetupEncryption && SetupRequest.WipeAlgorithm != TC_WIPE_NONE) { wipeBuffer = TCalloc (TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE); if (!wipeBuffer) @@ -1730,61 +1736,61 @@ static VOID SetupThreadProc (PVOID threadArg) goto err; } } else if (SetupRequest.DiscardUnreadableEncryptedSectors && SetupRequest.SetupMode == SetupDecryption) { // Discard unreadable encrypted sectors uint64 badSectorCount; status = ReadDeviceSkipUnreadableSectors (BootDriveFilterExtension->LowerDeviceObject, buffer, offset, setupBlockSize, &badSectorCount); if (!NT_SUCCESS (status)) { SetupResult = status; goto err; } } else { SetupResult = status; goto err; } } dataUnit.Value = offset.QuadPart / ENCRYPTION_DATA_UNIT_SIZE; if (SetupRequest.SetupMode == SetupEncryption) { EncryptDataUnits (buffer, &dataUnit, setupBlockSize / ENCRYPTION_DATA_UNIT_SIZE, Extension->Queue.CryptoInfo); if (SetupRequest.WipeAlgorithm != TC_WIPE_NONE) { - byte wipePass; + uint8 wipePass; int wipePassCount = GetWipePassCount (SetupRequest.WipeAlgorithm); if (wipePassCount <= 0) { SetupResult = STATUS_INVALID_PARAMETER; goto err; } for (wipePass = 1; wipePass <= wipePassCount; ++wipePass) { if (!WipeBuffer (SetupRequest.WipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, setupBlockSize)) { ULONG i; for (i = 0; i < setupBlockSize; ++i) { wipeBuffer[i] = buffer[i] + wipePass; } EncryptDataUnits (wipeBuffer, &dataUnit, setupBlockSize / ENCRYPTION_DATA_UNIT_SIZE, Extension->Queue.CryptoInfo); memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate)); } status = TCWriteDevice (BootDriveFilterExtension->LowerDeviceObject, wipeBuffer, offset, setupBlockSize); if (!NT_SUCCESS (status)) { // Undo failed write operation DecryptDataUnits (buffer, &dataUnit, setupBlockSize / ENCRYPTION_DATA_UNIT_SIZE, Extension->Queue.CryptoInfo); TCWriteDevice (BootDriveFilterExtension->LowerDeviceObject, buffer, offset, setupBlockSize); SetupResult = status; goto err; @@ -1990,60 +1996,61 @@ void GetBootEncryptionStatus (PIRP irp, PIO_STACK_LOCATION irpSp) if (ValidateIOBufferSize (irp, sizeof (BootEncryptionStatus), ValidateOutput)) { DriveFilterExtension *Extension = BootDriveFilterExtension; BootEncryptionStatus *bootEncStatus = (BootEncryptionStatus *) irp->AssociatedIrp.SystemBuffer; memset (bootEncStatus, 0, sizeof (*bootEncStatus)); if (BootArgsValid) bootEncStatus->BootLoaderVersion = BootArgs.BootLoaderVersion; bootEncStatus->DeviceFilterActive = DeviceFilterActive; bootEncStatus->SetupInProgress = SetupInProgress; bootEncStatus->SetupMode = SetupRequest.SetupMode; bootEncStatus->TransformWaitingForIdle = TransformWaitingForIdle; if (!BootDriveFound || !Extension || !Extension->DriveMounted) { bootEncStatus->DriveEncrypted = FALSE; bootEncStatus->DriveMounted = FALSE; bootEncStatus->VolumeHeaderPresent = FALSE; } else { bootEncStatus->DriveMounted = Extension->DriveMounted; bootEncStatus->VolumeHeaderPresent = Extension->VolumeHeaderPresent; bootEncStatus->DriveEncrypted = Extension->Queue.EncryptedAreaStart != -1; bootEncStatus->BootDriveLength = BootDriveLength; bootEncStatus->ConfiguredEncryptedAreaStart = Extension->ConfiguredEncryptedAreaStart; bootEncStatus->ConfiguredEncryptedAreaEnd = Extension->ConfiguredEncryptedAreaEnd; bootEncStatus->EncryptedAreaStart = Extension->Queue.EncryptedAreaStart; + bootEncStatus->MasterKeyVulnerable = Extension->HeaderCryptoInfo->bVulnerableMasterKey; if (SetupInProgress) { KIRQL irql; KeAcquireSpinLock (&SetupStatusSpinLock, &irql); bootEncStatus->EncryptedAreaEnd = SetupStatusEncryptedAreaEnd; KeReleaseSpinLock (&SetupStatusSpinLock, irql); } else bootEncStatus->EncryptedAreaEnd = Extension->Queue.EncryptedAreaEnd; bootEncStatus->VolumeHeaderSaltCrc32 = Extension->VolumeHeaderSaltCrc32; bootEncStatus->HibernationPreventionCount = HibernationPreventionCount; bootEncStatus->HiddenSysLeakProtectionCount = HiddenSysLeakProtectionCount; bootEncStatus->HiddenSystem = Extension->HiddenSystem; if (Extension->HiddenSystem) bootEncStatus->HiddenSystemPartitionStart = BootArgs.HiddenSystemPartitionStart; } irp->IoStatus.Information = sizeof (BootEncryptionStatus); irp->IoStatus.Status = STATUS_SUCCESS; } } void GetBootLoaderVersion (PIRP irp, PIO_STACK_LOCATION irpSp) { if (ValidateIOBufferSize (irp, sizeof (uint16), ValidateOutput)) @@ -2166,63 +2173,63 @@ CRYPTO_INFO *GetSystemDriveCryptoInfo () return BootDriveFilterExtension->Queue.CryptoInfo; } NTSTATUS AbortBootEncryptionSetup () { if (!IoIsSystemThread (PsGetCurrentThread()) && !UserCanAccessDriveDevice()) return STATUS_ACCESS_DENIED; if (EncryptionSetupThread) { EncryptionSetupThreadAbortRequested = TRUE; TCStopThread (EncryptionSetupThread, NULL); EncryptionSetupThread = NULL; } return STATUS_SUCCESS; } static VOID DecoySystemWipeThreadProc (PVOID threadArg) { DriveFilterExtension *Extension = BootDriveFilterExtension; LARGE_INTEGER offset; UINT64_STRUCT dataUnit; ULONG wipeBlockSize = TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE; CRYPTO_INFO *wipeCryptoInfo = NULL; - byte *wipeBuffer = NULL; - byte *wipeRandBuffer = NULL; - byte wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; + uint8 *wipeBuffer = NULL; + uint8 *wipeRandBuffer = NULL; + uint8 wipeRandChars[TC_WIPE_RAND_CHAR_COUNT]; int wipePass, wipePassCount; int ea = Extension->Queue.CryptoInfo->ea; KIRQL irql; NTSTATUS status; DecoySystemWipeResult = STATUS_UNSUCCESSFUL; wipeBuffer = TCalloc (TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE); if (!wipeBuffer) { DecoySystemWipeResult = STATUS_INSUFFICIENT_RESOURCES; goto ret; } wipeRandBuffer = TCalloc (TC_ENCRYPTION_SETUP_IO_BLOCK_SIZE); if (!wipeRandBuffer) { DecoySystemWipeResult = STATUS_INSUFFICIENT_RESOURCES; goto ret; } wipeCryptoInfo = crypto_open(); if (!wipeCryptoInfo) { DecoySystemWipeResult = STATUS_INSUFFICIENT_RESOURCES; goto ret; } wipeCryptoInfo->ea = ea; diff --git a/src/Driver/Driver.rc b/src/Driver/Driver.rc index 41452157..bf3481b8 100644 --- a/src/Driver/Driver.rc +++ b/src/Driver/Driver.rc @@ -1,82 +1,82 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "afxres.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,13,0 + PRODUCTVERSION 1,26,13,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x3L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Driver" - VALUE "FileVersion", "1.26" + VALUE "FileVersion", "1.26.13" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "veracrypt.sys" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26" + VALUE "ProductVersion", "1.26.13" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "\r\n" "\0" diff --git a/src/Driver/DumpFilter.c b/src/Driver/DumpFilter.c index 725a4fe0..aa059d9d 100644 --- a/src/Driver/DumpFilter.c +++ b/src/Driver/DumpFilter.c @@ -1,51 +1,51 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "DumpFilter.h" #include "DriveFilter.h" #include "Ntdriver.h" #include "Tests.h" #include "cpu.h" static DriveFilterExtension *BootDriveFilterExtension = NULL; static LARGE_INTEGER DumpPartitionOffset; -static byte *WriteFilterBuffer = NULL; +static uint8 *WriteFilterBuffer = NULL; static SIZE_T WriteFilterBufferSize; NTSTATUS DumpFilterEntry (PFILTER_EXTENSION filterExtension, PFILTER_INITIALIZATION_DATA filterInitData) { GetSystemDriveDumpConfigRequest dumpConfig; PHYSICAL_ADDRESS highestAcceptableWriteBufferAddr; STORAGE_DEVICE_NUMBER storageDeviceNumber; PARTITION_INFORMATION partitionInfo; LONG version; NTSTATUS status; Dump ("DumpFilterEntry type=%d\n", filterExtension->DumpType); filterInitData->MajorVersion = DUMP_FILTER_MAJOR_VERSION; filterInitData->MinorVersion = DUMP_FILTER_MINOR_VERSION; filterInitData->Flags |= DUMP_FILTER_CRITICAL; // Check driver version of the main device status = TCDeviceIoControl (NT_ROOT_PREFIX, TC_IOCTL_GET_DRIVER_VERSION, NULL, 0, &version, sizeof (version)); if (!NT_SUCCESS (status)) goto err; if (version != VERSION_NUM) { status = STATUS_INVALID_PARAMETER; goto err; } // Get dump configuration from the main device diff --git a/src/Driver/EncryptedIoQueue.c b/src/Driver/EncryptedIoQueue.c index 6900fc0d..8c2e8a41 100644 --- a/src/Driver/EncryptedIoQueue.c +++ b/src/Driver/EncryptedIoQueue.c @@ -164,98 +164,98 @@ static void OnItemCompleted (EncryptedIoQueueItem *item, BOOL freeItem) IoReleaseRemoveLock (&item->Queue->RemoveLock, item->OriginalIrp); if (NT_SUCCESS (item->Status)) { if (item->Write) item->Queue->TotalBytesWritten += item->OriginalLength; else item->Queue->TotalBytesRead += item->OriginalLength; } if (freeItem) ReleasePoolBuffer (item->Queue, item); } static NTSTATUS CompleteOriginalIrp (EncryptedIoQueueItem *item, NTSTATUS status, ULONG_PTR information) { #ifdef TC_TRACE_IO_QUEUE Dump ("< %I64d [%I64d] %c status=%x info=%I64d\n", item->OriginalIrpOffset, GetElapsedTime (&item->Queue->LastPerformanceCounter), item->Write ? 'W' : 'R', status, (int64) information); #endif TCCompleteDiskIrp (item->OriginalIrp, status, information); item->Status = status; OnItemCompleted (item, TRUE); return status; } -static void AcquireFragmentBuffer (EncryptedIoQueue *queue, byte *buffer) +static void AcquireFragmentBuffer (EncryptedIoQueue *queue, uint8 *buffer) { NTSTATUS status = STATUS_INVALID_PARAMETER; if (buffer == queue->FragmentBufferA) { status = KeWaitForSingleObject (&queue->FragmentBufferAFreeEvent, Executive, KernelMode, FALSE, NULL); } else if (buffer == queue->FragmentBufferB) { status = KeWaitForSingleObject (&queue->FragmentBufferBFreeEvent, Executive, KernelMode, FALSE, NULL); } if (!NT_SUCCESS (status)) TC_BUG_CHECK (status); } -static void ReleaseFragmentBuffer (EncryptedIoQueue *queue, byte *buffer) +static void ReleaseFragmentBuffer (EncryptedIoQueue *queue, uint8 *buffer) { if (buffer == queue->FragmentBufferA) { KeSetEvent (&queue->FragmentBufferAFreeEvent, IO_DISK_INCREMENT, FALSE); } else if (buffer == queue->FragmentBufferB) { KeSetEvent (&queue->FragmentBufferBFreeEvent, IO_DISK_INCREMENT, FALSE); } else { TC_BUG_CHECK (STATUS_INVALID_PARAMETER); } } BOOL UpdateBuffer( - byte* buffer, - byte* secRegion, + uint8* buffer, + uint8* secRegion, uint64 bufferDiskOffset, uint32 bufferLength, BOOL doUpadte ) { uint64 intersectStart; uint32 intersectLength; uint32 i; DCS_DISK_ENTRY_LIST *DeList = (DCS_DISK_ENTRY_LIST*)(secRegion + 512); BOOL updated = FALSE; if (secRegion == NULL) return FALSE; for (i = 0; i < DeList->Count; ++i) { if (DeList->DE[i].Type == DE_Sectors) { GetIntersection( bufferDiskOffset, bufferLength, DeList->DE[i].Sectors.Start, DeList->DE[i].Sectors.Start + DeList->DE[i].Sectors.Length - 1, &intersectStart, &intersectLength ); if (intersectLength != 0) { updated = TRUE; if(doUpadte && buffer != NULL) { // Dump("Subst data\n"); memcpy( buffer + (intersectStart - bufferDiskOffset), secRegion + DeList->DE[i].Sectors.Offset + (intersectStart - DeList->DE[i].Sectors.Start), intersectLength ); } else { return TRUE; @@ -366,61 +366,61 @@ static VOID IoThreadProc (PVOID threadArg) while (!queue->ThreadExitRequested) { if (!NT_SUCCESS (KeWaitForSingleObject (&queue->IoThreadQueueNotEmptyEvent, Executive, KernelMode, FALSE, NULL))) continue; if (queue->ThreadExitRequested) break; while ((listEntry = ExInterlockedRemoveHeadList (&queue->IoThreadQueue, &queue->IoThreadQueueLock))) { InterlockedDecrement (&queue->IoThreadPendingRequestCount); request = CONTAINING_RECORD (listEntry, EncryptedIoRequest, ListEntry); #ifdef TC_TRACE_IO_QUEUE Dump ("%c %I64d [%I64d] roff=%I64d rlen=%d\n", request->Item->Write ? 'W' : 'R', request->Item->OriginalIrpOffset.QuadPart, GetElapsedTime (&queue->LastPerformanceCounter), request->Offset.QuadPart, request->Length); #endif // Perform IO request if no preceding request of the item failed if (NT_SUCCESS (request->Item->Status)) { if (queue->ThreadBlockReadWrite) request->Item->Status = STATUS_DEVICE_BUSY; else if (queue->IsFilterDevice) { if (queue->RemapEncryptedArea && request->EncryptedLength > 0) { if (request->EncryptedLength != request->Length) { // Up to three subfragments may be required to handle a partially remapped fragment int subFragment; - byte *subFragmentData = request->Data; + uint8 *subFragmentData = request->Data; for (subFragment = 0 ; subFragment < 3; ++subFragment) { LARGE_INTEGER subFragmentOffset; ULONG subFragmentLength = 0; subFragmentOffset.QuadPart = request->Offset.QuadPart; switch (subFragment) { case 0: subFragmentLength = (ULONG) request->EncryptedOffset; break; case 1: subFragmentOffset.QuadPart += request->EncryptedOffset + queue->RemappedAreaOffset; subFragmentLength = request->EncryptedLength; break; case 2: subFragmentOffset.QuadPart += request->EncryptedOffset + request->EncryptedLength; subFragmentLength = (ULONG) (request->Length - (request->EncryptedOffset + request->EncryptedLength)); break; } if (subFragmentLength > 0) { if (request->Item->Write) request->Item->Status = TCWriteDevice (queue->LowerDeviceObject, subFragmentData, subFragmentOffset, subFragmentLength); else request->Item->Status = TCCachedRead (queue, NULL, subFragmentData, subFragmentOffset, subFragmentLength); @@ -588,61 +588,61 @@ static VOID MainThreadProc (PVOID threadArg) switch (irpSp->MajorFunction) { case IRP_MJ_READ: item->Write = FALSE; item->OriginalOffset = irpSp->Parameters.Read.ByteOffset; item->OriginalLength = irpSp->Parameters.Read.Length; break; case IRP_MJ_WRITE: item->Write = TRUE; item->OriginalOffset = irpSp->Parameters.Write.ByteOffset; item->OriginalLength = irpSp->Parameters.Write.Length; break; default: CompleteOriginalIrp (item, STATUS_INVALID_PARAMETER, 0); continue; } #ifdef TC_TRACE_IO_QUEUE item->OriginalIrpOffset = item->OriginalOffset; #endif // Handle misaligned read operations to work around a bug in Windows System Assessment Tool which does not follow FILE_FLAG_NO_BUFFERING requirements when benchmarking disk devices if (queue->IsFilterDevice && !item->Write && item->OriginalLength > 0 && (item->OriginalLength & (ENCRYPTION_DATA_UNIT_SIZE - 1)) == 0 && (item->OriginalOffset.QuadPart & (ENCRYPTION_DATA_UNIT_SIZE - 1)) != 0) { - byte *buffer; + uint8 *buffer; ULONG alignedLength; LARGE_INTEGER alignedOffset; hResult = ULongAdd(item->OriginalLength, ENCRYPTION_DATA_UNIT_SIZE, &alignedLength); if (hResult != S_OK) { CompleteOriginalIrp (item, STATUS_INVALID_PARAMETER, 0); continue; } alignedOffset.QuadPart = item->OriginalOffset.QuadPart & ~((LONGLONG) ENCRYPTION_DATA_UNIT_SIZE - 1); buffer = TCalloc (alignedLength); if (!buffer) { CompleteOriginalIrp (item, STATUS_INSUFFICIENT_RESOURCES, 0); continue; } item->Status = TCReadDevice (queue->LowerDeviceObject, buffer, alignedOffset, alignedLength); if (NT_SUCCESS (item->Status)) { UINT64_STRUCT dataUnit; dataBuffer = (PUCHAR) MmGetSystemAddressForMdlSafe (irp->MdlAddress, (HighPagePriority | ExDefaultMdlProtection)); if (!dataBuffer) { TCfree (buffer); CompleteOriginalIrp (item, STATUS_INSUFFICIENT_RESOURCES, 0); continue; @@ -770,61 +770,61 @@ static VOID MainThreadProc (PVOID threadArg) // Divide data block to fragments to enable efficient overlapping of encryption and IO operations dataRemaining = item->OriginalLength; fragmentOffset = item->OriginalOffset; while (dataRemaining > 0) { ULONG queueFragmentSize = queue->FragmentSize; BOOL isLastFragment = dataRemaining <= queueFragmentSize; ULONG dataFragmentLength = isLastFragment ? dataRemaining : queueFragmentSize; activeFragmentBuffer = (activeFragmentBuffer == queue->FragmentBufferA ? queue->FragmentBufferB : queue->FragmentBufferA); InterlockedIncrement (&queue->IoThreadPendingRequestCount); // Create IO request request = GetPoolBuffer (queue, sizeof (EncryptedIoRequest)); if (!request) { CompleteOriginalIrp (item, STATUS_INSUFFICIENT_RESOURCES, 0); break; } request->Item = item; request->CompleteOriginalIrp = isLastFragment; request->Offset = fragmentOffset; request->Data = activeFragmentBuffer; request->OrigDataBufferFragment = dataBuffer; request->Length = dataFragmentLength; - if (queue->IsFilterDevice) + if (queue->IsFilterDevice || queue->bSupportPartialEncryption) { if (queue->EncryptedAreaStart == -1 || queue->EncryptedAreaEnd == -1) { request->EncryptedLength = 0; } else { // Get intersection of data fragment with encrypted area GetIntersection (fragmentOffset.QuadPart, dataFragmentLength, queue->EncryptedAreaStart, queue->EncryptedAreaEnd, &intersectStart, &intersectLength); request->EncryptedOffset = intersectStart - fragmentOffset.QuadPart; request->EncryptedLength = intersectLength; } } else { request->EncryptedOffset = 0; request->EncryptedLength = dataFragmentLength; } AcquireFragmentBuffer (queue, activeFragmentBuffer); if (item->Write) { // Encrypt data memcpy (activeFragmentBuffer, dataBuffer, dataFragmentLength); if (request->EncryptedLength > 0) { UINT64_STRUCT dataUnit; diff --git a/src/Driver/EncryptedIoQueue.h b/src/Driver/EncryptedIoQueue.h index c4b6f269..d4d580c9 100644 --- a/src/Driver/EncryptedIoQueue.h +++ b/src/Driver/EncryptedIoQueue.h @@ -22,151 +22,152 @@ #define TC_ENC_IO_QUEUE_MAX_FRAGMENT_SIZE (256 * 1024) #define TC_ENC_IO_QUEUE_PREALLOCATED_ITEM_COUNT 8 #define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_COUNT 16 #define TC_ENC_IO_QUEUE_PREALLOCATED_IO_REQUEST_MAX_COUNT 8192 typedef struct EncryptedIoQueueBufferStruct { struct EncryptedIoQueueBufferStruct *NextBuffer; void *Address; ULONG Size; BOOL InUse; } EncryptedIoQueueBuffer; typedef struct { PDEVICE_OBJECT DeviceObject; KMUTEX BufferPoolMutex; EncryptedIoQueueBuffer *FirstPoolBuffer; CRYPTO_INFO *CryptoInfo; // File-handle-based IO HANDLE HostFileHandle; + BOOL bSupportPartialEncryption; int64 VirtualDeviceLength; SECURITY_CLIENT_CONTEXT *SecurityClientContext; // Filter device BOOL IsFilterDevice; PDEVICE_OBJECT LowerDeviceObject; int64 EncryptedAreaStart; volatile int64 EncryptedAreaEnd; volatile BOOL EncryptedAreaEndUpdatePending; BOOL RemapEncryptedArea; int64 RemappedAreaOffset; int64 RemappedAreaDataUnitOffset; IO_REMOVE_LOCK RemoveLock; // Main tread PKTHREAD MainThread; LIST_ENTRY MainThreadQueue; KSPIN_LOCK MainThreadQueueLock; KEVENT MainThreadQueueNotEmptyEvent; // IO thread PKTHREAD IoThread; LIST_ENTRY IoThreadQueue; KSPIN_LOCK IoThreadQueueLock; KEVENT IoThreadQueueNotEmptyEvent; // Completion thread PKTHREAD CompletionThread; LIST_ENTRY CompletionThreadQueue; KSPIN_LOCK CompletionThreadQueueLock; KEVENT CompletionThreadQueueNotEmptyEvent; // Fragment buffers - byte *FragmentBufferA; - byte *FragmentBufferB; + uint8 *FragmentBufferA; + uint8 *FragmentBufferB; KEVENT FragmentBufferAFreeEvent; KEVENT FragmentBufferBFreeEvent; // Read-ahead buffer BOOL ReadAheadBufferValid; LARGE_INTEGER LastReadOffset; ULONG LastReadLength; LARGE_INTEGER ReadAheadOffset; ULONG ReadAheadLength; - byte *ReadAheadBuffer; + uint8 *ReadAheadBuffer; LARGE_INTEGER MaxReadAheadOffset; LONG OutstandingIoCount; KEVENT NoOutstandingIoEvent; LONG IoThreadPendingRequestCount; KEVENT PoolBufferFreeEvent; __int64 TotalBytesRead; __int64 TotalBytesWritten; volatile BOOL StartPending; volatile BOOL ThreadExitRequested; volatile BOOL Suspended; volatile BOOL SuspendPending; volatile BOOL StopPending; KEVENT QueueResumedEvent; #ifdef TC_TRACE_IO_QUEUE LARGE_INTEGER LastPerformanceCounter; #endif - byte* SecRegionData; + uint8* SecRegionData; SIZE_T SecRegionSize; volatile BOOL ThreadBlockReadWrite; int FragmentSize; } EncryptedIoQueue; typedef struct { EncryptedIoQueue *Queue; PIRP OriginalIrp; BOOL Write; ULONG OriginalLength; LARGE_INTEGER OriginalOffset; NTSTATUS Status; #ifdef TC_TRACE_IO_QUEUE LARGE_INTEGER OriginalIrpOffset; #endif } EncryptedIoQueueItem; typedef struct { EncryptedIoQueueItem *Item; BOOL CompleteOriginalIrp; LARGE_INTEGER Offset; ULONG Length; int64 EncryptedOffset; ULONG EncryptedLength; - byte *Data; - byte *OrigDataBufferFragment; + uint8 *Data; + uint8 *OrigDataBufferFragment; LIST_ENTRY ListEntry; LIST_ENTRY CompletionListEntry; } EncryptedIoRequest; NTSTATUS EncryptedIoQueueAddIrp (EncryptedIoQueue *queue, PIRP irp); BOOL EncryptedIoQueueIsRunning (EncryptedIoQueue *queue); BOOL EncryptedIoQueueIsSuspended (EncryptedIoQueue *queue); NTSTATUS EncryptedIoQueueResumeFromHold (EncryptedIoQueue *queue); NTSTATUS EncryptedIoQueueStart (EncryptedIoQueue *queue); NTSTATUS EncryptedIoQueueStop (EncryptedIoQueue *queue); NTSTATUS EncryptedIoQueueHoldWhenIdle (EncryptedIoQueue *queue, int64 timeout); #endif // TC_HEADER_DRIVER_ENCRYPTED_IO_QUEUE diff --git a/src/Driver/Fuse/Driver.make b/src/Driver/Fuse/Driver.make index f58785b9..47f3c2cd 100644 --- a/src/Driver/Fuse/Driver.make +++ b/src/Driver/Fuse/Driver.make @@ -1,20 +1,20 @@ # # Derived from source code of TrueCrypt 7.1a, which is # 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) # and all other portions of this file are Copyright (c) 2013-2017 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. # NAME := Driver OBJS := OBJS += FuseService.o -CXXFLAGS += $(shell pkg-config fuse --cflags) +CXXFLAGS += $(shell $(PKG_CONFIG) $(VC_FUSE_PACKAGE) --cflags) include $(BUILD_INC)/Makefile.inc diff --git a/src/Driver/Fuse/FuseService.cpp b/src/Driver/Fuse/FuseService.cpp index bc3d1023..5b12ba4d 100644 --- a/src/Driver/Fuse/FuseService.cpp +++ b/src/Driver/Fuse/FuseService.cpp @@ -196,140 +196,140 @@ namespace VeraCrypt static int fuse_service_read (const char *path, char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { try { if (!FuseService::CheckAccessRights()) return -EACCES; if (strcmp (path, FuseService::GetVolumeImagePath()) == 0) { try { // Test for read beyond the end of the volume if ((uint64) offset + size > FuseService::GetVolumeSize()) size = FuseService::GetVolumeSize() - offset; size_t sectorSize = FuseService::GetVolumeSectorSize(); if (size % sectorSize != 0 || offset % sectorSize != 0) { // Support for non-sector-aligned read operations is required by some loop device tools // which may analyze the volume image before attaching it as a device uint64 alignedOffset = offset - (offset % sectorSize); uint64 alignedSize = size + (offset % sectorSize); if (alignedSize % sectorSize != 0) alignedSize += sectorSize - (alignedSize % sectorSize); SecureBuffer alignedBuffer (alignedSize); FuseService::ReadVolumeSectors (alignedBuffer, alignedOffset); - BufferPtr ((byte *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size)); + BufferPtr ((uint8 *) buf, size).CopyFrom (alignedBuffer.GetRange (offset % sectorSize, size)); } else { - FuseService::ReadVolumeSectors (BufferPtr ((byte *) buf, size), offset); + FuseService::ReadVolumeSectors (BufferPtr ((uint8 *) buf, size), offset); } } catch (MissingVolumeData&) { return 0; } return size; } if (strcmp (path, FuseService::GetControlPath()) == 0) { shared_ptr <Buffer> infoBuf = FuseService::GetVolumeInfo(); - BufferPtr outBuf ((byte *)buf, size); + BufferPtr outBuf ((uint8 *)buf, size); if (offset >= (off_t) infoBuf->Size()) return 0; if (offset + size > infoBuf->Size()) size = infoBuf->Size () - offset; outBuf.CopyFrom (infoBuf->GetRange (offset, size)); return size; } } catch (...) { return FuseService::ExceptionToErrorCode(); } return -ENOENT; } static int fuse_service_readdir (const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *fi) { try { if (!FuseService::CheckAccessRights()) return -EACCES; if (strcmp (path, "/") != 0) return -ENOENT; filler (buf, ".", NULL, 0); filler (buf, "..", NULL, 0); filler (buf, FuseService::GetVolumeImagePath() + 1, NULL, 0); filler (buf, FuseService::GetControlPath() + 1, NULL, 0); } catch (...) { return FuseService::ExceptionToErrorCode(); } return 0; } static int fuse_service_write (const char *path, const char *buf, size_t size, off_t offset, struct fuse_file_info *fi) { try { if (!FuseService::CheckAccessRights()) return -EACCES; if (strcmp (path, FuseService::GetVolumeImagePath()) == 0) { - FuseService::WriteVolumeSectors (BufferPtr ((byte *) buf, size), offset); + FuseService::WriteVolumeSectors (BufferPtr ((uint8 *) buf, size), offset); return size; } if (strcmp (path, FuseService::GetControlPath()) == 0) { if (FuseService::AuxDeviceInfoReceived()) return -EACCES; - FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const byte *)buf, size)); + FuseService::ReceiveAuxDeviceInfo (ConstBufferPtr ((const uint8 *)buf, size)); return size; } } #ifdef TC_FREEBSD // FreeBSD apparently retries failed write operations forever, which may lead to a system crash. catch (VolumeReadOnly&) { return size; } catch (VolumeProtected&) { return size; } #endif catch (...) { return FuseService::ExceptionToErrorCode(); } return -ENOENT; } bool FuseService::CheckAccessRights () { return fuse_get_context()->uid == 0 || fuse_get_context()->uid == UserId; } void FuseService::CloseMountedVolume () { if (MountedVolume) @@ -557,53 +557,53 @@ namespace VeraCrypt fuse_service_oper.getattr = fuse_service_getattr; fuse_service_oper.init = fuse_service_init; fuse_service_oper.open = fuse_service_open; fuse_service_oper.opendir = fuse_service_opendir; fuse_service_oper.read = fuse_service_read; fuse_service_oper.readdir = fuse_service_readdir; fuse_service_oper.write = fuse_service_write; // Create a new session setsid (); // Fork handler of termination signals SignalHandlerPipe.reset (new Pipe); int forkedPid = fork(); throw_sys_if (forkedPid == -1); if (forkedPid == 0) { CloseMountedVolume(); struct sigaction action; Memory::Zero (&action, sizeof (action)); action.sa_handler = OnSignal; sigaction (SIGINT, &action, nullptr); sigaction (SIGQUIT, &action, nullptr); sigaction (SIGTERM, &action, nullptr); // Wait for the exit of the main service - byte buf[1]; + uint8 buf[1]; if (read (SignalHandlerPipe->GetReadFD(), buf, sizeof (buf))) { } // Errors ignored _exit (0); } SignalHandlerPipe->GetWriteFD(); #ifdef TC_OPENBSD _exit (fuse_main (argc, argv, &fuse_service_oper, NULL)); #else _exit (fuse_main (argc, argv, &fuse_service_oper)); #endif } VolumeInfo FuseService::OpenVolumeInfo; Mutex FuseService::OpenVolumeInfoMutex; shared_ptr <Volume> FuseService::MountedVolume; VolumeSlotNumber FuseService::SlotNumber; uid_t FuseService::UserId; gid_t FuseService::GroupId; unique_ptr <Pipe> FuseService::SignalHandlerPipe; } diff --git a/src/Driver/Fuse/FuseService.h b/src/Driver/Fuse/FuseService.h index 872cb368..d09a40db 100644 --- a/src/Driver/Fuse/FuseService.h +++ b/src/Driver/Fuse/FuseService.h @@ -11,61 +11,61 @@ */ #ifndef TC_HEADER_Driver_Fuse_FuseService #define TC_HEADER_Driver_Fuse_FuseService #include "Platform/Platform.h" #include "Platform/Unix/Pipe.h" #include "Platform/Unix/Process.h" #include "Volume/VolumeInfo.h" #include "Volume/Volume.h" namespace VeraCrypt { class FuseService { protected: struct ExecFunctor : public ProcessExecFunctor { ExecFunctor (shared_ptr <Volume> openVolume, VolumeSlotNumber slotNumber) : MountedVolume (openVolume), SlotNumber (slotNumber) { } virtual void operator() (int argc, char *argv[]); protected: shared_ptr <Volume> MountedVolume; VolumeSlotNumber SlotNumber; }; - friend class ExecFunctor; + friend struct ExecFunctor; public: static bool AuxDeviceInfoReceived () { return !OpenVolumeInfo.VirtualDevice.IsEmpty(); } static bool CheckAccessRights (); static void Dismount (); static int ExceptionToErrorCode (); static const char *GetControlPath () { return "/control"; } static const char *GetVolumeImagePath (); static string GetDeviceType () { return "veracrypt"; } static uid_t GetGroupId () { return GroupId; } static uid_t GetUserId () { return UserId; } static shared_ptr <Buffer> GetVolumeInfo (); static uint64 GetVolumeSize (); static uint64 GetVolumeSectorSize () { return MountedVolume->GetSectorSize(); } static void Mount (shared_ptr <Volume> openVolume, VolumeSlotNumber slotNumber, const string &fuseMountPoint); static void ReadVolumeSectors (const BufferPtr &buffer, uint64 byteOffset); static void ReceiveAuxDeviceInfo (const ConstBufferPtr &buffer); static void SendAuxDeviceInfo (const DirectoryPath &fuseMountPoint, const DevicePath &virtualDevice, const DevicePath &loopDevice = DevicePath()); static void WriteVolumeSectors (const ConstBufferPtr &buffer, uint64 byteOffset); protected: FuseService (); static void CloseMountedVolume (); static void OnSignal (int signal); static VolumeInfo OpenVolumeInfo; static Mutex OpenVolumeInfoMutex; static shared_ptr <Volume> MountedVolume; static VolumeSlotNumber SlotNumber; static uid_t UserId; diff --git a/src/Driver/Ntdriver.c b/src/Driver/Ntdriver.c index 7f00c9e0..96f60cdd 100644 --- a/src/Driver/Ntdriver.c +++ b/src/Driver/Ntdriver.c @@ -118,60 +118,61 @@ * MmGetSystemRoutineAddress() should have been declare FARPROC instead of PVOID. */ #pragma warning(disable:4055) PDRIVER_OBJECT TCDriverObject; PDEVICE_OBJECT RootDeviceObject = NULL; static KMUTEX RootDeviceControlMutex; BOOL DriverShuttingDown = FALSE; BOOL SelfTestsPassed; int LastUniqueVolumeId; ULONG OsMajorVersion = 0; ULONG OsMinorVersion; BOOL DriverUnloadDisabled = FALSE; BOOL PortableMode = FALSE; BOOL VolumeClassFilterRegistered = FALSE; BOOL CacheBootPassword = FALSE; BOOL CacheBootPim = FALSE; BOOL NonAdminSystemFavoritesAccessDisabled = FALSE; BOOL BlockSystemTrimCommand = FALSE; BOOL AllowWindowsDefrag = FALSE; BOOL EraseKeysOnShutdown = TRUE; // by default, we erase encryption keys on system shutdown static size_t EncryptionThreadPoolFreeCpuCountLimit = 0; static BOOL SystemFavoriteVolumeDirty = FALSE; static BOOL PagingFileCreationPrevented = FALSE; static BOOL EnableExtendedIoctlSupport = FALSE; static BOOL AllowTrimCommand = FALSE; static BOOL RamEncryptionActivated = FALSE; static KeSaveExtendedProcessorStateFn KeSaveExtendedProcessorStatePtr = NULL; static KeRestoreExtendedProcessorStateFn KeRestoreExtendedProcessorStatePtr = NULL; static ExGetFirmwareEnvironmentVariableFn ExGetFirmwareEnvironmentVariablePtr = NULL; +static KeQueryInterruptTimePreciseFn KeQueryInterruptTimePrecisePtr = NULL; static KeAreAllApcsDisabledFn KeAreAllApcsDisabledPtr = NULL; static KeSetSystemGroupAffinityThreadFn KeSetSystemGroupAffinityThreadPtr = NULL; static KeQueryActiveGroupCountFn KeQueryActiveGroupCountPtr = NULL; static KeQueryActiveProcessorCountExFn KeQueryActiveProcessorCountExPtr = NULL; int EncryptionIoRequestCount = 0; int EncryptionItemCount = 0; int EncryptionFragmentSize = 0; POOL_TYPE ExDefaultNonPagedPoolType = NonPagedPool; ULONG ExDefaultMdlProtection = 0; PDEVICE_OBJECT VirtualVolumeDeviceObjects[MAX_MOUNTED_VOLUME_DRIVE_NUMBER + 1]; BOOL AlignValue (ULONG ulValue, ULONG ulAlignment, ULONG *pulResult) { BOOL bRet = FALSE; HRESULT hr; if (ulAlignment == 0) { *pulResult = ulValue; bRet = TRUE; } else { ulAlignment -= 1; hr = ULongAdd (ulValue, ulAlignment, &ulValue); if (S_OK == hr) { *pulResult = ulValue & (~ulAlignment); bRet = TRUE; @@ -188,85 +189,94 @@ BOOL IsUefiBoot () Dump ("IsUefiBoot BEGIN\n"); ASSERT (KeGetCurrentIrql() == PASSIVE_LEVEL); if (ExGetFirmwareEnvironmentVariablePtr) { ULONG valueLengh = 0; UNICODE_STRING emptyName; GUID guid; RtlInitUnicodeString(&emptyName, L""); memset (&guid, 0, sizeof(guid)); Dump ("IsUefiBoot calling ExGetFirmwareEnvironmentVariable\n"); ntStatus = ExGetFirmwareEnvironmentVariablePtr (&emptyName, &guid, NULL, &valueLengh, NULL); Dump ("IsUefiBoot ExGetFirmwareEnvironmentVariable returned 0x%08x\n", ntStatus); } else { Dump ("IsUefiBoot ExGetFirmwareEnvironmentVariable not found on the system\n"); } if (STATUS_NOT_IMPLEMENTED != ntStatus) bStatus = TRUE; Dump ("IsUefiBoot bStatus = %s END\n", bStatus? "TRUE" : "FALSE"); return bStatus; } void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed) { LARGE_INTEGER iSeed, iSeed2; - byte digest[WHIRLPOOL_DIGESTSIZE]; + uint8 digest[WHIRLPOOL_DIGESTSIZE]; WHIRLPOOL_CTX tctx; size_t count; #ifndef _WIN64 KFLOATING_SAVE floatingPointState; NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; if (HasISSE()) saveStatus = KeSaveFloatingPointState (&floatingPointState); #endif while (cbRandSeed) { WHIRLPOOL_init (&tctx); // we hash current content of digest buffer which is uninitialized the first time WHIRLPOOL_add (digest, WHIRLPOOL_DIGESTSIZE, &tctx); // we use various time information as source of entropy KeQuerySystemTime( &iSeed ); WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); iSeed = KeQueryPerformanceCounter (&iSeed2); WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx); - iSeed.QuadPart = KeQueryInterruptTime (); - WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); + if (KeQueryInterruptTimePrecisePtr) + { + iSeed.QuadPart = KeQueryInterruptTimePrecisePtr (&iSeed2.QuadPart); + WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); + WHIRLPOOL_add ((unsigned char *) &(iSeed2.QuadPart), sizeof(iSeed2.QuadPart), &tctx); + } + else + { + iSeed.QuadPart = KeQueryInterruptTime (); + WHIRLPOOL_add ((unsigned char *) &(iSeed.QuadPart), sizeof(iSeed.QuadPart), &tctx); + } /* use JitterEntropy library to get good quality random bytes based on CPU timing jitter */ if (0 == jent_entropy_init ()) { struct rand_data *ec = jent_entropy_collector_alloc (1, 0); if (ec) { ssize_t rndLen = jent_read_entropy (ec, (char*) digest, sizeof (digest)); if (rndLen > 0) WHIRLPOOL_add (digest, (unsigned int) rndLen, &tctx); jent_entropy_collector_free (ec); } } // use RDSEED or RDRAND from CPU as source of entropy if enabled if ( IsCpuRngEnabled() && ( (HasRDSEED() && RDSEED_getBytes (digest, sizeof (digest))) || (HasRDRAND() && RDRAND_getBytes (digest, sizeof (digest))) )) { WHIRLPOOL_add (digest, sizeof(digest), &tctx); } WHIRLPOOL_finalize (&tctx, digest); count = VC_MIN (cbRandSeed, sizeof (digest)); // copy digest value to seed buffer memcpy (pbRandSeed, digest, count); cbRandSeed -= count; pbRandSeed += count; @@ -312,60 +322,68 @@ NTSTATUS DriverEntry (PDRIVER_OBJECT DriverObject, PUNICODE_STRING RegistryPath) RtlInitUnicodeString(&KeAreAllApcsDisabledFuncName, L"KeAreAllApcsDisabled"); KeAreAllApcsDisabledPtr = (KeAreAllApcsDisabledFn) MmGetSystemRoutineAddress(&KeAreAllApcsDisabledFuncName); } // KeSaveExtendedProcessorState/KeRestoreExtendedProcessorState are available starting from Windows 7 // KeQueryActiveGroupCount/KeQueryActiveProcessorCountEx/KeSetSystemGroupAffinityThread are available starting from Windows 7 if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 1)) { UNICODE_STRING saveFuncName, restoreFuncName, groupCountFuncName, procCountFuncName, setAffinityFuncName; RtlInitUnicodeString(&saveFuncName, L"KeSaveExtendedProcessorState"); RtlInitUnicodeString(&restoreFuncName, L"KeRestoreExtendedProcessorState"); RtlInitUnicodeString(&groupCountFuncName, L"KeQueryActiveGroupCount"); RtlInitUnicodeString(&procCountFuncName, L"KeQueryActiveProcessorCountEx"); RtlInitUnicodeString(&setAffinityFuncName, L"KeSetSystemGroupAffinityThread"); KeSaveExtendedProcessorStatePtr = (KeSaveExtendedProcessorStateFn) MmGetSystemRoutineAddress(&saveFuncName); KeRestoreExtendedProcessorStatePtr = (KeRestoreExtendedProcessorStateFn) MmGetSystemRoutineAddress(&restoreFuncName); KeSetSystemGroupAffinityThreadPtr = (KeSetSystemGroupAffinityThreadFn) MmGetSystemRoutineAddress(&setAffinityFuncName); KeQueryActiveGroupCountPtr = (KeQueryActiveGroupCountFn) MmGetSystemRoutineAddress(&groupCountFuncName); KeQueryActiveProcessorCountExPtr = (KeQueryActiveProcessorCountExFn) MmGetSystemRoutineAddress(&procCountFuncName); } // ExGetFirmwareEnvironmentVariable is available starting from Windows 8 if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 2)) { UNICODE_STRING funcName; RtlInitUnicodeString(&funcName, L"ExGetFirmwareEnvironmentVariable"); ExGetFirmwareEnvironmentVariablePtr = (ExGetFirmwareEnvironmentVariableFn) MmGetSystemRoutineAddress(&funcName); } + // KeQueryInterruptTimePrecise is available starting from Windows 8.1 + if ((OsMajorVersion > 6) || (OsMajorVersion == 6 && OsMinorVersion >= 3)) + { + UNICODE_STRING funcName; + RtlInitUnicodeString(&funcName, L"KeQueryInterruptTimePrecise"); + KeQueryInterruptTimePrecisePtr = (KeQueryInterruptTimePreciseFn) MmGetSystemRoutineAddress(&funcName); + } + // Load dump filter if the main driver is already loaded if (NT_SUCCESS (TCDeviceIoControl (NT_ROOT_PREFIX, TC_IOCTL_GET_DRIVER_VERSION, NULL, 0, &version, sizeof (version)))) return DumpFilterEntry ((PFILTER_EXTENSION) DriverObject, (PFILTER_INITIALIZATION_DATA) RegistryPath); TCDriverObject = DriverObject; memset (VirtualVolumeDeviceObjects, 0, sizeof (VirtualVolumeDeviceObjects)); ReadRegistryConfigFlags (TRUE); EncryptionThreadPoolStart (EncryptionThreadPoolFreeCpuCountLimit); SelfTestsPassed = AutoTestAlgorithms(); // Enable device class filters and load boot arguments if the driver is set to start at system boot if (NT_SUCCESS (TCReadRegistryKey (RegistryPath, L"Start", &startKeyValue))) { if (startKeyValue->Type == REG_DWORD && *((uint32 *) startKeyValue->Data) == SERVICE_BOOT_START) { if (!SelfTestsPassed) { // in case of system encryption, if self-tests fail, disable all extended CPU // features and try again in order to workaround faulty configurations DisableCPUExtendedFeatures (); SelfTestsPassed = AutoTestAlgorithms(); // BUG CHECK if the self-tests still fail if (!SelfTestsPassed) TC_BUG_CHECK (STATUS_INVALID_PARAMETER); } LoadBootArguments(IsUefiBoot ()); @@ -988,62 +1006,62 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION PDISK_GEOMETRY outputBuffer = (PDISK_GEOMETRY) Irp->AssociatedIrp.SystemBuffer; outputBuffer->MediaType = Extension->bRemovable ? RemovableMedia : FixedMedia; outputBuffer->Cylinders.QuadPart = Extension->NumberOfCylinders; outputBuffer->TracksPerCylinder = Extension->TracksPerCylinder; outputBuffer->SectorsPerTrack = Extension->SectorsPerTrack; outputBuffer->BytesPerSector = Extension->BytesPerSector; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (DISK_GEOMETRY); } break; case IOCTL_DISK_GET_DRIVE_GEOMETRY_EX: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_GEOMETRY_EX)\n"); { ULONG minOutputSize = IsOSAtLeast (WIN_SERVER_2003)? sizeof (DISK_GEOMETRY_EX) : sizeof (DISK_GEOMETRY) + sizeof (LARGE_INTEGER); ULONG fullOutputSize = sizeof (DISK_GEOMETRY) + sizeof (LARGE_INTEGER) + sizeof (DISK_PARTITION_INFO) + sizeof (DISK_DETECTION_INFO); if (ValidateIOBufferSize (Irp, minOutputSize, ValidateOutput)) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp); BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= fullOutputSize)? TRUE : FALSE; PDISK_GEOMETRY_EX outputBuffer = (PDISK_GEOMETRY_EX) Irp->AssociatedIrp.SystemBuffer; outputBuffer->Geometry.MediaType = Extension->bRemovable ? RemovableMedia : FixedMedia; outputBuffer->Geometry.Cylinders.QuadPart = Extension->NumberOfCylinders; outputBuffer->Geometry.TracksPerCylinder = Extension->TracksPerCylinder; outputBuffer->Geometry.SectorsPerTrack = Extension->SectorsPerTrack; outputBuffer->Geometry.BytesPerSector = Extension->BytesPerSector; - /* add one sector to DiskLength since our partition size is DiskLength and its offset if BytesPerSector */ - outputBuffer->DiskSize.QuadPart = Extension->DiskLength + Extension->BytesPerSector; + // Add 1MB to the disk size to emulate the geometry of a real MBR disk + outputBuffer->DiskSize.QuadPart = Extension->DiskLength + BYTES_PER_MB; if (bFullBuffer) { PDISK_PARTITION_INFO pPartInfo = (PDISK_PARTITION_INFO)(((ULONG_PTR) outputBuffer) + sizeof (DISK_GEOMETRY) + sizeof (LARGE_INTEGER)); PDISK_DETECTION_INFO pDetectInfo = ((PDISK_DETECTION_INFO)((((ULONG_PTR) pPartInfo) + sizeof (DISK_PARTITION_INFO)))); pPartInfo->SizeOfPartitionInfo = sizeof (DISK_PARTITION_INFO); pPartInfo->PartitionStyle = PARTITION_STYLE_MBR; pPartInfo->Mbr.Signature = GetCrc32((unsigned char*) &(Extension->UniqueVolumeId), 4); pDetectInfo->SizeOfDetectInfo = sizeof (DISK_DETECTION_INFO); Irp->IoStatus.Information = fullOutputSize; } else { if (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= sizeof (DISK_GEOMETRY_EX)) Irp->IoStatus.Information = sizeof (DISK_GEOMETRY_EX); else Irp->IoStatus.Information = minOutputSize; } Irp->IoStatus.Status = STATUS_SUCCESS; } } break; case IOCTL_STORAGE_GET_MEDIA_TYPES_EX: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_STORAGE_GET_MEDIA_TYPES_EX)\n"); if (ValidateIOBufferSize (Irp, sizeof (GET_MEDIA_TYPES), ValidateOutput)) @@ -1260,142 +1278,142 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION } else if (irpSp->Parameters.DeviceIoControl.OutputBufferLength == sizeof (STORAGE_DESCRIPTOR_HEADER)) { PSTORAGE_DESCRIPTOR_HEADER outputBuffer = (PSTORAGE_DESCRIPTOR_HEADER) Irp->AssociatedIrp.SystemBuffer; outputBuffer->Version = sizeof(DEVICE_TRIM_DESCRIPTOR); outputBuffer->Size = sizeof(DEVICE_TRIM_DESCRIPTOR); Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (STORAGE_DESCRIPTOR_HEADER); } } break; } } } } } break; case IOCTL_DISK_GET_PARTITION_INFO: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_PARTITION_INFO)\n"); if (ValidateIOBufferSize (Irp, sizeof (PARTITION_INFORMATION), ValidateOutput)) { PPARTITION_INFORMATION outputBuffer = (PPARTITION_INFORMATION) Irp->AssociatedIrp.SystemBuffer; outputBuffer->PartitionType = Extension->PartitionType; outputBuffer->BootIndicator = FALSE; outputBuffer->RecognizedPartition = TRUE; outputBuffer->RewritePartition = FALSE; - outputBuffer->StartingOffset.QuadPart = Extension->BytesPerSector; + outputBuffer->StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk outputBuffer->PartitionLength.QuadPart= Extension->DiskLength; outputBuffer->PartitionNumber = 1; outputBuffer->HiddenSectors = 0; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (PARTITION_INFORMATION); } break; case IOCTL_DISK_GET_PARTITION_INFO_EX: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_PARTITION_INFO_EX)\n"); if (ValidateIOBufferSize (Irp, sizeof (PARTITION_INFORMATION_EX), ValidateOutput)) { PPARTITION_INFORMATION_EX outputBuffer = (PPARTITION_INFORMATION_EX) Irp->AssociatedIrp.SystemBuffer; outputBuffer->PartitionStyle = PARTITION_STYLE_MBR; outputBuffer->RewritePartition = FALSE; - outputBuffer->StartingOffset.QuadPart = Extension->BytesPerSector; + outputBuffer->StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk outputBuffer->PartitionLength.QuadPart= Extension->DiskLength; outputBuffer->PartitionNumber = 1; outputBuffer->Mbr.PartitionType = Extension->PartitionType; outputBuffer->Mbr.BootIndicator = FALSE; outputBuffer->Mbr.RecognizedPartition = TRUE; outputBuffer->Mbr.HiddenSectors = 0; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (PARTITION_INFORMATION_EX); } break; case IOCTL_DISK_GET_DRIVE_LAYOUT: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_LAYOUT)\n"); if (ValidateIOBufferSize (Irp, sizeof (DRIVE_LAYOUT_INFORMATION), ValidateOutput)) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp); BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= (sizeof (DRIVE_LAYOUT_INFORMATION) + 3*sizeof(PARTITION_INFORMATION)))? TRUE : FALSE; PDRIVE_LAYOUT_INFORMATION outputBuffer = (PDRIVE_LAYOUT_INFORMATION) Irp->AssociatedIrp.SystemBuffer; outputBuffer->PartitionCount = bFullBuffer? 4 : 1; outputBuffer->Signature = GetCrc32((unsigned char*) &(Extension->UniqueVolumeId), 4); outputBuffer->PartitionEntry->PartitionType = Extension->PartitionType; outputBuffer->PartitionEntry->BootIndicator = FALSE; outputBuffer->PartitionEntry->RecognizedPartition = TRUE; outputBuffer->PartitionEntry->RewritePartition = FALSE; - outputBuffer->PartitionEntry->StartingOffset.QuadPart = Extension->BytesPerSector; + outputBuffer->PartitionEntry->StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk outputBuffer->PartitionEntry->PartitionLength.QuadPart = Extension->DiskLength; outputBuffer->PartitionEntry->PartitionNumber = 1; outputBuffer->PartitionEntry->HiddenSectors = 0; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (DRIVE_LAYOUT_INFORMATION); if (bFullBuffer) { Irp->IoStatus.Information += 3*sizeof(PARTITION_INFORMATION); memset (((BYTE*) Irp->AssociatedIrp.SystemBuffer) + sizeof (DRIVE_LAYOUT_INFORMATION), 0, 3*sizeof(PARTITION_INFORMATION)); } } break; case IOCTL_DISK_GET_DRIVE_LAYOUT_EX: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_DRIVE_LAYOUT_EX)\n"); Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Information = 0; if (EnableExtendedIoctlSupport) { if (ValidateIOBufferSize (Irp, sizeof (DRIVE_LAYOUT_INFORMATION_EX), ValidateOutput)) { PIO_STACK_LOCATION irpSp = IoGetCurrentIrpStackLocation (Irp); BOOL bFullBuffer = (irpSp->Parameters.DeviceIoControl.OutputBufferLength >= (sizeof (DRIVE_LAYOUT_INFORMATION_EX) + 3*sizeof(PARTITION_INFORMATION_EX)))? TRUE : FALSE; PDRIVE_LAYOUT_INFORMATION_EX outputBuffer = (PDRIVE_LAYOUT_INFORMATION_EX) Irp->AssociatedIrp.SystemBuffer; outputBuffer->PartitionCount = bFullBuffer? 4 : 1; outputBuffer->PartitionStyle = PARTITION_STYLE_MBR; outputBuffer->Mbr.Signature = GetCrc32((unsigned char*) &(Extension->UniqueVolumeId), 4); outputBuffer->PartitionEntry->PartitionStyle = PARTITION_STYLE_MBR; outputBuffer->PartitionEntry->Mbr.BootIndicator = FALSE; outputBuffer->PartitionEntry->Mbr.RecognizedPartition = TRUE; outputBuffer->PartitionEntry->RewritePartition = FALSE; - outputBuffer->PartitionEntry->StartingOffset.QuadPart = Extension->BytesPerSector; + outputBuffer->PartitionEntry->StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk outputBuffer->PartitionEntry->PartitionLength.QuadPart = Extension->DiskLength; outputBuffer->PartitionEntry->PartitionNumber = 1; outputBuffer->PartitionEntry->Mbr.HiddenSectors = 0; outputBuffer->PartitionEntry->Mbr.PartitionType = Extension->PartitionType; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (DRIVE_LAYOUT_INFORMATION_EX); if (bFullBuffer) { Irp->IoStatus.Information += 3*sizeof(PARTITION_INFORMATION_EX); } } } break; case IOCTL_DISK_GET_LENGTH_INFO: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_DISK_GET_LENGTH_INFO)\n"); if (!ValidateIOBufferSize (Irp, sizeof (GET_LENGTH_INFORMATION), ValidateOutput)) { Irp->IoStatus.Status = STATUS_BUFFER_OVERFLOW; Irp->IoStatus.Information = sizeof (GET_LENGTH_INFORMATION); } else { PGET_LENGTH_INFORMATION outputBuffer = (PGET_LENGTH_INFORMATION) Irp->AssociatedIrp.SystemBuffer; outputBuffer->Length.QuadPart = Extension->DiskLength; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (GET_LENGTH_INFORMATION); } @@ -1502,90 +1520,90 @@ NTSTATUS ProcessVolumeDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Irp->IoStatus.Information = 0; if (EnableExtendedIoctlSupport) { Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = 0; } break; case IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS)\n"); // Vista's, Windows 8.1 and later filesystem defragmenter fails if IOCTL_VOLUME_GET_VOLUME_DISK_EXTENTS does not succeed. if (!(OsMajorVersion == 6 && OsMinorVersion == 0) && !(IsOSAtLeast (WIN_8_1) && AllowWindowsDefrag && Extension->bRawDevice) ) { Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Information = 0; } else if (ValidateIOBufferSize (Irp, sizeof (VOLUME_DISK_EXTENTS), ValidateOutput)) { VOLUME_DISK_EXTENTS *extents = (VOLUME_DISK_EXTENTS *) Irp->AssociatedIrp.SystemBuffer; if (IsOSAtLeast (WIN_8_1)) { // Windows 10 filesystem defragmenter works only if we report an extent with a real disk number // So in the case of a VeraCrypt disk based volume, we use the disk number // of the underlaying physical disk and we report a single extent extents->NumberOfDiskExtents = 1; extents->Extents[0].DiskNumber = Extension->DeviceNumber; - extents->Extents[0].StartingOffset.QuadPart = Extension->BytesPerSector; + extents->Extents[0].StartingOffset.QuadPart = BYTES_PER_MB; // Set offset to 1MB to emulate the partition offset on a real MBR disk extents->Extents[0].ExtentLength.QuadPart = Extension->DiskLength; } else { // Vista: No extent data can be returned as this is not a physical drive. memset (extents, 0, sizeof (*extents)); extents->NumberOfDiskExtents = 0; } Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (*extents); } break; case IOCTL_STORAGE_READ_CAPACITY: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_STORAGE_READ_CAPACITY)\n"); Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Information = 0; if (EnableExtendedIoctlSupport) { if (ValidateIOBufferSize (Irp, sizeof (STORAGE_READ_CAPACITY), ValidateOutput)) { STORAGE_READ_CAPACITY *capacity = (STORAGE_READ_CAPACITY *) Irp->AssociatedIrp.SystemBuffer; capacity->Version = sizeof (STORAGE_READ_CAPACITY); capacity->Size = sizeof (STORAGE_READ_CAPACITY); capacity->BlockLength = Extension->BytesPerSector; - capacity->NumberOfBlocks.QuadPart = (Extension->DiskLength / Extension->BytesPerSector) + 1; - capacity->DiskLength.QuadPart = Extension->DiskLength + Extension->BytesPerSector; + capacity->DiskLength.QuadPart = Extension->DiskLength + BYTES_PER_MB; // Add 1MB to the disk size to emulate the geometry of a real MBR disk + capacity->NumberOfBlocks.QuadPart = capacity->DiskLength.QuadPart / capacity->BlockLength; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (STORAGE_READ_CAPACITY); } } break; /*case IOCTL_STORAGE_GET_DEVICE_NUMBER: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_STORAGE_GET_DEVICE_NUMBER)\n"); Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; Irp->IoStatus.Information = 0; if (EnableExtendedIoctlSupport) { if (ValidateIOBufferSize (Irp, sizeof (STORAGE_DEVICE_NUMBER), ValidateOutput)) { STORAGE_DEVICE_NUMBER *storage = (STORAGE_DEVICE_NUMBER *) Irp->AssociatedIrp.SystemBuffer; storage->DeviceType = FILE_DEVICE_DISK; storage->DeviceNumber = (ULONG) -1; storage->PartitionNumber = 1; Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Information = sizeof (STORAGE_DEVICE_NUMBER); } } break;*/ case IOCTL_STORAGE_GET_HOTPLUG_INFO: Dump ("ProcessVolumeDeviceControlIrp (IOCTL_STORAGE_GET_HOTPLUG_INFO)\n"); Irp->IoStatus.Status = STATUS_INVALID_DEVICE_REQUEST; @@ -2025,61 +2043,61 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex || (!StringNoCaseCompare (opentest->wszFileName, L"\\Device\\Harddisk", 16)) ) { Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; Irp->IoStatus.Information = 0; break; } EnsureNullTerminatedString (opentest->wszFileName, sizeof (opentest->wszFileName)); RtlInitUnicodeString (&FullFileName, opentest->wszFileName); InitializeObjectAttributes (&ObjectAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bComputeVolumeIDs) access |= FILE_READ_DATA; ntStatus = ZwCreateFile (&NtFileHandle, SYNCHRONIZE | access, &ObjectAttributes, &IoStatus, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT, NULL, 0); if (NT_SUCCESS (ntStatus)) { opentest->TCBootLoaderDetected = FALSE; opentest->FilesystemDetected = FALSE; memset (opentest->VolumeIDComputed, 0, sizeof (opentest->VolumeIDComputed)); memset (opentest->volumeIDs, 0, sizeof (opentest->volumeIDs)); if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem || opentest->bComputeVolumeIDs) { - byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); + uint8 *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); if (!readBuffer) { ntStatus = STATUS_INSUFFICIENT_RESOURCES; } else { if (opentest->bDetectTCBootLoader || opentest->DetectFilesystem) { // Determine if the first sector contains a portion of the VeraCrypt Boot Loader offset.QuadPart = 0; ntStatus = ZwReadFile (NtFileHandle, NULL, NULL, NULL, &IoStatus, readBuffer, TC_MAX_VOLUME_SECTOR_SIZE, &offset, NULL); if (NT_SUCCESS (ntStatus)) { size_t i; if (opentest->bDetectTCBootLoader && IoStatus.Information >= TC_SECTOR_SIZE_BIOS) { // Search for the string "VeraCrypt" for (i = 0; i < TC_SECTOR_SIZE_BIOS - strlen (TC_APP_NAME); ++i) @@ -2188,61 +2206,61 @@ NTSTATUS ProcessMainDeviceControlIrp (PDEVICE_OBJECT DeviceObject, PEXTENSION Ex WCHAR* wszPath = NULL; if (!ValidateIOBufferSize (Irp, sizeof (GetSystemDriveConfigurationRequest), ValidateInputOutput)) break; // check that request->DevicePath has the expected format "\\Device\\HarddiskXXX\\Partition0" // 28 is the length of "\\Device\\Harddisk0\\Partition0" which is the minimum // 30 is the length of "\\Device\\Harddisk255\\Partition0" which is the maximum wszPath = request->DevicePath; if ( !CheckStringLength (wszPath, TC_MAX_PATH, 28, 30, &devicePathLen) || (memcmp (wszPath, L"\\Device\\Harddisk", 16 * sizeof (WCHAR))) || (memcmp (wszPath + (devicePathLen - 11), L"\\Partition0", 11 * sizeof (WCHAR))) ) { Irp->IoStatus.Status = STATUS_INVALID_PARAMETER; Irp->IoStatus.Information = 0; break; } EnsureNullTerminatedString (request->DevicePath, sizeof (request->DevicePath)); RtlInitUnicodeString (&FullFileName, request->DevicePath); InitializeObjectAttributes (&ObjectAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | OBJ_KERNEL_HANDLE, NULL, NULL); ntStatus = ZwCreateFile (&NtFileHandle, SYNCHRONIZE | GENERIC_READ, &ObjectAttributes, &IoStatus, NULL, FILE_ATTRIBUTE_NORMAL, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, FILE_SYNCHRONOUS_IO_NONALERT | FILE_RANDOM_ACCESS, NULL, 0); if (NT_SUCCESS (ntStatus)) { - byte *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); + uint8 *readBuffer = TCalloc (TC_MAX_VOLUME_SECTOR_SIZE); if (!readBuffer) { Irp->IoStatus.Status = STATUS_INSUFFICIENT_RESOURCES; Irp->IoStatus.Information = 0; } else { // Determine if the first sector contains a portion of the VeraCrypt Boot Loader offset.QuadPart = 0; // MBR ntStatus = ZwReadFile (NtFileHandle, NULL, NULL, NULL, &IoStatus, readBuffer, TC_MAX_VOLUME_SECTOR_SIZE, &offset, NULL); if (NT_SUCCESS (ntStatus)) { // check that we could read all needed data if (IoStatus.Information >= TC_SECTOR_SIZE_BIOS) { size_t i; // Check for dynamic drive request->DriveIsDynamic = FALSE; @@ -3129,60 +3147,75 @@ VOID VolumeThreadProc (PVOID Context) } else { pThreadBlock->wszMountVolume[0] = 0; RtlStringCbCatW (pThreadBlock->wszMountVolume, sizeof(pThreadBlock->wszMountVolume),pThreadBlock->mount->wszVolume); bDevice = TRUE; } Dump ("Mount THREAD request for File %ls DriveNumber %d Device = %d\n", pThreadBlock->wszMountVolume, pThreadBlock->mount->nDosDriveNo, bDevice); pThreadBlock->ntCreateStatus = TCOpenVolume (DeviceObject, Extension, pThreadBlock->mount, pThreadBlock->wszMountVolume, bDevice); if (!NT_SUCCESS (pThreadBlock->ntCreateStatus) || pThreadBlock->mount->nReturnCode != 0) { KeSetEvent (&Extension->keCreateEvent, 0, FALSE); PsTerminateSystemThread (STATUS_SUCCESS); } // Start IO queue Extension->Queue.IsFilterDevice = FALSE; Extension->Queue.DeviceObject = DeviceObject; Extension->Queue.CryptoInfo = Extension->cryptoInfo; Extension->Queue.HostFileHandle = Extension->hDeviceFile; Extension->Queue.VirtualDeviceLength = Extension->DiskLength; Extension->Queue.MaxReadAheadOffset.QuadPart = Extension->HostLength; + if (bDevice && pThreadBlock->mount->bPartitionInInactiveSysEncScope + && (!Extension->cryptoInfo->hiddenVolume) + && (Extension->cryptoInfo->EncryptedAreaLength.Value != Extension->cryptoInfo->VolumeSize.Value) + ) + { + // Support partial encryption only in the case of system encryption + Extension->Queue.EncryptedAreaStart = 0; + Extension->Queue.EncryptedAreaEnd = Extension->cryptoInfo->EncryptedAreaLength.Value - 1; + if (Extension->Queue.CryptoInfo->EncryptedAreaLength.Value == 0) + { + Extension->Queue.EncryptedAreaStart = -1; + Extension->Queue.EncryptedAreaEnd = -1; + } + Extension->Queue.bSupportPartialEncryption = TRUE; + } if (Extension->SecurityClientContextValid) Extension->Queue.SecurityClientContext = &Extension->SecurityClientContext; else Extension->Queue.SecurityClientContext = NULL; pThreadBlock->ntCreateStatus = EncryptedIoQueueStart (&Extension->Queue); if (!NT_SUCCESS (pThreadBlock->ntCreateStatus)) { TCCloseVolume (DeviceObject, Extension); pThreadBlock->mount->nReturnCode = ERR_OS_ERROR; KeSetEvent (&Extension->keCreateEvent, 0, FALSE); PsTerminateSystemThread (STATUS_SUCCESS); } KeSetEvent (&Extension->keCreateEvent, 0, FALSE); /* From this point on pThreadBlock cannot be used as it will have been released! */ pThreadBlock = NULL; for (;;) { /* Wait for a request from the dispatch routines. */ KeWaitForSingleObject ((PVOID) & Extension->RequestSemaphore, Executive, KernelMode, FALSE, NULL); for (;;) { PIO_STACK_LOCATION irpSp; PLIST_ENTRY request; @@ -3657,61 +3690,61 @@ NTSTATUS SendDeviceIoControlRequest (PDEVICE_OBJECT deviceObject, ULONG ioContro return args.Status; } KeInitializeEvent (&event, NotificationEvent, FALSE); irp = IoBuildDeviceIoControlRequest (ioControlCode, deviceObject, inputBuffer, inputBufferSize, outputBuffer, outputBufferSize, FALSE, &event, &ioStatusBlock); if (!irp) return STATUS_INSUFFICIENT_RESOURCES; ObReferenceObject (deviceObject); status = IoCallDriver (deviceObject, irp); if (status == STATUS_PENDING) { KeWaitForSingleObject (&event, Executive, KernelMode, FALSE, NULL); status = ioStatusBlock.Status; } ObDereferenceObject (deviceObject); return status; } NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *driveSize) { NTSTATUS status; LARGE_INTEGER sysLength; LARGE_INTEGER offset; - byte *sectorBuffer; + uint8 *sectorBuffer; ULONGLONG startTime; ULONG sectorSize; if (!UserCanAccessDriveDevice()) return STATUS_ACCESS_DENIED; status = GetDeviceSectorSize (driveDeviceObject, §orSize); if (!NT_SUCCESS (status)) return status; sectorBuffer = TCalloc (sectorSize); if (!sectorBuffer) return STATUS_INSUFFICIENT_RESOURCES; status = SendDeviceIoControlRequest (driveDeviceObject, IOCTL_DISK_GET_LENGTH_INFO, NULL, 0, &sysLength, sizeof (sysLength)); if (!NT_SUCCESS (status)) { Dump ("Failed to get drive size - error %x\n", status); TCfree (sectorBuffer); return status; } startTime = KeQueryInterruptTime (); for (offset.QuadPart = sysLength.QuadPart; ; offset.QuadPart += sectorSize) { status = TCReadDevice (driveDeviceObject, sectorBuffer, offset, sectorSize); if (NT_SUCCESS (status)) @@ -4859,99 +4892,99 @@ NTSTATUS ReadRegistryConfigFlags (BOOL driverEntry) NTSTATUS WriteRegistryConfigFlags (uint32 flags) { UNICODE_STRING name; RtlInitUnicodeString (&name, L"\\REGISTRY\\MACHINE\\SYSTEM\\CurrentControlSet\\Services\\veracrypt"); return TCWriteRegistryKey (&name, TC_DRIVER_CONFIG_REG_VALUE_NAME, REG_DWORD, &flags, sizeof (flags)); } NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector) { NTSTATUS status; DISK_GEOMETRY geometry; status = SendDeviceIoControlRequest (deviceObject, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &geometry, sizeof (geometry)); if (!NT_SUCCESS (status)) return status; *bytesPerSector = geometry.BytesPerSector; return STATUS_SUCCESS; } NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER startOffset, ULONG size, uint64 *zeroedSectorCount) { NTSTATUS status; ULONG sectorSize; ULONG sectorCount; - byte *sectorBuffer = NULL; + uint8 *sectorBuffer = NULL; *zeroedSectorCount = 0; status = GetDeviceSectorSize (deviceObject, §orSize); if (!NT_SUCCESS (status)) return status; sectorBuffer = TCalloc (sectorSize); if (!sectorBuffer) return STATUS_INSUFFICIENT_RESOURCES; for (sectorCount = size / sectorSize; sectorCount > 0; --sectorCount, startOffset.QuadPart += sectorSize) { status = TCReadDevice (deviceObject, sectorBuffer, startOffset, sectorSize); if (!NT_SUCCESS (status)) { Dump ("Zeroing sector at %I64d\n", startOffset.QuadPart); memset (sectorBuffer, 0, sectorSize); status = TCWriteDevice (deviceObject, sectorBuffer, startOffset, sectorSize); if (!NT_SUCCESS (status)) goto err; ++(*zeroedSectorCount); } } status = STATUS_SUCCESS; err: if (sectorBuffer) TCfree (sectorBuffer); return status; } -NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, byte *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount) +NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, uint8 *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount) { NTSTATUS status; ULONG sectorSize; ULONG sectorCount; *badSectorCount = 0; status = GetDeviceSectorSize (deviceObject, §orSize); if (!NT_SUCCESS (status)) return status; for (sectorCount = size / sectorSize; sectorCount > 0; --sectorCount, startOffset.QuadPart += sectorSize, buffer += sectorSize) { status = TCReadDevice (deviceObject, buffer, startOffset, sectorSize); if (!NT_SUCCESS (status)) { Dump ("Skipping bad sector at %I64d\n", startOffset.QuadPart); memset (buffer, 0, sectorSize); ++(*badSectorCount); } } return STATUS_SUCCESS; } BOOL IsVolumeAccessibleByCurrentUser (PEXTENSION volumeDeviceExtension) { SECURITY_SUBJECT_CONTEXT subContext; PACCESS_TOKEN accessToken; diff --git a/src/Driver/Ntdriver.h b/src/Driver/Ntdriver.h index 3bbeb457..3995ffdf 100644 --- a/src/Driver/Ntdriver.h +++ b/src/Driver/Ntdriver.h @@ -164,41 +164,41 @@ NTSTATUS TCFsctlCall (PFILE_OBJECT fileObject, LONG IoControlCode, void *InputBu NTSTATUS CreateDriveLink (int nDosDriveNo); NTSTATUS RemoveDriveLink (int nDosDriveNo); NTSTATUS MountManagerMount (MOUNT_STRUCT *mount); NTSTATUS MountManagerUnmount (int nDosDriveNo); NTSTATUS MountDevice (PDEVICE_OBJECT deviceObject, MOUNT_STRUCT *mount); NTSTATUS UnmountDevice (UNMOUNT_STRUCT *unmountRequest, PDEVICE_OBJECT deviceObject, BOOL ignoreOpenFiles); NTSTATUS UnmountAllDevices (UNMOUNT_STRUCT *unmountRequest, BOOL ignoreOpenFiles); NTSTATUS SymbolicLinkToTarget (PWSTR symlinkName, PWSTR targetName, USHORT maxTargetNameLength); BOOL RootDeviceControlMutexAcquireNoWait (); void RootDeviceControlMutexRelease (); BOOL RegionsOverlap (unsigned __int64 start1, unsigned __int64 end1, unsigned __int64 start2, unsigned __int64 end2); void GetIntersection (uint64 start1, uint32 length1, uint64 start2, uint64 end2, uint64 *intersectStart, uint32 *intersectLength); NTSTATUS TCCompleteIrp (PIRP irp, NTSTATUS status, ULONG_PTR information); NTSTATUS TCCompleteDiskIrp (PIRP irp, NTSTATUS status, ULONG_PTR information); NTSTATUS ProbeRealDriveSize (PDEVICE_OBJECT driveDeviceObject, LARGE_INTEGER *driveSize); BOOL UserCanAccessDriveDevice (); size_t GetCpuCount (WORD* pGroupCount); USHORT GetCpuGroup (size_t index); void SetThreadCpuGroupAffinity (USHORT index); void EnsureNullTerminatedString (wchar_t *str, size_t maxSizeInBytes); void *AllocateMemoryWithTimeout (size_t size, int retryDelay, int timeout); BOOL IsDriveLetterAvailable (int nDosDriveNo, DeviceNamespaceType namespaceType); NTSTATUS TCReadRegistryKey (PUNICODE_STRING keyPath, wchar_t *keyValueName, PKEY_VALUE_PARTIAL_INFORMATION *keyData); NTSTATUS TCWriteRegistryKey (PUNICODE_STRING keyPath, wchar_t *keyValueName, ULONG keyValueType, void *valueData, ULONG valueSize); BOOL IsVolumeClassFilterRegistered (); NTSTATUS ReadRegistryConfigFlags (BOOL driverEntry); NTSTATUS WriteRegistryConfigFlags (uint32 flags); BOOL ValidateIOBufferSize (PIRP irp, size_t requiredBufferSize, ValidateIOBufferSizeType type); NTSTATUS GetDeviceSectorSize (PDEVICE_OBJECT deviceObject, ULONG *bytesPerSector); NTSTATUS ZeroUnreadableSectors (PDEVICE_OBJECT deviceObject, LARGE_INTEGER startOffset, ULONG size, uint64 *zeroedSectorCount); -NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, byte *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount); +NTSTATUS ReadDeviceSkipUnreadableSectors (PDEVICE_OBJECT deviceObject, uint8 *buffer, LARGE_INTEGER startOffset, ULONG size, uint64 *badSectorCount); BOOL IsVolumeAccessibleByCurrentUser (PEXTENSION volumeDeviceExtension); void GetElapsedTimeInit (LARGE_INTEGER *lastPerfCounter); int64 GetElapsedTime (LARGE_INTEGER *lastPerfCounter); BOOL IsOSAtLeast (OSVersionEnum reqMinOS); PDEVICE_OBJECT GetVirtualVolumeDeviceObject (int driveNumber); void GetDriverRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed); #define TC_BUG_CHECK(status) KeBugCheckEx (SECURITY_SYSTEM, __LINE__, (ULONG_PTR) status, 0, 'VC') #endif // TC_HEADER_NTDRIVER diff --git a/src/Driver/Ntvol.c b/src/Driver/Ntvol.c index 177c0bf3..68f63f16 100644 --- a/src/Driver/Ntvol.c +++ b/src/Driver/Ntvol.c @@ -61,70 +61,72 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, /* when mounting with hidden volume protection, we cache the passwords after both outer and hidden volumes are mounted successfully*/ BOOL bAutoCachePassword = mount->bProtectHiddenVolume? FALSE : mount->bCache; Extension->pfoDeviceFile = NULL; Extension->hDeviceFile = NULL; Extension->bTimeStampValid = FALSE; /* default value for storage alignment */ Extension->HostMaximumTransferLength = 65536; Extension->HostMaximumPhysicalPages = 17; Extension->HostAlignmentMask = 0; /* default values for non-SSD drives */ Extension->IncursSeekPenalty = TRUE; Extension->TrimEnabled = FALSE; Extension->DeviceNumber = (ULONG) -1; RtlInitUnicodeString (&FullFileName, pwszMountVolume); InitializeObjectAttributes (&oaFileAttributes, &FullFileName, OBJ_CASE_INSENSITIVE | (forceAccessCheck ? OBJ_FORCE_ACCESS_CHECK : 0) | OBJ_KERNEL_HANDLE, NULL, NULL); KeInitializeEvent (&Extension->keVolumeEvent, NotificationEvent, FALSE); if (Extension->SecurityClientContextValid) { ntStatus = SeImpersonateClientEx (&Extension->SecurityClientContext, NULL); if (!NT_SUCCESS (ntStatus)) goto error; } mount->VolumeMountedReadOnlyAfterDeviceWriteProtected = FALSE; + mount->VolumeMountedReadOnlyAfterPartialSysEnc = FALSE; + mount->VolumeMasterKeyVulnerable = FALSE; // If we are opening a device, query its size first if (bRawDevice) { PARTITION_INFORMATION pi; PARTITION_INFORMATION_EX pix; LARGE_INTEGER diskLengthInfo; DISK_GEOMETRY_EX dg; STORAGE_PROPERTY_QUERY storagePropertyQuery = {0}; - byte* dgBuffer; + uint8* dgBuffer; STORAGE_DEVICE_NUMBER storageDeviceNumber; ntStatus = IoGetDeviceObjectPointer (&FullFileName, FILE_READ_DATA | FILE_READ_ATTRIBUTES, &Extension->pfoDeviceFile, &Extension->pFsdDevice); if (!NT_SUCCESS (ntStatus)) goto error; dgBuffer = TCalloc (256); if (!dgBuffer) { ntStatus = STATUS_INSUFFICIENT_RESOURCES; goto error; } ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY_EX, (char *) dgBuffer, 256); if (!NT_SUCCESS (ntStatus)) { DISK_GEOMETRY geo; ntStatus = TCSendHostDeviceIoControlRequest (DeviceObject, Extension, IOCTL_DISK_GET_DRIVE_GEOMETRY, (char *) &geo, sizeof (geo)); if (!NT_SUCCESS (ntStatus)) { TCfree (dgBuffer); goto error; } memset (&dg, 0, sizeof (dg)); memcpy (&dg.Geometry, &geo, sizeof (geo)); dg.DiskSize.QuadPart = geo.Cylinders.QuadPart * geo.SectorsPerTrack * geo.TracksPerCylinder * geo.BytesPerSector; @@ -620,94 +622,96 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, mount->bCachePim, readBuffer, &mount->VolumePassword, mount->pkcs5_prf, mount->VolumePim, &Extension->cryptoInfo); } ReadVolumeHeaderRecoveryMode = FALSE; if (mount->nReturnCode == 0 || mount->nReturnCode == ERR_CIPHER_INIT_WEAK_KEY) { /* Volume header successfully decrypted */ if (!Extension->cryptoInfo) { /* should never happen */ mount->nReturnCode = ERR_OUTOFMEMORY; ntStatus = STATUS_SUCCESS; goto error; } #ifdef _WIN64 if (IsRamEncryptionEnabled() && (volumeType == TC_VOLUME_TYPE_NORMAL || !mount->bProtectHiddenVolume)) VcProtectKeys (Extension->cryptoInfo, VcGetEncryptionID (Extension->cryptoInfo)); #endif Dump ("Volume header decrypted\n"); Dump ("Required program version = %x\n", (int) Extension->cryptoInfo->RequiredProgramVersion); Dump ("Legacy volume = %d\n", (int) Extension->cryptoInfo->LegacyVolume); + Dump ("Master key vulnerable = %d\n", (int) Extension->cryptoInfo->bVulnerableMasterKey); + + mount->VolumeMasterKeyVulnerable = Extension->cryptoInfo->bVulnerableMasterKey; if (IsHiddenSystemRunning() && !Extension->cryptoInfo->hiddenVolume) { Extension->bReadOnly = mount->bMountReadOnly = TRUE; HiddenSysLeakProtectionCount++; } Extension->cryptoInfo->bProtectHiddenVolume = FALSE; Extension->cryptoInfo->bHiddenVolProtectionAction = FALSE; Extension->cryptoInfo->bPartitionInInactiveSysEncScope = mount->bPartitionInInactiveSysEncScope; /* compute the ID of this volume: SHA-256 of the effective header */ sha256 (Extension->volumeID, readBuffer, TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (volumeType == TC_VOLUME_TYPE_NORMAL) { if (mount->bPartitionInInactiveSysEncScope) { if (Extension->cryptoInfo->EncryptedAreaStart.Value > (unsigned __int64) partitionStartingOffset || Extension->cryptoInfo->EncryptedAreaStart.Value + Extension->cryptoInfo->VolumeSize.Value <= (unsigned __int64) partitionStartingOffset) { // The partition is not within the key scope of system encryption mount->nReturnCode = ERR_PASSWORD_WRONG; ntStatus = STATUS_SUCCESS; goto error; } if (Extension->cryptoInfo->EncryptedAreaLength.Value != Extension->cryptoInfo->VolumeSize.Value) { - // Partial encryption is not supported for volumes mounted as regular - mount->nReturnCode = ERR_ENCRYPTION_NOT_COMPLETED; - ntStatus = STATUS_SUCCESS; - goto error; + // mount as readonly in case of partial system encryption + Extension->bReadOnly = mount->bMountReadOnly = TRUE; + mount->VolumeMountedReadOnlyAfterPartialSysEnc = TRUE; } } else if (Extension->cryptoInfo->HeaderFlags & TC_HEADER_FLAG_NONSYS_INPLACE_ENC) { if (Extension->cryptoInfo->EncryptedAreaLength.Value != Extension->cryptoInfo->VolumeSize.Value) { // Non-system in-place encryption process has not been completed on this volume mount->nReturnCode = ERR_NONSYS_INPLACE_ENC_INCOMPLETE; ntStatus = STATUS_SUCCESS; goto error; } } } Extension->cryptoInfo->FirstDataUnitNo.Value = 0; if (Extension->cryptoInfo->hiddenVolume && IsHiddenSystemRunning()) { // Prevent mount of a hidden system partition if the system hosted on it is currently running if (memcmp (Extension->cryptoInfo->master_keydata_hash, GetSystemDriveCryptoInfo()->master_keydata_hash, sizeof(Extension->cryptoInfo->master_keydata_hash)) == 0) { mount->nReturnCode = ERR_VOL_ALREADY_MOUNTED; ntStatus = STATUS_SUCCESS; goto error; } } switch (volumeType) { case TC_VOLUME_TYPE_NORMAL: @@ -771,62 +775,61 @@ NTSTATUS TCOpenVolume (PDEVICE_OBJECT DeviceObject, break; } Dump ("Volume data offset = %I64d\n", Extension->cryptoInfo->volDataAreaOffset); Dump ("Volume data size = %I64d\n", Extension->DiskLength); Dump ("Volume data end = %I64d\n", Extension->cryptoInfo->volDataAreaOffset + Extension->DiskLength - 1); if (Extension->DiskLength == 0) { Dump ("Incorrect volume size\n"); continue; } // If this is a hidden volume, make sure we are supposed to actually // mount it (i.e. not just to protect it) if (volumeType == TC_VOLUME_TYPE_NORMAL || !mount->bProtectHiddenVolume) { // Validate sector size if (bRawDevice && Extension->cryptoInfo->SectorSize != Extension->HostBytesPerSector) { mount->nReturnCode = ERR_PARAMETER_INCORRECT; ntStatus = STATUS_SUCCESS; goto error; } // Calculate virtual volume geometry Extension->TracksPerCylinder = 1; Extension->SectorsPerTrack = 1; Extension->BytesPerSector = Extension->cryptoInfo->SectorSize; - // Add extra sector since our virtual partition starts at Extension->BytesPerSector and not 0 - Extension->NumberOfCylinders = (Extension->DiskLength / Extension->BytesPerSector) + 1; + Extension->NumberOfCylinders = Extension->DiskLength / Extension->BytesPerSector; Extension->PartitionType = 0; Extension->bRawDevice = bRawDevice; memset (Extension->wszVolume, 0, sizeof (Extension->wszVolume)); if ((wcslen (pwszMountVolume) > 8) && (0 == memcmp (pwszMountVolume, WIDE ("\\??\\UNC\\"), 8 * sizeof (WCHAR)))) { /* UNC path */ RtlStringCbPrintfW (Extension->wszVolume, sizeof (Extension->wszVolume), WIDE ("\\??\\\\%s"), pwszMountVolume + 7); } else { RtlStringCbCopyW (Extension->wszVolume, sizeof(Extension->wszVolume),pwszMountVolume); } memset (Extension->wszLabel, 0, sizeof (Extension->wszLabel)); RtlStringCbCopyW (Extension->wszLabel, sizeof(Extension->wszLabel), mount->wszLabel); } // If we are to protect a hidden volume we cannot exit yet, for we must also // decrypt the hidden volume header. if (!(volumeType == TC_VOLUME_TYPE_NORMAL && mount->bProtectHiddenVolume)) { /* in case of mounting with hidden volume protection, we cache both passwords manually after bother outer and hidden volumes are mounted*/ if (mount->bProtectHiddenVolume && mount->bCache) { AddPasswordToCache(&mount->VolumePassword, mount->VolumePim, mount->bCachePim); diff --git a/src/Driver/veracrypt_vs2019.vcxproj b/src/Driver/veracrypt_vs2019.vcxproj index e956bcb0..8a360525 100644 --- a/src/Driver/veracrypt_vs2019.vcxproj +++ b/src/Driver/veracrypt_vs2019.vcxproj @@ -2,109 +2,120 @@ <Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <ItemGroup Label="ProjectConfigurations"> <ProjectConfiguration Include="Debug|ARM64"> <Configuration>Debug</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Debug|x64"> <Configuration>Debug</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <ItemGroup> <ClCompile Include="..\Common\Cache.c" /> <ClCompile Include="..\Common\Crc.c" /> - <ClCompile Include="..\Common\Crypto.c" /> + <ClCompile Include="..\Common\Crypto.c"> + <CallingConvention Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdCall</CallingConvention> + <CallingConvention Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">StdCall</CallingConvention> + </ClCompile> <ClCompile Include="..\Common\EncryptionThreadPool.c" /> <ClCompile Include="..\Common\Endian.c" /> <ClCompile Include="..\Common\GfMul.c" /> <ClCompile Include="..\Common\Pkcs5.c" /> <ClCompile Include="..\Common\Tests.c" /> <ClCompile Include="..\Common\Volumes.c" /> <ClCompile Include="..\Common\Wipe.c" /> <ClCompile Include="..\Common\Xts.c" /> - <ClCompile Include="..\Crypto\Aescrypt.c" /> + <ClCompile Include="..\Crypto\Aescrypt.c"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + </ClCompile> <ClCompile Include="..\Crypto\Aeskey.c" /> <ClCompile Include="..\Crypto\Aestab.c" /> <ClCompile Include="..\Crypto\blake2s.c" /> <ClCompile Include="..\Crypto\blake2s_SSE2.c" /> <ClCompile Include="..\Crypto\blake2s_SSE41.c" /> <ClCompile Include="..\Crypto\blake2s_SSSE3.c" /> <ClCompile Include="..\Crypto\Camellia.c" /> <ClCompile Include="..\Crypto\chacha-xmm.c" /> <ClCompile Include="..\Crypto\chacha256.c" /> <ClCompile Include="..\Crypto\chachaRng.c" /> <ClCompile Include="..\Crypto\cpu.c" /> <ClCompile Include="..\Crypto\jitterentropy-base.c" /> <ClCompile Include="..\Crypto\kuznyechik.c" /> <ClCompile Include="..\Crypto\kuznyechik_simd.c"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\Crypto\rdrand.c"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </ClCompile> <ClCompile Include="..\Crypto\SerpentFast.c" /> <ClCompile Include="..\Crypto\SerpentFast_simd.cpp"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> + </ClCompile> + <ClCompile Include="..\Crypto\Sha2.c"> + <CallingConvention Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">StdCall</CallingConvention> + <CallingConvention Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">StdCall</CallingConvention> </ClCompile> - <ClCompile Include="..\Crypto\Sha2.c" /> <ClCompile Include="..\Crypto\Streebog.c" /> <ClCompile Include="..\Crypto\t1ha2.c" /> <ClCompile Include="..\Crypto\t1ha2_selfcheck.c" /> <ClCompile Include="..\Crypto\t1ha_selfcheck.c" /> <ClCompile Include="..\Crypto\Twofish.c" /> <ClCompile Include="..\Crypto\Whirlpool.c" /> <ClCompile Include="Ntdriver.c" /> <ClCompile Include="VolumeFilter.c" /> <ClCompile Include="DriveFilter.c" /> <ClCompile Include="DumpFilter.c" /> <ClCompile Include="EncryptedIoQueue.c" /> <ClCompile Include="Ntvol.c" /> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}</ProjectGuid> <TemplateGuid>{f2f62967-0815-4fd7-9b86-6eedcac766eb}</TemplateGuid> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion> <MinimumVisualStudioVersion>12.0</MinimumVisualStudioVersion> <Configuration>Debug</Configuration> <Platform Condition="'$(Platform)' == ''">Win32</Platform> <RootNamespace>veracrypt</RootNamespace> <WindowsTargetPlatformVersion>$(LatestTargetPlatformVersion)</WindowsTargetPlatformVersion> <ProjectName>driver</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>true</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> @@ -143,456 +154,519 @@ <SupportsPackaging>false</SupportsPackaging> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> <DriverType>WDM</DriverType> <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION> <SupportsPackaging>false</SupportsPackaging> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <TargetVersion>Windows10</TargetVersion> <UseDebugLibraries>false</UseDebugLibraries> <PlatformToolset>WindowsKernelModeDriver10.0</PlatformToolset> <ConfigurationType>Driver</ConfigurationType> <DriverType>WDM</DriverType> <_NT_TARGET_VERSION>0x0A00</_NT_TARGET_VERSION> <SupportsPackaging>false</SupportsPackaging> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> - <OutDir>$(SolutionDir)$(Platform)\$(ConfigurationName)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</OutDir> <TargetName>veracrypt</TargetName> + <IntDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <TargetName>veracrypt</TargetName> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> + <OutDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <TargetName>veracrypt</TargetName> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> + <OutDir>$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(ConfigurationName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> <OutDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</OutDir> <TargetName>veracrypt</TargetName> + <IntDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <TargetName>veracrypt</TargetName> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> + <OutDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(ConfigurationName)\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <TargetName>veracrypt</TargetName> <DebuggerFlavor>DbgengKernelDebugger</DebuggerFlavor> + <OutDir>$(ProjectDir)$(ConfigurationName)\</OutDir> + <IntDir>$(ProjectDir)$(ConfigurationName)\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <PostBuildEvent> <Command>copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-arm64.sys"</Command> </PostBuildEvent> <Inf> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <CallingConvention>Cdecl</CallingConvention> </ClCompile> <PostBuildEvent> - <Command>copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-arm64.sys"</Command> + <Command>copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-x64.sys"</Command> </PostBuildEvent> <Inf> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;DEBUG;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <CallingConvention>StdCall</CallingConvention> </ClCompile> <PostBuildEvent> - <Command>copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-arm64.sys"</Command> + <Command>copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt.sys"</Command> </PostBuildEvent> <Inf> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-arm64.sys"</Command> </PostBuildEvent> <Inf> <SpecifyArchitecture>true</SpecifyArchitecture> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <CallingConvention>Cdecl</CallingConvention> </ClCompile> <PostBuildEvent> - <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-arm64.sys"</Command> + <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.sys"</Command> </PostBuildEvent> <Inf> <SpecifyArchitecture>true</SpecifyArchitecture> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Link> <AdditionalDependencies>fltmgr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile> + <GenerateMapFile>true</GenerateMapFile> </Link> <ClCompile> <AdditionalIncludeDirectories>$(SolutionDir)Common;$(SolutionDir)Crypto;$(SolutionDir);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TC_WINDOWS_DRIVER;_WIN32;_NO_CRT_STDIO_INLINE;%(PreprocessorDefinitions)</PreprocessorDefinitions> <DisableSpecificWarnings>4064;4627;4627;4366;4100;4057;4457;4456;4152;4213;4244;4127;4706;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <CallingConvention>StdCall</CallingConvention> </ClCompile> <PostBuildEvent> - <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-arm64.sys"</Command> + <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt.sys"</Command> </PostBuildEvent> <Inf> <SpecifyArchitecture>true</SpecifyArchitecture> <SpecifyDriverVerDirectiveVersion>false</SpecifyDriverVerDirectiveVersion> </Inf> </ItemDefinitionGroup> <ItemGroup> <FilesToPackage Include="$(TargetPath)" /> </ItemGroup> <ItemGroup> + <ClInclude Include="..\Common\Tcdefs.h" /> <ClInclude Include="..\Crypto\Aes.h" /> <ClInclude Include="..\Crypto\Aesopt.h" /> <ClInclude Include="..\Crypto\AesSmall.h" /> <ClInclude Include="..\Crypto\Aestab.h" /> <ClInclude Include="..\Crypto\Aes_hw_cpu.h" /> <ClInclude Include="..\Crypto\Camellia.h" /> <ClInclude Include="..\Crypto\chacha256.h" /> <ClInclude Include="..\Crypto\chachaRng.h" /> <ClInclude Include="..\Crypto\chacha_u1.h" /> <ClInclude Include="..\Crypto\chacha_u4.h" /> <ClInclude Include="..\Crypto\config.h" /> <ClInclude Include="..\Crypto\cpu.h" /> <ClInclude Include="..\Crypto\GostCipher.h" /> <ClInclude Include="..\Crypto\jitterentropy-base-user.h" /> <ClInclude Include="..\Crypto\jitterentropy.h" /> <ClInclude Include="..\Crypto\kuznyechik.h" /> <ClInclude Include="..\Crypto\misc.h" /> <ClInclude Include="..\Crypto\rdrand.h" /> <ClInclude Include="..\Crypto\Rmd160.h" /> <ClInclude Include="..\Crypto\SerpentFast.h" /> <ClInclude Include="..\Crypto\SerpentFast_sbox.h" /> <ClInclude Include="..\Crypto\Sha2.h" /> <ClInclude Include="..\Crypto\Streebog.h" /> <ClInclude Include="..\Crypto\t1ha.h" /> <ClInclude Include="..\Crypto\t1ha_bits.h" /> <ClInclude Include="..\Crypto\t1ha_selfcheck.h" /> <ClInclude Include="..\Crypto\Twofish.h" /> <ClInclude Include="..\Crypto\Whirlpool.h" /> <ClInclude Include="DriveFilter.h" /> <ClInclude Include="DumpFilter.h" /> <ClInclude Include="EncryptedIoQueue.h" /> <ClInclude Include="Ntdriver.h" /> <ClInclude Include="Ntvol.h" /> <ClInclude Include="Resource.h" /> <ClInclude Include="VolumeFilter.h" /> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Aes_hw_cpu.asm"> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -g -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox --prefix _ -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Aes_x64.asm"> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win64 -Ox -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Aes_x86.asm"> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox -g --prefix _ -o "$(TargetDir)\%(Filename).obj" "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & nasm.exe -Xvc -f win32 -Ox --prefix _ -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Twofish_x64.S"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Camellia_aesni_x64.S"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Camellia_x64.S"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -p gas -D WINABI -D __YASM__ -f win64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha256-x86-nayuki.S"> <FileType>Document</FileType> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & vsyasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f win32 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & vsyasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f win32 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha256_avx1_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha256_avx2_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha256_sse4_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha512-x86-nayuki.S"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & vsyasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f win32 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & vsyasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f win32 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha512-x64-nayuki.S"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -Xvc -p gas -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha512_avx1_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha512_avx2_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\sha512_sse4_x64.asm"> <FileType>Document</FileType> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & yasm.exe -D WINABI -D __YASM__ -f x64 -o "$(TargetDir)\%(Filename).obj" -l "$(TargetDir)\%(Filename).lst" "%(FullPath)"</Command> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> + <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\rdrand_ml.asm"> <FileType>Document</FileType> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & ml.exe /nologo /D_M_X86 /W3 /Cx /Zi /safeseh /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & ml.exe /nologo /D_M_X86 /W3 /Cx /Zi /safeseh /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)"</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </CustomBuild> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\rdseed_ml.asm"> <FileType>Document</FileType> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">echo %(Filename)%(Extension) & ml.exe /nologo /D_M_X86 /W3 /Cx /Zi /safeseh /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)"</Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> <Command Condition="'$(Configuration)|$(Platform)'=='Release|x64'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" </Command> - <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & ml64.exe /nologo /D_M_X64 /W3 /Cx /Zi /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)" -</Command> + <Command Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo %(Filename)%(Extension) & ml.exe /nologo /D_M_X86 /W3 /Cx /Zi /safeseh /Fo "$(TargetDir)\%(Filename).obj" /c "%(FullPath)"</Command> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <Outputs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(TargetDir)\%(Filename).obj;%(Outputs)</Outputs> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</ExcludedFromBuild> <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild> - <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</ExcludedFromBuild> </CustomBuild> </ItemGroup> <ItemGroup> <ResourceCompile Include="Driver.rc" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> </ImportGroup> </Project>
\ No newline at end of file diff --git a/src/Driver/veracrypt_vs2019.vcxproj.filters b/src/Driver/veracrypt_vs2019.vcxproj.filters index f0c7d0e3..43a1a222 100644 --- a/src/Driver/veracrypt_vs2019.vcxproj.filters +++ b/src/Driver/veracrypt_vs2019.vcxproj.filters @@ -237,60 +237,63 @@ <ClInclude Include="..\Crypto\SerpentFast.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\SerpentFast_sbox.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\Sha2.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\Streebog.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\t1ha.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\t1ha_bits.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\t1ha_selfcheck.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\Twofish.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\Whirlpool.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> <ClInclude Include="..\Crypto\AesSmall.h"> <Filter>Crypto\Header Files</Filter> </ClInclude> + <ClInclude Include="..\Common\Tcdefs.h"> + <Filter>Common</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <CustomBuild Include="..\Crypto\Aes_hw_cpu.asm"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\Aes_x64.asm"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\Aes_x86.asm"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\Twofish_x64.S"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\Camellia_aesni_x64.S"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\Camellia_x64.S"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\sha256-x86-nayuki.S"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\sha256_avx1_x64.asm"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\sha256_avx2_x64.asm"> <Filter>Crypto\Source Files</Filter> </CustomBuild> <CustomBuild Include="..\Crypto\sha256_sse4_x64.asm"> diff --git a/src/ExpandVolume/ExpandVolume.c b/src/ExpandVolume/ExpandVolume.c index 424948ea..34184dda 100644 --- a/src/ExpandVolume/ExpandVolume.c +++ b/src/ExpandVolume/ExpandVolume.c @@ -481,70 +481,71 @@ error: lpszVolume : char * [in] Pointer to a string that contains the path to the truecrypt volume pVolumePassword : Password * [in] Pointer to the volume password newHostSize : uint64 [in] new value of the volume host size (can be zero for devices, which means the volume should use all space of the host device) initFreeSpace : BOOL [in] if true, the new volume space will be initalized with random data Return value: int with Truecrypt error code (ERR_SUCCESS on success) Remarks: a lot of code is from TrueCrypt 'Common\Password.c' :: ChangePwd() */ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePassword, int VolumePkcs5, int VolumePim, uint64 newHostSize, BOOL initFreeSpace, BOOL bQuickExpand) { int nDosLinkCreated = 1, nStatus = ERR_OS_ERROR; wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; wchar_t szDosDevice[TC_MAX_PATH]; char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; PCRYPTO_INFO cryptoInfo = NULL, ci = NULL; void *dev = INVALID_HANDLE_VALUE; DWORD dwError; + DWORD bytesRead; BOOL bDevice; uint64 hostSize=0, newDataAreaSize, currentVolSize; DWORD HostSectorSize; FILETIME ftCreationTime; FILETIME ftLastWriteTime; FILETIME ftLastAccessTime; BOOL bTimeStampValid = FALSE; LARGE_INTEGER headerOffset; BOOL backupHeader; - byte *wipeBuffer = NULL; + uint8 *wipeBuffer = NULL; uint32 workChunkSize = TC_VOLUME_HEADER_GROUP_SIZE; #ifdef _WIN64 CRYPTO_INFO tmpCI; PCRYPTO_INFO cryptoInfoBackup = NULL; BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled(); #endif if (pVolumePassword->Length == 0) return -1; WaitCursor (); CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice); if (bDevice == FALSE) { StringCchCopyW (szCFDevice, ARRAYSIZE(szCFDevice), szDiskFile); } else { nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice), szCFDevice, sizeof(szCFDevice), FALSE); if (nDosLinkCreated != 0) // note: nStatus == ERR_OS_ERROR 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) goto error; else if (!bDevice && bPreserveTimestamp) @@ -645,73 +646,84 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas if (!GetFileSizeEx (dev, &fileSize)) { nStatus = ERR_OS_ERROR; goto error; } hostSize = fileSize.QuadPart; HostSectorSize = TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; //TO DO: get the real host disk sector size } if (Randinit ()) { if (CryptoAPILastError == ERROR_SUCCESS) nStatus = ERR_RAND_INIT_FAILED; else nStatus = ERR_CAPI_INIT_FAILED; goto error; } // Seek the volume header headerOffset.QuadPart = TC_VOLUME_HEADER_OFFSET; if (!SetFilePointerEx ((HANDLE) dev, headerOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } /* Read in volume header */ - nStatus = _lread ((HFILE) dev, buffer, sizeof (buffer)); - if (nStatus != sizeof (buffer)) + if (!ReadEffectiveVolumeHeader (bDevice, dev, buffer, &bytesRead)) + { + nStatus = ERR_OS_ERROR; + goto error; + } + + if (bytesRead != sizeof (buffer)) { // Windows may report EOF when reading sectors from the last cluster of a device formatted as NTFS memset (buffer, 0, sizeof (buffer)); } /* Try to decrypt the header */ nStatus = ReadVolumeHeader (FALSE, buffer, pVolumePassword, VolumePkcs5, VolumePim, &cryptoInfo, NULL); if (nStatus == ERR_CIPHER_INIT_WEAK_KEY) nStatus = 0; // We can ignore this error here + // if the volume master key is vulnerable, print a warning to inform the user + if ((nStatus == 0) && cryptoInfo->bVulnerableMasterKey) + { + DebugAddProgressDlgStatus(hwndDlg, GetString ("ERR_XTS_MASTERKEY_VULNERABLE_SHORT")); + } + if (nStatus != 0) { cryptoInfo = NULL; goto error; } #ifdef _WIN64 if (bIsRamEncryptionEnabled) { VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo)); } #endif if (cryptoInfo->HeaderFlags & TC_HEADER_FLAG_ENCRYPTED_SYSTEM) { nStatus = ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG; goto error; } if (bDevice && newHostSize == 0) { // this means we shall take all host space as new volume size newHostSize = hostSize; } if ( newHostSize % cryptoInfo->SectorSize != 0 || newHostSize > TC_MAX_VOLUME_SIZE || (bDevice && newHostSize > hostSize) ) { // 1. must be multiple of sector size // 2. truecrypt volume size limit // 3. for devices volume size can't be larger than host size @@ -990,78 +1002,78 @@ static int ExpandVolume (HWND hwndDlg, wchar_t *lpszVolume, Password *pVolumePas } if (!WriteEffectiveVolumeHeader (bDevice, dev, buffer)) { nStatus = ERR_OS_ERROR; goto error; } } FlushFileBuffers (dev); if (!backupHeader) break; backupHeader = FALSE; headerOffset.QuadPart = TC_VOLUME_HEADER_OFFSET; // offset for main header } /* header successfully updated */ nStatus = ERR_SUCCESS; if (bVolTransformThreadCancel) { nStatus = ERR_USER_ABORT; goto error; } /* wipe old backup header */ if ( !cryptoInfo->LegacyVolume ) { - byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; - byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; - byte wipePass; + uint8 wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; + uint8 wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; + uint8 wipePass; UINT64_STRUCT unitNo; LARGE_INTEGER offset; WipeAlgorithmId wipeAlgorithm = TC_WIPE_35_GUTMANN; if ( !RandgetBytes (hwndDlg, wipeRandChars, TC_WIPE_RAND_CHAR_COUNT, TRUE) || !RandgetBytes (hwndDlg, wipeRandCharsUpdate, TC_WIPE_RAND_CHAR_COUNT, TRUE) ) { nStatus = ERR_OS_ERROR; goto error; } DebugAddProgressDlgStatus(hwndDlg, GetString("EXPANDER_WIPING_OLD_HEADER")); - wipeBuffer = (byte *) TCalloc (workChunkSize); + wipeBuffer = (uint8 *) TCalloc (workChunkSize); if (!wipeBuffer) { nStatus = ERR_OUTOFMEMORY; goto error; } offset.QuadPart = currentVolSize - TC_VOLUME_HEADER_GROUP_SIZE; unitNo.Value = offset.QuadPart; for (wipePass = 1; wipePass <= GetWipePassCount (wipeAlgorithm); ++wipePass) { if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize)) { ULONG i; for (i = 0; i < workChunkSize; ++i) { wipeBuffer[i] = wipePass; } EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, cryptoInfo); memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate)); } if ( !SetFilePointerEx (dev, offset, NULL, FILE_BEGIN) || _lwrite ((HFILE)dev, (LPCSTR)wipeBuffer, workChunkSize) == HFILE_ERROR ) { // Write error DebugAddProgressDlgStatus(hwndDlg, L"Warning: Failed to wipe old backup header\r\n"); MessageBoxW (hwndDlg, L"WARNING: Failed to wipe old backup header!\n\nIt may be possible to use the current volume password to decrypt the old backup header even after a future password change.\n", lpszTitle, MB_OK | MB_ICONEXCLAMATION); diff --git a/src/ExpandVolume/ExpandVolume.rc b/src/ExpandVolume/ExpandVolume.rc index 41ed8c09..69c77dc4 100644 --- a/src/ExpandVolume/ExpandVolume.rc +++ b/src/ExpandVolume/ExpandVolume.rc @@ -165,83 +165,83 @@ BEGIN END IDD_EXPAND_PROGRESS_DLG, DIALOG BEGIN RIGHTMARGIN, 361 VERTGUIDE, 15 VERTGUIDE, 73 VERTGUIDE, 80 VERTGUIDE, 355 TOPMARGIN, 9 BOTTOMMARGIN, 268 HORZGUIDE, 176 END END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // HEADER // IDR_MOUNT_RSRC_HEADER HEADER "resource.h" ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Expander" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCryptExpander.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "#include ""..\\\\common\\\\resource.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "#include ""..\\\\common\\\\common.rc""\r\n" diff --git a/src/ExpandVolume/ExpandVolume.vcxproj b/src/ExpandVolume/ExpandVolume.vcxproj index ce87f4fb..62ff1a09 100644 --- a/src/ExpandVolume/ExpandVolume.vcxproj +++ b/src/ExpandVolume/ExpandVolume.vcxproj @@ -167,394 +167,394 @@ <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>false</FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;..\Common\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)ExpandVolume.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptExpander.exe "..\Debug\Setup Files" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <CustomBuildStep> <Command> </Command> </CustomBuildStep> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>false</FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;..\Common\x64\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)ExpandVolume.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCryptExpander-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptExpander.exe "..\Release\Setup Files\"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptExpander.exe "..\Release\Setup Files\"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;VC_EFI_CUSTOM_MODE;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptExpander.exe "..\Release\Setup Files\"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;VC_EFI_CUSTOM_MODE;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ProjectReference Include="..\Boot\Windows\Boot.vcxproj"> <Project>{8b7f059f-e4c7-4e11-88f5-ee8b8433072e}</Project> <ReferenceOutputAssembly>false</ReferenceOutputAssembly> </ProjectReference> <ProjectReference Include="..\Common\Lzma.vcxproj"> <Project>{b896fe1f-6bf3-4f75-9148-f841829073d9}</Project> </ProjectReference> <ProjectReference Include="..\Crypto\Crypto.vcxproj"> <Project>{993245cf-6b70-47ee-91bb-39f8fc6dc0e7}</Project> diff --git a/src/ExpandVolume/ExpandVolume_vs2019.vcxproj b/src/ExpandVolume/ExpandVolume_vs2019.vcxproj index 555c6d8f..e053cadf 100644 --- a/src/ExpandVolume/ExpandVolume_vs2019.vcxproj +++ b/src/ExpandVolume/ExpandVolume_vs2019.vcxproj @@ -23,80 +23,83 @@ </ProjectConfiguration> <ProjectConfiguration Include="ReleaseCustomEFI|x64"> <Configuration>ReleaseCustomEFI</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}</ProjectGuid> <RootNamespace>ExpandVolume</RootNamespace> <Keyword>Win32Proj</Keyword> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <ProjectName>ExpandVolume</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> @@ -106,530 +109,539 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">VeraCryptExpander</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">VeraCryptExpander</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <CustomBuildStep> <Command> </Command> </CustomBuildStep> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)ExpandVolume.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptExpander.exe "..\Debug\Setup Files" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <CustomBuildStep> <Command> </Command> </CustomBuildStep> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)ExpandVolume.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCryptExpander-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <CustomBuildStep> <Command> </Command> </CustomBuildStep> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)ExpandVolume.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <DataExecutionPrevention>true</DataExecutionPrevention> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCryptExpander-arm64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptExpander.exe "..\Release\Setup Files\"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;VC_EFI_CUSTOM_MODE;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptExpander.exe "..\Release\Setup Files\"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Release\crypto.lib;..\Common\ARM64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;VC_EFI_CUSTOM_MODE;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/Mount/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\pkcs11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VCEXPANDER;VC_EFI_CUSTOM_MODE;TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level3</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4311;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\AMD64\Release\crypto.lib;..\Common\AMD64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptExpander.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> </Link> <Manifest> <AdditionalManifestFiles>VeraCryptExpander.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCryptExpander-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ProjectReference Include="..\Common\Lzma_vs2019.vcxproj"> <Project>{b896fe1f-6bf3-4f75-9148-f841829073d9}</Project> </ProjectReference> <ProjectReference Include="..\Crypto\Crypto_vs2019.vcxproj"> <Project>{993245cf-6b70-47ee-91bb-39f8fc6dc0e7}</Project> <CopyLocalSatelliteAssemblies>true</CopyLocalSatelliteAssemblies> <ReferenceOutputAssembly>true</ReferenceOutputAssembly> </ProjectReference> <ProjectReference Include="..\Format\Format_vs2019.vcxproj"> <Project>{9dc1abe2-d18b-48fb-81d2-8c50adc57bcf}</Project> diff --git a/src/ExpandVolume/InitDataArea.c b/src/ExpandVolume/InitDataArea.c index 709f44b9..7237754a 100644 --- a/src/ExpandVolume/InitDataArea.c +++ b/src/ExpandVolume/InitDataArea.c @@ -189,61 +189,61 @@ BOOL WriteSector (void *dev, char *sector, char *write_buf, int *write_buf_cnt, __int64 *nSecNo, PCRYPTO_INFO cryptoInfo) { static __int32 updateTime = 0; (*nSecNo)++; memcpy (write_buf + *write_buf_cnt, sector, FormatSectorSize); (*write_buf_cnt) += FormatSectorSize; if (*write_buf_cnt == FormatWriteBufferSize && !FlushFormatWriteBuffer (dev, write_buf, write_buf_cnt, nSecNo, cryptoInfo)) return FALSE; if (GetTickCount () - updateTime > 25) { if (UpdateProgressBar (*nSecNo * FormatSectorSize)) return FALSE; updateTime = GetTickCount (); } return TRUE; } static volatile BOOL WriteThreadRunning; static volatile BOOL WriteThreadExitRequested; static HANDLE WriteThreadHandle; -static byte *WriteThreadBuffer; +static uint8 *WriteThreadBuffer; static HANDLE WriteBufferEmptyEvent; static HANDLE WriteBufferFullEvent; static volatile HANDLE WriteRequestHandle; static volatile int WriteRequestSize; static volatile DWORD WriteRequestResult; static void __cdecl FormatWriteThreadProc (void *arg) { DWORD bytesWritten; SetThreadPriority (GetCurrentThread(), THREAD_PRIORITY_HIGHEST); while (!WriteThreadExitRequested) { if (WaitForSingleObject (WriteBufferFullEvent, INFINITE) == WAIT_FAILED) { handleWin32Error (NULL, SRC_POS); break; } if (WriteThreadExitRequested) break; if (!WriteFile (WriteRequestHandle, WriteThreadBuffer, WriteRequestSize, &bytesWritten, NULL)) WriteRequestResult = GetLastError(); else WriteRequestResult = ERROR_SUCCESS; diff --git a/src/ExpandVolume/VeraCryptExpander.manifest b/src/ExpandVolume/VeraCryptExpander.manifest index 36c64bca..4905cac0 100644 --- a/src/ExpandVolume/VeraCryptExpander.manifest +++ b/src/ExpandVolume/VeraCryptExpander.manifest @@ -1,22 +1,39 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> - <v3:trustInfo xmlns:v3="urn:schemas-microsoft-com:asm.v3"> - <v3:security> - <v3:requestedPrivileges> - <v3:requestedExecutionLevel level="requireAdministrator" /> - </v3:requestedPrivileges> - </v3:security> - </v3:trustInfo> +<?xml version="1.0" encoding="utf-8" standalone="yes"?> +<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level="requireAdministrator" /> + </requestedPrivileges> + </security> + </trustInfo> + <asmv3:application> + <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> + <dpiAware>true</dpiAware> + </asmv3:windowsSettings> + </asmv3:application> + <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> + <application> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> + <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> + </application> + </compatibility> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly> diff --git a/src/ExpandVolume/WinMain.cpp b/src/ExpandVolume/WinMain.cpp index c2387d9e..9a822153 100644 --- a/src/ExpandVolume/WinMain.cpp +++ b/src/ExpandVolume/WinMain.cpp @@ -809,61 +809,61 @@ int ExtcvAskVolumePassword (HWND hwndDlg, const wchar_t* fileName, Password *pas PasswordDialogTitleStringId = titleStringId; PasswordDialogDisableMountOptions = !enableMountOptions; dlgParam.password = password; dlgParam.pkcs5 = pkcs5; dlgParam.pim = pim; StringCbCopyW (PasswordDlgVolume, sizeof(PasswordDlgVolume), fileName); result = SecureDesktopDialogBoxParam (hInst, MAKEINTRESOURCEW (IDD_PASSWORD_DLG), hwndDlg, (DLGPROC) ExtcvPasswordDlgProc, (LPARAM) &dlgParam); if (result != IDOK) { password->Length = 0; *pkcs5 = 0; *pim = 0; burn (&mountOptions.ProtectedHidVolPassword, sizeof (mountOptions.ProtectedHidVolPassword)); burn (&mountOptions.ProtectedHidVolPkcs5Prf, sizeof (mountOptions.ProtectedHidVolPkcs5Prf)); } return result == IDOK; } // GUI actions static BOOL SelectContainer (HWND hwndDlg) { - if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE, NULL) == FALSE) + if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE) == FALSE) return FALSE; AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory); VeraCryptExpander::EnableDisableButtons (hwndDlg); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); return TRUE; } static BOOL SelectPartition (HWND hwndDlg) { RawDevicesDlgParam param; param.pszFileName = szFileName; INT_PTR nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg, (DLGPROC) RawDevicesDlgProc, (LPARAM) & param); if (nResult == IDOK) { AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory); VeraCryptExpander::EnableDisableButtons (hwndDlg); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); return TRUE; } return FALSE; } void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) { wchar_t **lpszCommandLineArgs = NULL; /* Array of command line arguments */ int nNoCommandLineArgs; /* The number of arguments in the array */ @@ -935,61 +935,61 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { case WM_INITDIALOG: { int exitCode = 0; MainDlg = hwndDlg; // Set critical default options in case UsePreferences is false bPreserveTimestamp = defaultMountOptions.PreserveTimestamp = TRUE; bShowDisconnectedNetworkDrives = FALSE; bHideWaitingDialog = FALSE; bUseSecureDesktop = FALSE; bUseLegacyMaxPasswordLength = FALSE; VeraCryptExpander::ExtractCommandLine (hwndDlg, (wchar_t *) lParam); if (UsePreferences) { // General preferences VeraCryptExpander::LoadSettings (hwndDlg); // Keyfiles LoadDefaultKeyFilesParam (); RestoreDefaultKeyFilesParam (); } if (EnableMemoryProtection) { /* Protect this process memory from being accessed by non-admin users */ - EnableProcessProtection (); + ActivateMemoryProtection (); } InitMainDialog (hwndDlg); // Quit if (Quit) { exit (exitCode); } Silent = FALSE; } return 0; case WM_SYSCOMMAND: if (lw == IDC_ABOUT) { DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc); return 1; } return 0; case WM_ENDSESSION: VeraCryptExpander::EndMainDlg (hwndDlg); localcleanup (); return 0; case WM_DROPFILES: { HDROP hdrop = (HDROP) wParam; diff --git a/src/Format/Format.manifest b/src/Format/Format.manifest index 5d4cb896..79d86799 100644 --- a/src/Format/Format.manifest +++ b/src/Format/Format.manifest @@ -1,33 +1,39 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
\ No newline at end of file diff --git a/src/Format/Format.rc b/src/Format/Format.rc index 7d60524e..c988a811 100644 --- a/src/Format/Format.rc +++ b/src/Format/Format.rc @@ -1,83 +1,83 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" #include "..\\common\\resource.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Format" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt Format.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END ///////////////////////////////////////////////////////////////////////////// // // HEADER // IDR_FORMAT_RSRC_HEADER HEADER "resource.h" ///////////////////////////////////////////////////////////////////////////// // // TYPELIB // IDR_FORMAT_TLB TYPELIB "Format.tlb" ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_VOL_CREATION_WIZARD_DLG DIALOGEX 0, 0, 450, 250 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU diff --git a/src/Format/Format.vcxproj b/src/Format/Format.vcxproj index 06e3dca7..1ae26d43 100644 --- a/src/Format/Format.vcxproj +++ b/src/Format/Format.vcxproj @@ -154,356 +154,356 @@ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">VeraCryptFormat</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;..\Common\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;..\Common\x64\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptFormat.exe "..\Release\Setup Files\VeraCrypt Format.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptFormat.exe "..\Release\Setup Files\VeraCrypt Format.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptFormat.exe "..\Release\Setup Files\VeraCrypt Format.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\Common\CommandAPDU.cpp" /> <ClCompile Include="..\Common\EMVCard.cpp" /> <ClCompile Include="..\Common\EMVToken.cpp" /> <ClCompile Include="..\Common\PCSCException.cpp" /> <ClCompile Include="..\Common\ResponseAPDU.cpp" /> <ClCompile Include="..\Common\SCard.cpp" /> <ClCompile Include="..\Common\SCardLoader.cpp" /> <ClCompile Include="..\Common\SCardManager.cpp" /> <ClCompile Include="..\Common\SCardReader.cpp" /> <ClCompile Include="..\Common\TLVParser.cpp" /> diff --git a/src/Format/FormatCom.cpp b/src/Format/FormatCom.cpp index 18653761..90333f23 100644 --- a/src/Format/FormatCom.cpp +++ b/src/Format/FormatCom.cpp @@ -160,60 +160,65 @@ public: virtual DWORD STDMETHODCALLTYPE RestoreEfiSystemLoader () { return BaseCom::RestoreEfiSystemLoader (); } virtual DWORD STDMETHODCALLTYPE GetEfiBootDeviceNumber (BSTR* pSdn) { return BaseCom::GetEfiBootDeviceNumber (pSdn); } virtual DWORD STDMETHODCALLTYPE GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { return BaseCom::GetSecureBootConfig (pSecureBootEnabled, pVeraCryptKeysLoaded); } virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) { return BaseCom::WriteEfiBootSectorUserConfig (userConfig, customUserMessage,pim, hashAlg); } virtual DWORD STDMETHODCALLTYPE UpdateSetupConfigFile (BOOL bForInstall) { return BaseCom::UpdateSetupConfigFile (bForInstall); } virtual DWORD STDMETHODCALLTYPE NotifyService (DWORD dwNotifyCode) { return BaseCom::NotifyService (dwNotifyCode); } + virtual DWORD STDMETHODCALLTYPE FastFileResize (BSTR filePath, __int64 fileSize) + { + return BaseCom::FastFileResize (filePath, fileSize); + } + protected: DWORD MessageThreadId; LONG RefCount; ITrueCryptFormatCom *CallBack; }; extern "C" BOOL ComServerFormat () { SetProcessShutdownParameters (0x100, 0); TrueCryptFactory<TrueCryptFormatCom> factory (GetCurrentThreadId ()); DWORD cookie; if (IsUacSupported ()) UacElevated = TRUE; if (CoRegisterClassObject (CLSID_TrueCryptFormatCom, (LPUNKNOWN) &factory, CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &cookie) != S_OK) return FALSE; MSG msg; while (int r = GetMessageW (&msg, NULL, 0, 0)) { if (r == -1) return FALSE; TranslateMessage (&msg); DispatchMessageW (&msg); @@ -223,115 +228,141 @@ extern "C" BOOL ComServerFormat () break; } CoRevokeClassObject (cookie); return TRUE; } static BOOL ComGetInstance (HWND hWnd, ITrueCryptFormatCom **tcServer) { return ComGetInstanceBase (hWnd, CLSID_TrueCryptFormatCom, IID_ITrueCryptFormatCom, (void **) tcServer); } ITrueCryptFormatCom *GetElevatedInstance (HWND parent) { ITrueCryptFormatCom *instance; if (!ComGetInstance (parent, &instance)) throw UserAbort (SRC_POS); return instance; } extern "C" int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize) { CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hWnd, &tc)) r = tc->FormatNtfs (driveNo, clusterSize); else r = (int) GetLastError(); CoUninitialize (); return r; } extern "C" int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType) { CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hWnd, &tc)) r = tc->FormatFs (driveNo, clusterSize, fsType); else r = (int) GetLastError(); CoUninitialize (); return r; } extern "C" int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters) { CComPtr<ITrueCryptFormatCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) r = tc->AnalyzeHiddenVolumeHost ((__int64) hwndDlg, driveNo, hiddenVolHostSize, realClusterSize, nbrFreeClusters); else r = 0; CoUninitialize (); return r; } extern "C" BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value) { CComPtr<ITrueCryptFormatCom> tc; int r = 0; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) { CComBSTR keyPathBstr, valueNameBstr; BSTR bstr = W2BSTR(keyPath); if (bstr) { keyPathBstr.Attach (bstr); bstr = W2BSTR(valueName); if (bstr) { valueNameBstr.Attach (bstr); r = tc->WriteLocalMachineRegistryDwordValue (keyPathBstr, valueNameBstr, value); } else r = ERROR_OUTOFMEMORY; } else r = ERROR_OUTOFMEMORY; } CoUninitialize (); if (r == ERROR_SUCCESS) return TRUE; else { SetLastError (r); return FALSE; } } +extern "C" DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize) +{ + CComPtr<ITrueCryptFormatCom> tc; + DWORD r; + + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); + + if (ComGetInstance (hWnd, &tc)) + { + CComBSTR filePathBstr; + BSTR bstr = W2BSTR(filePath); + if (bstr) + { + filePathBstr.Attach (bstr); + r = tc->FastFileResize (filePathBstr, fileSize); + } + else + r = ERROR_OUTOFMEMORY; + } + else + r = GetLastError(); + + CoUninitialize (); + + return r; +} diff --git a/src/Format/FormatCom.h b/src/Format/FormatCom.h index 5ab6bd52..e474608d 100644 --- a/src/Format/FormatCom.h +++ b/src/Format/FormatCom.h @@ -3,36 +3,37 @@ 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_FORMAT_COM #define TC_HEADER_FORMAT_COM #include <windows.h> #ifdef __cplusplus #include "FormatCom_h.h" ITrueCryptFormatCom *GetElevatedInstance (HWND parent); extern "C" { #endif BOOL ComServerFormat (); int UacFormatNtfs (HWND hWnd, int driveNo, int clusterSize); int UacFormatFs (HWND hWnd, int driveNo, int clusterSize, int fsType); int UacAnalyzeHiddenVolumeHost (HWND hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters); int UacFormatVolume (char *cvolumePath , BOOL bDevice , unsigned __int64 size , unsigned __int64 hiddenVolHostSize , Password *password , int cipher , int pkcs5 , BOOL quickFormat, BOOL sparseFileSwitch, int fileSystem , int clusterSize, HWND hwndDlg , BOOL hiddenVol , int *realClusterSize); BOOL UacUpdateProgressBar (__int64 nSecNo, BOOL *bVolTransformThreadCancel); BOOL UacWriteLocalMachineRegistryDword (HWND hwndDlg, wchar_t *keyPath, wchar_t *valueName, DWORD value); +DWORD UacFastFileCreation (HWND hWnd, wchar_t* filePath, __int64 fileSize); #ifdef __cplusplus } #endif #endif // TC_HEADER_FORMAT_COM
\ No newline at end of file diff --git a/src/Format/FormatCom.idl b/src/Format/FormatCom.idl index cae4e155..7276de81 100644 --- a/src/Format/FormatCom.idl +++ b/src/Format/FormatCom.idl @@ -23,41 +23,42 @@ library TrueCryptFormatCom [ uuid(7AB357D9-A17F-466e-BCD6-F49E97C218D8), object, oleautomation, helpstring("VeraCrypt Format UAC Support Interface") ] interface ITrueCryptFormatCom : IUnknown { int AnalyzeHiddenVolumeHost (__int64 hwndDlg, int *driveNo, __int64 hiddenVolHostSize, int *realClusterSize, __int64 *nbrFreeClusters); DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output); DWORD CopyFile (BSTR sourceFile, BSTR destinationFile); DWORD DeleteFile (BSTR file); BOOL FormatNtfs (int driveNo, int clusterSize); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone); DWORD RegisterFilterDriver (BOOL registerDriver, int filterType); DWORD RegisterSystemFavoritesService (BOOL registerService); DWORD SetDriverServiceStartType (DWORD startType); DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value); BOOL FormatFs (int driveNo, int clusterSize, int fsType); DWORD GetFileSize (BSTR filePath, unsigned __int64* pSize); DWORD DeviceIoControl (BOOL readOnly, BOOL device, BSTR filePath, DWORD dwIoControlCode, BSTR input, BSTR *output); DWORD InstallEfiBootLoader (BOOL preserveUserConfig, BOOL hiddenOSCreation, int pim, int hashAlg); DWORD BackupEfiSystemLoader (); DWORD RestoreEfiSystemLoader (); DWORD GetEfiBootDeviceNumber (BSTR* pSdn); DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); DWORD UpdateSetupConfigFile (BOOL bForInstall); DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded); DWORD NotifyService (DWORD dwNotifyCode); + DWORD FastFileResize (BSTR filePath, __int64 fileSize); }; [ uuid(A96D3797-9F31-49f4-A0CE-9657392CF789), helpstring("VeraCrypt Format UAC Support Coclass") ] coclass TrueCryptFormatCom { [default] interface ITrueCryptFormatCom; } } diff --git a/src/Format/Format_vs2019.vcxproj b/src/Format/Format_vs2019.vcxproj index 819724f2..dc8de14a 100644 --- a/src/Format/Format_vs2019.vcxproj +++ b/src/Format/Format_vs2019.vcxproj @@ -23,80 +23,83 @@ </ProjectConfiguration> <ProjectConfiguration Include="ReleaseCustomEFI|x64"> <Configuration>ReleaseCustomEFI</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}</ProjectGuid> <RootNamespace>Format</RootNamespace> <Keyword>Win32Proj</Keyword> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <ProjectName>Format</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> @@ -106,465 +109,471 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">VeraCryptFormat</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">VeraCryptFormat</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptFormat.exe "..\Debug\Setup Files\VeraCrypt Format.exe" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Format.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <DataExecutionPrevention>true</DataExecutionPrevention> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptFormat.exe "..\Release\Setup Files\VeraCrypt Format.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptFormat.exe "..\Release\Setup Files\VeraCrypt Format.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Release\crypto.lib;..\Common\ARM64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'"> <Midl> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>VOLFORMAT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4204;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptFormat.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> </Link> <Manifest> <AdditionalManifestFiles>Format.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt Format-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\Common\CommandAPDU.cpp" /> <ClCompile Include="..\Common\EMVCard.cpp" /> <ClCompile Include="..\Common\EMVToken.cpp" /> <ClCompile Include="..\Common\PCSCException.cpp" /> <ClCompile Include="..\Common\ResponseAPDU.cpp" /> <ClCompile Include="..\Common\SCard.cpp" /> <ClCompile Include="..\Common\SCardLoader.cpp" /> <ClCompile Include="..\Common\SCardManager.cpp" /> <ClCompile Include="..\Common\SCardReader.cpp" /> <ClCompile Include="..\Common\TLVParser.cpp" /> <ClCompile Include="..\Common\Token.cpp" /> diff --git a/src/Format/InPlace.c b/src/Format/InPlace.c index 877ff7eb..361b8aeb 100644 --- a/src/Format/InPlace.c +++ b/src/Format/InPlace.c @@ -573,107 +573,107 @@ int EncryptPartitionInPlaceBegin (volatile FORMAT_VOL_PARAMETERS *volParams, vol nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, volParams->ea, FIRST_MODE_OF_OPERATION_ID, volParams->password, volParams->pkcs5, volParams->pim, wipePass == 0 ? NULL : (char *) cryptoInfo->master_keydata, &cryptoInfo, dataAreaSize, 0, TC_VOLUME_DATA_OFFSET + dataAreaSize, // Start of the encrypted area = the first byte of the backup heeader (encrypting from the end) 0, // No data is encrypted yet 0, volParams->headerFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, volParams->sectorSize, wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); if (nStatus != 0) goto closing_seq; offset.QuadPart = TC_VOLUME_DATA_OFFSET + dataAreaSize; if (!MoveFilePointer (dev, offset)) { nStatus = ERR_OS_ERROR; goto closing_seq; } // Write the backup header to the partition - if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + if (!WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header)) { nStatus = ERR_OS_ERROR; goto closing_seq; } // Fill the reserved sectors of the backup header area with random data nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, TRUE); if (nStatus != ERR_SUCCESS) goto closing_seq; // write fake hidden volume header to protect against attacks that use statistical entropy // analysis to detect presence of hidden volumes nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, volParams->ea, FIRST_MODE_OF_OPERATION_ID, NULL, 0, 0, NULL, &dummyInfo, dataAreaSize, dataAreaSize, TC_VOLUME_DATA_OFFSET + dataAreaSize, // Start of the encrypted area = the first byte of the backup heeader (encrypting from the end) dataAreaSize, // No data is encrypted yet 0, volParams->headerFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, volParams->sectorSize, wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); if (nStatus != ERR_SUCCESS) goto closing_seq; crypto_close (dummyInfo); offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; if (!MoveFilePointer (dev, offset)) { nStatus = ERR_OS_ERROR; goto closing_seq; } // Write the fake hidden backup header to the partition - if (!WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + if (!WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header)) { nStatus = ERR_OS_ERROR; goto closing_seq; } } /* Now we will try to decrypt the backup header to verify it has been correctly written. */ nStatus = OpenBackupHeader (dev, volParams->volumePath, volParams->password, volParams->pkcs5, volParams->pim, &cryptoInfo2, NULL, deviceSize); if (nStatus != ERR_SUCCESS || cryptoInfo->EncryptedAreaStart.Value != cryptoInfo2->EncryptedAreaStart.Value || cryptoInfo2->EncryptedAreaStart.Value == 0) { if (nStatus == ERR_SUCCESS) nStatus = ERR_PARAMETER_INCORRECT; goto closing_seq; } // The backup header is valid so we know we should be able to safely resume in-place encryption // of this partition even if the system/app crashes. /* Conceal the NTFS filesystem (by performing an easy-to-undo modification). This will prevent Windows and apps from interfering with the volume until it has been fully encrypted. */ @@ -727,108 +727,108 @@ closing_seq: if (cryptoInfo2 != NULL) { crypto_close (cryptoInfo2); cryptoInfo2 = NULL; } burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); TCfree (header); if (dosDev[0]) RemoveFakeDosName (volParams->volumePath, dosDev); *outHandle = dev; if (nStatus != ERR_SUCCESS) SetLastError (dwError); return nStatus; } int EncryptPartitionInPlaceResume (HANDLE dev, volatile FORMAT_VOL_PARAMETERS *volParams, WipeAlgorithmId wipeAlgorithm, volatile BOOL *bTryToCorrectReadErrors) { PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL, tmpCryptoInfo = NULL; UINT64_STRUCT unitNo; char *buf = NULL, *header = NULL; - byte *wipeBuffer = NULL; - byte wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; - byte wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; + uint8 *wipeBuffer = NULL; + uint8 wipeRandChars [TC_WIPE_RAND_CHAR_COUNT]; + uint8 wipeRandCharsUpdate [TC_WIPE_RAND_CHAR_COUNT]; WCHAR dosDev[TC_MAX_PATH] = {0}; WCHAR devName[MAX_PATH] = {0}; WCHAR deviceName[MAX_PATH]; int nStatus = ERR_SUCCESS; __int64 deviceSize; uint64 remainingBytes, lastHeaderUpdateDistance = 0, zeroedSectorCount = 0; uint32 workChunkSize; DWORD dwError, dwResult; BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE; LARGE_INTEGER offset; int sectorSize; int i; DWORD n; WCHAR *devicePath = volParams->volumePath; Password *password = volParams->password; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; DISK_GEOMETRY driveGeometry; HWND hwndDlg = volParams->hwndDlg; #ifdef _WIN64 BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled(); #endif bInPlaceEncNonSysResumed = TRUE; buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); if (!buf) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (!header) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (wipeAlgorithm != TC_WIPE_NONE) { - wipeBuffer = (byte *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); + wipeBuffer = (uint8 *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); if (!wipeBuffer) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } } headerCryptoInfo = crypto_open(); if (headerCryptoInfo == NULL) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } deviceSize = GetDeviceSize (devicePath); if (deviceSize < 0) { // Cannot determine the size of the partition nStatus = ERR_OS_ERROR; goto closing_seq; } if (dev == INVALID_HANDLE_VALUE) { StringCchCopyW (deviceName, ARRAYSIZE(deviceName), devicePath); if (FakeDosNameForDevice (deviceName, dosDev, sizeof(dosDev),devName, sizeof(devName),FALSE) != 0) { nStatus = ERR_OS_ERROR; @@ -947,135 +947,135 @@ inplace_enc_read: if (nStatus != ERR_SUCCESS) { // Due to write errors, we can't correct the read errors nStatus = ERR_OS_ERROR; goto closing_seq; } goto inplace_enc_read; } } SetLastError (dwTmpErr); // Preserve the original error code nStatus = ERR_OS_ERROR; goto closing_seq; } if (remainingBytes - workChunkSize < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE) { // We reached the inital portion of the filesystem, which we had concealed (in order to prevent // Windows from interfering with the volume). Now we need to undo that modification. for (i = 0; i < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE - (remainingBytes - workChunkSize); i++) buf[i] ^= TC_NTFS_CONCEAL_CONSTANT; } // Encrypt the plaintext in RAM - EncryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); + EncryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); // If enabled, wipe the area to which we will write the ciphertext if (wipeAlgorithm != TC_WIPE_NONE) { - byte wipePass; + uint8 wipePass; int wipePassCount = GetWipePassCount (wipeAlgorithm); if (wipePassCount <= 0) { SetLastError (ERROR_INVALID_PARAMETER); nStatus = ERR_PARAMETER_INCORRECT; goto closing_seq; } offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize; for (wipePass = 1; wipePass <= wipePassCount; ++wipePass) { if (!WipeBuffer (wipeAlgorithm, wipeRandChars, wipePass, wipeBuffer, workChunkSize)) { ULONG i; for (i = 0; i < workChunkSize; ++i) { wipeBuffer[i] = buf[i] + wipePass; } EncryptDataUnits (wipeBuffer, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); memcpy (wipeRandCharsUpdate, wipeBuffer, sizeof (wipeRandCharsUpdate)); } if (MoveFilePointer (dev, offset) == 0 || WriteFile (dev, wipeBuffer, workChunkSize, &n, NULL) == 0) { // Write error dwError = GetLastError(); // Undo failed write operation if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) { - DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); + DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); } SetLastError (dwError); nStatus = ERR_OS_ERROR; goto closing_seq; } } memcpy (wipeRandChars, wipeRandCharsUpdate, sizeof (wipeRandCharsUpdate)); } // Write the ciphertext offset.QuadPart = masterCryptoInfo->EncryptedAreaStart.Value - workChunkSize; if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; } if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0) { // Write error dwError = GetLastError(); // Undo failed write operation if (workChunkSize > TC_VOLUME_DATA_OFFSET && MoveFilePointer (dev, offset)) { - DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); + DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); WriteFile (dev, buf + TC_VOLUME_DATA_OFFSET, workChunkSize - TC_VOLUME_DATA_OFFSET, &n, NULL); } SetLastError (dwError); nStatus = ERR_OS_ERROR; goto closing_seq; } masterCryptoInfo->EncryptedAreaStart.Value -= workChunkSize; masterCryptoInfo->EncryptedAreaLength.Value += workChunkSize; remainingBytes -= workChunkSize; lastHeaderUpdateDistance += workChunkSize; bEncryptedAreaSizeChanged = TRUE; if (lastHeaderUpdateDistance >= TC_NONSYS_INPLACE_ENC_HEADER_UPDATE_INTERVAL) { nStatus = FastVolumeHeaderUpdate (dev, headerCryptoInfo, masterCryptoInfo, deviceSize); if (nStatus != ERR_SUCCESS) goto closing_seq; lastHeaderUpdateDistance = 0; } ExportProgressStats (masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->VolumeSize.Value); if (bVolTransformThreadCancel) @@ -1122,120 +1122,120 @@ inplace_enc_read: password, masterCryptoInfo->pkcs5, pim, (char *) masterCryptoInfo->master_keydata, &tmpCryptoInfo, masterCryptoInfo->VolumeSize.Value, 0, masterCryptoInfo->EncryptedAreaStart.Value, masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->RequiredProgramVersion, masterCryptoInfo->HeaderFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, masterCryptoInfo->SectorSize, wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); #ifdef _WIN64 if (bIsRamEncryptionEnabled) { masterCryptoInfo = cryptoInfoBackup; burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof(tmpCI)); } #endif if (nStatus != ERR_SUCCESS) goto closing_seq; offset.QuadPart = TC_VOLUME_HEADER_OFFSET; if (MoveFilePointer (dev, offset) == 0 - || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + || !WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header)) { nStatus = ERR_OS_ERROR; goto closing_seq; } #ifdef _WIN64 if (bIsRamEncryptionEnabled) { VirtualLock (&tmpCI, sizeof(tmpCI)); memcpy (&tmpCI, headerCryptoInfo, sizeof (CRYPTO_INFO)); VcUnprotectKeys (&tmpCI, VcGetEncryptionID (headerCryptoInfo)); cryptoInfoBackup = headerCryptoInfo; headerCryptoInfo = &tmpCI; } #endif // Fill the reserved sectors of the header area with random data nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, headerCryptoInfo, masterCryptoInfo->VolumeSize.Value, TRUE, FALSE); #ifdef _WIN64 if (bIsRamEncryptionEnabled) { headerCryptoInfo = cryptoInfoBackup; burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof(tmpCI)); } #endif if (nStatus != ERR_SUCCESS) goto closing_seq; // write fake hidden volume header to protect against attacks that use statistical entropy // analysis to detect presence of hidden volumes nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, headerCryptoInfo->ea, headerCryptoInfo->mode, NULL, 0, 0, NULL, &dummyInfo, masterCryptoInfo->VolumeSize.Value, masterCryptoInfo->VolumeSize.Value, masterCryptoInfo->EncryptedAreaStart.Value, masterCryptoInfo->EncryptedAreaLength.Value, masterCryptoInfo->RequiredProgramVersion, masterCryptoInfo->HeaderFlags | TC_HEADER_FLAG_NONSYS_INPLACE_ENC, masterCryptoInfo->SectorSize, wipeAlgorithm == TC_WIPE_NONE ? FALSE : (wipePass < PRAND_HEADER_WIPE_PASSES - 1)); if (nStatus != ERR_SUCCESS) goto closing_seq; crypto_close (dummyInfo); offset.QuadPart += TC_HIDDEN_VOLUME_HEADER_OFFSET; if (MoveFilePointer (dev, offset) == 0 - || !WriteEffectiveVolumeHeader (TRUE, dev, (byte *) header)) + || !WriteEffectiveVolumeHeader (TRUE, dev, (uint8 *) header)) { nStatus = ERR_OS_ERROR; goto closing_seq; } } // Update the configuration files SaveNonSysInPlaceEncSettings (-1, wipeAlgorithm, FALSE); SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_FINISHED); nStatus = ERR_SUCCESS; } else { // The process has been paused by the user or aborted by the wizard (e.g. on app exit) nStatus = ERR_USER_ABORT; SetNonSysInplaceEncUIStatus (NONSYS_INPLACE_ENC_STATUS_PAUSED); } closing_seq: dwError = GetLastError(); @@ -1289,61 +1289,61 @@ closing_seq: if (wipeBuffer != NULL) TCfree (wipeBuffer); if (zeroedSectorCount > 0) { wchar_t msg[30000] = {0}; wchar_t sizeStr[500] = {0}; GetSizeString (zeroedSectorCount * sectorSize, sizeStr, sizeof(sizeStr)); StringCbPrintfW (msg, sizeof(msg), GetString ("ZEROED_BAD_SECTOR_COUNT"), zeroedSectorCount, sizeStr); WarningDirect (msg, hwndDlg); } if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT) SetLastError (dwError); return nStatus; } int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile BOOL *DiscardUnreadableEncryptedSectors) { HANDLE dev = INVALID_HANDLE_VALUE; PCRYPTO_INFO masterCryptoInfo = NULL, headerCryptoInfo = NULL; UINT64_STRUCT unitNo; char *buf = NULL; - byte *tmpSectorBuf = NULL; + uint8 *tmpSectorBuf = NULL; WCHAR dosDev[TC_MAX_PATH] = {0}; WCHAR devName[MAX_PATH] = {0}; WCHAR deviceName[MAX_PATH]; int nStatus = ERR_SUCCESS; __int64 deviceSize; uint64 remainingBytes, workChunkStartByteOffset, lastHeaderUpdateDistance = 0, skippedBadSectorCount = 0; uint32 workChunkSize; DWORD dwError, dwResult; BOOL bPause = FALSE, bEncryptedAreaSizeChanged = FALSE; LARGE_INTEGER offset; int sectorSize; int i; DWORD n; WCHAR *devicePath = volParams->volumePath; Password *password = volParams->password; HWND hwndDlg = volParams->hwndDlg; int pkcs5_prf = volParams->pkcs5; int pim = volParams->pim; DISK_GEOMETRY driveGeometry; #ifdef _WIN64 BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled(); #endif buf = (char *) TCalloc (TC_MAX_NONSYS_INPLACE_ENC_WORK_CHUNK_SIZE); if (!buf) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } @@ -1405,61 +1405,61 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile // This should never be needed, but is still performed for extra safety (without checking the result) DeviceIoControl (dev, FSCTL_ALLOW_EXTENDED_DASD_IO, NULL, 0, NULL, 0, &dwResult, NULL); if (!DeviceIoControl (dev, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &driveGeometry, sizeof (driveGeometry), &dwResult, NULL)) { nStatus = ERR_OS_ERROR; goto closing_seq; } if ( (driveGeometry.BytesPerSector == 0) || (driveGeometry.BytesPerSector > TC_MAX_VOLUME_SECTOR_SIZE) || (driveGeometry.BytesPerSector % ENCRYPTION_DATA_UNIT_SIZE != 0) ) { Error ("SECTOR_SIZE_UNSUPPORTED", hwndDlg); nStatus = ERR_DONT_REPORT; goto closing_seq; } sectorSize = driveGeometry.BytesPerSector; - tmpSectorBuf = (byte *) TCalloc (sectorSize); + tmpSectorBuf = (uint8 *) TCalloc (sectorSize); if (!tmpSectorBuf) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } nStatus = OpenBackupHeader (dev, devicePath, password, pkcs5_prf, pim, &masterCryptoInfo, headerCryptoInfo, deviceSize); if (nStatus != ERR_SUCCESS) goto closing_seq; #ifdef _WIN64 if (bIsRamEncryptionEnabled) { VcProtectKeys (masterCryptoInfo, VcGetEncryptionID (masterCryptoInfo)); VcProtectKeys (headerCryptoInfo, VcGetEncryptionID (headerCryptoInfo)); } #endif if (masterCryptoInfo->LegacyVolume) { Error ("NONSYS_INPLACE_DECRYPTION_BAD_VOL_FORMAT", hwndDlg); nStatus = ERR_DONT_REPORT; goto closing_seq; } if (masterCryptoInfo->hiddenVolume) { Error ("NONSYS_INPLACE_DECRYPTION_CANT_DECRYPT_HID_VOL", hwndDlg); @@ -1593,61 +1593,61 @@ int DecryptPartitionInPlace (volatile FORMAT_VOL_PARAMETERS *volParams, volatile memset (tmpSectorBuf, 0, sectorSize); skippedBadSectorCount++; } memcpy (buf + tmpBufOffset, tmpSectorBuf, sectorSize); tmpSectorOffset.QuadPart += sectorSize; tmpBufOffset += sectorSize; } } else { SetLastError (dwTmpErr); // Preserve the original error code nStatus = ERR_OS_ERROR; goto closing_seq; } } else { SetLastError (dwTmpErr); // Preserve the original error code nStatus = ERR_OS_ERROR; goto closing_seq; } } // Decrypt the ciphertext in RAM - DecryptDataUnits ((byte *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); + DecryptDataUnits ((uint8 *) buf, &unitNo, workChunkSize / ENCRYPTION_DATA_UNIT_SIZE, masterCryptoInfo); // Conceal initial portion of the filesystem if (workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET < TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE) { // We are decrypting the initial TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE bytes of the filesystem. We will // conceal this portion to prevent Windows and applications from interfering with the volume. for (i = 0; i < min (TC_INITIAL_NTFS_CONCEAL_PORTION_SIZE, workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET + workChunkSize); i++) buf[i] ^= TC_NTFS_CONCEAL_CONSTANT; } // Write the plaintext offset.QuadPart = workChunkStartByteOffset - TC_VOLUME_DATA_OFFSET; if (MoveFilePointer (dev, offset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; } if (WriteFile (dev, buf, workChunkSize, &n, NULL) == 0) { // Write error nStatus = ERR_OS_ERROR; goto closing_seq; @@ -1816,125 +1816,125 @@ closing_seq: TCfree (tmpSectorBuf); tmpSectorBuf = NULL; } if (skippedBadSectorCount > 0) { wchar_t msg[30000] = {0}; wchar_t sizeStr[500] = {0}; GetSizeString (skippedBadSectorCount * sectorSize, sizeStr, sizeof(sizeStr)); StringCbPrintfW (msg, sizeof(msg), GetString ("SKIPPED_BAD_SECTOR_COUNT"), skippedBadSectorCount, sizeStr); WarningDirect (msg, hwndDlg); } if (nStatus != ERR_SUCCESS && nStatus != ERR_USER_ABORT) SetLastError (dwError); return nStatus; } int FastVolumeHeaderUpdate (HANDLE dev, CRYPTO_INFO *headerCryptoInfo, CRYPTO_INFO *masterCryptoInfo, __int64 deviceSize) { LARGE_INTEGER offset; DWORD n; int nStatus = ERR_SUCCESS; - byte *header; + uint8 *header; DWORD dwError; uint32 headerCrc32; - byte *fieldPos; + uint8 *fieldPos; PCRYPTO_INFO pCryptoInfo = headerCryptoInfo; #ifdef _WIN64 BOOL bIsRamEncryptionEnabled = IsRamEncryptionEnabled(); #endif - header = (byte *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE); + header = (uint8 *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (!header) return ERR_OUTOFMEMORY; VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); - fieldPos = (byte *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START; + fieldPos = (uint8 *) header + TC_HEADER_OFFSET_ENCRYPTED_AREA_START; offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; if (MoveFilePointer (dev, offset) == 0 || !ReadEffectiveVolumeHeader (TRUE, dev, header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) { nStatus = ERR_OS_ERROR; goto closing_seq; } #ifdef _WIN64 if (bIsRamEncryptionEnabled) { pCryptoInfo = crypto_open(); if (!pCryptoInfo) { nStatus = ERR_OUTOFMEMORY; goto closing_seq; } memcpy (pCryptoInfo, headerCryptoInfo, sizeof (CRYPTO_INFO)); VcUnprotectKeys (pCryptoInfo, VcGetEncryptionID (headerCryptoInfo)); } #endif DecryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); if (GetHeaderField32 (header, TC_HEADER_OFFSET_MAGIC) != 0x56455241) { nStatus = ERR_PARAMETER_INCORRECT; goto closing_seq; } mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaStart.Value)); mputInt64 (fieldPos, (masterCryptoInfo->EncryptedAreaLength.Value)); // We need to ensure the TC_HEADER_FLAG_NONSYS_INPLACE_ENC flag bit is set, because if volumes created by TC-format // were decrypted in place, it would be possible to mount them partially encrypted and it wouldn't be possible // to resume interrupted decryption after the wizard exits. masterCryptoInfo->HeaderFlags |= TC_HEADER_FLAG_NONSYS_INPLACE_ENC; - fieldPos = (byte *) header + TC_HEADER_OFFSET_FLAGS; + fieldPos = (uint8 *) header + TC_HEADER_OFFSET_FLAGS; mputLong (fieldPos, (masterCryptoInfo->HeaderFlags)); headerCrc32 = GetCrc32 (header + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC); - fieldPos = (byte *) header + TC_HEADER_OFFSET_HEADER_CRC; + fieldPos = (uint8 *) header + TC_HEADER_OFFSET_HEADER_CRC; mputLong (fieldPos, headerCrc32); EncryptBuffer (header + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, pCryptoInfo); if (MoveFilePointer (dev, offset) == 0 || !WriteEffectiveVolumeHeader (TRUE, dev, header)) { nStatus = ERR_OS_ERROR; goto closing_seq; } closing_seq: dwError = GetLastError(); #ifdef _WIN64 if (bIsRamEncryptionEnabled && pCryptoInfo) { crypto_close(pCryptoInfo); } #endif burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); TCfree (header); if (nStatus != ERR_SUCCESS) SetLastError (dwError); @@ -2181,94 +2181,97 @@ BOOL SaveNonSysInPlaceEncSettings (int delta, WipeAlgorithmId newWipeAlgorithm, } else if (!bDecrypt) { if (newWipeAlgorithm != TC_WIPE_NONE) { StringCbPrintfA (str, sizeof(str), "%d", (int) newWipeAlgorithm); SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE), (DWORD) strlen(str), FALSE, FALSE); } else if (FileExists (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE))) { _wremove (GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC_WIPE)); } } StringCbPrintfA (str, sizeof(str), "%d", count); return SaveBufferToFile (str, GetConfigPath (TC_APPD_FILENAME_NONSYS_INPLACE_ENC), (DWORD) strlen(str), FALSE, FALSE); } // This function moves the file pointer to the given offset. It first retrieves the current // file position using SetFilePointerEx() with FILE_CURRENT as the reference point, and then // calculates the difference between the current position and the desired position. Subsequently, // it moves the file pointer by the difference calculated using SetFilePointerEx() again. // // This approach of moving the file pointer relatively (instead of absolutely) was implemented // as a workaround to address the performance issues related to in-place encryption. When using // SetFilePointerEx() with FILE_BEGIN as the reference point, reaching the end of large drives // during in-place encryption can cause significant slowdowns. By moving the file pointer // relatively, these performance issues are mitigated. +// +// We fall back to absolute positioning if the relative positioning fails. BOOL MoveFilePointer (HANDLE dev, LARGE_INTEGER offset) { LARGE_INTEGER currOffset; LARGE_INTEGER diffOffset; currOffset.QuadPart = 0; - if (SetFilePointerEx (dev, currOffset, &currOffset, FILE_CURRENT) == 0) - return FALSE; - - diffOffset.QuadPart = offset.QuadPart - currOffset.QuadPart; - if (diffOffset.QuadPart == 0) - return TRUE; + if (SetFilePointerEx (dev, currOffset, &currOffset, FILE_CURRENT)) + { + diffOffset.QuadPart = offset.QuadPart - currOffset.QuadPart; + if (diffOffset.QuadPart == 0) + return TRUE; - // Moves the file pointer by the difference between current and desired positions - if (SetFilePointerEx (dev, diffOffset, NULL, FILE_CURRENT) == 0) - return FALSE; + // Moves the file pointer by the difference between current and desired positions + if (SetFilePointerEx (dev, diffOffset, NULL, FILE_CURRENT)) + return TRUE; + } - return TRUE; + // An error occurred, fallback to absolute positioning + return SetFilePointerEx (dev, offset, NULL, FILE_BEGIN); } // Repairs damaged sectors (i.e. those with read errors) by zeroing them. // Note that this operating fails if there are any write errors. int ZeroUnreadableSectors (HANDLE dev, LARGE_INTEGER startOffset, int64 size, int sectorSize, uint64 *zeroedSectorCount) { int nStatus; DWORD n; int64 sectorCount; LARGE_INTEGER workOffset; - byte *sectorBuffer = NULL; + uint8 *sectorBuffer = NULL; DWORD dwError; workOffset.QuadPart = startOffset.QuadPart; - sectorBuffer = (byte *) TCalloc (sectorSize); + sectorBuffer = (uint8 *) TCalloc (sectorSize); if (!sectorBuffer) return ERR_OUTOFMEMORY; if (!MoveFilePointer(dev, workOffset)) { nStatus = ERR_OS_ERROR; goto closing_seq; } for (sectorCount = size / sectorSize; sectorCount > 0; --sectorCount) { if (ReadFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0) { memset (sectorBuffer, 0, sectorSize); // If ReadFile failed, move back to start of the unreadable sector if (MoveFilePointer (dev, workOffset) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; } if (WriteFile (dev, sectorBuffer, sectorSize, &n, NULL) == 0) { nStatus = ERR_OS_ERROR; goto closing_seq; } ++(*zeroedSectorCount); @@ -2285,93 +2288,93 @@ closing_seq: if (sectorBuffer != NULL) TCfree (sectorBuffer); if (nStatus != ERR_SUCCESS) SetLastError (dwError); return nStatus; } static int OpenBackupHeader (HANDLE dev, const wchar_t *devicePath, Password *password, int pkcs5, int pim, PCRYPTO_INFO *retMasterCryptoInfo, CRYPTO_INFO *headerCryptoInfo, __int64 deviceSize) { LARGE_INTEGER offset; DWORD n; int nStatus = ERR_SUCCESS; char *header; DWORD dwError; header = (char *) TCalloc (TC_VOLUME_HEADER_EFFECTIVE_SIZE); if (!header) return ERR_OUTOFMEMORY; VirtualLock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); offset.QuadPart = deviceSize - TC_VOLUME_HEADER_GROUP_SIZE; if (MoveFilePointer (dev, offset) == 0 - || !ReadEffectiveVolumeHeader (TRUE, dev, (byte *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) + || !ReadEffectiveVolumeHeader (TRUE, dev, (uint8 *) header, &n) || n < TC_VOLUME_HEADER_EFFECTIVE_SIZE) { nStatus = ERR_OS_ERROR; goto closing_seq; } nStatus = ReadVolumeHeader (FALSE, header, password, pkcs5, pim, retMasterCryptoInfo, headerCryptoInfo); if (nStatus != ERR_SUCCESS) goto closing_seq; closing_seq: dwError = GetLastError(); burn (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); VirtualUnlock (header, TC_VOLUME_HEADER_EFFECTIVE_SIZE); TCfree (header); dwError = GetLastError(); if (nStatus != ERR_SUCCESS) SetLastError (dwError); return nStatus; } static BOOL GetFreeClusterBeforeThreshold (HANDLE volumeHandle, int64 *freeCluster, int64 clusterThreshold) { const int bitmapSize = 65536; - byte bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)]; + uint8 bitmapBuffer[bitmapSize + sizeof (VOLUME_BITMAP_BUFFER)]; VOLUME_BITMAP_BUFFER *bitmap = (VOLUME_BITMAP_BUFFER *) bitmapBuffer; STARTING_LCN_INPUT_BUFFER startLcn; startLcn.StartingLcn.QuadPart = 0; DWORD bytesReturned; while (DeviceIoControl (volumeHandle, FSCTL_GET_VOLUME_BITMAP, &startLcn, sizeof (startLcn), &bitmapBuffer, sizeof (bitmapBuffer), &bytesReturned, NULL) || GetLastError() == ERROR_MORE_DATA) { for (int64 bitmapIndex = 0; bitmapIndex < min (bitmapSize, (bitmap->BitmapSize.QuadPart / 8)); ++bitmapIndex) { if (bitmap->StartingLcn.QuadPart + bitmapIndex * 8 >= clusterThreshold) goto err; if (bitmap->Buffer[bitmapIndex] != 0xff) { for (int bit = 0; bit < 8; ++bit) { if ((bitmap->Buffer[bitmapIndex] & (1 << bit)) == 0) { *freeCluster = bitmap->StartingLcn.QuadPart + bitmapIndex * 8 + bit; if (*freeCluster >= clusterThreshold) goto err; return TRUE; } } } } diff --git a/src/Format/Tcformat.c b/src/Format/Tcformat.c index 8e95d0a4..658d3797 100644 --- a/src/Format/Tcformat.c +++ b/src/Format/Tcformat.c @@ -1079,78 +1079,60 @@ BOOL SwitchWizardToSysEncMode (void) NormalCursor (); return FALSE; } if (!ChangeWizardMode (WIZARD_MODE_SYS_DEVICE)) { NormalCursor (); return FALSE; } if (bSysDriveSelected || bSysPartitionSelected) { // The user selected the non-sys-device wizard mode but then selected a system device bWholeSysDrive = (bSysDriveSelected && !bSysPartitionSelected); bSysDriveSelected = FALSE; bSysPartitionSelected = FALSE; try { if (!bHiddenVol) { if (bWholeSysDrive && !BootEncObj->SystemPartitionCoversWholeDrive()) { if (BootEncObj->SystemDriveContainsNonStandardPartitions()) { if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES) bWholeSysDrive = FALSE; } - - if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive) - { - if (BootEncObj->SystemDriveContainsExtendedPartition()) - { - bWholeSysDrive = FALSE; - - Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg); - - if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO) - { - ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE); - return FALSE; - } - } - else - Warning ("WDE_EXTENDED_PARTITIONS_WARNING", MainDlg); - } } else if (BootEncObj->SystemPartitionCoversWholeDrive() && !bWholeSysDrive) bWholeSysDrive = (AskYesNo ("WHOLE_SYC_DEVICE_RECOM", MainDlg) == IDYES); } } catch (Exception &e) { e.Show (MainDlg); return FALSE; } if (!bHiddenVol) { // Skip SYSENC_SPAN_PAGE and SYSENC_TYPE_PAGE as the user already made the choice LoadPage (MainDlg, bWholeSysDrive ? SYSENC_PRE_DRIVE_ANALYSIS_PAGE : SYSENC_MULTI_BOOT_MODE_PAGE); } else { // The user selected the non-sys-device wizard mode but then selected a system device. // In addition, he selected the hidden volume mode. if (bWholeSysDrive) Warning ("HIDDEN_OS_PRECLUDES_SINGLE_KEY_WDE", MainDlg); bWholeSysDrive = FALSE; LoadPage (MainDlg, SYSENC_TYPE_PAGE); } @@ -4466,63 +4448,65 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PASSWORD_TITLE")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetDlgItem (hwndDlg, IDC_PASSWORD), GetDlgItem (hwndDlg, IDC_VERIFY), NULL, NULL, KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect()); volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); } break; case PIM_PAGE: { SendMessage (GetDlgItem (hwndDlg, IDC_PIM), EM_LIMITTEXT, SysEncInEffect()? MAX_BOOT_PIM: MAX_PIM, 0); if (volumePim > 0) { SetPim (hwndDlg, IDC_PIM, volumePim); PimValueChangedWarning = TRUE; SetDlgItemTextW (hwndDlg, IDC_PIM_HELP, GetString (SysEncInEffect ()? "PIM_SYSENC_CHANGE_WARNING" : "PIM_CHANGE_WARNING")); } SetFocus (GetDlgItem (hwndDlg, IDC_PIM)); - + #ifndef WOLFCRYPT_BACKEND SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (SysEncInEffect () && hash_algo != SHA512 && hash_algo != WHIRLPOOL? "PIM_SYSENC_HELP" : "PIM_HELP")); - + #else + SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString (SysEncInEffect () && hash_algo != SHA512? "PIM_SYSENC_HELP" : "PIM_HELP")); + #endif ToHyperlink (hwndDlg, IDC_LINK_PIM_INFO); if (CreatingHiddenSysVol()) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM_HIDDEN_OS_TITLE")); else if (bHiddenVol) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString (bHiddenVolHost ? "PIM_HIDVOL_HOST_TITLE" : "PIM_HIDVOL_TITLE")); else if (WizardMode == WIZARD_MODE_SYS_DEVICE) SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM")); else SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("PIM_TITLE")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); } break; case FILESYS_PAGE: { wchar_t szTmp[8192]; Init2RadButtonPageYesNo (nNeedToStoreFilesOver4GB); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("FILESYS_PAGE_TITLE")); StringCbCopyW (szTmp, sizeof(szTmp), GetString ("FILESYS_PAGE_HELP_QUESTION")); if (bHiddenVolHost) StringCbCatW (szTmp, sizeof(szTmp), L"\n\n"); @@ -5075,61 +5059,61 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), TRUE); /* Filesystems */ bNTFSallowed = FALSE; bFATallowed = FALSE; bNoFSallowed = FALSE; SendMessage (GetDlgItem (hwndDlg, IDC_FILESYS), CB_RESETCONTENT, 0, 0); EnableWindow (GetDlgItem (hwndDlg, IDC_FILESYS), TRUE); uint64 dataAreaSize = GetVolumeDataAreaSize (bHiddenVol && !bHiddenVolHost, nVolumeSize); if (!CreatingHiddenSysVol()) { if (dataAreaSize >= TC_MIN_NTFS_FS_SIZE && dataAreaSize <= TC_MAX_NTFS_FS_SIZE) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"NTFS", FILESYS_NTFS); bNTFSallowed = TRUE; } if (dataAreaSize >= TC_MIN_FAT_FS_SIZE && dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize()) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"FAT", FILESYS_FAT); bFATallowed = TRUE; } //exFAT support added starting from Vista SP1 - if (IsOSVersionAtLeast (WIN_VISTA, 1) && dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE) + if (dataAreaSize >= TC_MIN_EXFAT_FS_SIZE && dataAreaSize <= TC_MAX_EXFAT_FS_SIZE) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"exFAT", FILESYS_EXFAT); bEXFATallowed = TRUE; } //ReFS write support activated by default starting from Windows 10 //We don't support it yet for the creation of hidden volumes if ((!bHiddenVolHost) && IsOSVersionAtLeast (WIN_10, 0) && dataAreaSize >= TC_MIN_REFS_FS_SIZE && dataAreaSize <= TC_MAX_REFS_FS_SIZE) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), L"ReFS", FILESYS_REFS); bReFSallowed = TRUE; } } else { // We're creating a hidden volume for a hidden OS, so we don't need to format it with // any filesystem (the entire OS will be copied to the hidden volume sector by sector). EnableWindow (GetDlgItem (hwndDlg, IDC_FILESYS), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_CLUSTERSIZE), FALSE); } if (!bHiddenVolHost) { AddComboPair (GetDlgItem (hwndDlg, IDC_FILESYS), GetString ("NONE"), FILESYS_NONE); bNoFSallowed = TRUE; } EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); if (fileSystem == FILESYS_NONE) // If no file system has been previously selected @@ -5894,61 +5878,61 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa case IDC_GB: SendMessage (GetDlgItem (hwndDlg, IDC_GB), BM_SETCHECK, BST_CHECKED, 0); break; case IDC_TB: SendMessage (GetDlgItem (hwndDlg, IDC_TB), BM_SETCHECK, BST_CHECKED, 0); break; } VerifySizeAndUpdate (hwndDlg, FALSE); return 1; } if (lw == IDC_HIDVOL_WIZ_MODE_DIRECT && nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE) { bHiddenVolDirect = TRUE; return 1; } if (lw == IDC_HIDVOL_WIZ_MODE_FULL && nCurPageNo == HIDDEN_VOL_WIZARD_MODE_PAGE) { bHiddenVolDirect = FALSE; return 1; } if (lw == IDC_SELECT_VOLUME_LOCATION && nCurPageNo == VOLUME_LOCATION_PAGE) { if (!bDevice) { // Select file - if (BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, !bHiddenVolDirect, NULL) == FALSE) + if (BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, !bHiddenVolDirect) == FALSE) return 1; AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory); EnableDisableFileNext (GetDlgItem (hwndDlg, IDC_COMBO_BOX), GetDlgItem (GetParent (hwndDlg), IDC_NEXT)); return 1; } else { // Select device RawDevicesDlgParam param; param.pszFileName = szFileName; INT_PTR nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), GetParent (hwndDlg), (DLGPROC) RawDevicesDlgProc, (LPARAM) & param); // Check administrator privileges if (!wcsstr (szFileName, L"Floppy") && !IsAdmin() && !IsUacSupported ()) MessageBoxW (hwndDlg, GetString ("ADMIN_PRIVILEGES_WARN_DEVICES"), lpszTitle, MB_OK|MB_ICONWARNING); if (nResult == IDOK && wcslen (szFileName) > 0) { AddComboItem (GetDlgItem (hwndDlg, IDC_COMBO_BOX), szFileName, bHistory); EnableDisableFileNext (GetDlgItem (hwndDlg, IDC_COMBO_BOX), GetDlgItem (GetParent (hwndDlg), IDC_NEXT)); bDeviceTransformModeChoiceMade = FALSE; @@ -6085,61 +6069,61 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowText (GetDlgItem (hCurPage, IDC_RANDOM_BYTES), showKeys ? L" " : L"******************************** "); SetWindowText (GetDlgItem (hCurPage, IDC_HEADER_KEY), showKeys ? L"" : L"******************************** "); SetWindowText (GetDlgItem (hCurPage, IDC_DISK_KEY), showKeys ? L"" : L"******************************** "); return 1; } if (lw == IDC_DISPLAY_POOL_CONTENTS && (nCurPageNo == SYSENC_COLLECTING_RANDOM_DATA_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_RAND_DATA_PAGE)) { showKeys = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISPLAY_POOL_CONTENTS)); DisplayRandPool (hwndDlg, hRandPoolSys, showKeys); return 1; } if (lw == IDC_DISPLAY_KEYS && nCurPageNo == SYSENC_KEYS_GEN_PAGE) { showKeys = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISPLAY_KEYS)); DisplayPortionsOfKeys (GetDlgItem (hwndDlg, IDC_HEADER_KEY), GetDlgItem (hwndDlg, IDC_DISK_KEY), HeaderKeyGUIView, MasterKeyGUIView, !showKeys); return 1; } if (nCurPageNo == SYSENC_RESCUE_DISK_CREATION_PAGE) { if (lw == IDC_BROWSE) { wchar_t tmpszRescueDiskISO [TC_MAX_PATH+1]; - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", tmpszRescueDiskISO, FALSE, TRUE, NULL)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", tmpszRescueDiskISO, FALSE, TRUE)) return 1; StringCbCopyW (szRescueDiskISO, sizeof(szRescueDiskISO), tmpszRescueDiskISO); SetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO); EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1)); return 1; } if ( hw == EN_CHANGE ) { GetDlgItemText (hwndDlg, IDC_RESCUE_DISK_ISO_PATH, szRescueDiskISO, sizeof(szRescueDiskISO)); EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_RESCUE_DISK_ISO_PATH)) > 1)); return 1; } } if (nCurPageNo == SYSENC_RESCUE_DISK_BURN_PAGE && lw == IDC_DOWNLOAD_CD_BURN_SOFTWARE) { if (IsWindowsIsoBurnerAvailable()) LaunchWindowsIsoBurner (hwndDlg, szRescueDiskISO); else Applink ("isoburning"); return 1; } if ((nCurPageNo == SYSENC_WIPE_MODE_PAGE || nCurPageNo == NONSYS_INPLACE_ENC_WIPE_MODE_PAGE || nCurPageNo == DEVICE_WIPE_MODE_PAGE) @@ -6230,61 +6214,61 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SysEncMultiBootCfg.SystemOnBootDrive = -1; try { BootEncStatus = BootEncObj->GetStatus(); } catch (Exception &e) { e.Show (hwndDlg); Error ("ERR_GETTING_SYSTEM_ENCRYPTION_STATUS", MainDlg); EndMainDlg (MainDlg); return 0; } try { bSystemIsGPT = BootEncObj->GetSystemDriveConfiguration().SystemPartition.IsGPT; } catch (...) { } SendMessageW (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hTitleFont, (LPARAM) TRUE); SetWindowTextW (hwndDlg, lpszTitle); ExtractCommandLine (hwndDlg, (wchar_t *) lParam); if (EnableMemoryProtection) { /* Protect this process memory from being accessed by non-admin users */ - EnableProcessProtection (); + ActivateMemoryProtection (); } if (ComServerMode) { InitDialog (hwndDlg); if (!ComServerFormat ()) { handleWin32Error (hwndDlg, SRC_POS); exit (1); } exit (0); } fastCreateFile = CmdFastCreateFile; if (DirectCreationMode) { wchar_t root[TC_MAX_PATH]; DWORD fileSystemFlags = 0; uint64 dataAreaSize; wchar_t szFileSystemNameBuffer[256]; ULARGE_INTEGER free; showKeys = FALSE; bGuiMode = FALSE; if (CmdVolumePassword.Length == 0 && !FirstCmdKeyFile) AbortProcess ("ERR_PASSWORD_MISSING"); @@ -6397,98 +6381,88 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { AbortProcess ("ERR_EXFAT_INVALID_VOLUME_SIZE"); } if ( (fileSystem == FILESYS_REFS) && (dataAreaSize < TC_MIN_REFS_FS_SIZE || dataAreaSize > TC_MAX_REFS_FS_SIZE) ) { AbortProcess ("ERR_REFS_INVALID_VOLUME_SIZE"); } if ( (fileSystem == FILESYS_FAT) && (dataAreaSize < TC_MIN_FAT_FS_SIZE || dataAreaSize > (TC_MAX_FAT_SECTOR_COUNT * GetFormatSectorSize())) ) { AbortProcess ("ERR_FAT_INVALID_VOLUME_SIZE"); } /* Verify that the volume would not be too large for the host file system */ if (GetVolumePathName (szDiskFile, root, ARRAYSIZE (root)) && GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, ARRAYSIZE(szFileSystemNameBuffer)) && !wcsncmp (szFileSystemNameBuffer, L"FAT32", 5)) { // The host file system is FAT32 if (nVolumeSize >= 4 * BYTES_PER_GB) { AbortProcess ("VOLUME_TOO_LARGE_FOR_FAT32"); } } - /* Verify that the volume would not be too large for the operating system */ - if (!IsOSAtLeast (WIN_VISTA) - && nVolumeSize > 2 * BYTES_PER_TB) - { - AbortProcess ("VOLUME_TOO_LARGE_FOR_WINXP"); - } - if (volumePassword.Length > 0) { // Check password length (check also done for outer volume which is not the case in TrueCrypt). if (!CheckPasswordLength (NULL, volumePassword.Length, volumePim, FALSE, 0, Silent, Silent)) { exit (1); } } if (!KeyFilesApply (hwndDlg, &volumePassword, FirstCmdKeyFile, NULL)) { exit (1); } volTransformThreadFunction (hwndDlg); exit (bOperationSuccess? 0 : 1); } SHGetFolderPath (NULL, CSIDL_MYDOCUMENTS, NULL, 0, szRescueDiskISO); if (bSystemIsGPT) StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.zip"); else StringCbCatW (szRescueDiskISO, sizeof(szRescueDiskISO), L"\\VeraCrypt Rescue Disk.iso"); - if (IsOSAtLeast (WIN_VISTA)) - { - // Availability of in-place encryption (which is pre-selected by default whenever - // possible) makes partition-hosted volume creation safer. - bWarnDeviceFormatAdvanced = FALSE; - } + // Availability of in-place encryption (which is pre-selected by default whenever + // possible) makes partition-hosted volume creation safer. + bWarnDeviceFormatAdvanced = FALSE; #ifdef _DEBUG // For faster testing StringCchCopyA (szVerify, ARRAYSIZE(szVerify), "q"); StringCchCopyA (szRawPassword, ARRAYSIZE(szRawPassword), "q"); #endif PasswordEditDropTarget* pTarget = new PasswordEditDropTarget (); if (pTarget->Register (hwndDlg)) { SetWindowLongPtr (hwndDlg, DWLP_USER, (LONG_PTR) pTarget); } else delete pTarget; PostMessage (hwndDlg, TC_APPMSG_PERFORM_POST_WMINIT_TASKS, 0, 0); } return 0; case WM_SYSCOMMAND: if (lw == IDC_ABOUT) { DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc); return 1; } return 0; case WM_TIMER: switch (wParam) @@ -7211,134 +7185,118 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa return 1; } } // This check requires admin rights try { BootEncObj->InitialSecurityChecksForHiddenOS (); } catch (Exception &e) { e.Show (hwndDlg); EndMainDlg (MainDlg); // Some of the checks need the wizard to be restarted (results are cached until exit and the checks would fail even if the issues were rectified). return 1; } nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE - 1; // Skip irrelevant pages } else if (nCurPageNo == SYSENC_SPAN_PAGE) { try { if (bWholeSysDrive && !BootEncObj->SystemPartitionCoversWholeDrive()) { if (BootEncObj->SystemDriveContainsNonStandardPartitions()) { if (AskWarnYesNoString ((wstring (GetString ("SYSDRIVE_NON_STANDARD_PARTITIONS")) + L"\n\n" + GetString ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE")).c_str(), MainDlg) == IDYES) bWholeSysDrive = FALSE; } - - if (!IsOSAtLeast (WIN_VISTA) && bWholeSysDrive) - { - if (BootEncObj->SystemDriveContainsExtendedPartition()) - { - Error ("WDE_UNSUPPORTED_FOR_EXTENDED_PARTITIONS", MainDlg); - - if (AskYesNo ("ASK_ENCRYPT_PARTITION_INSTEAD_OF_DRIVE", MainDlg) == IDNO) - return 1; - - bWholeSysDrive = FALSE; - } - else - Warning ("WDE_EXTENDED_PARTITIONS_WARNING", hwndDlg); - } } if (!bWholeSysDrive && BootEncObj->SystemPartitionCoversWholeDrive()) bWholeSysDrive = (AskYesNo ("WHOLE_SYC_DEVICE_RECOM", hwndDlg) == IDYES); } catch (Exception &e) { e.Show (hwndDlg); NormalCursor (); return 1; } if (!bWholeSysDrive) nNewPageNo = SYSENC_MULTI_BOOT_MODE_PAGE - 1; // Skip irrelevant pages } else if (nCurPageNo == SYSENC_PRE_DRIVE_ANALYSIS_PAGE) { if ((SysEncDetectHiddenSectors = Get2RadButtonPageAnswer()) != 1) { // Skip drive analysis nNewPageNo = SYSENC_DRIVE_ANALYSIS_PAGE; // If the user had already searched for hidden sectors, we must clear (invalidate) the // result because now he changed his mind and no longer wishes to encrypt the hidden sectors. try { BootEncObj->InvalidateCachedSysDriveProperties (); } catch (Exception &e) { e.Show (MainDlg); EndMainDlg (MainDlg); exit(0); } } } else if (nCurPageNo == SYSENC_MULTI_BOOT_MODE_PAGE) { if (nMultiBoot > 1) { // Multi-boot if (AskWarnNoYes ("MULTI_BOOT_FOR_ADVANCED_ONLY", hwndDlg) == IDNO) return 1; if (bHiddenOS) { if (AskWarnNoYes ("HIDDEN_OS_MULTI_BOOT", hwndDlg) == IDNO) { Error ("UNSUPPORTED_HIDDEN_OS_MULTI_BOOT_CFG", hwndDlg); return 1; } } } if (bHiddenOS) { - if (IsOSAtLeast (WIN_7) - && BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent + if (BootEncObj->GetSystemDriveConfiguration().ExtraBootPartitionPresent && AskWarnYesNo ("CONFIRM_HIDDEN_OS_EXTRA_BOOT_PARTITION", hwndDlg) == IDNO) { TextInfoDialogBox (TC_TBXID_EXTRA_BOOT_PARTITION_REMOVAL_INSTRUCTIONS); NormalCursor (); return 1; } if (AskWarnYesNo ("DECOY_OS_REQUIREMENTS", hwndDlg) == IDNO) { NormalCursor (); return 1; } if (!ChangeWizardMode (WIZARD_MODE_NONSYS_DEVICE)) { NormalCursor (); return 1; } // Skip irrelevant pages nNewPageNo = HIDDEN_VOL_HOST_PRE_CIPHER_PAGE - 1; } else if ((nMultiBoot <= 1) || bSystemIsGPT) { // Single-boot (not creating a hidden OS) // Multi-boot in case of GPT // Skip irrelevant pages nNewPageNo = CIPHER_PAGE - 1; } @@ -7653,67 +7611,60 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa RandSetHashFunction (hash_algo); if (SysEncInEffect () || bInPlaceEncNonSys) nNewPageNo = PASSWORD_PAGE - 1; // Skip irrelevant pages } else if (nCurPageNo == SIZE_PAGE) { wchar_t szFileSystemNameBuffer[256]; VerifySizeAndUpdate (hCurPage, TRUE); if (!bDevice) { /* Verify that the volume would not be too large for the host file system */ wchar_t root[TC_MAX_PATH]; if (GetVolumePathName (szDiskFile, root, ARRAYSIZE (root)) && GetVolumeInformation (root, NULL, 0, NULL, NULL, NULL, szFileSystemNameBuffer, ARRAYSIZE(szFileSystemNameBuffer)) && !wcsncmp (szFileSystemNameBuffer, L"FAT32", 5)) { // The host file system is FAT32 if (nUIVolumeSize * nMultiplier >= 4 * BYTES_PER_GB) { Error ("VOLUME_TOO_LARGE_FOR_FAT32", hwndDlg); return 1; } } - /* Verify that the volume would not be too large for the operating system */ - - if (!IsOSAtLeast (WIN_VISTA) - && nUIVolumeSize * nMultiplier > 2 * BYTES_PER_TB) - { - Warning ("VOLUME_TOO_LARGE_FOR_WINXP", hwndDlg); - } } if (bHiddenVol && !bHiddenVolHost) // If it's a hidden volume { /* Ask for confirmation if the hidden volume is too large for the user to be able to write much more data to the outer volume. */ if (((double) nUIVolumeSize / (nMaximumHiddenVolSize / nMultiplier)) > 0.85) // 85% { if (AskWarnNoYes ("FREE_SPACE_FOR_WRITING_TO_OUTER_VOLUME", hwndDlg) == IDNO) return 1; } } if (!(bHiddenVolDirect && bHiddenVolHost)) nNewPageNo = PASSWORD_PAGE - 1; } else if (nCurPageNo == PASSWORD_PAGE) { VerifyPasswordAndUpdate (hwndDlg, GetDlgItem (MainDlg, IDC_NEXT), GetDlgItem (hCurPage, IDC_PASSWORD), GetDlgItem (hCurPage, IDC_VERIFY), volumePassword.Text, szVerify, KeyFilesEnable && FirstKeyFile!=NULL && !SysEncInEffect()); volumePassword.Length = (unsigned __int32) strlen ((char *) volumePassword.Text); if (volumePassword.Length > 0) @@ -9262,61 +9213,61 @@ void ExtractCommandLine (HWND hwndDlg, wchar_t *lpszCommandLine) else AbortProcess ("COMMAND_LINE_ERROR"); } break; case OptionEncryption: { wchar_t szTmp[64] = {0}; if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))) { CmdVolumeEA = EAGetByName (szTmp); if (CmdVolumeEA == 0) AbortProcess ("COMMAND_LINE_ERROR"); } else AbortProcess ("COMMAND_LINE_ERROR"); } break; case OptionFilesystem: { wchar_t szTmp[8] = {0}; if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))) { if (_wcsicmp(szTmp, L"NONE") == 0) CmdVolumeFilesystem = FILESYS_NONE; else if (_wcsicmp(szTmp, L"FAT32") == 0 || _wcsicmp(szTmp, L"FAT") == 0) CmdVolumeFilesystem = FILESYS_FAT; else if (_wcsicmp(szTmp, L"NTFS") == 0) CmdVolumeFilesystem = FILESYS_NTFS; - else if (IsOSVersionAtLeast (WIN_VISTA, 1) && _wcsicmp(szTmp, L"EXFAT") == 0) + else if (_wcsicmp(szTmp, L"EXFAT") == 0) CmdVolumeFilesystem = FILESYS_EXFAT; else if (IsOSVersionAtLeast (WIN_10, 0) && _wcsicmp(szTmp, L"ReFS") == 0) CmdVolumeFilesystem = FILESYS_REFS; else { AbortProcess ("COMMAND_LINE_ERROR"); } } else AbortProcess ("COMMAND_LINE_ERROR"); } break; case OptionPassword: { wchar_t szTmp[MAX_PASSWORD + 1]; if (HAS_ARGUMENT == GetArgumentValue (lpszCommandLineArgs, &i, nNoCommandLineArgs, szTmp, ARRAYSIZE (szTmp))) { int iLen = WideCharToMultiByte (CP_UTF8, 0, szTmp, -1, (LPSTR) CmdVolumePassword.Text, iMaxPasswordLength + 1, NULL, NULL); burn (szTmp, sizeof (szTmp)); if (iLen > 0) CmdVolumePassword.Length = (unsigned __int32) (iLen - 1); else AbortProcess ("COMMAND_LINE_ERROR"); } else AbortProcess ("COMMAND_LINE_ERROR"); } break; case OptionPkcs5: @@ -10623,94 +10574,89 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz VirtualLock (MasterKeyGUIView, sizeof(MasterKeyGUIView)); VirtualLock (HeaderKeyGUIView, sizeof(HeaderKeyGUIView)); VirtualLock (randPool, sizeof(randPool)); VirtualLock (lastRandPool, sizeof(lastRandPool)); VirtualLock (outRandPoolDispBuffer, sizeof(outRandPoolDispBuffer)); VirtualLock (&mouseEntropyGathered, sizeof(mouseEntropyGathered)); VirtualLock (&mouseEventsInitialCount, sizeof(mouseEventsInitialCount)); VirtualLock (maskRandPool, sizeof(maskRandPool)); VirtualLock (&szFileName, sizeof(szFileName)); VirtualLock (&szDiskFile, sizeof(szDiskFile)); DetectX86Features (); try { BootEncObj = new BootEncryption (NULL); } catch (Exception &e) { e.Show (NULL); } if (BootEncObj == NULL) AbortProcess ("INIT_SYS_ENC"); InitApp (hInstance, lpszCommandLine); - // Write block size greater than 64 KB causes a performance drop when writing to files on XP/Vista - if (!IsOSAtLeast (WIN_7)) - FormatWriteBufferSize = 64 * 1024; - #if TC_MAX_VOLUME_SECTOR_SIZE > 64 * 1024 #error TC_MAX_VOLUME_SECTOR_SIZE > 64 * 1024 #endif nPbar = IDC_PROGRESS_BAR; if (Randinit ()) { DWORD dwLastError = GetLastError (); wchar_t szTmp[4096]; if (CryptoAPILastError == ERROR_SUCCESS) StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("INIT_RAND"), SRC_POS, dwLastError); else StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CAPI_RAND"), SRC_POS, CryptoAPILastError); AbortProcessDirect (szTmp); } RegisterRedTick(hInstance); /* Allocate, dup, then store away the application title */ lpszTitle = GetString ("IDD_VOL_CREATION_WIZARD_DLG"); status = DriverAttach (); if (status != 0) { if (status == ERR_OS_ERROR) handleWin32Error (NULL, SRC_POS); else handleError (NULL, status, SRC_POS); AbortProcess ("NODRIVER"); } if (!AutoTestAlgorithms()) AbortProcess ("ERR_SELF_TESTS_FAILED"); /* Create the main dialog box */ DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_VOL_CREATION_WIZARD_DLG), NULL, (DLGPROC) MainDialogProc, (LPARAM)lpszCommandLine); - FinalizeApp (); return 0; } static DWORD GetFormatSectorSize () { if (!bDevice) return TC_SECTOR_SIZE_FILE_HOSTED_VOLUME; DISK_GEOMETRY_EX geometry; if (!GetDriveGeometry (szDiskFile, &geometry)) { handleWin32Error (MainDlg, SRC_POS); AbortProcessSilent(); } return geometry.Geometry.BytesPerSector; } diff --git a/src/LICENSE b/src/LICENSE index 19d47e25..2e1779a0 100644 --- a/src/LICENSE +++ b/src/LICENSE @@ -148,43 +148,43 @@ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS -Copyright 2013-2023 IDRIX +Copyright 2013-2024 IDRIX Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at https://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
\ No newline at end of file diff --git a/src/License.html b/src/License.html index ce476eeb..08a4aeae 100644 --- a/src/License.html +++ b/src/License.html @@ -136,85 +136,117 @@ This Product contains components that were created by third parties and that are 3. If you use any of the source code originally by Eric Young, you must in addition follow his terms and conditions.<br> <br> 4. Nothing requires that you accept this License, as you have not signed it. However, nothing else grants you permission to modify or distribute the product or its derivative works.<br> <br> These actions are prohibited by law if you do not accept this License.<br> <br> 5. If any of these license terms is found to be to broad in scope, and declared invalid by any court or legal process, you agree that all other terms shall not be so affected, and shall remain valid and enforceable.<br> <br> 6. THIS PROGRAM IS DISTRIBUTED FREE OF CHARGE, THEREFORE THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. UNLESS OTHERWISE STATED THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.<br> <br> 7. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM, INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS, EVEN IF SUCH HOLDER OR OTHER PARTY HAD PREVIOUSLY BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.<br> ____________________________________________________________<br> <br> Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.<br> <br> LICENSE TERMS<br> <br> The free distribution and use of this software is allowed (with or without changes) provided that:<br> <ol> <li>source code distributions include the above copyright notice, this list of conditions and the following disclaimer;<br> </li> <li>binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation;<br> </li> <li>the name of the copyright holder is not used to endorse products built using this software without specific written permission.</li> </ol> DISCLAIMER<br> <br> This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose.<br> ____________________________________________________________<br> <br> - Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler.<br> + Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler.<br> <br> This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.<br> <br> Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:<br> <ol> <li>The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.</li> <li> Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.</li> <li> This notice may not be removed or altered from any source distribution.</li> </ol> Jean-loup Gailly Mark Adler<br> jloup@gzip.org madler@alumni.caltech.edu<br> ____________________________________________________________<br> <br> - Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner<br> + Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner<br> <br> The authors can be contacted at <libzip@nih.at><br> <br> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<br> <br> <ol> <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li> <li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li> <li>The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission.</li> </ol> <br> THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br> ____________________________________________________________<br> <br> Copyright (c) 2013, Alexey Degtyarev. All rights reserved.<br> <br> ________________________________________________________<br> <br> Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov<br> <br> This program and the accompanying materials are licensed and made available under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).<br> <br> The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0<br> ____________________________________________________________<br> <br> Copyright (c) 1999-2016 Jack Lloyd. <br> <br> All rights reserved.<br> <br> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<br> <br> <ol> <li>Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.</li> <li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li> </ol> <br> THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br> ____________________________________________________________<br> +<br> +Copyright (c) 2013-2019 Stephan Mueller <smueller@chronox.de><br> +<br> +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<br> +<ol> +<li>Redistributions of source code must retain the above copyright notice, and the entire permission notice in its entirety, including the disclaimer of warranties.</li> +<li>Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.</li> +<li>The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.</li> +</ol> +<p> +ALTERNATIVELY, this product may be distributed under the terms of the GNU General Public License, in which case the provisions of the GPL2 are required INSTEAD OF the above restrictions. (This clause is necessary due to a potential bad interaction between the GPL and the restrictions contained in a BSD-style copyright.) +</p> +<p> +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +</p> +____________________________________________________________<br> +<br> +Copyright (c) 1999-2023 Igor Pavlov<br> +<br> +LZMA SDK is written and placed in the public domain by Igor Pavlov.<br> +<br> +Some code in LZMA SDK is based on public domain code from another developers:<br> +<ol> + <li> PPMd var.H (2001): Dmitry Shkarin</li> + <li> SHA-256: Wei Dai (Crypto++ library)</li> +</ol> +<p> + Anyone is free to copy, modify, publish, use, compile, sell, or distribute the <br> + original LZMA SDK code, either in source code form or as a compiled binary, for <br> + any purpose, commercial or non-commercial, and by any means. +</p> +____________________________________________________________<br> </body> </html> diff --git a/src/License.txt b/src/License.txt index cbdf8128..28b9b94f 100644 --- a/src/License.txt +++ b/src/License.txt @@ -652,82 +652,82 @@ ANY OTHER PROGRAMS, EVEN IF SUCH HOLDER OR OTHER PARTY HAD PREVIOUSLY BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ____________________________________________________________ Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. ____________________________________________________________ -Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu ____________________________________________________________ -Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner +Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner The authors can be contacted at <libzip@nih.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -743,34 +743,79 @@ version 3.0 (LGPL-3.0). The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0 ____________________________________________________________ Copyright (c) 1999-2016 Jack Lloyd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ____________________________________________________________ -LZMA SDK Copyright (C) 1999-2021 Igor Pavlov +Copyright (c) 2013-2019 Stephan Mueller <smueller@chronox.de> -Public domain +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, and the entire permission notice in its entirety, + including the disclaimer of warranties. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +ALTERNATIVELY, this product may be distributed under the terms of +the GNU General Public License, in which case the provisions of the +GPL2 are required INSTEAD OF the above restrictions. (This clause is +necessary due to a potential bad interaction between the GPL and the +restrictions contained in a BSD-style copyright.) + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH +ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +____________________________________________________________ +Copyright (c) 1999-2023 Igor Pavlov + +LZMA SDK is written and placed in the public domain by Igor Pavlov. + +Some code in LZMA SDK is based on public domain code from another developers: + 1) PPMd var.H (2001): Dmitry Shkarin + 2) SHA-256: Wei Dai (Crypto++ library) + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute the +original LZMA SDK code, either in source code form or as a compiled binary, for +any purpose, commercial or non-commercial, and by any means. ____________________________________________________________ diff --git a/src/Main/Application.cpp b/src/Main/Application.cpp index c72e2cc6..27b8f55a 100644 --- a/src/Main/Application.cpp +++ b/src/Main/Application.cpp @@ -62,61 +62,61 @@ namespace VeraCrypt configDir->swap(legacyConfigDir); } } #endif } //wcerr << L"Config dir: " << *configDir << endl; return configDir; } } wxApp* Application::CreateConsoleApp () { mUserInterface = new TextUserInterface; mUserInterfaceType = UserInterfaceType::Text; return mUserInterface; } #ifndef TC_NO_GUI wxApp* Application::CreateGuiApp () { mUserInterface = new GraphicUserInterface; mUserInterfaceType = UserInterfaceType::Graphic; wxSetEnv("WXSUPPRESS_SIZER_FLAGS_CHECK", "1"); return mUserInterface; } #endif FilePath Application::GetConfigFilePath (const wxString &configFileName, bool createConfigDir) { - static wxScopedPtr<const wxString> configDirC; + static std::unique_ptr<const wxString> configDirC; static bool configDirExists = false; if (!configDirExists) { if (!configDirC) { wxString *configDir; if (Core->IsInPortableMode()) { configDir = new wxString ( wxPathOnly(wxStandardPaths::Get().GetExecutablePath())); } else { configDir = GetXdgConfigPath(); } EnsureEndsWithPathSeparator(*configDir); configDirC.reset(configDir); } if (createConfigDir) { if (!wxDirExists(*configDirC)) { //wcerr << L"Creating config dir »" << *configDirC << L"« ..." << endl; throw_sys_sub_if( !wxMkdir(*configDirC, wxS_IRUSR | wxS_IWUSR | wxS_IXUSR), configDirC->ToStdWstring()); diff --git a/src/Main/CommandLineInterface.cpp b/src/Main/CommandLineInterface.cpp index 2bbc73ea..735cbeef 100644 --- a/src/Main/CommandLineInterface.cpp +++ b/src/Main/CommandLineInterface.cpp @@ -2,72 +2,76 @@ Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include <wx/cmdline.h> #include <wx/tokenzr.h> #include "Core/Core.h" #include "Application.h" #include "CommandLineInterface.h" #include "LanguageStrings.h" #include "UserInterfaceException.h" namespace VeraCrypt { CommandLineInterface::CommandLineInterface (int argc, wchar_t** argv, UserInterfaceType::Enum interfaceType) : ArgCommand (CommandId::None), ArgFilesystem (VolumeCreationOptions::FilesystemType::Unknown), ArgNewPim (-1), ArgNoHiddenVolumeProtection (false), ArgPim (-1), ArgSize (0), ArgVolumeType (VolumeType::Unknown), + ArgAllowScreencapture (false), ArgDisableFileSizeCheck (false), ArgUseLegacyPassword (false), #if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword (false), #endif StartBackgroundTask (false) { wxCmdLineParser parser; parser.SetCmdLine (argc, argv); parser.SetSwitchChars (L"-"); +#if defined(TC_WINDOWS) || defined(TC_MACOSX) + parser.AddSwitch (L"", L"allow-screencapture", _("Allow window to be included in screenshots and screen captures (Windows/MacOS)")); +#endif parser.AddOption (L"", L"auto-mount", _("Auto mount device-hosted/favorite volumes")); parser.AddSwitch (L"", L"backup-headers", _("Backup volume headers")); parser.AddSwitch (L"", L"background-task", _("Start Background Task")); #ifdef TC_WINDOWS parser.AddSwitch (L"", L"cache", _("Cache passwords and keyfiles")); #endif parser.AddSwitch (L"C", L"change", _("Change password or keyfiles")); parser.AddSwitch (L"c", L"create", _("Create new volume")); parser.AddSwitch (L"", L"create-keyfile", _("Create new keyfile")); parser.AddSwitch (L"", L"delete-token-keyfiles", _("Delete security token keyfiles")); parser.AddSwitch (L"d", L"dismount", _("Dismount volume")); parser.AddSwitch (L"", L"display-password", _("Display password while typing")); parser.AddOption (L"", L"encryption", _("Encryption algorithm")); parser.AddSwitch (L"", L"explore", _("Open explorer window for mounted volume")); parser.AddSwitch (L"", L"export-token-keyfile",_("Export keyfile from token")); parser.AddOption (L"", L"filesystem", _("Filesystem type")); parser.AddSwitch (L"f", L"force", _("Force mount/dismount/overwrite")); #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) parser.AddOption (L"", L"fs-options", _("Filesystem mount options")); #endif parser.AddOption (L"", L"hash", _("Hash algorithm")); parser.AddSwitch (L"h", L"help", _("Display detailed command line help"), wxCMD_LINE_OPTION_HELP); parser.AddSwitch (L"", L"import-token-keyfiles", _("Import keyfiles to security token")); parser.AddOption (L"k", L"keyfiles", _("Keyfiles")); parser.AddSwitch (L"l", L"list", _("List mounted volumes")); parser.AddSwitch (L"", L"list-token-keyfiles", _("List token keyfiles")); parser.AddSwitch (L"", L"list-securitytoken-keyfiles", _("List security token keyfiles")); parser.AddSwitch (L"", L"list-emvtoken-keyfiles", _("List EMV token keyfiles")); parser.AddSwitch (L"", L"load-preferences", _("Load user preferences")); parser.AddSwitch (L"", L"mount", _("Mount volume interactively")); @@ -115,60 +119,65 @@ namespace VeraCrypt if (parser.Parse () > 0) throw_err (_("Incorrect command line specified.")); if (parser.Found (L"help")) { ArgCommand = CommandId::Help; return; } if (parser.Found (L"text") && interfaceType != UserInterfaceType::Text) { wstring msg = wstring (_("Option -t or --text must be specified as the first argument.")); wcerr << msg << endl; throw_err (msg); } if (parser.Found (L"version")) { ArgCommand = CommandId::DisplayVersion; return; } // Preferences if (parser.Found (L"load-preferences")) { // Load preferences first to allow command line options to override them Preferences.Load(); ArgMountOptions = Preferences.DefaultMountOptions; } +#if defined(TC_WINDOWS) || defined(TC_MACOSX) + ArgAllowScreencapture = parser.Found (L"allow-screencapture"); +#else + ArgAllowScreencapture = true; // Protection against screenshots is supported only on Windows and MacOS +#endif // Commands if (parser.Found (L"auto-mount", &str)) { CheckCommandSingle(); wxStringTokenizer tokenizer (str, L","); while (tokenizer.HasMoreTokens()) { wxString token = tokenizer.GetNextToken(); if (token == L"devices") { if (ArgCommand == CommandId::AutoMountFavorites) ArgCommand = CommandId::AutoMountDevicesFavorites; else ArgCommand = CommandId::AutoMountDevices; param1IsMountPoint = true; } else if (token == L"favorites") { if (ArgCommand == CommandId::AutoMountDevices) ArgCommand = CommandId::AutoMountDevicesFavorites; else ArgCommand = CommandId::AutoMountFavorites; } else { throw_err (LangString["UNKNOWN_OPTION"] + L": " + token); } @@ -320,60 +329,70 @@ namespace VeraCrypt #ifdef TC_LINUX else if (str.IsSameAs (L"Ext2", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext2; else if (str.IsSameAs (L"Ext3", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext3; else if (str.IsSameAs (L"Ext4", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext4; else if (str.IsSameAs (L"NTFS", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::NTFS; else if (str.IsSameAs (L"exFAT", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::exFAT; else if (str.IsSameAs (L"Btrfs", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Btrfs; #elif defined (TC_MACOSX) else if ( str.IsSameAs (L"HFS", false) || str.IsSameAs (L"HFS+", false) || str.IsSameAs (L"MacOsExt", false) ) { ArgFilesystem = VolumeCreationOptions::FilesystemType::MacOsExt; } else if (str.IsSameAs (L"exFAT", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::exFAT; else if (str.IsSameAs (L"Btrfs", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::Btrfs; else if (str.IsSameAs (L"APFS", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::APFS; #elif defined (TC_FREEBSD) || defined (TC_SOLARIS) else if (str.IsSameAs (L"UFS", false)) ArgFilesystem = VolumeCreationOptions::FilesystemType::UFS; + else if (str.IsSameAs (L"Ext2", false)) + ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext2; + else if (str.IsSameAs (L"Ext3", false)) + ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext3; + else if (str.IsSameAs (L"Ext4", false)) + ArgFilesystem = VolumeCreationOptions::FilesystemType::Ext4; + else if (str.IsSameAs (L"NTFS", false)) + ArgFilesystem = VolumeCreationOptions::FilesystemType::NTFS; + else if (str.IsSameAs (L"exFAT", false)) + ArgFilesystem = VolumeCreationOptions::FilesystemType::exFAT; #endif else throw_err (LangString["UNKNOWN_OPTION"] + L": " + str); } } ArgForce = parser.Found (L"force"); ArgDisableFileSizeCheck = parser.Found (L"no-size-check"); ArgUseLegacyPassword = parser.Found (L"legacy-password-maxlength"); #if defined(TC_LINUX ) || defined (TC_FREEBSD) ArgUseDummySudoPassword = parser.Found (L"use-dummy-sudo-password"); #endif #if !defined(TC_WINDOWS) && !defined(TC_MACOSX) if (parser.Found (L"fs-options", &str)) ArgMountOptions.FilesystemOptions = str; #endif if (parser.Found (L"hash", &str)) { ArgHash.reset(); foreach (shared_ptr <Hash> hash, Hash::GetAvailableAlgorithms()) { wxString hashName (hash->GetName()); wxString hashAltName (hash->GetAltName()); if (hashName.IsSameAs (str, false) || hashAltName.IsSameAs (str, false)) ArgHash = hash; } @@ -797,50 +816,50 @@ namespace VeraCrypt if (!mountedVolumeSpec.IsEmpty() && filteredVolumes.size() < 1) throw_err (_("No such volume is mounted.")); return filteredVolumes; } shared_ptr<VolumePassword> ToUTF8Password (const wchar_t* str, size_t charCount, size_t maxUtf8Len) { if (charCount > 0) { shared_ptr<SecureBuffer> utf8Buffer = ToUTF8Buffer (str, charCount, maxUtf8Len); return shared_ptr<VolumePassword>(new VolumePassword (*utf8Buffer)); } else return shared_ptr<VolumePassword>(new VolumePassword ()); } shared_ptr<SecureBuffer> ToUTF8Buffer (const wchar_t* str, size_t charCount, size_t maxUtf8Len) { if (charCount == (size_t) -1) charCount = wcslen (str); if (charCount > 0) { wxMBConvUTF8 utf8; size_t ulen = utf8.FromWChar (NULL, 0, str, charCount); if (wxCONV_FAILED == ulen) throw PasswordUTF8Invalid (SRC_POS); SecureBuffer passwordBuf(ulen); - ulen = utf8.FromWChar ((char*) (byte*) passwordBuf, ulen, str, charCount); + ulen = utf8.FromWChar ((char*) (uint8*) passwordBuf, ulen, str, charCount); if (wxCONV_FAILED == ulen) throw PasswordUTF8Invalid (SRC_POS); if (ulen > maxUtf8Len) { if (maxUtf8Len == VolumePassword::MaxLegacySize) throw PasswordLegacyUTF8TooLong (SRC_POS); else throw PasswordUTF8TooLong (SRC_POS); } - ConstBufferPtr utf8Buffer ((byte*) passwordBuf, ulen); + ConstBufferPtr utf8Buffer ((uint8*) passwordBuf, ulen); return shared_ptr<SecureBuffer>(new SecureBuffer (utf8Buffer)); } else return shared_ptr<SecureBuffer>(new SecureBuffer ()); } unique_ptr <CommandLineInterface> CmdLine; } diff --git a/src/Main/CommandLineInterface.h b/src/Main/CommandLineInterface.h index 4003dc05..f773ca6f 100644 --- a/src/Main/CommandLineInterface.h +++ b/src/Main/CommandLineInterface.h @@ -57,56 +57,57 @@ namespace VeraCrypt { public: CommandLineInterface (int argc, wchar_t** argv, UserInterfaceType::Enum interfaceType); virtual ~CommandLineInterface (); CommandId::Enum ArgCommand; bool ArgDisplayPassword; shared_ptr <EncryptionAlgorithm> ArgEncryptionAlgorithm; shared_ptr <FilePath> ArgFilePath; VolumeCreationOptions::FilesystemType::Enum ArgFilesystem; bool ArgForce; shared_ptr <Hash> ArgHash; shared_ptr <KeyfileList> ArgKeyfiles; MountOptions ArgMountOptions; shared_ptr <DirectoryPath> ArgMountPoint; shared_ptr <Hash> ArgNewHash; shared_ptr <KeyfileList> ArgNewKeyfiles; shared_ptr <VolumePassword> ArgNewPassword; int ArgNewPim; bool ArgNoHiddenVolumeProtection; shared_ptr <VolumePassword> ArgPassword; int ArgPim; bool ArgQuick; FilesystemPath ArgRandomSourcePath; uint64 ArgSize; shared_ptr <VolumePath> ArgVolumePath; VolumeInfoList ArgVolumes; VolumeType::Enum ArgVolumeType; shared_ptr<SecureBuffer> ArgTokenPin; + bool ArgAllowScreencapture; bool ArgDisableFileSizeCheck; bool ArgUseLegacyPassword; #if defined(TC_LINUX ) || defined (TC_FREEBSD) bool ArgUseDummySudoPassword; #endif bool StartBackgroundTask; UserPreferences Preferences; protected: void CheckCommandSingle () const; shared_ptr <KeyfileList> ToKeyfileList (const wxString &arg) const; VolumeInfoList GetMountedVolumes (const wxString &filter) const; private: CommandLineInterface (const CommandLineInterface &); CommandLineInterface &operator= (const CommandLineInterface &); }; shared_ptr<VolumePassword> ToUTF8Password (const wchar_t* str, size_t charCount, size_t maxUtf8Len); shared_ptr<SecureBuffer> ToUTF8Buffer (const wchar_t* str, size_t charCount, size_t maxUtf8Len); extern unique_ptr <CommandLineInterface> CmdLine; } #endif // TC_HEADER_Main_CommandInterface diff --git a/src/Main/Forms/AboutDialog.cpp b/src/Main/Forms/AboutDialog.cpp index ba341dd2..01c579d5 100644 --- a/src/Main/Forms/AboutDialog.cpp +++ b/src/Main/Forms/AboutDialog.cpp @@ -1,79 +1,83 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include "Volume/Version.h" #include "Main/Application.h" #include "Main/GraphicUserInterface.h" #include "Main/Resources.h" #include "AboutDialog.h" namespace VeraCrypt { AboutDialog::AboutDialog (wxWindow* parent) : AboutDialogBase (parent) { LogoBitmap->SetBitmap (Resources::GetTextualLogoBitmap()); wxFont versionStaticTextFont = VersionStaticText->GetFont(); versionStaticTextFont.SetWeight (wxFONTWEIGHT_BOLD); VersionStaticText->SetFont (versionStaticTextFont); - VersionStaticText->SetLabel (Application::GetName() + L" " + StringConverter::ToWide (Version::String())); + wstring versionStr = StringConverter::ToWide (Version::String()); +#ifdef VC_MACOSX_FUSET + versionStr += L" (FUSE-T build)"; +#endif + VersionStaticText->SetLabel (Application::GetName() + L" " + versionStr); CopyrightStaticText->SetLabel (TC_STR_RELEASED_BY); WebsiteHyperlink->SetLabel (L"www.idrix.fr"); CreditsTextCtrl->SetMinSize (wxSize ( Gui->GetCharWidth (CreditsTextCtrl) * 70, Gui->GetCharHeight (CreditsTextCtrl) * 6 #ifdef TC_WINDOWS - 5 #else - 11 #endif )); Layout(); Fit(); Center(); CreditsTextCtrl->ChangeValue ( L"Portions of this software are based in part on the works of the following people: " L"Paul Le Roux, " L"Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, Niels Ferguson, " L"Lars Knudsen, Ross Anderson, Eli Biham, " L"Joan Daemen, Vincent Rijmen, " L"Jean-loup Gailly, Mark Adler, " L"Phillip Rogaway, " L"Hans Dobbertin, Antoon Bosselaers, Bart Preneel, Jack Lloyd" L"Paulo Barreto, Brian Gladman, Wei Dai, Peter Gutmann, and many others.\n\n" L"Portions of this software:\n" - L"Copyright \xA9 2013-2022 IDRIX. All rights reserved.\n" + L"Copyright \xA9 2013-2024 IDRIX. All rights reserved.\n" L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\n" L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\n" L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\n" - L"Copyright \xA9 1995-2017 Jean-loup Gailly and Mark Adler.\n" + L"Copyright \xA9 1995-2023 Jean-loup Gailly and Mark Adler.\n" L"Copyright \xA9 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov.\n" - L"Copyright \xA9 1999-2017 Dieter Baron and Thomas Klausner.\n" + L"Copyright \xA9 1999-2023 Dieter Baron and Thomas Klausner.\n" L"Copyright \xA9 2013, Alexey Degtyarev. All rights reserved.\n" L"Copyright \xA9 1999-2016 Jack Lloyd. All rights reserved.\n" L"Copyright \xA9 2013-2019 Stephan Mueller <smueller@chronox.de>\n" - L"Copyright \xA9 1999-2021 Igor Pavlov\n\n" + L"Copyright \xA9 1999-2023 Igor Pavlov\n\n" L"\nThis software as a whole:\n" - L"Copyright \xA9 2013-2022 IDRIX. All rights reserved.\n\n" + L"Copyright \xA9 2013-2024 IDRIX. All rights reserved.\n\n" L"This software uses wxWidgets library, which is copyright \xA9 1998-2011 Julian Smart, Robert Roebling et al.\n\n" L"An IDRIX Release"); } } diff --git a/src/Main/Forms/BenchmarkDialog.cpp b/src/Main/Forms/BenchmarkDialog.cpp index 7b0209ff..6e2cff64 100644 --- a/src/Main/Forms/BenchmarkDialog.cpp +++ b/src/Main/Forms/BenchmarkDialog.cpp @@ -1,78 +1,81 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "Main/GraphicUserInterface.h" #include "BenchmarkDialog.h" namespace VeraCrypt { BenchmarkDialog::BenchmarkDialog (wxWindow *parent) : BenchmarkDialogBase (parent) { BenchmarkNoteStaticText->SetLabel (LangString["IDT_BOX_BENCHMARK_INFO"]); BenchmarkNoteStaticText->Wrap (RightSizer->GetSize().GetWidth()); list <size_t> bufferSizes; bufferSizes.push_back (1 * BYTES_PER_MB); bufferSizes.push_back (5 * BYTES_PER_MB); bufferSizes.push_back (10 * BYTES_PER_MB); bufferSizes.push_back (50 * BYTES_PER_MB); bufferSizes.push_back (100 * BYTES_PER_MB); bufferSizes.push_back (200 * BYTES_PER_MB); bufferSizes.push_back (500 * BYTES_PER_MB); bufferSizes.push_back (1 * BYTES_PER_GB); foreach (size_t size, bufferSizes) { BufferSizeChoice->Append (Gui->SizeToString (size), (void *) size); } BenchmarkChoice->Select (0); BufferSizeChoice->Select (1); UpdateBenchmarkList (); - - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + + VolumePimText->SetMinSize (wxSize (Gui->GetCharWidth (VolumePimText) * 15, -1)); + + wxTextValidator validator (wxFILTER_DIGITS); VolumePimText->SetValidator (validator); Layout(); Fit(); Center(); } void BenchmarkDialog::UpdateBenchmarkList () { int index = BenchmarkChoice->GetSelection (); if (index == 1) { // PRF case m_volumePimLabel->Show (); VolumePimText->Show (); BufferSizeChoice->Hide (); m_bufferSizeLabel->Hide (); } else { m_volumePimLabel->Hide (); VolumePimText->Hide (); BufferSizeChoice->Show (); m_bufferSizeLabel->Show (); } BenchmarkListCtrl->DeleteAllItems(); BenchmarkListCtrl->DeleteAllColumns(); @@ -182,63 +185,67 @@ namespace VeraCrypt fields[ColumnHashMean] = Gui->SpeedToString (result.MeanSpeed); } Gui->AppendToListCtrl (BenchmarkListCtrl, fields); } BenchmarkListCtrl->SetColumnWidth(0, wxLIST_AUTOSIZE); wxSize minSize = BenchmarkListCtrl->GetBestSize (); minSize.IncBy (10, 20); BenchmarkListCtrl->SetMinSize(minSize); Layout (); Fit(); } void BenchmarkDialog::DoBenchmark (list<BenchmarkResult>& results, Buffer& buffer, int opIndex) { try { if (opIndex == 0) { EncryptionAlgorithmList encryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms) { if (!ea->IsDeprecated()) { BenchmarkResult result; result.AlgorithmName = ea->GetName(true); Buffer key (ea->GetKeySize()); ea->SetKey (key); - + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> xts (new EncryptionModeWolfCryptXTS); + ea->SetKeyXTS (key); + #else shared_ptr <EncryptionMode> xts (new EncryptionModeXTS); - xts->SetKey (key); + #endif + xts->SetKey (key); ea->SetMode (xts); wxLongLong startTime = wxGetLocalTimeMillis(); // CPU "warm up" (an attempt to prevent skewed results on systems where CPU frequency gradually changes depending on CPU load). do { ea->EncryptSectors (buffer, 0, buffer.Size() / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); } while (wxGetLocalTimeMillis().GetValue() - startTime.GetValue() < 20); uint64 size = 0; uint64 time; startTime = wxGetLocalTimeMillis(); do { ea->EncryptSectors (buffer, 0, buffer.Size() / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); size += buffer.Size(); time = (uint64) (wxGetLocalTimeMillis().GetValue() - startTime.GetValue()); } while (time < 100); result.EncryptionSpeed = size * 1000 / time; startTime = wxGetLocalTimeMillis(); size = 0; do { @@ -247,61 +254,61 @@ namespace VeraCrypt time = (uint64) (wxGetLocalTimeMillis().GetValue() - startTime.GetValue()); } while (time < 100); result.DecryptionSpeed = size * 1000 / time; result.MeanSpeed = (result.EncryptionSpeed + result.DecryptionSpeed) / 2; bool inserted = false; for (list <BenchmarkResult>::iterator i = results.begin(); i != results.end(); ++i) { if (i->MeanSpeed < result.MeanSpeed) { results.insert (i, result); inserted = true; break; } } if (!inserted) results.push_back (result); } } } else if (opIndex == 1) { Buffer dk(MASTER_KEYDATA_SIZE); Buffer salt(64); const 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"}; unsigned long pim; Pkcs5KdfList prfList = Pkcs5Kdf::GetAvailableAlgorithms (); - VolumePassword password ((const byte*) "passphrase-1234567890", 21); + VolumePassword password ((const uint8*) "passphrase-1234567890", 21); memcpy (&pim, buffer.Ptr (), sizeof (unsigned long)); memcpy (salt.Ptr(), tmp_salt, 64); foreach (shared_ptr <Pkcs5Kdf> prf, prfList) { if (!prf->IsDeprecated()) { BenchmarkResult result; result.AlgorithmName = prf->GetName (); result.Iterations = (uint64) prf->GetIterationCount (pim); uint64 time; wxLongLong startTime = wxGetLocalTimeMillis(); for (int i = 1; i <= 2; i++) { prf->DeriveKey (dk, password, pim, salt); } time = (uint64) (wxGetLocalTimeMillis().GetValue() - startTime.GetValue()); result.Time = time / 2; bool inserted = false; for (list <BenchmarkResult>::iterator i = results.begin(); i != results.end(); ++i) { if (i->Time > result.Time) { results.insert (i, result); diff --git a/src/Main/Forms/ChangePasswordDialog.cpp b/src/Main/Forms/ChangePasswordDialog.cpp index 397ee693..39da8e60 100644 --- a/src/Main/Forms/ChangePasswordDialog.cpp +++ b/src/Main/Forms/ChangePasswordDialog.cpp @@ -144,103 +144,108 @@ namespace VeraCrypt NewPasswordPanel->SetFocusToPasswordTextCtrl(); return; } } else if (newPim > 0 && newPim < 485) { if (!Gui->AskYesNo (LangString ["PIM_SMALL_WARNING"], false, true)) { NewPasswordPanel->SetFocusToPimTextCtrl(); return; } } } } else { newPassword = CurrentPasswordPanel->GetPassword(); newPim = CurrentPasswordPanel->GetVolumePim(); } shared_ptr <KeyfileList> newKeyfiles; if (DialogMode == Mode::ChangePasswordAndKeyfiles || DialogMode == Mode::ChangeKeyfiles) newKeyfiles = NewPasswordPanel->GetKeyfiles(); else if (DialogMode != Mode::RemoveAllKeyfiles) newKeyfiles = CurrentPasswordPanel->GetKeyfiles(); /* force the display of the random enriching interface */ RandomNumberGenerator::SetEnrichedByUserStatus (false); Gui->UserEnrichRandomPool (this, NewPasswordPanel->GetPkcs5Kdf() ? NewPasswordPanel->GetPkcs5Kdf()->GetHash() : shared_ptr <Hash>()); + bool masterKeyVulnerable = false; { #ifdef TC_UNIX // Temporarily take ownership of a device if the user is not an administrator UserId origDeviceOwner ((uid_t) -1); if (!Core->HasAdminPrivileges() && Path->IsDevice()) { origDeviceOwner = FilesystemPath (wstring (*Path)).GetOwner(); Core->SetFileOwner (*Path, UserId (getuid())); } finally_do_arg2 (FilesystemPath, *Path, UserId, origDeviceOwner, { if (finally_arg2.SystemId != (uid_t) -1) Core->SetFileOwner (finally_arg, finally_arg2); }); #endif wxBusyCursor busy; ChangePasswordThreadRoutine routine(Path, Gui->GetPreferences().DefaultMountOptions.PreserveTimestamps, CurrentPasswordPanel->GetPassword(), CurrentPasswordPanel->GetVolumePim(), CurrentPasswordPanel->GetPkcs5Kdf(), CurrentPasswordPanel->GetKeyfiles(), newPassword, newPim, newKeyfiles, NewPasswordPanel->GetPkcs5Kdf(), NewPasswordPanel->GetHeaderWipeCount(), Gui->GetPreferences().EMVSupportEnabled); Gui->ExecuteWaitThreadRoutine (this, &routine); + masterKeyVulnerable = routine.m_masterKeyVulnerable; } switch (DialogMode) { case Mode::ChangePasswordAndKeyfiles: Gui->ShowInfo ("PASSWORD_CHANGED"); break; case Mode::ChangeKeyfiles: case Mode::RemoveAllKeyfiles: Gui->ShowInfo ("KEYFILE_CHANGED"); break; case Mode::ChangePkcs5Prf: Gui->ShowInfo ("PKCS5_PRF_CHANGED"); break; default: throw ParameterIncorrect (SRC_POS); } + if (masterKeyVulnerable) + Gui->ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + EndModal (wxID_OK); } catch (UnportablePassword &e) { Gui->ShowError (e); NewPasswordPanel->SetFocusToPasswordTextCtrl(); } catch (PasswordException &e) { Gui->ShowWarning (e); CurrentPasswordPanel->SetFocusToPasswordTextCtrl(); } catch (exception &e) { Gui->ShowError (e); } } void ChangePasswordDialog::OnPasswordPanelUpdate () { bool ok = true; try { bool passwordEmpty = CurrentPasswordPanel->GetPassword()->IsEmpty(); bool keyfilesEmpty = !CurrentPasswordPanel->GetKeyfiles() || CurrentPasswordPanel->GetKeyfiles()->empty(); if (passwordEmpty && keyfilesEmpty) ok = false; diff --git a/src/Main/Forms/EncryptionTestDialog.cpp b/src/Main/Forms/EncryptionTestDialog.cpp index 17184a0e..af3f9833 100644 --- a/src/Main/Forms/EncryptionTestDialog.cpp +++ b/src/Main/Forms/EncryptionTestDialog.cpp @@ -1,44 +1,47 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "Volume/EncryptionTest.h" #include "Main/GraphicUserInterface.h" #include "EncryptionTestDialog.h" namespace VeraCrypt { EncryptionTestDialog::EncryptionTestDialog (wxWindow* parent) : EncryptionTestDialogBase (parent) { EncryptionAlgorithms = EncryptionAlgorithm::GetAvailableAlgorithms(); foreach (shared_ptr <EncryptionAlgorithm> ea, EncryptionAlgorithms) { if (!ea->IsDeprecated()) EncryptionAlgorithmChoice->Append (ea->GetName(true), ea.get()); } EncryptionAlgorithmChoice->Select (0); Reset(); Fit(); Layout(); Center(); } void EncryptionTestDialog::EncryptOrDecrypt (bool encrypt) { try { bool xts = XtsModeCheckBox->IsChecked(); @@ -67,112 +70,117 @@ namespace VeraCrypt throw_err (LangString["TEST_INCORRECT_SECONDARY_KEY_SIZE"]); uint64 dataUnitNumber; size_t blockNumber; try { dataUnitNumber = StringConverter::ToUInt64 (wstring (DataUnitNumberTextCtrl->GetValue())); } catch (...) { DataUnitNumberTextCtrl->SetFocus(); throw StringConversionFailed (SRC_POS); } try { blockNumber = StringConverter::ToUInt32 (wstring (BlockNumberTextCtrl->GetValue())); if (blockNumber > 31) { blockNumber = 31; BlockNumberTextCtrl->SetValue (L"31"); } } catch (...) { BlockNumberTextCtrl->SetFocus(); throw StringConversionFailed (SRC_POS); } + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> xts (new EncryptionModeWolfCryptXTS); + ea->SetKeyXTS (secondaryKey); + #else shared_ptr <EncryptionMode> xts (new EncryptionModeXTS); - xts->SetKey (secondaryKey); + #endif + xts->SetKey (secondaryKey); ea->SetMode (xts); Buffer sector (ENCRYPTION_DATA_UNIT_SIZE); BufferPtr block = sector.GetRange (blockNumber * ea->GetMaxBlockSize(), ea->GetMaxBlockSize()); block.CopyFrom (data); if (encrypt) ea->EncryptSectors (sector, dataUnitNumber, 1, sector.Size()); else ea->DecryptSectors (sector, dataUnitNumber, 1, sector.Size()); data.CopyFrom (block); } else { if (encrypt) ea->GetCiphers().front()->EncryptBlock (data); else ea->GetCiphers().front()->DecryptBlock (data); } SetTextCtrlData (encrypt ? CipherTextTextCtrl : PlainTextTextCtrl, data); } catch (exception &e) { Gui->ShowError (e); } } shared_ptr <EncryptionAlgorithm> EncryptionTestDialog::GetSelectedEncryptionAlgorithm () const { return Gui->GetSelectedData <EncryptionAlgorithm> (EncryptionAlgorithmChoice)->GetNew(); } void EncryptionTestDialog::GetTextCtrlData (wxTextCtrl *textCtrl, Buffer &buffer) const { - vector <byte> data; + vector <uint8> data; string dataStr = StringConverter::ToSingle (wstring (textCtrl->GetValue())); for (size_t i = 0; i < dataStr.size() / 2; ++i) { unsigned int dataByte; if (sscanf (dataStr.substr (i * 2, 2).c_str(), "%x", &dataByte) != 1) { textCtrl->SetFocus(); throw StringConversionFailed (SRC_POS); } - data.push_back ((byte) dataByte); + data.push_back ((uint8) dataByte); } if (data.empty()) return; buffer.CopyFrom (ConstBufferPtr (&data.front(), data.size())); } void EncryptionTestDialog::OnAutoTestAllButtonClick (wxCommandEvent& event) { try { { wxBusyCursor busy; EncryptionTest::TestAll(); } Gui->ShowInfo ("TESTS_PASSED"); } catch (Exception &e) { Gui->ShowError (e); Gui->ShowError ("TESTS_FAILED"); } } void EncryptionTestDialog::OnEncryptionAlgorithmSelected () { shared_ptr <EncryptionAlgorithm> ea = GetSelectedEncryptionAlgorithm(); diff --git a/src/Main/Forms/Forms.cpp b/src/Main/Forms/Forms.cpp index d2e7bf68..9ffad555 100644 --- a/src/Main/Forms/Forms.cpp +++ b/src/Main/Forms/Forms.cpp @@ -103,60 +103,64 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t ToolsMenu->AppendSeparator(); BackupVolumeHeadersMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_BACKUP_VOL_HEADER") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( BackupVolumeHeadersMenuItem ); RestoreVolumeHeaderMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_RESTORE_VOL_HEADER") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( RestoreVolumeHeaderMenuItem ); ToolsMenu->AppendSeparator(); wxMenuItem* CreateKeyfileMenuItem; CreateKeyfileMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_KEYFILE_GENERATOR") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( CreateKeyfileMenuItem ); wxMenuItem* ManageSecurityTokenKeyfilesMenuItem; ManageSecurityTokenKeyfilesMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_MANAGE_TOKEN_KEYFILES") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( ManageSecurityTokenKeyfilesMenuItem ); wxMenuItem* CloseAllSecurityTokenSessionsMenuItem; CloseAllSecurityTokenSessionsMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_CLOSE_ALL_TOKEN_SESSIONS") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( CloseAllSecurityTokenSessionsMenuItem ); ToolsMenu->AppendSeparator(); WipeCachedPasswordsMenuItem = new wxMenuItem( ToolsMenu, wxID_ANY, wxString( _("IDM_WIPE_CACHE") ) , wxEmptyString, wxITEM_NORMAL ); ToolsMenu->Append( WipeCachedPasswordsMenuItem ); MainMenuBar->Append( ToolsMenu, _("MENU_TOOLS") ); SettingsMenu = new wxMenu(); + wxMenuItem* LanguageMenuItem; + LanguageMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_LANGUAGE") ) , wxEmptyString, wxITEM_NORMAL ); + SettingsMenu->Append( LanguageMenuItem ); + HotkeysMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_HOTKEY_SETTINGS") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( HotkeysMenuItem ); wxMenuItem* DefaultKeyfilesMenuItem; DefaultKeyfilesMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_DEFAULT_KEYFILES") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( DefaultKeyfilesMenuItem ); wxMenuItem* DefaultMountParametersMenuItem; DefaultMountParametersMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_DEFAULT_MOUNT_PARAMETERS") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( DefaultMountParametersMenuItem ); wxMenuItem* SecurityTokenPreferencesMenuItem; SecurityTokenPreferencesMenuItem = new wxMenuItem( SettingsMenu, wxID_ANY, wxString( _("IDM_TOKEN_PREFERENCES") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( SecurityTokenPreferencesMenuItem ); SettingsMenu->AppendSeparator(); PreferencesMenuItem = new wxMenuItem( SettingsMenu, wxID_PREFERENCES, wxString( _("IDM_PREFERENCES") ) , wxEmptyString, wxITEM_NORMAL ); SettingsMenu->Append( PreferencesMenuItem ); MainMenuBar->Append( SettingsMenu, _("MENU_SETTINGS") ); HelpMenu = new wxMenu(); wxMenuItem* UserGuideMenuItem; UserGuideMenuItem = new wxMenuItem( HelpMenu, wxID_HELP, wxString( _("IDM_HELP") ) , wxEmptyString, wxITEM_NORMAL ); HelpMenu->Append( UserGuideMenuItem ); wxMenuItem* OnlineHelpMenuItem; OnlineHelpMenuItem = new wxMenuItem( HelpMenu, wxID_ANY, wxString( _("IDM_ONLINE_HELP") ) , wxEmptyString, wxITEM_NORMAL ); HelpMenu->Append( OnlineHelpMenuItem ); @@ -407,98 +411,113 @@ MainFrameBase::MainFrameBase( wxWindow* parent, wxWindowID id, const wxString& t bSizer1->Fit( this ); this->Centre( wxBOTH ); // Connect Events this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( MainFrameBase::OnActivate ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrameBase::OnClose ) ); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnCreateVolumeButtonClick ), this, CreateNewVolumeMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnMountVolumeMenuItemSelected ), this, MountVolumeMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnMountAllDevicesButtonClick ), this, AutoMountDevicesMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDismountVolumeMenuItemSelected ), this, DismountVolumeMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDismountAllButtonClick ), this, DismountAllMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnChangePasswordMenuItemSelected ), this, ChangePasswordMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnChangePkcs5PrfMenuItemSelected ), this, ChangePkcs5PrfMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnChangeKeyfilesMenuItemSelected ), this, ChangeKeyfilesMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnRemoveKeyfilesMenuItemSelected ), this, RemoveKeyfilesMenuItem->GetId()); VolumesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnVolumePropertiesButtonClick ), this, VolumePropertiesMenuItem->GetId()); FavoritesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnAddToFavoritesMenuItemSelected ), this, AddToFavoritesMenuItem->GetId()); FavoritesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnAddAllMountedToFavoritesMenuItemSelected ), this, AddAllMountedToFavoritesMenuItem->GetId()); FavoritesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnOrganizeFavoritesMenuItemSelected ), this, OrganizeFavoritesMenuItem->GetId()); FavoritesMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnMountAllFavoritesMenuItemSelected ), this, MountAllFavoritesMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnBenchmarkMenuItemSelected ), this, BenchmarkMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnEncryptionTestMenuItemSelected ), this, EncryptionTestMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnCreateVolumeButtonClick ), this, VolumeCreationWizardMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnBackupVolumeHeadersMenuItemSelected ), this, BackupVolumeHeadersMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnRestoreVolumeHeaderMenuItemSelected ), this, RestoreVolumeHeaderMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnCreateKeyfileMenuItemSelected ), this, CreateKeyfileMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnManageSecurityTokenKeyfilesMenuItemSelected ), this, ManageSecurityTokenKeyfilesMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnCloseAllSecurityTokenSessionsMenuItemSelected ), this, CloseAllSecurityTokenSessionsMenuItem->GetId()); ToolsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnWipeCacheButtonClick ), this, WipeCachedPasswordsMenuItem->GetId()); + SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnLanguageMenuItemSelected ), this, LanguageMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnHotkeysMenuItemSelected ), this, HotkeysMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDefaultKeyfilesMenuItemSelected ), this, DefaultKeyfilesMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDefaultMountParametersMenuItemSelected ), this, DefaultMountParametersMenuItem->GetId()); SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnSecurityTokenPreferencesMenuItemSelected ), this, SecurityTokenPreferencesMenuItem->GetId()); +#ifdef TC_MACOSX + this->Connect( PreferencesMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnPreferencesMenuItemSelected ) ); + this->Connect( UserGuideMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnUserGuideMenuItemSelected ) ); +#else SettingsMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnPreferencesMenuItemSelected ), this, PreferencesMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnUserGuideMenuItemSelected ), this, UserGuideMenuItem->GetId()); +#endif HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnOnlineHelpMenuItemSelected ), this, OnlineHelpMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnBeginnersTutorialMenuItemSelected ), this, BeginnersTutorialMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnFaqMenuItemSelected ), this, FaqMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnWebsiteMenuItemSelected ), this, WebsiteMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDownloadsMenuItemSelected ), this, DownloadsMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnNewsMenuItemSelected ), this, NewsMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnVersionHistoryMenuItemSelected ), this, VersionHistoryMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnDonateMenuItemSelected ), this, DonateMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnContactMenuItemSelected ), this, ContactMenuItem->GetId()); HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnLegalNoticesMenuItemSelected ), this, LegalNoticesMenuItem->GetId()); +#ifdef TC_MACOSX + this->Connect( AboutMenuItem->GetId(), wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnAboutMenuItemSelected ) ); +#else HelpMenu->Bind(wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnAboutMenuItemSelected ), this, AboutMenuItem->GetId()); +#endif SlotListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( MainFrameBase::OnListItemActivated ), NULL, this ); SlotListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( MainFrameBase::OnListItemDeselected ), NULL, this ); SlotListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( MainFrameBase::OnListItemRightClick ), NULL, this ); SlotListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFrameBase::OnListItemSelected ), NULL, this ); CreateVolumeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnCreateVolumeButtonClick ), NULL, this ); VolumePropertiesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumePropertiesButtonClick ), NULL, this ); WipeCacheButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnWipeCacheButtonClick ), NULL, this ); LogoBitmap->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrameBase::OnLogoBitmapClick ), NULL, this ); SelectFileButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnSelectFileButtonClick ), NULL, this ); NoHistoryCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainFrameBase::OnNoHistoryCheckBoxClick ), NULL, this ); VolumeToolsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumeToolsButtonClick ), NULL, this ); SelectDeviceButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnSelectDeviceButtonClick ), NULL, this ); VolumeButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumeButtonClick ), NULL, this ); MountAllDevicesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnMountAllDevicesButtonClick ), NULL, this ); DismountAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnDismountAllButtonClick ), NULL, this ); ExitButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnExitButtonClick ), NULL, this ); } MainFrameBase::~MainFrameBase() { // Disconnect Events +#ifdef TC_MACOSX + this->Disconnect( wxID_PREFERENCES, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnPreferencesMenuItemSelected ) ); + this->Disconnect( wxID_HELP, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnUserGuideMenuItemSelected ) ); + this->Disconnect( wxID_ABOUT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrameBase::OnAboutMenuItemSelected ) ); +#endif this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( MainFrameBase::OnActivate ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( MainFrameBase::OnClose ) ); SlotListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( MainFrameBase::OnListItemActivated ), NULL, this ); SlotListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( MainFrameBase::OnListItemDeselected ), NULL, this ); SlotListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK, wxListEventHandler( MainFrameBase::OnListItemRightClick ), NULL, this ); SlotListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( MainFrameBase::OnListItemSelected ), NULL, this ); CreateVolumeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnCreateVolumeButtonClick ), NULL, this ); VolumePropertiesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumePropertiesButtonClick ), NULL, this ); WipeCacheButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnWipeCacheButtonClick ), NULL, this ); LogoBitmap->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( MainFrameBase::OnLogoBitmapClick ), NULL, this ); SelectFileButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnSelectFileButtonClick ), NULL, this ); NoHistoryCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( MainFrameBase::OnNoHistoryCheckBoxClick ), NULL, this ); VolumeToolsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumeToolsButtonClick ), NULL, this ); SelectDeviceButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnSelectDeviceButtonClick ), NULL, this ); VolumeButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnVolumeButtonClick ), NULL, this ); MountAllDevicesButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnMountAllDevicesButtonClick ), NULL, this ); DismountAllButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnDismountAllButtonClick ), NULL, this ); ExitButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( MainFrameBase::OnExitButtonClick ), NULL, this ); } WizardFrameBase::WizardFrameBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( 800,500 ), wxDefaultSize ); MainSizer = new wxBoxSizer( wxVERTICAL ); MainPanel = new wxPanel( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); wxBoxSizer* bSizer63; bSizer63 = new wxBoxSizer( wxVERTICAL ); @@ -2209,121 +2228,186 @@ PreferencesDialogBase::PreferencesDialogBase( wxWindow* parent, wxWindowID id, c sbSizer23->Add( fgSizer4, 1, wxALIGN_RIGHT, 5 ); sbSizer21->Add( sbSizer23, 0, wxEXPAND|wxALL, 5 ); wxStaticBoxSizer* sbSizer24; sbSizer24 = new wxStaticBoxSizer( new wxStaticBox( sbSizer21->GetStaticBox(), wxID_ANY, _("IDT_FORMAT_OPTIONS") ), wxVERTICAL ); BeepAfterHotkeyMountDismountCheckBox = new wxCheckBox( sbSizer24->GetStaticBox(), wxID_ANY, _("LINUX_SOUND_NOTIFICATION"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer24->Add( BeepAfterHotkeyMountDismountCheckBox, 0, wxALL, 5 ); DisplayMessageAfterHotkeyDismountCheckBox = new wxCheckBox( sbSizer24->GetStaticBox(), wxID_ANY, _("LINUX_CONFIRM_AFTER_DISMOUNT"), wxDefaultPosition, wxDefaultSize, 0 ); sbSizer24->Add( DisplayMessageAfterHotkeyDismountCheckBox, 0, wxALL, 5 ); sbSizer21->Add( sbSizer24, 0, wxEXPAND|wxALL, 5 ); bSizer38->Add( sbSizer21, 1, wxEXPAND|wxALL, 5 ); bSizer51->Add( bSizer38, 1, wxEXPAND|wxALL, 5 ); HotkeysPage->SetSizer( bSizer51 ); HotkeysPage->Layout(); bSizer51->Fit( HotkeysPage ); PreferencesNotebook->AddPage( HotkeysPage, _("LINUX_HOTKEYS"), false ); + LanguagesPage = new wxPanel( PreferencesNotebook, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL ); + wxBoxSizer* bSizer170; + bSizer170 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer171; + bSizer171 = new wxBoxSizer( wxVERTICAL ); + + wxBoxSizer* bSizer173; + bSizer173 = new wxBoxSizer( wxVERTICAL ); + + wxStaticBoxSizer* sbSizer49; + sbSizer49 = new wxStaticBoxSizer( new wxStaticBox( LanguagesPage, wxID_ANY, _("LINUX_LANGUAGE") ), wxVERTICAL ); + + wxBoxSizer* bSizer174; + bSizer174 = new wxBoxSizer( wxHORIZONTAL ); + + m_staticText73 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("IDT_ACTIVE_LANG_PACK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText73->Wrap( -1 ); + bSizer174->Add( m_staticText73, 0, wxLEFT|wxTOP, 5 ); + + m_staticText74 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("CURRENT_LANGUAGE_PACK"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText74->Wrap( -1 ); + bSizer174->Add( m_staticText74, 0, wxLEFT|wxRIGHT|wxTOP, 5 ); + + + sbSizer49->Add( bSizer174, 0, wxBOTTOM, 5 ); + + wxWrapSizer* wSizer1; + wSizer1 = new wxWrapSizer( wxHORIZONTAL, wxWRAPSIZER_DEFAULT_FLAGS ); + + m_staticText72 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("IDT_LANGPACK_AUTHORS"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText72->Wrap( -1 ); + wSizer1->Add( m_staticText72, 0, wxBOTTOM|wxLEFT, 5 ); + + m_staticText71 = new wxStaticText( sbSizer49->GetStaticBox(), wxID_ANY, _("LANGUAGE_TRANSLATORS"), wxDefaultPosition, wxDefaultSize, 0 ); + m_staticText71->Wrap( -1 ); + wSizer1->Add( m_staticText71, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT, 5 ); + + + sbSizer49->Add( wSizer1, 0, 0, 5 ); + + LanguageListBox = new wxListBox( sbSizer49->GetStaticBox(), wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_SINGLE|wxLB_SORT ); + sbSizer49->Add( LanguageListBox, 1, wxEXPAND|wxLEFT|wxRIGHT|wxTOP, 5 ); + + SysDefaultLangButton = new wxButton( sbSizer49->GetStaticBox(), wxID_ANY, _("LINUX_SELECT_SYS_DEFAULT_LANG"), wxDefaultPosition, wxDefaultSize, 0 ); + sbSizer49->Add( SysDefaultLangButton, 0, wxALIGN_BOTTOM|wxALL|wxEXPAND, 5 ); + + + bSizer173->Add( sbSizer49, 1, wxALL|wxEXPAND, 5 ); + + + bSizer171->Add( bSizer173, 1, wxEXPAND, 5 ); + + + bSizer170->Add( bSizer171, 1, wxALL|wxEXPAND, 5 ); + + + LanguagesPage->SetSizer( bSizer170 ); + LanguagesPage->Layout(); + bSizer170->Fit( LanguagesPage ); + PreferencesNotebook->AddPage( LanguagesPage, _("LINUX_LANGUAGE"), false ); bSizer178->Add( PreferencesNotebook, 1, wxEXPAND | wxALL, 5 ); wxBoxSizer* bSizer182; bSizer182 = new wxBoxSizer( wxHORIZONTAL ); bSizer182->Add( 0, 0, 1, wxEXPAND, 5 ); OKButton = new wxButton( this, wxID_OK, _("IDOK"), wxDefaultPosition, wxDefaultSize, 0 ); OKButton->SetDefault(); bSizer182->Add( OKButton, 0, wxALL, 5 ); CancelButton = new wxButton( this, wxID_CANCEL, _("IDCANCEL"), wxDefaultPosition, wxDefaultSize, 0 ); bSizer182->Add( CancelButton, 0, wxALL, 5 ); bSizer178->Add( bSizer182, 0, wxALL|wxEXPAND, 5 ); bSizer32->Add( bSizer178, 1, wxEXPAND, 5 ); this->SetSizer( bSizer32 ); this->Layout(); bSizer32->Fit( this ); // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PreferencesDialogBase::OnClose ) ); + PreferencesNotebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( PreferencesDialogBase::OnPageChanged ), NULL, this ); DismountOnScreenSaverCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnScreenSaverCheckBoxClick ), NULL, this ); DismountOnPowerSavingCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnPowerSavingCheckBoxClick ), NULL, this ); ForceAutoDismountCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnForceAutoDismountCheckBoxClick ), NULL, this ); PreserveTimestampsCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnPreserveTimestampsCheckBoxClick ), NULL, this ); BackgroundTaskEnabledCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnBackgroundTaskEnabledCheckBoxClick ), NULL, this ); NoKernelCryptoCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnNoKernelCryptoCheckBoxClick ), NULL, this ); NoHardwareCryptoCheckBox->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnNoHardwareCryptoCheckBoxClick ), NULL, this ); SelectPkcs11ModuleButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSelectPkcs11ModuleButtonClick ), NULL, this ); HotkeyListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemDeselected ), NULL, this ); HotkeyListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemSelected ), NULL, this ); AssignHotkeyButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnAssignHotkeyButtonClick ), NULL, this ); RemoveHotkeyButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnRemoveHotkeyButtonClick ), NULL, this ); + SysDefaultLangButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSysDefaultLangButtonClick ), NULL, this ); OKButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnOKButtonClick ), NULL, this ); } PreferencesDialogBase::~PreferencesDialogBase() { // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( PreferencesDialogBase::OnClose ) ); + PreferencesNotebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( PreferencesDialogBase::OnPageChanged ), NULL, this ); DismountOnScreenSaverCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnScreenSaverCheckBoxClick ), NULL, this ); DismountOnPowerSavingCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnDismountOnPowerSavingCheckBoxClick ), NULL, this ); ForceAutoDismountCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnForceAutoDismountCheckBoxClick ), NULL, this ); PreserveTimestampsCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnPreserveTimestampsCheckBoxClick ), NULL, this ); BackgroundTaskEnabledCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnBackgroundTaskEnabledCheckBoxClick ), NULL, this ); NoKernelCryptoCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnNoKernelCryptoCheckBoxClick ), NULL, this ); NoHardwareCryptoCheckBox->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnNoHardwareCryptoCheckBoxClick ), NULL, this ); SelectPkcs11ModuleButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSelectPkcs11ModuleButtonClick ), NULL, this ); HotkeyListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemDeselected ), NULL, this ); HotkeyListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( PreferencesDialogBase::OnHotkeyListItemSelected ), NULL, this ); AssignHotkeyButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnAssignHotkeyButtonClick ), NULL, this ); RemoveHotkeyButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnRemoveHotkeyButtonClick ), NULL, this ); + SysDefaultLangButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnSysDefaultLangButtonClick ), NULL, this ); OKButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( PreferencesDialogBase::OnOKButtonClick ), NULL, this ); } RandomPoolEnrichmentDialogBase::RandomPoolEnrichmentDialogBase( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style ) { this->SetSizeHints( wxDefaultSize, wxDefaultSize ); MainSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer144; bSizer144 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer145; bSizer145 = new wxBoxSizer( wxHORIZONTAL ); bSizer145->Add( 0, 0, 1, wxEXPAND, 5 ); wxStaticText* m_staticText49; m_staticText49 = new wxStaticText( this, wxID_ANY, _("IDT_PRF"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticText49->Wrap( -1 ); bSizer145->Add( m_staticText49, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); wxArrayString HashChoiceChoices; HashChoice = new wxChoice( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, HashChoiceChoices, 0 ); HashChoice->SetSelection( 0 ); bSizer145->Add( HashChoice, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); @@ -2674,73 +2758,73 @@ InfoWizardPageBase::InfoWizardPageBase( wxWindow* parent, wxWindowID id, const w this->SetSizer( bSizer71 ); this->Layout(); bSizer71->Fit( this ); } InfoWizardPageBase::~InfoWizardPageBase() { } KeyfilesPanelBase::KeyfilesPanelBase( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name ) : wxPanel( parent, id, pos, size, style, name ) { this->SetMinSize( wxSize( 500,300 ) ); wxBoxSizer* bSizer19; bSizer19 = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bSizer20; bSizer20 = new wxBoxSizer( wxHORIZONTAL ); wxBoxSizer* bSizer21; bSizer21 = new wxBoxSizer( wxVERTICAL ); KeyfilesListCtrl = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_SORT_HEADER|wxLC_REPORT|wxBORDER_SUNKEN ); bSizer21->Add( KeyfilesListCtrl, 1, wxEXPAND|wxALL, 5 ); wxBoxSizer* bSizer137; bSizer137 = new wxBoxSizer( wxHORIZONTAL ); AddFilesButton = new wxButton( this, wxID_ANY, _("IDC_KEYADD"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddFilesButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddFilesButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); AddDirectoryButton = new wxButton( this, wxID_ANY, _("IDC_ADD_KEYFILE_PATH"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddDirectoryButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddDirectoryButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); AddSecurityTokenSignatureButton = new wxButton( this, wxID_ANY, _("IDC_TOKEN_FILES_ADD"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( AddSecurityTokenSignatureButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( AddSecurityTokenSignatureButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); RemoveButton = new wxButton( this, wxID_ANY, _("IDC_KEYREMOVE"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( RemoveButton, 0, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 5 ); + bSizer137->Add( RemoveButton, 0, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 5 ); RemoveAllButton = new wxButton( this, wxID_ANY, _("IDC_KEYREMOVEALL"), wxDefaultPosition, wxDefaultSize, 0 ); - bSizer137->Add( RemoveAllButton, 0, wxEXPAND|wxALL, 5 ); + bSizer137->Add( RemoveAllButton, 0, wxALL|wxEXPAND, 5 ); bSizer21->Add( bSizer137, 0, wxEXPAND, 5 ); bSizer20->Add( bSizer21, 1, wxEXPAND, 5 ); bSizer19->Add( bSizer20, 1, wxEXPAND, 5 ); this->SetSizer( bSizer19 ); this->Layout(); bSizer19->Fit( this ); // Connect Events KeyfilesListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( KeyfilesPanelBase::OnListItemDeselected ), NULL, this ); KeyfilesListCtrl->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( KeyfilesPanelBase::OnListItemSelected ), NULL, this ); KeyfilesListCtrl->Connect( wxEVT_SIZE, wxSizeEventHandler( KeyfilesPanelBase::OnListSizeChanged ), NULL, this ); AddFilesButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( KeyfilesPanelBase::OnAddFilesButtonClick ), NULL, this ); AddDirectoryButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( KeyfilesPanelBase::OnAddDirectoryButtonClick ), NULL, this ); AddSecurityTokenSignatureButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( KeyfilesPanelBase::OnAddSecurityTokenSignatureButtonClick ), NULL, this ); RemoveButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( KeyfilesPanelBase::OnRemoveButtonClick ), NULL, this ); RemoveAllButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( KeyfilesPanelBase::OnRemoveAllButtonClick ), NULL, this ); } KeyfilesPanelBase::~KeyfilesPanelBase() { // Disconnect Events KeyfilesListCtrl->Disconnect( wxEVT_COMMAND_LIST_ITEM_DESELECTED, wxListEventHandler( KeyfilesPanelBase::OnListItemDeselected ), NULL, this ); diff --git a/src/Main/Forms/Forms.h b/src/Main/Forms/Forms.h index 96a03c79..70a8c230 100644 --- a/src/Main/Forms/Forms.h +++ b/src/Main/Forms/Forms.h @@ -11,60 +11,62 @@ #include <wx/xrc/xmlres.h> #include <wx/intl.h> #include "WizardPage.h" #include <wx/string.h> #include <wx/bitmap.h> #include <wx/image.h> #include <wx/icon.h> #include <wx/menu.h> #include <wx/gdicmn.h> #include <wx/font.h> #include <wx/colour.h> #include <wx/settings.h> #include <wx/listctrl.h> #include <wx/sizer.h> #include <wx/statbox.h> #include <wx/button.h> #include <wx/statbmp.h> #include <wx/combobox.h> #include <wx/checkbox.h> #include <wx/gbsizer.h> #include <wx/panel.h> #include <wx/frame.h> #include <wx/stattext.h> #include <wx/hyperlink.h> #include <wx/statline.h> #include <wx/textctrl.h> #include <wx/dialog.h> #include <wx/choice.h> #include <wx/gauge.h> #include <wx/spinctrl.h> +#include <wx/wrapsizer.h> +#include <wx/listbox.h> #include <wx/notebook.h> #include "international.h" /////////////////////////////////////////////////////////////////////////// namespace VeraCrypt { /////////////////////////////////////////////////////////////////////////////// /// Class MainFrameBase /////////////////////////////////////////////////////////////////////////////// class MainFrameBase : public wxFrame { private: protected: wxMenuBar* MainMenuBar; wxMenu* VolumesMenu; wxMenuItem* MountVolumeMenuItem; wxMenuItem* DismountVolumeMenuItem; wxMenuItem* DismountAllMenuItem; wxMenuItem* VolumePropertiesMenuItem; wxMenu* FavoritesMenu; wxMenuItem* AddToFavoritesMenuItem; wxMenuItem* AddAllMountedToFavoritesMenuItem; wxMenu* ToolsMenu; wxMenuItem* BackupVolumeHeadersMenuItem; wxMenuItem* RestoreVolumeHeaderMenuItem; wxMenuItem* WipeCachedPasswordsMenuItem; wxMenu* SettingsMenu; @@ -89,60 +91,61 @@ namespace VeraCrypt wxButton* VolumeButton; wxButton* MountAllDevicesButton; wxButton* DismountAllButton; wxButton* ExitButton; // Virtual event handlers, override them in your derived class virtual void OnActivate( wxActivateEvent& event ) { event.Skip(); } virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnCreateVolumeButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnMountVolumeMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnMountAllDevicesButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDismountVolumeMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDismountAllButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnChangePasswordMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnChangePkcs5PrfMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnChangeKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnRemoveKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnVolumePropertiesButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddToFavoritesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnAddAllMountedToFavoritesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnOrganizeFavoritesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnMountAllFavoritesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnBenchmarkMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnEncryptionTestMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnBackupVolumeHeadersMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnRestoreVolumeHeaderMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnCreateKeyfileMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnManageSecurityTokenKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnCloseAllSecurityTokenSessionsMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnWipeCacheButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnLanguageMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnHotkeysMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDefaultKeyfilesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDefaultMountParametersMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnSecurityTokenPreferencesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnPreferencesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnUserGuideMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnOnlineHelpMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnBeginnersTutorialMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnFaqMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnWebsiteMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDownloadsMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnNewsMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnVersionHistoryMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnDonateMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnContactMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnLegalNoticesMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnAboutMenuItemSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnListItemActivated( wxListEvent& event ) { event.Skip(); } virtual void OnListItemDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnListItemRightClick( wxListEvent& event ) { event.Skip(); } virtual void OnListItemSelected( wxListEvent& event ) { event.Skip(); } virtual void OnLogoBitmapClick( wxMouseEvent& event ) { event.Skip(); } virtual void OnSelectFileButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnNoHistoryCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnVolumeToolsButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnSelectDeviceButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnVolumeButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnExitButtonClick( wxCommandEvent& event ) { event.Skip(); } @@ -586,85 +589,94 @@ namespace VeraCrypt wxCheckBox* BackgroundTaskMenuDismountItemsEnabledCheckBox; wxPanel* SystemIntegrationPage; wxStaticBoxSizer* LogOnSizer; wxCheckBox* StartOnLogonCheckBox; wxCheckBox* MountFavoritesOnLogonCheckBox; wxCheckBox* MountDevicesOnLogonCheckBox; wxStaticBoxSizer* ExplorerSizer; wxCheckBox* OpenExplorerWindowAfterMountCheckBox; wxCheckBox* CloseExplorerWindowsOnDismountCheckBox; wxStaticBoxSizer* KernelServicesSizer; wxCheckBox* NoKernelCryptoCheckBox; wxPanel* PerformanceOptionsPage; wxStaticText* AesHwCpuSupportedStaticText; wxCheckBox* NoHardwareCryptoCheckBox; wxBoxSizer* DefaultKeyfilesSizer; wxCheckBox* UseKeyfilesCheckBox; wxTextCtrl* Pkcs11ModulePathTextCtrl; wxButton* SelectPkcs11ModuleButton; wxCheckBox* CloseSecurityTokenSessionsAfterMountCheckBox; wxCheckBox* EMVSupportEnabledCheckBox; wxListCtrl* HotkeyListCtrl; wxTextCtrl* HotkeyTextCtrl; wxButton* AssignHotkeyButton; wxCheckBox* HotkeyControlCheckBox; wxCheckBox* HotkeyShiftCheckBox; wxCheckBox* HotkeyAltCheckBox; wxCheckBox* HotkeyWinCheckBox; wxButton* RemoveHotkeyButton; wxCheckBox* BeepAfterHotkeyMountDismountCheckBox; wxCheckBox* DisplayMessageAfterHotkeyDismountCheckBox; + wxStaticText* m_staticText73; + wxStaticText* m_staticText74; + wxStaticText* m_staticText72; + wxStaticText* m_staticText71; + wxButton* SysDefaultLangButton; wxButton* OKButton; wxButton* CancelButton; // Virtual event handlers, override them in your derived class virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } + virtual void OnPageChanged( wxNotebookEvent& event ) { event.Skip(); } virtual void OnDismountOnScreenSaverCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnDismountOnPowerSavingCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnForceAutoDismountCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnPreserveTimestampsCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnBackgroundTaskEnabledCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnNoKernelCryptoCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnNoHardwareCryptoCheckBoxClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnSelectPkcs11ModuleButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnHotkeyListItemDeselected( wxListEvent& event ) { event.Skip(); } virtual void OnHotkeyListItemSelected( wxListEvent& event ) { event.Skip(); } virtual void OnAssignHotkeyButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnRemoveHotkeyButtonClick( wxCommandEvent& event ) { event.Skip(); } + virtual void OnSysDefaultLangButtonClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOKButtonClick( wxCommandEvent& event ) { event.Skip(); } public: wxPanel* DefaultMountOptionsPage; wxPanel* DefaultKeyfilesPage; wxPanel* SecurityTokensPage; wxPanel* HotkeysPage; + wxPanel* LanguagesPage; + wxListBox* LanguageListBox; PreferencesDialogBase( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("IDD_PREFERENCES_DLG"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( -1,-1 ), long style = wxDEFAULT_DIALOG_STYLE ); ~PreferencesDialogBase(); }; /////////////////////////////////////////////////////////////////////////////// /// Class RandomPoolEnrichmentDialogBase /////////////////////////////////////////////////////////////////////////////// class RandomPoolEnrichmentDialogBase : public wxDialog { private: protected: wxBoxSizer* MainSizer; wxChoice* HashChoice; wxStaticText* RandomPoolStaticText; wxCheckBox* ShowRandomPoolCheckBox; wxGauge* CollectedEntropy; wxStaticText* MouseStaticText; wxButton* ContinueButton; // Virtual event handlers, override them in your derived class virtual void OnMouseMotion( wxMouseEvent& event ) { event.Skip(); } virtual void OnHashSelected( wxCommandEvent& event ) { event.Skip(); } virtual void OnShowRandomPoolCheckBoxClicked( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/src/Main/Forms/KeyfileGeneratorDialog.cpp b/src/Main/Forms/KeyfileGeneratorDialog.cpp index 2d729ccf..85443f45 100644 --- a/src/Main/Forms/KeyfileGeneratorDialog.cpp +++ b/src/Main/Forms/KeyfileGeneratorDialog.cpp @@ -137,66 +137,66 @@ namespace VeraCrypt wxString msg = wxString::Format(LangString["KEYFILE_ALREADY_EXISTS"], keyfileName.GetFullPath()); if (!Gui->AskYesNo (msg, false, true)) return; } { FilePath keyfilePath((const wchar_t*) keyfileName.GetFullPath().c_str()); File keyfile; keyfile.Open (keyfilePath, File::CreateWrite); keyfile.Write (keyfileBuffer); } } Gui->ShowInfo ("KEYFILE_CREATED"); } catch (exception &e) { Gui->ShowError (e); } } void KeyfileGeneratorDialog::OnHashSelected (wxCommandEvent& event) { RandomNumberGenerator::SetHash (Gui->GetSelectedData <Hash> (HashChoice)->GetNew()); } void KeyfileGeneratorDialog::OnMouseMotion (wxMouseEvent& event) { event.Skip(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event))); long coord = event.GetX(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); coord = event.GetY(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); if (ShowRandomPoolCheckBox->IsChecked()) ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); else HideBytes (RandomPoolStaticText, 24); /* conservative estimate: 1 mouse move event brings 1 bit of entropy * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848 */ ScopeLock lock (AccessMutex); if (MouseEventsCounter < (RNG_POOL_SIZE * 8)) CollectedEntropy->SetValue (++MouseEventsCounter); } void KeyfileGeneratorDialog::OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event) { if (!event.IsChecked()) HideBytes (RandomPoolStaticText, 24); } void KeyfileGeneratorDialog::OnRandomSizeCheckBoxClicked (wxCommandEvent& event) { if (!event.IsChecked()) KeyfilesSize->Enable(); else KeyfilesSize->Disable(); } void KeyfileGeneratorDialog::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer, bool appendDots) { diff --git a/src/Main/Forms/MainFrame.cpp b/src/Main/Forms/MainFrame.cpp index de1c99a4..77f371d8 100644 --- a/src/Main/Forms/MainFrame.cpp +++ b/src/Main/Forms/MainFrame.cpp @@ -57,60 +57,61 @@ namespace VeraCrypt wxBusyCursor busy; SetName (Application::GetName()); SetTitle (Application::GetName()); SetIcon (Resources::GetVeraCryptIcon()); #if defined(TC_UNIX) && !defined(TC_MACOSX) try { string fifoPath = GetShowRequestFifoPath(); remove (fifoPath.c_str()); throw_sys_if (mkfifo (fifoPath.c_str(), S_IRUSR | S_IWUSR) == -1); ShowRequestFifo = open (fifoPath.c_str(), O_RDONLY | O_NONBLOCK); throw_sys_if (ShowRequestFifo == -1); } catch (...) { #ifdef DEBUG throw; #endif } #endif InitControls(); InitPreferences(); InitTaskBarIcon(); InitEvents(); InitMessageFilter(); + InitWindowPrivacy(); if (!GetPreferences().SecurityTokenModule.IsEmpty() && !SecurityToken::IsInitialized()) { try { Gui->InitSecurityTokenLibrary(); } catch (exception &e) { Gui->ShowError (e); } } Connect( wxID_EXIT, wxEVT_COMMAND_MENU_SELECTED, wxCommandEventHandler( MainFrame::OnQuit ) ); Connect( wxID_ANY, wxEVT_COMMAND_UPDATE_VOLUME_LIST, wxCommandEventHandler( MainFrame::OnUpdateVolumeList ) ); Connect( wxID_ANY, wxEVT_COMMAND_PREF_UPDATED, wxCommandEventHandler( MainFrame::OnPreferencesUpdated ) ); Connect( wxID_ANY, wxEVT_COMMAND_OPEN_VOLUME_REQUEST, wxCommandEventHandler( MainFrame::OnOpenVolumeSystemRequest ) ); #ifdef TC_MACOSX Connect( wxID_ANY, wxEVT_MOVE, wxMoveEventHandler( MainFrame::OnMoveHandler ) ); #endif } MainFrame::~MainFrame () { #if defined(TC_UNIX) && !defined(TC_MACOSX) if (ShowRequestFifo != -1) { try { @@ -443,60 +444,66 @@ namespace VeraCrypt PDEV_BROADCAST_HDR hdr = (PDEV_BROADCAST_HDR) lParam; if (wParam == DBT_DEVICEREMOVECOMPLETE && hdr->dbch_devicetype == DBT_DEVTYP_VOLUME) { PDEV_BROADCAST_VOLUME vol = (PDEV_BROADCAST_VOLUME) lParam; for (wchar_t driveNo = 0; driveNo < 26; ++driveNo) { if (vol->dbcv_unitmask & (1 << driveNo)) frame->OnDeviceChange (wstring (StringFormatter (L"{0}:\\", wchar_t (L'A' + driveNo)))); } } else { frame->OnDeviceChange (); } } return CallWindowProc (MainFrameWndProc, hwnd, message, wParam, lParam); } #endif void MainFrame::InitMessageFilter () { #ifdef TC_WINDOWS HWND mainFrameHwnd = static_cast <HWND> (GetHandle()); MainFrameWndProc = (WNDPROC) GetWindowLongPtr (mainFrameHwnd, GWL_WNDPROC); SetWindowLongPtr (mainFrameHwnd, GWL_WNDPROC, (LONG_PTR) MainFrameWndProcFilter); #endif } + + void MainFrame::InitWindowPrivacy () + { + Gui->SetContentProtection(!CmdLine->ArgAllowScreencapture); + } + void MainFrame::InitPreferences () { try { LoadPreferences(); VolumeSlotNumber lastSelectedSlotNumber = GetPreferences().LastSelectedSlotNumber; if (Core->IsSlotNumberValid (lastSelectedSlotNumber)) { long slotIndex = SlotNumberToItemIndex (lastSelectedSlotNumber); if (slotIndex >= 0) { SlotListCtrl->SetItemState (slotIndex, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED); SlotListCtrl->EnsureVisible (slotIndex); } } LoadFavoriteVolumes(); VolumeHistory::Load(); if (VolumePathComboBox->GetValue().empty() && !VolumeHistory::Get().empty()) SetVolumePath (VolumeHistory::Get().front()); } catch (exception &e) { Gui->ShowError (e); Gui->ShowError (LangString["LINUX_ERROR_LOADING_CONFIG"] + wstring (Application::GetConfigFilePath (L""))); } } @@ -1041,60 +1048,71 @@ namespace VeraCrypt } break; case Hotkey::Id::ShowHideApplication: Gui->SetBackgroundMode (!Gui->IsInBackgroundMode()); break; case Hotkey::Id::WipeCache: WipeCache(); Gui->ShowInfo ("PASSWORD_CACHE_WIPED"); break; default: assert (false); break; } #endif // TC_WINDOWS } void MainFrame::OnHotkeysMenuItemSelected (wxCommandEvent& event) { #ifdef TC_MACOSX if (Gui->IsInBackgroundMode()) Gui->SetBackgroundMode (false); #endif PreferencesDialog dialog (this); dialog.SelectPage (dialog.HotkeysPage); dialog.ShowModal(); } + void MainFrame::OnLanguageMenuItemSelected (wxCommandEvent& event) + { +#ifdef TC_MACOSX + if (Gui->IsInBackgroundMode()) + Gui->SetBackgroundMode (false); +#endif + PreferencesDialog dialog (this); + dialog.SelectPage (dialog.LanguagesPage); + dialog.ShowModal(); + } + void MainFrame::OnLegalNoticesMenuItemSelected (wxCommandEvent& event) { #ifdef TC_MACOSX if (Gui->IsInBackgroundMode()) Gui->SetBackgroundMode (false); #endif LegalNoticesDialog dialog (this); dialog.ShowModal(); } void MainFrame::OnListChanged () { OnListItemSelectionChanged(); UpdateControls(); } void MainFrame::OnListItemActivated (wxListEvent& event) { if (IsMountedSlotSelected()) OpenSelectedVolume(); else MountVolume(); } void MainFrame::OnListItemDeleted (long itemIndex) { if (SelectedItemIndex > itemIndex) --SelectedItemIndex; } @@ -1399,61 +1417,61 @@ namespace VeraCrypt static bool previousState = false; if (running && !previousState) { previousState = true; Gui->OnAutoDismountAllEvent(); } else { previousState = running; } } #endif } } if (Gui->IsInBackgroundMode()) { if (!GetPreferences().BackgroundTaskEnabled) { Close (true); } else if (MountedVolumes.empty() && (GetPreferences().CloseBackgroundTaskOnNoVolumes || Core->IsInPortableMode())) { Close (true); } } #if defined(TC_UNIX) && !defined(TC_MACOSX) try { - byte buf[128]; + uint8 buf[128]; if (read (ShowRequestFifo, buf, sizeof (buf)) > 0 && Gui->IsInBackgroundMode()) Gui->SetBackgroundMode (false); } catch (...) { #ifdef DEBUG throw; #endif } #endif } catch (exception &e) { Gui->ShowError (e); } } void MainFrame::OnVolumeButtonClick (wxCommandEvent& event) { if (IsMountedSlotSelected()) DismountVolume(); else MountVolume(); } void MainFrame::OnVolumePropertiesButtonClick (wxCommandEvent& event) { shared_ptr <VolumeInfo> selectedVolume = GetSelectedVolume(); if (selectedVolume) { diff --git a/src/Main/Forms/MainFrame.h b/src/Main/Forms/MainFrame.h index 5372adbb..ed1c44f7 100644 --- a/src/Main/Forms/MainFrame.h +++ b/src/Main/Forms/MainFrame.h @@ -57,104 +57,106 @@ namespace VeraCrypt #endif protected: enum { ColumnSlot = 0, ColumnPath, ColumnSize, #ifdef TC_WINDOWS ColumnEA, #else ColumnMountPoint, #endif ColumnType }; void AddToFavorites (const VolumeInfoList &volumes); bool CanExit () const; void ChangePassword (ChangePasswordDialog::Mode::Enum mode = ChangePasswordDialog::Mode::ChangePasswordAndKeyfiles); void CheckFilesystem (bool repair = false); bool CheckVolumePathNotEmpty () const; void DismountVolume (shared_ptr <VolumeInfo> volume = shared_ptr <VolumeInfo> ()); const UserPreferences &GetPreferences () const { return Gui->GetPreferences(); } shared_ptr <VolumeInfo> GetSelectedVolume () const; shared_ptr <VolumePath> GetSelectedVolumePath () const { return make_shared <VolumePath> (wstring (VolumePathComboBox->GetValue())); } void InitControls (); void InitEvents (); void InitMessageFilter (); void InitPreferences (); void InitTaskBarIcon (); + void InitWindowPrivacy(); bool IsFreeSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); } bool IsMountedSlotSelected () const { return SlotListCtrl->GetSelectedItemCount() == 1 && !Gui->GetListCtrlSubItemText (SlotListCtrl, SelectedItemIndex, ColumnPath).empty(); } void LoadFavoriteVolumes (); void LoadPreferences (); void MountAllDevices (); void MountVolume (); void OnAboutMenuItemSelected (wxCommandEvent& event); void OnQuit(wxCommandEvent& event) { Close(true); } void OnActivate (wxActivateEvent& event); void OnAddAllMountedToFavoritesMenuItemSelected (wxCommandEvent& event); void OnAddToFavoritesMenuItemSelected (wxCommandEvent& event); void OnBackupVolumeHeadersMenuItemSelected (wxCommandEvent& event); void OnBeginnersTutorialMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"tutorial"); } void OnBenchmarkMenuItemSelected (wxCommandEvent& event); void OnChangeKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangeKeyfiles); } void OnChangePasswordMenuItemSelected (wxCommandEvent& event) { ChangePassword (); } void OnChangePkcs5PrfMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::ChangePkcs5Prf); } void OnCheckFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (); } void OnClearSlotSelectionMenuItemSelected (wxCommandEvent& event); void OnClose (wxCloseEvent& event); void OnCloseAllSecurityTokenSessionsMenuItemSelected (wxCommandEvent& event); void OnDonateMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"donate"); } void OnContactMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"contact"); } void OnCreateKeyfileMenuItemSelected (wxCommandEvent& event) { #ifdef TC_MACOSX if (Gui->IsInBackgroundMode()) Gui->SetBackgroundMode (false); #endif Gui->CreateKeyfile(); } void OnCreateVolumeButtonClick (wxCommandEvent& event); void OnDefaultKeyfilesMenuItemSelected (wxCommandEvent& event); void OnDefaultMountParametersMenuItemSelected( wxCommandEvent& event ); void OnDismountAllButtonClick (wxCommandEvent& event); void OnDismountVolumeMenuItemSelected (wxCommandEvent& event) { DismountVolume(); } void OnDownloadsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"downloads"); } void OnEncryptionTestMenuItemSelected (wxCommandEvent& event); void OnExitButtonClick (wxCommandEvent& event); void OnFavoriteVolumeMenuItemSelected (wxCommandEvent& event); void OnFaqMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"faq"); } void OnHiddenVolumeProtectionTriggered (shared_ptr <VolumeInfo> protectedVolume); void OnHotkey (wxKeyEvent& event); void OnHotkeysMenuItemSelected (wxCommandEvent& event); + void OnLanguageMenuItemSelected (wxCommandEvent& event); void OnLegalNoticesMenuItemSelected (wxCommandEvent& event); void OnListChanged (); void OnListItemActivated (wxListEvent& event); void OnListItemDeleted (long itemIndex); void OnListItemDeselected (wxListEvent& event); void OnListItemInserted (long itemIndex); void OnListItemRightClick (wxListEvent& event); void OnListItemSelected (wxListEvent& event); void OnListItemSelectionChanged (); void OnLogoBitmapClick (wxMouseEvent &event) { wxCommandEvent ev; OnAboutMenuItemSelected (ev); } void OnManageSecurityTokenKeyfilesMenuItemSelected (wxCommandEvent& event); void OnMountAllDevicesButtonClick (wxCommandEvent& event); void OnMountAllFavoritesMenuItemSelected (wxCommandEvent& event); void OnMountVolumeMenuItemSelected (wxCommandEvent& event) { MountVolume(); } void OnNewsMenuItemSelected (wxCommandEvent& event) { Gui->OpenHomepageLink (this, L"news"); } void OnNoHistoryCheckBoxClick (wxCommandEvent& event); void OnOnlineHelpMenuItemSelected (wxCommandEvent& event) { Gui->OpenOnlineHelp (this); } void OnOpenVolumeMenuItemSelected (wxCommandEvent& event) { OpenSelectedVolume(); } void OnOpenVolumeSystemRequest (wxCommandEvent& event); void OnOpenVolumeSystemRequestEvent (EventArgs &args); void OnOrganizeFavoritesMenuItemSelected (wxCommandEvent& event); void OnPreferencesMenuItemSelected (wxCommandEvent& event); void OnPreferencesUpdated (wxCommandEvent& event); void OnPreferencesUpdatedEvent (EventArgs &args) { wxQueueEvent (this, new wxCommandEvent( wxEVT_COMMAND_PREF_UPDATED,0)); } void OnRemoveKeyfilesMenuItemSelected (wxCommandEvent& event) { ChangePassword (ChangePasswordDialog::Mode::RemoveAllKeyfiles); } void OnRepairFilesystemMenuItemSelected( wxCommandEvent& event ) { CheckFilesystem (true); } void OnRestoreVolumeHeaderMenuItemSelected (wxCommandEvent& event); void OnSecurityTokenPreferencesMenuItemSelected (wxCommandEvent& event); void OnSelectDeviceAndMountMenuItemSelected (wxCommandEvent& event); void OnSelectDeviceButtonClick (wxCommandEvent& event); diff --git a/src/Main/Forms/PreferencesDialog.cpp b/src/Main/Forms/PreferencesDialog.cpp index 91204389..4e7644b6 100644 --- a/src/Main/Forms/PreferencesDialog.cpp +++ b/src/Main/Forms/PreferencesDialog.cpp @@ -1,100 +1,184 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include <wx/dynlib.h> #ifdef TC_WINDOWS #include <wx/msw/registry.h> +#else +#include <wx/dir.h> +#include <wx/arrstr.h> #endif #include "Common/SecurityToken.h" #include "Main/Main.h" #include "Main/Application.h" #include "Main/GraphicUserInterface.h" #include "Volume/Cipher.h" #include "PreferencesDialog.h" namespace VeraCrypt { PreferencesDialog::PreferencesDialog (wxWindow* parent) : PreferencesDialogBase (parent), LastVirtualKeyPressed (0), Preferences (Gui->GetPreferences()), RestoreValidatorBell (false) { #define TC_CHECK_BOX_VALIDATOR(NAME) (TC_JOIN(NAME,CheckBox))->SetValidator (wxGenericValidator (&Preferences.NAME)); #ifdef TC_MACOSX PreferencesNotebook->SetMinSize (wxSize (Gui->GetCharWidth (PreferencesNotebook) * 108, -1)); #endif // Security TC_CHECK_BOX_VALIDATOR (DismountOnLogOff); TC_CHECK_BOX_VALIDATOR (DismountOnPowerSaving); TC_CHECK_BOX_VALIDATOR (DismountOnScreenSaver); TC_CHECK_BOX_VALIDATOR (DismountOnInactivity); DismountOnInactivitySpinCtrl->SetValidator (wxGenericValidator (&Preferences.MaxVolumeIdleTime)); TC_CHECK_BOX_VALIDATOR (ForceAutoDismount); PreserveTimestampsCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.PreserveTimestamps)); TC_CHECK_BOX_VALIDATOR (WipeCacheOnAutoDismount); TC_CHECK_BOX_VALIDATOR (WipeCacheOnClose); // Mount options CachePasswordsCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.CachePassword)); MountReadOnlyCheckBox->SetValue (Preferences.DefaultMountOptions.Protection == VolumeProtection::ReadOnly); MountRemovableCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.Removable)); FilesystemOptionsTextCtrl->SetValue (Preferences.DefaultMountOptions.FilesystemOptions); int index, prfInitialIndex = 0; Pkcs5PrfChoice->Append (LangString["AUTODETECTION"]); foreach_ref (const Pkcs5Kdf &kdf, Pkcs5Kdf::GetAvailableAlgorithms()) { index = Pkcs5PrfChoice->Append (kdf.GetName()); if (Preferences.DefaultMountOptions.Kdf && (Preferences.DefaultMountOptions.Kdf->GetName() == kdf.GetName()) ) { prfInitialIndex = index; } } Pkcs5PrfChoice->Select (prfInitialIndex); + // Language for non-Windows +#ifndef TC_WINDOWS +#if defined (TC_MACOSX) + wxDir languagesFolder(StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/"); +#else + wxDir languagesFolder("/usr/share/veracrypt/languages/"); +#endif + wxArrayString langArray; + LanguageListBox->Append("System default"); + LanguageListBox->Append("English"); + + langEntries = { + {"system", L"System default"}, + {"ar", L"العربية"}, + {"be", L"БеларуÑкаÑ"}, + {"bg", L"БългарÑки"}, + {"ca", L"Català "}, + {"co", L"Corsu"}, + {"cs", L"ÄŒeÅ¡tina"}, + {"da", L"Dansk"}, + {"de", L"Deutsch"}, + {"el", L"Ελληνικά"}, + {"en", L"English"}, + {"es", L"Español"}, + {"et", L"Eesti"}, + {"eu", L"Euskara"}, + {"fa", L"Ùارسي"}, + {"fi", L"Suomi"}, + {"fr", L"Français"}, + {"he", L"עברית"}, + {"hu", L"Magyar"}, + {"id", L"Bahasa Indonesia"}, + {"it", L"Italiano"}, + {"ja", L"日本語"}, + {"ka", L"ქáƒáƒ თული"}, + {"ko", L"í•œêµì–´"}, + {"lv", L"LatvieÅ¡u"}, + {"nb", L"Norsk BokmÃ¥l"}, + {"nl", L"Nederlands"}, + {"nn", L"Norsk Nynorsk"}, + {"pl", L"Polski"}, + {"ro", L"Română"}, + {"ru", L"РуÑÑкий"}, + {"pt-br", L"Português-Brasil"}, + {"sk", L"SlovenÄina"}, + {"sl", L"SlovenÅ¡Äina"}, + {"sv", L"Svenska"}, + {"th", L"ภาษาไทย"}, + {"tr", L"Türkçe"}, + {"uk", L"УкраїнÑька"}, + {"uz", L"Ўзбекча"}, + {"vi", L"Tiếng Việt"}, + {"zh-cn", L"简体ä¸æ–‡"}, + {"zh-hk", L"ç¹é«”ä¸æ–‡(香港)"}, + {"zh-tw", L"ç¹é«”ä¸æ–‡"} + }; + + if (wxDir::Exists(languagesFolder.GetName())) { + size_t langCount; + langCount = wxDir::GetAllFiles(languagesFolder.GetName(), &langArray, "*.xml", wxDIR_FILES); + for (size_t i = 0; i < langCount; ++i) { + wxFileName filename(langArray[i]); + + // Get the name part of the file (without extension) + wxString basename = filename.GetName(); + + // Check if the basename matches the pattern "Language.langId" + if (basename.StartsWith("Language.")) { + wxString langId = basename.AfterFirst('.'); + + // Verify if the language ID exists in langEntries map + wxString langNative = langEntries[langId]; + if (!langNative.empty()) { + LanguageListBox->Append(langNative); + } + } + } + } +#endif + + // Keyfiles TC_CHECK_BOX_VALIDATOR (UseKeyfiles); DefaultKeyfilesPanel = new KeyfilesPanel (DefaultKeyfilesPage, make_shared <KeyfileList> (Preferences.DefaultKeyfiles)); DefaultKeyfilesSizer->Add (DefaultKeyfilesPanel, 1, wxALL | wxEXPAND); DefaultKeyfilesSizer->Layout(); TC_CHECK_BOX_VALIDATOR (BackgroundTaskEnabled); TC_CHECK_BOX_VALIDATOR (CloseBackgroundTaskOnNoVolumes); CloseBackgroundTaskOnNoVolumesCheckBox->Show (!Core->IsInPortableMode()); TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuDismountItemsEnabled); TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuMountItemsEnabled); TC_CHECK_BOX_VALIDATOR (BackgroundTaskMenuOpenItemsEnabled); // Encryption AesHwCpuSupportedStaticText->SetLabel ( #ifdef TC_AES_HW_CPU (HasAESNI() ? LangString["UISTR_YES"] : LangString["UISTR_NO"])); #else LangString["NOT_APPLICABLE_OR_NOT_AVAILABLE"]); #endif NoHardwareCryptoCheckBox->SetValidator (wxGenericValidator (&Preferences.DefaultMountOptions.NoHardwareCrypto)); // Security tokens Pkcs11ModulePathTextCtrl->SetValue (wstring (Preferences.SecurityTokenModule)); TC_CHECK_BOX_VALIDATOR (CloseSecurityTokenSessionsAfterMount); TC_CHECK_BOX_VALIDATOR (EMVSupportEnabled); // System integration TC_CHECK_BOX_VALIDATOR (StartOnLogon); @@ -211,60 +295,69 @@ namespace VeraCrypt void Notify() { Dialog->OnTimer(); } PreferencesDialog *Dialog; }; mTimer.reset (dynamic_cast <wxTimer *> (new Timer (this))); mTimer->Start (25); #endif } PreferencesDialog::~PreferencesDialog () { #ifdef TC_WINDOWS if (RestoreValidatorBell) wxTextValidator::SuppressBellOnError (false); #endif } void PreferencesDialog::SelectPage (wxPanel *page) { for (size_t pageIndex = 0; pageIndex < PreferencesNotebook->GetPageCount(); pageIndex++) { if (PreferencesNotebook->GetPage (pageIndex) == page) PreferencesNotebook->ChangeSelection (pageIndex); } } + void PreferencesDialog::OnSysDefaultLangButtonClick (wxCommandEvent& event) + { + // SetStringSelection()'s Assert currently broken in sorted ListBoxes on macOS, workaround: + int itemIndex = LanguageListBox->FindString("System default", true); + if (itemIndex != wxNOT_FOUND) { + LanguageListBox->SetSelection(itemIndex); + } + } + void PreferencesDialog::OnAssignHotkeyButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS foreach (long item, Gui->GetListCtrlSelectedItems (HotkeyListCtrl)) { Hotkey *hotkey = reinterpret_cast <Hotkey *> (HotkeyListCtrl->GetItemData (item)); int mods = 0; mods |= HotkeyShiftCheckBox->IsChecked() ? wxMOD_SHIFT : 0; mods |= HotkeyControlCheckBox->IsChecked() ? wxMOD_CONTROL : 0; mods |= HotkeyAltCheckBox->IsChecked() ? wxMOD_ALT : 0; mods |= HotkeyWinCheckBox->IsChecked() ? wxMOD_WIN : 0; // F1 is help and F12 is reserved for use by the debugger at all times if (mods == 0 && (LastVirtualKeyPressed == VK_F1 || LastVirtualKeyPressed == VK_F12)) { Gui->ShowError ("CANNOT_USE_RESERVED_KEY"); return; } // Test if the hotkey can be registered if (!this->RegisterHotKey (hotkey->Id, mods, LastVirtualKeyPressed)) { Gui->ShowError (SystemException (SRC_POS)); return; } UnregisterHotKey (hotkey->Id); foreach_ref (const Hotkey &h, Preferences.Hotkeys) { @@ -328,93 +421,113 @@ namespace VeraCrypt void PreferencesDialog::OnDismountOnPowerSavingCheckBoxClick (wxCommandEvent& event) { if (event.IsChecked() && !ForceAutoDismountCheckBox->IsChecked()) Gui->ShowWarning ("WARN_PREF_AUTO_DISMOUNT"); } void PreferencesDialog::OnDismountOnScreenSaverCheckBoxClick (wxCommandEvent& event) { if (event.IsChecked() && !ForceAutoDismountCheckBox->IsChecked()) Gui->ShowWarning ("WARN_PREF_AUTO_DISMOUNT"); } void PreferencesDialog::OnForceAutoDismountCheckBoxClick (wxCommandEvent& event) { if (!event.IsChecked()) ForceAutoDismountCheckBox->SetValue (!Gui->AskYesNo (LangString["CONFIRM_NO_FORCED_AUTODISMOUNT"], false, true)); } void PreferencesDialog::OnHotkeyListItemDeselected (wxListEvent& event) { UpdateHotkeyButtons(); } void PreferencesDialog::OnHotkeyListItemSelected (wxListEvent& event) { UpdateHotkeyButtons(); HotkeyTextCtrl->ChangeValue (LangString ["PRESS_A_KEY_TO_ASSIGN"]); AssignHotkeyButton->Enable (false); } + // Fixes an issue where going through PreferencesNotebook tabs would unintentionally select the first entry + // in the LanguageListBox and thus cause a language change on OKButton press. + void PreferencesDialog::OnPageChanged(wxBookCtrlEvent &event) + { + LanguageListBox->DeselectAll(); + } + void PreferencesDialog::OnOKButtonClick (wxCommandEvent& event) { #ifdef TC_WINDOWS HotkeyTextCtrl->SetValidator (wxTextValidator (wxFILTER_NONE)); #endif if (!Validate()) return; shared_ptr <Pkcs5Kdf> selectedKdf; if (Pkcs5PrfChoice->GetSelection () != 0) { try { selectedKdf = Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection ())); } catch (ParameterIncorrect&) { return; } } TransferDataFromWindow(); Preferences.DefaultMountOptions.Protection = MountReadOnlyCheckBox->IsChecked() ? VolumeProtection::ReadOnly : VolumeProtection::None; Preferences.DefaultMountOptions.FilesystemOptions = FilesystemOptionsTextCtrl->GetValue(); Preferences.DefaultKeyfiles = *DefaultKeyfilesPanel->GetKeyfiles(); Preferences.DefaultMountOptions.Kdf = selectedKdf; Preferences.DefaultMountOptions.ProtectionKdf = selectedKdf; bool securityTokenModuleChanged = (Preferences.SecurityTokenModule != wstring (Pkcs11ModulePathTextCtrl->GetValue())); Preferences.SecurityTokenModule = wstring (Pkcs11ModulePathTextCtrl->GetValue()); + if (LanguageListBox->GetSelection() != wxNOT_FOUND) { + wxString langToFind = LanguageListBox->GetString(LanguageListBox->GetSelection()); + for (map<wxString, std::wstring>::const_iterator each = langEntries.begin(); each != langEntries.end(); ++each) { + if (each->second == langToFind) { + Preferences.Language = each->first; +#ifdef DEBUG + cout << "Lang set to: " << each->first << endl; +#endif + } + } + Gui->ShowInfo (LangString["LINUX_RESTART_FOR_LANGUAGE_CHANGE"]); + } + Gui->SetPreferences (Preferences); try { if (securityTokenModuleChanged) { if (Preferences.SecurityTokenModule.IsEmpty()) { if (SecurityToken::IsInitialized()) SecurityToken::CloseLibrary (); } else { Gui->InitSecurityTokenLibrary(); } } } catch (exception &e) { Gui->ShowError (e); } #ifdef TC_WINDOWS // Hotkeys Hotkey::RegisterList (Gui->GetMainFrame(), Preferences.Hotkeys); #endif EndModal (wxID_OK); } diff --git a/src/Main/Forms/PreferencesDialog.h b/src/Main/Forms/PreferencesDialog.h index 0cd1482a..5e7f7e71 100644 --- a/src/Main/Forms/PreferencesDialog.h +++ b/src/Main/Forms/PreferencesDialog.h @@ -13,52 +13,55 @@ #ifndef TC_HEADER_Main_Forms_PreferencesDialog #define TC_HEADER_Main_Forms_PreferencesDialog #include "Forms.h" #include "Main/Main.h" #include "KeyfilesPanel.h" namespace VeraCrypt { class PreferencesDialog : public PreferencesDialogBase { public: PreferencesDialog (wxWindow* parent); ~PreferencesDialog (); void SelectPage (wxPanel *page); protected: void OnAssignHotkeyButtonClick (wxCommandEvent& event); void OnBackgroundTaskEnabledCheckBoxClick (wxCommandEvent& event); void OnCancelButtonClick (wxCommandEvent& event) { EndModal (wxID_CANCEL); } void OnClose (wxCloseEvent& event); void OnDismountOnPowerSavingCheckBoxClick (wxCommandEvent& event); void OnDismountOnScreenSaverCheckBoxClick (wxCommandEvent& event); void OnForceAutoDismountCheckBoxClick (wxCommandEvent& event); void OnHotkeyListItemDeselected (wxListEvent& event); void OnHotkeyListItemSelected (wxListEvent& event); void OnNoHardwareCryptoCheckBoxClick (wxCommandEvent& event); void OnNoKernelCryptoCheckBoxClick (wxCommandEvent& event); void OnOKButtonClick (wxCommandEvent& event); + void OnPageChanged (wxBookCtrlEvent& event); void OnPreserveTimestampsCheckBoxClick (wxCommandEvent& event); void OnRemoveHotkeyButtonClick (wxCommandEvent& event); void OnSelectPkcs11ModuleButtonClick (wxCommandEvent& event); + void OnSysDefaultLangButtonClick (wxCommandEvent& event); void OnTimer (); void UpdateHotkeyButtons(); enum { ColumnHotkeyDescription = 0, ColumnHotkey }; KeyfilesPanel *DefaultKeyfilesPanel; int LastVirtualKeyPressed; unique_ptr <wxTimer> mTimer; UserPreferences Preferences; bool RestoreValidatorBell; HotkeyList UnregisteredHotkeys; + map<wxString, wstring> langEntries; }; } #endif // TC_HEADER_Main_Forms_PreferencesDialog diff --git a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp index e5ef160b..b48d5af6 100644 --- a/src/Main/Forms/RandomPoolEnrichmentDialog.cpp +++ b/src/Main/Forms/RandomPoolEnrichmentDialog.cpp @@ -36,66 +36,66 @@ namespace VeraCrypt HideBytes (RandomPoolStaticText, 24); MouseStaticText->Wrap (Gui->GetCharWidth (MouseStaticText) * 70); CollectedEntropy->SetRange (RNG_POOL_SIZE * 8); MainSizer->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 24)); Layout(); Fit(); Center(); MouseEventsCounter = 0; foreach (wxWindow *c, this->GetChildren()) c->Connect (wxEVT_MOTION, wxMouseEventHandler (RandomPoolEnrichmentDialog::OnMouseMotion), nullptr, this); } RandomPoolEnrichmentDialog::~RandomPoolEnrichmentDialog () { } void RandomPoolEnrichmentDialog::OnHashSelected (wxCommandEvent& event) { RandomNumberGenerator::SetHash (Gui->GetSelectedData <Hash> (HashChoice)->GetNew()); } void RandomPoolEnrichmentDialog::OnMouseMotion (wxMouseEvent& event) { event.Skip(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event))); long coord = event.GetX(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); coord = event.GetY(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); if (ShowRandomPoolCheckBox->IsChecked()) ShowBytes (RandomPoolStaticText, RandomNumberGenerator::PeekPool().GetRange (0, 24)); else HideBytes (RandomPoolStaticText, 24); /* conservative estimate: 1 mouse move event brings 1 bit of entropy * https://security.stackexchange.com/questions/32844/for-how-much-time-should-i-randomly-move-the-mouse-for-generating-encryption-key/32848#32848 */ ScopeLock lock (AccessMutex); if (MouseEventsCounter < (RNG_POOL_SIZE * 8)) CollectedEntropy->SetValue (++MouseEventsCounter); } void RandomPoolEnrichmentDialog::OnShowRandomPoolCheckBoxClicked (wxCommandEvent& event) { if (!event.IsChecked()) HideBytes (RandomPoolStaticText, 24); } void RandomPoolEnrichmentDialog::ShowBytes (wxStaticText *textCtrl, const ConstBufferPtr &buffer) { wxString str; for (size_t i = 0; i < buffer.Size(); ++i) { str += wxString::Format (L"%02X", buffer[i]); } str += L".."; diff --git a/src/Main/Forms/SecurityTokenKeyfilesDialog.cpp b/src/Main/Forms/SecurityTokenKeyfilesDialog.cpp index d78e22fd..bbbeff74 100644 --- a/src/Main/Forms/SecurityTokenKeyfilesDialog.cpp +++ b/src/Main/Forms/SecurityTokenKeyfilesDialog.cpp @@ -28,148 +28,147 @@ namespace VeraCrypt SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenSlotId, LangString["TOKEN_SLOT_ID"], wxLIST_FORMAT_CENTER, 1); colPermilles.push_back (102); SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenLabel, LangString["TOKEN_NAME"], wxLIST_FORMAT_LEFT, 1); colPermilles.push_back (368); SecurityTokenKeyfileListCtrl->InsertColumn (ColumnSecurityTokenKeyfileLabel, LangString["TOKEN_DATA_OBJECT_LABEL"], wxLIST_FORMAT_LEFT, 1); colPermilles.push_back (529); FillSecurityTokenKeyfileListCtrl(); Gui->SetListCtrlWidth (SecurityTokenKeyfileListCtrl, 65); Gui->SetListCtrlHeight (SecurityTokenKeyfileListCtrl, 16); Gui->SetListCtrlColumnWidths (SecurityTokenKeyfileListCtrl, colPermilles); Fit(); Layout(); Center(); DeleteButton->Disable(); ExportButton->Disable(); OKButton->Disable(); OKButton->SetDefault(); } void SecurityTokenKeyfilesDialog::FillSecurityTokenKeyfileListCtrl () { wxBusyCursor busy; SecurityTokenKeyfileListCtrl->DeleteAllItems(); SecurityTokenKeyfileList = Token::GetAvailableKeyfiles(Gui->GetPreferences().EMVSupportEnabled); - size_t i = 0; foreach (const shared_ptr<TokenKeyfile> key, SecurityTokenKeyfileList) { vector <wstring> fields (SecurityTokenKeyfileListCtrl->GetColumnCount()); fields[ColumnSecurityTokenSlotId] = StringConverter::ToWide ((uint64) key->Token->SlotId); fields[ColumnSecurityTokenLabel] = key->Token->Label; fields[ColumnSecurityTokenKeyfileLabel] = key->Id; Gui->AppendToListCtrl (SecurityTokenKeyfileListCtrl, fields, 0, key.get()); } } void SecurityTokenKeyfilesDialog::OnDeleteButtonClick (wxCommandEvent& event) { try { if (!Gui->AskYesNo (LangString["CONFIRM_SEL_FILES_DELETE"])) return; wxBusyCursor busy; foreach (long item, Gui->GetListCtrlSelectedItems (SecurityTokenKeyfileListCtrl)) { SecurityToken::DeleteKeyfile (*reinterpret_cast <SecurityTokenKeyfile *> (SecurityTokenKeyfileListCtrl->GetItemData (item))); } FillSecurityTokenKeyfileListCtrl(); } catch (exception &e) { Gui->ShowError (e); } } void SecurityTokenKeyfilesDialog::OnExportButtonClick (wxCommandEvent& event) { try { foreach (long item, Gui->GetListCtrlSelectedItems (SecurityTokenKeyfileListCtrl)) { TokenKeyfile *keyfile = reinterpret_cast <TokenKeyfile *> (SecurityTokenKeyfileListCtrl->GetItemData (item)); FilePathList files = Gui->SelectFiles (this, wxEmptyString, true); if (!files.empty()) { wxBusyCursor busy; - vector <byte> keyfileData; + vector <uint8> keyfileData; keyfile->GetKeyfileData (keyfileData); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); }); File keyfile; keyfile.Open (*files.front(), File::CreateWrite); keyfile.Write (keyfileDataBuf); } else break; Gui->ShowInfo ("KEYFILE_EXPORTED"); } } catch (exception &e) { Gui->ShowError (e); } } void SecurityTokenKeyfilesDialog::OnImportButtonClick (wxCommandEvent& event) { try { FilePathList keyfilePaths = Gui->SelectFiles (this, LangString["SELECT_KEYFILES"], false); if (keyfilePaths.empty()) return; FilePath keyfilePath = *keyfilePaths.front(); File keyfile; keyfile.Open (keyfilePath, File::OpenRead, File::ShareReadWrite, File::PreserveTimestamps); if (keyfile.Length() > 0) { - vector <byte> keyfileData (keyfile.Length()); + vector <uint8> keyfileData (keyfile.Length()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); keyfile.ReadCompleteBuffer (keyfileDataBuf); finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); }); NewSecurityTokenKeyfileDialog newKeyfileDialog (this, keyfilePath.ToBaseName()); if (newKeyfileDialog.ShowModal() == wxID_OK) { wxBusyCursor busy; SecurityToken::CreateKeyfile (newKeyfileDialog.GetSelectedSlotId(), keyfileData, StringConverter::ToSingle (newKeyfileDialog.GetKeyfileName())); FillSecurityTokenKeyfileListCtrl(); } } else throw InsufficientData (SRC_POS, keyfilePath); } catch (exception &e) { Gui->ShowError (e); } } void SecurityTokenKeyfilesDialog::OnListItemDeselected (wxListEvent& event) { if (SecurityTokenKeyfileListCtrl->GetSelectedItemCount() == 0) { DeleteButton->Disable(); ExportButton->Disable(); diff --git a/src/Main/Forms/TrueCrypt.fbp b/src/Main/Forms/TrueCrypt.fbp index 498b6f83..0b40a99e 100644 --- a/src/Main/Forms/TrueCrypt.fbp +++ b/src/Main/Forms/TrueCrypt.fbp @@ -441,60 +441,74 @@ <object class="separator" expanded="0"> <property name="name">m_separator10</property> <property name="permission">none</property> </object> <object class="wxMenuItem" expanded="0"> <property name="bitmap"></property> <property name="checked">0</property> <property name="enabled">1</property> <property name="help"></property> <property name="id">wxID_ANY</property> <property name="kind">wxITEM_NORMAL</property> <property name="label">IDM_WIPE_CACHE</property> <property name="name">WipeCachedPasswordsMenuItem</property> <property name="permission">protected</property> <property name="shortcut"></property> <property name="unchecked_bitmap"></property> <event name="OnMenuSelection">OnWipeCacheButtonClick</event> </object> </object> <object class="wxMenu" expanded="0"> <property name="label">MENU_SETTINGS</property> <property name="name">SettingsMenu</property> <property name="permission">protected</property> <object class="wxMenuItem" expanded="0"> <property name="bitmap"></property> <property name="checked">0</property> <property name="enabled">1</property> <property name="help"></property> <property name="id">wxID_ANY</property> <property name="kind">wxITEM_NORMAL</property> + <property name="label">IDM_LANGUAGE</property> + <property name="name">LanguageMenuItem</property> + <property name="permission">none</property> + <property name="shortcut"></property> + <property name="unchecked_bitmap"></property> + <event name="OnMenuSelection">OnLanguageMenuItemSelected</event> + </object> + <object class="wxMenuItem" expanded="0"> + <property name="bitmap"></property> + <property name="checked">0</property> + <property name="enabled">1</property> + <property name="help"></property> + <property name="id">wxID_ANY</property> + <property name="kind">wxITEM_NORMAL</property> <property name="label">IDM_HOTKEY_SETTINGS</property> <property name="name">HotkeysMenuItem</property> <property name="permission">protected</property> <property name="shortcut"></property> <property name="unchecked_bitmap"></property> <event name="OnMenuSelection">OnHotkeysMenuItemSelected</event> </object> <object class="wxMenuItem" expanded="0"> <property name="bitmap"></property> <property name="checked">0</property> <property name="enabled">1</property> <property name="help"></property> <property name="id">wxID_ANY</property> <property name="kind">wxITEM_NORMAL</property> <property name="label">IDM_DEFAULT_KEYFILES</property> <property name="name">DefaultKeyfilesMenuItem</property> <property name="permission">none</property> <property name="shortcut"></property> <property name="unchecked_bitmap"></property> <event name="OnMenuSelection">OnDefaultKeyfilesMenuItemSelected</event> </object> <object class="wxMenuItem" expanded="0"> <property name="bitmap"></property> <property name="checked">0</property> <property name="enabled">1</property> <property name="help"></property> <property name="id">wxID_ANY</property> <property name="kind">wxITEM_NORMAL</property> <property name="label">IDM_DEFAULT_MOUNT_PARAMETERS</property> <property name="name">DefaultMountParametersMenuItem</property> @@ -10837,60 +10851,61 @@ <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="max_size"></property> <property name="maximize_button">0</property> <property name="maximum_size"></property> <property name="min_size"></property> <property name="minimize_button">0</property> <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">PreferencesNotebook</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> + <event name="OnNotebookPageChanged">OnPageChanged</event> <object class="notebookpage" expanded="0"> <property name="bitmap"></property> <property name="label">LINUX_PREF_TAB_SECURITY</property> <property name="select">1</property> <object class="wxPanel" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> @@ -14845,60 +14860,563 @@ <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> </object> </object> </object> </object> </object> </object> </object> </object> </object> </object> </object> + <object class="notebookpage" expanded="0"> + <property name="bitmap"></property> + <property name="label">LINUX_LANGUAGE</property> + <property name="select">0</property> + <object class="wxPanel" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">LanguagesPage</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">public</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style">wxTAB_TRAVERSAL</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer170</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer171</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer173</property> + <property name="orient">wxVERTICAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALL|wxEXPAND</property> + <property name="proportion">1</property> + <object class="wxStaticBoxSizer" expanded="0"> + <property name="id">wxID_ANY</property> + <property name="label">LINUX_LANGUAGE</property> + <property name="minimum_size"></property> + <property name="name">sbSizer49</property> + <property name="orient">wxVERTICAL</property> + <property name="parent">1</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxBOTTOM</property> + <property name="proportion">0</property> + <object class="wxBoxSizer" expanded="0"> + <property name="minimum_size"></property> + <property name="name">bSizer174</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxLEFT|wxTOP</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">IDT_ACTIVE_LANG_PACK</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText73</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxLEFT|wxRIGHT|wxTOP</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">CURRENT_LANGUAGE_PACK</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText74</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag"></property> + <property name="proportion">0</property> + <object class="wxWrapSizer" expanded="0"> + <property name="flags">wxWRAPSIZER_DEFAULT_FLAGS</property> + <property name="minimum_size"></property> + <property name="name">wSizer1</property> + <property name="orient">wxHORIZONTAL</property> + <property name="permission">none</property> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxBOTTOM|wxLEFT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">IDT_LANGPACK_AUTHORS</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText72</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxLEFT|wxRIGHT</property> + <property name="proportion">0</property> + <object class="wxStaticText" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">LANGUAGE_TRANSLATORS</property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">m_staticText71</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <property name="wrap">-1</property> + </object> + </object> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxEXPAND|wxLEFT|wxRIGHT|wxTOP</property> + <property name="proportion">1</property> + <object class="wxListBox" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="choices"></property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="default_pane">0</property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size">-1,-1</property> + <property name="moveable">1</property> + <property name="name">LanguageListBox</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">public</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style">wxLB_SINGLE|wxLB_SORT</property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + </object> + </object> + <object class="sizeritem" expanded="0"> + <property name="border">5</property> + <property name="flag">wxALIGN_BOTTOM|wxALL|wxEXPAND</property> + <property name="proportion">0</property> + <object class="wxButton" expanded="0"> + <property name="BottomDockable">1</property> + <property name="LeftDockable">1</property> + <property name="RightDockable">1</property> + <property name="TopDockable">1</property> + <property name="aui_layer"></property> + <property name="aui_name"></property> + <property name="aui_position"></property> + <property name="aui_row"></property> + <property name="auth_needed">0</property> + <property name="best_size"></property> + <property name="bg"></property> + <property name="bitmap"></property> + <property name="caption"></property> + <property name="caption_visible">1</property> + <property name="center_pane">0</property> + <property name="close_button">1</property> + <property name="context_help"></property> + <property name="context_menu">1</property> + <property name="current"></property> + <property name="default">0</property> + <property name="default_pane">0</property> + <property name="disabled"></property> + <property name="dock">Dock</property> + <property name="dock_fixed">0</property> + <property name="docking">Left</property> + <property name="enabled">1</property> + <property name="fg"></property> + <property name="floatable">1</property> + <property name="focus"></property> + <property name="font"></property> + <property name="gripper">0</property> + <property name="hidden">0</property> + <property name="id">wxID_ANY</property> + <property name="label">LINUX_SELECT_SYS_DEFAULT_LANG</property> + <property name="margins"></property> + <property name="markup">0</property> + <property name="max_size"></property> + <property name="maximize_button">0</property> + <property name="maximum_size"></property> + <property name="min_size"></property> + <property name="minimize_button">0</property> + <property name="minimum_size"></property> + <property name="moveable">1</property> + <property name="name">SysDefaultLangButton</property> + <property name="pane_border">1</property> + <property name="pane_position"></property> + <property name="pane_size"></property> + <property name="permission">protected</property> + <property name="pin_button">1</property> + <property name="pos"></property> + <property name="position"></property> + <property name="pressed"></property> + <property name="resize">Resizable</property> + <property name="show">1</property> + <property name="size"></property> + <property name="style"></property> + <property name="subclass">; ; forward_declare</property> + <property name="toolbar_pane">0</property> + <property name="tooltip"></property> + <property name="validator_data_type"></property> + <property name="validator_style">wxFILTER_NONE</property> + <property name="validator_type">wxDefaultValidator</property> + <property name="validator_variable"></property> + <property name="window_extra_style"></property> + <property name="window_name"></property> + <property name="window_style"></property> + <event name="OnButtonClick">OnSysDefaultLangButtonClick</event> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> + </object> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer182</property> <property name="orient">wxHORIZONTAL</property> <property name="permission">none</property> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">1</property> <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> @@ -17243,61 +17761,61 @@ <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style">wxLC_NO_SORT_HEADER|wxLC_REPORT</property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style">wxBORDER_SUNKEN</property> <event name="OnListItemDeselected">OnListItemDeselected</event> <event name="OnListItemSelected">OnListItemSelected</event> <event name="OnSize">OnListSizeChanged</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer137</property> <property name="orient">wxHORIZONTAL</property> <property name="permission">none</property> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="auth_needed">0</property> <property name="best_size"></property> <property name="bg"></property> <property name="bitmap"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="current"></property> <property name="default">0</property> <property name="default_pane">0</property> <property name="disabled"></property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> @@ -17317,61 +17835,61 @@ <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">AddFilesButton</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="position"></property> <property name="pressed"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnButtonClick">OnAddFilesButtonClick</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="auth_needed">0</property> <property name="best_size"></property> <property name="bg"></property> <property name="bitmap"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="current"></property> <property name="default">0</property> <property name="default_pane">0</property> <property name="disabled"></property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> @@ -17391,61 +17909,61 @@ <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">AddDirectoryButton</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="position"></property> <property name="pressed"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnButtonClick">OnAddDirectoryButtonClick</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="auth_needed">0</property> <property name="best_size"></property> <property name="bg"></property> <property name="bitmap"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="current"></property> <property name="default">0</property> <property name="default_pane">0</property> <property name="disabled"></property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> @@ -17465,61 +17983,61 @@ <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">AddSecurityTokenSignatureButton</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="position"></property> <property name="pressed"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnButtonClick">OnAddSecurityTokenSignatureButtonClick</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxTOP|wxBOTTOM|wxLEFT</property> + <property name="flag">wxBOTTOM|wxEXPAND|wxLEFT|wxTOP</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="auth_needed">0</property> <property name="best_size"></property> <property name="bg"></property> <property name="bitmap"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="current"></property> <property name="default">0</property> <property name="default_pane">0</property> <property name="disabled"></property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> @@ -17539,61 +18057,61 @@ <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">RemoveButton</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="position"></property> <property name="pressed"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnButtonClick">OnRemoveButtonClick</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> - <property name="flag">wxEXPAND|wxALL</property> + <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> <object class="wxButton" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="auth_needed">0</property> <property name="best_size"></property> <property name="bg"></property> <property name="bitmap"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="current"></property> <property name="default">0</property> <property name="default_pane">0</property> <property name="disabled"></property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> @@ -22182,163 +22700,163 @@ <property name="wrap">-1</property> </object> </object> </object> </object> </object> </object> <object class="Panel" expanded="0"> <property name="aui_managed">0</property> <property name="aui_manager_style">wxAUI_MGR_DEFAULT</property> <property name="bg"></property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="enabled">1</property> <property name="event_handler">impl_virtual</property> <property name="fg"></property> <property name="font"></property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="maximum_size"></property> <property name="minimum_size"></property> <property name="name">VolumeSizeWizardPageBase</property> <property name="pos"></property> <property name="size">-1,-1</property> <property name="subclass">WizardPage; WizardPage.h</property> <property name="tooltip"></property> <property name="two_step_creation">0</property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style">wxTAB_TRAVERSAL</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer98</property> <property name="orient">wxVERTICAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer99</property> <property name="orient">wxVERTICAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND</property> <property name="proportion">0</property> - <object class="wxBoxSizer" expanded="1"> + <object class="wxBoxSizer" expanded="0"> <property name="minimum_size"></property> <property name="name">bSizer100</property> <property name="orient">wxHORIZONTAL</property> <property name="permission">none</property> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL</property> <property name="proportion">0</property> - <object class="wxTextCtrl" expanded="1"> + <object class="wxTextCtrl" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="max_size"></property> <property name="maximize_button">0</property> <property name="maximum_size"></property> <property name="maxlength">0</property> <property name="min_size"></property> <property name="minimize_button">0</property> <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">VolumeSizeTextCtrl</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="value"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnText">OnVolumeSizeTextChanged</event> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL</property> <property name="proportion">0</property> - <object class="wxChoice" expanded="1"> + <object class="wxChoice" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="choices"></property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="max_size"></property> <property name="maximize_button">0</property> @@ -22347,71 +22865,71 @@ <property name="minimize_button">0</property> <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">VolumeSizePrefixChoice</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="resize">Resizable</property> <property name="selection">0</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnChoice">OnVolumeSizePrefixSelected</event> </object> </object> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> <object class="wxCheckBox" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="checked">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> @@ -22436,132 +22954,132 @@ <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass">; forward_declare</property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="validator_data_type"></property> <property name="validator_style">wxFILTER_NONE</property> <property name="validator_type">wxDefaultValidator</property> <property name="validator_variable"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <event name="OnCheckBox">OnUseAllFreeSpaceCheckBoxClick</event> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxBOTTOM|wxEXPAND|wxTOP</property> <property name="proportion">0</property> <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> - <object class="wxStaticText" expanded="1"> + <object class="wxStaticText" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="label"></property> <property name="markup">0</property> <property name="max_size"></property> <property name="maximize_button">0</property> <property name="maximum_size"></property> <property name="min_size"></property> <property name="minimize_button">0</property> <property name="minimum_size"></property> <property name="moveable">1</property> <property name="name">FreeSpaceStaticText</property> <property name="pane_border">1</property> <property name="pane_position"></property> <property name="pane_size"></property> <property name="permission">protected</property> <property name="pin_button">1</property> <property name="pos"></property> <property name="resize">Resizable</property> <property name="show">1</property> <property name="size"></property> <property name="style"></property> <property name="subclass"></property> <property name="toolbar_pane">0</property> <property name="tooltip"></property> <property name="window_extra_style"></property> <property name="window_name"></property> <property name="window_style"></property> <property name="wrap">-1</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxEXPAND|wxTOP|wxBOTTOM</property> <property name="proportion">0</property> - <object class="spacer" expanded="1"> + <object class="spacer" expanded="0"> <property name="height">0</property> <property name="permission">protected</property> <property name="width">0</property> </object> </object> - <object class="sizeritem" expanded="1"> + <object class="sizeritem" expanded="0"> <property name="border">5</property> <property name="flag">wxALL|wxEXPAND</property> <property name="proportion">0</property> - <object class="wxStaticText" expanded="1"> + <object class="wxStaticText" expanded="0"> <property name="BottomDockable">1</property> <property name="LeftDockable">1</property> <property name="RightDockable">1</property> <property name="TopDockable">1</property> <property name="aui_layer"></property> <property name="aui_name"></property> <property name="aui_position"></property> <property name="aui_row"></property> <property name="best_size"></property> <property name="bg"></property> <property name="caption"></property> <property name="caption_visible">1</property> <property name="center_pane">0</property> <property name="close_button">1</property> <property name="context_help"></property> <property name="context_menu">1</property> <property name="default_pane">0</property> <property name="dock">Dock</property> <property name="dock_fixed">0</property> <property name="docking">Left</property> <property name="enabled">1</property> <property name="fg"></property> <property name="floatable">1</property> <property name="font"></property> <property name="gripper">0</property> <property name="hidden">0</property> <property name="id">wxID_ANY</property> <property name="label"></property> <property name="markup">0</property> <property name="max_size"></property> diff --git a/src/Main/Forms/VolumeCreationWizard.cpp b/src/Main/Forms/VolumeCreationWizard.cpp index 2653ff66..311738ca 100644 --- a/src/Main/Forms/VolumeCreationWizard.cpp +++ b/src/Main/Forms/VolumeCreationWizard.cpp @@ -10,60 +10,73 @@ code distribution packages. */ #include "System.h" #include "Platform/SystemInfo.h" #ifdef TC_UNIX #include <unistd.h> #include <sys/statvfs.h> // header for statvfs #include "Platform/Unix/Process.h" #endif #include "Core/RandomNumberGenerator.h" #include "Core/VolumeCreator.h" #include "Main/Application.h" #include "Main/GraphicUserInterface.h" #include "Main/Resources.h" #include "VolumeCreationWizard.h" #include "EncryptionOptionsWizardPage.h" #include "InfoWizardPage.h" #include "ProgressWizardPage.h" #include "SingleChoiceWizardPage.h" #include "VolumeCreationProgressWizardPage.h" #include "VolumeFormatOptionsWizardPage.h" #include "VolumeLocationWizardPage.h" #include "VolumePasswordWizardPage.h" #include "VolumePimWizardPage.h" #include "VolumeSizeWizardPage.h" #include "WaitDialog.h" namespace VeraCrypt { + class OpenOuterVolumeFunctor : public Functor + { + public: + OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { } + + virtual void operator() () + { + Gui->OpenExplorerWindow (OuterVolumeMountPoint); + } + + DirectoryPath OuterVolumeMountPoint; + }; + #ifdef TC_MACOSX bool VolumeCreationWizard::ProcessEvent(wxEvent& event) { if(GraphicUserInterface::HandlePasswordEntryCustomEvent (event)) return true; else return WizardFrame::ProcessEvent(event); } #endif VolumeCreationWizard::VolumeCreationWizard (wxWindow* parent) : WizardFrame (parent), CrossPlatformSupport (true), DisplayKeyInfo (false), LargeFilesSupport (false), QuickFormatEnabled (false), SelectedFilesystemClusterSize (0), SelectedFilesystemType (VolumeCreationOptions::FilesystemType::FAT), SelectedVolumeHostType (VolumeHostType::File), SelectedVolumeType (VolumeType::Normal), Pim (0), OuterPim (0), SectorSize (0), VolumeSize (0) { RandomNumberGenerator::Start(); SetTitle (LangString["INTRO_TITLE"]); SetImage (Resources::GetVolumeCreationWizardBitmap (Gui->GetCharHeight (this) * 21)); @@ -311,165 +324,153 @@ namespace VeraCrypt SetCancelButtonText (LangString["IDC_EXIT"]); return page; } case Step::OuterVolumeContents: { ClearHistory(); MountOptions mountOptions; mountOptions.Keyfiles = Keyfiles; mountOptions.Password = Password; mountOptions.Pim = Pim; mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath); try { wxBusyCursor busy; Gui->SetActiveFrame (this); MountedOuterVolume = Core->MountVolume (mountOptions); } catch (exception &e) { Gui->SetActiveFrame (this); Gui->ShowError (e); Close(); return new InfoWizardPage (GetPageParent()); } - struct OpenOuterVolumeFunctor : public Functor - { - OpenOuterVolumeFunctor (const DirectoryPath &outerVolumeMountPoint) : OuterVolumeMountPoint (outerVolumeMountPoint) { } - - virtual void operator() () - { - Gui->OpenExplorerWindow (OuterVolumeMountPoint); - } - - DirectoryPath OuterVolumeMountPoint; - }; - InfoWizardPage *page = new InfoWizardPage (GetPageParent(), LangString["LINUX_OPEN_OUTER_VOL"], shared_ptr <Functor> (new OpenOuterVolumeFunctor (MountedOuterVolume->MountPoint))); page->SetPageTitle (LangString["HIDVOL_HOST_FILLING_TITLE"]); page->SetPageText (StringFormatter (LangString["LINUX_OUTER_VOL_IS_MOUNTED"], wstring (MountedOuterVolume->MountPoint))); return page; } case Step::HiddenVolume: { ClearHistory(); OuterVolume = false; LargeFilesSupport = false; Pim = 0; InfoWizardPage *page = new InfoWizardPage (GetPageParent()); page->SetPageTitle (LangString["HIDVOL_PRE_CIPHER_TITLE"]); page->SetPageText (LangString["HIDVOL_PRE_CIPHER_HELP"]); return page; } default: throw ParameterIncorrect (SRC_POS); } } void VolumeCreationWizard::OnAbortButtonClick (EventArgs &args) { AbortRequested = true; } void VolumeCreationWizard::OnMouseMotion (wxMouseEvent& event) { event.Skip(); if (!IsWorkInProgress() && RandomNumberGenerator::IsRunning()) { - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&event), sizeof (event))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&event), sizeof (event))); long coord = event.GetX(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); coord = event.GetY(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&coord), sizeof (coord))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&coord), sizeof (coord))); VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); if (page) { page->IncrementEntropyProgress (); } } } void VolumeCreationWizard::OnProgressTimer () { if (!IsWorkInProgress()) return; if (AbortRequested && !AbortConfirmationPending) { AbortConfirmationPending = true; if (Gui->AskYesNo (LangString ["FORMAT_ABORT"], true)) { if (IsWorkInProgress() && Creator.get() != nullptr) { CreationAborted = true; Creator->Abort(); } } AbortRequested = false; AbortConfirmationPending = false; } VolumeCreator::ProgressInfo progress = Creator->GetProgressInfo(); VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); page->SetProgressValue (progress.SizeDone); if (!progress.CreationInProgress && !AbortConfirmationPending) { SetWorkInProgress (false); OnVolumeCreatorFinished (); } } void VolumeCreationWizard::OnRandomPoolUpdateTimer () { if (!IsWorkInProgress()) { wxLongLong time = wxGetLocalTimeMillis(); - RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <byte *> (&time), sizeof (time))); + RandomNumberGenerator::AddToPool (ConstBufferPtr (reinterpret_cast <uint8 *> (&time), sizeof (time))); } } void VolumeCreationWizard::OnVolumeCreatorFinished () { VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); ProgressTimer.reset(); page->SetProgressState (false); Gui->EndInteractiveBusyState (this); SetWorkInProgress (false); UpdateControls(); try { if (!CreationAborted) { Creator->CheckResult(); #ifdef TC_UNIX // Format non-FAT filesystem const char *fsFormatter = VolumeCreationOptions::FilesystemType::GetFsFormatter (SelectedFilesystemType); if (fsFormatter) { wxBusyCursor busy; MountOptions mountOptions (Gui->GetPreferences().DefaultMountOptions); mountOptions.Path = make_shared <VolumePath> (SelectedVolumePath); @@ -948,61 +949,61 @@ namespace VeraCrypt SingleChoiceWizardPage <bool> *page = dynamic_cast <SingleChoiceWizardPage <bool> *> (GetCurrentPage()); try { CrossPlatformSupport = page->GetSelection(); } catch (NoItemSelected &) { return GetCurrentStep(); } if (forward && CrossPlatformSupport) Gui->ShowWarning (StringFormatter (LangString["LINUX_NOT_FAT_HINT"], SystemInfo::GetPlatformName())); return Step::CreationProgress; } case Step::CreationProgress: { VolumeCreationProgressWizardPage *page = dynamic_cast <VolumeCreationProgressWizardPage *> (GetCurrentPage()); DisplayKeyInfo = page->IsKeyInfoDisplayed(); if (forward) { if (SelectedVolumeType != VolumeType::Hidden || OuterVolume) { if (OuterVolume && VolumeSize > TC_MAX_FAT_SECTOR_COUNT * SectorSize) { uint64 limit = TC_MAX_FAT_SECTOR_COUNT * SectorSize / BYTES_PER_TB; - wstring err = StringFormatter (LangString["LINUX_ERROR_SIZE_HIDDEN_VOL"], limit, limit * 1024); + wstring err = static_cast<wstring>(StringFormatter (LangString["LINUX_ERROR_SIZE_HIDDEN_VOL"], limit, limit * 1024)); if (SectorSize < 4096) { err += LangString["LINUX_MAX_SIZE_HINT"]; #if defined (TC_LINUX) err += LangString["LINUX_DOT_LF"]; #else err += LangString["LINUX_NOT_SUPPORTED"]; #endif } Gui->ShowError (err); return GetCurrentStep(); } if (SelectedVolumePath.IsDevice()) { wxString confirmMsg = LangString["OVERWRITEPROMPT_DEVICE"]; if (!Gui->AskYesNo (wxString::Format (confirmMsg, wxString (LangString["DEVICE"]).c_str(), wstring (SelectedVolumePath).c_str(), L""), false, true)) return GetCurrentStep(); } else if (FilesystemPath (wstring (SelectedVolumePath)).IsFile()) { wxString confirmMsg = LangString["OVERWRITEPROMPT"]; if (!Gui->AskYesNo (wxString::Format (confirmMsg, wstring (SelectedVolumePath).c_str()), false, true)) return GetCurrentStep(); } } diff --git a/src/Main/Forms/VolumePasswordPanel.cpp b/src/Main/Forms/VolumePasswordPanel.cpp index 32b92edc..0555f339 100644 --- a/src/Main/Forms/VolumePasswordPanel.cpp +++ b/src/Main/Forms/VolumePasswordPanel.cpp @@ -145,105 +145,103 @@ namespace VeraCrypt }; if (enableKeyfiles) { SetDropTarget (new FileDropTarget (this)); foreach (wxWindow *c, GetChildren()) c->SetDropTarget (new FileDropTarget (this)); } Layout(); Fit(); } VolumePasswordPanel::~VolumePasswordPanel () { WipeTextCtrl (PasswordTextCtrl); WipeTextCtrl (ConfirmPasswordTextCtrl); } void VolumePasswordPanel::AddKeyfile (shared_ptr <Keyfile> keyfile) { if (!Keyfiles) Keyfiles.reset (new KeyfileList); Keyfiles->push_back (keyfile); UseKeyfilesCheckBox->SetValue (true); } void VolumePasswordPanel::SetPimValidator () { - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + wxTextValidator validator (wxFILTER_DIGITS); VolumePimTextCtrl->SetValidator (validator); } void VolumePasswordPanel::DisplayPassword (bool display, wxTextCtrl **textCtrl, int row) { FreezeScope freeze (this); bool isPim = (*textCtrl == VolumePimTextCtrl); int colspan = isPim? 1 : 2; size_t maxPasswordLength = CmdLine->ArgUseLegacyPassword? VolumePassword::MaxLegacySize : VolumePassword::MaxSize; wxTextCtrl *newTextCtrl = new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, display ? 0 : wxTE_PASSWORD); newTextCtrl->SetMaxLength (isPim? MAX_PIM_DIGITS : maxPasswordLength); newTextCtrl->SetValue ((*textCtrl)->GetValue()); newTextCtrl->SetMinSize ((*textCtrl)->GetSize()); GridBagSizer->Detach ((*textCtrl)); GridBagSizer->Add (newTextCtrl, wxGBPosition (row, 1), wxGBSpan (1, colspan), wxEXPAND|wxBOTTOM, 5); (*textCtrl)->Show (false); WipeTextCtrl (*textCtrl); Fit(); Layout(); newTextCtrl->SetMinSize ((*textCtrl)->GetMinSize()); newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, isPim? wxCommandEventHandler (VolumePasswordPanel::OnPimChanged): wxCommandEventHandler (VolumePasswordPanel::OnTextChanged), nullptr, this); delete *textCtrl; *textCtrl = newTextCtrl; if (isPim) SetPimValidator (); } shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (bool bForceLegacyPassword) const { return GetPassword (PasswordTextCtrl, bForceLegacyPassword); } shared_ptr <VolumePassword> VolumePasswordPanel::GetPassword (wxTextCtrl *textCtrl, bool bLegacyPassword) const { shared_ptr <VolumePassword> password; wchar_t passwordBuf[VolumePassword::MaxSize + 1]; size_t maxPasswordLength = (bLegacyPassword || CmdLine->ArgUseLegacyPassword)? VolumePassword::MaxLegacySize: VolumePassword::MaxSize; - finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); + finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <uint8 *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); #ifdef TC_WINDOWS int len = GetWindowText (static_cast <HWND> (textCtrl->GetHandle()), passwordBuf, VolumePassword::MaxSize + 1); password = ToUTF8Password (passwordBuf, len, maxPasswordLength); #else wxString passwordStr (textCtrl->GetValue()); // A copy of the password is created here by wxWidgets, which cannot be erased for (size_t i = 0; i < passwordStr.size() && i < maxPasswordLength; ++i) { passwordBuf[i] = (wchar_t) passwordStr[i]; passwordStr[i] = L'X'; } password = ToUTF8Password (passwordBuf, passwordStr.size() <= maxPasswordLength ? passwordStr.size() : maxPasswordLength, maxPasswordLength); #endif return password; } shared_ptr <Pkcs5Kdf> VolumePasswordPanel::GetPkcs5Kdf () const { try { int index = Pkcs5PrfChoice->GetSelection (); if ((wxNOT_FOUND == index) || (0 == index)) { // auto-detection return shared_ptr <Pkcs5Kdf> (); } else return Pkcs5Kdf::GetAlgorithm (wstring (Pkcs5PrfChoice->GetStringSelection())); } catch (ParameterIncorrect&) @@ -440,44 +438,45 @@ namespace VeraCrypt VolumePimHelpStaticText->SetForegroundColour(*wxRED); VolumePimHelpStaticText->SetLabel(LangString["PIM_CHANGE_WARNING"]); guiUpdated = true; } if (!pimChanged && VolumePimHelpStaticText->GetForegroundColour() != wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)) { VolumePimHelpStaticText->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); VolumePimHelpStaticText->SetLabel(LangString["IDC_PIM_HELP"]); guiUpdated = true; } if (guiUpdated) { Layout(); Fit(); GetParent()->Layout(); GetParent()->Fit(); } return guiUpdated; } void VolumePasswordPanel::OnUsePimCheckBoxClick( wxCommandEvent& event ) { if (EnablePimEntry) { wxWindow* layoutParent = TopOwnerParent? TopOwnerParent : GetParent(); PimCheckBox->Show (false); VolumePimStaticText->Show (true); VolumePimTextCtrl->Show (true); VolumePimHelpStaticText->Show (true); + VolumePimTextCtrl->SetFocus(); if (DisplayPasswordCheckBox->IsChecked ()) DisplayPassword (true, &VolumePimTextCtrl, 3); else { Layout(); Fit(); } layoutParent->Layout(); layoutParent->Fit(); } } } diff --git a/src/Main/Forms/VolumePimWizardPage.cpp b/src/Main/Forms/VolumePimWizardPage.cpp index c4f7014b..6500affb 100644 --- a/src/Main/Forms/VolumePimWizardPage.cpp +++ b/src/Main/Forms/VolumePimWizardPage.cpp @@ -1,55 +1,56 @@ /* Copyright (c) 2015-2016 Mounir IDRASSI for the VeraCrypt project. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #include "System.h" #include "Main/GraphicUserInterface.h" #include "VolumePimWizardPage.h" namespace VeraCrypt { VolumePimWizardPage::VolumePimWizardPage (wxPanel* parent) : VolumePimWizardPageBase (parent) { + VolumePimTextCtrl->SetMinSize (wxSize (Gui->GetCharWidth (VolumePimTextCtrl) * 15, -1)); SetPimValidator (); } VolumePimWizardPage::~VolumePimWizardPage () { } int VolumePimWizardPage::GetVolumePim () const { if (VolumePimTextCtrl->IsEnabled ()) { wxString pimStr (VolumePimTextCtrl->GetValue()); long pim = 0; if (pimStr.IsEmpty()) return 0; if (((size_t) wxNOT_FOUND == pimStr.find_first_not_of (wxT("0123456789"))) && pimStr.ToLong (&pim) && pim <= MAX_PIM_VALUE) return (int) pim; else return -1; } else return 0; } void VolumePimWizardPage::SetVolumePim (int pim) { if (pim > 0) { @@ -64,63 +65,61 @@ namespace VeraCrypt } bool VolumePimWizardPage::IsValid () { return true; } void VolumePimWizardPage::OnPimChanged (wxCommandEvent& event) { OnPimValueChanged (GetVolumePim ()); } void VolumePimWizardPage::OnPimValueChanged (int pim) { if (pim > 0) { VolumePimHelpStaticText->SetForegroundColour(*wxRED); VolumePimHelpStaticText->SetLabel(LangString["PIM_CHANGE_WARNING"]); } else { VolumePimHelpStaticText->SetForegroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT)); VolumePimHelpStaticText->SetLabel(LangString["IDC_PIM_HELP"]); } Fit(); Layout(); } void VolumePimWizardPage::SetPimValidator () { - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + wxTextValidator validator (wxFILTER_DIGITS); VolumePimTextCtrl->SetValidator (validator); } void VolumePimWizardPage::OnDisplayPimCheckBoxClick( wxCommandEvent& event ) { FreezeScope freeze (this); bool display = event.IsChecked (); wxTextCtrl *newTextCtrl = new wxTextCtrl (this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, display ? 0 : wxTE_PASSWORD); newTextCtrl->SetMaxLength (MAX_PIM_DIGITS); newTextCtrl->SetValue (VolumePimTextCtrl->GetValue()); newTextCtrl->SetMinSize (VolumePimTextCtrl->GetSize()); PimSizer->Replace (VolumePimTextCtrl, newTextCtrl); VolumePimTextCtrl->Show (false); int txtLen = VolumePimTextCtrl->GetLineLength(0); if (txtLen > 0) { VolumePimTextCtrl->SetValue (wxString (L'X', txtLen)); } GetVolumePim (); Fit(); Layout(); newTextCtrl->SetMinSize (VolumePimTextCtrl->GetMinSize()); newTextCtrl->Connect (wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler (VolumePimWizardPage::OnPimChanged), nullptr, this); delete VolumePimTextCtrl; VolumePimTextCtrl = newTextCtrl; diff --git a/src/Main/Forms/VolumeSizeWizardPage.cpp b/src/Main/Forms/VolumeSizeWizardPage.cpp index 83fdd40f..08aa7052 100644 --- a/src/Main/Forms/VolumeSizeWizardPage.cpp +++ b/src/Main/Forms/VolumeSizeWizardPage.cpp @@ -46,63 +46,61 @@ namespace VeraCrypt diskSpace += static_cast<wxLongLong_t>(containerSizeUnsigned.GetValue()); } AvailableDiskSpace = (uint64) diskSpace.GetValue (); } FreeSpaceStaticText->SetFont (Gui->GetDefaultBoldFont (this)); if (!freeSpaceText.empty()) { FreeSpaceStaticText->SetLabel (freeSpaceText); } else { #ifdef TC_WINDOWS wxString drive = wxFileName (wstring (volumePath)).GetVolume(); if (!drive.empty()) { FreeSpaceStaticText->SetLabel (StringFormatter (LangString["LINUX_FREE_SPACE_ON_DRIVE"], drive, Gui->SizeToString (diskSpace.GetValue()))); } else #endif { FreeSpaceStaticText->SetLabel (StringFormatter (LangString["DISK_FREE"], Gui->SizeToString (diskSpace.GetValue()))); } } VolumeSizeTextCtrl->SetMinSize (wxSize (Gui->GetCharWidth (VolumeSizeTextCtrl) * 20, -1)); - wxTextValidator validator (wxFILTER_INCLUDE_CHAR_LIST); // wxFILTER_NUMERIC does not exclude - . , etc. - const wxChar *valArr[] = { L"0", L"1", L"2", L"3", L"4", L"5", L"6", L"7", L"8", L"9" }; - validator.SetIncludes (wxArrayString (array_capacity (valArr), (const wxChar **) &valArr)); + wxTextValidator validator (wxFILTER_DIGITS); VolumeSizeTextCtrl->SetValidator (validator); } uint64 VolumeSizeWizardPage::GetVolumeSize () const { uint64 prefixMult = 1; uint64 val; if (UseAllFreeSpaceCheckBox->IsChecked ()) { val = MaxVolumeSizeValid ? MaxVolumeSize : AvailableDiskSpace; } else { int selection = VolumeSizePrefixChoice->GetSelection(); if (selection == wxNOT_FOUND) return 0; uint64 counter = reinterpret_cast <uint64> (VolumeSizePrefixChoice->GetClientData (selection)); while (counter) { prefixMult *= 1024; counter--; } val = StringConverter::ToUInt64 (wstring(VolumeSizeTextCtrl->GetValue())); } if (val <= 0x7fffFFFFffffFFFFull / prefixMult) { val *= prefixMult; uint32 sectorSizeRem = val % SectorSize; diff --git a/src/Main/Forms/WaitDialog.cpp b/src/Main/Forms/WaitDialog.cpp index d53656f9..102d479a 100644 --- a/src/Main/Forms/WaitDialog.cpp +++ b/src/Main/Forms/WaitDialog.cpp @@ -1,40 +1,43 @@ /* Copyright (c) 2013-2017 IDRIX. All rights reserved. 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. */ #include "System.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "Main/GraphicUserInterface.h" #include "Common/PCSCException.h" #include "Common/SecurityToken.h" #include "WaitDialog.h" namespace VeraCrypt { DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED) DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD) DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_PIN) DEFINE_EVENT_TYPE(wxEVT_COMMAND_WAITDIALOG_SHOW_MSG) wxThread::ExitCode WaitThread::Entry() { m_pRoutine->Execute(); wxQueueEvent (m_pHandler, new wxCommandEvent( wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED,0)); return (wxThread::ExitCode)0; // success } void WaitDialog::ThrowException(Exception* ex) { #define VC_CONVERT_EXCEPTION(NAME) if (dynamic_cast<NAME*> (ex)) throw (NAME&) *ex; VC_CONVERT_EXCEPTION (PasswordIncorrect); VC_CONVERT_EXCEPTION (PasswordKeyfilesIncorrect); VC_CONVERT_EXCEPTION (PasswordOrKeyboardLayoutIncorrect); VC_CONVERT_EXCEPTION (PasswordOrMountOptionsIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordIncorrect); VC_CONVERT_EXCEPTION (ProtectionPasswordKeyfilesIncorrect); VC_CONVERT_EXCEPTION (PasswordEmpty); VC_CONVERT_EXCEPTION (PasswordTooLong); diff --git a/src/Main/Forms/WaitDialog.h b/src/Main/Forms/WaitDialog.h index 89de8718..53f5048b 100644 --- a/src/Main/Forms/WaitDialog.h +++ b/src/Main/Forms/WaitDialog.h @@ -53,61 +53,61 @@ namespace VeraCrypt WaitStaticText->SetLabel (label); WaitProgessBar->Pulse(); Layout(); GetSizer()->Fit( this ); Centre( wxBOTH ); Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED, wxCommandEventHandler( WaitDialog::OnThreadCompletion ) ); Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD, wxCommandEventHandler( WaitDialog::OnAdminPasswordRequest ) ); Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_PIN, wxCommandEventHandler( WaitDialog::OnPinRequest ) ); Connect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_SHOW_MSG, wxCommandEventHandler( WaitDialog::OnShowMsg ) ); Connect( wxEVT_TIMER, wxTimerEventHandler( WaitDialog::OnProgressTimer ), NULL, this ); m_thread = new WaitThread(this, pRoutine); } ~WaitDialog() { Disconnect( wxEVT_TIMER, wxTimerEventHandler( WaitDialog::OnProgressTimer )); Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOGTHREAD_COMPLETED, wxCommandEventHandler( WaitDialog::OnThreadCompletion ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_ADMIN_PASSWORD, wxCommandEventHandler( WaitDialog::OnAdminPasswordRequest ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_PIN, wxCommandEventHandler( WaitDialog::OnPinRequest ) ); Disconnect( wxID_ANY, wxEVT_COMMAND_WAITDIALOG_SHOW_MSG, wxCommandEventHandler( WaitDialog::OnShowMsg ) ); } virtual void OnWaitDialogInit( wxInitDialogEvent& event ) { m_thread->Run(); m_timer.Start(100); m_bThreadRunning = true; } - int GetCharWidth (wxWindow *window) const + static int ComputeCharWidth (wxWindow *window) { int width; int height; window->GetTextExtent (L"a", &width, &height); if (width < 1) return 7; return width; } class ShowMessageParam { public: wxString m_message; wxString m_caption; long m_style; bool m_topMost; ShowMessageParam(const wxString &message, const wxString &caption,long style, bool topMost) : m_message(message), m_caption(caption), m_style(style), m_topMost(topMost) {} }; int RequestShowMessage (const wxString &message, const wxString &caption,long style, bool topMost) { long lResult = -1; if (m_queue.IsOk()) { wxString sResult; ShowMessageParam* pParam = new ShowMessageParam(message, caption, style, topMost); @@ -152,61 +152,61 @@ namespace VeraCrypt { event.Veto (); } else event.Skip (); } void OnThreadCompletion(wxCommandEvent &) { m_bThreadRunning = false; m_queue.Clear(); EndModal(0); } void OnAdminPasswordRequest(wxCommandEvent &) { wxPasswordEntryDialog dialog (this, LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); if (dialog.ShowModal() != wxID_OK) m_queue.Post(wxT("")); else m_queue.Post(dialog.GetValue()); } void OnPinRequest(wxCommandEvent &e) { wxPasswordEntryDialog dialog (this, wxString::Format (LangString["ENTER_TOKEN_PASSWORD"], e.GetString()), LangString["IDD_TOKEN_PASSWORD"]); - dialog.SetSize (wxSize (GetCharWidth (&dialog) * 50, -1)); + dialog.SetSize (wxSize (ComputeCharWidth (&dialog) * 50, -1)); if (dialog.ShowModal() != wxID_OK) m_queue.Post(wxT("")); else m_queue.Post(dialog.GetValue()); } void OnShowMsg(wxCommandEvent &e) { ShowMessageParam* pParam = (ShowMessageParam*) e.GetClientData(); if (pParam->m_topMost) { if (!IsActive()) RequestUserAttention (wxUSER_ATTENTION_ERROR); pParam->m_style |= wxSTAY_ON_TOP; } wxMessageDialog cur(this, pParam->m_message, pParam->m_caption, pParam->m_style); cur.SetYesNoLabels(LangString["UISTR_YES"], LangString["UISTR_NO"]); int iResult = (cur.ShowModal() == wxID_YES ? wxYES : wxNO); delete pParam; m_queue.Post(wxString::Format(wxT("%d"), iResult)); } void OnProgressTimer(wxTimerEvent& event) { WaitProgessBar->Pulse(); } virtual void Run(void) { ShowModal(); if (m_pRoutine->HasException()) ThrowException(m_pRoutine->m_pException); } diff --git a/src/Main/GraphicUserInterface.cpp b/src/Main/GraphicUserInterface.cpp index 16db8f83..1cb62671 100644 --- a/src/Main/GraphicUserInterface.cpp +++ b/src/Main/GraphicUserInterface.cpp @@ -10,60 +10,86 @@ code distribution packages. */ #include "System.h" #ifdef TC_UNIX #include <wx/mimetype.h> #include <wx/sckipc.h> #include <fcntl.h> #include <signal.h> #include <unistd.h> #include <sys/stat.h> #include <sys/types.h> #include <sys/utsname.h> #include "Platform/Unix/Process.h" #endif #include "Common/SecurityToken.h" #include "Application.h" #include "GraphicUserInterface.h" #include "FatalErrorHandler.h" #include "Forms/DeviceSelectionDialog.h" #include "Forms/KeyfileGeneratorDialog.h" #include "Forms/MainFrame.h" #include "Forms/MountOptionsDialog.h" #include "Forms/RandomPoolEnrichmentDialog.h" #include "Forms/SecurityTokenKeyfilesDialog.h" namespace VeraCrypt { + class AdminPasswordGUIRequestHandler : public GetStringFunctor + { + public: + virtual void operator() (string &passwordStr) + { + + wxString sValue; + if (Gui->GetWaitDialog()) + { + Gui->GetWaitDialog()->RequestAdminPassword(sValue); + if (sValue.IsEmpty()) + throw UserAbort (SRC_POS); + } + else + { + wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); + if (dialog.ShowModal() != wxID_OK) + throw UserAbort (SRC_POS); + sValue = dialog.GetValue(); + } + wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased + finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); + + StringConverter::ToSingle (wPassword, passwordStr); + } + }; #ifdef TC_MACOSX int GraphicUserInterface::g_customIdCmdV = 0; int GraphicUserInterface::g_customIdCmdA = 0; #endif GraphicUserInterface::GraphicUserInterface () : ActiveFrame (nullptr), BackgroundMode (false), mMainFrame (nullptr), mWaitDialog (nullptr) { #ifdef TC_UNIX signal (SIGHUP, OnSignal); signal (SIGINT, OnSignal); signal (SIGQUIT, OnSignal); signal (SIGTERM, OnSignal); #endif #ifdef TC_MACOSX g_customIdCmdV = wxNewId(); g_customIdCmdA = wxNewId(); wxApp::s_macHelpMenuTitleName = LangString["MENU_HELP"]; #endif } GraphicUserInterface::~GraphicUserInterface () { try { if (RandomNumberGenerator::IsRunning()) @@ -138,60 +164,61 @@ namespace VeraCrypt #ifdef TC_UNIX // Temporarily take ownership of a device if the user is not an administrator UserId origDeviceOwner ((uid_t) -1); if (!Core->HasAdminPrivileges() && volumePath->IsDevice()) { origDeviceOwner = FilesystemPath (wstring (*volumePath)).GetOwner(); Core->SetFileOwner (*volumePath, UserId (getuid())); } finally_do_arg2 (FilesystemPath, *volumePath, UserId, origDeviceOwner, { if (finally_arg2.SystemId != (uid_t) -1) Core->SetFileOwner (finally_arg, finally_arg2); }); #endif ShowInfo ("EXTERNAL_VOL_HEADER_BAK_FIRST_INFO"); shared_ptr <Volume> normalVolume; shared_ptr <Volume> hiddenVolume; MountOptions normalVolumeMountOptions; MountOptions hiddenVolumeMountOptions; normalVolumeMountOptions.Path = volumePath; hiddenVolumeMountOptions.Path = volumePath; VolumeType::Enum volumeType = VolumeType::Normal; + bool masterKeyVulnerable = false; // Open both types of volumes while (true) { shared_ptr <Volume> volume; MountOptions *options = (volumeType == VolumeType::Hidden ? &hiddenVolumeMountOptions : &normalVolumeMountOptions); MountOptionsDialog dialog (parent, *options, LangString[volumeType == VolumeType::Hidden ? "ENTER_HIDDEN_VOL_PASSWORD" : "ENTER_NORMAL_VOL_PASSWORD"], true); while (!volume) { dialog.Hide(); if (dialog.ShowModal() != wxID_OK) return; try { wxBusyCursor busy; OpenVolumeThreadRoutine routine( options->Path, options->PreserveTimestamps, options->Password, options->Pim, options->Kdf, options->Keyfiles, options->EMVSupportEnabled, options->Protection, options->ProtectionPassword, @@ -220,60 +247,67 @@ namespace VeraCrypt options->Pim, options->Kdf, options->Keyfiles, options->EMVSupportEnabled, options->Protection, options->ProtectionPassword, options->ProtectionPim, options->ProtectionKdf, options->ProtectionKeyfiles, true, volumeType, true ); ExecuteWaitThreadRoutine (parent, &routine2); volume = routine2.m_pVolume; bFailed = false; } catch (...) { } } if (bFailed) ShowWarning (e); else ShowWarning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK"); } } + // check if volume master key is vulnerable + if (volume->IsMasterKeyVulnerable()) + { + masterKeyVulnerable = true; + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + } + if (volumeType == VolumeType::Hidden) hiddenVolume = volume; else normalVolume = volume; // Ask whether a hidden volume is present if (volumeType == VolumeType::Normal) { wxArrayString choices; choices.Add (LangString["VOLUME_CONTAINS_HIDDEN"]); choices.Add (LangString["VOLUME_DOES_NOT_CONTAIN_HIDDEN"]); wxSingleChoiceDialog choiceDialog (parent, LangString["DOES_VOLUME_CONTAIN_HIDDEN"], Application::GetName(), choices); choiceDialog.SetSize (wxSize (Gui->GetCharWidth (&choiceDialog) * 60, -1)); choiceDialog.SetSelection (0); if (choiceDialog.ShowModal() != wxID_OK) return; switch (choiceDialog.GetSelection()) { case 0: volumeType = VolumeType::Hidden; continue; case 1: break; default: return; @@ -313,60 +347,64 @@ namespace VeraCrypt { wxBusyCursor busy; // Re-encrypt volume header SecureBuffer newHeaderBuffer (normalVolume->GetLayout()->GetHeaderSize()); ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, normalVolume->GetHeader(), normalVolumeMountOptions.Password, normalVolumeMountOptions.Pim, normalVolumeMountOptions.Keyfiles, normalVolumeMountOptions.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); backupFile.Write (newHeaderBuffer); if (hiddenVolume) { // Re-encrypt hidden volume header ReEncryptHeaderThreadRoutine hiddenRoutine(newHeaderBuffer, hiddenVolume->GetHeader(), hiddenVolumeMountOptions.Password, hiddenVolumeMountOptions.Pim, hiddenVolumeMountOptions.Keyfiles, hiddenVolumeMountOptions.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &hiddenRoutine); } else { // Store random data in place of hidden volume header shared_ptr <EncryptionAlgorithm> ea = normalVolume->GetEncryptionAlgorithm(); Core->RandomizeEncryptionAlgorithmKey (ea); ea->Encrypt (newHeaderBuffer); } backupFile.Write (newHeaderBuffer); } ShowWarning ("VOL_HEADER_BACKED_UP"); + + // display again warning that master key is vulnerable + if (masterKeyVulnerable) + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); } void GraphicUserInterface::BeginInteractiveBusyState (wxWindow *window) { static unique_ptr <wxCursor> arrowWaitCursor; if (arrowWaitCursor.get() == nullptr) arrowWaitCursor.reset (new wxCursor (wxCURSOR_ARROWWAIT)); window->SetCursor (*arrowWaitCursor); } void GraphicUserInterface::CreateKeyfile (shared_ptr <FilePath> keyfilePath) const { try { KeyfileGeneratorDialog dialog (GetActiveWindow()); dialog.ShowModal(); } catch (exception &e) { ShowError (e); } } void GraphicUserInterface::ClearListCtrlSelection (wxListCtrl *listCtrl) const { foreach (long item, GetListCtrlSelectedItems (listCtrl)) listCtrl->SetItemState (item, 0, wxLIST_STATE_SELECTED); } @@ -425,87 +463,61 @@ namespace VeraCrypt #ifdef __WXGTK__ // GTK for some reason unhides a hidden window if it is a parent of a new window if (IsInBackgroundMode()) return nullptr; #endif if (wxTopLevelWindows.size() == 1) return dynamic_cast <wxTopLevelWindow *> (wxTopLevelWindows.front()); #ifdef __WXGTK__ wxLongLong startTime = wxGetLocalTimeMillis(); do { #endif foreach (wxWindow *window, wxTopLevelWindows) { wxTopLevelWindow *topLevelWin = dynamic_cast <wxTopLevelWindow *> (window); if (topLevelWin && topLevelWin->IsActive() && topLevelWin->IsShown()) return topLevelWin; } #ifdef __WXGTK__ Yield(); // GTK does a lot of operations asynchronously, which makes it prone to many race conditions } while (wxGetLocalTimeMillis() - startTime < 500); #endif return dynamic_cast <wxTopLevelWindow *> (ActiveFrame ? ActiveFrame : GetTopWindow()); } shared_ptr <GetStringFunctor> GraphicUserInterface::GetAdminPasswordRequestHandler () { - struct AdminPasswordRequestHandler : public GetStringFunctor - { - virtual void operator() (string &passwordStr) - { - - wxString sValue; - if (Gui->GetWaitDialog()) - { - Gui->GetWaitDialog()->RequestAdminPassword(sValue); - if (sValue.IsEmpty()) - throw UserAbort (SRC_POS); - } - else - { - wxPasswordEntryDialog dialog (Gui->GetActiveWindow(), LangString["LINUX_ADMIN_PW_QUERY"], LangString["LINUX_ADMIN_PW_QUERY_TITLE"]); - if (dialog.ShowModal() != wxID_OK) - throw UserAbort (SRC_POS); - sValue = dialog.GetValue(); - } - wstring wPassword (sValue); // A copy of the password is created here by wxWidgets, which cannot be erased - finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); - - StringConverter::ToSingle (wPassword, passwordStr); - } - }; - - return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler); + return shared_ptr <GetStringFunctor> (new AdminPasswordGUIRequestHandler); } int GraphicUserInterface::GetCharHeight (wxWindow *window) const { int width; int height; window->GetTextExtent (L"a", &width, &height); if (height < 1) return 14; return height; } int GraphicUserInterface::GetCharWidth (wxWindow *window) const { int width; int height; window->GetTextExtent (L"a", &width, &height); if (width < 1) return 7; return width; } wxFont GraphicUserInterface::GetDefaultBoldFont (wxWindow *window) const { return wxFont ( #ifdef __WXGTK__ @@ -965,61 +977,61 @@ namespace VeraCrypt wxLog::SetLogLevel (logLevel); if (SingleInstanceChecker->IsAnotherRunning()) { #ifdef TC_WINDOWS class Client: public wxDDEClient { public: Client() {}; wxConnectionBase *OnMakeConnection () { return new Connection; } }; unique_ptr <wxDDEClient> client (new Client); unique_ptr <wxConnectionBase> connection (client->MakeConnection (L"localhost", serverName, L"raise")); if (connection.get() && connection->Execute (nullptr)) { connection->Disconnect(); Application::SetExitCode (0); return false; } #endif #if defined(TC_UNIX) && !defined(TC_MACOSX) try { int showFifo = open (string (MainFrame::GetShowRequestFifoPath()).c_str(), O_WRONLY | O_NONBLOCK); throw_sys_if (showFifo == -1); - byte buf[1] = { 1 }; + uint8 buf[1] = { 1 }; if (write (showFifo, buf, 1) == 1) { close (showFifo); Gui->ShowInfo (LangString["LINUX_VC_RUNNING_ALREADY"]); Application::SetExitCode (0); return false; } close (showFifo); } catch (...) { #ifdef DEBUG throw; #endif } // This is a false positive as VeraCrypt is not running (pipe not available) // we continue running after cleaning the lock file // and creating a new instance of the checker wxString lockFileName = wxGetHomeDir(); if ( lockFileName.Last() != wxT('/') ) { lockFileName += wxT('/'); } lockFileName << instanceCheckerName; if (wxRemoveFile (lockFileName)) { SingleInstanceChecker.reset (new wxSingleInstanceChecker (instanceCheckerName)); @@ -1413,112 +1425,115 @@ namespace VeraCrypt // Ask whether to restore internal or external backup bool restoreInternalBackup; wxArrayString choices; choices.Add (LangString["HEADER_RESTORE_INTERNAL"]); choices.Add (LangString["HEADER_RESTORE_EXTERNAL"]); wxSingleChoiceDialog choiceDialog (parent, LangString["HEADER_RESTORE_EXTERNAL_INTERNAL"], Application::GetName(), choices); choiceDialog.SetSize (wxSize (Gui->GetCharWidth (&choiceDialog) * 80, -1)); choiceDialog.SetSelection (0); if (choiceDialog.ShowModal() != wxID_OK) return; switch (choiceDialog.GetSelection()) { case 0: restoreInternalBackup = true; break; case 1: restoreInternalBackup = false; break; default: return; } /* force the display of the random enriching interface */ RandomNumberGenerator::SetEnrichedByUserStatus (false); + bool masterKeyVulnerable = false; if (restoreInternalBackup) { // Restore header from the internal backup shared_ptr <Volume> volume; MountOptions options; options.Path = volumePath; MountOptionsDialog dialog (parent, options, wxEmptyString, true); while (!volume) { dialog.Hide(); if (dialog.ShowModal() != wxID_OK) return; try { wxBusyCursor busy; OpenVolumeThreadRoutine routine( options.Path, options.PreserveTimestamps, options.Password, options.Pim, options.Kdf, options.Keyfiles, options.EMVSupportEnabled, options.Protection, options.ProtectionPassword, options.ProtectionPim, options.ProtectionKdf, options.ProtectionKeyfiles, options.SharedAccessAllowed, VolumeType::Unknown, true ); ExecuteWaitThreadRoutine (parent, &routine); volume = routine.m_pVolume; } catch (PasswordException &e) { ShowWarning (e); } } shared_ptr <VolumeLayout> layout = volume->GetLayout(); if (typeid (*layout) == typeid (VolumeLayoutV1Normal)) { ShowError ("VOLUME_HAS_NO_BACKUP_HEADER"); return; } + masterKeyVulnerable = volume->IsMasterKeyVulnerable(); + RandomNumberGenerator::Start(); UserEnrichRandomPool (nullptr); // Re-encrypt volume header wxBusyCursor busy; SecureBuffer newHeaderBuffer (volume->GetLayout()->GetHeaderSize()); ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, volume->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); // Write volume header int headerOffset = volume->GetLayout()->GetHeaderOffset(); shared_ptr <File> volumeFile = volume->GetFile(); if (headerOffset >= 0) volumeFile->SeekAt (headerOffset); else volumeFile->SeekEnd (headerOffset); volumeFile->Write (newHeaderBuffer); } else { // Restore header from an external backup wxString confirmMsg = LangString["CONFIRM_VOL_HEADER_RESTORE"]; if (!AskYesNo (wxString::Format (confirmMsg, wstring (*volumePath).c_str()), true, true)) return; @@ -1563,115 +1578,122 @@ namespace VeraCrypt { wxBusyCursor busy; // Test volume layouts foreach (shared_ptr <VolumeLayout> layout, VolumeLayout::GetAvailableLayouts ()) { if (layout->HasDriveHeader()) continue; if (!legacyBackup && (typeid (*layout) == typeid (VolumeLayoutV1Normal))) continue; if (legacyBackup && (typeid (*layout) == typeid (VolumeLayoutV2Normal) || typeid (*layout) == typeid (VolumeLayoutV2Hidden))) continue; SecureBuffer headerBuffer (layout->GetHeaderSize()); backupFile.ReadAt (headerBuffer, layout->GetType() == VolumeType::Hidden ? layout->GetHeaderSize() : 0); // Decrypt header shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password, options.EMVSupportEnabled); Pkcs5KdfList keyDerivationFunctions = layout->GetSupportedKeyDerivationFunctions(); EncryptionAlgorithmList encryptionAlgorithms = layout->GetSupportedEncryptionAlgorithms(); EncryptionModeList encryptionModes = layout->GetSupportedEncryptionModes(); DecryptThreadRoutine decryptRoutine(layout->GetHeader(), headerBuffer, *passwordKey, options.Pim, options.Kdf, keyDerivationFunctions, encryptionAlgorithms, encryptionModes); ExecuteWaitThreadRoutine (parent, &decryptRoutine); if (decryptRoutine.m_bResult) { + masterKeyVulnerable = layout->GetHeader()->IsMasterKeyVulnerable(); decryptedLayout = layout; break; } } if (!decryptedLayout) throw PasswordIncorrect (SRC_POS); } catch (PasswordException &e) { ShowWarning (e); } } File volumeFile; volumeFile.Open (*volumePath, File::OpenReadWrite, File::ShareNone, File::PreserveTimestamps); RandomNumberGenerator::Start(); UserEnrichRandomPool (nullptr); // Re-encrypt volume header wxBusyCursor busy; SecureBuffer newHeaderBuffer (decryptedLayout->GetHeaderSize()); ReEncryptHeaderThreadRoutine routine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &routine); // Write volume header int headerOffset = decryptedLayout->GetHeaderOffset(); if (headerOffset >= 0) volumeFile.SeekAt (headerOffset); else volumeFile.SeekEnd (headerOffset); volumeFile.Write (newHeaderBuffer); if (decryptedLayout->HasBackupHeader()) { // Re-encrypt backup volume header ReEncryptHeaderThreadRoutine backupRoutine(newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); ExecuteWaitThreadRoutine (parent, &backupRoutine); // Write backup volume header headerOffset = decryptedLayout->GetBackupHeaderOffset(); if (headerOffset >= 0) volumeFile.SeekAt (headerOffset); else volumeFile.SeekEnd (headerOffset); volumeFile.Write (newHeaderBuffer); } } ShowInfo ("VOL_HEADER_RESTORED"); + + // display warning if the volume master key is vulnerable + if (masterKeyVulnerable) + { + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + } } DevicePath GraphicUserInterface::SelectDevice (wxWindow *parent) const { try { DeviceSelectionDialog dialog (parent); if (dialog.ShowModal() == wxID_OK) { return dialog.SelectedDevice.Path; } } catch (exception &e) { Gui->ShowError (e); } return DevicePath(); } DirectoryPath GraphicUserInterface::SelectDirectory (wxWindow *parent, const wxString &message, bool existingOnly) const { /* Avoid OS leaking previously used directory when user choose not to save history */ wxString defaultPath; if (!GetPreferences().SaveHistory) defaultPath = wxGetHomeDir (); return DirectoryPath (::wxDirSelector (!message.empty() ? message : #ifdef __WXGTK__ wxDirSelectorPromptStr, @@ -1825,60 +1847,68 @@ namespace VeraCrypt listCtrl->DeleteAllItems(); } else listCtrl->GetItemRect (0, itemRect); int headerHeight = itemRect.y; #ifdef TC_WINDOWS headerHeight += 4; #elif defined (TC_MACOSX) headerHeight += 7; #elif defined (__WXGTK__) headerHeight += 5; #endif int rowHeight = itemRect.height; #ifdef TC_MACOSX rowHeight += 1; #endif listCtrl->SetMinSize (wxSize (listCtrl->GetMinSize().GetWidth(), rowHeight * rowCount + headerHeight)); } void GraphicUserInterface::SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar) const { int width = GetCharWidth (listCtrl) * charCount; #ifdef TC_MACOSX if (!hasVerticalScrollbar) width += GetScrollbarWidth (listCtrl); #endif listCtrl->SetMinSize (wxSize (width, listCtrl->GetMinSize().GetHeight())); } + + void GraphicUserInterface::SetContentProtection (bool enable) const + { +#if defined(TC_WINDOWS) || defined(TC_MACOSX) + GetActiveWindow()->SetContentProtection(enable ? wxCONTENT_PROTECTION_ENABLED : wxCONTENT_PROTECTION_NONE); +#endif + } + void GraphicUserInterface::ShowErrorTopMost (const wxString &message) const { ShowMessage (message, wxOK | wxICON_ERROR, true); } void GraphicUserInterface::ShowInfoTopMost (const wxString &message) const { ShowMessage (message, wxOK | wxICON_INFORMATION, true); } int GraphicUserInterface::ShowMessage (const wxString &message, long style, bool topMost) const { wxString caption = Application::GetName(); wxString subMessage = message; #ifdef TC_MACOSX size_t p = message.find (L"\n"); if (p != string::npos) { // Divide message to caption and info message caption = message.substr (0, p); p = message.find_first_not_of (L'\n', p); if (p != string::npos) subMessage = message.substr (p); else subMessage.clear(); if (subMessage.EndsWith (L"?")) { diff --git a/src/Main/GraphicUserInterface.h b/src/Main/GraphicUserInterface.h index d48b7973..d333551c 100644 --- a/src/Main/GraphicUserInterface.h +++ b/src/Main/GraphicUserInterface.h @@ -59,60 +59,61 @@ namespace VeraCrypt virtual list <long> GetListCtrlSelectedItems (wxListCtrl *listCtrl) const; virtual wxString GetListCtrlSubItemText (wxListCtrl *listCtrl, long itemIndex, int columnIndex) const; virtual void ImportTokenKeyfiles () const { ThrowTextModeRequired(); } virtual void InitSecurityTokenLibrary () const; virtual void InsertToListCtrl (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields, int imageIndex = -1, void *itemDataPtr = nullptr) const; virtual bool IsInBackgroundMode () const { return BackgroundMode; } virtual bool IsTheOnlyTopLevelWindow (const wxWindow *window) const; virtual void ListTokenKeyfiles () const; virtual void ListSecurityTokenKeyfiles () const; virtual void ListEMVTokenKeyfiles () const; virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const; virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) const; virtual void MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const; virtual void OnAutoDismountAllEvent (); virtual bool OnInit (); virtual void OnLogOff (); virtual void OpenDocument (wxWindow *parent, const wxFileName &document); virtual void OpenHomepageLink (wxWindow *parent, const wxString &linkId, const wxString &extraVars = wxEmptyString); virtual void OpenOnlineHelp (wxWindow *parent); virtual void OpenUserGuide (wxWindow *parent); virtual void RestoreVolumeHeaders (shared_ptr <VolumePath> volumePath) const; virtual DevicePath SelectDevice (wxWindow *parent) const; virtual DirectoryPath SelectDirectory (wxWindow *parent, const wxString &message = wxEmptyString, bool existingOnly = true) const; virtual FilePathList SelectFiles (wxWindow *parent, const wxString &caption, bool saveMode = false, bool allowMultiple = false, const list < pair <wstring, wstring> > &fileExtensions = (list < pair <wstring, wstring> > ()), const DirectoryPath &directory = DirectoryPath()) const; virtual FilePath SelectVolumeFile (wxWindow *parent, bool saveMode = false, const DirectoryPath &directory = DirectoryPath()) const; virtual void SetActiveFrame (wxFrame *frame) { ActiveFrame = frame; } virtual void SetBackgroundMode (bool state); virtual void SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar = true) const; virtual void SetListCtrlHeight (wxListCtrl *listCtrl, size_t rowCount) const; virtual void SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar = true) const; + virtual void SetContentProtection(bool enable) const; virtual void ShowErrorTopMost (char *langStringId) const { ShowErrorTopMost (LangString[langStringId]); } virtual void ShowErrorTopMost (const wxString &message) const; virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); } virtual void ShowInfoTopMost (const wxString &message) const; virtual void ShowWarningTopMost (char *langStringId) const { ShowWarningTopMost (LangString[langStringId]); } virtual void ShowWarningTopMost (const wxString &message) const; virtual bool UpdateListCtrlItem (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields) const; virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr <Hash> hash = shared_ptr <Hash>()) const; virtual void Yield () const; virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const; WaitDialog* GetWaitDialog () { return mWaitDialog; } void ExecuteWaitThreadRoutine (wxWindow *parent, WaitThreadRoutine *pRoutine) const; #ifdef TC_MACOSX virtual void MacOpenFiles (const wxArrayString &fileNames); virtual void MacReopenApp (); static bool HandlePasswordEntryCustomEvent (wxEvent& event); static void InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window); #endif template <class T> T *GetSelectedData (wxControlWithItems *control) const { int sel = control->GetSelection(); if (sel == wxNOT_FOUND) return nullptr; return reinterpret_cast <T *> (control->GetClientData (sel)); } diff --git a/src/Main/LanguageStrings.cpp b/src/Main/LanguageStrings.cpp index 71914ec7..9a983712 100644 --- a/src/Main/LanguageStrings.cpp +++ b/src/Main/LanguageStrings.cpp @@ -16,53 +16,58 @@ #include "Xml.h" namespace VeraCrypt { LanguageStrings::LanguageStrings () { } LanguageStrings::~LanguageStrings () { } wxString LanguageStrings::operator[] (const string &key) const { if (Map.count (key) > 0) return wxString (Map.find (key)->second); // return "VeraCrypt" as it is if (key == "VeraCrypt") return L"VeraCrypt"; return wxString (L"?") + StringConverter::ToWide (key) + L"?"; } wstring LanguageStrings::Get (const string &key) const { return wstring (LangString[key]); } void LanguageStrings::Init () { - static byte LanguageXml[] = + static uint8 LanguageXml[] = { # include "Common/Language.xml.h" , 0 }; string def = string ((const char*) LanguageXml); foreach (XmlNode node, XmlParser (def).GetNodes (L"entry")) { wxString text = node.InnerText; text.Replace (L"\\n", L"\n"); Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } - foreach (XmlNode node, XmlParser (Resources::GetLanguageXml()).GetNodes (L"entry")) + string translatedXml = Resources::GetLanguageXml(); + foreach (XmlNode node, XmlParser (translatedXml).GetNodes (L"entry")) { wxString text = node.InnerText; text.Replace (L"\\n", L"\n"); Map[StringConverter::ToSingle (wstring (node.Attributes[L"key"]))] = text; } + + XmlNode node = XmlParser (translatedXml).GetNodes (L"language").front(); + Map["LANGUAGE_TRANSLATORS"] = wxString (node.Attributes[L"translators"]); + Map["CURRENT_LANGUAGE_PACK"] = wxString (node.Attributes[L"name"]); } LanguageStrings LangString; } diff --git a/src/Main/Main.make b/src/Main/Main.make index 84f9d755..178c4669 100755 --- a/src/Main/Main.make +++ b/src/Main/Main.make @@ -75,181 +75,229 @@ RESOURCES += ../Mount/Drive_icon_96dpi.bmp.h RESOURCES += ../Mount/Drive_icon_mask_96dpi.bmp.h RESOURCES += ../Mount/Logo_96dpi.bmp.h endif CXXFLAGS += -I$(BASE_DIR)/Main #------ wxWidgets configuration ------ ifdef TC_NO_GUI WX_CONFIG_LIBS := base else WX_CONFIG_LIBS := adv,core,base endif ifeq "$(TC_BUILD_CONFIG)" "Release" CXXFLAGS += $(shell $(WX_CONFIG) $(WX_CONFIG_ARGS) --cxxflags) WX_LIBS = $(shell $(WX_CONFIG) $(WX_CONFIG_ARGS) --libs $(WX_CONFIG_LIBS)) else CXXFLAGS += $(shell $(WX_CONFIG) --debug $(WX_CONFIG_ARGS) --cxxflags) WX_LIBS = $(shell $(WX_CONFIG) --debug $(WX_CONFIG_ARGS) --libs $(WX_CONFIG_LIBS)) endif #------ FUSE configuration ------ -FUSE_LIBS = $(shell pkg-config fuse --libs) +FUSE_LIBS = $(shell $(PKG_CONFIG) $(VC_FUSE_PACKAGE) --libs) #------ Executable ------ export TC_VERSION := $(shell grep VERSION_STRING ../Common/Tcdefs.h | head -n 1 | cut -d'"' -f 2) #------ Linux package naming ------ ifeq "$(PLATFORM)" "Linux" ifdef TC_NO_GUI INSTALLER_TYPE := console ifeq "$(origin NOSSE2)" "command line" PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_console_$(PLATFORM_ARCH)_legacy.tar.gz else PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_console_$(PLATFORM_ARCH).tar.gz endif else INSTALLER_TYPE := gui ifeq "$(origin NOSSE2)" "command line" PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_$(PLATFORM_ARCH)_legacy.tar.gz else PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_$(PLATFORM_ARCH).tar.gz endif endif +# Determine GUI/GTK conditions +GUI_CONDITION := $(filter gui,$(INSTALLER_TYPE)) +GTK2_CONDITION := $(filter 2,$(GTK_VERSION)) + ifeq "$(origin NOSSE2)" "command line" INTERNAL_INSTALLER_NAME := veracrypt_install_$(INSTALLER_TYPE)_$(CPU_ARCH)_legacy.sh + +ifneq (,$(GUI_CONDITION)) +ifneq (,$(GTK2_CONDITION)) +INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-gtk2-gui-$(CPU_ARCH)-legacy +else INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH)-legacy +endif +else +INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH)-legacy +endif + else INTERNAL_INSTALLER_NAME := veracrypt_install_$(INSTALLER_TYPE)_$(CPU_ARCH).sh + +ifneq (,$(GUI_CONDITION)) +ifneq (,$(GTK2_CONDITION)) +INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-gtk2-gui-$(CPU_ARCH) +else +INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH) +endif +else INSTALLER_NAME := veracrypt-$(TC_VERSION)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH) endif endif + +endif #----------------------------------- #------ FreeBSD package naming ------ ifeq "$(PLATFORM)" "FreeBSD" SYSTEMNAME = $(shell uname -n) ifdef TC_NO_GUI INSTALLER_TYPE := console PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_$(SYSTEMNAME)_console_$(PLATFORM_ARCH).tar.gz else INSTALLER_TYPE := gui PACKAGE_NAME := $(APPNAME)_$(TC_VERSION)_$(SYSTEMNAME)_$(PLATFORM_ARCH).tar.gz endif +# Determine GUI/GTK conditions +GUI_CONDITION := $(filter gui,$(INSTALLER_TYPE)) +GTK2_CONDITION := $(filter 2,$(GTK_VERSION)) + INTERNAL_INSTALLER_NAME := veracrypt_install_f$(SYSTEMNAME)_$(INSTALLER_TYPE)_$(CPU_ARCH).sh + +ifneq (,$(GUI_CONDITION)) +ifneq (,$(GTK2_CONDITION)) +INSTALLER_NAME := veracrypt-$(TC_VERSION)-$(SYSTEMNAME)-setup-gtk2-gui-$(CPU_ARCH) +else +INSTALLER_NAME := veracrypt-$(TC_VERSION)-$(SYSTEMNAME)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH) +endif +else INSTALLER_NAME := veracrypt-$(TC_VERSION)-$(SYSTEMNAME)-setup-$(INSTALLER_TYPE)-$(CPU_ARCH) +endif endif #----------------------------------- $(APPNAME): $(LIBS) $(OBJS) @echo Linking $@ - $(CXX) -o $(APPNAME) $(OBJS) $(LIBS) $(FUSE_LIBS) $(WX_LIBS) $(LFLAGS) + $(CXX) -o $(APPNAME) $(OBJS) $(LIBS) $(AYATANA_LIBS) $(FUSE_LIBS) $(WX_LIBS) $(LFLAGS) ifeq "$(TC_BUILD_CONFIG)" "Release" ifndef NOSTRIP strip $(APPNAME) endif ifndef NOTEST ./$(APPNAME) --text --test >/dev/null || exit 1 endif ifeq "$(PLATFORM_UNSUPPORTED)" "1" @echo; echo "WARNING: This platform may be unsupported. To avoid possible serious problems, please read the chapter pertaining to $(PLATFORM) in Readme.txt."; echo endif endif ifeq "$(PLATFORM)" "MacOSX" prepare: $(APPNAME) mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/doc/HTML mkdir -p $(APPNAME).app/Contents/MacOS $(APPNAME).app/Contents/Resources/languages -rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME) -rm -f $(APPNAME).app/Contents/MacOS/$(APPNAME)_console ifeq "$(TC_BUILD_CONFIG)" "Release" ifdef TC_NO_GUI cp $(BASE_DIR)/Main/$(APPNAME) $(APPNAME).app/Contents/MacOS/$(APPNAME)_console else cp $(BASE_DIR)/Main/$(APPNAME) $(APPNAME).app/Contents/MacOS/$(APPNAME) endif else ifdef TC_NO_GUI -rm -f $(BASE_DIR)/Main/$(APPNAME)_console cp $(BASE_DIR)/Main/$(APPNAME) $(BASE_DIR)/Main/$(APPNAME)_console -ln -sf $(BASE_DIR)/Main/$(APPNAME)_console $(APPNAME).app/Contents/MacOS/$(APPNAME)_console else -ln -sf $(BASE_DIR)/Main/$(APPNAME) $(APPNAME).app/Contents/MacOS/$(APPNAME) endif endif cp $(BASE_DIR)/Resources/Icons/VeraCrypt.icns $(APPNAME).app/Contents/Resources cp $(BASE_DIR)/Resources/Icons/VeraCrypt_Volume.icns $(APPNAME).app/Contents/Resources cp -R $(BASE_DIR)/../doc/html/* $(APPNAME).app/Contents/Resources/doc/HTML cp $(BASE_DIR)/../Translations/* $(APPNAME).app/Contents/Resources/languages echo -n APPLTRUE >$(APPNAME).app/Contents/PkgInfo ifdef VC_LEGACY_BUILD sed -e 's/_VERSION_/$(patsubst %a,%.1,$(patsubst %b,%.2,$(TC_VERSION)))/' ../Build/Resources/MacOSX/Info.plist.legacy.xml >$(APPNAME).app/Contents/Info.plist else sed -e 's/_VERSION_/$(patsubst %a,%.1,$(patsubst %b,%.2,$(TC_VERSION)))/' ../Build/Resources/MacOSX/Info.plist.xml >$(APPNAME).app/Contents/Info.plist endif chmod -R go-w $(APPNAME).app +ifneq ("$(LOCAL_DEVELOPMENT_BUILD)","true") codesign -s "Developer ID Application: IDRIX (Z933746L2S)" --timestamp $(APPNAME).app +endif install: prepare cp -R $(APPNAME).app /Applications/. package: prepare ifdef VC_LEGACY_BUILD /usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt_Legacy.pkgproj productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt Legacy $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg rm -f $(APPNAME)_Legacy_$(TC_VERSION).dmg else +ifeq "$(VC_OSX_FUSET)" "1" + /usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt_fuse-t.pkgproj +else /usr/local/bin/packagesbuild $(BASE_DIR)/Setup/MacOSX/veracrypt.pkgproj +endif +ifneq ("$(LOCAL_DEVELOPMENT_BUILD)","true") productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg +else + # copy the unsigned package to the expected location + cp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt $(TC_VERSION).pkg" $(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg +endif rm -f $(APPNAME)_$(TC_VERSION).dmg endif rm -f "$(BASE_DIR)/Setup/MacOSX/template.dmg" rm -fr "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg" mkdir -p "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg" bunzip2 -k -f "$(BASE_DIR)/Setup/MacOSX/template.dmg.bz2" hdiutil attach "$(BASE_DIR)/Setup/MacOSX/template.dmg" -noautoopen -quiet -mountpoint "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg" cp "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_$(TC_VERSION).pkg" "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg/VeraCrypt_Installer.pkg" hdiutil detach "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg" -quiet -force ifdef VC_LEGACY_BUILD hdiutil convert "$(BASE_DIR)/Setup/MacOSX/template.dmg" -quiet -format UDZO -imagekey zlib-level=9 -o $(APPNAME)_Legacy_$(TC_VERSION).dmg else hdiutil convert "$(BASE_DIR)/Setup/MacOSX/template.dmg" -quiet -format UDZO -imagekey zlib-level=9 -o $(APPNAME)_$(TC_VERSION).dmg endif rm -f "$(BASE_DIR)/Setup/MacOSX/template.dmg" rm -fr "$(BASE_DIR)/Setup/MacOSX/VeraCrypt_dmg" endif ifeq "$(PLATFORM)" "Linux" prepare: $(APPNAME) rm -fr $(BASE_DIR)/Setup/Linux/usr mkdir -p $(BASE_DIR)/Setup/Linux/usr/bin mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/doc/$(APPNAME)/HTML cp $(BASE_DIR)/Main/$(APPNAME) $(BASE_DIR)/Setup/Linux/usr/bin/$(APPNAME) cp $(BASE_DIR)/Setup/Linux/$(APPNAME)-uninstall.sh $(BASE_DIR)/Setup/Linux/usr/bin/$(APPNAME)-uninstall.sh chmod +x $(BASE_DIR)/Setup/Linux/usr/bin/$(APPNAME)-uninstall.sh cp $(BASE_DIR)/License.txt $(BASE_DIR)/Setup/Linux/usr/share/doc/$(APPNAME)/License.txt cp -R $(BASE_DIR)/../doc/html/* "$(BASE_DIR)/Setup/Linux/usr/share/doc/$(APPNAME)/HTML" @@ -283,60 +331,62 @@ package: prepare @echo "#!/bin/sh" > $(INTERNAL_INSTALLER_NAME) @echo "VERSION=$(TC_VERSION)" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_TYPE=tar" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_NAME=$(PACKAGE_NAME)" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_START=1112" >> $(INTERNAL_INSTALLER_NAME) @echo "INSTALLER_TYPE=$(INSTALLER_TYPE)" >> $(INTERNAL_INSTALLER_NAME) @cat $(BASE_DIR)/Setup/Linux/veracrypt_install_template.sh >> $(INTERNAL_INSTALLER_NAME) @cat $(BASE_DIR)/Setup/Linux/$(PACKAGE_NAME) >> $(INTERNAL_INSTALLER_NAME) chmod +x $(INTERNAL_INSTALLER_NAME) rm -fr $(BASE_DIR)/Setup/Linux/packaging mkdir -p $(BASE_DIR)/Setup/Linux/packaging cp $(INTERNAL_INSTALLER_NAME) $(BASE_DIR)/Setup/Linux/packaging/. makeself $(BASE_DIR)/Setup/Linux/packaging $(BASE_DIR)/Setup/Linux/$(INSTALLER_NAME) "VeraCrypt $(TC_VERSION) Installer" ./$(INTERNAL_INSTALLER_NAME) endif endif ifeq "$(PLATFORM)" "FreeBSD" prepare: $(APPNAME) rm -fr $(BASE_DIR)/Setup/FreeBSD/usr mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/bin mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/doc/$(APPNAME)/HTML cp $(BASE_DIR)/Main/$(APPNAME) $(BASE_DIR)/Setup/FreeBSD/usr/bin/$(APPNAME) cp $(BASE_DIR)/Setup/Linux/$(APPNAME)-uninstall.sh $(BASE_DIR)/Setup/FreeBSD/usr/bin/$(APPNAME)-uninstall.sh chmod +x $(BASE_DIR)/Setup/FreeBSD/usr/bin/$(APPNAME)-uninstall.sh cp $(BASE_DIR)/License.txt $(BASE_DIR)/Setup/FreeBSD/usr/share/doc/$(APPNAME)/License.txt cp -R $(BASE_DIR)/../doc/html/* "$(BASE_DIR)/Setup/FreeBSD/usr/share/doc/$(APPNAME)/HTML" + mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/veracrypt/languages + cp -r $(BASE_DIR)/../Translations/* $(BASE_DIR)/Setup/FreeBSD/usr/share/veracrypt/languages/ ifndef TC_NO_GUI mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/applications mkdir -p $(BASE_DIR)/Setup/FreeBSD/usr/share/pixmaps mkdir -p $(BASE_DIR)/Setup/Linux/usr/share/mime/packages cp $(BASE_DIR)/Resources/Icons/VeraCrypt-256x256.xpm $(BASE_DIR)/Setup/FreeBSD/usr/share/pixmaps/$(APPNAME).xpm cp $(BASE_DIR)/Setup/Linux/$(APPNAME).desktop $(BASE_DIR)/Setup/FreeBSD/usr/share/applications/$(APPNAME).desktop cp $(BASE_DIR)/Setup/Linux/$(APPNAME).xml $(BASE_DIR)/Setup/Linux/usr/share/mime/packages/$(APPNAME).xml endif chown -R root:wheel $(BASE_DIR)/Setup/FreeBSD/usr chmod -R go-w $(BASE_DIR)/Setup/FreeBSD/usr install: prepare ifneq "$(DESTDIR)" "" mkdir -p $(DESTDIR) endif cp -R $(BASE_DIR)/Setup/FreeBSD/usr $(DESTDIR)/. ifeq "$(TC_BUILD_CONFIG)" "Release" package: prepare tar cfz $(BASE_DIR)/Setup/FreeBSD/$(PACKAGE_NAME) --directory $(BASE_DIR)/Setup/FreeBSD usr @rm -fr $(INTERNAL_INSTALLER_NAME) @echo "#!/bin/sh" > $(INTERNAL_INSTALLER_NAME) @echo "VERSION=$(TC_VERSION)" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_TYPE=tar" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_NAME=$(PACKAGE_NAME)" >> $(INTERNAL_INSTALLER_NAME) @echo "PACKAGE_START=1108" >> $(INTERNAL_INSTALLER_NAME) @echo "INSTALLER_TYPE=$(INSTALLER_TYPE)" >> $(INTERNAL_INSTALLER_NAME) diff --git a/src/Main/Resources.cpp b/src/Main/Resources.cpp index d9a787a5..f00c14f7 100644 --- a/src/Main/Resources.cpp +++ b/src/Main/Resources.cpp @@ -1,266 +1,278 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include "Platform/Platform.h" #include "Resources.h" #ifdef TC_WINDOWS #include "Main/resource.h" #else #ifdef TC_MACOSX #include "Application.h" #endif #include "Platform/File.h" #include "Platform/StringConverter.h" #include <stdio.h> +#include "UserPreferences.h" #endif namespace VeraCrypt { #ifdef TC_WINDOWS static ConstBufferPtr GetWindowsResource (const wchar_t *resourceType, const wchar_t *resourceName) { HGLOBAL hResL; HRSRC hRes; hRes = FindResource (NULL, resourceName, resourceType); throw_sys_if (!hRes); hResL = LoadResource (NULL, hRes); throw_sys_if (!hResL); - const byte *resPtr = (const byte *) LockResource (hResL); + const uint8 *resPtr = (const uint8 *) LockResource (hResL); throw_sys_if (!resPtr); return ConstBufferPtr (resPtr, SizeofResource (NULL, hRes)); } #endif // TC_WINDOWS - string Resources::GetLanguageXml () { #ifdef TC_WINDOWS ConstBufferPtr res = GetWindowsResource (L"XML", L"IDR_LANGUAGE"); Buffer strBuf (res.Size() + 1); strBuf.Zero(); strBuf.CopyFrom (res); return string (reinterpret_cast <char *> (strBuf.Ptr())); #else // get language from env LANG // support: C,POSIX, // support for e.g. german: de_DE.UTF-8, de.UTF8, de_DE, de // not support e.g.: de@Euro string defaultLang("en"); #if defined (TC_MACOSX) string filenamePrefix = StringConverter::ToSingle (Application::GetExecutableDirectory()) + "/../Resources/languages/Language."; #else string filenamePrefix("/usr/share/veracrypt/languages/Language."); #endif string filenamePost(".xml"); string filename = filenamePrefix + defaultLang + filenamePost; - if(const char* env_p = getenv("LANG")){ - string lang(env_p); + + UserPreferences Preferences; + Preferences.Load(); + string preferredLang = string(Preferences.Language.begin(), Preferences.Language.end()); #ifdef DEBUG - std::cout << lang << std::endl; + std::cout << "Config language: " << preferredLang << std::endl; #endif - if ( lang.size() > 1 ){ - int found = lang.find("."); - if ( found > 1 ){ - string langTag = lang.substr (0,found); - string lowerLangTag(StringConverter::ToLower (langTag) ); - int foundUnderscore = lowerLangTag.find("_"); - if ( foundUnderscore > 0 ) { - lowerLangTag.replace(foundUnderscore,1,1,'-'); - filename = filenamePrefix + lowerLangTag + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - string shortLangTag = lowerLangTag.substr(0,foundUnderscore); - filename = filenamePrefix + shortLangTag + filenamePost; + + if (preferredLang == "system") { + if (const char *env_p = getenv("LANG")) { + string lang(env_p); +#ifdef DEBUG + std::cout << "env $LANG: " << lang << std::endl; +#endif + if (lang.size() > 1) { + int found = lang.find("."); + if (found > 1) { + string langTag = lang.substr(0, found); + string lowerLangTag(StringConverter::ToLower(langTag)); + int foundUnderscore = lowerLangTag.find("_"); + if (foundUnderscore > 0) { + lowerLangTag.replace(foundUnderscore, 1, 1, '-'); + filename = filenamePrefix + lowerLangTag + filenamePost; FilesystemPath xml(filename); - if (! xml.IsFile()){ + if (!xml.IsFile()) { + string shortLangTag = lowerLangTag.substr(0, foundUnderscore); + filename = filenamePrefix + shortLangTag + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { + filename = filenamePrefix + defaultLang + filenamePost; + } + } + } else { + filename = filenamePrefix + langTag + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { filename = filenamePrefix + defaultLang + filenamePost; } } - }else{ - filename = filenamePrefix + langTag + filenamePost; + } else { + string lowerLang(StringConverter::ToLower(lang)); + filename = filenamePrefix + lowerLang + filenamePost; FilesystemPath xml(filename); - if (! xml.IsFile()){ - filename = filenamePrefix + defaultLang + filenamePost; - } - } - }else{ - string lowerLang(StringConverter::ToLower (lang) ); - filename = filenamePrefix + lowerLang + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - int foundUnderscore = lowerLang.find("_"); - if ( foundUnderscore > 0 ) { - lowerLang.replace(foundUnderscore,1,1,'-'); - filename = filenamePrefix + lowerLang + filenamePost; - FilesystemPath xml(filename); - if (! xml.IsFile()){ - filename = filenamePrefix + defaultLang + filenamePost; + if (!xml.IsFile()) { + int foundUnderscore = lowerLang.find("_"); + if (foundUnderscore > 0) { + lowerLang.replace(foundUnderscore, 1, 1, '-'); + filename = filenamePrefix + lowerLang + filenamePost; + FilesystemPath xml(filename); + if (!xml.IsFile()) { + filename = filenamePrefix + defaultLang + filenamePost; + } } } } } } + } else { + filename = filenamePrefix + preferredLang + filenamePost; } FilesystemPath xml(filename); if ( xml.IsFile() ){ File file; file.Open (xml, File::OpenRead, File::ShareRead); - vector <byte> keyfileData (file.Length()); + vector <uint8> keyfileData (file.Length()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); file.ReadCompleteBuffer (keyfileDataBuf); file.Close(); string langxml(keyfileData.begin(), keyfileData.end()); return langxml; } - static byte LanguageXml[] = + static uint8 LanguageXml[] = { # include "Common/Language.xml.h" , 0 }; return string ((const char*) LanguageXml); #endif } string Resources::GetLegalNotices () { #ifdef TC_WINDOWS ConstBufferPtr res = GetWindowsResource (L"TEXT", L"IDR_LICENSE"); Buffer strBuf (res.Size() + 1); strBuf.Zero(); strBuf.CopyFrom (res); return string (reinterpret_cast <char *> (strBuf.Ptr())); #else - static byte License[] = + static uint8 License[] = { # include "License.txt.h" , 0 }; return string ((const char*) License); #endif } #ifndef TC_NO_GUI wxBitmap Resources::GetDriveIconBitmap () { #ifdef TC_WINDOWS return wxBitmap (L"IDB_DRIVE_ICON", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0)); #else - static const byte DriveIcon[] = + static const uint8 DriveIcon[] = { # include "Mount/Drive_icon_96dpi.bmp.h" }; wxMemoryInputStream stream (DriveIcon, sizeof (DriveIcon)); return wxBitmap (wxImage (stream).Resize (wxSize (16, 12), wxPoint (0, 0))); #endif } wxBitmap Resources::GetDriveIconMaskBitmap () { #ifdef TC_WINDOWS wxImage image = wxBitmap (L"IDB_DRIVE_ICON_MASK", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0)); return wxBitmap (image.ConvertToMono (0, 0, 0), 1); #else - static const byte DriveIconMask[] = + static const uint8 DriveIconMask[] = { # include "Mount/Drive_icon_mask_96dpi.bmp.h" }; wxMemoryInputStream stream (DriveIconMask, sizeof (DriveIconMask)); wxImage image (stream); image.Resize (wxSize (16, 12), wxPoint (0, 0)); -# ifdef __WXGTK__ +# if defined __WXGTK__ || defined TC_MACOSX return wxBitmap (image.ConvertToMono (0, 0, 0), 1); # else return wxBitmap (image); # endif #endif } wxBitmap Resources::GetLogoBitmap () { #ifdef TC_WINDOWS return wxBitmap (L"IDB_LOGO", wxBITMAP_TYPE_BMP_RESOURCE); #else - static const byte Logo[] = + static const uint8 Logo[] = { # include "Mount/Logo_96dpi.bmp.h" }; wxMemoryInputStream stream (Logo, sizeof (Logo)); return wxBitmap (wxImage (stream)); #endif } wxBitmap Resources::GetTextualLogoBitmap () { #ifdef TC_WINDOWS return wxBitmap (L"IDB_TEXTUAL_LOGO", wxBITMAP_TYPE_BMP_RESOURCE); #else - static const byte Logo[] = + static const uint8 Logo[] = { # include "Common/Textual_logo_96dpi.bmp.h" }; wxMemoryInputStream stream (Logo, sizeof (Logo)); return wxBitmap (wxImage (stream)); #endif } wxIcon Resources::GetVeraCryptIcon () { #ifdef TC_WINDOWS return wxIcon (L"IDI_TRUECRYPT_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16); #else # include "Resources/Icons/VeraCrypt-256x256.xpm" return wxIcon (VeraCryptIcon256x256); #endif } wxBitmap Resources::GetVolumeCreationWizardBitmap (int height) { #ifdef TC_WINDOWS return wxBitmap (L"IDB_VOLUME_WIZARD_BITMAP", wxBITMAP_TYPE_BMP_RESOURCE); #else - static const byte VolumeWizardIcon[] = + static const uint8 VolumeWizardIcon[] = { # include "Format/VeraCrypt_Wizard.bmp.h" }; wxMemoryInputStream stream (VolumeWizardIcon, sizeof (VolumeWizardIcon)); wxImage image (stream); if (height != -1) { double scaleFactor = double (height) / double (image.GetHeight()); image.Rescale (int (image.GetWidth() * scaleFactor), int (image.GetHeight() * scaleFactor), wxIMAGE_QUALITY_HIGH); } return wxBitmap (image); #endif } #endif // !TC_NO_GUI } diff --git a/src/Main/StringFormatter.h b/src/Main/StringFormatter.h index 33a47a35..d7f64dd0 100644 --- a/src/Main/StringFormatter.h +++ b/src/Main/StringFormatter.h @@ -25,44 +25,47 @@ namespace VeraCrypt StringFormatterArg (const char c) : Empty (false) { string s; s += c; StringArg = StringConverter::ToWide (s); } StringFormatterArg (const wchar_t c) : Empty (false), Referenced (false), StringArg (c) { } StringFormatterArg (const char *str) : Empty (false), Referenced (false), StringArg (StringConverter::ToWide (str)) { } StringFormatterArg (const wchar_t *str) : Empty (false), Referenced (false), StringArg (str) { } StringFormatterArg (const string &str) : Empty (false), Referenced (false), StringArg (StringConverter::ToWide (str)) { } StringFormatterArg (const wstring &str) : Empty (false), Referenced (false), StringArg (str) { } StringFormatterArg (const wxString &str) : Empty (false), Referenced (false), StringArg (str) { } StringFormatterArg (int32 number) : Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { } StringFormatterArg (uint32 number) : Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { } StringFormatterArg (int64 number) : Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { } StringFormatterArg (uint64 number) : Empty (false), Referenced (false), StringArg (StringConverter::FromNumber (number)) { } operator wxString () { Referenced = true; return StringArg; } bool IsEmpty () const { return Empty; } bool WasReferenced() const { return Referenced; } protected: bool Empty; bool Referenced; wxString StringArg; }; class StringFormatter { public: StringFormatter (const wxString &format, StringFormatterArg arg0 = StringFormatterArg(), StringFormatterArg arg1 = StringFormatterArg(), StringFormatterArg arg2 = StringFormatterArg(), StringFormatterArg arg3 = StringFormatterArg(), StringFormatterArg arg4 = StringFormatterArg(), StringFormatterArg arg5 = StringFormatterArg(), StringFormatterArg arg6 = StringFormatterArg(), StringFormatterArg arg7 = StringFormatterArg(), StringFormatterArg arg8 = StringFormatterArg(), StringFormatterArg arg9 = StringFormatterArg()); virtual ~StringFormatter (); +#if (__cplusplus >= 201103L) + explicit +#endif operator wstring () const { return wstring (FormattedString); } operator wxString () const { return FormattedString; } operator StringFormatterArg () const { return FormattedString; } protected: wxString FormattedString; private: StringFormatter (const StringFormatter &); StringFormatter &operator= (const StringFormatter &); }; } #endif // TC_HEADER_Main_StringFormatter diff --git a/src/Main/TextUserInterface.cpp b/src/Main/TextUserInterface.cpp index 37b346bd..bc3f6f5a 100644 --- a/src/Main/TextUserInterface.cpp +++ b/src/Main/TextUserInterface.cpp @@ -3,60 +3,81 @@ 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #ifdef TC_UNIX #include <signal.h> #include <termios.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include "Platform/Unix/Process.h" #endif #include <wx/platinfo.h> #include "Common/Token.h" #include "Common/SecurityToken.h" #include "Common/EMVToken.h" #include "Core/RandomNumberGenerator.h" #include "Application.h" #include "TextUserInterface.h" namespace VeraCrypt { + class AdminPasswordTextRequestHandler : public GetStringFunctor + { + public: + AdminPasswordTextRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { } + virtual void operator() (string &passwordStr) + { + UI->ShowString (_("Enter your user password or administrator password: ")); + + TextUserInterface::SetTerminalEcho (false); + finally_do ({ TextUserInterface::SetTerminalEcho (true); }); + + wstring wPassword (UI->ReadInputStreamLine()); + finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); + + UI->ShowString (L"\n"); + + StringConverter::ToSingle (wPassword, passwordStr); + } + TextUserInterface *UI; + }; + TextUserInterface::TextUserInterface () { #ifdef TC_UNIX signal (SIGHUP, OnSignal); signal (SIGINT, OnSignal); signal (SIGQUIT, OnSignal); signal (SIGTERM, OnSignal); struct stat statBuf; if (fstat (0, &statBuf) != -1) #endif { FInputStream.reset (new wxFFileInputStream (stdin)); // Set fallback encoding of the stream converter to UTF-8 // to make sure we interpret multibyte symbols properly TextInputStream.reset (new wxTextInputStream (*FInputStream, wxT(" \t"), wxConvAuto(wxFONTENCODING_UTF8))); } } TextUserInterface::~TextUserInterface () { try { if (RandomNumberGenerator::IsRunning()) RandomNumberGenerator::Stop(); } catch (...) { } #ifdef TC_UNIX signal (SIGHUP, SIG_DFL); @@ -73,61 +94,61 @@ namespace VeraCrypt shared_ptr <KeyfileList> TextUserInterface::AskKeyfiles (const wxString &message) const { wxString msg = _("Enter keyfile"); if (!message.empty()) msg = message; make_shared_auto (KeyfileList, keyfiles); wxString s; wxString m = msg + L" [" + _("none") + L"]: "; while (!(s = AskString (m)).empty()) { keyfiles->push_back (make_shared <Keyfile> (wstring (s))); m = msg + L" [" + _("finish") + L"]: "; } return keyfiles; } shared_ptr <VolumePassword> TextUserInterface::AskPassword (const wxString &message, bool verify) const { wxString msg = LangString["ENTER_PASSWORD"] + L": "; if (!message.empty()) msg = message + L": "; SetTerminalEcho (false); finally_do ({ TextUserInterface::SetTerminalEcho (true); }); wchar_t passwordBuf[4096]; - finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <byte *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); + finally_do_arg (BufferPtr, BufferPtr (reinterpret_cast <uint8 *> (passwordBuf), sizeof (passwordBuf)), { finally_arg.Erase(); }); shared_ptr<VolumePassword> password; bool verPhase = false; while (true) { ShowString (verPhase ? wxString (_("Re-enter password: ")) : msg); wxString passwordStr; ReadInputStreamLine (passwordStr); size_t length = passwordStr.size(); ShowString (L"\n"); if (!verPhase && length < 1) { return shared_ptr <VolumePassword>(new VolumePassword ()); } for (size_t i = 0; i < length && i < VolumePassword::MaxSize; ++i) { passwordBuf[i] = (wchar_t) passwordStr[i]; const_cast <wchar_t *> (passwordStr.wc_str())[i] = L'X'; } if (verify && verPhase) { shared_ptr <VolumePassword> verPassword = ToUTF8Password (passwordBuf, length, CmdLine->ArgUseLegacyPassword? VolumePassword::MaxLegacySize : VolumePassword::MaxSize); @@ -266,60 +287,61 @@ namespace VeraCrypt if (!volumePath) throw UserAbort (SRC_POS); #ifdef TC_WINDOWS if (Core->IsVolumeMounted (*volumePath)) throw_err (LangString["DISMOUNT_FIRST"]); #endif ShowInfo ("EXTERNAL_VOL_HEADER_BAK_FIRST_INFO"); shared_ptr <Pkcs5Kdf> kdf; if (CmdLine->ArgHash) { kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } shared_ptr <Volume> normalVolume; shared_ptr <Volume> hiddenVolume; MountOptions normalVolumeMountOptions; MountOptions hiddenVolumeMountOptions; normalVolumeMountOptions.Path = volumePath; hiddenVolumeMountOptions.Path = volumePath; normalVolumeMountOptions.EMVSupportEnabled = true; hiddenVolumeMountOptions.EMVSupportEnabled = true; VolumeType::Enum volumeType = VolumeType::Normal; + bool masterKeyVulnerable = false; // Open both types of volumes while (true) { shared_ptr <Volume> volume; MountOptions *options = (volumeType == VolumeType::Hidden ? &hiddenVolumeMountOptions : &normalVolumeMountOptions); while (!volume) { ShowString (L"\n"); options->Password = AskPassword (LangString[volumeType == VolumeType::Hidden ? "ENTER_HIDDEN_VOL_PASSWORD" : "ENTER_NORMAL_VOL_PASSWORD"]); options->Pim = AskPim (volumeType == VolumeType::Hidden ?_("Enter PIM for the hidden volume") : _("Enter PIM for the normal/outer volume")); options->Keyfiles = AskKeyfiles(); try { volume = Core->OpenVolume ( options->Path, options->PreserveTimestamps, options->Password, options->Pim, kdf, options->Keyfiles, options->EMVSupportEnabled, options->Protection, options->ProtectionPassword, options->ProtectionPim, options->ProtectionKdf, options->ProtectionKeyfiles, true, @@ -339,60 +361,67 @@ namespace VeraCrypt options->PreserveTimestamps, options->Password, options->Pim, kdf, options->Keyfiles, options->EMVSupportEnabled, options->Protection, options->ProtectionPassword, options->ProtectionPim, options->ProtectionKdf, options->ProtectionKeyfiles, true, volumeType, true ); bFailed = false; } catch (...) { } } if (bFailed) ShowInfo (e); else ShowInfo ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK"); } } + // check if volume master key is vulnerable + if (volume->IsMasterKeyVulnerable()) + { + masterKeyVulnerable = true; + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + } + if (volumeType == VolumeType::Hidden) hiddenVolume = volume; else normalVolume = volume; // Ask whether a hidden volume is present if (volumeType == VolumeType::Normal && AskYesNo (L"\n" + LangString["DOES_VOLUME_CONTAIN_HIDDEN"])) { volumeType = VolumeType::Hidden; continue; } break; } if (hiddenVolume) { if (typeid (*normalVolume->GetLayout()) == typeid (VolumeLayoutV1Normal)) throw ParameterIncorrect (SRC_POS); if (typeid (*normalVolume->GetLayout()) == typeid (VolumeLayoutV2Normal) && typeid (*hiddenVolume->GetLayout()) != typeid (VolumeLayoutV2Hidden)) throw ParameterIncorrect (SRC_POS); } // Ask user to select backup file path wxString confirmMsg = L"\n" + LangString["CONFIRM_VOL_HEADER_BAK"] + L"\n"; if (!AskYesNo (wxString::Format (confirmMsg, wstring (*volumePath).c_str()), true)) return; @@ -406,60 +435,64 @@ namespace VeraCrypt backupFile.Open (filePath, File::CreateWrite); RandomNumberGenerator::Start(); /* force the display of the random enriching interface */ RandomNumberGenerator::SetEnrichedByUserStatus (false); UserEnrichRandomPool(); // Re-encrypt volume header SecureBuffer newHeaderBuffer (normalVolume->GetLayout()->GetHeaderSize()); Core->ReEncryptVolumeHeaderWithNewSalt (newHeaderBuffer, normalVolume->GetHeader(), normalVolumeMountOptions.Password, normalVolumeMountOptions.Pim, normalVolumeMountOptions.Keyfiles, normalVolumeMountOptions.EMVSupportEnabled); backupFile.Write (newHeaderBuffer); if (hiddenVolume) { // Re-encrypt hidden volume header Core->ReEncryptVolumeHeaderWithNewSalt (newHeaderBuffer, hiddenVolume->GetHeader(), hiddenVolumeMountOptions.Password, hiddenVolumeMountOptions.Pim, hiddenVolumeMountOptions.Keyfiles, hiddenVolumeMountOptions.EMVSupportEnabled); } else { // Store random data in place of hidden volume header shared_ptr <EncryptionAlgorithm> ea = normalVolume->GetEncryptionAlgorithm(); Core->RandomizeEncryptionAlgorithmKey (ea); ea->Encrypt (newHeaderBuffer); } backupFile.Write (newHeaderBuffer); ShowString (L"\n"); ShowInfo ("VOL_HEADER_BACKED_UP"); + + // display again warning that master key is vulnerable + if (masterKeyVulnerable) + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); } void TextUserInterface::ChangePassword (shared_ptr <VolumePath> volumePath, shared_ptr <VolumePassword> password, int pim, shared_ptr <Hash> currentHash, shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> newPassword, int newPim, shared_ptr <KeyfileList> newKeyfiles, shared_ptr <Hash> newHash) const { shared_ptr <Volume> volume; // Volume path if (!volumePath.get()) { if (Preferences.NonInteractive) throw MissingArgument (SRC_POS); volumePath = AskVolumePath (); } if (volumePath->IsEmpty()) throw UserAbort (SRC_POS); bool passwordInteractive = !password.get(); bool keyfilesInteractive = !keyfiles.get(); shared_ptr<Pkcs5Kdf> kdf; if (currentHash) { kdf = Pkcs5Kdf::GetAlgorithm (*currentHash); } while (true) { // Current password @@ -484,60 +517,66 @@ namespace VeraCrypt if (keyfilesInteractive) { // Ask for keyfiles only if required try { keyfiles.reset (new KeyfileList); volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, pim, kdf, keyfiles, true); } catch (PasswordException&) { if (!Preferences.NonInteractive) keyfiles = AskKeyfiles (); } } if (!volume.get()) volume = Core->OpenVolume (volumePath, Preferences.DefaultMountOptions.PreserveTimestamps, password, pim, kdf, keyfiles, true); } catch (PasswordException &e) { if (Preferences.NonInteractive || !passwordInteractive || !keyfilesInteractive) throw; ShowInfo (e); continue; } break; } + // display warning if volume master key is vulnerable + if (volume->IsMasterKeyVulnerable()) + { + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + } + // New password if (!newPassword.get() && !Preferences.NonInteractive) newPassword = AskPassword (_("Enter new password"), true); // New PIM if ((newPim < 0) && !Preferences.NonInteractive) newPim = AskPim (_("Enter new PIM")); // New keyfiles if (!newKeyfiles.get() && !Preferences.NonInteractive) { if (keyfiles.get() && keyfiles->size() > 0 && AskYesNo (_("Keep current keyfiles?"), true)) newKeyfiles = keyfiles; else newKeyfiles = AskKeyfiles (_("Enter new keyfile")); } /* force the display of the random enriching interface */ RandomNumberGenerator::SetEnrichedByUserStatus (false); UserEnrichRandomPool(); Core->ChangePassword (volume, newPassword, newPim, newKeyfiles, true, newHash ? Pkcs5Kdf::GetAlgorithm (*newHash) : shared_ptr <Pkcs5Kdf>()); ShowInfo ("PASSWORD_CHANGED"); } void TextUserInterface::CreateKeyfile (shared_ptr <FilePath> keyfilePath) const { FilePath path; @@ -629,107 +668,120 @@ namespace VeraCrypt File file; file.Open (fsPath); hostSize = file.Length(); } else if (fsPath.IsDevice()) { hostSize = Core->GetDeviceSize (fsPath); } else { throw_err (_("Hidden volume can be created only in an existing file or device.")); } if (hostSize < TC_MIN_HIDDEN_VOLUME_HOST_SIZE) throw_err (StringFormatter (_("Minimum outer volume size is {0}."), SizeToString (TC_MIN_HIDDEN_VOLUME_HOST_SIZE))); } uint64 minVolumeSize = options->Type == VolumeType::Hidden ? TC_MIN_HIDDEN_VOLUME_SIZE : TC_MIN_VOLUME_SIZE; uint64 maxVolumeSize = options->Type == VolumeType::Hidden ? VolumeLayoutV2Normal().GetMaxDataSize (hostSize) - TC_MIN_FAT_FS_SIZE : TC_MAX_VOLUME_SIZE_GENERAL; if (options->Path.IsDevice() && options->Type != VolumeType::Hidden) { if (options->Size != 0) throw_err (_("Volume size cannot be changed for device-hosted volumes.")); options->Size = Core->GetDeviceSize (options->Path); } else { uint64 AvailableDiskSpace = 0; - wxLongLong diskSpace = 0; - wxString parentDir = wxFileName (wstring (options->Path)).GetPath(); - if (parentDir.IsEmpty()) + if (options->Path.IsDevice()) { - parentDir = wxT("."); + AvailableDiskSpace = maxVolumeSize; } - if (wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace)) + else { - AvailableDiskSpace = (uint64) diskSpace.GetValue (); - if (maxVolumeSize > AvailableDiskSpace) - maxVolumeSize = AvailableDiskSpace; + wxLongLong diskSpace = 0; + wxString parentDir = wxFileName (wstring (options->Path)).GetPath(); + if (parentDir.IsEmpty()) + { + parentDir = wxT("."); + } + if (options->Type == VolumeType::Normal && wxDirExists(parentDir) && wxGetDiskSpace (parentDir, nullptr, &diskSpace)) + { + AvailableDiskSpace = (uint64) diskSpace.GetValue (); + if (maxVolumeSize > AvailableDiskSpace) + maxVolumeSize = AvailableDiskSpace; + } } if (options->Size == (uint64) (-1)) { - if (AvailableDiskSpace) + if (options->Type == VolumeType::Hidden) { + throw_err (_("Please do not use maximum size for hidden volume. As we do not mount the outer volume to determine the available space, it is your responsibility to choose a value so that the hidden volume does not overlap the outer volume.")); + } + else if (AvailableDiskSpace) { // caller requesting maximum size - // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace + // we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes options->Size = maxVolumeSize; } else { throw_err (_("Failed to get available disk space on the selected target.")); } } options->Quick = false; uint32 sectorSizeRem = options->Size % options->SectorSize; if (sectorSizeRem != 0) options->Size += options->SectorSize - sectorSizeRem; while (options->Size == 0) { if (Preferences.NonInteractive) throw MissingArgument (SRC_POS); uint64 multiplier = 1024 * 1024; - wxString sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG/sizeT/max): ") : _("\nEnter volume size (sizeK/size[M]/sizeG.sizeT/max): ")); + wxString sizeStr = AskString (options->Type == VolumeType::Hidden ? _("\nEnter hidden volume size (sizeK/size[M]/sizeG/sizeT): ") : _("\nEnter volume size (sizeK/size[M]/sizeG.sizeT/max): ")); if (sizeStr.CmpNoCase(wxT("max")) == 0) { multiplier = 1; - if (AvailableDiskSpace) + if (options->Type == VolumeType::Hidden) { + throw_err (_("Please do not use maximum size for hidden volume. As we do not mount the outer volume to determine the available space, it is your responsibility to choose a value so that the hidden volume does not overlap the outer volume.")); + } + else if (AvailableDiskSpace) { // caller requesting maximum size - // we use maxVolumeSize because it is guaranteed to be less of equal to AvailableDiskSpace + // we use maxVolumeSize because it is guaranteed to be less or equal to AvailableDiskSpace for outer volumes options->Size = maxVolumeSize; } else { throw_err (_("Failed to get available disk space on the selected target.")); } } else { multiplier = 1024 * 1024; size_t index = sizeStr.find_first_not_of (wxT("0123456789")); if (index == 0) { continue; } else if (index != (size_t) wxNOT_FOUND) { wxString sizeSuffix = sizeStr.Mid(index); if (sizeSuffix.CmpNoCase(wxT("K")) == 0 || sizeSuffix.CmpNoCase(wxT("KiB")) == 0) multiplier = BYTES_PER_KB; else if (sizeSuffix.CmpNoCase(wxT("M")) == 0 || sizeSuffix.CmpNoCase(wxT("MiB")) == 0) multiplier = BYTES_PER_MB; else if (sizeSuffix.CmpNoCase(wxT("G")) == 0 || sizeSuffix.CmpNoCase(wxT("GiB")) == 0) multiplier = BYTES_PER_GB; else if (sizeSuffix.CmpNoCase(wxT("T")) == 0 || sizeSuffix.CmpNoCase(wxT("TiB")) == 0) multiplier = BYTES_PER_TB; else continue; sizeStr = sizeStr.Left (index); @@ -1020,165 +1072,145 @@ namespace VeraCrypt } #endif // TC_UNIX ShowInfo (options->Type == VolumeType::Hidden ? "HIDVOL_FORMAT_FINISHED_HELP" : "FORMAT_FINISHED_INFO"); } void TextUserInterface::DeleteSecurityTokenKeyfiles () const { shared_ptr <KeyfileList> keyfiles = AskKeyfiles(); if (keyfiles->empty()) throw UserAbort(); foreach_ref (const Keyfile &keyfile, *keyfiles) { SecurityToken::DeleteKeyfile (TokenKeyfilePath (FilePath (keyfile))); } } void TextUserInterface::DoShowError (const wxString &message) const { wcerr << L"Error: " << static_cast<wstring> (message) << endl; } void TextUserInterface::DoShowInfo (const wxString &message) const { wcout << static_cast<wstring> (message) << endl; } void TextUserInterface::DoShowString (const wxString &str) const { - wcout << str.c_str(); + wcout << str.c_str() << flush; } void TextUserInterface::DoShowWarning (const wxString &message) const { wcerr << L"Warning: " << static_cast<wstring> (message) << endl; } void TextUserInterface::ExportTokenKeyfile () const { wstring keyfilePath = AskString (_("Enter token keyfile path: ")); if (keyfilePath.empty()) throw UserAbort (SRC_POS); shared_ptr<TokenKeyfile> tokenKeyfile = Token::getTokenKeyfile(keyfilePath); - vector <byte> keyfileData; + vector <uint8> keyfileData; tokenKeyfile->GetKeyfileData (keyfileData); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); }); FilePath exportFilePath = AskFilePath(); if (exportFilePath.IsEmpty()) throw UserAbort (SRC_POS); File keyfile; keyfile.Open (exportFilePath, File::CreateWrite); keyfile.Write (keyfileDataBuf); } shared_ptr <GetStringFunctor> TextUserInterface::GetAdminPasswordRequestHandler () { - struct AdminPasswordRequestHandler : public GetStringFunctor - { - AdminPasswordRequestHandler (TextUserInterface *userInterface) : UI (userInterface) { } - virtual void operator() (string &passwordStr) - { - UI->ShowString (_("Enter your user password or administrator password: ")); - - TextUserInterface::SetTerminalEcho (false); - finally_do ({ TextUserInterface::SetTerminalEcho (true); }); - - wstring wPassword (UI->ReadInputStreamLine()); - finally_do_arg (wstring *, &wPassword, { StringConverter::Erase (*finally_arg); }); - - UI->ShowString (L"\n"); - - StringConverter::ToSingle (wPassword, passwordStr); - } - TextUserInterface *UI; - }; - - return shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler (this)); + return shared_ptr <GetStringFunctor> (new AdminPasswordTextRequestHandler (this)); } void TextUserInterface::ImportTokenKeyfiles () const { list <shared_ptr<TokenInfo>> tokens = Token::GetAvailableTokens(); if (tokens.empty()) throw_err (LangString ["NO_TOKENS_FOUND"]); CK_SLOT_ID slotId; if (tokens.size() == 1) { slotId = tokens.front()->SlotId; } else { foreach (const shared_ptr<TokenInfo> &token, tokens) { wstringstream tokenLabel; tokenLabel << L"[" << token->SlotId << L"] " << LangString["TOKEN_SLOT_ID"].c_str() << L" " << token->SlotId << L" " << token->Label; ShowInfo (tokenLabel.str()); } slotId = (CK_SLOT_ID) AskSelection (tokens.back()->SlotId, tokens.front()->SlotId); } shared_ptr <KeyfileList> keyfiles; if (CmdLine->ArgKeyfiles.get() && !CmdLine->ArgKeyfiles->empty()) keyfiles = CmdLine->ArgKeyfiles; else if (!Preferences.NonInteractive) { keyfiles = AskKeyfiles(); if (keyfiles->empty()) throw UserAbort(); } else throw MissingArgument (SRC_POS); foreach_ref (const Keyfile &keyfilePath, *keyfiles) { File keyfile; keyfile.Open (keyfilePath, File::OpenRead, File::ShareReadWrite, File::PreserveTimestamps); if (keyfile.Length() > 0) { - vector <byte> keyfileData (keyfile.Length()); + vector <uint8> keyfileData (keyfile.Length()); BufferPtr keyfileDataBuf (&keyfileData.front(), keyfileData.size()); keyfile.ReadCompleteBuffer (keyfileDataBuf); finally_do_arg (BufferPtr, keyfileDataBuf, { finally_arg.Erase(); }); SecurityToken::CreateKeyfile (slotId, keyfileData, string (FilePath (keyfilePath).ToBaseName())); } else throw InsufficientData (SRC_POS, FilePath (keyfilePath)); } } void TextUserInterface::InitSecurityTokenLibrary () const { if (Preferences.SecurityTokenModule.IsEmpty()) throw_err (LangString ["NO_PKCS11_MODULE_SPECIFIED"]); struct PinRequestHandler : public GetPinFunctor { PinRequestHandler (const TextUserInterface *userInterface) : UI (userInterface) { } virtual void operator() (string &passwordStr) { if (CmdLine->ArgTokenPin && CmdLine->ArgTokenPin->IsAllocated ()) { passwordStr.clear(); passwordStr.insert (0, (char*) CmdLine->ArgTokenPin->Ptr (), CmdLine->ArgTokenPin->Size()); return; } @@ -1375,61 +1407,60 @@ namespace VeraCrypt { // Try to mount the volume using the backup header options.UseBackupHeaders = true; try { volume = UserInterface::MountVolume (options); ShowWarning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK"); } catch (...) { options.UseBackupHeaders = false; ShowInfo (e); options.Password.reset(); options.Pim = -1; } } else { ShowInfo (e); options.Password.reset(); options.Pim = -1; } ShowString (L"\n"); } catch (PasswordException &e) { ShowInfo (e); options.Password.reset(); - options.Pim = -1; } } #ifdef TC_LINUX if (!Preferences.NonInteractive && !Preferences.DisableKernelEncryptionModeWarning && volume->EncryptionModeName != L"XTS") { ShowWarning (LangString["ENCRYPTION_MODE_NOT_SUPPORTED_BY_KERNEL"]); } #endif return volume; } bool TextUserInterface::OnInit () { try { DefaultMessageOutput = new wxMessageOutputStderr; wxMessageOutput::Set (DefaultMessageOutput); InterfaceType = UserInterfaceType::Text; Init(); } catch (exception &e) { ShowError (e); return false; } return true; @@ -1499,107 +1530,110 @@ namespace VeraCrypt // Ask whether to restore internal or external backup bool restoreInternalBackup; shared_ptr <Pkcs5Kdf> kdf; if (CmdLine->ArgHash) { kdf = Pkcs5Kdf::GetAlgorithm (*CmdLine->ArgHash); } ShowInfo (LangString["HEADER_RESTORE_EXTERNAL_INTERNAL"]); ShowInfo (L"\n1) " + LangString["HEADER_RESTORE_INTERNAL"]); ShowInfo (L"2) " + LangString["HEADER_RESTORE_EXTERNAL"] + L"\n"); switch (AskSelection (2)) { case 1: restoreInternalBackup = true; break; case 2: restoreInternalBackup = false; break; default: throw UserAbort (SRC_POS); } /* force the display of the random enriching interface */ RandomNumberGenerator::SetEnrichedByUserStatus (false); + bool masterKeyVulnerable = false; if (restoreInternalBackup) { // Restore header from the internal backup shared_ptr <Volume> volume; MountOptions options; options.Path = volumePath; options.EMVSupportEnabled = true; while (!volume) { ShowString (L"\n"); options.Password = AskPassword(); options.Pim = AskPim(); options.Keyfiles = AskKeyfiles(); try { volume = Core->OpenVolume ( options.Path, options.PreserveTimestamps, options.Password, options.Pim, kdf, options.Keyfiles, options.EMVSupportEnabled, options.Protection, options.ProtectionPassword, options.ProtectionPim, options.ProtectionKdf, options.ProtectionKeyfiles, options.SharedAccessAllowed, VolumeType::Unknown, true ); } catch (PasswordException &e) { ShowInfo (e); } } shared_ptr <VolumeLayout> layout = volume->GetLayout(); if (typeid (*layout) == typeid (VolumeLayoutV1Normal)) { throw_err (LangString ["VOLUME_HAS_NO_BACKUP_HEADER"]); } + masterKeyVulnerable = volume->IsMasterKeyVulnerable(); + RandomNumberGenerator::Start(); UserEnrichRandomPool(); // Re-encrypt volume header SecureBuffer newHeaderBuffer (volume->GetLayout()->GetHeaderSize()); Core->ReEncryptVolumeHeaderWithNewSalt (newHeaderBuffer, volume->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); // Write volume header int headerOffset = volume->GetLayout()->GetHeaderOffset(); shared_ptr <File> volumeFile = volume->GetFile(); if (headerOffset >= 0) volumeFile->SeekAt (headerOffset); else volumeFile->SeekEnd (headerOffset); volumeFile->Write (newHeaderBuffer); } else { // Restore header from an external backup wxString confirmMsg = L"\n\n" + LangString["CONFIRM_VOL_HEADER_RESTORE"]; if (!AskYesNo (wxString::Format (confirmMsg, wstring (*volumePath).c_str()), true, true)) return; ShowString (L"\n"); FilePath filePath = AskFilePath(); @@ -1633,110 +1667,116 @@ namespace VeraCrypt shared_ptr <VolumeLayout> decryptedLayout; while (!decryptedLayout) { options.Password = AskPassword (L"\n" + LangString["ENTER_HEADER_BACKUP_PASSWORD"]); options.Pim = AskPim (_("Enter PIM")); options.Keyfiles = AskKeyfiles(); try { // Test volume layouts foreach (shared_ptr <VolumeLayout> layout, VolumeLayout::GetAvailableLayouts ()) { if (layout->HasDriveHeader()) continue; if (!legacyBackup && (typeid (*layout) == typeid (VolumeLayoutV1Normal))) continue; if (legacyBackup && (typeid (*layout) == typeid (VolumeLayoutV2Normal) || typeid (*layout) == typeid (VolumeLayoutV2Hidden))) continue; SecureBuffer headerBuffer (layout->GetHeaderSize()); backupFile.ReadAt (headerBuffer, layout->GetType() == VolumeType::Hidden ? layout->GetHeaderSize() : 0); // Decrypt header shared_ptr <VolumePassword> passwordKey = Keyfile::ApplyListToPassword (options.Keyfiles, options.Password, options.EMVSupportEnabled); if (layout->GetHeader()->Decrypt (headerBuffer, *passwordKey, options.Pim, kdf, layout->GetSupportedKeyDerivationFunctions(), layout->GetSupportedEncryptionAlgorithms(), layout->GetSupportedEncryptionModes())) { decryptedLayout = layout; + masterKeyVulnerable = layout->GetHeader()->IsMasterKeyVulnerable(); break; } } if (!decryptedLayout) throw PasswordIncorrect (SRC_POS); } catch (PasswordException &e) { ShowWarning (e); } } File volumeFile; volumeFile.Open (*volumePath, File::OpenReadWrite, File::ShareNone, File::PreserveTimestamps); RandomNumberGenerator::Start(); UserEnrichRandomPool(); // Re-encrypt volume header SecureBuffer newHeaderBuffer (decryptedLayout->GetHeaderSize()); Core->ReEncryptVolumeHeaderWithNewSalt (newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); // Write volume header int headerOffset = decryptedLayout->GetHeaderOffset(); if (headerOffset >= 0) volumeFile.SeekAt (headerOffset); else volumeFile.SeekEnd (headerOffset); volumeFile.Write (newHeaderBuffer); if (decryptedLayout->HasBackupHeader()) { // Re-encrypt backup volume header Core->ReEncryptVolumeHeaderWithNewSalt (newHeaderBuffer, decryptedLayout->GetHeader(), options.Password, options.Pim, options.Keyfiles, options.EMVSupportEnabled); // Write backup volume header headerOffset = decryptedLayout->GetBackupHeaderOffset(); if (headerOffset >= 0) volumeFile.SeekAt (headerOffset); else volumeFile.SeekEnd (headerOffset); volumeFile.Write (newHeaderBuffer); } } ShowString (L"\n"); ShowInfo ("VOL_HEADER_RESTORED"); + // display warning if the volume master key is vulnerable + if (masterKeyVulnerable) + { + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + } } void TextUserInterface::SetTerminalEcho (bool enable) { if (CmdLine->ArgDisplayPassword) return; #ifdef TC_UNIX struct termios termAttr; if (tcgetattr (0, &termAttr) == 0) { if (!enable) { termAttr.c_lflag &= ~ECHO; throw_sys_if (tcsetattr (0, TCSANOW, &termAttr) != 0); } else { termAttr.c_lflag |= ECHO; throw_sys_if (tcsetattr (0, TCSANOW, &termAttr) != 0); } } #endif } void TextUserInterface::UserEnrichRandomPool () const { RandomNumberGenerator::Start(); if (RandomNumberGenerator::IsEnrichedByUser()) @@ -1745,45 +1785,45 @@ namespace VeraCrypt if (CmdLine->ArgHash) RandomNumberGenerator::SetHash (CmdLine->ArgHash); if (!CmdLine->ArgRandomSourcePath.IsEmpty()) { SecureBuffer buffer (RandomNumberGenerator::PoolSize); File randSourceFile; randSourceFile.Open (CmdLine->ArgRandomSourcePath, File::OpenRead); for (size_t i = 0; i < buffer.Size(); ++i) { if (randSourceFile.Read (buffer.GetRange (i, 1)) < 1) break; } RandomNumberGenerator::AddToPool (buffer); RandomNumberGenerator::SetEnrichedByUserStatus (true); } else if (!Preferences.NonInteractive) { int randCharsRequired = RandomNumberGenerator::PoolSize; ShowInfo (StringFormatter (_("\nPlease type at least {0} randomly chosen characters and then press Enter:"), randCharsRequired)); SetTerminalEcho (false); finally_do ({ TextUserInterface::SetTerminalEcho (true); }); while (randCharsRequired > 0) { wstring randStr = AskString(); - RandomNumberGenerator::AddToPool (ConstBufferPtr ((byte *) randStr.c_str(), randStr.size() * sizeof (wchar_t))); + RandomNumberGenerator::AddToPool (ConstBufferPtr ((uint8 *) randStr.c_str(), randStr.size() * sizeof (wchar_t))); randCharsRequired -= randStr.size(); if (randCharsRequired > 0) ShowInfo (StringFormatter (_("Characters remaining: {0}"), randCharsRequired)); } ShowString (L"\n"); RandomNumberGenerator::SetEnrichedByUserStatus (true); } } wxMessageOutput *DefaultMessageOutput; } diff --git a/src/Main/TextUserInterface.h b/src/Main/TextUserInterface.h index becb1d59..34a7cb40 100644 --- a/src/Main/TextUserInterface.h +++ b/src/Main/TextUserInterface.h @@ -1,54 +1,56 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Main_TextUserInterface #define TC_HEADER_Main_TextUserInterface #include "System.h" #include "Main.h" #include "UserInterface.h" namespace VeraCrypt { + class AdminPasswordTextRequestHandler; class TextUserInterface : public UserInterface { public: + friend class AdminPasswordTextRequestHandler; TextUserInterface (); virtual ~TextUserInterface (); virtual FilePath AskFilePath (const wxString &message = wxEmptyString) const; virtual shared_ptr <KeyfileList> AskKeyfiles (const wxString &message = L"") const; virtual shared_ptr <VolumePassword> AskPassword (const wxString &message = L"", bool verify = false) const; virtual int AskPim (const wxString &message = L"") const; virtual ssize_t AskSelection (ssize_t optionCount, ssize_t defaultOption = -1) const; virtual wstring AskString (const wxString &message = wxEmptyString) const; virtual shared_ptr <VolumePath> AskVolumePath (const wxString &message = L"") const; virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const; virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const; virtual void BeginBusyState () const { } virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), int pim = 0, shared_ptr <Hash> currentHash = shared_ptr <Hash>(), shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), int newPim = 0, shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const; virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const; virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const; virtual void DeleteSecurityTokenKeyfiles () const; virtual void DoShowError (const wxString &message) const; virtual void DoShowInfo (const wxString &message) const; virtual void DoShowString (const wxString &str) const; virtual void DoShowWarning (const wxString &message) const; virtual void EndBusyState () const { } virtual void ExportTokenKeyfile () const; virtual shared_ptr <GetStringFunctor> GetAdminPasswordRequestHandler (); virtual void ImportTokenKeyfiles () const; #ifndef TC_NO_GUI virtual bool Initialize (int &argc, wxChar **argv) { return wxAppBase::Initialize(argc, argv); } #endif virtual void InitSecurityTokenLibrary () const; virtual void ListTokenKeyfiles () const; diff --git a/src/Main/Unix/Main.cpp b/src/Main/Unix/Main.cpp index 39a2eaba..ffc71a8d 100644 --- a/src/Main/Unix/Main.cpp +++ b/src/Main/Unix/Main.cpp @@ -49,61 +49,61 @@ int main (int argc, char **argv) try { CoreService::ProcessElevatedRequests(); return 0; } catch (exception &e) { #ifdef DEBUG SystemLog::WriteException (e); #endif } catch (...) { } return 1; } // Start core service CoreService::Start(); finally_do ({ CoreService::Stop(); }); // Start encryption thread pool EncryptionThreadPool::Start(); finally_do ({ EncryptionThreadPool::Stop(); }); #ifdef TC_NO_GUI bool forceTextUI = true; #else bool forceTextUI = false; #endif #ifdef __WXGTK__ - if (!getenv ("DISPLAY")) + if (!getenv ("DISPLAY") && !getenv ("WAYLAND_DISPLAY")) forceTextUI = true; #endif // Initialize application if (forceTextUI || (argc > 1 && (strcmp (argv[1], "-t") == 0 || strcmp (argv[1], "--text") == 0))) { Application::Initialize (UserInterfaceType::Text); } else { #if defined (TC_MACOSX) && !defined (TC_NO_GUI) if (argc > 1 && !(argc == 2 && strstr (argv[1], "-psn_") == argv[1])) { ProcessSerialNumber p; if (GetCurrentProcess (&p) == noErr) { TransformProcessType (&p, kProcessTransformToForegroundApplication); SetFrontProcess (&p); } } #endif Application::Initialize (UserInterfaceType::Graphic); } Application::SetExitCode (1); // Start application if (::wxEntry (argc, argv) == 0) Application::SetExitCode (0); } diff --git a/src/Main/UserInterface.cpp b/src/Main/UserInterface.cpp index 822c53c7..b216101a 100644 --- a/src/Main/UserInterface.cpp +++ b/src/Main/UserInterface.cpp @@ -5,60 +5,69 @@ Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "System.h" #include <set> #include <typeinfo> #include <wx/apptrait.h> #include <wx/cmdline.h> #include "Crypto/cpu.h" #include "Platform/PlatformTest.h" #include "Common/PCSCException.h" #ifdef TC_UNIX #include <errno.h> #include "Platform/Unix/Process.h" #endif #include "Platform/SystemInfo.h" #include "Platform/SystemException.h" #include "Common/SecurityToken.h" #include "Volume/EncryptionTest.h" #include "Application.h" #include "FavoriteVolume.h" #include "UserInterface.h" namespace VeraCrypt { + class AdminPasswordRequestHandler : public GetStringFunctor + { + public: + virtual void operator() (string &str) + { + throw ElevationFailed (SRC_POS, "sudo", 1, ""); + } + }; + UserInterface::UserInterface () { } UserInterface::~UserInterface () { Core->WarningEvent.Disconnect (this); Core->VolumeMountedEvent.Disconnect (this); try { if (SecurityToken::IsInitialized()) SecurityToken::CloseLibrary(); } catch (...) { } } void UserInterface::CheckRequirementsForMountingVolume () const { #ifdef TC_LINUX if (!Preferences.NonInteractive) { if (!SystemInfo::IsVersionAtLeast (2, 6, 24)) ShowWarning (LangString["LINUX_KERNEL_OLD"]); } #endif // TC_LINUX } void UserInterface::CloseExplorerWindows (shared_ptr <VolumeInfo> mountedVolume) const { @@ -363,61 +372,61 @@ namespace VeraCrypt size_t pos = typeName.find ("VeraCrypt::"); if (pos != string::npos) { return StringConverter::ToWide (typeName.substr (pos + string ("VeraCrypt::").size())) + L" at " + StringConverter::ToWide (ex.what()); } return StringConverter::ToWide (typeName) + L" at " + StringConverter::ToWide (ex.what()); } wxString UserInterface::ExceptionToString (const Exception &ex) { // Error messages const ErrorMessage *errMsgEx = dynamic_cast <const ErrorMessage *> (&ex); if (errMsgEx) return wstring (*errMsgEx).c_str(); // ExecutedProcessFailed const ExecutedProcessFailed *execEx = dynamic_cast <const ExecutedProcessFailed *> (&ex); if (execEx) { wstring errOutput; // ElevationFailed if (dynamic_cast <const ElevationFailed*> (&ex)) errOutput += wxString (LangString["LINUX_CANT_GET_ADMIN_PRIV"]) + (StringConverter::Trim (execEx->GetErrorOutput()).empty() ? L". " : L": "); errOutput += StringConverter::ToWide (execEx->GetErrorOutput()); if (errOutput.empty()) - return errOutput + StringFormatter (LangString["LINUX_COMMAND_GET_ERROR"], execEx->GetCommand(), execEx->GetExitCode()); + return errOutput + static_cast<wstring>(StringFormatter (LangString["LINUX_COMMAND_GET_ERROR"], execEx->GetCommand(), execEx->GetExitCode())); return wxString (errOutput).Trim (true); } // PasswordIncorrect if (dynamic_cast <const PasswordException *> (&ex)) { wxString message = ExceptionTypeToString (typeid (ex)); #ifndef TC_NO_GUI if (Application::GetUserInterfaceType() == UserInterfaceType::Graphic && wxGetKeyState (WXK_CAPITAL)) message += wxString (L"\n\n") + LangString["CAPSLOCK_ON"]; #endif if (Keyfile::WasHiddenFilePresentInKeyfilePath()) { #ifdef TC_UNIX message += LangString["LINUX_HIDDEN_FILES_PRESENT_IN_KEYFILE_PATH"]; #else message += LangString["HIDDEN_FILES_PRESENT_IN_KEYFILE_PATH"]; #endif } return message; } // PKCS#11 Exception if (dynamic_cast <const Pkcs11Exception *> (&ex)) { string errorString = string (dynamic_cast <const Pkcs11Exception &> (ex)); @@ -483,116 +492,108 @@ namespace VeraCrypt EX2MSG (NoDriveLetterAvailable, LangString["NO_FREE_DRIVES"]); EX2MSG (PasswordEmpty, LangString["LINUX_EX2MSG_PASSWORDEMPTY"]); EX2MSG (PasswordIncorrect, LangString["PASSWORD_WRONG"]); EX2MSG (PasswordKeyfilesIncorrect, LangString["PASSWORD_OR_KEYFILE_WRONG"]); EX2MSG (PasswordOrKeyboardLayoutIncorrect, LangString["PASSWORD_OR_KEYFILE_WRONG"] + LangString["LINUX_EX2MSG_PASSWORDORKEYBOARDLAYOUTINCORRECT"]); EX2MSG (PasswordOrMountOptionsIncorrect, LangString["PASSWORD_OR_KEYFILE_OR_MODE_WRONG"] + LangString["LINUX_EX2MSG_PASSWORDORMOUNTOPTIONSINCORRECT"]); EX2MSG (PasswordTooLong, StringFormatter (LangString["LINUX_EX2MSG_PASSWORDTOOLONG"], (int) VolumePassword::MaxSize)); EX2MSG (PasswordUTF8TooLong, LangString["PASSWORD_UTF8_TOO_LONG"]); EX2MSG (PasswordLegacyUTF8TooLong, LangString["LEGACY_PASSWORD_UTF8_TOO_LONG"]); EX2MSG (PasswordUTF8Invalid, LangString["PASSWORD_UTF8_INVALID"]); EX2MSG (PartitionDeviceRequired, LangString["LINUX_EX2MSG_PARTITIONDEVICEREQUIRED"]); EX2MSG (ProtectionPasswordIncorrect, LangString["LINUX_EX2MSG_PROTECTIONPASSWORDINCORRECT"]); EX2MSG (ProtectionPasswordKeyfilesIncorrect, LangString["LINUX_EX2MSG_PROTECTIONPASSWORDKEYFILESINCORRECT"]); EX2MSG (RootDeviceUnavailable, LangString["NODRIVER"]); EX2MSG (SecurityTokenKeyfileAlreadyExists, LangString["TOKEN_KEYFILE_ALREADY_EXISTS"]); EX2MSG (SecurityTokenKeyfileNotFound, LangString["TOKEN_KEYFILE_NOT_FOUND"]); EX2MSG (SecurityTokenLibraryNotInitialized, LangString["PKCS11_MODULE_INIT_FAILED"]); EX2MSG (StringConversionFailed, LangString["LINUX_EX2MSG_STRINGCONVERSIONFAILED"]); EX2MSG (StringFormatterException, LangString["LINUX_EX2MSG_STRINGFORMATTEREXCEPTION"]); EX2MSG (TemporaryDirectoryFailure, LangString["LINUX_EX2MSG_TEMPORARYDIRECTORYFAILURE"]); EX2MSG (UnportablePassword, LangString["UNSUPPORTED_CHARS_IN_PWD"]); EX2MSG (CommandAPDUNotValid, LangString["COMMAND_APDU_INVALID"]); EX2MSG (ExtendedAPDUNotSupported, LangString["EXTENDED_APDU_UNSUPPORTED"]); EX2MSG (ScardLibraryInitializationFailed, LangString["SCARD_MODULE_INIT_FAILED"]); EX2MSG (EMVUnknownCardType, LangString["EMV_UNKNOWN_CARD_TYPE"]); EX2MSG (EMVSelectAIDFailed, LangString["EMV_SELECT_AID_FAILED"]); EX2MSG (EMVIccCertNotFound, LangString["EMV_ICC_CERT_NOTFOUND"]); EX2MSG (EMVIssuerCertNotFound, LangString["EMV_ISSUER_CERT_NOTFOUND"]); EX2MSG (EMVCPLCNotFound, LangString["EMV_CPLC_NOTFOUND"]); - EX2MSG (InvalidEMVPath, LangString["EMV_PAN_NOTFOUND"]); - EX2MSG (EMVKeyfileDataNotFound, LangString["INVALID_EMV_PATH"]); - EX2MSG (EMVPANNotFound, LangString["EMV_KEYFILE_DATA_NOTFOUND"]); + EX2MSG (InvalidEMVPath, LangString["INVALID_EMV_PATH"]); + EX2MSG (EMVKeyfileDataNotFound, LangString["EMV_KEYFILE_DATA_NOTFOUND"]); + EX2MSG (EMVPANNotFound, LangString["EMV_PAN_NOTFOUND"]); #if defined (TC_LINUX) EX2MSG (TerminalNotFound, LangString["LINUX_EX2MSG_TERMINALNOTFOUND"]); EX2MSG (UnsupportedSectorSize, LangString["SECTOR_SIZE_UNSUPPORTED"]); EX2MSG (UnsupportedSectorSizeHiddenVolumeProtection, LangString["LINUX_EX2MSG_UNSUPPORTEDSECTORSIZEHIDDENVOLUMEPROTECTION"]); EX2MSG (UnsupportedSectorSizeNoKernelCrypto, LangString["LINUX_EX2MSG_UNSUPPORTEDSECTORSIZENOKERNELCRYPTO"]); #else EX2MSG (UnsupportedSectorSize, LangString["LINUX_EX2MSG_UNSUPPORTEDSECTORSIZE"]); #endif EX2MSG (VolumeAlreadyMounted, LangString["VOL_ALREADY_MOUNTED"]); EX2MSG (VolumeEncryptionNotCompleted, LangString["ERR_ENCRYPTION_NOT_COMPLETED"]); EX2MSG (VolumeHostInUse, LangString["LINUX_EX2MSG_VOLUMEHOSTINUSE"]); EX2MSG (VolumeSlotUnavailable, LangString["LINUX_EX2MSG_VOLUMESLOTUNAVAILABLE"]); #ifdef TC_MACOSX EX2MSG (HigherFuseVersionRequired, LangString["LINUX_EX2MSG_HIGHERFUSEVERSIONREQUIRED"]); #endif #undef EX2MSG return L""; } void UserInterface::Init () { SetAppName (Application::GetName()); SetClassName (Application::GetName()); #ifdef CRYPTOPP_CPUID_AVAILABLE DetectX86Features (); #endif LangString.Init(); Core->Init(); CmdLine.reset (new CommandLineInterface (argc, argv, InterfaceType)); SetPreferences (CmdLine->Preferences); Core->SetApplicationExecutablePath (Application::GetExecutablePath()); if (!Preferences.NonInteractive) { Core->SetAdminPasswordCallback (GetAdminPasswordRequestHandler()); } else { - struct AdminPasswordRequestHandler : public GetStringFunctor - { - virtual void operator() (string &str) - { - throw ElevationFailed (SRC_POS, "sudo", 1, ""); - } - }; - Core->SetAdminPasswordCallback (shared_ptr <GetStringFunctor> (new AdminPasswordRequestHandler)); } #if defined(TC_LINUX ) || defined (TC_FREEBSD) Core->ForceUseDummySudoPassword (CmdLine->ArgUseDummySudoPassword); #endif Core->WarningEvent.Connect (EventConnector <UserInterface> (this, &UserInterface::OnWarning)); Core->VolumeMountedEvent.Connect (EventConnector <UserInterface> (this, &UserInterface::OnVolumeMounted)); if (!CmdLine->Preferences.SecurityTokenModule.IsEmpty() && !SecurityToken::IsInitialized()) { try { InitSecurityTokenLibrary(); } catch (exception &e) { if (Preferences.NonInteractive) throw; ShowError (e); } } } void UserInterface::ListMountedVolumes (const VolumeInfoList &volumes) const { if (volumes.size() < 1) throw_err (LangString["NO_VOLUMES_MOUNTED"]); @@ -624,342 +625,365 @@ namespace VeraCrypt BusyScope busy (this); VolumeInfoList newMountedVolumes; if (!options.MountPoint) options.MountPoint.reset (new DirectoryPath); Core->CoalesceSlotNumberAndMountPoint (options); bool sharedAccessAllowed = options.SharedAccessAllowed; bool someVolumesShared = false; HostDeviceList devices; foreach (shared_ptr <HostDevice> device, Core->GetHostDevices (true)) { if (device->Partitions.empty()) devices.push_back (device); else { foreach (shared_ptr <HostDevice> partition, device->Partitions) devices.push_back (partition); } } set <wstring> mountedVolumes; foreach_ref (const VolumeInfo &v, Core->GetMountedVolumes()) mountedVolumes.insert (v.Path); bool protectedVolumeMounted = false; bool legacyVolumeMounted = false; + bool vulnerableVolumeMounted = false; foreach_ref (const HostDevice &device, devices) { if (mountedVolumes.find (wstring (device.Path)) != mountedVolumes.end()) continue; Yield(); options.SlotNumber = Core->GetFirstFreeSlotNumber (options.SlotNumber); options.MountPoint.reset (new DirectoryPath); options.Path.reset (new VolumePath (device.Path)); try { try { options.SharedAccessAllowed = sharedAccessAllowed; newMountedVolumes.push_back (Core->MountVolume (options)); } catch (VolumeHostInUse&) { if (!sharedAccessAllowed) { try { options.SharedAccessAllowed = true; newMountedVolumes.push_back (Core->MountVolume (options)); someVolumesShared = true; } catch (VolumeHostInUse&) { continue; } } else continue; } if (newMountedVolumes.back()->Protection == VolumeProtection::HiddenVolumeReadOnly) protectedVolumeMounted = true; if (newMountedVolumes.back()->EncryptionAlgorithmMinBlockSize == 8) legacyVolumeMounted = true; + + if (newMountedVolumes.back()->MasterKeyVulnerable) + vulnerableVolumeMounted = true; + } catch (DriverError&) { } catch (MissingVolumeData&) { } catch (PasswordException&) { } catch (SystemException&) { } catch (ExecutedProcessFailed&) { } } if (newMountedVolumes.empty()) { ShowWarning (LangString [options.Keyfiles && !options.Keyfiles->empty() ? "PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT" : "PASSWORD_WRONG_AUTOMOUNT"]); } else { + if (vulnerableVolumeMounted) + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + if (someVolumesShared) ShowWarning ("DEVICE_IN_USE_INFO"); if (legacyVolumeMounted) ShowWarning ("WARN_64_BIT_BLOCK_CIPHER"); if (protectedVolumeMounted) ShowInfo (LangString[newMountedVolumes.size() > 1 ? "HIDVOL_PROT_WARN_AFTER_MOUNT_PLURAL" : "HIDVOL_PROT_WARN_AFTER_MOUNT"]); } if (!newMountedVolumes.empty() && GetPreferences().CloseSecurityTokenSessionsAfterMount) SecurityToken::CloseAllSessions(); return newMountedVolumes; } VolumeInfoList UserInterface::MountAllFavoriteVolumes (MountOptions &options) { BusyScope busy (this); VolumeInfoList newMountedVolumes; foreach_ref (const FavoriteVolume &favorite, FavoriteVolume::LoadList()) { shared_ptr <VolumeInfo> mountedVolume = Core->GetMountedVolume (favorite.Path); if (mountedVolume) { if (mountedVolume->MountPoint != favorite.MountPoint) ShowInfo (StringFormatter (LangString["VOLUME_ALREADY_MOUNTED"], wstring (favorite.Path))); continue; } favorite.ToMountOptions (options); + bool mountPerformed = false; if (Preferences.NonInteractive) { BusyScope busy (this); newMountedVolumes.push_back (Core->MountVolume (options)); + mountPerformed = true; } else { try { BusyScope busy (this); newMountedVolumes.push_back (Core->MountVolume (options)); + mountPerformed = true; } catch (...) { UserPreferences prefs = GetPreferences(); if (prefs.CloseSecurityTokenSessionsAfterMount) Preferences.CloseSecurityTokenSessionsAfterMount = false; shared_ptr <VolumeInfo> volume = MountVolume (options); if (prefs.CloseSecurityTokenSessionsAfterMount) Preferences.CloseSecurityTokenSessionsAfterMount = true; if (!volume) break; newMountedVolumes.push_back (volume); } } + + if (mountPerformed && newMountedVolumes.back()->MasterKeyVulnerable) + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); } if (!newMountedVolumes.empty() && GetPreferences().CloseSecurityTokenSessionsAfterMount) SecurityToken::CloseAllSessions(); return newMountedVolumes; } shared_ptr <VolumeInfo> UserInterface::MountVolume (MountOptions &options) const { shared_ptr <VolumeInfo> volume; try { volume = MountVolumeThread (options); } catch (VolumeHostInUse&) { if (options.SharedAccessAllowed) throw_err (LangString["FILE_IN_USE_FAILED"]); if (!AskYesNo (StringFormatter (LangString["VOLUME_HOST_IN_USE"], wstring (*options.Path)), false, true)) throw UserAbort (SRC_POS); try { options.SharedAccessAllowed = true; volume = Core->MountVolume (options); } catch (VolumeHostInUse&) { throw_err (LangString["FILE_IN_USE_FAILED"]); } } + if (volume->MasterKeyVulnerable) + ShowWarning ("ERR_XTS_MASTERKEY_VULNERABLE"); + if (volume->EncryptionAlgorithmMinBlockSize == 8) ShowWarning ("WARN_64_BIT_BLOCK_CIPHER"); if (VolumeHasUnrecommendedExtension (*options.Path)) ShowWarning ("EXE_FILE_EXTENSION_MOUNT_WARNING"); if (options.Protection == VolumeProtection::HiddenVolumeReadOnly) ShowInfo ("HIDVOL_PROT_WARN_AFTER_MOUNT"); if (GetPreferences().CloseSecurityTokenSessionsAfterMount) SecurityToken::CloseAllSessions(); return volume; } void UserInterface::OnUnhandledException () { try { throw; } catch (UserAbort&) { } catch (exception &e) { ShowError (e); } catch (...) { ShowError (LangString["LINUX_UNKNOWN_EXC_OCCURRED"]); } Yield(); Application::SetExitCode (1); } void UserInterface::OnVolumeMounted (EventArgs &args) { shared_ptr <VolumeInfo> mountedVolume = (dynamic_cast <VolumeEventArgs &> (args)).mVolume; if (Preferences.OpenExplorerWindowAfterMount && !mountedVolume->MountPoint.IsEmpty()) OpenExplorerWindow (mountedVolume->MountPoint); } void UserInterface::OnWarning (EventArgs &args) { ExceptionEventArgs &e = dynamic_cast <ExceptionEventArgs &> (args); ShowWarning (e.mException); } +#if !defined(TC_WINDOWS) && !defined(TC_MACOSX) +// Function to check if a given executable exists and is executable +static bool IsExecutable(const string& exe) { + return wxFileName::IsFileExecutable("/usr/bin/" + exe) || + wxFileName::IsFileExecutable("/usr/local/bin/" + exe); +} +#endif + void UserInterface::OpenExplorerWindow (const DirectoryPath &path) { if (path.IsEmpty()) return; list <string> args; #ifdef TC_WINDOWS wstring p (Directory::AppendSeparator (path)); SHFILEINFO fInfo; SHGetFileInfo (p.c_str(), 0, &fInfo, sizeof (fInfo), 0); // Force explorer to discover the drive ShellExecute (GetTopWindow() ? static_cast <HWND> (GetTopWindow()->GetHandle()) : nullptr, L"open", p.c_str(), nullptr, nullptr, SW_SHOWNORMAL); #elif defined (TC_MACOSX) args.push_back (string (path)); try { Process::Execute ("open", args); } catch (exception &e) { ShowError (e); } #else - // MIME handler for directory seems to be unavailable through wxWidgets - wxString desktop = GetTraits()->GetDesktopEnvironment(); - bool xdgOpenPresent = wxFileName::IsFileExecutable (wxT("/usr/bin/xdg-open")) || wxFileName::IsFileExecutable (wxT("/usr/local/bin/xdg-open")); - bool nautilusPresent = wxFileName::IsFileExecutable (wxT("/usr/bin/nautilus")) || wxFileName::IsFileExecutable (wxT("/usr/local/bin/nautilus")); - - if (desktop == L"GNOME" || (desktop.empty() && !xdgOpenPresent && nautilusPresent)) - { - // args.push_back ("--no-default-window"); // This option causes nautilus not to launch under FreeBSD 11 - args.push_back ("--no-desktop"); - args.push_back (string (path)); - try - { - Process::Execute ("nautilus", args, 2000); + string directoryPath = string(path); + // Primary attempt: Use xdg-open + if (IsExecutable("xdg-open")) { + try { + args.push_back(directoryPath); + Process::Execute("xdg-open", args, 2000); + return; } catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } + catch (exception&) {} } - else if (desktop == L"KDE") - { - try - { - args.push_back (string (path)); - Process::Execute ("dolphin", args, 2000); - } - catch (TimeOut&) { } - catch (exception&) - { + + // Fallback attempts: Try known file managers + const char* fallbackFileManagers[] = { "gio", "kioclient5", "kfmclient", "exo-open", "nautilus", "dolphin", "caja", "thunar", "pcmanfm" }; + const size_t numFileManagers = sizeof(fallbackFileManagers) / sizeof(fallbackFileManagers[0]); + + for (size_t i = 0; i < numFileManagers; ++i) { + const char* fm = fallbackFileManagers[i]; + if (IsExecutable(fm)) { args.clear(); - args.push_back ("openURL"); - args.push_back (string (path)); - try - { - Process::Execute ("kfmclient", args, 2000); + if (strcmp(fm, "gio") == 0) { + args.push_back("open"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "kioclient5") == 0) { + args.push_back("exec"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "kfmclient") == 0) { + args.push_back("openURL"); + args.push_back(directoryPath); + } + else if (strcmp(fm, "exo-open") == 0) { + args.push_back("--launch"); + args.push_back("FileManager"); + args.push_back(directoryPath); + } + else { + args.push_back(directoryPath); + } + + try { + Process::Execute(fm, args, 2000); + return; // Success } catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } + catch (exception &) {} } } - else if (xdgOpenPresent) - { - // Fallback on the standard xdg-open command - // which is not always available by default - args.push_back (string (path)); - try - { - Process::Execute ("xdg-open", args, 2000); - } - catch (TimeOut&) { } - catch (exception &e) { ShowError (e); } - } - else - { - ShowWarning (wxT("Unable to find a file manager to open the mounted volume")); - } + + ShowWarning(wxT("Unable to find a file manager to open the mounted volume.\n" + "Please install xdg-utils or set a default file manager.")); #endif } bool UserInterface::ProcessCommandLine () { CommandLineInterface &cmdLine = *CmdLine; if (cmdLine.ArgCommand == CommandId::None) return false; if (Preferences.UseStandardInput) { wstring pwdInput; getline(wcin, pwdInput); size_t maxUtf8Len = cmdLine.ArgUseLegacyPassword? VolumePassword::MaxLegacySize : VolumePassword::MaxSize; cmdLine.ArgPassword = ToUTF8Password ( pwdInput.c_str (), pwdInput.size (), maxUtf8Len); } switch (cmdLine.ArgCommand) { case CommandId::AutoMountDevices: case CommandId::AutoMountFavorites: case CommandId::AutoMountDevicesFavorites: case CommandId::MountVolume: { cmdLine.ArgMountOptions.Path = cmdLine.ArgVolumePath; cmdLine.ArgMountOptions.MountPoint = cmdLine.ArgMountPoint; cmdLine.ArgMountOptions.Password = cmdLine.ArgPassword; cmdLine.ArgMountOptions.Pim = cmdLine.ArgPim; @@ -1181,61 +1205,62 @@ namespace VeraCrypt "--restore-headers[=VOLUME_PATH]\n" " Restore volume headers from the embedded or an external backup. All required\n" " options are requested from the user.\n" "\n" "--save-preferences\n" " Save user preferences.\n" "\n" "--test\n" " Test internal algorithms used in the process of encryption and decryption.\n" "\n" "--version\n" " Display program version.\n" "\n" "--volume-properties[=MOUNTED_VOLUME]\n" " Display properties of a mounted volume. See below for description of\n" " MOUNTED_VOLUME.\n" "\n" "MOUNTED_VOLUME:\n" " Specifies a mounted volume. One of the following forms can be used:\n" " 1) Path to the encrypted VeraCrypt volume.\n" " 2) Mount directory of the volume's filesystem (if mounted).\n" " 3) Slot number of the mounted volume (requires --slot).\n" "\n" "\n" "Options:\n" "\n" "--display-password\n" " Display password characters while typing.\n" "\n" "--encryption=ENCRYPTION_ALGORITHM\n" - " Use specified encryption algorithm when creating a new volume. When cascasing algorithms, they must be seperated by a dash. For example: AES-Twofish. \n" + " Use specified encryption algorithm when creating a new volume. When cascading\n" + " algorithms, they must be separated by a dash. For example: AES-Twofish.\n" "\n" "--filesystem=TYPE\n" " Filesystem type to mount. The TYPE argument is passed to mount(8) command\n" " with option -t. Default type is 'auto'. When creating a new volume, this\n" " option specifies the filesystem to be created on the new volume.\n" " Filesystem type 'none' disables mounting or creating a filesystem.\n" "\n" "--force\n" " Force mounting of a volume in use, dismounting of a volume in use, or\n" " overwriting a file. Note that this option has no effect on some platforms.\n" "\n" "--fs-options=OPTIONS\n" " Filesystem mount options. The OPTIONS argument is passed to mount(8)\n" " command with option -o when a filesystem on a VeraCrypt volume is mounted.\n" " This option is not available on some platforms.\n" "\n" "--hash=HASH\n" " Use specified hash algorithm when creating a new volume or changing password\n" " and/or keyfiles. This option also specifies the mixing PRF of the random\n" " number generator.\n" "\n" "-k, --keyfiles=KEYFILE1[,KEYFILE2,KEYFILE3,...]\n" " Use specified keyfiles when mounting a volume or when changing password\n" " and/or keyfiles. When a directory is specified, all files inside it will be\n" " used (non-recursively). Multiple keyfiles must be separated by comma.\n" " Use double comma (,,) to specify a comma contained in keyfile's name.\n" " Keyfile stored on a security token must be specified as\n" " token://slot/SLOT_NUMBER/file/FILENAME for a security token keyfile\n" " and emv://slot/SLOT_NUMBER for an EMV token keyfile.\n" " An empty keyfile (-k \"\") disables\n" @@ -1488,61 +1513,61 @@ namespace VeraCrypt else if (speed > 1024ULL*1024*1024*1024*1024) return wxString::Format (L"%.1f %s", (double)(speed/1024.0/1024/1024/1024/1024), LangString["PB_PER_SEC"].c_str()); else if (speed > 1024ULL*1024*1024*1024*99) s << speed/1024/1024/1024/1024 << L" " << LangString["TB_PER_SEC"].c_str(); else if (speed > 1024ULL*1024*1024*1024) return wxString::Format (L"%.1f %s", (double)(speed/1024.0/1024/1024/1024), LangString["TB_PER_SEC"].c_str()); else if (speed > 1024ULL*1024*1024*99) s << speed/1024/1024/1024 << L" " << LangString["GB_PER_SEC"].c_str(); else if (speed > 1024ULL*1024*999) return wxString::Format (L"%.1f %s", (double)(speed/1024.0/1024/1024), LangString["GB_PER_SEC"].c_str()); else if (speed > 1024ULL*1024*9) s << speed/1024/1024 << L" " << LangString["MB_PER_SEC"].c_str(); else if (speed > 1024ULL*999) return wxString::Format (L"%.1f %s", (double)(speed/1024.0/1024), LangString["MB_PER_SEC"].c_str()); else if (speed > 1024ULL) s << speed/1024 << L" " << LangString["KB_PER_SEC"].c_str(); else s << speed << L" " << LangString["B_PER_SEC"].c_str(); return s.str(); } void UserInterface::Test () const { if (!PlatformTest::TestAll()) throw TestFailed (SRC_POS); EncryptionTest::TestAll(); // StringFormatter - if (StringFormatter (L"{9} {8} {7} {6} {5} {4} {3} {2} {1} {0} {{0}}", "1", L"2", '3', L'4', 5, 6, 7, 8, 9, 10) != L"10 9 8 7 6 5 4 3 2 1 {0}") + if (static_cast<wstring>(StringFormatter (L"{9} {8} {7} {6} {5} {4} {3} {2} {1} {0} {{0}}", "1", L"2", '3', L'4', 5, 6, 7, 8, 9, 10)) != L"10 9 8 7 6 5 4 3 2 1 {0}") throw TestFailed (SRC_POS); try { StringFormatter (L"{0} {1}", 1); throw TestFailed (SRC_POS); } catch (StringFormatterException&) { } try { StringFormatter (L"{0} {1} {1}", 1, 2, 3); throw TestFailed (SRC_POS); } catch (StringFormatterException&) { } try { StringFormatter (L"{0} 1}", 1, 2); throw TestFailed (SRC_POS); } catch (StringFormatterException&) { } try { StringFormatter (L"{0} {1", 1, 2); throw TestFailed (SRC_POS); } catch (StringFormatterException&) { } ShowInfo ("TESTS_PASSED"); diff --git a/src/Main/UserPreferences.cpp b/src/Main/UserPreferences.cpp index 9dbd35f6..194cb6df 100644 --- a/src/Main/UserPreferences.cpp +++ b/src/Main/UserPreferences.cpp @@ -31,127 +31,136 @@ namespace VeraCrypt cfgVar = 0; else cfgVar = StringConverter::ToUInt32 (wstring (cfgText)); } void UserPreferences::SetValue (const wxString &cfgText, uint64 &cfgVar) { if (cfgText.empty()) cfgVar = 0; else cfgVar = StringConverter::ToUInt64 (wstring (cfgText)); } void UserPreferences::SetValue (const wxString &cfgText, wstring &cfgVar) { cfgVar = cfgText; } void UserPreferences::SetValue (const wxString &cfgText, wxString &cfgVar) { cfgVar = cfgText; } void UserPreferences::SetValue (const wxString &cfgText, FilesystemPath &cfgVar) { cfgVar = wstring (cfgText); } void UserPreferences::Load() { + // first we clear the unknown config map entries + UnknownConfigMapEntries.clear(); + // Preferences FilePath cfgPath = Application::GetConfigFilePath (GetPreferencesFileName()); if (cfgPath.IsFile()) { map <wxString, wxString> configMap; foreach (XmlNode node, XmlParser (cfgPath).GetNodes (L"config")) { configMap[node.Attributes[L"key"]] = node.InnerText; } -#define TC_CONFIG_SET(NAME) SetValue (configMap[L###NAME], NAME) +#define TC_CONFIG_SET(NAME) if (configMap.count(L###NAME) > 0) { SetValue (configMap[L###NAME], NAME); configMap.erase (L###NAME); } TC_CONFIG_SET (BackgroundTaskEnabled); TC_CONFIG_SET (BackgroundTaskMenuDismountItemsEnabled); TC_CONFIG_SET (BackgroundTaskMenuMountItemsEnabled); TC_CONFIG_SET (BackgroundTaskMenuOpenItemsEnabled); TC_CONFIG_SET (BeepAfterHotkeyMountDismount); - SetValue (configMap[L"CachePasswords"], DefaultMountOptions.CachePassword); + if (configMap.count(L"CachePasswords") > 0) { SetValue (configMap[L"CachePasswords"], DefaultMountOptions.CachePassword); configMap.erase (L"CachePasswords"); } TC_CONFIG_SET (CloseBackgroundTaskOnNoVolumes); TC_CONFIG_SET (CloseExplorerWindowsOnDismount); TC_CONFIG_SET (CloseSecurityTokenSessionsAfterMount); TC_CONFIG_SET (EMVSupportEnabled); TC_CONFIG_SET (DisableKernelEncryptionModeWarning); TC_CONFIG_SET (DismountOnInactivity); TC_CONFIG_SET (DismountOnLogOff); TC_CONFIG_SET (DismountOnPowerSaving); TC_CONFIG_SET (DismountOnScreenSaver); TC_CONFIG_SET (DisplayMessageAfterHotkeyDismount); TC_CONFIG_SET (BackgroundTaskEnabled); - SetValue (configMap[L"FilesystemOptions"], DefaultMountOptions.FilesystemOptions); + if (configMap.count(L"FilesystemOptions") > 0) { SetValue (configMap[L"FilesystemOptions"], DefaultMountOptions.FilesystemOptions); configMap.erase (L"FilesystemOptions"); } TC_CONFIG_SET (ForceAutoDismount); + TC_CONFIG_SET (Language); TC_CONFIG_SET (LastSelectedSlotNumber); TC_CONFIG_SET (MaxVolumeIdleTime); TC_CONFIG_SET (MountDevicesOnLogon); TC_CONFIG_SET (MountFavoritesOnLogon); bool readOnly = false; - SetValue (configMap[L"MountVolumesReadOnly"], readOnly); + if (configMap.count(L"MountVolumesReadOnly") > 0) { SetValue (configMap[L"MountVolumesReadOnly"], readOnly); configMap.erase (L"MountVolumesReadOnly"); } DefaultMountOptions.Protection = readOnly ? VolumeProtection::ReadOnly : VolumeProtection::None; - SetValue (configMap[L"MountVolumesRemovable"], DefaultMountOptions.Removable); - SetValue (configMap[L"NoHardwareCrypto"], DefaultMountOptions.NoHardwareCrypto); - SetValue (configMap[L"NoKernelCrypto"], DefaultMountOptions.NoKernelCrypto); + if (configMap.count(L"MountVolumesRemovable") > 0) { SetValue (configMap[L"MountVolumesRemovable"], DefaultMountOptions.Removable); configMap.erase (L"MountVolumesRemovable"); } + if (configMap.count(L"NoHardwareCrypto") > 0) { SetValue (configMap[L"NoHardwareCrypto"], DefaultMountOptions.NoHardwareCrypto); configMap.erase (L"NoHardwareCrypto"); } + if (configMap.count(L"NoKernelCrypto") > 0) { SetValue (configMap[L"NoKernelCrypto"], DefaultMountOptions.NoKernelCrypto); configMap.erase (L"NoKernelCrypto"); } TC_CONFIG_SET (OpenExplorerWindowAfterMount); - SetValue (configMap[L"PreserveTimestamps"], DefaultMountOptions.PreserveTimestamps); + if (configMap.count(L"PreserveTimestamps") > 0) { SetValue (configMap[L"PreserveTimestamps"], DefaultMountOptions.PreserveTimestamps); configMap.erase (L"PreserveTimestamps"); } TC_CONFIG_SET (SaveHistory); - SetValue (configMap[L"SecurityTokenLibrary"], SecurityTokenModule); + if (configMap.count(L"SecurityTokenLibrary") > 0) { SetValue (configMap[L"SecurityTokenLibrary"], SecurityTokenModule); configMap.erase (L"SecurityTokenLibrary"); } TC_CONFIG_SET (StartOnLogon); TC_CONFIG_SET (UseKeyfiles); TC_CONFIG_SET (WipeCacheOnAutoDismount); TC_CONFIG_SET (WipeCacheOnClose); wstring defaultPrf; - SetValue (configMap[L"DefaultPRF"], defaultPrf); + if (configMap.count(L"DefaultPRF") > 0) { SetValue (configMap[L"DefaultPRF"], defaultPrf); configMap.erase (L"DefaultPRF"); } + if (defaultPrf.empty()) + defaultPrf = L"autodetection"; shared_ptr <Pkcs5Kdf> savedKdf; try { if (defaultPrf != L"autodetection") savedKdf = Pkcs5Kdf::GetAlgorithm (defaultPrf); } catch (ParameterIncorrect&) { } DefaultMountOptions.Kdf = savedKdf; DefaultMountOptions.ProtectionKdf = savedKdf; + + // at this point, the configMap should be empty, if not, we have unknown config entries that we need to store + UnknownConfigMapEntries = configMap; } // Default keyfiles cfgPath = Application::GetConfigFilePath (GetDefaultKeyfilesFileName()); if (cfgPath.IsFile()) { foreach (const XmlNode &node, XmlParser (cfgPath).GetNodes (L"keyfile")) { DefaultKeyfiles.push_back (make_shared <Keyfile> ((wstring) node.InnerText)); } } #ifdef TC_WINDOWS // Hotkeys Hotkeys = Hotkey::LoadList(); #endif } void UserPreferences::Save() const { // Preferences class ConfigXmlFormatter { public: void AddEntry (const wchar_t *key, const wxString &value) { if (!value.empty()) { XmlNode config (L"config"); config.Attributes[L"key"] = key; @@ -179,82 +188,89 @@ namespace VeraCrypt AddEntry (key, s.str()); } XmlNode XmlConfig; }; ConfigXmlFormatter formatter; formatter.XmlConfig.Name = L"configuration"; #define TC_CONFIG_ADD(NAME) formatter.AddEntry (L###NAME, NAME) TC_CONFIG_ADD (BackgroundTaskEnabled); TC_CONFIG_ADD (BackgroundTaskMenuDismountItemsEnabled); TC_CONFIG_ADD (BackgroundTaskMenuMountItemsEnabled); TC_CONFIG_ADD (BackgroundTaskMenuOpenItemsEnabled); TC_CONFIG_ADD (BeepAfterHotkeyMountDismount); formatter.AddEntry (L"CachePasswords", DefaultMountOptions.CachePassword); TC_CONFIG_ADD (CloseBackgroundTaskOnNoVolumes); TC_CONFIG_ADD (CloseExplorerWindowsOnDismount); TC_CONFIG_ADD (CloseSecurityTokenSessionsAfterMount); TC_CONFIG_ADD (EMVSupportEnabled); TC_CONFIG_ADD (DisableKernelEncryptionModeWarning); TC_CONFIG_ADD (DismountOnInactivity); TC_CONFIG_ADD (DismountOnLogOff); TC_CONFIG_ADD (DismountOnPowerSaving); TC_CONFIG_ADD (DismountOnScreenSaver); TC_CONFIG_ADD (DisplayMessageAfterHotkeyDismount); TC_CONFIG_ADD (BackgroundTaskEnabled); formatter.AddEntry (L"FilesystemOptions", DefaultMountOptions.FilesystemOptions); TC_CONFIG_ADD (ForceAutoDismount); + TC_CONFIG_ADD (Language); TC_CONFIG_ADD (LastSelectedSlotNumber); TC_CONFIG_ADD (MaxVolumeIdleTime); TC_CONFIG_ADD (MountDevicesOnLogon); TC_CONFIG_ADD (MountFavoritesOnLogon); formatter.AddEntry (L"MountVolumesReadOnly", DefaultMountOptions.Protection == VolumeProtection::ReadOnly); formatter.AddEntry (L"MountVolumesRemovable", DefaultMountOptions.Removable); formatter.AddEntry (L"NoHardwareCrypto", DefaultMountOptions.NoHardwareCrypto); formatter.AddEntry (L"NoKernelCrypto", DefaultMountOptions.NoKernelCrypto); TC_CONFIG_ADD (OpenExplorerWindowAfterMount); formatter.AddEntry (L"PreserveTimestamps", DefaultMountOptions.PreserveTimestamps); TC_CONFIG_ADD (SaveHistory); formatter.AddEntry (L"SecurityTokenLibrary", wstring (SecurityTokenModule)); TC_CONFIG_ADD (StartOnLogon); TC_CONFIG_ADD (UseKeyfiles); TC_CONFIG_ADD (WipeCacheOnAutoDismount); TC_CONFIG_ADD (WipeCacheOnClose); wstring defaultPrf = L"autodetection"; if (DefaultMountOptions.Kdf) defaultPrf = DefaultMountOptions.Kdf->GetName (); formatter.AddEntry (L"DefaultPRF", defaultPrf); + // add unknown config entries by iterating over all elements of the UnknownConfigMapEntries map + for (map<wxString, wxString>::const_iterator it = UnknownConfigMapEntries.begin(); it != UnknownConfigMapEntries.end(); ++it) + { + formatter.AddEntry(it->first.c_str(), it->second); + } + XmlWriter writer (Application::GetConfigFilePath (GetPreferencesFileName(), true)); writer.WriteNode (formatter.XmlConfig); writer.Close(); // Default keyfiles FilePath keyfilesCfgPath = Application::GetConfigFilePath (GetDefaultKeyfilesFileName(), true); if (DefaultKeyfiles.empty()) { if (keyfilesCfgPath.IsFile()) keyfilesCfgPath.Delete(); } else { XmlNode keyfilesXml (L"defaultkeyfiles"); foreach_ref (const Keyfile &keyfile, DefaultKeyfiles) { keyfilesXml.InnerNodes.push_back (XmlNode (L"keyfile", wxString (wstring(FilesystemPath (keyfile))))); } XmlWriter keyfileWriter (keyfilesCfgPath); keyfileWriter.WriteNode (keyfilesXml); keyfileWriter.Close(); } #ifdef TC_WINDOWS // Hotkeys Hotkey::SaveList (Hotkeys); #endif diff --git a/src/Main/UserPreferences.h b/src/Main/UserPreferences.h index 6d53fb5f..25621656 100644 --- a/src/Main/UserPreferences.h +++ b/src/Main/UserPreferences.h @@ -12,104 +12,110 @@ #ifndef TC_HEADER_Main_UserPreferences #define TC_HEADER_Main_UserPreferences #include "System.h" #include "Main.h" #include "Hotkey.h" namespace VeraCrypt { struct UserPreferences { UserPreferences () : BackgroundTaskEnabled (true), BackgroundTaskMenuDismountItemsEnabled (true), BackgroundTaskMenuMountItemsEnabled (true), BackgroundTaskMenuOpenItemsEnabled (true), BeepAfterHotkeyMountDismount (false), CloseBackgroundTaskOnNoVolumes (true), CloseExplorerWindowsOnDismount (true), CloseSecurityTokenSessionsAfterMount (false), EMVSupportEnabled (false), DisableKernelEncryptionModeWarning (false), DismountOnInactivity (false), DismountOnLogOff (true), DismountOnPowerSaving (false), DismountOnScreenSaver (false), DisplayMessageAfterHotkeyDismount (false), ForceAutoDismount (true), + Language (L"system"), LastSelectedSlotNumber (0), MaxVolumeIdleTime (60), MountDevicesOnLogon (false), MountFavoritesOnLogon (false), NonInteractive (false), UseStandardInput (false), OpenExplorerWindowAfterMount (false), SaveHistory (false), StartOnLogon (false), UseKeyfiles (false), Verbose (false), WipeCacheOnAutoDismount (true), WipeCacheOnClose (false) { } virtual ~UserPreferences () { } void Load(); void Save() const; HotkeyList Hotkeys; KeyfileList DefaultKeyfiles; MountOptions DefaultMountOptions; bool BackgroundTaskEnabled; bool BackgroundTaskMenuDismountItemsEnabled; bool BackgroundTaskMenuMountItemsEnabled; bool BackgroundTaskMenuOpenItemsEnabled; bool BeepAfterHotkeyMountDismount; bool CloseBackgroundTaskOnNoVolumes; bool CloseExplorerWindowsOnDismount; bool CloseSecurityTokenSessionsAfterMount; bool EMVSupportEnabled; bool DisableKernelEncryptionModeWarning; bool DismountOnInactivity; bool DismountOnLogOff; bool DismountOnPowerSaving; bool DismountOnScreenSaver; bool DisplayMessageAfterHotkeyDismount; bool ForceAutoDismount; + wstring Language; uint64 LastSelectedSlotNumber; int32 MaxVolumeIdleTime; bool MountDevicesOnLogon; bool MountFavoritesOnLogon; bool NonInteractive; bool UseStandardInput; bool OpenExplorerWindowAfterMount; bool SaveHistory; FilePath SecurityTokenModule; bool StartOnLogon; bool UseKeyfiles; bool Verbose; bool WipeCacheOnAutoDismount; bool WipeCacheOnClose; + // A map used to store unknown entries from the configuration file in order to preserve them when saving the configuration. + // This helps to preserve unknown entries that may be used by future versions of VeraCrypt or entries used by old versions that were removed from current version. + map <wxString, wxString> UnknownConfigMapEntries; + protected: wxString GetDefaultKeyfilesFileName () const { return L"Default Keyfiles.xml"; } #ifdef TC_PROTOTYPE wxString GetPreferencesFileName () const { return L"Configuration_Debug.xml"; } #else wxString GetPreferencesFileName () const { return L"Configuration.xml"; } #endif void SetValue (const wxString &cfgText, bool &cfgVar); void SetValue (const wxString &cfgText, int &cfgVar); void SetValue (const wxString &cfgText, uint64 &cfgVar); void SetValue (const wxString &cfgText, wstring &cfgVar); void SetValue (const wxString &cfgText, wxString &cfgVar); void SetValue (const wxString &cfgText, FilesystemPath &cfgVar); }; } #endif // TC_HEADER_Main_UserPreferences diff --git a/src/Main/Xml.cpp b/src/Main/Xml.cpp index 6d0faa18..bf286a55 100644 --- a/src/Main/Xml.cpp +++ b/src/Main/Xml.cpp @@ -81,61 +81,61 @@ namespace VeraCrypt if (innerTextEnd == string::npos) throw ParameterIncorrect (SRC_POS); xmlNode.InnerText = ConvertEscapedChars (XmlText.substr (innerTextPos, innerTextEnd - innerTextPos)); nodePos = innerTextEnd; } nodeList.push_back (xmlNode); } return nodeList; } XmlWriter::XmlWriter (const FilePath &fileName) { MemOutStream.reset (new wxMemoryOutputStream); TextOutStream.reset (new wxTextOutputStream (*MemOutStream)); OutFile.Open (fileName, File::CreateWrite); *TextOutStream << L"<?xml version=\"1.0\" encoding=\"utf-8\"?>" << endl << L"<VeraCrypt>" << endl; CurrentIndentLevel = 0; } void XmlWriter::Close() { if (MemOutStream.get()) { *TextOutStream << L"</VeraCrypt>" << endl; wxStreamBuffer *buf = MemOutStream->GetOutputStreamBuffer(); - OutFile.Write (ConstBufferPtr (reinterpret_cast <byte *> (buf->GetBufferStart()), buf->GetBufferSize())); + OutFile.Write (ConstBufferPtr (reinterpret_cast <uint8 *> (buf->GetBufferStart()), buf->GetBufferSize())); OutFile.Close(); TextOutStream.reset(); MemOutStream.reset(); } } wxString XmlWriter::EscapeChars (wxString rawString) const { rawString.Replace (L"<", L"<"); rawString.Replace (L">", L">"); rawString.Replace (L"&", L"&"); rawString.Replace (L"\"", L"""); return rawString; } void XmlWriter::WriteNode (const XmlNode &xmlNode) { XmlNodeList nodes; nodes.push_back (xmlNode); WriteNodes (nodes); } void XmlWriter::WriteNodes (const XmlNodeList &xmlNodes) { CurrentIndentLevel++; wxString indent; for (int i = 0; i < CurrentIndentLevel; ++i) indent += L"\t"; diff --git a/src/Makefile b/src/Makefile index f6ec5041..15af9c6c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,524 +1,596 @@ # # Derived from source code of TrueCrypt 7.1a, which is # 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) # and all other portions of this file are Copyright (c) 2013-2017 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. # #------ Command line arguments ------ # DEBUG: Disable optimizations and enable debugging checks # DEBUGGER: Enable debugging information for use by debuggers # NOASM: Exclude modules requiring assembler # NOGUI: Disable graphical user interface (build console-only application) # NOSTRIP: Do not strip release binary # NOTEST: Do not test release binary # RESOURCEDIR: Run-time resource directory # VERBOSE: Enable verbose messages # WXSTATIC: Use static wxWidgets library # SSSE3: Enable SSSE3 support in compiler # SSE41: Enable SSE4.1 support in compiler # NOSSE2: Disable SEE2 support in compiler -# WITHGTK3: Build wxWidgets against GTK3 +# WOLFCRYPT: Build with wolfCrypt as crypto provider (see Crypto/wolfCrypt.md) +# WITHFUSET: Build with FUSE-T support on macOS instead of MacFUSE #------ Targets ------ # all # clean # wxbuild: Configure and build wxWidgets - source code must be located at $(WX_ROOT) #------ Build configuration ------ export APPNAME := veracrypt export BASE_DIR := $(CURDIR) export BUILD_INC := $(BASE_DIR)/Build/Include export AR ?= ar export CC ?= gcc export CXX ?= g++ export AS := yasm export RANLIB ?= ranlib export CFLAGS := -Wall export CXXFLAGS := -Wall -Wno-unused-parameter C_CXX_FLAGS := -MMD -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGE_FILES -I$(BASE_DIR) -I$(BASE_DIR)/Crypto export ASFLAGS := -D __GNUC__ -D __YASM__ export LFLAGS := +export PKG_CONFIG ?= pkg-config export PKG_CONFIG_PATH ?= /usr/local/lib/pkgconfig +export VC_FUSE_PACKAGE := fuse +export VC_OSX_FUSET ?= 0 export WX_CONFIG ?= wx-config export WX_CONFIG_ARGS := --unicode WX_CONFIGURE_FLAGS := export WXCONFIG_CFLAGS := export WXCONFIG_CXXFLAGS := WX_ROOT ?= $(BASE_DIR)/wxWidgets export TC_BUILD_CONFIG := Release +ifeq "$(origin WITHFUSET)" "command line" + ifneq "$(WITHFUSET)" "0" + VC_OSX_FUSET := 1 + endif +endif + ifeq "$(origin DEBUG)" "command line" ifneq "$(DEBUG)" "0" TC_BUILD_CONFIG := Debug endif endif ifeq "$(origin NOGUI)" "command line" export TC_NO_GUI := 1 C_CXX_FLAGS += -DTC_NO_GUI -DwxUSE_GUI=0 WX_CONFIGURE_FLAGS += --disable-gui endif ifdef PKCS11_INC C_CXX_FLAGS += -I$(PKCS11_INC) else C_CXX_FLAGS += -I$(CURDIR)/PKCS11 endif ifeq "$(origin RESOURCEDIR)" "command line" C_CXX_FLAGS += -DTC_RESOURCE_DIR="$(RESOURCEDIR)" endif ifneq "$(origin VERBOSE)" "command line" MAKEFLAGS += -s endif ifeq "$(origin WXSTATIC)" "command line" export VC_WX_STATIC := 1 WX_CONFIG = $(WX_BUILD_DIR)/wx-config WX_CONFIG_ARGS += --static ifneq "$(WXSTATIC)" "FULL" export VC_WX_MINIMAL := 1 endif endif -ifeq "$(origin INDICATOR)" "command line" - ifneq (,$(findstring gtk3,$(shell $(WX_CONFIG) --selected-config))) - INDICATOR_LIBRARY=ayatana-appindicator3-0.1 - else - INDICATOR_LIBRARY=ayatana-appindicator-0.1 - endif - export LIBS += $(shell pkg-config --libs $(INDICATOR_LIBRARY)) - C_CXX_FLAGS += $(shell pkg-config --cflags $(INDICATOR_LIBRARY)) -DHAVE_INDICATORS -endif - #------ Release configuration ------ ifeq "$(TC_BUILD_CONFIG)" "Release" C_CXX_FLAGS += -O2 -fno-strict-aliasing # Do not enable strict aliasing export WX_BUILD_DIR ?= $(BASE_DIR)/wxrelease WX_CONFIGURE_FLAGS += --disable-debug_flag --disable-debug_gdb --disable-debug_info else #------ Debug configuration ------ C_CXX_FLAGS += -DDEBUG CXXFLAGS += -fno-default-inline -Wno-unused-function -Wno-unused-variable export WX_BUILD_DIR ?= $(BASE_DIR)/wxdebug WX_CONFIGURE_FLAGS += --enable-debug_flag --disable-debug_gdb --disable-debug_info endif #------ Debugger configuration ------ ifeq "$(origin DEBUGGER)" "command line" C_CXX_FLAGS += -ggdb WX_CONFIGURE_FLAGS += --enable-debug_gdb --enable-debug_info endif #------ Platform configuration ------ export PLATFORM := "Unknown" export PLATFORM_ARCH := "Unknown" export PLATFORM_UNSUPPORTED := 0 export CPU_ARCH ?= unknown export SIMD_SUPPORTED := 0 export DISABLE_AESNI ?= 0 +export ENABLE_WOLFCRYPT ?= 0 export GCC_GTEQ_440 := 0 export GCC_GTEQ_430 := 0 +export GTK_VERSION := 0 ARCH ?= $(shell uname -m) ifneq (,$(filter i386 i486 i586 i686 x86,$(ARCH))) CPU_ARCH = x86 ASFLAGS += -f elf32 -D __BITS__=32 else ifneq (,$(filter x86_64 x86-64 amd64 x64,$(ARCH))) CPU_ARCH = x64 ASFLAGS += -f elf64 -D __BITS__=64 else ifneq (,$(filter armv7l,$(ARCH))) PLATFORM_ARCH := armv7 CPU_ARCH = armv7 endif ifeq "$(origin NOASM)" "command line" CPU_ARCH = unknown C_CXX_FLAGS += -DCRYPTOPP_DISABLE_X86ASM endif ifeq "$(CPU_ARCH)" "x86" PLATFORM_ARCH := i386 SIMD_SUPPORTED := 1 C_CXX_FLAGS += -D TC_ARCH_X86 else ifeq "$(CPU_ARCH)" "x64" PLATFORM_ARCH := amd64 SIMD_SUPPORTED := 1 C_CXX_FLAGS += -D TC_ARCH_X64 endif ifeq "$(origin NOSSE2)" "command line" SIMD_SUPPORTED := 0 endif ifeq "$(origin NOAESNI)" "command line" DISABLE_AESNI := 1 endif +ifeq "$(origin WOLFCRYPT)" "command line" + ENABLE_WOLFCRYPT := 1 + C_CXX_FLAGS += -DWOLFCRYPT_BACKEND + export LIBS += -lwolfssl + export LD_LIBRARY_PATH=/usr/local/lib +endif + #------ Linux configuration ------ ifeq "$(shell uname -s)" "Linux" PLATFORM := Linux C_CXX_FLAGS += -DTC_UNIX -DTC_LINUX # PCSC - C_CXX_FLAGS += $(shell pkg-config --cflags libpcsclite) - - - # GNU GCC version 11 and higher compile with -std=gnu++17 by default - # which breaks "byte" definitions in Crypto++ library. So set - # -std=gnu++14 instead. - GCC11PLUS := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 11) - ifeq "$(GCC11PLUS)" "1" - CXXFLAGS += -std=gnu++14 - endif + C_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags libpcsclite) + + # Extract the major and minor version numbers of GCC in a combined format for easy comparison + GCC_VERSION := $(shell $(CC) -dumpversion | awk -F. '{printf "%d%02d", $$1, $$2}') + + # Set the C++ standard based on the version numbers + ifeq ($(shell expr $(GCC_VERSION) \< 408), 1) + # GCC version below 4.8 support minimal C++11 features through the switch -std=c++0x + CXXFLAGS += -std=c++0x + else ifeq ($(GCC_VERSION), 408) + # GCC version 4.8 supports C++11 features through the switch -std=c++11 + CXXFLAGS += -std=c++11 + else ifeq ($(shell expr $(GCC_VERSION) \>= 1100), 1) + # GNU GCC version 11 and higher compile with -std=gnu++17 by default + # which breaks "byte" definitions in Crypto++ library. So set -std=gnu++14 instead. + CXXFLAGS += -std=gnu++14 + endif + # Linked in GCC versions below 6 was setting large value for MAXPAGESIZE which is not good for ASLR security + # So, we need to manually add the linker flag "-z max-page-size=4096" to set the maximum page size to 4KB + # in order to improve ASLR security. Starting from GCC 6, the default value of MAXPAGESIZE is 4KB. + ifeq ($(shell expr $(GCC_VERSION) \< 600), 1) + LFLAGS += -Wl,-z,max-page-size=4096 + endif ifeq "$(SIMD_SUPPORTED)" "1" CFLAGS += -msse2 CXXFLAGS += -msse2 GCC_GTEQ_440 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40400) GCC_GTEQ_430 := $(shell expr `$(CC) -dumpversion | sed -e 's/\.\([0-9][0-9]\)/\1/g' -e 's/\.\([0-9]\)/0\1/g' -e 's/^[0-9]\{3,4\}$$/&00/' -e 's/^[0-9]\{1,2\}$$/&0000/'` \>= 40300) ifeq "$(DISABLE_AESNI)" "1" CFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI CXXFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI else ifeq "$(GCC_GTEQ_440)" "1" CFLAGS += -maes CXXFLAGS += -maes endif endif ifeq "$(GCC_GTEQ_430)" "1" ifeq "$(origin SSSE3)" "command line" CFLAGS += -mssse3 CXXFLAGS += -mssse3 endif ifeq "$(origin SSE41)" "command line" CFLAGS += -mssse3 -msse4.1 CXXFLAGS += -mssse3 -msse4.1 endif endif endif ifeq "$(TC_BUILD_CONFIG)" "Release" C_CXX_FLAGS += -fdata-sections -ffunction-sections -fpie LFLAGS += -Wl,--gc-sections -pie ifneq "$(shell ld --help 2>&1 | grep sysv | wc -l)" "0" LFLAGS += -Wl,--hash-style=sysv endif WXCONFIG_CFLAGS += -fdata-sections -ffunction-sections -fpie WXCONFIG_CXXFLAGS += -fdata-sections -ffunction-sections -fpie endif ifneq "$(origin WXSTATIC)" "command line" LFLAGS += -ldl else GCC5USED := $(shell expr `$(CC) -dumpversion | cut -f1 -d.` \>= 5) ifeq "$(GCC5USED)" "1" CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0 WXCONFIG_CXXFLAGS += -D_GLIBCXX_USE_CXX11_ABI=0 endif endif ifeq "$(origin NOSSE2)" "command line" CFLAGS += -mno-sse2 CXXFLAGS += -mno-sse2 WXCONFIG_CFLAGS += -mno-sse2 WXCONFIG_CXXFLAGS += -mno-sse2 endif - - ifeq "$(origin WITHGTK3)" "command line" - WX_CONFIGURE_FLAGS += --with-gtk=3 - else - WX_CONFIGURE_FLAGS += --with-gtk=2 - endif - endif #------ Mac OS X configuration ------ ifeq "$(shell uname -s)" "Darwin" PLATFORM := MacOSX APPNAME := VeraCrypt - export VC_OSX_TARGET ?= 10.7 - export VC_OSX_SDK ?= $(VC_OSX_TARGET) + export VC_OSX_TARGET ?= 12 + # use the output of the command "xcrun --show-sdk-version" to set the SDK version if not set + export VC_OSX_SDK ?= $(shell xcrun --show-sdk-version) #check to see if XCode 3 path exists.Otherwise, use XCode 4 path VC_OSX_SDK_PATH := /Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk ifeq ($(wildcard $(VC_OSX_SDK_PATH)/SDKSettings.plist),) - VC_OSX_SDK_PATH := /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX$(VC_OSX_SDK).sdk + VC_OSX_SDK_PATH := $(shell xcrun --sdk macosx$(VC_OSX_SDK) --show-sdk-path) + ifeq ($(VC_OSX_SDK_PATH),) +$(error Specified SDK version was not found, ensure your active developer directory is correct through xcode-select) + endif endif #----- Legacy build if OSX <= 10.8: we build both 32-bit and 64-bit ---- ifneq (,$(filter 10.6 10.7 10.8,$(VC_OSX_TARGET))) export VC_LEGACY_BUILD := 1 endif CC := gcc CXX := g++ + GCC_GTEQ_430 := 1 + + CXXFLAGS += -std=c++11 C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_MACOSX -mmacosx-version-min=$(VC_OSX_TARGET) -isysroot $(VC_OSX_SDK_PATH) LFLAGS += -mmacosx-version-min=$(VC_OSX_TARGET) -Wl,-syslibroot $(VC_OSX_SDK_PATH) + # Xcode 15 linker emits a warning "no platform load command found" when linking object files generated by yasm + # To suppress this warning, we need to use -Wl,-ld_classic flag in order to use the old ld64 linker + # https://mjtsai.com/blog/2024/03/15/xcode-15-no-platform-load-command-found/ + # We can check whether newer linker is in use if ld -v reports dyld instead of ld64. + ifeq ($(shell xcrun --sdk macosx$(VC_OSX_SDK) ld -v 2>&1 | grep -oE 'PROJECT:[^-]+' | cut -d: -f2),dyld) + LFLAGS += -Wl,-ld_classic + endif + WX_CONFIGURE_FLAGS += --with-macosx-version-min=$(VC_OSX_TARGET) --with-macosx-sdk=$(VC_OSX_SDK_PATH) - ifeq "$(CPU_ARCH)" "x64" - CPU_ARCH = x86 + ifneq "$(VC_OSX_FUSET)" "0" + C_CXX_FLAGS += -DVC_MACOSX_FUSET + VC_FUSE_PACKAGE := fuse-t endif - - ifeq "$(CPU_ARCH)" "arm64" - CPU_ARCH = x86 + + # Set x86 assembly flags (-msse2, -mssse3, -msse4.1) + # Apply flags if SIMD_SUPPORTED is 1 or if not in local development build (we are creating universal binary in this case) + ifneq "$(LOCAL_DEVELOPMENT_BUILD)" "true" + SIMD_SUPPORTED = 1 endif - CFLAGS += -msse2 - CXXFLAGS += -msse2 + ifeq "$(SIMD_SUPPORTED)" "1" + CFLAGS += -msse2 + CXXFLAGS += -msse2 - ifeq "$(origin SSSE3)" "command line" - CFLAGS += -mssse3 - CXXFLAGS += -mssse3 - endif + ifeq "$(origin SSSE3)" "command line" + CFLAGS += -mssse3 + CXXFLAGS += -mssse3 + endif - ifeq "$(origin SSE41)" "command line" - CFLAGS += -mssse3 -msse4.1 - CXXFLAGS += -mssse3 -msse4.1 + ifeq "$(origin SSE41)" "command line" + CFLAGS += -mssse3 -msse4.1 + CXXFLAGS += -mssse3 -msse4.1 + endif endif - AS := $(BASE_DIR)/Build/Tools/MacOSX/yasm + AS ?= $(BASE_DIR)/Build/Tools/MacOSX/yasm export ASFLAGS32 := -D __GNUC__ -D __YASM__ -D __BITS__=32 --prefix=_ -f macho32 export ASFLAGS64 := -D __GNUC__ -D __YASM__ -D __BITS__=64 --prefix=_ -f macho64 ifeq "$(TC_BUILD_CONFIG)" "Release" - export DISABLE_PRECOMPILED_HEADERS := 1 + export DISABLE_PRECOMPILED_HEADERS := 1 - S := $(C_CXX_FLAGS) - C_CXX_FLAGS = $(subst -MMD,,$(S)) + C_CXX_FLAGS := $(subst -MMD,,$(C_CXX_FLAGS)) -gfull + LFLAGS += -Wl,-dead_strip - C_CXX_FLAGS += -gfull -arch x86_64 - LFLAGS += -Wl,-dead_strip -arch x86_64 - - WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-svg + # Initialize architecture flag + ARCH_FLAG := -arch x86_64 - #----- Legacy build: we build both 32-bit and 64-bit ---- - ifdef VC_LEGACY_BUILD - C_CXX_FLAGS += -arch i386 - LFLAGS += -arch i386 - WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64 + # Set architecture flags based on build type and CPU architecture + ifeq "$(LOCAL_DEVELOPMENT_BUILD)" "true" + ifeq "$(CPU_ARCH)" "arm64" + ARCH_FLAG := -arch arm64 + endif + WX_CONFIGURE_FLAGS += --disable-universal_binary else - CXXFLAGS += -std=c++11 - C_CXX_FLAGS += -arch arm64 - LFLAGS += -arch arm64 - WX_CONFIGURE_FLAGS += --enable-universal_binary=arm64,x86_64 + # Legacy build settings + ifdef VC_LEGACY_BUILD + ARCH_FLAG += -arch i386 + WX_CONFIGURE_FLAGS += --enable-universal_binary=i386,x86_64 + else + # Non-development build defaults to universal binary for arm64 and x86_64 + ARCH_FLAG += -arch arm64 + WX_CONFIGURE_FLAGS += --enable-universal_binary=arm64,x86_64 + endif endif + # Apply architecture flags + C_CXX_FLAGS += $(ARCH_FLAG) + LFLAGS += $(ARCH_FLAG) + + WX_CONFIGURE_FLAGS += --without-libpng --disable-gif --disable-pcx --disable-tga --disable-iff --disable-svg WXCONFIG_CFLAGS += -gfull WXCONFIG_CXXFLAGS += -gfull else WX_CONFIGURE_FLAGS += --disable-universal_binary endif endif #------ FreeBSD configuration ------ ifeq "$(shell uname -s)" "FreeBSD" PLATFORM := FreeBSD PLATFORM_UNSUPPORTED := 1 C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_FREEBSD # PCSC - C_CXX_FLAGS += $(shell pkg-config --cflags libpcsclite) + C_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags libpcsclite) CC := cc CXX := c++ + + GCC_GTEQ_430 := 1 ifeq "$(TC_BUILD_CONFIG)" "Release" C_CXX_FLAGS += -fdata-sections -ffunction-sections -fpie LFLAGS += -Wl,--gc-sections -pie ifneq "$(shell ld --help 2>&1 | grep sysv | wc -l)" "0" LFLAGS += -Wl,--hash-style=sysv endif WXCONFIG_CFLAGS += -fpie -fPIC WXCONFIG_CXXFLAGS += -fpie -fPIC endif ifeq "$(SIMD_SUPPORTED)" "1" CFLAGS += -msse2 CXXFLAGS += -msse2 ifeq "$(DISABLE_AESNI)" "1" CFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI CXXFLAGS += -mno-aes -DCRYPTOPP_DISABLE_AESNI else CFLAGS += -maes CXXFLAGS += -maes endif ifeq "$(origin SSSE3)" "command line" CFLAGS += -mssse3 CXXFLAGS += -mssse3 endif ifeq "$(origin SSE41)" "command line" CFLAGS += -mssse3 -msse4.1 CXXFLAGS += -mssse3 -msse4.1 endif endif ifeq "$(origin NOSSE2)" "command line" CFLAGS += -mno-sse2 CXXFLAGS += -mno-sse2 WXCONFIG_CFLAGS += -mno-sse2 WXCONFIG_CXXFLAGS += -mno-sse2 endif endif #------ OpenBSD configuration ------ ifeq "$(shell uname -s)" "OpenBSD" PLATFORM := OpenBSD PLATFORM_UNSUPPORTED := 1 C_CXX_FLAGS += -DTC_UNIX -DTC_BSD -DTC_OPENBSD # PCSC - C_CXX_FLAGS += $(shell pkg-config --cflags libpcsclite) + C_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags libpcsclite) CC := cc CXX := c++ + GCC_GTEQ_430 := 1 + ifeq "$(TC_BUILD_CONFIG)" "Release" C_CXX_FLAGS += -fdata-sections -ffunction-sections -fpie LFLAGS += -Wl,--gc-sections -pie WXCONFIG_CFLAGS += -fpie -fPIC WXCONFIG_CXXFLAGS += -fpie -fPIC endif endif #------ Solaris configuration ------ ifeq "$(shell uname -s)" "SunOS" PLATFORM := Solaris PLATFORM_UNSUPPORTED := 1 C_CXX_FLAGS += -DTC_UNIX -DTC_SOLARIS WX_CONFIGURE_FLAGS += --with-gtk # PCSC - C_CXX_FLAGS += $(shell pkg-config --cflags libpcsclite) + C_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags libpcsclite) endif +ifneq (,$(filter Linux FreeBSD OpenBSD,$(PLATFORM))) + # Determine GTK version + GTK_VERSION := $(shell $(PKG_CONFIG) --modversion gtk+-3.0 2>/dev/null | grep -o '^3' || echo 2) + ifeq ($(GTK_VERSION),3) + WX_CONFIGURE_FLAGS += --with-gtk=3 + else + WX_CONFIGURE_FLAGS += --with-gtk=2 + endif + + ifeq "$(origin INDICATOR)" "command line" + ifeq ($(GTK_VERSION),3) + INDICATOR_LIBRARY=ayatana-appindicator3-0.1 + else + INDICATOR_LIBRARY=ayatana-appindicator-0.1 + endif + export AYATANA_LIBS += $(shell $(PKG_CONFIG) --libs $(INDICATOR_LIBRARY)) + C_CXX_FLAGS += $(shell $(PKG_CONFIG) --cflags $(INDICATOR_LIBRARY)) -DHAVE_INDICATORS + endif +endif #------ Common configuration ------ CFLAGS := $(C_CXX_FLAGS) $(CFLAGS) $(TC_EXTRA_CFLAGS) CXXFLAGS := $(C_CXX_FLAGS) $(CXXFLAGS) $(TC_EXTRA_CXXFLAGS) LFLAGS := $(LFLAGS) $(TC_EXTRA_LFLAGS) WX_CONFIGURE_FLAGS += --enable-unicode -disable-shared --disable-dependency-tracking --enable-exceptions --enable-std_string --enable-dataobj --enable-mimetype ifdef VC_WX_MINIMAL WX_CONFIGURE_FLAGS += --disable-protocol --disable-protocols --disable-url --disable-ipc --disable-sockets --without-libcurl --disable-fs_inet --disable-ole --disable-docview --disable-clipboard \ --disable-help --disable-html --disable-mshtmlhelp --disable-htmlhelp --disable-mdi --disable-metafile --disable-addremovectrl --disable-webview \ --disable-xrc --disable-aui --disable-postscript --disable-printarch \ --disable-arcstream --disable-fs_archive --disable-fs_zip --disable-tarstream --disable-zipstream \ --disable-animatectrl --disable-bmpcombobox --disable-calendar --disable-caret --disable-checklst --disable-collpane --disable-colourpicker --disable-comboctrl \ --disable-datepick --disable-display --disable-dirpicker --disable-filepicker --disable-fontpicker --disable-grid --disable-dataviewctrl \ --disable-listbook --disable-odcombobox --disable-sash --disable-searchctrl --disable-slider --disable-splitter --disable-togglebtn \ --disable-toolbar --disable-tbarnative --disable-treebook --disable-toolbook --disable-tipwindow --disable-popupwin \ --disable-commondlg --disable-aboutdlg --disable-coldlg --disable-finddlg --disable-fontdlg --disable-numberdlg --disable-splash \ --disable-tipdlg --disable-progressdlg --disable-wizarddlg --disable-miniframe --disable-splines --disable-palette \ --disable-richtext --disable-dialupman --disable-debugreport --disable-filesystem --disable-rearrangectrl --disable-treelist --disable-richmsgdlg \ --disable-richtooltip --disable-propgrid --disable-stc --without-libnotify \ --without-gtkprint --without-gnomevfs --disable-fsvolume --disable-fswatcher \ --disable-sound --disable-mediactrl --disable-joystick --disable-apple_ieee \ --disable-gif --disable-pcx --disable-tga --disable-iff --disable-gif --disable-pnm --disable-svg \ --without-expat --without-libtiff --without-libjpeg --without-libpng -without-regex --without-zlib -ifeq "$(PLATFORM)" "Linux" +ifneq (,$(filter Linux FreeBSD,$(PLATFORM))) WX_CONFIGURE_FLAGS += --disable-tooltips -ifneq "$(origin WITHGTK3)" "command line" +ifneq ($(GTK_VERSION),3) WX_CONFIGURE_FLAGS += --disable-graphics_ctx endif else WX_CONFIGURE_FLAGS += --disable-graphics_ctx endif +else +# Disable libtiff on macOS +ifeq "$(PLATFORM)" "MacOSX" + WX_CONFIGURE_FLAGS += --without-libtiff +endif endif #------ Project build ------ PROJ_DIRS := Platform Volume Driver/Fuse Core Main .PHONY: all clean wxbuild all clean: @if pwd | grep -q ' '; then echo 'Error: source code is stored in a path containing spaces' >&2; exit 1; fi @for DIR in $(PROJ_DIRS); do \ PROJ=$$(echo $$DIR | cut -d/ -f1); \ $(MAKE) -C $$DIR -f $$PROJ.make NAME=$$PROJ $(MAKECMDGOALS) || exit $?; \ export LIBS="$(BASE_DIR)/$$DIR/$$PROJ.a $$LIBS"; \ done install: $(MAKE) -C Main -f Main.make NAME=Main install package: $(MAKE) -C Main -f Main.make NAME=Main package #------ wxWidgets build ------ ifeq "$(MAKECMDGOALS)" "wxbuild" CFLAGS := CXXFLAGS := LFLAGS := diff --git a/src/Mount/Favorites.cpp b/src/Mount/Favorites.cpp index 93b7a5a6..de4d5a08 100644 --- a/src/Mount/Favorites.cpp +++ b/src/Mount/Favorites.cpp @@ -590,61 +590,61 @@ namespace VeraCrypt } } DWORD size; char *favoritesXml = LoadFile (favoritesFilePath.c_str(), &size); if (systemFavorites && !IsAdmin() && !noUacElevation) DeleteFile (GetConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES)); char *xml = favoritesXml; char mountPoint[MAX_PATH], volume[MAX_PATH]; if (xml == NULL) return; while (xml = XmlFindElement (xml, "volume")) { FavoriteVolume favorite; XmlGetAttributeText (xml, "mountpoint", mountPoint, sizeof (mountPoint)); favorite.MountPoint = Utf8StringToWide (mountPoint); XmlGetNodeText (xml, volume, sizeof (volume)); favorite.Path = Utf8StringToWide (volume); char label[1024]; XmlGetAttributeText (xml, "ID", label, sizeof (label)); if (strlen (label) == (2*VOLUME_ID_SIZE)) { - std::vector<byte> arr; + std::vector<uint8> arr; if (HexWideStringToArray (Utf8StringToWide (label).c_str(), arr) && arr.size() == VOLUME_ID_SIZE) { memcpy (favorite.VolumeID, &arr[0], VOLUME_ID_SIZE); } } XmlGetAttributeText (xml, "label", label, sizeof (label)); favorite.Label = Utf8StringToWide (label); XmlGetAttributeText (xml, "pim", label, sizeof (label)); if (strlen(label) == 0) { /* support old attribute name before it was changed to PIM*/ XmlGetAttributeText (xml, "pin", label, sizeof (label)); } if (label[0]) { favorite.Pim = strtol (label, NULL, 10); if (favorite.Pim < 0 || favorite.Pim > (systemFavorites? MAX_BOOT_PIM_VALUE : MAX_PIM_VALUE)) favorite.Pim = -1; } else favorite.Pim = -1; char boolVal[2]; XmlGetAttributeText (xml, "readonly", boolVal, sizeof (boolVal)); if (boolVal[0]) favorite.ReadOnly = (boolVal[0] == '1'); XmlGetAttributeText (xml, "removable", boolVal, sizeof (boolVal)); diff --git a/src/Mount/MainCom.cpp b/src/Mount/MainCom.cpp index 9226e15b..ce6803ac 100644 --- a/src/Mount/MainCom.cpp +++ b/src/Mount/MainCom.cpp @@ -181,60 +181,65 @@ public: virtual DWORD STDMETHODCALLTYPE RestoreEfiSystemLoader () { return BaseCom::RestoreEfiSystemLoader (); } virtual DWORD STDMETHODCALLTYPE GetEfiBootDeviceNumber (BSTR* pSdn) { return BaseCom::GetEfiBootDeviceNumber (pSdn); } virtual DWORD STDMETHODCALLTYPE GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { return BaseCom::GetSecureBootConfig (pSecureBootEnabled, pVeraCryptKeysLoaded); } virtual DWORD STDMETHODCALLTYPE WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg) { return BaseCom::WriteEfiBootSectorUserConfig (userConfig, customUserMessage,pim, hashAlg); } virtual DWORD STDMETHODCALLTYPE UpdateSetupConfigFile (BOOL bForInstall) { return BaseCom::UpdateSetupConfigFile (bForInstall); } virtual DWORD STDMETHODCALLTYPE NotifyService (DWORD dwNotifyCode) { return BaseCom::NotifyService (dwNotifyCode); } + virtual DWORD STDMETHODCALLTYPE FastFileResize (BSTR filePath, __int64 fileSize) + { + return BaseCom::FastFileResize (filePath, fileSize); + } + protected: DWORD MessageThreadId; LONG RefCount; }; extern "C" BOOL ComServerMain () { SetProcessShutdownParameters (0x100, 0); TrueCryptFactory<TrueCryptMainCom> factory (GetCurrentThreadId ()); DWORD cookie; if (IsUacSupported ()) UacElevated = TRUE; if (CoRegisterClassObject (CLSID_TrueCryptMainCom, (LPUNKNOWN) &factory, CLSCTX_LOCAL_SERVER, REGCLS_SINGLEUSE, &cookie) != S_OK) return FALSE; MSG msg; while (int r = GetMessageW (&msg, NULL, 0, 0)) { if (r == -1) return FALSE; TranslateMessage (&msg); DispatchMessageW (&msg); if (msg.message == WM_APP @@ -243,102 +248,102 @@ extern "C" BOOL ComServerMain () break; } CoRevokeClassObject (cookie); return TRUE; } static BOOL ComGetInstance (HWND hWnd, ITrueCryptMainCom **tcServer) { return ComGetInstanceBase (hWnd, CLSID_TrueCryptMainCom, IID_ITrueCryptMainCom, (void **) tcServer); } ITrueCryptMainCom *GetElevatedInstance (HWND parent) { ITrueCryptMainCom *instance; if (!ComGetInstance (parent, &instance)) throw UserAbort (SRC_POS); return instance; } extern "C" int UacBackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, wchar_t *lpszVolume) { CComPtr<ITrueCryptMainCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) { CComBSTR volumeBstr; BSTR bstr = W2BSTR(lpszVolume); if (bstr) { volumeBstr.Attach (bstr); r = tc->BackupVolumeHeader ((__int64) hwndDlg, bRequireConfirmation, volumeBstr); } else r = ERR_OUTOFMEMORY; } else r = -1; CoUninitialize (); return r; } extern "C" int UacRestoreVolumeHeader (HWND hwndDlg, wchar_t *lpszVolume) { CComPtr<ITrueCryptMainCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) { CComBSTR volumeBstr; BSTR bstr = W2BSTR(lpszVolume); if (bstr) { volumeBstr.Attach (bstr); r = tc->RestoreVolumeHeader ((__int64) hwndDlg, volumeBstr); } else r = ERR_OUTOFMEMORY; } else r = -1; CoUninitialize (); return r; } extern "C" int UacChangePwd (wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg) { CComPtr<ITrueCryptMainCom> tc; int r; - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if (ComGetInstance (hwndDlg, &tc)) { CComBSTR bstrVolume (lpszVolume); WaitCursor (); r = tc->ChangePasswordEx3 (bstrVolume, oldPassword, old_pkcs5, old_pim, newPassword, pkcs5, pim, wipePassCount, (__int64) hwndDlg); NormalCursor (); } else r = -1; CoUninitialize (); return r; } diff --git a/src/Mount/MainCom.idl b/src/Mount/MainCom.idl index 6ad9dd1b..06c2e48f 100644 --- a/src/Mount/MainCom.idl +++ b/src/Mount/MainCom.idl @@ -27,41 +27,42 @@ library TrueCryptMainCom helpstring("VeraCrypt Main UAC Support Interface") ] interface ITrueCryptMainCom : IUnknown { void AnalyzeKernelMiniDump (__int64 hwndDlg); int BackupVolumeHeader (__int64 hwndDlg, BOOL bRequireConfirmation, BSTR lpszVolume); DWORD CallDriver (DWORD ioctl, BSTR input, BSTR *output); int ChangePassword (BSTR volumePath, Password *oldPassword, Password *newPassword, int pkcs5, int wipePassCount, __int64 hWnd); DWORD CopyFile (BSTR sourceFile, BSTR destinationFile); DWORD DeleteFile (BSTR file); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); DWORD ReadWriteFile (BOOL write, BOOL device, BSTR filePath, BSTR *bufferBstr, unsigned __int64 offset, unsigned __int32 size, DWORD *sizeDone); DWORD RegisterFilterDriver (BOOL registerDriver, int filterType); DWORD RegisterSystemFavoritesService (BOOL registerService); int RestoreVolumeHeader (__int64 hwndDlg, BSTR lpszVolume); DWORD SetDriverServiceStartType (DWORD startType); DWORD WriteLocalMachineRegistryDwordValue (BSTR keyPath, BSTR valueName, DWORD value); int ChangePasswordEx (BSTR volumePath, Password *oldPassword, int old_pkcs5, Password *newPassword, int pkcs5, int wipePassCount, __int64 hWnd); int ChangePasswordEx2 (BSTR volumePath, Password *oldPassword, int old_pkcs5, Password *newPassword, int pkcs5, int wipePassCount, __int64 hWnd); int ChangePasswordEx3 (BSTR volumePath, Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, __int64 hWnd); DWORD GetFileSize (BSTR filePath, unsigned __int64* pSize); DWORD DeviceIoControl (BOOL readOnly, BOOL device, BSTR filePath, DWORD dwIoControlCode, BSTR input, BSTR *output); DWORD InstallEfiBootLoader (BOOL preserveUserConfig, BOOL hiddenOSCreation, int pim, int hashAlg); DWORD BackupEfiSystemLoader (); DWORD RestoreEfiSystemLoader (); DWORD GetEfiBootDeviceNumber (BSTR* pSdn); DWORD WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMessage, int pim, int hashAlg); DWORD UpdateSetupConfigFile (BOOL bForInstall); DWORD GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded); DWORD NotifyService (DWORD dwNotifyCode); + DWORD FastFileResize (BSTR filePath, __int64 fileSize); }; [ uuid(FE8B3B95-C80C-41f7-830F-FBA271C26F7E), helpstring("VeraCrypt Main UAC Support Coclass") ] coclass TrueCryptMainCom { [default] interface ITrueCryptMainCom; } } diff --git a/src/Mount/Mount.c b/src/Mount/Mount.c index 83ae9a9c..a851ebef 100644 --- a/src/Mount/Mount.c +++ b/src/Mount/Mount.c @@ -268,61 +268,61 @@ static void UnregisterWtsAndPowerNotification(HWND hWnd) } static std::vector<MSXML2::IXMLDOMNodePtr> GetReadChildNodes (MSXML2::IXMLDOMNodeListPtr childs) { std::vector<MSXML2::IXMLDOMNodePtr> list; if (childs && childs->Getlength()) { for (long i = 0; i < childs->Getlength(); i++) { MSXML2::IXMLDOMNodePtr node = childs->Getitem(i); if (node) { //skip comments if (node->GetnodeType() == NODE_COMMENT) continue; // skip root xml node if (node->GetbaseName().GetBSTR() && (0 == strcmp ("xml", (const char*) node->GetbaseName()))) continue; list.push_back (node); } } } return list; } static bool validateDcsPropXml(const char* xmlData) { bool bValid = false; - HRESULT hr = CoInitialize(NULL); + HRESULT hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); if(FAILED(hr)) return false; else { MSXML2::IXMLDOMDocumentPtr pXMLDom; hr= pXMLDom.CreateInstance(__uuidof(MSXML2::DOMDocument60), NULL, CLSCTX_INPROC_SERVER); if (SUCCEEDED(hr)) { try { pXMLDom->async = VARIANT_FALSE; pXMLDom->validateOnParse = VARIANT_FALSE; pXMLDom->resolveExternals = VARIANT_FALSE; if(pXMLDom->loadXML(xmlData) == VARIANT_TRUE && pXMLDom->hasChildNodes()) { MSXML2::IXMLDOMNodePtr veracryptNode, configurationNode, configNode; std::vector<MSXML2::IXMLDOMNodePtr> nodes = GetReadChildNodes (pXMLDom->GetchildNodes()); size_t nodesCount = nodes.size(); if (nodesCount == 1 && ((veracryptNode = nodes[0])->GetnodeType() == NODE_ELEMENT) && veracryptNode->GetnodeName().GetBSTR() && (0 == strcmp ((const char*) veracryptNode->GetnodeName(), "VeraCrypt")) && veracryptNode->hasChildNodes() ) { nodes = GetReadChildNodes (veracryptNode->GetchildNodes()); nodesCount = nodes.size(); if ((nodesCount == 1) @@ -675,61 +675,63 @@ void EnableDisableButtons (HWND hwndDlg) switch (x) { case TC_MLIST_ITEM_NONSYS_VOL: { SetWindowTextW (hOKButton, GetString ("UNMOUNT_BUTTON")); DisableSplitButton(hwndDlg, IDOK); EnableWindow (hOKButton, TRUE); // Invalid the button IDOK so that it will be redrawn InvalidateRect (hOKButton, NULL, TRUE); EnableMenuItem (GetMenu (hwndDlg), IDM_UNMOUNT_VOLUME, MF_ENABLED); EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_PROPERTIES), TRUE); EnableMenuItem (GetMenu (hwndDlg), IDM_VOLUME_PROPERTIES, MF_ENABLED); } break; case TC_MLIST_ITEM_SYS_PARTITION: case TC_MLIST_ITEM_SYS_DRIVE: EnableSplitButton(hwndDlg, IDOK); EnableWindow (hOKButton, FALSE); SetWindowTextW (hOKButton, GetString ("MOUNT_BUTTON")); // Invalid the button IDOK so that it will be redrawn InvalidateRect (hOKButton, NULL, TRUE); EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_PROPERTIES), TRUE); EnableMenuItem (GetMenu (hwndDlg), IDM_UNMOUNT_VOLUME, MF_GRAYED); break; case TC_MLIST_ITEM_FREE: default: +#if !defined(VCEXPANDER) EnableSplitButton(hwndDlg, IDOK); +#endif SetWindowTextW (hOKButton, GetString ("MOUNT_BUTTON")); // Invalid the button IDOK so that it will be redrawn InvalidateRect (hOKButton, NULL, TRUE); EnableWindow (GetDlgItem (hwndDlg, IDC_VOLUME_PROPERTIES), FALSE); EnableMenuItem (GetMenu (hwndDlg), IDM_VOLUME_PROPERTIES, MF_GRAYED); EnableMenuItem (GetMenu (hwndDlg), IDM_UNMOUNT_VOLUME, MF_GRAYED); } EnableWindow (GetDlgItem (hwndDlg, IDC_WIPE_CACHE), !IsPasswordCacheEmpty()); EnableMenuItem (GetMenu (hwndDlg), IDM_WIPE_CACHE, IsPasswordCacheEmpty() ? MF_GRAYED:MF_ENABLED); EnableMenuItem (GetMenu (hwndDlg), IDM_CLEAR_HISTORY, IsComboEmpty (GetDlgItem (hwndDlg, IDC_VOLUME)) ? MF_GRAYED:MF_ENABLED); } BOOL VolumeSelected (HWND hwndDlg) { return (GetWindowTextLength (GetDlgItem (hwndDlg, IDC_VOLUME)) > 0); } void GetVolumePath (HWND hwndDlg, LPWSTR szPath, int nMaxCount) { GetWindowText (GetDlgItem (hwndDlg, IDC_VOLUME), szPath, nMaxCount); CorrectFileName (szPath); } /* Returns TRUE if the last partition/drive selected via the Select Device dialog box was the system partition/drive and if it is encrypted. WARNING: This function is very fast but not always reliable (for example, if the user manually types a device path before Select Device is invoked during the session; after the Select Device dialog has been invoked at least once, the correct system device paths are cached). Therefore, it must NOT be used before performing any dangerous operations (such as header backup restore or formatting a @@ -1232,60 +1234,74 @@ void SaveSettings (HWND hwndDlg) } // Returns TRUE if system encryption or decryption had been or is in progress and has not been completed static BOOL SysEncryptionOrDecryptionRequired (void) { /* If you update this function, revise SysEncryptionOrDecryptionRequired() in Tcformat.c as well. */ try { BootEncStatus = BootEncObj->GetStatus(); } catch (Exception &e) { e.Show (MainDlg); } return (SystemEncryptionStatus == SYSENC_STATUS_ENCRYPTING || SystemEncryptionStatus == SYSENC_STATUS_DECRYPTING || ( BootEncStatus.DriveMounted && ( BootEncStatus.ConfiguredEncryptedAreaStart != BootEncStatus.EncryptedAreaStart || BootEncStatus.ConfiguredEncryptedAreaEnd != BootEncStatus.EncryptedAreaEnd ) ) ); } +// Returns TRUE if system encryption master key is vulnerable +static BOOL SysEncryptionMasterKeyVulnerable (void) +{ + try + { + BootEncStatus = BootEncObj->GetStatus(); + return (BootEncStatus.DriveMounted || BootEncStatus.DriveEncrypted) && BootEncStatus.MasterKeyVulnerable; + } + catch (Exception &) + { + return FALSE; + } +} + // Returns TRUE if the system partition/drive is completely encrypted static BOOL SysDriveOrPartitionFullyEncrypted (BOOL bSilent) { /* If you update this function, revise SysDriveOrPartitionFullyEncrypted() in Tcformat.c as well. */ try { BootEncStatus = BootEncObj->GetStatus(); } catch (Exception &e) { if (!bSilent) e.Show (MainDlg); } return (!BootEncStatus.SetupInProgress && BootEncStatus.ConfiguredEncryptedAreaEnd != 0 && BootEncStatus.ConfiguredEncryptedAreaEnd != -1 && BootEncStatus.ConfiguredEncryptedAreaStart == BootEncStatus.EncryptedAreaStart && BootEncStatus.ConfiguredEncryptedAreaEnd == BootEncStatus.EncryptedAreaEnd); } // Returns TRUE if the system partition/drive is being filtered by the TrueCrypt driver and the key data // was successfully decrypted (the device is fully ready to be encrypted or decrypted). Note that this // function does not examine whether the system device is encrypted or not (or to what extent). static BOOL SysEncDeviceActive (BOOL bSilent) { try { BootEncStatus = BootEncObj->GetStatus(); @@ -4487,61 +4503,61 @@ BOOL CALLBACK TravelerDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa EnableWindow (GetDlgItem (hwndDlg, IDT_MOUNT_SETTINGS), enabled); if (!bAutoRunWarningDisplayed && (lw == IDC_AUTORUN_MOUNT || lw == IDC_AUTORUN_START)) { bAutoRunWarningDisplayed = TRUE; Warning ("AUTORUN_MAY_NOT_ALWAYS_WORK", hwndDlg); } return 1; } if (lw == IDC_BROWSE_FILES) { wchar_t dstDir[MAX_PATH]; wchar_t volName[MAX_PATH] = { 0 }; GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstDir, ARRAYSIZE (dstDir)); if (BrowseFilesInDir (hwndDlg, "OPEN_TITLE", dstDir, volName, bHistory, FALSE, NULL)) SetDlgItemText (hwndDlg, IDC_VOLUME_NAME, wcschr (volName, L'\\') + 1); return 1; } if (lw == IDC_BROWSE_DIRS) { wchar_t dstPath[MAX_PATH * 2]; GetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath, ARRAYSIZE (dstPath)); - if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", dstPath)) + if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", dstPath, dstPath)) SetDlgItemText (hwndDlg, IDC_DIRECTORY, dstPath); return 1; } if (lw == IDCANCEL || lw == IDCLOSE) { EndDialog (hwndDlg, lw); return 1; } if (lw == IDC_CREATE) { BOOL copyWizard, copyExpander, bExplore, bCacheInDriver, bIncludePimInCache, bAutoRun, bAutoMount, bMountReadOnly; WCHAR dstDir[MAX_PATH + 1]; WCHAR srcPath[1024 + MAX_PATH + 1]; WCHAR dstPath[2*MAX_PATH + 1]; WCHAR appDir[1024]; WCHAR volName[MAX_PATH + 2]; int drive; WCHAR* ptr; GetDlgItemTextW (hwndDlg, IDC_DIRECTORY, dstDir, array_capacity (dstDir)); volName[0] = 0; GetDlgItemTextW (hwndDlg, IDC_VOLUME_NAME, volName + 1, (array_capacity (volName)) - 1); drive = (int) SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_GETCURSEL, 0, 0); drive = (int) SendDlgItemMessage (hwndDlg, IDC_DRIVELIST, CB_GETITEMDATA, drive, 0); @@ -5538,75 +5554,72 @@ retry: { for (i = 0; i < 26; i++) { if ((prevMountList.ulMountedDrives & (1 << i)) && (!(mountList.ulMountedDrives & (1 << i))) && IsNullTerminateString (prevMountList.wszLabel[i], 33) && wcslen (prevMountList.wszLabel[i])) { UpdateDriveCustomLabel (i, prevMountList.wszLabel[i], FALSE); } } } } BroadcastDeviceChange (DBT_DEVICEREMOVECOMPLETE, 0, prevMountList.ulMountedDrives & ~mountList.ulMountedDrives); RefreshMainDlg (hwndDlg); NormalCursor(); if (unmount.nReturnCode != 0) { if (forceUnmount) status = FALSE; if (unmount.nReturnCode == ERR_FILES_OPEN) { if (interact && IDYES == AskWarnYesNoTopmost ("UNMOUNTALL_LOCK_FAILED", hwndDlg)) { forceUnmount = TRUE; goto retry; } - if (IsOSAtLeast (WIN_7)) + // Undo SHCNE_DRIVEREMOVED + if ( DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, NULL, 0, &mountList, sizeof (mountList), &dwResult, NULL) + && mountList.ulMountedDrives + && (mountList.ulMountedDrives < (1 << 26)) + ) { - // Undo SHCNE_DRIVEREMOVED - if ( DeviceIoControl (hDriver, TC_IOCTL_GET_MOUNTED_VOLUMES, NULL, 0, &mountList, sizeof (mountList), &dwResult, NULL) - && mountList.ulMountedDrives - && (mountList.ulMountedDrives < (1 << 26)) - ) + for (i = 0; i < 26; i++) { - for (i = 0; i < 26; i++) + if (mountList.ulMountedDrives & (1 << i)) { - if (mountList.ulMountedDrives & (1 << i)) - { - wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 }; - SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); - } + wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 }; + SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); } } } return FALSE; } if (interact && !Silent) MessageBoxW (hwndDlg, GetString ("UNMOUNT_FAILED"), lpszTitle, MB_ICONERROR); } else { if (bBeep) MessageBeep (0xFFFFFFFF); } return status; } static BOOL MountAllDevicesThreadCode (HWND hwndDlg, BOOL bPasswordPrompt) { HWND driveList = GetDlgItem (MainDlg, IDC_DRIVELIST); int selDrive = ListView_GetSelectionMark (driveList); BOOL shared = FALSE, status = FALSE, bHeaderBakRetry = FALSE; int mountedVolCount = 0; vector <HostDevice> devices; int EffectiveVolumePkcs5 = CmdVolumePkcs5; /* Priority is given to command line parameters * Default values used only when nothing specified in command line @@ -6543,61 +6556,61 @@ static void ShowSystemEncryptionStatus (HWND hwndDlg) BootEncStatus.HiddenSystemPartitionStart, BootEncStatus.ConfiguredEncryptedAreaStart, BootEncStatus.ConfiguredEncryptedAreaEnd, BootEncStatus.EncryptedAreaStart, BootEncStatus.EncryptedAreaEnd, encryptedRatio); } if (!BootEncStatus.DriveEncrypted && !BootEncStatus.DriveMounted) { Info ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg); return; } DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_VOLUME_PROPERTIES), hwndDlg, (DLGPROC) VolumePropertiesDlgProc, (LPARAM) TRUE); } static void ResumeInterruptedNonSysInplaceEncProcess (BOOL bDecrypt) { // IMPORTANT: This function must not check any config files! Otherwise, if a config file was lost or corrupt, // the user would not be able resume encryption and the data on the volume would be inaccessible. LaunchVolCreationWizard (MainDlg, bDecrypt? L"/resumeinplacedec" : L"/zinplace", FALSE); } BOOL SelectContainer (HWND hwndDlg) { - if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE, NULL) == FALSE) + if (BrowseFiles (hwndDlg, "OPEN_VOL_TITLE", szFileName, bHistory, FALSE) == FALSE) return FALSE; AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory); EnableDisableButtons (hwndDlg); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); return TRUE; } BOOL SelectPartition (HWND hwndDlg) { RawDevicesDlgParam param; param.pszFileName = szFileName; INT_PTR nResult = DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_RAWDEVICES_DLG), hwndDlg, (DLGPROC) RawDevicesDlgProc, (LPARAM) & param); if (nResult == IDOK) { AddComboItem (GetDlgItem (hwndDlg, IDC_VOLUME), szFileName, bHistory); EnableDisableButtons (hwndDlg); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); return TRUE; } return FALSE; } static void WipeCache (HWND hwndDlg, BOOL silent) { DWORD dwResult; BOOL bResult; @@ -7072,61 +7085,61 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa StringCbCopyW (szRescueDiskExtension, sizeof (szRescueDiskExtension), L"zip"); else StringCbCopyW (szRescueDiskExtension, sizeof (szRescueDiskExtension), L"iso"); StringCbCopyW (szDefaultRescueDiskName, sizeof (szDefaultRescueDiskName), L"VeraCrypt Rescue Disk."); StringCbCatW (szDefaultRescueDiskName, sizeof (szDefaultRescueDiskName), szRescueDiskExtension); if (UsePreferences) { // General preferences LoadSettings (hwndDlg); // Save language to XML configuration file if it has been selected in the setup // so that other VeraCrypt programs will pick it up if (bLanguageSetInSetup) SaveSettings (hwndDlg); // Keyfiles LoadDefaultKeyFilesParam (); RestoreDefaultKeyFilesParam (); // if maximum password length is set to legacy value, abort if password in command line is longer if (bUseLegacyMaxPasswordLength && CmdVolumePasswordValid && (CmdVolumePassword.Length > MAX_LEGACY_PASSWORD)) AbortProcess ("COMMAND_LINE_ERROR"); } if (EnableMemoryProtection) { /* Protect this process memory from being accessed by non-admin users */ - EnableProcessProtection (); + ActivateMemoryProtection (); } if (ComServerMode) { InitDialog (hwndDlg); if (!ComServerMain ()) { handleWin32Error (hwndDlg, SRC_POS); exit (1); } exit (0); } if (CmdMountOptionsValid) mountOptions = CmdMountOptions; InitMainDialog (hwndDlg); try { if (IsHiddenOSRunning()) { uint32 driverConfig = ReadDriverConfigurationFlags(); if (BootEncObj->GetInstalledBootLoaderVersion() != VERSION_NUM) Warning ("UPDATE_TC_IN_HIDDEN_OS_TOO", hwndDlg); if ( !(driverConfig & TC_DRIVER_CONFIG_DISABLE_EVIL_MAID_ATTACK_DETECTION) && !BootEncObj->CheckBootloaderFingerprint ()) Warning ("BOOT_LOADER_FINGERPRINT_CHECK_FAILED", hwndDlg); } @@ -7411,91 +7424,103 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetForegroundWindow (h); if (TaskBarIconMutex == NULL) exit (0); } } HookMouseWheel (hwndDlg, IDC_VOLUME); // Register hot keys if (!RegisterAllHotkeys (hwndDlg, Hotkeys) && TaskBarIconMutex != NULL) // Warn only if we are the first instance of TrueCrypt Warning("HOTKEY_REGISTRATION_ERROR", hwndDlg); Silent = FALSE; GetMountList (&LastKnownMountList); SetTimer (hwndDlg, TIMER_ID_MAIN, TIMER_INTERVAL_MAIN, NULL); SetTimer (hwndDlg, TIMER_ID_UPDATE_DEVICE_LIST, TIMER_INTERVAL_UPDATE_DEVICE_LIST, NULL); taskBarCreatedMsg = RegisterWindowMessage (L"TaskbarCreated"); AllowMessageInUIPI (taskBarCreatedMsg); SetFocus (GetDlgItem (hwndDlg, IDC_DRIVELIST)); /* Check system encryption status */ if (!Quit) // Do not care about system encryption or in-place encryption if we were launched from the system startup sequence (the wizard was added to it too). { + BOOL bActionPerformed = FALSE; if (SysEncryptionOrDecryptionRequired ()) { if (!MutexExistsOnSystem (TC_MUTEX_NAME_SYSENC)) // If no instance of the wizard is currently taking care of system encryption { + bActionPerformed = TRUE; // We shouldn't block the mutex at this point if (SystemEncryptionStatus == SYSENC_STATUS_PRETEST || AskWarnYesNo ("SYSTEM_ENCRYPTION_RESUME_PROMPT", hwndDlg) == IDYES) { // The wizard was not launched during the system startup seq, or the user may have forgotten // to resume the encryption/decryption process. SystemDriveConfiguration config; try { config = BootEncObj->GetSystemDriveConfiguration (); } catch (Exception &e) { e.Show (MainDlg); } LaunchVolCreationWizard (hwndDlg, L"/csysenc", FALSE); } } } if (bInPlaceEncNonSysPending && !NonSysInplaceEncInProgressElsewhere()) { BOOL bDecrypt = FALSE; if (AskNonSysInPlaceEncryptionResume(hwndDlg, &bDecrypt) == IDYES) + { + bActionPerformed = TRUE; ResumeInterruptedNonSysInplaceEncProcess (bDecrypt); + } + } + + if (!bActionPerformed) + { + // display warning if the master key is vulnerable + if (SysEncryptionMasterKeyVulnerable()) + WarningTopMost ("ERR_SYSENC_XTS_MASTERKEY_VULNERABLE", hwndDlg); } } if (TaskBarIconMutex != NULL) RegisterWtsAndPowerNotification(hwndDlg); DoPostInstallTasks (hwndDlg); ResetCurrentDirectory (); } return 0; case WM_MOUSEWHEEL: return HandleDriveListMouseWheelEvent (uMsg, wParam, lParam, FALSE); case WM_CONTEXTMENU: { HWND hList = GetDlgItem (hwndDlg, IDC_DRIVELIST); // only handle if it is coming from keyboard and if the drive // list has focus. The other cases are handled elsewhere if ( (-1 == GET_X_LPARAM(lParam)) && (-1 == GET_Y_LPARAM(lParam)) && (GetFocus () == hList) ) { INT item = ListView_GetSelectionMark (hList); if (item >= 0) { nSelectedDriveIndex = item; DisplayDriveListContextMenu (hwndDlg, NULL); } } @@ -8084,72 +8109,74 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa { wchar_t selectedVolume [TC_MAX_PATH + 1]; GetVolumePath (hwndDlg, selectedVolume, ARRAYSIZE (selectedVolume)); KeyFilesApply (hwndDlg, &mountOptions.ProtectedHidVolPassword, hidVolProtKeyFilesParam.FirstKeyFile, selectedVolume); } } if (CheckMountList (hwndDlg, FALSE)) _beginthread(mountThreadFunction, 0, hwndDlg); } return 1; } /* Right click and drag&drop operations */ switch (((NM_LISTVIEW *) lParam)->hdr.code) { case NM_RCLICK: case LVN_BEGINRDRAG: /* If the mouse was moving while the right mouse button is pressed, popup menu would not open, because drag&drop operation would be initiated. Therefore, we're handling RMB drag-and-drop operations as well. */ { DisplayDriveListContextMenu (hwndDlg, lParam); return 1; } } } +#if !defined(VCEXPANDER) else { LPNMHDR pnmh = (LPNMHDR)lParam; if (pnmh->idFrom == IDOK && pnmh->code == BCN_DROPDOWN) { // Create a popup menu for the split button HMENU hmenu = CreateMountNoCacheDropdownMenu(); HandleMountButtonDropdown(pnmh->hwndFrom, hwndDlg, hmenu); DestroyMenu(hmenu); } } +#endif return 0; case WM_ERASEBKGND: return 0; case WM_COMMAND: if (lw == IDCANCEL || lw == IDC_EXIT) { EndMainDlg (hwndDlg); return 1; } if (lw == IDHELP || lw == IDM_HELP) { OpenPageHelp (hwndDlg, 0); return 1; } if (lw == IDM_ABOUT || lw == IDC_LOGO) { DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc); return 1; } if (lw == IDOK && LOWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) == TC_MLIST_ITEM_NONSYS_VOL || lw == IDM_UNMOUNT_VOLUME) { if (lw == IDM_UNMOUNT_VOLUME && LOWORD (GetSelectedLong (GetDlgItem (hwndDlg, IDC_DRIVELIST))) != TC_MLIST_ITEM_NONSYS_VOL) { @@ -9910,62 +9937,61 @@ static DWORD WINAPI SystemFavoritesServiceCtrlHandler ( DWORD dwControl, return NO_ERROR; } static LONG WINAPI SystemFavoritesServiceExceptionHandler (EXCEPTION_POINTERS *ep) { SetUnhandledExceptionFilter (NULL); if (!(ReadDriverConfigurationFlags() & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD)) WipeCache (NULL, TRUE); UnhandledExceptionFilter (ep); return EXCEPTION_EXECUTE_HANDLER; } static void SystemFavoritesServiceInvalidParameterHandler (const wchar_t *expression, const wchar_t *function, const wchar_t *file, unsigned int line, uintptr_t reserved) { TC_THROW_FATAL_EXCEPTION; } static VOID WINAPI SystemFavoritesServiceMain (DWORD argc, LPTSTR *argv) { BOOL status = FALSE; DEV_BROADCAST_DEVICEINTERFACE hdr; BOOL bSkipMount = FALSE; BOOL bUpdateLoader = FALSE; DWORD i; memset (&SystemFavoritesServiceStatus, 0, sizeof (SystemFavoritesServiceStatus)); SystemFavoritesServiceStatus.dwServiceType = SERVICE_WIN32_OWN_PROCESS; SystemFavoritesServiceStatus.dwControlsAccepted = SERVICE_ACCEPT_STOP; - if (IsOSAtLeast (WIN_VISTA)) - SystemFavoritesServiceStatus.dwControlsAccepted |= SERVICE_ACCEPT_PRESHUTDOWN | SERVICE_ACCEPT_SESSIONCHANGE | SERVICE_ACCEPT_POWEREVENT; + SystemFavoritesServiceStatus.dwControlsAccepted |= SERVICE_ACCEPT_PRESHUTDOWN | SERVICE_ACCEPT_SESSIONCHANGE | SERVICE_ACCEPT_POWEREVENT; for (i = 1; i < argc; i++) { if (0 == _wcsicmp (argv[i], VC_SYSTEM_FAVORITES_SERVICE_ARG_SKIP_MOUNT)) bSkipMount = TRUE; else if (0 == _wcsicmp (argv[i], VC_SYSTEM_FAVORITES_SERVICE_ARG_UPDATE_LOADER)) bUpdateLoader = TRUE; } ZeroMemory (&hdr, sizeof(hdr)); hdr.dbcc_size = sizeof (hdr); hdr.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE; SystemFavoritesServiceStatusHandle = RegisterServiceCtrlHandlerEx (TC_SYSTEM_FAVORITES_SERVICE_NAME, SystemFavoritesServiceCtrlHandler, NULL); if (!SystemFavoritesServiceStatusHandle) return; SystemFavoriteServiceStopEvent = CreateEvent (NULL, FALSE, FALSE, NULL); if (!SystemFavoriteServiceStopEvent) return; SystemFavoriteServiceNotify = RegisterDeviceNotification (SystemFavoritesServiceStatusHandle, &hdr,DEVICE_NOTIFY_SERVICE_HANDLE | DEVICE_NOTIFY_ALL_INTERFACE_CLASSES); SetUnhandledExceptionFilter (SystemFavoritesServiceExceptionHandler); _set_invalid_parameter_handler (SystemFavoritesServiceInvalidParameterHandler); if (bUpdateLoader) { SystemFavoritesServiceSetStatus (SERVICE_START_PENDING, 120000); SystemFavoritesServiceUpdateLoaderProcessing (TRUE); @@ -10109,61 +10135,60 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz catch (Exception &e) { e.Show (NULL); } if (BootEncObj == NULL) AbortProcess ("INIT_SYS_ENC"); InitApp (hInstance, lpszCommandLine); RegisterRedTick(hInstance); /* Allocate, dup, then store away the application title */ lpszTitle = L"VeraCrypt"; status = DriverAttach (); if (status != 0) { if (status == ERR_OS_ERROR) handleWin32Error (NULL, SRC_POS); else handleError (NULL, status, SRC_POS); AbortProcess ("NODRIVER"); } /* Create the main dialog box */ DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_MOUNT_DLG), NULL, (DLGPROC) MainDialogProc, (LPARAM) lpszCommandLine); - FinalizeApp (); /* Terminate */ return 0; } #endif BOOL TaskBarIconAdd (HWND hwnd) { NOTIFYICONDATAW tnid; ZeroMemory (&tnid, sizeof (tnid)); // Only one icon may be created if (TaskBarIconMutex != NULL) return TRUE; TaskBarIconMutex = CreateMutex (NULL, TRUE, L"VeraCryptTaskBarIcon"); if (TaskBarIconMutex == NULL || GetLastError () == ERROR_ALREADY_EXISTS) { if (TaskBarIconMutex != NULL) { CloseHandle(TaskBarIconMutex); TaskBarIconMutex = NULL; } return FALSE; } tnid.cbSize = sizeof (NOTIFYICONDATAW); tnid.hWnd = hwnd; tnid.uID = IDI_TRUECRYPT_ICON; tnid.uFlags = NIF_MESSAGE | NIF_ICON | NIF_TIP; @@ -10800,62 +10825,62 @@ static void HandleHotKey (HWND hwndDlg, WPARAM wParam) InfoBalloon (NULL, "ALL_TOKEN_SESSIONS_CLOSED", hwndDlg); break; } } void ChangeMainWindowVisibility () { MainWindowHidden = !MainWindowHidden; if (!MainWindowHidden) SetForegroundWindow (MainDlg); ShowWindow (MainDlg, !MainWindowHidden ? SW_SHOW : SW_HIDE); if (!MainWindowHidden) ShowWindow (MainDlg, SW_RESTORE); } int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const wchar_t *lpszVolume) { int nStatus = ERR_OS_ERROR; wchar_t szTmp[4096]; int fBackup = -1; OpenVolumeContext volume; OpenVolumeContext hiddenVolume; Password hiddenVolPassword; int hiddenVolPkcs5 = 0, hiddenVolPim = 0; - CRYPTOPP_ALIGN_DATA(16) byte temporaryKey[MASTER_KEYDATA_SIZE]; - CRYPTOPP_ALIGN_DATA(16) byte originalK2[MASTER_KEYDATA_SIZE]; + CRYPTOPP_ALIGN_DATA(16) uint8 temporaryKey[MASTER_KEYDATA_SIZE]; + CRYPTOPP_ALIGN_DATA(16) uint8 originalK2[MASTER_KEYDATA_SIZE]; int EffectiveVolumePkcs5 = CmdVolumePkcs5; int EffectiveVolumePim = CmdVolumePim; /* Priority is given to command line parameters * Default values used only when nothing specified in command line */ if (EffectiveVolumePkcs5 == 0) EffectiveVolumePkcs5 = DefaultVolumePkcs5; if (!lpszVolume) { nStatus = ERR_OUTOFMEMORY; handleError (hwndDlg, nStatus, SRC_POS); return nStatus; } volume.VolumeIsOpen = FALSE; hiddenVolume.VolumeIsOpen = FALSE; switch (IsSystemDevicePath (lpszVolume, hwndDlg, TRUE)) { case 1: case 2: if (AskErrNoYes ("BACKUP_HEADER_NOT_FOR_SYS_DEVICE", hwndDlg) == IDYES) CreateRescueDisk (hwndDlg); return 0; } if (IsMountedVolume (lpszVolume)) @@ -10935,73 +10960,73 @@ int BackupVolumeHeader (HWND hwndDlg, BOOL bRequireConfirmation, const wchar_t * default: nStatus = ERR_SUCCESS; goto ret; } } break; } if (nStatus != ERR_PASSWORD_WRONG) goto error; handleError (hwndDlg, nStatus, SRC_POS); } } noHidden: if (hiddenVolume.VolumeIsOpen && volume.CryptoInfo->LegacyVolume != hiddenVolume.CryptoInfo->LegacyVolume) { nStatus = ERR_PARAMETER_INCORRECT; goto error; } StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CONFIRM_VOL_HEADER_BAK"), lpszVolume); if (bRequireConfirmation && (MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONQUESTION|MB_DEFBUTTON1) == IDNO)) goto ret; /* Select backup file */ - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, TRUE, NULL)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, TRUE)) goto ret; /* Conceive the backup file */ if ((fBackup = _wopen(szFileName, _O_CREAT|_O_TRUNC|_O_WRONLY|_O_BINARY, _S_IREAD|_S_IWRITE)) == -1) { nStatus = ERR_OS_ERROR; goto error; } // Backup headers - byte backup[TC_VOLUME_HEADER_GROUP_SIZE]; + uint8 backup[TC_VOLUME_HEADER_GROUP_SIZE]; bool legacyVolume = volume.CryptoInfo->LegacyVolume ? true : false; int backupFileSize = legacyVolume ? TC_VOLUME_HEADER_SIZE_LEGACY * 2 : TC_VOLUME_HEADER_GROUP_SIZE; // Fill backup buffer with random data memcpy (originalK2, volume.CryptoInfo->k2, sizeof (volume.CryptoInfo->k2)); if (Randinit() != ERR_SUCCESS) { if (CryptoAPILastError == ERROR_SUCCESS) nStatus = ERR_RAND_INIT_FAILED; else nStatus = ERR_CAPI_INIT_FAILED; goto error; } /* force the display of the random enriching dialog */ SetRandomPoolEnrichedByUserStatus (FALSE); NormalCursor(); UserEnrichRandomPool (hwndDlg); WaitCursor(); // Temporary keys if (!RandgetBytes (hwndDlg, temporaryKey, EAGetKeySize (volume.CryptoInfo->ea), TRUE) || !RandgetBytes (hwndDlg, volume.CryptoInfo->k2, sizeof (volume.CryptoInfo->k2), FALSE)) { nStatus = ERR_PARAMETER_INCORRECT; goto error; } @@ -11199,80 +11224,80 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) if (nStatus == ERR_SUCCESS) break; if (nStatus != ERR_PASSWORD_WRONG) goto error; handleError (hwndDlg, nStatus, SRC_POS); } if (volume.CryptoInfo->LegacyVolume) { Error ("VOLUME_HAS_NO_BACKUP_HEADER", hwndDlg); nStatus = ERROR_SUCCESS; goto error; } // Create a new header with a new salt char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; nStatus = ReEncryptVolumeHeader (hwndDlg, buffer, FALSE, volume.CryptoInfo, &VolumePassword, VolumePim, FALSE); if (nStatus != 0) goto error; headerOffset.QuadPart = volume.CryptoInfo->hiddenVolume ? TC_HIDDEN_VOLUME_HEADER_OFFSET : TC_VOLUME_HEADER_OFFSET; if (!SetFilePointerEx (volume.HostFileHandle, headerOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } - if (!WriteEffectiveVolumeHeader (volume.IsDevice, volume.HostFileHandle, (byte *) buffer)) + if (!WriteEffectiveVolumeHeader (volume.IsDevice, volume.HostFileHandle, (uint8 *) buffer)) { nStatus = ERR_OS_ERROR; goto error; } } else { // Restore header from an external backup StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CONFIRM_VOL_HEADER_RESTORE"), lpszVolume); if (MessageBoxW (hwndDlg, szTmp, lpszTitle, YES_NO|MB_ICONWARNING|MB_DEFBUTTON2) == IDNO) { nStatus = ERR_SUCCESS; goto ret; } /* Select backup file */ - if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, FALSE, NULL)) + if (!BrowseFiles (hwndDlg, "OPEN_TITLE", szFileName, bHistory, FALSE)) { nStatus = ERR_SUCCESS; goto ret; } /* Open the backup file */ fBackup = CreateFile (szFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (fBackup == INVALID_HANDLE_VALUE) { nStatus = ERR_OS_ERROR; goto error; } // Determine size of the backup file LARGE_INTEGER backupSize; if (!GetFileSizeEx (fBackup, &backupSize)) { nStatus = ERR_OS_ERROR; goto error; } CreateFullVolumePath (szDiskFile, sizeof(szDiskFile), lpszVolume, &bDevice); if (bDevice == FALSE) StringCbCopyW (szCFDevice, sizeof(szCFDevice), szDiskFile); else { nDosLinkCreated = FakeDosNameForDevice (szDiskFile, szDosDevice, sizeof(szDosDevice),szCFDevice, sizeof(szCFDevice),FALSE); if (nDosLinkCreated != 0) goto error; @@ -11425,105 +11450,111 @@ int RestoreVolumeHeader (HWND hwndDlg, const wchar_t *lpszVolume) VolumePkcs5 = GuiPkcs5; VolumePim = GuiPim; burn (&GuiPkcs5, sizeof (GuiPkcs5)); burn (&GuiPim, sizeof (GuiPim)); } if (KeyFilesEnable && FirstKeyFile) KeyFilesApply (hwndDlg, &VolumePassword, FirstKeyFile, bDevice? NULL : lpszVolume); // Decrypt volume header headerOffsetBackupFile = 0; for (int type = TC_VOLUME_TYPE_NORMAL; type <= TC_VOLUME_TYPE_HIDDEN; ++type) { if (type == TC_VOLUME_TYPE_HIDDEN) headerOffsetBackupFile += (legacyBackup ? TC_VOLUME_HEADER_SIZE_LEGACY : TC_VOLUME_HEADER_SIZE); nStatus = ReadVolumeHeader (FALSE, buffer + headerOffsetBackupFile, &VolumePassword, VolumePkcs5, VolumePim, &restoredCryptoInfo, NULL); if (nStatus == ERR_SUCCESS) break; } if (nStatus == ERR_SUCCESS) break; if (nStatus != ERR_PASSWORD_WRONG) goto error; handleError (hwndDlg, nStatus, SRC_POS); } + // display a warning if the master key is vulnerable + if (restoredCryptoInfo->bVulnerableMasterKey) + { + Warning ("ERR_XTS_MASTERKEY_VULNERABLE", hwndDlg); + } + BOOL hiddenVol = restoredCryptoInfo->hiddenVolume; if (legacyBackup) { headerOffset.QuadPart = hiddenVol ? hostSize - TC_HIDDEN_VOLUME_HEADER_OFFSET_LEGACY : TC_VOLUME_HEADER_OFFSET; } else { headerOffset.QuadPart = hiddenVol ? TC_HIDDEN_VOLUME_HEADER_OFFSET : TC_VOLUME_HEADER_OFFSET; headerBackupOffset.QuadPart = hiddenVol ? hostSize - TC_VOLUME_HEADER_SIZE : hostSize - TC_VOLUME_HEADER_GROUP_SIZE; } WaitCursor(); // Restore header encrypted with a new key nStatus = ReEncryptVolumeHeader (hwndDlg, buffer, FALSE, restoredCryptoInfo, &VolumePassword, VolumePim, FALSE); if (nStatus != ERR_SUCCESS) goto error; if (!SetFilePointerEx (dev, headerOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } - if (!WriteEffectiveVolumeHeader (bDevice, dev, (byte *) buffer)) + if (!WriteEffectiveVolumeHeader (bDevice, dev, (uint8 *) buffer)) { nStatus = ERR_OS_ERROR; goto error; } if (!restoredCryptoInfo->LegacyVolume) { // Restore backup header encrypted with a new key nStatus = ReEncryptVolumeHeader (hwndDlg, buffer, FALSE, restoredCryptoInfo, &VolumePassword, VolumePim, FALSE); if (nStatus != ERR_SUCCESS) goto error; if (!SetFilePointerEx (dev, headerBackupOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; } - if (!WriteEffectiveVolumeHeader (bDevice, dev, (byte *) buffer)) + if (!WriteEffectiveVolumeHeader (bDevice, dev, (uint8 *) buffer)) { nStatus = ERR_OS_ERROR; goto error; } } } /* Volume header has been successfully restored */ Info("VOL_HEADER_RESTORED", hwndDlg); ret: nStatus = ERR_SUCCESS; error: dwError = GetLastError (); NormalCursor(); if (restoreInternalBackup) { CloseVolume (&volume); } else { if (restoredCryptoInfo) crypto_close (restoredCryptoInfo); if (bTimeStampValid) SetFileTime (dev, &ftCreationTime, &ftLastAccessTime, &ftLastWriteTime); @@ -11537,240 +11568,268 @@ error: RemoveFakeDosName (szDiskFile, szDosDevice); } SetLastError (dwError); if (nStatus != 0) handleError (hwndDlg, nStatus, SRC_POS); burn (&VolumePassword, sizeof (VolumePassword)); burn (&VolumePkcs5, sizeof (VolumePkcs5)); burn (&VolumePim, sizeof (VolumePim)); RestoreDefaultKeyFilesParam(); RandStop (FALSE); NormalCursor(); return nStatus; } void SetDriverConfigurationFlag (uint32 flag, BOOL state) { if (BootEncObj) BootEncObj->SetDriverConfigurationFlag (flag, state ? true : false); } void SetServiceConfigurationFlag (uint32 flag, BOOL state) { if (BootEncObj) BootEncObj->SetServiceConfigurationFlag (flag, state ? true : false); } +void SetMemoryProtectionConfig (BOOL bEnable) +{ + DWORD config = bEnable? 1: 0; + if (BootEncObj) + BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", VC_ENABLE_MEMORY_PROTECTION, config); +} void NotifyService (DWORD dwNotifyCmd) { if (BootEncObj) BootEncObj->NotifyService (dwNotifyCmd); } static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { + static HWND hDisableMemProtectionTooltipWnd = NULL; WORD lw = LOWORD (wParam); switch (msg) { case WM_INITDIALOG: { LocalizeDialog (hwndDlg, "IDD_PERFORMANCE_SETTINGS"); uint32 driverConfig = ReadDriverConfigurationFlags(); CheckDlgButton (hwndDlg, IDC_ENABLE_HARDWARE_ENCRYPTION, (driverConfig & TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION) ? BST_UNCHECKED : BST_CHECKED); CheckDlgButton (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT, (driverConfig & TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL) ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD, (driverConfig & VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM) ? BST_CHECKED : BST_UNCHECKED); // checkbox for Windows Defragmenter only usuable starting from Windows 8.1 // on previous versions, we can not control Windows defragmenter so // this settings is always checked. if (IsOSAtLeast (WIN_8_1)) CheckDlgButton (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG, (driverConfig & VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAG) ? BST_CHECKED : BST_UNCHECKED); else { CheckDlgButton (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG, BST_CHECKED); EnableWindow (GetDlgItem (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG), FALSE); } if (IsCpuRngSupported()) { CheckDlgButton (hwndDlg, IDC_ENABLE_CPU_RNG, (driverConfig & VC_DRIVER_CONFIG_ENABLE_CPU_RNG) ? BST_CHECKED : BST_UNCHECKED); } else { CheckDlgButton (hwndDlg, IDC_ENABLE_CPU_RNG, BST_UNCHECKED); EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_CPU_RNG), FALSE); } - if (IsOSAtLeast (WIN_7) && IsRamEncryptionSupported()) + if (IsRamEncryptionSupported()) { CheckDlgButton (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION, (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION) ? BST_CHECKED : BST_UNCHECKED); } else { CheckDlgButton (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION, BST_UNCHECKED); EnableWindow (GetDlgItem (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION), FALSE); } + CheckDlgButton (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION, ReadMemoryProtectionConfig() ? BST_UNCHECKED : BST_CHECKED); + size_t cpuCount = GetCpuCount(NULL); HWND freeCpuCombo = GetDlgItem (hwndDlg, IDC_ENCRYPTION_FREE_CPU_COUNT); uint32 encryptionFreeCpuCount = ReadEncryptionThreadPoolFreeCpuCountLimit(); if (encryptionFreeCpuCount > (uint32) (cpuCount - 1)) encryptionFreeCpuCount = (uint32) (cpuCount - 1); for (uint32 i = 1; i < cpuCount; ++i) { wstringstream s; s << i; AddComboPair (freeCpuCombo, s.str().c_str(), i); } if (cpuCount < 2 || encryptionFreeCpuCount == 0) EnableWindow (freeCpuCombo, FALSE); if (cpuCount < 2) EnableWindow (GetDlgItem (hwndDlg, IDC_LIMIT_ENC_THREAD_POOL), FALSE); if (encryptionFreeCpuCount != 0) { CheckDlgButton (hwndDlg, IDC_LIMIT_ENC_THREAD_POOL, BST_CHECKED); SendMessage (freeCpuCombo, CB_SETCURSEL, encryptionFreeCpuCount - 1, 0); } SetWindowTextW (GetDlgItem (hwndDlg, IDT_LIMIT_ENC_THREAD_POOL_NOTE), GetString("LIMIT_ENC_THREAD_POOL_NOTE")); SetDlgItemTextW (hwndDlg, IDC_HW_AES_SUPPORTED_BY_CPU, (wstring (L" ") + (GetString (HasAESNI() ? "UISTR_YES" : "UISTR_NO"))).c_str()); ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_HW_ACCELERATION); ToHyperlink (hwndDlg, IDC_MORE_INFO_ON_THREAD_BASED_PARALLELIZATION); + + hDisableMemProtectionTooltipWnd = CreateToolTip (IDC_DISABLE_MEMORY_PROTECTION, hwndDlg, "DISABLE_MEMORY_PROTECTION_WARNING"); + // make IDC_DISABLE_MEMORY_PROTECTION control fit the text so that the tooltip is shown only when mouse is over the text + AccommodateCheckBoxTextWidth(hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); + // make the help button adjacent to the checkbox + MakeControlsContiguous(hwndDlg, IDC_DISABLE_MEMORY_PROTECTION, IDC_DISABLE_MEMORY_PROTECTION_HELP); } return 0; + // handle message to destroy hDisableMemProtectionTooltipWnd when the dialog is closed + case WM_DESTROY: + if (hDisableMemProtectionTooltipWnd) + { + DestroyWindow (hDisableMemProtectionTooltipWnd); + hDisableMemProtectionTooltipWnd = NULL; + } + break; + case WM_COMMAND: switch (lw) { case IDCANCEL: EndDialog (hwndDlg, lw); return 1; case IDOK: { if (IsNonInstallMode()) { Error ("FEATURE_REQUIRES_INSTALLATION", hwndDlg); EndDialog (hwndDlg, IDCANCEL); return 1; } BOOL disableHW = !IsDlgButtonChecked (hwndDlg, IDC_ENABLE_HARDWARE_ENCRYPTION); BOOL enableCpuRng = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_CPU_RNG); BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION); BOOL enableExtendedIOCTL = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_EXTENDED_IOCTL_SUPPORT); BOOL allowTrimCommand = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_TRIM_NONSYS_SSD); BOOL allowWindowsDefrag = IsDlgButtonChecked (hwndDlg, IDC_ALLOW_WINDOWS_DEFRAG); + BOOL bDisableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); try { VOLUME_PROPERTIES_STRUCT prop; bool rebootRequired = false; uint32 driverConfig = ReadDriverConfigurationFlags(); try { BootEncStatus = BootEncObj->GetStatus(); BootEncObj->GetVolumeProperties (&prop); } catch (...) { BootEncStatus.DriveMounted = false; } if (BootEncStatus.DriveMounted && !bSystemIsGPT) { - byte userConfig; + uint8 userConfig; string customUserMessage; uint16 bootLoaderVersion; if (!BootEncObj->ReadBootSectorConfig (nullptr, 0, &userConfig, &customUserMessage, &bootLoaderVersion)) return 1; if (bootLoaderVersion != VERSION_NUM) Warning ("BOOT_LOADER_VERSION_INCORRECT_PREFERENCES", hwndDlg); if (disableHW) userConfig |= TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_DISABLE_HW_ENCRYPTION; BootEncObj->WriteBootSectorUserConfig (userConfig, customUserMessage, prop.volumePim, prop.pkcs5); } SetDriverConfigurationFlag (TC_DRIVER_CONFIG_DISABLE_HARDWARE_ENCRYPTION, disableHW); SetDriverConfigurationFlag (TC_DRIVER_CONFIG_ENABLE_EXTENDED_IOCTL, enableExtendedIOCTL); SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_NONSYS_TRIM, allowTrimCommand); if (IsOSAtLeast (WIN_8_1)) SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ALLOW_WINDOWS_DEFRAG, allowWindowsDefrag); SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_CPU_RNG, enableCpuRng); - if (IsOSAtLeast (WIN_7)) + + BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE; + if (originalRamEncryptionEnabled != enableRamEncryption) { - BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE; - if (originalRamEncryptionEnabled != enableRamEncryption) + if (enableRamEncryption) { - if (enableRamEncryption) + // Disable Hibernate and Fast Startup if they are enabled + BOOL bHibernateEnabled, bHiberbootEnabled; + if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled)) { - // Disable Hibernate and Fast Startup if they are enabled - BOOL bHibernateEnabled, bHiberbootEnabled; - if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled)) - { - if (bHibernateEnabled) - { - BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabled", 0); - } + if (bHibernateEnabled) + { + BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Power", L"HibernateEnabled", 0); + } - if (bHiberbootEnabled) - { - BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0); - } + if (bHiberbootEnabled) + { + BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Power", L"HiberbootEnabled", 0); } } - rebootRequired = true; } - SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption); + rebootRequired = true; } + SetDriverConfigurationFlag (VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION, enableRamEncryption); + + BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig(); + if(originalDisableMemoryProtection != bDisableMemoryProtection) + rebootRequired = true; + SetMemoryProtectionConfig (!bDisableMemoryProtection); DWORD bytesReturned; if (!DeviceIoControl (hDriver, TC_IOCTL_REREAD_DRIVER_CONFIG, NULL, 0, NULL, 0, &bytesReturned, NULL)) handleWin32Error (hwndDlg, SRC_POS); EnableHwEncryption (!disableHW); EnableCpuRng (enableCpuRng); uint32 cpuFreeCount = 0; if (IsDlgButtonChecked (hwndDlg, IDC_LIMIT_ENC_THREAD_POOL)) { LRESULT cpuFreeItem = SendMessage (GetDlgItem (hwndDlg, IDC_ENCRYPTION_FREE_CPU_COUNT), CB_GETCURSEL, 0, 0); if (cpuFreeItem != CB_ERR) cpuFreeCount = (uint32) (cpuFreeItem + 1); } if (ReadEncryptionThreadPoolFreeCpuCountLimit() != cpuFreeCount) { BootEncObj->WriteLocalMachineRegistryDwordValue (L"SYSTEM\\CurrentControlSet\\Services\\veracrypt", TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME, cpuFreeCount); rebootRequired = true; } if (rebootRequired) Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); EndDialog (hwndDlg, lw); return 1; } catch (Exception &e) { @@ -11812,60 +11871,78 @@ static BOOL CALLBACK PerformanceSettingsDlgProc (HWND hwndDlg, UINT msg, WPARAM case IDC_ENABLE_RAM_ENCRYPTION: { uint32 driverConfig = ReadDriverConfigurationFlags(); BOOL originalRamEncryptionEnabled = (driverConfig & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION)? TRUE : FALSE; BOOL enableRamEncryption = IsDlgButtonChecked (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION); if (originalRamEncryptionEnabled != enableRamEncryption) { if (enableRamEncryption) { // check if Hibernate or Fast Startup are enabled BOOL bHibernateEnabled, bHiberbootEnabled; if (GetHibernateStatus (bHibernateEnabled, bHiberbootEnabled)) { if (bHibernateEnabled || bHiberbootEnabled) { if (AskWarnYesNo ("RAM_ENCRYPTION_DISABLE_HIBERNATE", hwndDlg) == IDNO) { CheckDlgButton (hwndDlg, IDC_ENABLE_RAM_ENCRYPTION, BST_UNCHECKED); return 1; } } } } Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); } } return 1; + case IDC_DISABLE_MEMORY_PROTECTION: + { + BOOL disableMemoryProtection = IsDlgButtonChecked (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); + BOOL originalDisableMemoryProtection = !ReadMemoryProtectionConfig(); + if (disableMemoryProtection != originalDisableMemoryProtection) + { + if (disableMemoryProtection) + { + Warning ("DISABLE_MEMORY_PROTECTION_WARNING", hwndDlg); + } + + Warning ("SETTING_REQUIRES_REBOOT", hwndDlg); + } + } + return 1; + case IDC_DISABLE_MEMORY_PROTECTION_HELP: + Applink ("memoryprotection"); + return 1; case IDC_BENCHMARK: Benchmark (hwndDlg); return 1; case IDC_MORE_INFO_ON_HW_ACCELERATION: Applink ("hwacceleration"); return 1; case IDC_MORE_INFO_ON_THREAD_BASED_PARALLELIZATION: Applink ("parallelization"); return 1; } return 0; } return 0; } static BOOL CALLBACK SecurityTokenPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); switch (msg) { case WM_INITDIALOG: LocalizeDialog (hwndDlg, "IDD_TOKEN_PREFERENCES"); SetDlgItemText (hwndDlg, IDC_PKCS11_MODULE, SecurityTokenLibraryPath); CheckDlgButton (hwndDlg, IDC_CLOSE_TOKEN_SESSION_AFTER_MOUNT, CloseSecurityTokenSessionsAfterMount ? BST_CHECKED : BST_UNCHECKED); @@ -12049,81 +12126,81 @@ static BOOL CALLBACK DefaultMountParametersDlgProc (HWND hwndDlg, UINT msg, WPAR case IDOK: { int pkcs5 = (int) SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETITEMDATA, SendMessage (GetDlgItem (hwndDlg, IDC_PKCS5_PRF_ID), CB_GETCURSEL, 0, 0), 0); WaitCursor (); DefaultVolumePkcs5 = pkcs5; SaveSettings (hwndDlg); NormalCursor (); EndDialog (hwndDlg, lw); return 1; } } return 0; } return 0; } void SecurityTokenPreferencesDialog (HWND hwndDlg) { DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_TOKEN_PREFERENCES), hwndDlg, (DLGPROC) SecurityTokenPreferencesDlgProc, 0); } static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); static std::string platforminfo; - static byte currentUserConfig; + static uint8 currentUserConfig; static string currentCustomUserMessage; switch (msg) { case WM_INITDIALOG: { BootEncryptionStatus BootEncStatus = BootEncObj->GetStatus(); if (!BootEncStatus.DriveMounted) { Warning ("SYS_DRIVE_NOT_ENCRYPTED", hwndDlg); EndDialog (hwndDlg, IDCANCEL); return 1; } try { LocalizeDialog (hwndDlg, "IDD_SYSENC_SETTINGS"); uint32 driverConfig = ReadDriverConfigurationFlags(); uint32 serviceConfig = ReadServiceConfigurationFlags(); - byte userConfig; + uint8 userConfig; string customUserMessage; uint16 bootLoaderVersion = 0; BOOL bPasswordCacheEnabled = (driverConfig & TC_DRIVER_CONFIG_CACHE_BOOT_PASSWORD)? TRUE : FALSE; BOOL bPimCacheEnabled = (driverConfig & TC_DRIVER_CONFIG_CACHE_BOOT_PIM)? TRUE : FALSE; BOOL bBlockSysEncTrimEnabled = (driverConfig & VC_DRIVER_CONFIG_BLOCK_SYS_TRIM)? TRUE : FALSE; BOOL bClearKeysEnabled = (driverConfig & VC_DRIVER_CONFIG_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION)? TRUE : FALSE; BOOL bAutoFixBootloader = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_UPDATE_LOADER)? FALSE : TRUE; BOOL bForceVeraCryptNextBoot = FALSE; BOOL bForceSetVeraCryptBootEntry = TRUE; BOOL bForceVeraCryptFirstEntry = TRUE; if (bSystemIsGPT) { bForceVeraCryptNextBoot = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_FORCE_SET_BOOTNEXT)? TRUE : FALSE; bForceSetVeraCryptBootEntry = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_SET_BOOTENTRY)? FALSE : TRUE; bForceVeraCryptFirstEntry = (serviceConfig & VC_SYSTEM_FAVORITES_SERVICE_CONFIG_DONT_FORCE_FIRST_BOOTENTRY)? FALSE : TRUE; } BOOL bIsHiddenOS = IsHiddenOSRunning (); if (bClearKeysEnabled) { // the clear keys option works only if the service is running if (!BootEncObj->IsSystemFavoritesServiceRunning()) bClearKeysEnabled = false; } if (!BootEncObj->ReadBootSectorConfig (nullptr, 0, &userConfig, &customUserMessage, &bootLoaderVersion)) { // operations canceled @@ -12246,61 +12323,61 @@ static BOOL CALLBACK BootLoaderPreferencesDlgProc (HWND hwndDlg, UINT msg, WPARA } catch (Exception &e) { e.Show(hwndDlg); } } return 0; case IDOK: { VOLUME_PROPERTIES_STRUCT prop; if (!BootEncObj->GetStatus().DriveMounted) { EndDialog (hwndDlg, IDCANCEL); return 1; } try { BootEncObj->GetVolumeProperties (&prop); } catch (Exception &e) { e.Show (hwndDlg); EndDialog (hwndDlg, IDCANCEL); return 1; } char customUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1] = {0}; if (!bSystemIsGPT) GetDlgItemTextA (hwndDlg, IDC_CUSTOM_BOOT_LOADER_MESSAGE, customUserMessage, sizeof (customUserMessage)); - byte userConfig = currentUserConfig; + uint8 userConfig = currentUserConfig; if (IsDlgButtonChecked (hwndDlg, IDC_DISABLE_BOOT_LOADER_PIM_PROMPT)) userConfig |= TC_BOOT_USER_CFG_FLAG_DISABLE_PIM; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_DISABLE_PIM; if (bSystemIsGPT) { if (IsDlgButtonChecked (hwndDlg, IDC_DISABLE_BOOT_LOADER_HASH_PROMPT)) userConfig |= TC_BOOT_USER_CFG_FLAG_STORE_HASH; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_STORE_HASH; } else { if (IsDlgButtonChecked (hwndDlg, IDC_DISABLE_BOOT_LOADER_OUTPUT)) userConfig |= TC_BOOT_USER_CFG_FLAG_SILENT_MODE; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_SILENT_MODE; if (!IsDlgButtonChecked (hwndDlg, IDC_ALLOW_ESC_PBA_BYPASS)) userConfig |= TC_BOOT_USER_CFG_FLAG_DISABLE_ESC; else userConfig &= ~TC_BOOT_USER_CFG_FLAG_DISABLE_ESC; } try { BOOL bPasswordCacheEnabled = IsDlgButtonChecked (hwndDlg, IDC_BOOT_LOADER_CACHE_PASSWORD); BOOL bPimCacheEnabled = IsDlgButtonChecked (hwndDlg, IDC_BOOT_LOADER_CACHE_PIM); diff --git a/src/Mount/Mount.manifest b/src/Mount/Mount.manifest index 5d4cb896..79d86799 100644 --- a/src/Mount/Mount.manifest +++ b/src/Mount/Mount.manifest @@ -1,33 +1,39 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
\ No newline at end of file diff --git a/src/Mount/Mount.rc b/src/Mount/Mount.rc index a1ff8cc3..9953469e 100644 --- a/src/Mount/Mount.rc +++ b/src/Mount/Mount.rc @@ -294,91 +294,94 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN GROUPBOX "Boot Loader Screen Options",IDT_BOOT_LOADER_SCREEN_OPTIONS,8,7,355,45 CONTROL "Do not request PIM in the pre-boot authentication screen (PIM value is stored unencrypted on disk)",IDC_DISABLE_BOOT_LOADER_PIM_PROMPT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,20,339,9 CONTROL "Do not request Hash algorithm in the pre-boot authentication screen",IDC_DISABLE_BOOT_LOADER_HASH_PROMPT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,35,339,9 GROUPBOX "Security Options",IDT_SECURITY_OPTIONS,7,53,355,75 CONTROL "&Cache pre-boot authentication password in driver memory (for mounting of non-system volumes)",IDC_BOOT_LOADER_CACHE_PASSWORD, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,68,339,10 CONTROL "Include PIM when caching pre-boot authentication password",IDC_BOOT_LOADER_CACHE_PIM, "Button",BS_AUTOCHECKBOX | WS_DISABLED | WS_TABSTOP,16,83,340,10 CONTROL "Block TRIM command on system partition/drive",IDC_BLOCK_SYSENC_TRIM, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,98,340,10 CONTROL "Clear encryption keys from memory if a new device is inserted",IDC_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,112,340,10 GROUPBOX "Advanced Options",IDT_ADVANCED_OPTIONS,7,131,355,91 CONTROL "Automatically fix boot configuration issues that may prevent Windows from starting",IDC_UPDATE_BOOTLOADER_ON_SHUTDOWN, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,144,340,10 CONTROL "Force machine to boot on VeraCrypt in the next startup",IDC_FORCE_NEXT_BOOT_VERACRYPT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,158,340,10 CONTROL "Force the presence of VeraCrypt entry in the EFI firmware boot menu",IDC_FORCE_VERACRYPT_BOOT_ENTRY, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,172,340,10 CONTROL "Force VeraCrypt entry to be the first in the EFI firmware boot menu",IDC_FORCE_VERACRYPT_FIRST_BOOT_ENTRY, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,186,340,10 PUSHBUTTON "Edit Boot Loader Configuration",IDC_EDIT_DCSPROP,10,201,173,14 PUSHBUTTON "Display EFI Platform Information",IDC_SHOW_PLATFORMINFO,187,201,173,14 PUSHBUTTON "Cancel",IDCANCEL,313,226,50,14 DEFPUSHBUTTON "OK",IDOK,255,226,50,14 END -IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 371, 293 +IDD_PERFORMANCE_SETTINGS DIALOGEX 0, 0, 371, 300 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Performance Options" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_HW_AES_SUPPORTED_BY_CPU,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,294,21,57,12,WS_EX_CLIENTEDGE CONTROL "Accelerate AES encryption/decryption by using the AES instructions of the processor (if available)",IDC_ENABLE_HARDWARE_ENCRYPTION, "Button",BS_AUTOCHECKBOX | BS_MULTILINE | WS_TABSTOP,18,41,340,17 LTEXT "More information",IDC_MORE_INFO_ON_HW_ACCELERATION,18,61,165,10,SS_NOTIFY CONTROL "Do not use the following number of logical processors for encryption/decryption:",IDC_LIMIT_ENC_THREAD_POOL, "Button",BS_AUTOCHECKBOX | BS_TOP | WS_TABSTOP,18,103,283,11 COMBOBOX IDC_ENCRYPTION_FREE_CPU_COUNT,304,101,48,51,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "",IDT_LIMIT_ENC_THREAD_POOL_NOTE,18,126,334,33 LTEXT "More information",IDC_MORE_INFO_ON_THREAD_BASED_PARALLELIZATION,18,159,165,10,SS_NOTIFY CONTROL "Enable extended disk control codes support",IDC_ENABLE_EXTENDED_IOCTL_SUPPORT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,198,337,10 CONTROL "Allow TRIM command for non-system SSD partition/drive",IDC_ALLOW_TRIM_NONSYS_SSD, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,212,337,10 - PUSHBUTTON "&Benchmark",IDC_BENCHMARK,7,272,59,14 - DEFPUSHBUTTON "OK",IDOK,257,272,50,14 - PUSHBUTTON "Cancel",IDCANCEL,314,272,50,14 - LTEXT "Processor (CPU) in this computer supports hardware acceleration for AES:",IDT_HW_AES_SUPPORTED_BY_CPU,18,23,273,9 - GROUPBOX "Hardware Acceleration",IDT_ACCELERATION_OPTIONS,7,6,355,74 - GROUPBOX "Thread-Based Parallelization",IDT_PARALLELIZATION_OPTIONS,7,84,355,93 - GROUPBOX "Driver Configuration",IDT_DRIVER_OPTIONS,7,183,357,86 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,211,337,10 CONTROL "Allow Windows Disk Defragmenter to defragment non-system partition/drive",IDC_ALLOW_WINDOWS_DEFRAG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,226,337,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,224,337,10 CONTROL "Use CPU hardware random generator as an additional source of entropy",IDC_ENABLE_CPU_RNG, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,240,335,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,237,335,10 CONTROL "Activate encryption of keys and passwords stored in RAM",IDC_ENABLE_RAM_ENCRYPTION, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,254,337,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,250,337,10 + CONTROL "Disable memory protection for Accessibility tools compatibility",IDC_DISABLE_MEMORY_PROTECTION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,263,339,10 + PUSHBUTTON "?",IDC_DISABLE_MEMORY_PROTECTION_HELP,364,259,7,14 + PUSHBUTTON "&Benchmark",IDC_BENCHMARK,7,279,59,14 + DEFPUSHBUTTON "OK",IDOK,257,279,50,14 + PUSHBUTTON "Cancel",IDCANCEL,314,279,50,14 + LTEXT "Processor (CPU) in this computer supports hardware acceleration for AES:",IDT_HW_AES_SUPPORTED_BY_CPU,18,23,273,9 + GROUPBOX "Hardware Acceleration",IDT_ACCELERATION_OPTIONS,7,6,355,74 + GROUPBOX "Thread-Based Parallelization",IDT_PARALLELIZATION_OPTIONS,7,84,355,93 + GROUPBOX "Driver Configuration",IDT_DRIVER_OPTIONS,7,183,357,95 END IDD_FAVORITE_VOLUMES DIALOGEX 0, 0, 380, 368 STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt - Favorite Volumes" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_FAVORITE_VOLUMES_LIST,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_ALIGNLEFT | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,366,92 PUSHBUTTON "Move &Up",IDC_FAVORITE_MOVE_UP,7,104,63,14 PUSHBUTTON "Move &Down",IDC_FAVORITE_MOVE_DOWN,74,104,63,14 PUSHBUTTON "&Remove",IDC_FAVORITE_REMOVE,310,104,63,14 EDITTEXT IDC_FAVORITE_LABEL,18,225,344,13,ES_AUTOHSCROLL CONTROL "Mount selected volume as read-o&nly",IDC_FAVORITE_MOUNT_READONLY, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,255,349,10 CONTROL "Mount selected volume as remo&vable medium",IDC_FAVORITE_MOUNT_REMOVABLE, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,269,349,10 CONTROL "Mount selected volume upon log&on",IDC_FAVORITE_MOUNT_ON_LOGON, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,283,349,10 CONTROL "Mount selected volume when its host device gets &connected",IDC_FAVORITE_MOUNT_ON_ARRIVAL, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,297,349,10 CONTROL "Open &Explorer window for selected volume when successfully mounted",IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,311,349,11 CONTROL "Do not mount selected volume when 'Mount Favorite Volumes' &hot key is pressed",IDC_FAVORITE_DISABLE_HOTKEY, "Button",BS_AUTOCHECKBOX | WS_TABSTOP,18,326,349,11 LTEXT "Help on favorite volumes",IDC_FAVORITES_HELP_LINK,17,351,237,10,SS_NOTIFY DEFPUSHBUTTON "OK",IDOK,269,347,50,14 PUSHBUTTON "Cancel",IDCANCEL,323,347,50,14 GROUPBOX "",IDC_FAV_VOL_OPTIONS_GROUP_BOX,7,123,366,219 LTEXT "Label of selected favorite volume:",IDT_FAVORITE_LABEL,18,215,202,8 GROUPBOX "Global Settings",IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX,7,300,366,42 @@ -494,119 +497,119 @@ BEGIN IDD_HOTKEYS_DLG, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 382 TOPMARGIN, 7 BOTTOMMARGIN, 250 END IDD_TOKEN_PREFERENCES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 309 TOPMARGIN, 7 BOTTOMMARGIN, 192 END IDD_EFI_SYSENC_SETTINGS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 368 TOPMARGIN, 7 BOTTOMMARGIN, 240 END IDD_PERFORMANCE_SETTINGS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 364 TOPMARGIN, 7 - BOTTOMMARGIN, 286 + BOTTOMMARGIN, 293 END IDD_FAVORITE_VOLUMES, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 373 TOPMARGIN, 7 BOTTOMMARGIN, 361 END IDD_DEFAULT_MOUNT_PARAMETERS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 160 TOPMARGIN, 7 BOTTOMMARGIN, 58 END IDD_SYSENC_SETTINGS, DIALOG BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 364 TOPMARGIN, 7 BOTTOMMARGIN, 334 END END #endif // APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // // TEXTINCLUDE // 1 TEXTINCLUDE BEGIN "resource.h\0" END 2 TEXTINCLUDE BEGIN "#include ""afxres.h""\r\n" "#include ""..\\\\common\\\\resource.h""\r\n" "\0" END 3 TEXTINCLUDE BEGIN "#include ""..\\\\common\\\\common.rc""\r\n" diff --git a/src/Mount/Mount.vcxproj b/src/Mount/Mount.vcxproj index 480ef694..01d013f7 100644 --- a/src/Mount/Mount.vcxproj +++ b/src/Mount/Mount.vcxproj @@ -163,383 +163,383 @@ <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>false</FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;..\Common\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Mount.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCrypt.exe "..\Debug\Setup Files" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <FunctionLevelLinking>false</FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;..\Common\x64\Debug\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Mount.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCrypt.exe "..\Release\Setup Files"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCrypt.exe "..\Release\Setup Files"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;..\Common\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCrypt.exe "..\Release\Setup Files"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;..\Common\x64\Release\lzma.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\Common\CommandAPDU.cpp" /> <ClCompile Include="..\Common\EMVCard.cpp" /> <ClCompile Include="..\Common\EMVToken.cpp" /> <ClCompile Include="..\Common\PCSCException.cpp" /> <ClCompile Include="..\Common\ResponseAPDU.cpp" /> <ClCompile Include="..\Common\SCard.cpp" /> <ClCompile Include="..\Common\SCardLoader.cpp" /> <ClCompile Include="..\Common\SCardManager.cpp" /> <ClCompile Include="..\Common\SCardReader.cpp" /> <ClCompile Include="..\Common\TLVParser.cpp" /> diff --git a/src/Mount/Mount_vs2019.vcxproj b/src/Mount/Mount_vs2019.vcxproj index b75121e4..c63953fc 100644 --- a/src/Mount/Mount_vs2019.vcxproj +++ b/src/Mount/Mount_vs2019.vcxproj @@ -23,80 +23,83 @@ </ProjectConfiguration> <ProjectConfiguration Include="ReleaseCustomEFI|x64"> <Configuration>ReleaseCustomEFI</Configuration> <Platform>x64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|ARM64"> <Configuration>Release</Configuration> <Platform>ARM64</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|Win32"> <Configuration>Release</Configuration> <Platform>Win32</Platform> </ProjectConfiguration> <ProjectConfiguration Include="Release|x64"> <Configuration>Release</Configuration> <Platform>x64</Platform> </ProjectConfiguration> </ItemGroup> <PropertyGroup Label="Globals"> <ProjectGuid>{E4C40F94-E7F9-4981-86E4-186B46F993F3}</ProjectGuid> <RootNamespace>Mount</RootNamespace> <Keyword>Win32Proj</Keyword> <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> <ProjectName>Mount</ProjectName> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> + <SpectreMitigation>Spectre</SpectreMitigation> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> <ConfigurationType>Application</ConfigurationType> <CharacterSet>Unicode</CharacterSet> <PlatformToolset>v142</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> @@ -106,510 +109,519 @@ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets"> <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> </ImportGroup> <PropertyGroup Label="UserMacros" /> <PropertyGroup> <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</OutDir> - <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</OutDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(Platform)\$(Configuration)\</IntDir> - <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(Platform)\$(Configuration)\</IntDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'">VeraCrypt</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'">VeraCrypt</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Debug\crypto.lib;..\Common\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Mount.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCrypt.exe "..\Debug\Setup Files" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Debug\crypto.lib;..\Common\x64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Mount.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-x64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <ExceptionHandling>Sync</ExceptionHandling> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> - <FunctionLevelLinking>false</FunctionLevelLinking> + <FunctionLevelLinking> + </FunctionLevelLinking> <PrecompiledHeader> </PrecompiledHeader> <BrowseInformation> </BrowseInformation> <BrowseInformationFile> </BrowseInformationFile> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Debug\crypto.lib;..\Common\ARM64\Debug\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Mount.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <DataExecutionPrevention>true</DataExecutionPrevention> + <GenerateMapFile>true</GenerateMapFile> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy $(TargetPath) "..\Debug\Setup Files\VeraCrypt-arm64.exe" >NUL: </Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCrypt.exe "..\Release\Setup Files"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\Release\crypto.lib;..\Common\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCrypt.exe "..\Release\Setup Files"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\ARM64\Release\crypto.lib;..\Common\ARM64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|x64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TargetEnvironment>X64</TargetEnvironment> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX64</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-x64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|ARM64'"> <Midl> <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <TypeLibraryName>$(SolutionDir)/$(ProjectName)/$(ProjectName).tlb</TypeLibraryName> <OutputDirectory> </OutputDirectory> </Midl> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>TCMOUNT;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalDependencies>..\Crypto\x64\Release\crypto.lib;..\Common\x64\Release\Zip.lib;mpr.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCrypt.exe</OutputFile> <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries> - <DelayLoadDLLs>mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> </Link> <Manifest> <AdditionalManifestFiles>Mount.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy $(TargetPath) "..\Release\Setup Files\VeraCrypt-arm64.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;WIN64;ARM64;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="..\Common\CommandAPDU.cpp" /> <ClCompile Include="..\Common\EMVCard.cpp" /> <ClCompile Include="..\Common\EMVToken.cpp" /> <ClCompile Include="..\Common\PCSCException.cpp" /> <ClCompile Include="..\Common\ResponseAPDU.cpp" /> <ClCompile Include="..\Common\SCard.cpp" /> <ClCompile Include="..\Common\SCardLoader.cpp" /> <ClCompile Include="..\Common\SCardManager.cpp" /> <ClCompile Include="..\Common\SCardReader.cpp" /> <ClCompile Include="..\Common\TLVParser.cpp" /> <ClCompile Include="..\Common\Token.cpp" /> diff --git a/src/Mount/Resource.h b/src/Mount/Resource.h index 0b778b4c..fef9da49 100644 --- a/src/Mount/Resource.h +++ b/src/Mount/Resource.h @@ -171,62 +171,62 @@ #define IDT_DRIVER_OPTIONS 1149 #define IDC_ENABLE_EXTENDED_IOCTL_SUPPORT 1150 #define IDC_DISABLE_EVIL_MAID_ATTACK_DETECTION 1151 #define IDC_WIPE_MODE 1152 #define IDT_WIPE_MODE 1153 #define IDC_PREF_CACHE_PIM 1154 #define IDC_BOOT_LOADER_CACHE_PIM 1155 #define IDC_SHOW_DISCONNECTED_NETWORK_DRIVES 1156 #define IDT_VOLUME_ID 1157 #define IDC_FAVORITE_VOLUME_ID 1158 #define IDC_FAVORITE_USE_VOLUME_ID 1159 #define IDC_DISABLE_BOOT_LOADER_PIM_PROMPT 1160 #define IDC_HIDE_WAITING_DIALOG 1161 #define IDC_DISABLE_BOOT_LOADER_HASH_PROMPT 1162 #define IDC_SECURE_DESKTOP_PASSWORD_ENTRY 1163 #define IDC_SHOW_PLATFORMINFO 1164 #define IDC_EDIT_DCSPROP 1165 #define IDT_ADVANCED_OPTIONS 1166 #define IDC_ALLOW_TRIM_NONSYS_SSD 1167 #define IDC_BLOCK_SYSENC_TRIM 1168 #define IDC_ALLOW_WINDOWS_DEFRAG 1169 #define IDC_LOWER_BOX 1170 #define IDC_CLEAR_KEYS_ON_NEW_DEVICE_INSERTION 1171 #define IDC_ENABLE_CPU_RNG 1172 #define IDC_ENABLE_RAM_ENCRYPTION 1173 #define IDC_USE_LEGACY_MAX_PASSWORD_LENGTH 1174 #define IDC_UPDATE_BOOTLOADER_ON_SHUTDOWN 1175 #define IDC_FORCE_NEXT_BOOT_VERACRYPT 1176 #define IDC_FORCE_VERACRYPT_BOOT_ENTRY 1177 #define IDC_FORCE_VERACRYPT_FIRST_BOOT_ENTRY 1178 -#define IDC_ENABLE_EMV_SUPPORT 1179 -#define IDT_EMV_OPTIONS 1180 +#define IDC_ENABLE_EMV_SUPPORT 1179 +#define IDT_EMV_OPTIONS 1180 #define IDM_HELP 40001 #define IDM_ABOUT 40002 #define IDM_UNMOUNT_VOLUME 40003 #define IDM_CLEAR_HISTORY 40004 #define IDM_BENCHMARK 40005 #define IDM_TRAVELER 40006 #define IDM_MOUNT_VOLUME_OPTIONS 40007 #define IDM_FAQ 40008 #define IDM_REFRESH_DRIVE_LETTERS 40009 #define IDM_DEFAULT_KEYFILES 40010 #define IDM_WEBSITE 40011 #define IDM_MOUNTALL 40012 #define IDM_UNMOUNTALL 40013 #define IDM_MOUNT_VOLUME 40014 #define IDM_CHANGE_PASSWORD 40015 #define IDM_VOLUME_WIZARD 40016 #define IDM_CREATE_VOLUME 40017 #define IDM_WIPE_CACHE 40018 #define IDM_PREFERENCES 40019 #define IDM_LICENSE 40020 #define IDM_SELECT_FILE 40021 #define IDM_SELECT_DEVICE 40022 #define IDM_VOLUME_PROPERTIES 40023 #define IDM_LANGUAGE 40024 #define IDM_MOUNT_FAVORITE_VOLUMES 40025 #define IDM_BACKUP_VOL_HEADER 40026 #define IDM_RESTORE_VOL_HEADER 40027 #define IDM_HOTKEY_SETTINGS 40028 #define IDM_TC_DOWNLOADS 40029 #define IDM_NEWS 40030 @@ -250,34 +250,34 @@ #define IDM_SYSENC_RESUME 40048 #define IDM_MOUNT_SYSENC_PART_WITHOUT_PBA 40049 #define IDM_CREATE_HIDDEN_OS 40050 #define IDM_TOKEN_PREFERENCES 40051 #define IDM_CLOSE_ALL_TOKEN_SESSIONS 40052 #define IDM_SYS_ENC_SETTINGS 40053 #define IDM_SYSENC_SETTINGS 40054 #define IDM_RESUME_INTERRUPTED_PROC 40055 #define IDM_MANAGE_TOKEN_KEYFILES 40056 #define IDM_SYS_FAVORITES_SETTINGS 40057 #define IDM_ORGANIZE_FAVORITES 40058 #define IDM_ORGANIZE_SYSTEM_FAVORITES 40059 #define IDM_ADD_VOLUME_TO_FAVORITES 40060 #define IDM_ADD_VOLUME_TO_SYSTEM_FAVORITES 40061 #define IDM_PERFORMANCE_SETTINGS 40062 #define IDM_ANALYZE_SYSTEM_CRASH 40063 #define IDM_DONATE 40064 #define IDM_VOLUME_EXPANDER 40065 #define IDM_DEFAULT_MOUNT_PARAMETERS 40066 #define IDM_DECRYPT_NONSYS_VOL 40067 #define IDM_VERIFY_RESCUE_DISK_ISO 40068 #define IDM_MOUNIT_NO_CACHE 40069 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 #define _APS_NEXT_RESOURCE_VALUE 120 #define _APS_NEXT_COMMAND_VALUE 40070 -#define _APS_NEXT_CONTROL_VALUE 1179 +#define _APS_NEXT_CONTROL_VALUE 1181 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif @@ -1,31 +1,31 @@ -Copyright 2013-2023 IDRIX +Copyright 2013-2024 IDRIX Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ____________________________________________________________ Copyright (c) 2008-2012 TrueCrypt Developers Association. All rights reserved. Governed by the TrueCrypt License 3.0 the full text of which is contained in the file License.txt included in TrueCrypt binary and source code distribution packages. ____________________________________________________________ License agreement for Encryption for the Masses. Copyright (C) 1998-2000 Paul Le Roux. All Rights Reserved. This product can be copied and distributed free of charge, including source code. You may modify this product and source code, and distribute such modifications, and you may derive new works based on this @@ -84,82 +84,82 @@ ANY OTHER PROGRAMS, EVEN IF SUCH HOLDER OR OTHER PARTY HAD PREVIOUSLY BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ____________________________________________________________ Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved. LICENSE TERMS The free distribution and use of this software is allowed (with or without changes) provided that: 1. source code distributions include the above copyright notice, this list of conditions and the following disclaimer; 2. binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation; 3. the name of the copyright holder is not used to endorse products built using this software without specific written permission. DISCLAIMER This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose. ____________________________________________________________ -Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler +Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu ____________________________________________________________ -Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner +Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner The authors can be contacted at <libzip@nih.at> Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @@ -175,34 +175,79 @@ version 3.0 (LGPL-3.0). The full text of the license may be found at https://opensource.org/licenses/LGPL-3.0 ____________________________________________________________ Copyright (c) 1999-2016 Jack Lloyd. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ____________________________________________________________ -LZMA SDK Copyright (C) 1999-2021 Igor Pavlov +Copyright (c) 2013-2019 Stephan Mueller <smueller@chronox.de> -Public domain +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the above copyright + notice, and the entire permission notice in its entirety, + including the disclaimer of warranties. + +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +ALTERNATIVELY, this product may be distributed under the terms of +the GNU General Public License, in which case the provisions of the +GPL2 are required INSTEAD OF the above restrictions. (This clause is +necessary due to a potential bad interaction between the GPL and the +restrictions contained in a BSD-style copyright.) + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH +ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +____________________________________________________________ +Copyright (c) 1999-2023 Igor Pavlov + +LZMA SDK is written and placed in the public domain by Igor Pavlov. + +Some code in LZMA SDK is based on public domain code from another developers: + 1) PPMd var.H (2001): Dmitry Shkarin + 2) SHA-256: Wei Dai (Crypto++ library) + +Anyone is free to copy, modify, publish, use, compile, sell, or distribute the +original LZMA SDK code, either in source code form or as a compiled binary, for +any purpose, commercial or non-commercial, and by any means. ____________________________________________________________
\ No newline at end of file diff --git a/src/Platform/Buffer.cpp b/src/Platform/Buffer.cpp index 82c2a3f1..5829b1d9 100644 --- a/src/Platform/Buffer.cpp +++ b/src/Platform/Buffer.cpp @@ -17,61 +17,61 @@ namespace VeraCrypt { Buffer::Buffer () : DataPtr (nullptr), DataSize (0), DataAlignment (0) { } Buffer::Buffer (size_t size, size_t alignment) : DataPtr (nullptr), DataSize (0), DataAlignment (0) { Allocate (size, alignment); } Buffer::~Buffer () { if (DataPtr != nullptr) Free (); } void Buffer::Allocate (size_t size, size_t alignment) { if (size < 1) throw ParameterIncorrect (SRC_POS); if (DataPtr != nullptr) { if ((DataSize == size) && (DataAlignment == alignment)) return; Free(); } try { - DataPtr = static_cast<byte *> ((alignment > 0)? Memory::AllocateAligned (size, alignment) : Memory::Allocate (size)); + DataPtr = static_cast<uint8 *> ((alignment > 0)? Memory::AllocateAligned (size, alignment) : Memory::Allocate (size)); DataSize = size; DataAlignment = alignment; } catch (...) { DataPtr = nullptr; DataSize = 0; DataAlignment = 0; throw; } } void Buffer::CopyFrom (const ConstBufferPtr &bufferPtr, size_t alignment) { if (!IsAllocated () || ((bufferPtr.Size()) && (DataAlignment != alignment))) { if (IsAllocated ()) Free (); if (bufferPtr.Size()) Allocate (bufferPtr.Size(), alignment); } else if (bufferPtr.Size() > DataSize) throw ParameterTooLarge (SRC_POS); if (bufferPtr.Size()) Memory::Copy (DataPtr, bufferPtr.Get(), bufferPtr.Size()); } void Buffer::Erase () diff --git a/src/Platform/Buffer.h b/src/Platform/Buffer.h index 1150fcf5..a1eb0918 100644 --- a/src/Platform/Buffer.h +++ b/src/Platform/Buffer.h @@ -1,121 +1,121 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Platform_Buffer #define TC_HEADER_Platform_Buffer #include "PlatformBase.h" #include "Memory.h" namespace VeraCrypt { class ConstBufferPtr { public: ConstBufferPtr () : DataPtr (nullptr), DataSize (0) { } - ConstBufferPtr (const byte *data, size_t size) + ConstBufferPtr (const uint8 *data, size_t size) : DataPtr (data), DataSize (size) { } virtual ~ConstBufferPtr () { } - operator const byte * () const { return DataPtr; } + operator const uint8 * () const { return DataPtr; } bool IsDataEqual (const ConstBufferPtr &other) const { return Memory::Compare (DataPtr, DataSize, other.DataPtr, other.DataSize) == 0; } - const byte *Get () const { return DataPtr; } + const uint8 *Get () const { return DataPtr; } ConstBufferPtr GetRange (size_t offset, size_t size) const; - void Set (const byte *data, size_t size) { DataPtr = data; DataSize = size; } + void Set (const uint8 *data, size_t size) { DataPtr = data; DataSize = size; } size_t Size () const { return DataSize; } protected: - const byte *DataPtr; + const uint8 *DataPtr; size_t DataSize; }; class BufferPtr { public: BufferPtr () : DataPtr (nullptr), DataSize (0) { } - BufferPtr (byte *data, size_t size) + BufferPtr (uint8 *data, size_t size) : DataPtr (data), DataSize (size) { } virtual ~BufferPtr () { } - operator byte * () const { return DataPtr; } + operator uint8 * () const { return DataPtr; } void CopyFrom (const ConstBufferPtr &bufferPtr) const; void Erase () const { Zero(); } - byte *Get () const { return DataPtr; } + uint8 *Get () const { return DataPtr; } BufferPtr GetRange (size_t offset, size_t size) const; - void Set (byte *data, size_t size) { DataPtr = data; DataSize = size; } + void Set (uint8 *data, size_t size) { DataPtr = data; DataSize = size; } size_t Size () const { return DataSize; } void Zero () const { Memory::Zero (DataPtr, DataSize); } operator ConstBufferPtr () const { return ConstBufferPtr (DataPtr, DataSize); } protected: - byte *DataPtr; + uint8 *DataPtr; size_t DataSize; }; class Buffer { public: Buffer (); Buffer (size_t size, size_t alignment = 0); Buffer (const ConstBufferPtr &bufferPtr, size_t alignment = 0) { CopyFrom (bufferPtr, alignment); } virtual ~Buffer (); virtual void Allocate (size_t size, size_t alignment = 0); virtual void CopyFrom (const ConstBufferPtr &bufferPtr, size_t alignment = 0); - virtual byte *Ptr () const { return DataPtr; } + virtual uint8 *Ptr () const { return DataPtr; } virtual void Erase (); virtual void Free (); virtual BufferPtr GetRange (size_t offset, size_t size) const; virtual size_t Size () const { return DataSize; } virtual size_t Alignment () const { return DataAlignment; } virtual bool IsAllocated () const { return DataSize != 0; } virtual void Zero (); - virtual operator byte * () const { return DataPtr; } + virtual operator uint8 * () const { return DataPtr; } virtual operator BufferPtr () const { return BufferPtr (DataPtr, DataSize); } virtual operator ConstBufferPtr () const { return ConstBufferPtr (DataPtr, DataSize); } protected: - byte *DataPtr; + uint8 *DataPtr; size_t DataSize; size_t DataAlignment; private: Buffer (const Buffer &); Buffer &operator= (const Buffer &); }; class SecureBuffer : public Buffer { public: SecureBuffer () { } SecureBuffer (size_t size, size_t alignment = 0); SecureBuffer (const ConstBufferPtr &bufferPtr) { CopyFrom (bufferPtr); } virtual ~SecureBuffer (); virtual void Allocate (size_t size, size_t alignment = 0); virtual void Free (); private: SecureBuffer (const SecureBuffer &); SecureBuffer &operator= (const SecureBuffer &); }; } #endif // TC_HEADER_Platform_Buffer diff --git a/src/Platform/FileStream.h b/src/Platform/FileStream.h index 0ef40862..66df1999 100644 --- a/src/Platform/FileStream.h +++ b/src/Platform/FileStream.h @@ -16,47 +16,47 @@ #include "PlatformBase.h" #include "File.h" #include "SharedPtr.h" #include "Stream.h" namespace VeraCrypt { class FileStream : public Stream { public: FileStream (shared_ptr <File> file) : DataFile (file) { } FileStream (File::SystemFileHandleType openFileHandle) { DataFile.reset (new File ()); DataFile->AssignSystemHandle (openFileHandle); } virtual ~FileStream () { } virtual uint64 Read (const BufferPtr &buffer) { return DataFile->Read (buffer); } virtual void ReadCompleteBuffer (const BufferPtr &buffer) { DataFile->ReadCompleteBuffer (buffer); } virtual string ReadToEnd () { string str; vector <char> buffer (4096); uint64 len; - while ((len = DataFile->Read (BufferPtr (reinterpret_cast <byte *> (&buffer[0]), buffer.size()))) > 0) + while ((len = DataFile->Read (BufferPtr (reinterpret_cast <uint8 *> (&buffer[0]), buffer.size()))) > 0) str.insert (str.end(), buffer.begin(), buffer.begin() + static_cast <int> (len)); return str; } virtual void Write (const ConstBufferPtr &data) { DataFile->Write (data); } protected: shared_ptr <File> DataFile; }; } #endif // TC_HEADER_Platform_FileStream diff --git a/src/Platform/Memory.h b/src/Platform/Memory.h index e0d4bfe3..b124022f 100644 --- a/src/Platform/Memory.h +++ b/src/Platform/Memory.h @@ -58,123 +58,123 @@ # define LITTLE_ENDIAN __LITTLE_ENDIAN # endif # ifndef BIG_ENDIAN # define BIG_ENDIAN __BIG_ENDIAN # endif #endif // !BYTE_ORDER #if BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN # error Unsupported byte ordering detected. #endif namespace VeraCrypt { class Memory { public: static void *Allocate (size_t size); static void *AllocateAligned (size_t size, size_t alignment); static int Compare (const void *memory1, size_t size1, const void *memory2, size_t size2); static void Copy (void *memoryDestination, const void *memorySource, size_t size); static void Free (void *memory); static void FreeAligned (void *memory); static void Zero (void *memory, size_t size); }; class Endian { public: - static byte Big (const byte &x) + static uint8 Big (const uint8 &x) { return x; } static uint16 Big (const uint16 &x) { #if BYTE_ORDER == BIG_ENDIAN return x; #else return MirrorBytes (x); #endif } static uint32 Big (const uint32 &x) { #if BYTE_ORDER == BIG_ENDIAN return x; #else return MirrorBytes (x); #endif } static uint64 Big (const uint64 &x) { #if BYTE_ORDER == BIG_ENDIAN return x; #else return MirrorBytes (x); #endif } - static byte Little (const byte &x) + static uint8 Little (const uint8 &x) { return x; } static uint16 Little (const uint16 &x) { #if BYTE_ORDER == LITTLE_ENDIAN return x; #else return MirrorBytes (x); #endif } static uint32 Little (const uint32 &x) { #if BYTE_ORDER == LITTLE_ENDIAN return x; #else return MirrorBytes (x); #endif } static uint64 Little (const uint64 &x) { #if BYTE_ORDER == LITTLE_ENDIAN return x; #else return MirrorBytes (x); #endif } protected: static uint16 MirrorBytes (const uint16 &x) { return (x << 8) | (x >> 8); } static uint32 MirrorBytes (const uint32 &x) { - uint32 n = (byte) x; - n <<= 8; n |= (byte) (x >> 8); - n <<= 8; n |= (byte) (x >> 16); - return (n << 8) | (byte) (x >> 24); + uint32 n = (uint8) x; + n <<= 8; n |= (uint8) (x >> 8); + n <<= 8; n |= (uint8) (x >> 16); + return (n << 8) | (uint8) (x >> 24); } static uint64 MirrorBytes (const uint64 &x) { - uint64 n = (byte) x; - n <<= 8; n |= (byte) (x >> 8); - n <<= 8; n |= (byte) (x >> 16); - n <<= 8; n |= (byte) (x >> 24); - n <<= 8; n |= (byte) (x >> 32); - n <<= 8; n |= (byte) (x >> 40); - n <<= 8; n |= (byte) (x >> 48); - return (n << 8) | (byte) (x >> 56); + uint64 n = (uint8) x; + n <<= 8; n |= (uint8) (x >> 8); + n <<= 8; n |= (uint8) (x >> 16); + n <<= 8; n |= (uint8) (x >> 24); + n <<= 8; n |= (uint8) (x >> 32); + n <<= 8; n |= (uint8) (x >> 40); + n <<= 8; n |= (uint8) (x >> 48); + return (n << 8) | (uint8) (x >> 56); } }; } #endif // TC_HEADER_Platform_Memory diff --git a/src/Platform/MemoryStream.cpp b/src/Platform/MemoryStream.cpp index 8bf229fe..1bd090b9 100644 --- a/src/Platform/MemoryStream.cpp +++ b/src/Platform/MemoryStream.cpp @@ -1,51 +1,51 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Exception.h" #include "MemoryStream.h" namespace VeraCrypt { MemoryStream::MemoryStream (const ConstBufferPtr &data) : ReadPosition (0) { - Data = vector <byte> (data.Size()); + Data = vector <uint8> (data.Size()); BufferPtr (&Data[0], Data.size()).CopyFrom (data); } uint64 MemoryStream::Read (const BufferPtr &buffer) { if (Data.size() == 0) throw ParameterIncorrect (SRC_POS); ConstBufferPtr streamBuf (*this); size_t len = buffer.Size(); if (streamBuf.Size() - ReadPosition < len) len = streamBuf.Size() - ReadPosition; BufferPtr(buffer).CopyFrom (streamBuf.GetRange (ReadPosition, len)); ReadPosition += len; return len; } void MemoryStream::ReadCompleteBuffer (const BufferPtr &buffer) { if (Read (buffer) != buffer.Size()) throw InsufficientData (SRC_POS); } void MemoryStream::Write (const ConstBufferPtr &data) { for (uint64 i = 0; i < data.Size(); i++) Data.push_back (data[i]); } } diff --git a/src/Platform/MemoryStream.h b/src/Platform/MemoryStream.h index 3df0bd13..068e6d6e 100644 --- a/src/Platform/MemoryStream.h +++ b/src/Platform/MemoryStream.h @@ -5,36 +5,36 @@ Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Platform_MemoryStream #define TC_HEADER_Platform_MemoryStream #include "PlatformBase.h" #include "Stream.h" namespace VeraCrypt { class MemoryStream : public Stream { public: MemoryStream () : ReadPosition (0) { } MemoryStream (const ConstBufferPtr &data); virtual ~MemoryStream () { } operator ConstBufferPtr () const { return ConstBufferPtr (&Data[0], Data.size()); } virtual uint64 Read (const BufferPtr &buffer); virtual void ReadCompleteBuffer (const BufferPtr &buffer); virtual void Write (const ConstBufferPtr &data); protected: - vector <byte> Data; + vector <uint8> Data; size_t ReadPosition; }; } #endif // TC_HEADER_Platform_MemoryStream diff --git a/src/Platform/PlatformBase.h b/src/Platform/PlatformBase.h index 22022dc7..e378704c 100644 --- a/src/Platform/PlatformBase.h +++ b/src/Platform/PlatformBase.h @@ -16,71 +16,71 @@ #include <cstddef> #include <list> #include <map> #include <memory> #include <sstream> #include <string> #include <vector> #ifndef _MSC_VER #include <inttypes.h> #endif using namespace std; #ifdef nullptr #undef nullptr #endif #if !(defined(_MSC_VER) && _MSC_VER >= 1600) #define nullptr 0 #endif namespace VeraCrypt { #ifdef _MSC_VER # ifndef TC_INT_TYPES_DEFINED typedef __int8 int8; typedef __int16 int16; typedef __int32 int32; typedef __int64 int64; - typedef unsigned __int8 byte; + typedef unsigned __int8 uint8; typedef unsigned __int16 uint16; typedef unsigned __int32 uint32; typedef unsigned __int64 uint64; # endif #else typedef int8_t int8; typedef int16_t int16; typedef int32_t int32; typedef int64_t int64; - typedef uint8_t byte; + typedef uint8_t uint8; typedef uint16_t uint16; typedef uint32_t uint32; typedef uint64_t uint64; #endif } #if (defined(_WIN32) || defined(_WIN64)) && !defined(TC_WINDOWS) # define TC_WINDOWS #endif #if defined(_DEBUG) && !defined(DEBUG) # define DEBUG #endif #ifndef TC_TO_STRING # define TC_TO_STRING2(n) #n # define TC_TO_STRING(n) TC_TO_STRING2(n) #endif #define TC_JOIN_ARGS(a,b) a##b #define TC_JOIN(a,b) TC_JOIN_ARGS(a,b) #ifdef __GNUC__ template <class T> string GetFunctionName (T pos) { string s (pos); size_t p = s.find ('('); if (p == string::npos) return s; s = s.substr (0, p); diff --git a/src/Platform/PlatformTest.cpp b/src/Platform/PlatformTest.cpp index 7362d6bf..9a3faae2 100644 --- a/src/Platform/PlatformTest.cpp +++ b/src/Platform/PlatformTest.cpp @@ -49,61 +49,61 @@ namespace VeraCrypt uint64 i64 = 0x0123456789abcdefULL; string str = "string test"; wstring wstr = L"wstring test"; string convStr = "test"; StringConverter::ToSingle (wstr, convStr); if (convStr != "wstring test") throw TestFailed (SRC_POS); StringConverter::Erase (convStr); if (convStr != " ") throw TestFailed (SRC_POS); wstring wEraseTest = L"erase test"; StringConverter::Erase (wEraseTest); if (wEraseTest != L" ") throw TestFailed (SRC_POS); list <string> stringList; stringList.push_back (str + "1"); stringList.push_back (str + "2"); stringList.push_back (str + "3"); list <wstring> wstringList; wstringList.push_back (wstr + L"1"); wstringList.push_back (wstr + L"2"); wstringList.push_back (wstr + L"3"); Buffer buffer (10); for (size_t i = 0; i < buffer.Size(); i++) - buffer[i] = (byte) i; + buffer[i] = (uint8) i; ser.Serialize ("int32", i32); ser.Serialize ("int64", i64); ser.Serialize ("string", str); ser.Serialize ("wstring", wstr); ser.Serialize ("stringList", stringList); ser.Serialize ("wstringList", wstringList); ser.Serialize ("buffer", ConstBufferPtr (buffer)); ExecutedProcessFailed ex (SRC_POS, "cmd", -123, "error output"); ex.Serialize (stream); list < shared_ptr <ExecutedProcessFailed> > exList; exList.push_back (make_shared <ExecutedProcessFailed> (ExecutedProcessFailed (SRC_POS, "cmd", -123, "error output1"))); exList.push_back (make_shared <ExecutedProcessFailed> (ExecutedProcessFailed (SRC_POS, "cmd", -234, "error output2"))); exList.push_back (make_shared <ExecutedProcessFailed> (ExecutedProcessFailed (SRC_POS, "cmd", -567, "error output3"))); Serializable::SerializeList (stream, exList); #if 0 if (file->IsOpen()) file->SeekAt (0); #endif uint32 di32; ser.Deserialize ("int32", di32); if (i32 != di32) throw TestFailed (SRC_POS); uint64 di64; ser.Deserialize ("int64", di64); @@ -114,61 +114,61 @@ namespace VeraCrypt ser.Deserialize ("string", dstr); if (str != dstr) throw TestFailed (SRC_POS); wstring dwstr; ser.Deserialize ("wstring", dwstr); if (str != dstr) throw TestFailed (SRC_POS); int i = 1; foreach (string item, ser.DeserializeStringList ("stringList")) { stringstream s; s << str << i++; if (item != s.str()) throw TestFailed (SRC_POS); } i = 1; foreach (wstring item, ser.DeserializeWStringList ("wstringList")) { wstringstream s; s << wstr << i++; if (item != s.str()) throw TestFailed (SRC_POS); } Buffer dbuffer (10); ser.Deserialize ("buffer", buffer); for (size_t i = 0; i < buffer.Size(); i++) - if (buffer[i] != (byte) i) + if (buffer[i] != (uint8) i) throw TestFailed (SRC_POS); shared_ptr <ExecutedProcessFailed> dex = Serializable::DeserializeNew <ExecutedProcessFailed> (stream); if (!dex || dex->GetCommand() != "cmd" || dex->GetExitCode() != -123 || dex->GetErrorOutput() != "error output") throw TestFailed (SRC_POS); list < shared_ptr <ExecutedProcessFailed> > dexList; Serializable::DeserializeList (stream, dexList); i = 1; foreach_ref (const ExecutedProcessFailed &ex, dexList) { stringstream s; s << "error output" << i++; if (ex.GetErrorOutput() != s.str()) throw TestFailed (SRC_POS); } } // shared_ptr, Mutex, ScopeLock, SyncEvent, Thread static struct { shared_ptr <int> SharedIntPtr; Mutex IntMutex; SyncEvent ExitAllowedEvent; } ThreadTestData; void PlatformTest::ThreadTest () @@ -211,61 +211,61 @@ namespace VeraCrypt } if (*ThreadTestData.SharedIntPtr != 0) throw TestFailed (SRC_POS); } TC_THREAD_PROC PlatformTest::ThreadTestProc (void *arg) { if (arg != (void *) &ThreadTestData) return 0; { ScopeLock sl (ThreadTestData.IntMutex); ++(*ThreadTestData.SharedIntPtr); } ThreadTestData.ExitAllowedEvent.Wait(); { ScopeLock sl (ThreadTestData.IntMutex); --(*ThreadTestData.SharedIntPtr); } return 0; } bool PlatformTest::TestAll () { // Integer types - if (sizeof (byte) != 1 || sizeof (int8) != 1 || sizeof (__int8) != 1) throw TestFailed (SRC_POS); + if (sizeof (uint8) != 1 || sizeof (int8) != 1 || sizeof (__int8) != 1) throw TestFailed (SRC_POS); if (sizeof (uint16) != 2 || sizeof (int16) != 2 || sizeof (__int16) != 2) throw TestFailed (SRC_POS); if (sizeof (uint32) != 4 || sizeof (int32) != 4 || sizeof (__int32) != 4) throw TestFailed (SRC_POS); if (sizeof (uint64) != 8 || sizeof (int64) != 8) throw TestFailed (SRC_POS); // Exception handling TestFlag = false; try { try { throw TestFailed (SRC_POS); } catch (...) { throw; } return false; } catch (Exception &) { TestFlag = true; } if (!TestFlag) return false; // RTTI RttiTest rtti; RttiTestBase &rttiBaseRef = rtti; RttiTestBase *rttiBasePtr = &rtti; diff --git a/src/Platform/Serializer.cpp b/src/Platform/Serializer.cpp index b69fe891..6f428b15 100644 --- a/src/Platform/Serializer.cpp +++ b/src/Platform/Serializer.cpp @@ -1,74 +1,74 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Exception.h" #include "ForEach.h" #include "Memory.h" #include "Serializer.h" namespace VeraCrypt { template <typename T> T Serializer::Deserialize () { uint64 size; - DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &size, sizeof (size))); + DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &size, sizeof (size))); if (Endian::Big (size) != sizeof (T)) throw ParameterIncorrect (SRC_POS); T data; - DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data, sizeof (data))); + DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data, sizeof (data))); return Endian::Big (data); } void Serializer::Deserialize (const string &name, bool &data) { ValidateName (name); - data = Deserialize <byte> () == 1; + data = Deserialize <uint8> () == 1; } - void Serializer::Deserialize (const string &name, byte &data) + void Serializer::Deserialize (const string &name, uint8 &data) { ValidateName (name); - data = Deserialize <byte> (); + data = Deserialize <uint8> (); } void Serializer::Deserialize (const string &name, int32 &data) { ValidateName (name); data = (int32) Deserialize <uint32> (); } void Serializer::Deserialize (const string &name, int64 &data) { ValidateName (name); data = (int64) Deserialize <uint64> (); } void Serializer::Deserialize (const string &name, uint32 &data) { ValidateName (name); data = Deserialize <uint32> (); } void Serializer::Deserialize (const string &name, uint64 &data) { ValidateName (name); data = Deserialize <uint64> (); } void Serializer::Deserialize (const string &name, string &data) { ValidateName (name); data = DeserializeString (); @@ -100,129 +100,129 @@ namespace VeraCrypt int32 Serializer::DeserializeInt32 (const string &name) { ValidateName (name); return Deserialize <uint32> (); } int64 Serializer::DeserializeInt64 (const string &name) { ValidateName (name); return Deserialize <uint64> (); } uint32 Serializer::DeserializeUInt32 (const string &name) { ValidateName (name); return Deserialize <uint32> (); } uint64 Serializer::DeserializeUInt64 (const string &name) { ValidateName (name); return Deserialize <uint64> (); } string Serializer::DeserializeString () { uint64 size = Deserialize <uint64> (); vector <char> data ((size_t) size); - DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data[0], (size_t) size)); + DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data[0], (size_t) size)); return string (&data[0]); } string Serializer::DeserializeString (const string &name) { ValidateName (name); return DeserializeString (); } list <string> Serializer::DeserializeStringList (const string &name) { ValidateName (name); list <string> deserializedList; uint64 listSize = Deserialize <uint64> (); for (size_t i = 0; i < listSize; i++) deserializedList.push_back (DeserializeString ()); return deserializedList; } wstring Serializer::DeserializeWString () { uint64 size = Deserialize <uint64> (); vector <wchar_t> data ((size_t) size / sizeof (wchar_t)); - DataStream->ReadCompleteBuffer (BufferPtr ((byte *) &data[0], (size_t) size)); + DataStream->ReadCompleteBuffer (BufferPtr ((uint8 *) &data[0], (size_t) size)); return wstring (&data[0]); } list <wstring> Serializer::DeserializeWStringList (const string &name) { ValidateName (name); list <wstring> deserializedList; uint64 listSize = Deserialize <uint64> (); for (size_t i = 0; i < listSize; i++) deserializedList.push_back (DeserializeWString ()); return deserializedList; } wstring Serializer::DeserializeWString (const string &name) { ValidateName (name); return DeserializeWString (); } template <typename T> void Serializer::Serialize (T data) { uint64 size = Endian::Big (uint64 (sizeof (data))); - DataStream->Write (ConstBufferPtr ((byte *) &size, sizeof (size))); + DataStream->Write (ConstBufferPtr ((uint8 *) &size, sizeof (size))); data = Endian::Big (data); - DataStream->Write (ConstBufferPtr ((byte *) &data, sizeof (data))); + DataStream->Write (ConstBufferPtr ((uint8 *) &data, sizeof (data))); } void Serializer::Serialize (const string &name, bool data) { SerializeString (name); - byte d = data ? 1 : 0; + uint8 d = data ? 1 : 0; Serialize (d); } - void Serializer::Serialize (const string &name, byte data) + void Serializer::Serialize (const string &name, uint8 data) { SerializeString (name); Serialize (data); } void Serializer::Serialize (const string &name, const char *data) { Serialize (name, string (data)); } void Serializer::Serialize (const string &name, int32 data) { SerializeString (name); Serialize ((uint32) data); } void Serializer::Serialize (const string &name, int64 data) { SerializeString (name); Serialize ((uint64) data); } void Serializer::Serialize (const string &name, uint32 data) { SerializeString (name); Serialize (data); } void Serializer::Serialize (const string &name, uint64 data) { @@ -255,49 +255,49 @@ namespace VeraCrypt Serialize (listSize); foreach (const string &item, stringList) SerializeString (item); } void Serializer::Serialize (const string &name, const list <wstring> &stringList) { SerializeString (name); uint64 listSize = stringList.size(); Serialize (listSize); foreach (const wstring &item, stringList) SerializeWString (item); } void Serializer::Serialize (const string &name, const ConstBufferPtr &data) { SerializeString (name); uint64 size = data.Size(); Serialize (size); DataStream->Write (data); } void Serializer::SerializeString (const string &data) { Serialize ((uint64) data.size() + 1); - DataStream->Write (ConstBufferPtr ((byte *) (data.data() ? data.data() : data.c_str()), data.size() + 1)); + DataStream->Write (ConstBufferPtr ((uint8 *) (data.data() ? data.data() : data.c_str()), data.size() + 1)); } void Serializer::SerializeWString (const wstring &data) { uint64 size = (data.size() + 1) * sizeof (wchar_t); Serialize (size); - DataStream->Write (ConstBufferPtr ((byte *) (data.data() ? data.data() : data.c_str()), (size_t) size)); + DataStream->Write (ConstBufferPtr ((uint8 *) (data.data() ? data.data() : data.c_str()), (size_t) size)); } void Serializer::ValidateName (const string &name) { string dName = DeserializeString(); if (dName != name) { throw ParameterIncorrect (SRC_POS); } } } diff --git a/src/Platform/Serializer.h b/src/Platform/Serializer.h index c2dac324..3617a83b 100644 --- a/src/Platform/Serializer.h +++ b/src/Platform/Serializer.h @@ -1,78 +1,78 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Platform_Serializer #define TC_HEADER_Platform_Serializer #include "PlatformBase.h" #include "Buffer.h" #include "SharedPtr.h" #include "Stream.h" namespace VeraCrypt { class Serializer { public: Serializer (shared_ptr <Stream> stream) : DataStream (stream) { } virtual ~Serializer () { } void Deserialize (const string &name, bool &data); - void Deserialize (const string &name, byte &data); + void Deserialize (const string &name, uint8 &data); void Deserialize (const string &name, int32 &data); void Deserialize (const string &name, int64 &data); void Deserialize (const string &name, uint32 &data); void Deserialize (const string &name, uint64 &data); void Deserialize (const string &name, string &data); void Deserialize (const string &name, wstring &data); void Deserialize (const string &name, const BufferPtr &data); bool DeserializeBool (const string &name); int32 DeserializeInt32 (const string &name); int64 DeserializeInt64 (const string &name); uint32 DeserializeUInt32 (const string &name); uint64 DeserializeUInt64 (const string &name); string DeserializeString (const string &name); list <string> DeserializeStringList (const string &name); wstring DeserializeWString (const string &name); list <wstring> DeserializeWStringList (const string &name); void Serialize (const string &name, bool data); - void Serialize (const string &name, byte data); + void Serialize (const string &name, uint8 data); void Serialize (const string &name, const char *data); void Serialize (const string &name, int32 data); void Serialize (const string &name, int64 data); void Serialize (const string &name, uint32 data); void Serialize (const string &name, uint64 data); void Serialize (const string &name, const string &data); void Serialize (const string &name, const wstring &data); void Serialize (const string &name, const wchar_t *data); void Serialize (const string &name, const list <string> &stringList); void Serialize (const string &name, const list <wstring> &stringList); void Serialize (const string &name, const ConstBufferPtr &data); protected: template <typename T> T Deserialize (); string DeserializeString (); wstring DeserializeWString (); template <typename T> void Serialize (T data); void SerializeString (const string &data); void SerializeWString (const wstring &data); void ValidateName (const string &name); shared_ptr <Stream> DataStream; private: Serializer (const Serializer &); Serializer &operator= (const Serializer &); }; } #endif // TC_HEADER_Platform_Serializer diff --git a/src/Platform/SharedPtr.h b/src/Platform/SharedPtr.h index 29669714..f80b2167 100644 --- a/src/Platform/SharedPtr.h +++ b/src/Platform/SharedPtr.h @@ -1,54 +1,54 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Platform_SharedPtr #define TC_HEADER_Platform_SharedPtr #include <stdexcept> #include <memory> #include "SharedVal.h" #ifdef nullptr namespace VeraCrypt { -#if (__cplusplus >= 201103L) +#if (__cplusplus >= 201103L) || defined(__GXX_EXPERIMENTAL_CXX0X__) #define VC_USE_NATIVE_PTR 1 #endif #ifdef VC_USE_NATIVE_PTR #define shared_ptr std::shared_ptr #define make_shared std::make_shared #define move_ptr std::move #else template <class T> class SharedPtr { public: explicit SharedPtr () : Pointer (nullptr), UseCount (nullptr) { } explicit SharedPtr (T *pointer) : Pointer (pointer), UseCount (new SharedVal <uint64> (1)) { } SharedPtr (const SharedPtr &source) { CopyFrom (source); } ~SharedPtr () { Release(); } diff --git a/src/Platform/StringConverter.cpp b/src/Platform/StringConverter.cpp index e1a6df98..7b3134ee 100644 --- a/src/Platform/StringConverter.cpp +++ b/src/Platform/StringConverter.cpp @@ -358,62 +358,62 @@ namespace VeraCrypt if (size == (size_t) -1) throw StringConversionFailed (SRC_POS); vector <wchar_t> buf (size + 1); Memory::Zero (&mbState, sizeof (mbState)); if ((size = mbsrtowcs (&buf[0], &src, buf.size(), &mbState)) == (size_t) -1) throw StringConversionFailed (SRC_POS); wstring s; s.insert (s.begin(), buf.begin(), buf.begin() + size); return s; } catch (...) { if (noThrow) return L""; throw; } } void StringConverter::ToWideBuffer (const wstring &str, wchar_t *buffer, size_t bufferSize) { if (str.length() < 1) { buffer[0] = 0; return; } BufferPtr ( - (byte *) buffer, + (uint8 *) buffer, bufferSize).CopyFrom ( - ConstBufferPtr ((byte *) (wstring (str).c_str()), + ConstBufferPtr ((uint8 *) (wstring (str).c_str()), (str.length() + 1) * sizeof (wchar_t) ) ); } string StringConverter::Trim (const string &str) { size_t start = 0; size_t end = str.size(); if (end < 1) return str; foreach (char c, str) { if (c > ' ') break; ++start; } foreach_reverse (char c, str) { if (c > ' ') break; --end; } return str.substr (start, end - start); } } diff --git a/src/Platform/TextReader.cpp b/src/Platform/TextReader.cpp index 7d6a0c64..bdaf19c2 100644 --- a/src/Platform/TextReader.cpp +++ b/src/Platform/TextReader.cpp @@ -1,41 +1,41 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "TextReader.h" namespace VeraCrypt { TextReader::TextReader (const FilePath &path) { InputFile.reset (new File); InputFile->Open (path); InputStream = shared_ptr <Stream> (new FileStream (InputFile)); } bool TextReader::ReadLine (string &outputString) { outputString.erase(); char c; - while (InputStream->Read (BufferPtr ((byte *) &c, sizeof (c))) == sizeof (c)) + while (InputStream->Read (BufferPtr ((uint8 *) &c, sizeof (c))) == sizeof (c)) { if (c == '\r') continue; if (c == '\n') return true; outputString += c; } return !outputString.empty(); } } diff --git a/src/Platform/Unix/File.cpp b/src/Platform/Unix/File.cpp index d3413800..207efb4e 100644 --- a/src/Platform/Unix/File.cpp +++ b/src/Platform/Unix/File.cpp @@ -195,60 +195,71 @@ namespace VeraCrypt #else throw NotImplemented (SRC_POS); #endif } uint64 File::Length () const { if_debug (ValidateState()); // BSD does not support seeking to the end of a device #ifdef TC_BSD if (Path.IsBlockDevice() || Path.IsCharacterDevice()) { # ifdef TC_MACOSX uint32 blockSize; uint64 blockCount; throw_sys_sub_if (ioctl (FileHandle, DKIOCGETBLOCKSIZE, &blockSize) == -1, wstring (Path)); throw_sys_sub_if (ioctl (FileHandle, DKIOCGETBLOCKCOUNT, &blockCount) == -1, wstring (Path)); return blockCount * blockSize; # elif TC_OPENBSD struct disklabel dl; throw_sys_sub_if (ioctl (FileHandle, DIOCGPDINFO, &dl) == -1, wstring (Path)); return DL_GETDSIZE(&dl); # else uint64 mediaSize; throw_sys_sub_if (ioctl (FileHandle, DIOCGMEDIASIZE, &mediaSize) == -1, wstring (Path)); return mediaSize; # endif } #endif +#ifdef TC_LINUX + // On Linux, try to use BLKGETSIZE64 for devices + if (Path.IsDevice()) + { + uint64 mediaSize; + if (ioctl (FileHandle, BLKGETSIZE64, &mediaSize) != -1) + { + return mediaSize; + } + } +#endif off_t current = lseek (FileHandle, 0, SEEK_CUR); throw_sys_sub_if (current == -1, wstring (Path)); SeekEnd (0); uint64 length = lseek (FileHandle, 0, SEEK_CUR); SeekAt (current); return length; } void File::Open (const FilePath &path, FileOpenMode mode, FileShareMode shareMode, FileOpenFlags flags) { #ifdef TC_LINUX int sysFlags = O_LARGEFILE; #else int sysFlags = 0; #endif switch (mode) { case CreateReadWrite: sysFlags |= O_CREAT | O_TRUNC | O_RDWR; break; case CreateWrite: sysFlags |= O_CREAT | O_TRUNC | O_WRONLY; break; case OpenRead: sysFlags |= O_RDONLY; break; diff --git a/src/Platform/Unix/Process.cpp b/src/Platform/Unix/Process.cpp index 36b01e6b..46b14a1e 100644 --- a/src/Platform/Unix/Process.cpp +++ b/src/Platform/Unix/Process.cpp @@ -147,59 +147,59 @@ namespace VeraCrypt stdOutput.insert (stdOutput.end(), buffer.begin(), buffer.begin() + bytesRead); else if (fd == errPipe.GetReadFD()) errOutput.insert (errOutput.end(), buffer.begin(), buffer.begin() + bytesRead); else if (fd == exceptionPipe.GetReadFD()) exOutput.insert (exOutput.end(), buffer.begin(), buffer.begin() + bytesRead); } } if (bytesRead == 0) { waitRes = waitpid (forkedPid, &status, 0); break; } } catch (TimeOut&) { timeTaken += pollTimeout; if (timeOut >= 0 && timeTaken >= timeOut) throw; } } while ((waitRes = waitpid (forkedPid, &status, WNOHANG)) == 0); throw_sys_if (waitRes == -1); if (!exOutput.empty()) { unique_ptr <Serializable> deserializedObject; Exception *deserializedException = nullptr; try { - shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((byte *) &exOutput[0], exOutput.size()))); + shared_ptr <Stream> stream (new MemoryStream (ConstBufferPtr ((uint8 *) &exOutput[0], exOutput.size()))); deserializedObject.reset (Serializable::DeserializeNew (stream)); deserializedException = dynamic_cast <Exception*> (deserializedObject.get()); } catch (...) { } if (deserializedException) deserializedException->Throw(); } int exitCode = (WIFEXITED (status) ? WEXITSTATUS (status) : 1); if (exitCode != 0) { string strErrOutput; if (!errOutput.empty()) strErrOutput.insert (strErrOutput.begin(), errOutput.begin(), errOutput.end()); throw ExecutedProcessFailed (SRC_POS, processName, exitCode, strErrOutput); } string strOutput; if (!stdOutput.empty()) strOutput.insert (strOutput.begin(), stdOutput.begin(), stdOutput.end()); return strOutput; } } diff --git a/src/Readme.txt b/src/Readme.txt index babc3d69..a20ab4f8 100644 --- a/src/Readme.txt +++ b/src/Readme.txt @@ -74,174 +74,191 @@ The folder "Signing" contains a batch file (sign.bat) that will sign all VeraCrypt components using a code signing certificate present on the certificate store and also build the final installation setup and MSI package. The batch file suppose that the code signing certificate is issued by GlobalSign. This is the case for IDRIX's certificate. If yours is issued by another CA, then you should put its intermediate certificates in the "Signing" folder and modify sign.bat accordingly. In order to generate MSI packages, WiX Toolset v3.11 must be installed. VeraCrypt EFI Boot Loader: -------------------------- VeraCrypt source code contains pre-built EFI binaries under src\Boot\EFI. The source code of VeraCrypt EFI Boot Loader is licensed under LGPL and it is available at https://github.com/veracrypt/VeraCrypt-DCS. For build instructions, please refer to the file src\Boot\EFI\Readme.txt. II. Linux and Mac OS X ====================== A detailed guide on how to build VeraCrypt on Linux can be found in the file doc/html/CompilingGuidelineLinux.html. it is also available online at https://www.veracrypt.fr/en/CompilingGuidelineLinux.html Requirements for Building VeraCrypt for Linux and Mac OS X: ----------------------------------------------------------- - GNU Make - GNU C++ Compiler 4.0 or compatible -- Apple Xcode (Mac OS X only) +- Apple Xcode or Xcode command line tools (Mac OS X only) - YASM 1.3.0 or newer (Linux only, x86/x64 architecture only) - pkg-config - wxWidgets 3.0 shared library and header files installed or wxWidgets 3.0 library source code (available at https://www.wxwidgets.org) - FUSE library and header files (available at https://github.com/libfuse/libfuse and https://osxfuse.github.io/) - PCSC-lite library and header files (available at https://github.com/LudovicRousseau/PCSC) Instructions for Building VeraCrypt for Linux and Mac OS X: ----------------------------------------------------------- 1) Change the current directory to the root of the VeraCrypt source code. 2) If you have no wxWidgets shared library installed, run the following command to configure the wxWidgets static library for VeraCrypt and to build it: $ make WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild The variable WX_ROOT must point to the location of the source code of the wxWidgets library. Output files will be placed in the './wxrelease/' directory. 3) To build VeraCrypt, run the following command: $ make or if you have no wxWidgets shared library installed: $ make WXSTATIC=1 4) If successful, the VeraCrypt executable should be located in the directory 'Main'. By default, a universal executable supporting both graphical and text user interface (through the switch --text) is built. On Linux, a console-only executable, which requires no GUI library, can be built using the 'NOGUI' parameter: $ make NOGUI=1 WXSTATIC=1 WX_ROOT=/usr/src/wxWidgets wxbuild $ make NOGUI=1 WXSTATIC=1 On MacOSX, building a console-only executable is not supported. Mac OS X specifics: ----------------------------------------------------------- -Under MacOSX, the SDK for OSX 11.3 is used by default. To use another version -of the SDK (i.e. 10.15), you can export the environment variable VC_OSX_TARGET: +Under MacOSX, the lastest installed SDK is used by default. To use a different version +of the SDK when building using make, you can export the environment variable VC_OSX_SDK: - $ export VC_OSX_TARGET=10.15 + $ export VC_OSX_SDK=13.0 +For development dependencies management, you can use homebrew (https://brew.sh). -Before building under MacOSX, pkg-config must be installed if not yet available. -Get it from https://pkgconfig.freedesktop.org/releases/pkg-config-0.28.tar.gz and + $ brew install pkg-config yasm wxwidgets + +You also need system dependencies + + $ brew install --cask macfuse packages + +After installating dependencies via brew, you can build a local development build + + $ ./src/Build/build_veracrypt_macosx.sh -b + +If you want to build the package, you also need to pass `-p` to the build script above. The built +executable will be in `.src/Main` + +If you prefer to build from sources, or without homebrew, pkg-config and packages must be installed. + +Get pkg-config from https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz and compile using the following commands : - $ ./configure --with-internal-glib + $ CFLAGS="-Wno-int-conversion" CXXFLAGS="-Wno-int-conversion" ./configure --with-internal-glib $ make $ sudo make install After making sure pkg-config is available, download and install OSXFuse from https://osxfuse.github.io/ The script build_veracrypt_macosx.sh available under "src/Build" performs the full build of VeraCrypt including the creation of the installer pkg. It expects -to find the wxWidgets 3.1.2 sources at the same level as where you put +to find the wxWidgets 3.2.5 sources at the same level as where you put VeraCrypt sources (i.e. if "src" path is "/Users/joe/Projects/VeraCrypt/src" -then wxWidgets should be at "/Users/joe/Projects/wxWidgets-3.1.2") +then wxWidgets should be at "/Users/joe/Projects/wxWidgets-3.2.5") -The build process uses Code Signing certificates whose ID is specified in +The make build process uses Code Signing certificates whose ID is specified in src/Main/Main.make (look for lines containing "Developer ID Application" and "Developer ID Installer"). You'll have to modify these lines to put the ID of your Code Signing certificates or comment them if you don't have one. Because of incompatibility issues with OSXFUSE, the SDK 10.9 generates a VeraCrypt binary that has issues communicating with the OSXFUSE kernel extension. Thus, we recommend using a different OSX SDK version for building VeraCrypt. - +To build the installation package, you will need Packages (http://s.sudre.free.fr/Software/Packages/about.html). +The Packages installer that is used for VeraCrypt official build has been notarized by IDRIX and it is available at +https://github.com/idrassi/packages/releases III. FreeBSD ============================ FreeBSD is supported starting from version 11. The build requirements and instructions are the same as Linux except that gmake should be used instead of make. IV. Third-Party Developers (Contributors) ========================================= If you intend to implement a feature, please contact us first to make sure: 1) That the feature has not been implemented (we may have already implemented it, but haven't released the code yet). 2) That the feature is acceptable. 3) Whether we need help of third-party developers with implementing the feature. Information on how to contact us can be found at: https://www.veracrypt.fr/ V. Legal Information ==================== Copyright Information --------------------- This software as a whole: -Copyright (c) 2013-2023 IDRIX. All rights reserved. +Copyright (c) 2013-2024 IDRIX. All rights reserved. Portions of this software: -Copyright (c) 2013-2023 IDRIX. All rights reserved. +Copyright (c) 2013-2024 IDRIX. All rights reserved. Copyright (c) 2003-2012 TrueCrypt Developers Association. All rights reserved. Copyright (c) 1998-2000 Paul Le Roux. All rights reserved. Copyright (c) 1998-2008 Brian Gladman, Worcester, UK. All rights reserved. -Copyright (c) 1995-2017 Jean-loup Gailly and Mark Adler. +Copyright (c) 1995-2023 Jean-loup Gailly and Mark Adler. Copyright (c) 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov -Copyright (c) 1999-2020 Dieter Baron and Thomas Klausner. +Copyright (c) 1999-2023 Dieter Baron and Thomas Klausner. Copyright (c) 2013, Alexey Degtyarev. All rights reserved. Copyright (c) 1999-2016 Jack Lloyd. All rights reserved. Copyright (c) 2013-2019 Stephan Mueller <smueller@chronox.de> -Copyright (c) 1999-2021 Igor Pavlov +Copyright (c) 1999-2023 Igor Pavlov For more information, please see the legal notices attached to parts of the source code. Trademark Information --------------------- Any trademarks contained in the source code, binaries, and/or in the documentation, are the sole property of their respective owners. VI. Further Information ======================= https://www.veracrypt.fr diff --git a/src/Release/Setup Files/Product64.wxs b/src/Release/Setup Files/Product64.wxs index fdf521ec..00fdad6a 100644 --- a/src/Release/Setup Files/Product64.wxs +++ b/src/Release/Setup Files/Product64.wxs @@ -1,45 +1,45 @@ <?xml version="1.0" encoding="utf-8"?> <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"> <!-- FullProductVersion's first 3 parts MUST BE incremented at each release in order for upgrades to work ; Windows Installer ignores the 4th part --> - <?define var.FullProductVersion = 1.26.4?> + <?define var.FullProductVersion = 1.26.15?> <?define var.ProductName = VeraCrypt $(var.FullProductVersion)?> <!-- Unique GUID identifying this family of product (32-bit and 64-bit have the same) --> <?define var.UpgradeCode = {298F5D2B-3B01-4A13-BEFD-4B3C7BE43BC6}?> <!-- Unique GUID identifying this product release (32-bit and 64-bit have different ones) --> <!-- MUST BE regenerated for each new release --> - <?define var.ProductGuid = {2F519B5E-B6A3-4050-8B79-0E420AF5581D}?> + <?define var.ProductGuid = {71867013-A794-4A50-AC6A-0153F9868C8C}?> <!-- Unique GUID identifying a particular Windows Installer package --> <!-- When compiling a product, it should not be set in order to allow it to be generated for each build --> <?define var.PackageCode = "*"?> <!-- Set path to License file --> <?define var.licenseRtf = "$(sys.CURRENTDIR)\License.rtf"?> <!-- See https://wixtoolset.org/documentation/manual/v3/xsd/wix/product.html --> <!-- Lang will be defined in a .wxl file which will be passed to the WIX linker 'light' --> <Product Id="$(var.ProductGuid)" Language="!(loc.Lang)" Manufacturer="IDRIX" Name="$(var.ProductName)" Version="$(var.FullProductVersion)" UpgradeCode="$(var.UpgradeCode)"> <!-- See https://wixtoolset.org/documentation/manual/v3/xsd/wix/package.html --> <!-- InstallerVersion="500"(v5.0) Released with Windows 7 and later, see https://en.wikipedia.org/wiki/Windows_Installer --> <!-- Language IDs (LCIDs) can be found here https://docs.microsoft.com/en-us/previous-versions/windows/embedded/ms912047(v=winembedded.10)?redirectedfrom=MSDN --> <!-- InstallScope="perMachine" sets <Property Id="ALLUSERS" Value="1". Because we set it manually from checkbox, we do not set InstallScope. /> --> <!-- InstallPrivileges="elevated" makes it so that Install button has little shield which prompts for Admin password if needed. If the MSI is installed from an elevated cmd, no password is asked --> <!-- Languages is optional ; We set it to 0 to avoid LGHT0309 : Failed to open merge module for validation --> <Package Compressed="yes" Id="$(var.PackageCode)" InstallerVersion="500" InstallPrivileges="elevated" Keywords="VeraCrypt MSI Installer" Manufacturer="IDRIX" @@ -194,904 +194,1524 @@ <Directory Id="System64Folder"> <!-- Reference C:\Windows\System32\Drivers --> <!-- The directory is not created here, instead if is implicitly created when we add install using { Component, Files } ... --> <!-- The creation can be forced without installing files by setting CreateFolder inside Component --> <Directory Id="DRIVERSFOLDER" Name="Drivers"/> </Directory> <!-- Reference C:\Program Files (only 64-bit) --> <Directory Id="ProgramFiles64Folder"> <!-- Reference C:\Program Files\VeraCrypt --> <!-- The directory is not created here, instead if is implicitly created when we install files using { Component, Files } ... --> <!-- The creation can be forced without installing files by setting CreateFolder inside Component --> <Directory Id="APPLICATIONROOTFOLDER" Name="VeraCrypt"> <!-- Reference C:\Program Files\VeraCrypt\Languages --> <Directory Id="LANGUAGESFOLDER" Name="Languages"/> <!-- Reference C:\Program Files\VeraCrypt\docs --> <Directory Id="DOCSFOLDER" Name="docs"> <!-- Reference C:\Program Files\VeraCrypt\docs\EFI-DCS --> <Directory Id="EFIDOCSFOLDER" Name="EFI-DCS"/> <!-- Reference C:\Program Files\VeraCrypt\docs\html --> <Directory Id="HTMLDOCSFOLDER" Name="html"> <!-- Reference C:\Program Files\VeraCrypt\docs\html\en --> - <Directory Id="ENHTMLDOCSFOLDER" Name="en"/> + <Directory Id="ENHTMLDOCSFOLDER" Name="en"> + + <!-- Reference C:\Program Files\VeraCrypt\docs\html\en\CompilingGuidelineWin --> + <Directory Id="ENGUIDEHTMLFOLDER" Name="CompilingGuidelineWin"/> + + <!-- Reference C:\Program Files\VeraCrypt\docs\html\en\ru --> + <Directory Id="ENRUHTMLFOLDER" Name="ru"/> + + </Directory> </Directory> </Directory> </Directory> </Directory> </Directory> <!-- Directories referencing to install components --> <!-- Refer to C:\Windows\System32\Drivers in order to install files in it --> <DirectoryRef Id="DRIVERSFOLDER"> <!-- Add files to the installer package inside components --> <!-- We restrict ourselves to a single file per component to avoid any problems --> <!-- Generatable guids are supported only for components with a single file as the component's keypath or no files and a registry value as the keypath --> <!-- The KeyPath for a Component is a single resource that the Windows Installer uses to determine if a Component "exists" on a machine --> <Component Id="veracryptDriverSys" Guid="{6A1833A1-8A99-42B0-8ABF-9601EFE54DB8}" > <File Id="veracryptDriver.sys" Name="veracrypt.sys" Source="$(sys.CURRENTDIR)\veracrypt-x64.sys" KeyPath="yes" DiskId="1" /> </Component> </DirectoryRef> <!-- Refer to C:\Program Files\VeraCrypt in order to install files in it --> <DirectoryRef Id="APPLICATIONROOTFOLDER"> <Component Id="LICENSEFile" Guid="{370D29C4-3A58-4B9E-A0D6-A06430FCCA6D}"> - <File Id="LICENSE" Name="LICENSE" Source="$(sys.CURRENTDIR)\LICENSE" KeyPath="yes" DiskId="1" /> + <File Id="LICENSE" Name="LICENSE" Source="$(sys.CURRENTDIR)\LICENSE" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="LicenseTxt" Guid="{14F0F218-FBA2-4C68-820B-376345AB9D33}"> - <File Id="License.txt" Name="License.txt" Source="$(sys.CURRENTDIR)\License.txt" KeyPath="yes" DiskId="1" /> + <File Id="License.txt" Name="License.txt" Source="$(sys.CURRENTDIR)\License.txt" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="NOTICEFile" Guid="{56980D3E-9568-446D-8518-CA381EBE56C4}"> - <File Id="NOTICE" Name="NOTICE" Source="$(sys.CURRENTDIR)\NOTICE" KeyPath="yes" DiskId="1" /> + <File Id="NOTICE" Name="NOTICE" Source="$(sys.CURRENTDIR)\NOTICE" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="VeraCrypt_FormatExe" Guid="{55F89F55-62A6-40D0-A7B4-BC2505C118AA}"> <File Id="VeraCrypt_Format.exe" Name="VeraCrypt Format.exe" Source="$(sys.CURRENTDIR)\VeraCrypt Format-x64.exe" KeyPath="yes" DiskId="1" /> </Component> <Component Id="veracryptCat" Guid="{F1910CF2-3DA7-471D-845E-1A1C20AD3076}"> - <File Id="veracrypt.cat" Name="veracrypt.cat" Source="$(sys.CURRENTDIR)\veracrypt-x64.cat" KeyPath="yes" DiskId="1" /> + <File Id="veracrypt.cat" Name="veracrypt.cat" Source="$(sys.CURRENTDIR)\veracrypt-x64.cat" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="VeraCryptExe" Guid="{9C13F7BE-6ACE-48DE-BD44-714F421ADC2C}"> <File Id="VeraCrypt.exe" Name="VeraCrypt.exe" Source="$(sys.CURRENTDIR)\VeraCrypt-x64.exe" KeyPath="yes" DiskId="1" /> </Component> <Component Id="veracryptInf" Guid="{955B99DC-74C3-476D-8ECE-52FD0916EA34}"> - <File Id="veracrypt.inf" Name="veracrypt.inf" Source="$(sys.CURRENTDIR)\veracrypt.inf" KeyPath="yes" DiskId="1" /> + <File Id="veracrypt.inf" Name="veracrypt.inf" Source="$(sys.CURRENTDIR)\veracrypt.inf" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="veracryptSys" Guid="{5CE01773-01EA-417C-BBA4-8363881763DC}"> <File Id="veracrypt.sys" Name="veracrypt.sys" Source="$(sys.CURRENTDIR)\veracrypt-x64.sys" KeyPath="yes" DiskId="1" /> </Component> <Component Id="VeraCryptExpanderExe" Guid="{FF1F4376-9025-4124-808E-1C4B58024F14}"> <File Id="VeraCryptExpander.exe" Name="VeraCryptExpander.exe" Source="$(sys.CURRENTDIR)\VeraCryptExpander-x64.exe" KeyPath="yes" DiskId="1" /> </Component> <Component Id="VeraCryptComRegExe" Guid="{A922CAA3-5D78-49BC-92C9-B317FD7050A7}"> <!-- Needed only to be able to perform RegisterComServers() & UnregisterComServers --> <File Id="VeraCryptComReg.exe" Name="VeraCrypt COMReg.exe" Source="$(sys.CURRENTDIR)\VeraCrypt COMReg.exe" Hidden="yes" KeyPath="yes" DiskId="1" /> </Component> </DirectoryRef> <!-- Refer to C:\Program Files\VeraCrypt\Languages in order to install files in it --> <!-- Components generated using 'heat dir ".\Translations" -gg -sfrag -template:fragment -out directory.wxs -var "sys.CURRENTDIR"' --> <DirectoryRef Id="LANGUAGESFOLDER"> <Component Id="cmpF27E43A4E59E04A5B095C5101B229139" Guid="{8EB22F2F-AFE2-45E5-92C3-AB50B377935E}"> - <File Id="fil1B0F0BB59C5EE9FC44F8DA3BA57CB272" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ar.xml" DiskId="1" /> + <File Id="fil1B0F0BB59C5EE9FC44F8DA3BA57CB272" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ar.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4350812363930B900E24C845940DF416" Guid="{52F707BF-2C0D-4690-84E8-8C1806BFC740}"> - <File Id="fil7E02C9035678F667086D2D483D8FDF35" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.be.xml" DiskId="1" /> + <File Id="fil7E02C9035678F667086D2D483D8FDF35" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.be.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1DD254125CF07901EACECC70930818B0" Guid="{AD31462E-039E-41CF-B2CF-D73FD4075C76}"> - <File Id="filA52BE38FF2164268AA9562C09281D09B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.bg.xml" DiskId="1" /> + <File Id="filA52BE38FF2164268AA9562C09281D09B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.bg.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp8C9E97CFD69D3BCB44B84D886720F3FC" Guid="{A328C74D-C352-4406-8C75-8BA159210936}"> - <File Id="fil2A31F450F9C022901212461A240C5D17" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ca.xml" DiskId="1" /> + <File Id="fil2A31F450F9C022901212461A240C5D17" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ca.xml" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp8EEB5407564497843BCFB99ECD7450CD" Guid="{2C24BFAF-798B-4480-BCC1-23C766447E26}"> + <File Id="fil05C1472701031E1165B20A1F476071FF" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.co.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2BC45D6EC406DDC470E8501442A7AF68" Guid="{5E99CB8F-33E2-430C-A0B2-A31058D6D449}"> - <File Id="fil0F3AB0CD6266BA1530A0253F059A85DD" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.cs.xml" DiskId="1" /> + <File Id="fil0F3AB0CD6266BA1530A0253F059A85DD" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.cs.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp74A0CA1914A6C6FE33D76DE1C01C676D" Guid="{F1E82507-7C31-41F0-A643-69BB53F3CD41}"> - <File Id="filDED1A10C5657065D291DC62CA9A32FAE" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.da.xml" DiskId="1" /> + <File Id="filDED1A10C5657065D291DC62CA9A32FAE" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.da.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpC186D3472CE1EC872FF1B0CF3682B3B6" Guid="{C23FC0D1-A6B7-4AB1-BA05-EBDC1B4328F9}"> - <File Id="filF4D7849840B295D75BA68B5F6C12F7B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.de.xml" DiskId="1" /> + <File Id="filF4D7849840B295D75BA68B5F6C12F7B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.de.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2AB0B613D25DDEF3466CBC86BD6B878B" Guid="{3757C2DE-FCC8-4970-8CB8-A0D9B2404A1C}"> - <File Id="fil7AECCD25826C51216C12F09DC87F1B22" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.el.xml" DiskId="1" /> + <File Id="fil7AECCD25826C51216C12F09DC87F1B22" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.el.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB09224EB45E097BF511CBC5DBE3E251C" Guid="{70B91FFF-BDB7-48AE-A664-243A057F1EA7}"> - <File Id="filC426C0D58EE0FC49743BDB8AEDA3C6BE" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.es.xml" DiskId="1" /> + <File Id="filC426C0D58EE0FC49743BDB8AEDA3C6BE" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.es.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF24BBBEB613F893CBC5FBF6533CB48C9" Guid="{F578356A-16E1-42CF-8DB2-2DC21B4C154B}"> - <File Id="fil38AB8BFA030ACBECA75C821E3574759A" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.et.xml" DiskId="1" /> + <File Id="fil38AB8BFA030ACBECA75C821E3574759A" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.et.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp50E1DEF37599D2900447B13FC285B7B7" Guid="{1FDF2F45-97F1-40C0-A450-A2342BBF913C}"> - <File Id="fil1BCCDEC84EB4D85DB0380FCD6153D1FA" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.eu.xml" DiskId="1" /> + <File Id="fil1BCCDEC84EB4D85DB0380FCD6153D1FA" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.eu.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp46E5A0DB48A03A91267C97A664BD9BD4" Guid="{07165ABB-1B3C-4C0F-A73E-E3A85AB37B58}"> - <File Id="fil1AC953E5BA23EC81206D212369F1544D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fa.xml" DiskId="1" /> + <File Id="fil1AC953E5BA23EC81206D212369F1544D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fa.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp95BAB91FA0B7E37D5B9343478899CC75" Guid="{F0ADBE30-225D-4EF9-B0F4-1ADEFEF07625}"> - <File Id="filEEF3EF4EEE97747B255238CFB88EAF9C" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fi.xml" DiskId="1" /> + <File Id="filEEF3EF4EEE97747B255238CFB88EAF9C" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fi.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE73E4CCF9F6EC39998B9BE35E43768CC" Guid="{EA4FADF0-BF20-40FD-9BAA-D1023357FD28}"> - <File Id="filFB10C722F275051A8DDB25D4D9AF43E5" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fr.xml" DiskId="1" /> + <File Id="filFB10C722F275051A8DDB25D4D9AF43E5" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.fr.xml" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp8E5262918FDC1B2986951E925B0B9AA5" Guid="{C467DF8F-E07D-4C2B-B5D5-1E4B898C4942}"> + <File Id="fil12FBBE0FB30498855B0E7185B5E18A10" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.he.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp28EEAA4B2230460BDDA61DEFBC71A905" Guid="{68D7B2E5-273B-4782-AF3D-65F255BBF9B2}"> - <File Id="filD03BE3868262DD16654690ED91BC89C8" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.hu.xml" DiskId="1" /> + <File Id="filD03BE3868262DD16654690ED91BC89C8" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.hu.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpCFF4CB46421F1A713D45607393ED9B90" Guid="{F96AF79F-0364-4A68-8790-209C751C37FB}"> - <File Id="fil040570D344D75F6A57E5DD5ECB94BD8B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.id.xml" DiskId="1" /> + <File Id="fil040570D344D75F6A57E5DD5ECB94BD8B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.id.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp31601B4199D0CD3977758A3F2B63CDE7" Guid="{9F347364-2673-4184-A069-342A88BAF90C}"> - <File Id="fil5A7288C1B9CC498419FC14D5B12B1D8D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.it.xml" DiskId="1" /> + <File Id="fil5A7288C1B9CC498419FC14D5B12B1D8D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.it.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp8E2E0489348A190B00532591CE0AC325" Guid="{BE526CC3-99F7-4F94-AFC4-C86FCF0D742C}"> - <File Id="fil9DF155D4A63D3AAAFDBF3BEF8C47BBEA" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ja.xml" DiskId="1" /> + <File Id="fil9DF155D4A63D3AAAFDBF3BEF8C47BBEA" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ja.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpEE57E2901F12294E638E66C39F1B39BB" Guid="{C2CAFD97-84B7-4053-A8D0-DE21F4D8F741}"> - <File Id="filFD48E7A9628E7FF9B3D96BD222A3A0D9" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ka.xml" DiskId="1" /> + <File Id="filFD48E7A9628E7FF9B3D96BD222A3A0D9" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ka.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2F1F644C870AFF8970FE18AF2CD151C4" Guid="{96564F4E-7D92-40B3-84F6-84B357EB4F41}"> - <File Id="filF68A13BECFA9D8DD21B371298AF93B5B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ko.xml" DiskId="1" /> + <File Id="filF68A13BECFA9D8DD21B371298AF93B5B" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ko.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4B8E0B5A7B7A8BE4267C722B1434E4CF" Guid="{E9AD4FA0-9CD7-43B9-8099-69AD6EB1A305}"> - <File Id="fil23F177B7621D7D78240CAA60E6AB1048" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.lv.xml" DiskId="1" /> + <File Id="fil23F177B7621D7D78240CAA60E6AB1048" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.lv.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp84BB49D30BDBB4212707D14B7A9C13F1" Guid="{B63CC062-CD52-463F-8B30-1E611A90EDA9}"> - <File Id="filA7135961859CF705E28FFF4DA79A28C2" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.my.xml" DiskId="1" /> + <File Id="filA7135961859CF705E28FFF4DA79A28C2" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.my.xml" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6097F5CB407EFCDADFEA02548151AD81" Guid="{1A88CAD2-9C59-4E0E-9915-6006E5907346}"> + <File Id="filC743CCDC4A101E271BA40FDF6F08CC12" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.nb.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp406E3BE632055CDDE1E42F45E31318DC" Guid="{627980E8-F6BE-4794-B9BC-68F96267D721}"> - <File Id="filF46FDB7781620EB1D7491039E4029463" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.nl.xml" DiskId="1" /> + <File Id="filF46FDB7781620EB1D7491039E4029463" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.nl.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4E363AF94947A27A4E9CF57C69E6DE54" Guid="{9D17F34C-4475-4995-A696-FE3EA54F2FBB}"> - <File Id="fil24BA52B3E3209F48021C1D75AF5BBDB4" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.nn.xml" DiskId="1" /> + <File Id="fil24BA52B3E3209F48021C1D75AF5BBDB4" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.nn.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp562F7970AF2F9EF535AC21A84C7229D1" Guid="{9F36CA4F-BF14-40D7-81A2-8ADFCC0EF30B}"> - <File Id="fil8C40C1C5E3776F4C0FCF8BD02D742D70" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.pl.xml" DiskId="1" /> + <File Id="fil8C40C1C5E3776F4C0FCF8BD02D742D70" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.pl.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp19EF976916B5E207A32BA08C3143A281" Guid="{B0EAEA97-9176-4613-9338-41B63B85CB18}"> - <File Id="fil6CC66A3690F008524FCCB68FA1EE1176" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.pt-br.xml" DiskId="1" /> + <File Id="fil6CC66A3690F008524FCCB68FA1EE1176" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.pt-br.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4C9B5090256B2E88D27C9CF7E6CFD9EF" Guid="{8D783A02-023C-4018-8315-79A82BA593E2}"> - <File Id="filA3239DE9C316B9C04171EB42F4F9653D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ro.xml" DiskId="1" /> + <File Id="filA3239DE9C316B9C04171EB42F4F9653D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ro.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp91165C08D5943C21F132A349F8CBAAE7" Guid="{0C3290FF-8000-42CF-8329-92C828AE5A53}"> - <File Id="fil77375796E780F641C2FF5E6E3D4CAFDB" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ru.xml" DiskId="1" /> + <File Id="fil77375796E780F641C2FF5E6E3D4CAFDB" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.ru.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4A51B27F9D8DBBABFE4581EC2B162832" Guid="{FB8CCAC7-0EAC-4C1A-B5E5-BEFD8F7B47E6}"> - <File Id="fil414686FD325EB0C5D03FC4693978451D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sk.xml" DiskId="1" /> + <File Id="fil414686FD325EB0C5D03FC4693978451D" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sk.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp041827E393D8777802256FD480D377FC" Guid="{7FEB72AD-48CA-4330-A4C9-A22218EC5D8F}"> - <File Id="fil4EABC40F288E8289D4888EB0BE6F07B1" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sl.xml" DiskId="1" /> + <File Id="fil4EABC40F288E8289D4888EB0BE6F07B1" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sl.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp68CC2DB5FA70FC1F6CA959FB5E1B78BF" Guid="{00D9FB47-120C-4061-B2DB-8F3D5D94F221}"> - <File Id="fil90E6ABC4A98B19C0ECCDCC9712928162" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sv.xml" DiskId="1" /> + <File Id="fil90E6ABC4A98B19C0ECCDCC9712928162" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.sv.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFF128AFA659D8C2E65E0BE55E0943F83" Guid="{5AB50FC2-867A-4239-850F-AD2C0FCDA2DE}"> - <File Id="fil5BF14221A225DAB25A02463BBC92DC37" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.th.xml" DiskId="1" /> + <File Id="fil5BF14221A225DAB25A02463BBC92DC37" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.th.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1896040764F0DF6F89280C428013ECE7" Guid="{3A2D27E8-4AB3-471A-A574-F148DCDF8D8C}"> - <File Id="filE839661CD956C44F0E95C85AAA11D6FF" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.tr.xml" DiskId="1" /> + <File Id="filE839661CD956C44F0E95C85AAA11D6FF" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.tr.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA52EAD237A44CBD337E302185BE12FB2" Guid="{4D7A4A01-5AFB-4B37-93C7-91B9DA96BA30}"> - <File Id="fil9E3A6DE502ECEF2025129A97D3F98CA2" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.uk.xml" DiskId="1" /> + <File Id="fil9E3A6DE502ECEF2025129A97D3F98CA2" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.uk.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpBBB82A6228B54372ACAF9B1310CB2025" Guid="{939C9CDD-0CEA-4161-9812-96B77B643C2E}"> - <File Id="fil4B209843380976D1FBEB96B21EB849B5" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.uz.xml" DiskId="1" /> + <File Id="fil4B209843380976D1FBEB96B21EB849B5" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.uz.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4A275EC29DB9B5ECD56CD9C62D358750" Guid="{0E29F3C1-2D27-4F1F-BEC0-C39CA1B4EAAF}"> - <File Id="fil1FD00998B7A757165A03FDFD6D241F14" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.vi.xml" DiskId="1" /> + <File Id="fil1FD00998B7A757165A03FDFD6D241F14" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.vi.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp8DF0B84F470901D8800F8CAB88A90656" Guid="{7B9A6F50-C242-4DAE-BD10-CDF2D63FB4AC}"> - <File Id="fil4EC683D0A468CAA1D4B8FC6FFCBFEAD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-cn.xml" DiskId="1" /> + <File Id="fil4EC683D0A468CAA1D4B8FC6FFCBFEAD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-cn.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp529250BEE557732B5B8CBC47914A0F2A" Guid="{2D4E3902-96E9-4C8B-BF8C-623D10FF7B57}"> - <File Id="fil915C308602F025646FC5A874F74AA475" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-hk.xml" DiskId="1" /> + <File Id="fil915C308602F025646FC5A874F74AA475" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-hk.xml" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp38274F8F5E4F600A9AC5225A0472D656" Guid="{74B65782-BFB6-42CD-B3BA-D736C7B0B3BE}"> - <File Id="filFD4B1ECAE9F0FF855503D800C1A2891A" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-tw.xml" DiskId="1" /> + <File Id="filFD4B1ECAE9F0FF855503D800C1A2891A" KeyPath="yes" Source="$(sys.CURRENTDIR)\Languages\Language.zh-tw.xml" Checksum="yes" DiskId="1" /> </Component> </DirectoryRef> <!-- Refer to C:\Program Files\VeraCrypt\docs in order to install files in it --> <DirectoryRef Id="DOCSFOLDER"> <Component Id="VCUserGuideChm" Guid="{8CBE67F1-D493-4B33-9141-DB221021C59B}"> - <File Id="VeraCrypt_User_Guide.chm" Name="VeraCrypt User Guide.chm" Source="$(sys.CURRENTDIR)\docs\VeraCrypt User Guide.chm" KeyPath="yes" DiskId="1" /> + <File Id="VeraCrypt_User_Guide.chm" Name="VeraCrypt User Guide.chm" Source="$(sys.CURRENTDIR)\docs\VeraCrypt User Guide.chm" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> </DirectoryRef> <!-- Refer to C:\Program Files\VeraCrypt\docs\EFI-DCS in order to install files in it --> <DirectoryRef Id="EFIDOCSFOLDER"> <Component Id="dcs_tpm_owner_02_pdf" Guid="{DC75D11E-8250-4DDD-9BD2-451194F8717D}"> - <File Id="dcs_tpm_owner_02.pdf" Name="dcs_tpm_owner_02.pdf" Source="$(sys.CURRENTDIR)\docs\EFI-DCS\dcs_tpm_owner_02.pdf" KeyPath="yes" DiskId="1" /> + <File Id="dcs_tpm_owner_02.pdf" Name="dcs_tpm_owner_02.pdf" Source="$(sys.CURRENTDIR)\docs\EFI-DCS\dcs_tpm_owner_02.pdf" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> <Component Id="disk_encryption_v1_2_pdf" Guid="{DFD46CE4-B65B-468A-B236-3E5C43090235}"> - <File Id="disk_encryption_v1_2.pdf" Name="disk_encryption_v1_2.pdf" Source="$(sys.CURRENTDIR)\docs\EFI-DCS\disk_encryption_v1_2.pdf" KeyPath="yes" DiskId="1" /> + <File Id="disk_encryption_v1_2.pdf" Name="disk_encryption_v1_2.pdf" Source="$(sys.CURRENTDIR)\docs\EFI-DCS\disk_encryption_v1_2.pdf" KeyPath="yes" Checksum="yes" DiskId="1" /> </Component> </DirectoryRef> <!-- Refer to C:\Program Files\VeraCrypt\docs\html\en in order to install files in it --> <!-- Components generated using 'heat dir ".\html" -gg -sfrag -template:fragment -out directory.wxs -var "sys.CURRENTDIR"' --> <DirectoryRef Id="ENHTMLDOCSFOLDER"> <Component Id="cmp5A2505C1E4CE33EAC578A8D1C8C505D2" Guid="{EB5FB334-0E04-4DC8-BCA7-9233982B0FF8}"> - <File Id="fil2FC60DD03A8AFECD3E1FB3B2F358CDF5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Acknowledgements.html" DiskId="1" /> + <File Id="fil2FC60DD03A8AFECD3E1FB3B2F358CDF5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Acknowledgements.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE985CD1A96188861286D758A12A1D0A1" Guid="{25ED8C45-E6AF-4582-ADDE-5EDF51BF4EC2}"> - <File Id="fil81B62ADB5DD42B4C9666C61A4F59E00C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Additional Security Requirements and Precautions.html" DiskId="1" /> + <File Id="fil81B62ADB5DD42B4C9666C61A4F59E00C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Additional Security Requirements and Precautions.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp310514F655B6D66F5308A5823B0AB691" Guid="{B18F4EA7-2A2E-4DB2-BA72-E1AE3C090C4D}"> - <File Id="fil8194761219752C0F565AAD6F30B00920" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\AES.html" DiskId="1" /> + <File Id="fil8194761219752C0F565AAD6F30B00920" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\AES.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0664DF8B1FE440C02B1E20D2F23C2CDF" Guid="{2A048A0F-A19B-4EE2-A1FA-2761C8931A29}"> - <File Id="fil6B563B1A4AA551468283EEB5872DD176" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\arrow_right.gif" DiskId="1" /> + <File Id="fil6B563B1A4AA551468283EEB5872DD176" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\arrow_right.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2934E77CB835216789F88BD686160A94" Guid="{084CDB58-6A9F-4985-9818-727FBFF0D95B}"> - <File Id="fil960742ACFA2D79EEC2E6D45D7A93047B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Authenticity and Integrity.html" DiskId="1" /> + <File Id="fil960742ACFA2D79EEC2E6D45D7A93047B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Authenticity and Integrity.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp688E76C9A297923D616068E33A6A4F49" Guid="{63DABE8B-7EE0-479E-890F-701C7E890647}"> - <File Id="filCC9CD11F958A26366B700B8EE8812A65" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Authors.html" DiskId="1" /> + <File Id="filCC9CD11F958A26366B700B8EE8812A65" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Authors.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC40B9AEA2BA26327EDBF8EE050CB076B" Guid="{F3D7A2DA-32AC-4418-997E-B7E2AEF8A099}"> + <File Id="fil2DE49A9DD9C4A7B8D0D3A654CF73A48F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Avoid Third-Party File Extensions.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2ABB10C0A5AC0F1084EDF94E0FDFFD09" Guid="{034D6A64-B712-49C1-9450-5585B207C8AD}"> - <File Id="fil63E5CE3D0A91ACFF543B523A58476CCF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\bank_30x30.png" DiskId="1" /> + <File Id="fil63E5CE3D0A91ACFF543B523A58476CCF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\bank_30x30.png" Checksum="yes" DiskId="1" /> </Component> - <Component Id="cmp32E7F4F5C0F44D00B53E3946E7E1FCF9" Guid="{4A9AD9E2-8ADA-41BF-B2EC-643579DF9B35}"> - <File Id="filD1052E711F1CD089D66C27B04EDD6113" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BCH_Logo_48x30.png" DiskId="1" /> + <Component Id="cmp793A7E676882B650FFCEE4F41B92CB85" Guid="{73A7AE9C-003C-4DF6-AD85-3FE264669165}"> + <File Id="filD1052E711F1CD089D66C27B04EDD6113" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BCH_Logo_30x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp989B890D94671F634D04D8F945090F21" Guid="{4C123649-753C-404B-908D-AF1B48CBB844}"> - <File Id="fil02D4C60C8A30C22AE1F14E33DA3DA38C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BC_Logo_30x30.png" DiskId="1" /> + <File Id="fil02D4C60C8A30C22AE1F14E33DA3DA38C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BC_Logo_30x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp109BF0667C5A7B7036CCAAD9B29D9449" Guid="{5951DADE-1544-4213-A018-E33CC10AFA5C}"> - <File Id="fil07FA1CE512F8C8605304C23C4DFE264D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial.html" DiskId="1" /> + <File Id="fil07FA1CE512F8C8605304C23C4DFE264D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp82ABD3094B751094F3A49CD338A3713D" Guid="{1D02B8D8-92E6-4E2E-B29B-1C3633C625BB}"> - <File Id="fil4431451829FDF5841BC97BA0A0CA8133" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_001.jpg" DiskId="1" /> + <File Id="fil4431451829FDF5841BC97BA0A0CA8133" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_001.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE6A18205CB9F847CD7C4375AED2196D5" Guid="{D84BA05D-74CB-47CE-8098-C3C27E9292BA}"> - <File Id="fil89FAEFEC223673825DC022EED971C0E0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_002.jpg" DiskId="1" /> + <File Id="fil89FAEFEC223673825DC022EED971C0E0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_002.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAA4D61C5E17E2A8513EC120AC9B1DB8A" Guid="{62C84C2A-D459-4BE2-84B4-7D43F3C5726E}"> - <File Id="filE334137ACF34B80CE263C7A3868862FE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_003.jpg" DiskId="1" /> + <File Id="filE334137ACF34B80CE263C7A3868862FE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_003.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp39251BC13DA4AD6508E18D90D86DF06D" Guid="{E4095A6D-EAD5-429C-A75F-39758A7F1C87}"> - <File Id="fil924A6AEB99A9EF73D5240117A35F4A73" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_004.jpg" DiskId="1" /> + <File Id="fil924A6AEB99A9EF73D5240117A35F4A73" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_004.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpBABB0BD95FD763E9C72D2F51C325CF15" Guid="{0905EB74-CB03-4479-8D47-D5F1071E6D1C}"> - <File Id="fil2C527AD0D6FF9D8991263AEAEF0028C1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_005.jpg" DiskId="1" /> + <File Id="fil2C527AD0D6FF9D8991263AEAEF0028C1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_005.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2FE3B3719DCC4362AFF8BF7B4CADFF80" Guid="{8F29956A-6555-45C9-B254-F277FD9D0230}"> - <File Id="fil1CCA48715513D4C909E9B413C8D1DDD0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_007.jpg" DiskId="1" /> + <File Id="fil1CCA48715513D4C909E9B413C8D1DDD0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_007.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2FC8BD312D06FEC4E244604E27117B62" Guid="{22F89049-FED2-46D8-A298-E43ECE3226B9}"> - <File Id="fil4F7DCD31A2B30BC40BCC4E76DDCE58C1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_008.jpg" DiskId="1" /> + <File Id="fil4F7DCD31A2B30BC40BCC4E76DDCE58C1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_008.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAE99FB30CC29DF92E71A31EC39E61EF5" Guid="{C125C0FE-AEC0-455B-A7A6-BD216E712F11}"> - <File Id="fil3E632F1EA36028C0146D810EB2A994BB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_009.jpg" DiskId="1" /> + <File Id="fil3E632F1EA36028C0146D810EB2A994BB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_009.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp535B1A9BACA231F518973D620DC23779" Guid="{35958B4E-683D-4F34-B510-04E5801B4A1C}"> - <File Id="fil820662B184499949D0F2AF8C702010BF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_010.jpg" DiskId="1" /> + <File Id="fil820662B184499949D0F2AF8C702010BF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_010.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD2ED5F6D8C0A4CA0D26F9F1BB34AB8BA" Guid="{E3CDE6DA-DCC0-418C-926F-406962D00BB7}"> - <File Id="fil0377513CEC808B0549D7B1D3AC22DED8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_011.jpg" DiskId="1" /> + <File Id="fil0377513CEC808B0549D7B1D3AC22DED8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_011.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp5F7E0D8587039E1BA0F236F228C163BD" Guid="{B3E56E0C-7368-42D8-9EEC-56FC2568A649}"> - <File Id="fil07880CC54CBA150765E18E78D707B361" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_012.jpg" DiskId="1" /> + <File Id="fil07880CC54CBA150765E18E78D707B361" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_012.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF4DA2D3DABC768C2040A67A993C53E9E" Guid="{817105D4-7E68-417B-9592-F664A20AD861}"> - <File Id="filA63E7BA341C510BB5F5BE441475173A0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_013.jpg" DiskId="1" /> + <File Id="filA63E7BA341C510BB5F5BE441475173A0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_013.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpC0AD9100DE0F43E8149F8D3271B02D17" Guid="{81CFCB27-3F21-493C-AA7A-836E05157AC3}"> - <File Id="fil1872F82E98E3D4AAE017F70E311912DE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_014.jpg" DiskId="1" /> + <File Id="fil1872F82E98E3D4AAE017F70E311912DE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_014.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp32646E8087D106AE2B62E5DCF2419EDD" Guid="{54C078C1-1641-4A06-BBCA-D6A2C0389695}"> - <File Id="fil0C921426CF20987C0ED9364F11F534F0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_015.jpg" DiskId="1" /> + <File Id="fil0C921426CF20987C0ED9364F11F534F0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_015.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB3C777FAF214F7D304EE7CF907D7FF57" Guid="{C44D9DD8-7803-41C1-9323-4CFD516C2DEB}"> - <File Id="filE9FA9200D40A4970139496FD4D09CC9C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_016.jpg" DiskId="1" /> + <File Id="filE9FA9200D40A4970139496FD4D09CC9C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_016.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp338115DF524F0B412A21AB64F59240DD" Guid="{D4B1FD10-580F-4889-95F4-EDFFFC3C1309}"> - <File Id="fil74DD6EA64196A3168E669A1FF7AE3E0A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_017.jpg" DiskId="1" /> + <File Id="fil74DD6EA64196A3168E669A1FF7AE3E0A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_017.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2F24E0C7B7175D60257F6D01231C8373" Guid="{BF43A78C-C0A8-498E-A3EF-7D0265F1E312}"> - <File Id="fil37771854D19D4FEC1E9E8DB377B24B8D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_018.jpg" DiskId="1" /> + <File Id="fil37771854D19D4FEC1E9E8DB377B24B8D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_018.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAE9D52ADD94D3A2711AA79FA0C91CA00" Guid="{3EF7862C-7D09-4662-BF1C-67D05EBF9711}"> - <File Id="filEC84ED23804D7FD220C90FF50B92FD7C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_019.jpg" DiskId="1" /> + <File Id="filEC84ED23804D7FD220C90FF50B92FD7C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_019.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0A6270FD26128E8D1CC83E392E91A772" Guid="{5252F18E-BFB7-4FCC-865E-809BBD431C22}"> - <File Id="filBB21339DA6F921A2596897061F9C1F7E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_020.jpg" DiskId="1" /> + <File Id="filBB21339DA6F921A2596897061F9C1F7E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_020.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpEDB0E152195A7EB91BBB28631B689E0B" Guid="{C3750B19-85AF-4B35-98C9-969168C0C19F}"> - <File Id="fil23F7783C38C515A1DAA07F85B306D695" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_021.jpg" DiskId="1" /> + <File Id="fil23F7783C38C515A1DAA07F85B306D695" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_021.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFD76EB6B5546D1C38CC33FABA95FAA15" Guid="{AA874CBC-A2B7-48C6-AC23-654C190C65B0}"> - <File Id="fil769661E570AC147356DE7C8AD17F9F76" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_022.jpg" DiskId="1" /> + <File Id="fil769661E570AC147356DE7C8AD17F9F76" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_022.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpDC4FD19F507A5152351B9F71C8691486" Guid="{5B95B2F6-EF6F-4D08-9014-F4C621EA49D3}"> - <File Id="fil6AD3B2642AC17EBF625FEBC38F376F96" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_023.gif" DiskId="1" /> + <File Id="fil6AD3B2642AC17EBF625FEBC38F376F96" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_023.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9E45BE754042F9DD742A0B7B9F27E786" Guid="{7DD3EFD4-E5DC-4D5A-BCE0-5E2F6FA86E9C}"> - <File Id="fil29A133B2F2F200139A6F8BA5753FD673" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_024.gif" DiskId="1" /> + <File Id="fil29A133B2F2F200139A6F8BA5753FD673" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_024.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB6AC414023A6BDBF855F4A807DAE138C" Guid="{557B4D3A-C503-4EAF-8DFC-5B9177A1F737}"> - <File Id="filE1FF7E56D4D7BAE636B289521CD0C787" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_034.png" DiskId="1" /> + <File Id="filE1FF7E56D4D7BAE636B289521CD0C787" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Beginner's Tutorial_Image_034.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA80F47C0DB1649FE99DA7D449012D2D7" Guid="{E4AB233F-F5AE-4B26-83E5-524108F801B6}"> - <File Id="filC92F8B3C25C841839FF268DAF13ADBCC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BLAKE2s-256.html" DiskId="1" /> + <File Id="filC92F8B3C25C841839FF268DAF13ADBCC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\BLAKE2s-256.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp053692809BD5B3F5682AFCC539A767A3" Guid="{C99F1ECB-6AAB-4D06-B4C7-134CD2502104}"> - <File Id="fil9D6A859E5E76057E4E64E35D03BF1739" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Camellia.html" DiskId="1" /> + <File Id="fil9D6A859E5E76057E4E64E35D03BF1739" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Camellia.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9049A791E9E1AB7FF01BD7F08D1CB069" Guid="{F9B7E6CD-6AAB-4FD2-9CCC-8D13191057FA}"> - <File Id="fil768C59AC95806B46E5921E83E17DF406" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Cascades.html" DiskId="1" /> + <File Id="fil768C59AC95806B46E5921E83E17DF406" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Cascades.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4E6F9484484A40645D519F688ED9C21E" Guid="{5231376B-B4D8-4733-8EA9-ECA11DD034BF}"> - <File Id="fil45397F2F396BA3408992A437902E6951" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Changing Passwords and Keyfiles.html" DiskId="1" /> + <File Id="fil45397F2F396BA3408992A437902E6951" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Changing Passwords and Keyfiles.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3CF724F2A2347A2A30C85CB76490F687" Guid="{BB072BB5-3F7F-4F18-B00F-0A75D3AC0F49}"> - <File Id="filF949C326CAEAC18B9572844C807C9D19" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Choosing Passwords and Keyfiles.html" DiskId="1" /> + <File Id="filF949C326CAEAC18B9572844C807C9D19" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Choosing Passwords and Keyfiles.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3858A4BB7577362DE87F4485575DFC99" Guid="{94549BE1-9A7B-4DA7-A66F-17193865335E}"> - <File Id="fil72F9481463D425378DDDD5FCDBCC909B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Command Line Usage.html" DiskId="1" /> + <File Id="fil72F9481463D425378DDDD5FCDBCC909B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Command Line Usage.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA06B9542AEB64F96BB784F47800158A8" Guid="{87929DDC-82A3-42CF-B610-D625A9EC404A}"> - <File Id="filD596E938BA564F06A23DAAAA0909B229" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineLinux.html" DiskId="1" /> + <File Id="filD596E938BA564F06A23DAAAA0909B229" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineLinux.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpACD4069DDF564A8DAB5D542BB8850131" Guid="{657E9938-9161-4C60-9112-944DD2BF2DE8}"> - <File Id="fil0794C6C86BD24D62883FD840ADE90FC7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelines.html" DiskId="1" /> - </Component> - <Component Id="cmp735FE6B2F10C43019E11256864209EBC" Guid="{F87625DF-E610-4CCF-94E7-7293DDCD35DB}"> - <File Id="filAB026A12CD59448B0346D8FB6BD594EB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\AddNewSystemVar.jpg" DiskId="1" /> - </Component> - <Component Id="cmp89BB363FF83EBA271361A4208E069DA9" Guid="{1E6E3A37-453A-4E81-AC23-45F3BB4800E2}"> - <File Id="filE7535CB597FF0868DC51F9D3E8A1E45C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\CertificateCannotBeVerified.jpg" DiskId="1" /> - </Component> - <Component Id="cmp5115B3C02C1C0CF975E4B7C3152C163A" Guid="{D705F09B-8F81-48FE-A6D6-B46EE47425CE}"> - <File Id="fil8DCBEED9F9CD2F449C888E90DBEC8A0F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\CertVerifyFails.jpg" DiskId="1" /> - </Component> - <Component Id="cmp3E70583F999D652B21E6E2D526666F61" Guid="{EA0DBD20-DFB7-4DF2-B29C-538C7FAE83C3}"> - <File Id="fil8BA636EB3F15CDFBF9B1B07AF40CAF5C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DistributionPackageDamaged.jpg" DiskId="1" /> - </Component> - <Component Id="cmpC2D0D30677874908C48FF8A921712958" Guid="{0CB7D629-B12B-4CCB-B65D-F92BC4099ED1}"> - <File Id="filABD544E660E7612EF24A540F4DAC89DE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVS2010.jpg" DiskId="1" /> - </Component> - <Component Id="cmp88EB50D9762FA92B2E52313A7C92F2DD" Guid="{BF41CBAB-594C-42FF-BC86-88869CD77445}"> - <File Id="filD123B515FACC275A341B8C7A4DD19074" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVS2019.jpg" DiskId="1" /> - </Component> - <Component Id="cmp3DABA5B6F2E779D915E1B8D680AE7855" Guid="{203AC826-E013-40E8-A944-9D9622669066}"> - <File Id="fil6BA9B558534B9399EA06F31375A6D8C5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVSBuildTools.jpg" DiskId="1" /> - </Component> - <Component Id="cmp2EA15F417E5EE9D31E028263C137695F" Guid="{F4EDBAFC-4B84-4502-9AA4-4272281B26B9}"> - <File Id="fil2DD203CD9997BD21FC45EFDF85BECE94" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\gzipCommandLine.jpg" DiskId="1" /> - </Component> - <Component Id="cmp51D438A1152A65EAD414012A5EAEA2CA" Guid="{8B4B3B03-9D19-4D15-9060-1ABB4CF4A80E}"> - <File Id="fil612E91212B4BE3447B34C59AD43D5FC2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\NasmCommandLine.jpg" DiskId="1" /> - </Component> - <Component Id="cmpD52CCEF7A4A330F26D3B3F7355D03646" Guid="{4C764331-E584-49C0-80FA-9251776108E3}"> - <File Id="fil63F42635C3D23E1CC8D9541703F69B96" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-1.jpg" DiskId="1" /> - </Component> - <Component Id="cmp1A9BFDDFF15FF47166075F319B97BB6E" Guid="{F0EF5133-371D-4767-9265-266277E4D939}"> - <File Id="fil609F8FC8F03A7AC92A7DDB6123F2771B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-2.jpg" DiskId="1" /> - </Component> - <Component Id="cmp320762048B274197D27F739096C4A23A" Guid="{118CF290-CD2D-4515-A55D-48AD4DBEF8F0}"> - <File Id="fil08D2CB8983DA4BA20DFFA5471E60CAD3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-3.jpg" DiskId="1" /> - </Component> - <Component Id="cmp952051BDCF309CAEB1D62701560D8F78" Guid="{6BA07F89-BAA5-4E06-BE93-65AF8DF895EC}"> - <File Id="fil335EB17B9D8DE11A9A8E0204C43BB2C7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-4.jpg" DiskId="1" /> - </Component> - <Component Id="cmp6AB232B7503BC35E25CB33C789242482" Guid="{0B2B14B7-2D21-4904-999D-8DA37C7289BE}"> - <File Id="fil9069630D9AA559C8EA243ADEB3DF0B69" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectAdvancedSystemSettings.jpg" DiskId="1" /> - </Component> - <Component Id="cmpE8ABDCD58C9636346FAE7E941A38CA6E" Guid="{2CF0B479-EFAF-499E-8630-AE4E41C8E424}"> - <File Id="filA8C1D27C90C6647C16EB5EE8728DC943" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectEnvironmentVariables.jpg" DiskId="1" /> - </Component> - <Component Id="cmp9CD73EB218D7148E55F141E31AEC9D8C" Guid="{299F81CE-0140-4A97-93C2-C6B2CD3F8514}"> - <File Id="fil8DB747C30552955A70B6FDAC1BC95198" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectPathVariable.jpg" DiskId="1" /> - </Component> - <Component Id="cmpE504F295E3ED5CEBDCF231608F6757B2" Guid="{0B23E02F-0D76-4F41-9081-CCC6A2634F05}"> - <File Id="fil4E06FA5FE9FA09E4F71E22CFA0FC7BA9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectThisPC.jpg" DiskId="1" /> - </Component> - <Component Id="cmp84A8D3A9BF75ED8047B7DEAB02F26003" Guid="{1EE2E63F-CE1F-4D90-97E9-AE186BC6DDA0}"> - <File Id="fil0470CF25D1C5B0A85FD8091673E3E2E0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\upxCommandLine.jpg" DiskId="1" /> - </Component> - <Component Id="cmp63A4BE623C0E3F77B3BFA5B467C33A1A" Guid="{845FE6B7-11D1-4FEB-AFBE-A9EC8B7775DD}"> - <File Id="filDC81CAAEC5DCB86937437877F26C046A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010BuildSolution.jpg" DiskId="1" /> - </Component> - <Component Id="cmp63CE6B664C7396B79B1B28591EEC72B9" Guid="{E0F7F066-1B4F-48B8-8C02-AB0661E0AFF5}"> - <File Id="filC02619AFFB25501B6AA29599FAA01DEB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010Win32Config.jpg" DiskId="1" /> - </Component> - <Component Id="cmp4D6100E03DC3B05F17A7E2BA4AAF1EA1" Guid="{3AF8735B-D193-4F71-8C51-E8B1FE71CE5B}"> - <File Id="filF697D096B67A6A8C84BB93AEB4199206" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010X64Config.jpg" DiskId="1" /> - </Component> - <Component Id="cmpB7641BE40D4D1642AB3647B669008A94" Guid="{15A8F3D3-4364-4499-BBA9-2E29CD19D5C4}"> - <File Id="filBD820E84E255A9B91DDC38D189515EE6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2019ARM64Config.jpg" DiskId="1" /> - </Component> - <Component Id="cmp4DB96DA8172D79B63A7FBE08E016A280" Guid="{E6F2B68D-8CD9-42DE-AC2A-B5A2AB1F5DC1}"> - <File Id="filEFA99F46C962110CBA6A0B14162F1764" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2019BuildSolution.jpg" DiskId="1" /> - </Component> - <Component Id="cmp615D3647A56F3ED6F0766CEEE9EFCF9F" Guid="{7A343344-91E3-4AEA-BD32-5E524AE8BEA4}"> - <File Id="filD10154F2B3C2E7CB1EF84555EDA195C3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\YasmCommandLine.jpg" DiskId="1" /> + <File Id="fil0794C6C86BD24D62883FD840ADE90FC7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelines.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9FDD7E3C06564AF29700B82B19BC0501" Guid="{5DC9861F-1EB1-457D-9FAA-01DB499F6040}"> - <File Id="filC4ADB6F8DFE44319BB70B7089B72BFBF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin.html" DiskId="1" /> + <File Id="filC4ADB6F8DFE44319BB70B7089B72BFBF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp90AB4CF273108F47223E3432838CDE37" Guid="{9510EAF5-F452-4991-9BA2-F1F641C1D697}"> - <File Id="fil1DAD595818432F019735F37E86305500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Contact.html" DiskId="1" /> + <File Id="fil1DAD595818432F019735F37E86305500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Contact.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB9A0461BF7CF75538111B088C986A62F" Guid="{EC931A38-5F11-4C02-AA88-3A072E802C0B}"> - <File Id="fil8ABFD40EA9A1BE1765D794C2B8EAF909" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Contributed Resources.html" DiskId="1" /> + <File Id="fil8ABFD40EA9A1BE1765D794C2B8EAF909" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Contributed Resources.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp33C4617DBE37ED14B978BC4770F0C3F8" Guid="{387DE078-7507-48EF-A5A3-3A72FAAC8301}"> + <File Id="fil07A195AACB6D39C19DFCDC356E01958A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Conversion_Guide_VeraCrypt_1.26_and_Later.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD8C7B52BC03709FAB2642B93BFE4FFE8" Guid="{1592BAD3-086F-4DDE-8970-199B44FFBD6E}"> - <File Id="filE99ED4C6D87549A1F623A37A5C47552A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Converting TrueCrypt volumes and partitions.html" DiskId="1" /> + <File Id="filE99ED4C6D87549A1F623A37A5C47552A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Converting TrueCrypt volumes and partitions.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFD6EB163EA6B74C4F59FF04D2B3796CC" Guid="{60D5BA7E-7466-4F09-ADB4-571A7502DD7B}"> - <File Id="filBD6D90F11807407F91F2F7AEA5DDC8EA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Converting TrueCrypt volumes and partitions_truecrypt_convertion.jpg" DiskId="1" /> + <File Id="filBD6D90F11807407F91F2F7AEA5DDC8EA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Converting TrueCrypt volumes and partitions_truecrypt_convertion.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp612D2E75E857D164665BE8CA37570D04" Guid="{6D667BD9-F8C1-4C46-BEA0-6AAA44B838CA}"> - <File Id="fil14C75587323CCC7F69E32786D82A5BD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Creating New Volumes.html" DiskId="1" /> + <File Id="fil14C75587323CCC7F69E32786D82A5BD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Creating New Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF65BF759DA7F65BAD6D74A83FEF9D205" Guid="{08FEF348-778B-42C7-81B9-F62EA5F658A6}"> - <File Id="filDAF1BCFE93CF42677E91DCF5E515D861" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Data Leaks.html" DiskId="1" /> + <File Id="filDAF1BCFE93CF42677E91DCF5E515D861" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Data Leaks.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA6A249B42C89657DE664B9D88D04DB3F" Guid="{76F64E31-ED27-46A8-8A0D-6CFB4A79B856}"> - <File Id="fil58A7A13A2773C5CDDBF9D85254395A75" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Default Mount Parameters.html" DiskId="1" /> + <File Id="fil58A7A13A2773C5CDDBF9D85254395A75" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Default Mount Parameters.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpEE8A03DA56EF1B35979430E8711A6960" Guid="{034B338B-7719-4E70-B08E-C118CBCD2432}"> - <File Id="fil7D0C9ABA361EB2D263FA1F2EDB839223" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Default Mount Parameters_VeraCrypt_password_using_default_parameters.png" DiskId="1" /> + <File Id="fil7D0C9ABA361EB2D263FA1F2EDB839223" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Default Mount Parameters_VeraCrypt_password_using_default_parameters.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp628E75C5DD0F38348B6F8694D5D5149C" Guid="{B4CA9CED-3087-4115-AC8C-A8E12C3A4383}"> - <File Id="filAFAAE965983C249FC9A818A28333DFA4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Defragmenting.html" DiskId="1" /> + <File Id="filAFAAE965983C249FC9A818A28333DFA4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Defragmenting.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp40BDD4F3CA20DEE006E087930EF3847C" Guid="{696CB75F-F832-4E11-9617-E4F05B6CA29A}"> - <File Id="fil7887EE82BC26C1CFAAC5CD3A29EF5049" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Digital Signatures.html" DiskId="1" /> + <File Id="fil7887EE82BC26C1CFAAC5CD3A29EF5049" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Digital Signatures.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp7AEEABAF151FCE92735664A55F7B8FFA" Guid="{40361F33-E50C-492C-8D5F-9B32B2318FBF}"> - <File Id="filE430D3D4AD453AD90952510D4194438A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Disclaimers.html" DiskId="1" /> + <File Id="filE430D3D4AD453AD90952510D4194438A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Disclaimers.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9380DDE2560B4D8EE9CC363AF4BC7B5F" Guid="{787E2CF2-DF61-4341-94A2-497BCF9882C8}"> - <File Id="fil04BCDEC7438B23A6BBF1C95ACF126266" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Documentation.html" DiskId="1" /> + <File Id="fil04BCDEC7438B23A6BBF1C95ACF126266" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Documentation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp84A94F04CD486338F57C03B316145945" Guid="{44F12D12-3BB4-4FE5-B829-5D471C05A2AF}"> - <File Id="fil07C7557AAF506EE9095B8C76E9C56776" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation.html" DiskId="1" /> + <File Id="fil07C7557AAF506EE9095B8C76E9C56776" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpDF544847A4B1F86B3BA3468336CD73FE" Guid="{8E46CB17-1956-4E28-B8F4-30DEFCEA1CF6}"> - <File Id="filD27301F6F853ABFC08499D4085599774" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_Bank.html" DiskId="1" /> + <File Id="filD27301F6F853ABFC08499D4085599774" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_Bank.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9A6A861B59A23E534C7407EF95500AA5" Guid="{044EF38F-E86C-4A28-B675-CA7E8E318559}"> - <File Id="fil87AEAF6DE829555C03BF7888DDD40D8F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate.gif" DiskId="1" /> + <File Id="fil87AEAF6DE829555C03BF7888DDD40D8F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp09C34B1CBDE9F2F4E897340B1C67728E" Guid="{CEA5EA37-6E8B-4DC0-A4DC-F95A050D36A1}"> - <File Id="fil2E4790AC38717B6E5E9B77A926CA98C4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_CHF.gif" DiskId="1" /> + <File Id="fil2E4790AC38717B6E5E9B77A926CA98C4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_CHF.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD3183A7373751A19B4B7C9B041F9035D" Guid="{23A3ADFD-3BC8-4F77-9281-EED6A67CAFFD}"> - <File Id="fil12198C69AEB78A4CDE5C4343E8EE27A7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_Dollars.gif" DiskId="1" /> + <File Id="fil12198C69AEB78A4CDE5C4343E8EE27A7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_Dollars.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3DED9073AB120DC026C48E9CDF9283EB" Guid="{8F9DA5BB-3BFE-4D21-8B79-65AFBFC93ECF}"> - <File Id="filDA4E4CC3AAE26E3ADE9CFF4940975500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_Euros.gif" DiskId="1" /> + <File Id="filDA4E4CC3AAE26E3ADE9CFF4940975500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_Euros.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0FF3027C2662D967ACB4B01BA7BC85F9" Guid="{1B9D2475-C2D0-4695-B51D-AE53BFF05A46}"> - <File Id="filF7C4F27359F58FD995B964FF3B5AAAFF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_GBP.gif" DiskId="1" /> + <File Id="filF7C4F27359F58FD995B964FF3B5AAAFF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_GBP.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3FC9C0126A2074CAABCF73197358F824" Guid="{7AD29EC1-38EF-4F2A-8038-E70A6D360CA0}"> - <File Id="fil0D75D569E37C808031A4217294796BC7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_PLN.gif" DiskId="1" /> + <File Id="fil0D75D569E37C808031A4217294796BC7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_PLN.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1830E220882FBA276350032258B478AA" Guid="{A1A3410C-6B91-44FF-AC33-BDB18F4F2022}"> - <File Id="fil7779997A454E1C0068F2DF292319AA6A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_YEN.gif" DiskId="1" /> + <File Id="fil7779997A454E1C0068F2DF292319AA6A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_donate_YEN.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp433CCCF103F2A8AF57F9FC528232C836" Guid="{D427BFF5-7DC7-4414-A920-51E2CAAAB671}"> + <File Id="fil64A82A6BA01444F0F0AF2BFBFCB524D1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VC_BTC_Sigwit.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE5D6E9DF3EE1301C6D5A4F44362BCE96" Guid="{0811DEAF-F857-4839-A31B-C1B3A2C932FE}"> - <File Id="fil83A3E2E3996B9CC933A606F6E4661FD5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_BitcoinCash.png" DiskId="1" /> + <File Id="fil83A3E2E3996B9CC933A606F6E4661FD5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_BitcoinCash.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB7B429D414CF1DD05A4B70CE94E343F7" Guid="{04490FFA-387E-4FD7-9449-AB6C99886EA9}"> - <File Id="fil25C86292E018E61CB762731F14261986" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Bitcoin_small.png" DiskId="1" /> + <File Id="fil25C86292E018E61CB762731F14261986" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Bitcoin_small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp00845B9781D5633702C834BCB4EB93D1" Guid="{A41BFAC5-42BF-45DB-BFF9-703F9DBE7346}"> - <File Id="filAD426632459DB7AB1528AC311CE28870" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Ethereum.png" DiskId="1" /> + <File Id="filAD426632459DB7AB1528AC311CE28870" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Ethereum.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp47F92D029E335F7865F8ACB30763FED2" Guid="{A6C96C85-D0E8-442B-8C84-8705F17EE4C7}"> - <File Id="fil155C2578FFCBDBD39679AB6AF62EEA7B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Litecoin.png" DiskId="1" /> + <File Id="fil155C2578FFCBDBD39679AB6AF62EEA7B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Litecoin.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF3B90B0C1F316854E9142B22783ACF19" Guid="{A369FF58-377C-47B9-A2A6-B222CA95898C}"> - <File Id="filBE9E8FB59340806B67751E8BC2E00071" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Monero.png" DiskId="1" /> + <File Id="filBE9E8FB59340806B67751E8BC2E00071" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Donation_VeraCrypt_Monero.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBD37FB188B29DB82A15EBC9C1DB66F94" Guid="{20A19599-83B8-4DF7-8B42-84F20DFA760F}"> + <File Id="fil8D7D976D180AF0CD0B43FD64BEF15E5B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\EMV Smart Cards.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2EC17F48BC15C5405D2DB40FC6E01745" Guid="{700262B3-5BB2-4482-B96B-A511EA875986}"> - <File Id="filACA26698300072DB7F917CA47A8AB6B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Encryption Algorithms.html" DiskId="1" /> + <File Id="filACA26698300072DB7F917CA47A8AB6B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Encryption Algorithms.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE00F8980768E14DF59474B5CB3D84041" Guid="{45C099F3-92B5-4514-9049-BEA244F0C942}"> - <File Id="fil0B06214692CAA0ACCACC01D1372A93B5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Encryption Scheme.html" DiskId="1" /> + <File Id="fil0B06214692CAA0ACCACC01D1372A93B5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Encryption Scheme.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD17B73F5892E45458E960025558B3452" Guid="{F974B54B-B964-4B65-A718-DF09BE96F106}"> - <File Id="filAEB57F6A5B5C2593D13AEF942A2C721C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Ethereum_Logo_19x30.png" DiskId="1" /> + <File Id="filAEB57F6A5B5C2593D13AEF942A2C721C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Ethereum_Logo_19x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF45A8248FAFA80A8DF62989C477E7C0F" Guid="{9184BA24-53AB-4753-907C-E88D7F56B3FE}"> - <File Id="filA72BC6DCFD81551D166437E20BA8224F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\FAQ.html" DiskId="1" /> + <File Id="filA72BC6DCFD81551D166437E20BA8224F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\FAQ.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD066CBBD66E8CABB4AD4B928F823A5D2" Guid="{A8B260B0-505C-4948-801F-A03236A0D61D}"> - <File Id="filACB34BF3CCD1B081CBA230C962B4023D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Favorite Volumes.html" DiskId="1" /> + <File Id="filACB34BF3CCD1B081CBA230C962B4023D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Favorite Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpACFE3B967BB844C3FD0FE21C9E87EE5B" Guid="{46D1B528-C7B7-4AEC-B5AE-0A3F91D4312E}"> - <File Id="fil88A41060BD4F57CB6135E162D4AB5CD7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-au-small.png" DiskId="1" /> + <File Id="fil88A41060BD4F57CB6135E162D4AB5CD7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-au-small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFAA171DECE81EA4EA99B5570C9FF7D0E" Guid="{6EC15848-F7A8-40B3-88DF-52010E89E634}"> - <File Id="fil16558379B1C9116103DF96CB9C5C36AD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-au.png" DiskId="1" /> + <File Id="fil16558379B1C9116103DF96CB9C5C36AD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-au.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp7C1E782A2C12520E4CACF0D8FD4EAA4E" Guid="{625A778A-7F8A-42D8-A725-85973721DFF0}"> - <File Id="filA16A3EF20ACB7C21ACD09A4D1593A6F1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-eu-small.png" DiskId="1" /> + <File Id="filA16A3EF20ACB7C21ACD09A4D1593A6F1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-eu-small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE9009D51D7CF4AA8BBA735E91F1D6044" Guid="{58D024BC-047D-44AA-9818-9E68C256D84D}"> - <File Id="filCEC0006C74C3A5D4FB0CDA60EEE61C91" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-eu.png" DiskId="1" /> + <File Id="filCEC0006C74C3A5D4FB0CDA60EEE61C91" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-eu.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp5D46BFDD0D54DD715695756148C22028" Guid="{42A27E61-0190-4654-8996-91B092CC314F}"> - <File Id="filE84495221B2E5A505F3AA4CA4595C7A9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-gb-small.png" DiskId="1" /> + <File Id="filE84495221B2E5A505F3AA4CA4595C7A9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-gb-small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE34BBB4D255F23D71B0143270915E6D7" Guid="{5E95AE9C-8807-4E4D-81DA-1A83DACDC8A1}"> - <File Id="filECFBF3D126ECCB088B3B313A370D71ED" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-gb.png" DiskId="1" /> + <File Id="filECFBF3D126ECCB088B3B313A370D71ED" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-gb.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpEB665F1BFDB30B20C90142CCD1DA7664" Guid="{DB6617B7-2FEE-4FDB-A2DA-834B33B29C3E}"> - <File Id="fil968867F284C9559835DFF02CFA106E13" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-nz-small.png" DiskId="1" /> + <File Id="fil968867F284C9559835DFF02CFA106E13" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-nz-small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFDCC994071E7ADACE3EB2CBACC60E34A" Guid="{0494762C-CFB8-4CF7-85AA-0650B2B4E813}"> - <File Id="filF5C5A9923D299431406A6B5D8D2BF34D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-nz.png" DiskId="1" /> + <File Id="filF5C5A9923D299431406A6B5D8D2BF34D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-nz.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp21A3A9B1C7FAA004EF937114F0F41C61" Guid="{2F88A1FE-94B5-46E0-93C2-DE9F9BEE58FF}"> - <File Id="filC1071DD08F53BDD0249A4E15993448D6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-us-small.png" DiskId="1" /> + <File Id="filC1071DD08F53BDD0249A4E15993448D6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-us-small.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFD4A149B4654FEF0542A5ECE211A86B8" Guid="{CC1D951A-2C70-4AE4-AC3C-E2D56789B981}"> - <File Id="fil1120ADD37C4E5039A94D7442675B202D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-us.png" DiskId="1" /> + <File Id="fil1120ADD37C4E5039A94D7442675B202D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flag-us.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE7CDDDCDA7CD20F1150F2879E0293D1D" Guid="{67630C6C-178E-41CF-A74A-AA086E5B4553}"> - <File Id="filA42CDEA93CCFE721C2569FA3D0786D57" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flattr-badge-large.png" DiskId="1" /> + <File Id="filA42CDEA93CCFE721C2569FA3D0786D57" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\flattr-badge-large.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9CDBE7ACC2D5393535D2981C3DD73682" Guid="{97414D97-9C51-419A-9FE2-392223B7600A}"> - <File Id="fil901AA5AF4A010844A1F50A5881B8FD16" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\gf2_mul.gif" DiskId="1" /> + <File Id="fil901AA5AF4A010844A1F50A5881B8FD16" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\gf2_mul.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF09EAA16502FCF137AAD38D70D50B200" Guid="{95BBE9B0-AB65-43FF-A3C4-0D347BE43DF0}"> - <File Id="fil3E73719A927F1E24178C1E3C05DC1384" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hardware Acceleration.html" DiskId="1" /> + <File Id="fil3E73719A927F1E24178C1E3C05DC1384" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hardware Acceleration.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp62D4B7B5DACB58D3EEA9E6D3385769A7" Guid="{285C17A2-418E-4ACD-B0E8-A3940A9E9E61}"> - <File Id="fil05C2A8A0846F0288FDC2580173316E05" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hash Algorithms.html" DiskId="1" /> + <File Id="fil05C2A8A0846F0288FDC2580173316E05" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hash Algorithms.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpBF36D06FA293DFD3AFA1543C43A54E17" Guid="{EC20DE1B-F10D-4F9E-9CEA-8E06170EE71C}"> - <File Id="fil12E28B4819EEC3590C5CFA611E8BAF01" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Header Key Derivation.html" DiskId="1" /> + <File Id="fil12E28B4819EEC3590C5CFA611E8BAF01" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Header Key Derivation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp7345D3EE0CFEA227E8AA9ADADF95E623" Guid="{F5E2342E-2879-48B1-B3CE-5C626AEDC366}"> - <File Id="fil25DB00F86CBD631E7750B8050A9CC9CD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hibernation File.html" DiskId="1" /> + <File Id="fil25DB00F86CBD631E7750B8050A9CC9CD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hibernation File.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE92C5D4B774B7214B49931528F7EDCF6" Guid="{44B9627E-29EC-4B8E-9B20-3D0ECCC77C1E}"> - <File Id="filA094EFE79FB6AAAEDCCC3C997972E35E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hidden Operating System.html" DiskId="1" /> + <File Id="filA094EFE79FB6AAAEDCCC3C997972E35E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hidden Operating System.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB6A3927A1BE4D2836C1007D3CC989C4B" Guid="{13D8AB5D-0F73-4C29-AB08-9086313EF010}"> - <File Id="filC7CDBCEC9B1D4BA6BCFC0362CE353D51" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hidden Volume.html" DiskId="1" /> + <File Id="filC7CDBCEC9B1D4BA6BCFC0362CE353D51" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hidden Volume.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp28666EA10A3DCEC7D2583ADD52785FDC" Guid="{55E58038-C992-4683-AA9F-9CA4111884FF}"> - <File Id="fil707007462E284E1048B6AB488EFFD466" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_facebook_veracrypt.png" DiskId="1" /> + <File Id="fil707007462E284E1048B6AB488EFFD466" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_facebook_veracrypt.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp08768A6308C114126260614CCDF6F72E" Guid="{30FDB2BD-5E5B-421E-97AE-F819944A4B57}"> - <File Id="filFA4C178FEBD09C0A4D38AA90B4523E9E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_reddit.png" DiskId="1" /> + <File Id="filFA4C178FEBD09C0A4D38AA90B4523E9E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_reddit.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF00E284DEEE43B341D12987E20DB76C5" Guid="{A2160846-E461-4C23-BC88-64531B3D2C59}"> - <File Id="fil4A9EA521DBB6DD5E280E4186CD34FA11" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_utilities-file-archiver-3.png" DiskId="1" /> + <File Id="fil4A9EA521DBB6DD5E280E4186CD34FA11" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_utilities-file-archiver-3.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB75BD74E0F63097DC1777FF4BF440479" Guid="{E2C9732A-0FD0-4A33-9B69-0BCD132AB427}"> - <File Id="filDABCE60F828DEEE9AE5064EA3F71EC67" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_VeraCrypt_Default_Mount_Parameters.png" DiskId="1" /> + <File Id="filDABCE60F828DEEE9AE5064EA3F71EC67" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_VeraCrypt_Default_Mount_Parameters.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1745256A6ECE8FB1779B0DA82CEECAB9" Guid="{1A5FBC9F-430E-4F8D-AEA4-7391D85F2E27}"> - <File Id="fil9C3B9E9CFB06A1F7C162B4941656906A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_VeraCrypt_menu_Default_Mount_Parameters.png" DiskId="1" /> + <File Id="fil9C3B9E9CFB06A1F7C162B4941656906A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Home_VeraCrypt_menu_Default_Mount_Parameters.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3F248F4BDDB12D98D3CF173FEA01CE24" Guid="{1B2E6370-1DD1-42D8-9E84-6D85922DFA07}"> - <File Id="fil9E39BB9774782EA2337679D8B86AB1A5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hot Keys.html" DiskId="1" /> + <File Id="fil9E39BB9774782EA2337679D8B86AB1A5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Hot Keys.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1209E63998A1D1504B062C4ECC45EE07" Guid="{ED60D316-7B35-4622-90B5-938260E9E150}"> - <File Id="fil2B4301AD5F5E385426DEEE0DE166D557" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\How to Back Up Securely.html" DiskId="1" /> + <File Id="fil2B4301AD5F5E385426DEEE0DE166D557" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\How to Back Up Securely.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp035C544DF9B46B9DD7871AD7898B7D36" Guid="{44C5611E-FF00-41F3-B744-E18801513D89}"> - <File Id="filF60B07EAEE2B63ECAA396508EC68858F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Incompatibilities.html" DiskId="1" /> + <File Id="filF60B07EAEE2B63ECAA396508EC68858F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Incompatibilities.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA891AF32EF72B7AC80533FC31773B604" Guid="{305DB86E-AE27-4634-9CE1-C4C875EF9569}"> - <File Id="fil8F60E744AB05081B8929E635DDF7B733" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Introduction.html" DiskId="1" /> + <File Id="fil8F60E744AB05081B8929E635DDF7B733" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Introduction.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1FC684D1C3742A927228DE9A669A2895" Guid="{EE9D3F20-7EB4-4628-ADE6-51238E60A998}"> - <File Id="fil9BA13C18F0927CFB3AFBFBDA5944B166" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Issues and Limitations.html" DiskId="1" /> + <File Id="fil9BA13C18F0927CFB3AFBFBDA5944B166" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Issues and Limitations.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp265116FC4778248E01BADFB30A2C32A7" Guid="{37C6EB1F-7A7D-4F00-9204-51240EB7FB81}"> - <File Id="filC57676C07D244DB5A336F1D52D978004" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Journaling File Systems.html" DiskId="1" /> + <File Id="filC57676C07D244DB5A336F1D52D978004" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Journaling File Systems.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB2A3FFEE7A15E23A2835A843438E3669" Guid="{BF14B9BF-8AFB-4E5E-80E4-CA2F3D132F51}"> - <File Id="filF08A4DB40EFF11FE0784034B3D70B750" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles in VeraCrypt.html" DiskId="1" /> + <File Id="filF08A4DB40EFF11FE0784034B3D70B750" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles in VeraCrypt.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFC8FB415783E0AA424FBD685EFACF54E" Guid="{01FCB5FD-953B-49D6-B993-6AC117052F6B}"> - <File Id="fil6DA5794E0BA3F26779AFE828D4E41AAC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles in VeraCrypt_Image_040.gif" DiskId="1" /> + <File Id="fil6DA5794E0BA3F26779AFE828D4E41AAC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles in VeraCrypt_Image_040.gif" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2BCEA21755E1C812ACCF15A09210FCCD" Guid="{0CECEA1A-AB6B-49B6-8D07-8D86B452995A}"> - <File Id="fil5450B4F3DD747980B87B30ACEC318F6E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles.html" DiskId="1" /> + <File Id="fil5450B4F3DD747980B87B30ACEC318F6E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Keyfiles.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9EC1750F7CD9717D3A761FC2930C509D" Guid="{980F49E8-EBCD-4720-8466-C03DC2B3BBD7}"> - <File Id="fil780042F951150166D5D328C10993CE7E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Kuznyechik.html" DiskId="1" /> + <File Id="fil780042F951150166D5D328C10993CE7E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Kuznyechik.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4298A84BD6956E2A2742B5678BCFF173" Guid="{2809427F-697F-48A4-853B-5BE4AE1E720A}"> - <File Id="fil01E37EFCBAF6AB983418B79E3DD75E88" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Language Packs.html" DiskId="1" /> + <File Id="fil01E37EFCBAF6AB983418B79E3DD75E88" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Language Packs.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2D9F7D88EF1F843BDEA5A39D13330B8A" Guid="{7A515A66-AD7E-4B89-8935-62C7B3FCF0A7}"> - <File Id="fil587E308C1A86BF1B8DA5BEFF409C509E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Legal Information.html" DiskId="1" /> + <File Id="fil587E308C1A86BF1B8DA5BEFF409C509E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Legal Information.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp58EAECCB29CB9ABDDDB72F9378E4EE77" Guid="{03CB945A-4EE1-4EC6-8360-56B00FD8C7E8}"> - <File Id="fil76CDD0FA0D1CFE86ABAFDF8ED174B7D5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\liberapay_donate.svg" DiskId="1" /> + <File Id="fil76CDD0FA0D1CFE86ABAFDF8ED174B7D5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\liberapay_donate.svg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp61C660976A230AD4AD8B42A90D4BCC7C" Guid="{7B5EFF52-9EBF-4A15-8117-684E0B40EC9E}"> - <File Id="filE7AA75571211982F69DEE42B8A42D2BA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\LTC_Logo_30x30.png" DiskId="1" /> + <File Id="filE7AA75571211982F69DEE42B8A42D2BA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\LTC_Logo_30x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp29A0605ED3FB7D4E2EAC833D56411563" Guid="{A65BBFC8-1956-4F8E-A0C8-74D32230342F}"> - <File Id="fil9DB1C5CAE05C434550F18FEFC614D725" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Main Program Window.html" DiskId="1" /> + <File Id="fil9DB1C5CAE05C434550F18FEFC614D725" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Main Program Window.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4A0EF1CFD1E1DE8B4E7BF698E05680E9" Guid="{273E1197-B7FC-40E4-AFB0-317D1D0AD816}"> - <File Id="fil8F40D01C235606BC89A05FF0956B7146" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Malware.html" DiskId="1" /> + <File Id="fil8F40D01C235606BC89A05FF0956B7146" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Malware.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1E4F8137AD337BEA1B902E6B003AB953" Guid="{6FF05277-1E0B-4885-8AC4-9B3044DA19CA}"> - <File Id="fil1C19C87ED25856F0A34F96A3AA92D695" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Memory Dump Files.html" DiskId="1" /> + <File Id="fil1C19C87ED25856F0A34F96A3AA92D695" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Memory Dump Files.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp8D35F7D61B2B7DF0EDEAE2E56031E7CB" Guid="{41103C48-5692-4593-8042-75B847917265}"> - <File Id="fil03685445FCFED7E0BA2CA91812337283" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Miscellaneous.html" DiskId="1" /> + <File Id="fil03685445FCFED7E0BA2CA91812337283" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Miscellaneous.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpDE2C66707086A509EABD0F9F6E8BDB1A" Guid="{077B9131-7B76-4E56-9895-0A34F2B7DB5A}"> - <File Id="fil52FBC994010BF4A06B7C78261E002986" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Modes of Operation.html" DiskId="1" /> + <File Id="fil52FBC994010BF4A06B7C78261E002986" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Modes of Operation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpA80443C3767E3E51F3DE88BFD0D7A33B" Guid="{221A050D-548A-42F2-9555-7ECA43D71CB6}"> - <File Id="filD4C6BB0CDA1B086217E6C8B6E4930DEE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Monero_Logo_30x30.png" DiskId="1" /> + <File Id="filD4C6BB0CDA1B086217E6C8B6E4930DEE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Monero_Logo_30x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp214446AAABEBAC0C3827B8977083FAE2" Guid="{76AB42FF-2CD5-4CC2-9E32-640FFA611F17}"> - <File Id="fil82C85BB54B2E986169D519B2AAF71A46" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Mounting VeraCrypt Volumes.html" DiskId="1" /> + <File Id="fil82C85BB54B2E986169D519B2AAF71A46" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Mounting VeraCrypt Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4AF022868FE6883520C700676C43B15D" Guid="{DE7F786D-2B71-4654-86F1-C02CCDA23E23}"> - <File Id="fil1B5039BFF40C7C3BAA602D9AE17668E6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Multi-User Environment.html" DiskId="1" /> + <File Id="fil1B5039BFF40C7C3BAA602D9AE17668E6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Multi-User Environment.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp340BBEC25292C3BE778BA8F158DB87B1" Guid="{34107694-BD63-4466-9317-E2745861F0FE}"> + <File Id="filDF64E26B5CFC7EDB198C7CEA46690CA0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Normal Dismount vs Force Dismount.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpC27AA2C4496C9EFA95DCD663B031B5D0" Guid="{23C15FAB-969E-491A-802E-ADE3255F9002}"> - <File Id="fil5FA8E7B0268E1EF7F9FAFA478FE0C8B1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Notation.html" DiskId="1" /> + <File Id="fil5FA8E7B0268E1EF7F9FAFA478FE0C8B1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Notation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9CBBC8311BBFC54C8DC1162BB17E5AED" Guid="{9C5C22CF-AB15-4D0C-B715-AF1E31B0AFD0}"> - <File Id="fil7A50CAD8D98A751781AF007ABEE22CD2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Paging File.html" DiskId="1" /> + <File Id="fil7A50CAD8D98A751781AF007ABEE22CD2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Paging File.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp033461B0777614621A2ED7B4E2B08D55" Guid="{1A3135F7-200E-4563-90C3-79E5511394CD}"> - <File Id="fil45662024A9E5B2BEBA51908F9478105E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Parallelization.html" DiskId="1" /> + <File Id="fil45662024A9E5B2BEBA51908F9478105E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Parallelization.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0E43CDBBAE343957423AE2907AC16883" Guid="{5C63387F-3BB8-405A-BA0A-10F87C828F9A}"> - <File Id="fil70B46565AEC42A408480FE289D55EA5E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\paypal_30x30.png" DiskId="1" /> + <File Id="fil70B46565AEC42A408480FE289D55EA5E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\paypal_30x30.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp8A8526D2061A14810E1B7A8A6E527DCD" Guid="{F46FE563-00F0-465E-A7E7-901B1B3F412E}"> - <File Id="filF33DCC20E8AA63F4190D46B9D22D71C6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM).html" DiskId="1" /> + <File Id="filF33DCC20E8AA63F4190D46B9D22D71C6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM).html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAE2DADEF126C59D8CCD3A18D8CDC49C8" Guid="{EF70E2B7-4109-4327-BE89-0D411119AC4D}"> - <File Id="fil357A891A8A012F17A7B040E444D36B5F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step1.png" DiskId="1" /> + <File Id="fil357A891A8A012F17A7B040E444D36B5F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step1.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp2F972A5C99F7EE708B7C232EE8647672" Guid="{3190ECDC-675E-4845-A885-F12A1DF98B80}"> - <File Id="filF8BC3136E117642C05A9DE926C174FAF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step2.png" DiskId="1" /> + <File Id="filF8BC3136E117642C05A9DE926C174FAF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step2.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB21F7D781FE7B006ABCA7974A21F29E2" Guid="{E07A247C-4600-4FAD-9766-585D2385EA6B}"> - <File Id="fil559077BE31FD160F8A07CC74414D0B6A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step1.png" DiskId="1" /> + <File Id="fil559077BE31FD160F8A07CC74414D0B6A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step1.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF345174585735CD7A31AE138DDE8B439" Guid="{516094A0-18EA-4AA4-806C-DAFC7BAF1245}"> - <File Id="fil191704A44DE6065F1A5919C5EB1D49E1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step2.png" DiskId="1" /> + <File Id="fil191704A44DE6065F1A5919C5EB1D49E1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step2.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp06772C03A0ECA40F11F1D5C5ACD607D8" Guid="{9235C68E-30B0-4B4C-94EB-6BDBC4057677}"> - <File Id="filF226612AEE0B01C8ECE40DDF61B34478" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step1.png" DiskId="1" /> + <File Id="filF226612AEE0B01C8ECE40DDF61B34478" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step1.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp79E890B8891FA87AA5B10A67E15E7E8E" Guid="{E0EA3C67-4624-47E1-A528-9859B868C7A5}"> - <File Id="fil6351515AD3FA423CD458336ABC480500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step2.png" DiskId="1" /> + <File Id="fil6351515AD3FA423CD458336ABC480500" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step2.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp89C46AE8EC4175E62A9CFE3DF9DF924A" Guid="{0A572658-4C6A-4F2A-8302-FF92CCEA3FB4}"> - <File Id="fil0435E327F9A0E86EC58E465ED1474BBB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Physical Security.html" DiskId="1" /> + <File Id="fil0435E327F9A0E86EC58E465ED1474BBB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Physical Security.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpC8F860B10D41961424874F69C6D84ED3" Guid="{ED207B14-7958-4933-BF3A-1A1F85ECBA4E}"> - <File Id="fil3B718B54EE1655F0A905435EE96043B9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Pipelining.html" DiskId="1" /> + <File Id="fil3B718B54EE1655F0A905435EE96043B9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Pipelining.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp285021B8CBC8E92B1CBCE4C88731083C" Guid="{86BDBC99-AC0B-4542-B14E-99908DD27628}"> - <File Id="filB7C15B9F7B056DB59B2E536B74F5F1AE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Plausible Deniability.html" DiskId="1" /> + <File Id="filB7C15B9F7B056DB59B2E536B74F5F1AE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Plausible Deniability.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpABE9B0A93A9B14C0732EBD8CD17A11AE" Guid="{5EE9BF82-FFB8-4511-B967-3383965953FB}"> - <File Id="filE75832AA56BFC08BDB777474186CECD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Portable Mode.html" DiskId="1" /> + <File Id="filE75832AA56BFC08BDB777474186CECD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Portable Mode.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD9B960879A3227B971E33222CE13BC18" Guid="{BD467209-9DA1-4383-BE25-E2EC8C9616ED}"> - <File Id="filFBF0DB894794EFB2376487A579DFED67" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Preface.html" DiskId="1" /> + <File Id="filFBF0DB894794EFB2376487A579DFED67" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Preface.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3B3BB414D13FDBF2B0C7A9CEBD7D98F5" Guid="{2CF8409E-3423-44A2-96FA-54D793EEB3F0}"> - <File Id="fil7F7441447BC07C288597FEFA0D495255" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Program Menu.html" DiskId="1" /> + <File Id="fil7F7441447BC07C288597FEFA0D495255" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Program Menu.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB39B1096387C2617720F515D24953B37" Guid="{48233666-96CF-4C73-9284-259EC39EA2B7}"> - <File Id="filBE0C2BED7FB2DD3D2FC511AC4D7D385A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes.html" DiskId="1" /> + <File Id="filBE0C2BED7FB2DD3D2FC511AC4D7D385A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp493A37205039E2A3A476A1A4F5360EBF" Guid="{3D92A6B0-B03F-4C86-8020-F756FBAADDC8}"> - <File Id="filC70F6B9415FAADA8160DB4529D0BE54D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_027.jpg" DiskId="1" /> + <File Id="filC70F6B9415FAADA8160DB4529D0BE54D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_027.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpF36A771DF9B1C4CD8E82C08A6D3D0786" Guid="{C0D77203-5FAC-4052-A490-ABB0346384AF}"> - <File Id="filE1423115AD04FF5AEC6F63AA963CB4D6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_028.jpg" DiskId="1" /> + <File Id="filE1423115AD04FF5AEC6F63AA963CB4D6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_028.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp63F6A68C5538B45661168554BC3B93D1" Guid="{252A5E82-AD3A-49A7-8185-421735A09DCE}"> - <File Id="fil5286E3B666BFB60D10FBA4CF8D8F6925" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_029.jpg" DiskId="1" /> + <File Id="fil5286E3B666BFB60D10FBA4CF8D8F6925" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_029.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0158A6D8BED6391AC7150B6C6AE2A9F9" Guid="{5A0D3271-1439-4E71-B7F6-D645FEC8FD49}"> - <File Id="fil2C5151D680BC4575AC607487970F87D8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_030.jpg" DiskId="1" /> + <File Id="fil2C5151D680BC4575AC607487970F87D8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_030.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpDE45667E9E3CD9F800EAC1E02B57AAB7" Guid="{333167EF-38B6-49E2-A24A-04E08F7D87BE}"> - <File Id="fil1B03C5F8575364F36A893E5EE4723659" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_031.jpg" DiskId="1" /> + <File Id="fil1B03C5F8575364F36A893E5EE4723659" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Protection of Hidden Volumes_Image_031.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp632453049391BAACDD117A40EC442743" Guid="{75B50C72-2495-4A22-BFDA-5BFE041EB265}"> - <File Id="fil37E6C8BC6738BF93446E4F2D13E312EC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Random Number Generator.html" DiskId="1" /> + <File Id="fil37E6C8BC6738BF93446E4F2D13E312EC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Random Number Generator.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpCE16E453CAD75A461B4FEBF451A51B7B" Guid="{E68D3F57-0A30-4492-9088-F2D1B0C7934A}"> - <File Id="filC3043FC38C97C7B8038FF12DD7882D85" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Reallocated Sectors.html" DiskId="1" /> + <File Id="filC3043FC38C97C7B8038FF12DD7882D85" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Reallocated Sectors.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpC741D187A28A87BD33866C9AC09A1298" Guid="{FB850461-6BD1-495F-9C10-19A34CFA0F16}"> - <File Id="filFFB70B91C00A69849F9E36950C6606B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\References.html" DiskId="1" /> + <File Id="filFFB70B91C00A69849F9E36950C6606B3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\References.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB313B00E647A121B2CBE47F3048A18A7" Guid="{5985576D-6F6C-4D96-9B3E-9E0961CF9FAF}"> - <File Id="fil2EB5F87C05CCC55D3964D595C85EF19E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Release Notes.html" DiskId="1" /> + <File Id="fil2EB5F87C05CCC55D3964D595C85EF19E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Release Notes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp400428F6494DE58618E3B92539548C39" Guid="{0A1869ED-25F1-4430-97A5-4C6EA8CDA7FC}"> - <File Id="filEDEDEF956F04F36B4163989F9AB9285F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Removable Medium Volume.html" DiskId="1" /> + <File Id="filEDEDEF956F04F36B4163989F9AB9285F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Removable Medium Volume.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFB2313AB16EF2467366ED136C0E61CE6" Guid="{CFEC9559-9F85-46C6-9E98-AEBB573B96FE}"> - <File Id="filE496203C4727FDF47F8352CB9722A8C7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Removing Encryption.html" DiskId="1" /> + <File Id="filE496203C4727FDF47F8352CB9722A8C7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Removing Encryption.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB4C7B1A7A3EC0CB2DE805AC5CC5FC0D7" Guid="{4534E8B2-114E-4173-AE3E-75E0D96EB573}"> - <File Id="fil8CFD1CFDCBE261B6F91D9E587F8720C0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Model.html" DiskId="1" /> + <File Id="fil8CFD1CFDCBE261B6F91D9E587F8720C0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Model.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp00540BF93A805E0B9996945B61E1BC2F" Guid="{1D5B7A85-87F3-45AF-9C09-BA7E088A835D}"> - <File Id="filA7A29851126AC571C090BB0FBEE83CB5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Requirements and Precautions.html" DiskId="1" /> + <File Id="filA7A29851126AC571C090BB0FBEE83CB5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Requirements and Precautions.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp4C46C6668AD830D543AFE593D51676B3" Guid="{4CD21E9D-243F-4A58-A535-AA8EF9D2BFD1}"> - <File Id="fil440C5158A3CD96689918C976DC917325" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Requirements for Hidden Volumes.html" DiskId="1" /> + <File Id="fil440C5158A3CD96689918C976DC917325" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Requirements for Hidden Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp6EE914124966E3A0F695359116413DD4" Guid="{724FA79D-49BC-4075-ABF4-0C318AE39855}"> - <File Id="filD229058EB41E2E150C0CA4D0EC1DF39B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Tokens & Smart Cards.html" DiskId="1" /> + <File Id="filD229058EB41E2E150C0CA4D0EC1DF39B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Security Tokens & Smart Cards.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp28E29B4CA17AB51913B756CD9397EEFE" Guid="{1B9083B9-8E76-44CA-AE3E-0771B1ABA62B}"> - <File Id="filC173058120D357E87951F41755A9210B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Serpent.html" DiskId="1" /> + <File Id="filC173058120D357E87951F41755A9210B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Serpent.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp5DF24509F284FABC600232197F803DE5" Guid="{120A40CF-E44A-4F4F-9072-93248DABACA2}"> - <File Id="fil01F3ACD810057C4A059A5C424E1B79E1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\SHA-256.html" DiskId="1" /> + <File Id="fil01F3ACD810057C4A059A5C424E1B79E1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\SHA-256.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp09E31B885345FBEA1F473AF7A10FD88D" Guid="{1B1C80CF-6C3C-4C7D-BE7B-579042701D0F}"> - <File Id="fil2E702CC679444D8DDB66A3FBDB32C807" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\SHA-512.html" DiskId="1" /> + <File Id="fil2E702CC679444D8DDB66A3FBDB32C807" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\SHA-512.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAE05C79A35A43ECCAC995A711DC4D60B" Guid="{151A493F-38A5-4EF1-9740-255B610B4117}"> - <File Id="fil167B9CF3B9CD2FA5458778733095F780" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Sharing over Network.html" DiskId="1" /> + <File Id="fil167B9CF3B9CD2FA5458778733095F780" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Sharing over Network.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB6D91209A93313D08150643F1738DED8" Guid="{270DF8A0-8859-49F3-BF05-2F155C3CA428}"> - <File Id="filF3B75776C2FEC0F4397274BCA02330DB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Source Code.html" DiskId="1" /> + <File Id="filF3B75776C2FEC0F4397274BCA02330DB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Source Code.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpDB66E821EC13977824FB1069DF5DAA69" Guid="{D08B0614-2B88-4445-9B47-52BEA0E29E77}"> - <File Id="filA67FBF7D25BFBA155A0E4570F404CBEE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Standard Compliance.html" DiskId="1" /> + <File Id="filA67FBF7D25BFBA155A0E4570F404CBEE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Standard Compliance.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp159AB26E32632FC87229090B3AA89BF8" Guid="{B35B4FD4-D82C-47E9-BB2A-5539115F40CC}"> - <File Id="filBFED47E502C7539F724D68EAF73A554D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Streebog.html" DiskId="1" /> + <File Id="filBFED47E502C7539F724D68EAF73A554D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Streebog.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp5BE3E12343551B853E1B143371CBEBE6" Guid="{5ACC0589-AD8D-4BAC-BD40-201BAD7D07BC}"> - <File Id="filA40C816E149FB745F49DAF482DF97F3B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\styles.css" DiskId="1" /> + <File Id="filA40C816E149FB745F49DAF482DF97F3B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\styles.css" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0E081D9499DA225BB788494A1D86893D" Guid="{A79816FA-0683-4097-988B-75FB49DF3265}"> - <File Id="filB5B2E158090CD673A8FE9D55020AFC48" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Supported Operating Systems.html" DiskId="1" /> + <File Id="filB5B2E158090CD673A8FE9D55020AFC48" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Supported Operating Systems.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpBC7134AF21BAE309E9FD1A52ADF92527" Guid="{9570C06B-324A-4216-8D39-57AE06CAC70A}"> - <File Id="fil6D85A49AF2B16D6EE47465F315B140EF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Supported Systems for System Encryption.html" DiskId="1" /> + <File Id="fil6D85A49AF2B16D6EE47465F315B140EF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Supported Systems for System Encryption.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB586F01E9F9657C498F2AB64E1F51BD7" Guid="{9E7FE222-18AC-48E5-ADAD-2A45BD498DAB}"> - <File Id="fil4943B1ACB69010EBD9EC4E9D4E010E11" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\System Encryption.html" DiskId="1" /> + <File Id="fil4943B1ACB69010EBD9EC4E9D4E010E11" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\System Encryption.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp6EB049078039C276CADA69E7B79FDFA8" Guid="{8BDEFB8D-9143-45EE-8095-65B5F4C95417}"> - <File Id="fil5A3E287172F44E471AE59AE8AB15B797" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\System Favorite Volumes.html" DiskId="1" /> + <File Id="fil5A3E287172F44E471AE59AE8AB15B797" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\System Favorite Volumes.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3135BB68A1F44DDD9FE19B7D5FB4ED7B" Guid="{00ED20A0-F1D4-443F-91EE-646A14B229BA}"> - <File Id="fil2C3C74388CBEB07327ED4D549C0067FE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Technical Details.html" DiskId="1" /> + <File Id="fil2C3C74388CBEB07327ED4D549C0067FE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Technical Details.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp98ECAD990DF7B535B05EF6E840B7B2DF" Guid="{1827AFAB-C8B0-46BF-B281-88662B87E583}"> - <File Id="filAB4D4629FE812B0E1CDB1E3CBFB4A297" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Trim Operation.html" DiskId="1" /> + <File Id="filAB4D4629FE812B0E1CDB1E3CBFB4A297" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Trim Operation.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpFE417CCCB859A1C3E4FB90A9C4E132F0" Guid="{A03D9719-6170-4239-9E67-5857521417C3}"> - <File Id="filECA5FD7DEC2F3112CF19DB201F4DD774" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Troubleshooting.html" DiskId="1" /> + <File Id="filECA5FD7DEC2F3112CF19DB201F4DD774" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Troubleshooting.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpD91C00B1B2AACF38761B45D0574884D7" Guid="{52CD1733-C124-401A-9830-56AECD35F8DF}"> - <File Id="fil524C8D572AD8121392C6584496A57345" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\TrueCrypt Support.html" DiskId="1" /> + <File Id="fil524C8D572AD8121392C6584496A57345" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\TrueCrypt Support.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp590EDE3CE6E09D0D43B35287E849B75A" Guid="{5A433701-05CD-4972-9B85-B318BFD5D8DD}"> - <File Id="fil35D6691D20085B8A5F8941864C44EC0C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\TrueCrypt Support_truecrypt_mode_gui.jpg" DiskId="1" /> + <File Id="fil35D6691D20085B8A5F8941864C44EC0C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\TrueCrypt Support_truecrypt_mode_gui.jpg" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9D6F95F912C3B9C95E92E39BA1CE6BC9" Guid="{95929E0A-1AB1-44BC-A86D-F4F4B552121F}"> - <File Id="filE04EC2E8B20706A01283B31462E0DB0F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\twitter_veracrypt.PNG" DiskId="1" /> + <File Id="filE04EC2E8B20706A01283B31462E0DB0F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\twitter_veracrypt.PNG" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpAD429D8A050A0D31B661626BDCA9C952" Guid="{6437B9F6-6024-4ACA-8FF1-23A613E2373E}"> - <File Id="filC71BF1DDF8EB4C886801C1E95CD42F31" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Twofish.html" DiskId="1" /> + <File Id="filC71BF1DDF8EB4C886801C1E95CD42F31" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Twofish.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp3BDE199844AB81673ABB0E5E61E9B7B5" Guid="{95B5F172-3BBE-4620-B68A-F2D3473C066C}"> - <File Id="filD2BC6D56B2FF1A44DB6FF7B24B594430" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Unencrypted Data in RAM.html" DiskId="1" /> + <File Id="filD2BC6D56B2FF1A44DB6FF7B24B594430" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Unencrypted Data in RAM.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0A4AB9AEF0D351FA5E63BCD67DC00607" Guid="{CF5B6BB4-4263-4354-BA4F-ADF283A0F238}"> - <File Id="fil82416621AEEFEB29EFA3DE265214EA14" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Uninstalling VeraCrypt.html" DiskId="1" /> + <File Id="fil82416621AEEFEB29EFA3DE265214EA14" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Uninstalling VeraCrypt.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpCC25F1CB6A1C9D8B47C407B818F73B59" Guid="{5E74CF1D-85A3-4A4F-B1D8-E965912E00DA}"> - <File Id="fil9D6D114ED531555871AD956FCBA5B7DC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Using VeraCrypt Without Administrator Privileges.html" DiskId="1" /> + <File Id="fil9D6D114ED531555871AD956FCBA5B7DC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Using VeraCrypt Without Administrator Privileges.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE0F5E8A2D6FEF181686370F0E1EAC632" Guid="{FDF54DAD-73B4-4D06-A292-353E3AFC27F7}"> - <File Id="fil980276E3BC07E82993537096C68872EF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Background Task.html" DiskId="1" /> + <File Id="fil980276E3BC07E82993537096C68872EF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Background Task.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp46B2E8BCD50BD668153E793EB737BC39" Guid="{A899B8CF-2847-4BC2-BDD5-4B9C77EC13F9}"> - <File Id="filF1064BAE73402AAE56CBD0BED505159D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Hidden Operating System.html" DiskId="1" /> + <File Id="filF1064BAE73402AAE56CBD0BED505159D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Hidden Operating System.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0305CC2824E44F697B402E56A0CD1754" Guid="{4A81FE38-C1CE-430D-855B-2126B865A643}"> - <File Id="filB279C24D2499DFD0899469188292D02E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt License.html" DiskId="1" /> + <File Id="filB279C24D2499DFD0899469188292D02E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt License.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9DD3085A37E22E035A65C74A5B9C209E" Guid="{B7D36E91-D8FE-4E85-A69F-0A3A381C1C65}"> + <File Id="filAB85146302AE4E183B91C079E609D501" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Memory Protection.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1FFF1F3DF3F162C4AEDA7871C7886618" Guid="{8178164B-C657-40BC-854D-55E06F002939}"> + <File Id="fil045BED1ADE4CE7CDFCC60D97F1C5C2E4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt RAM Encryption.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp0E00CBDCB82A904FD6AD82E458CA6AA7" Guid="{54998F1F-E717-4881-B63E-A3493B3EB7FD}"> - <File Id="fil069503600DD8A66DCDA448933183871D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Rescue Disk.html" DiskId="1" /> + <File Id="fil069503600DD8A66DCDA448933183871D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Rescue Disk.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp594B5E68E63675F4986F6717BC1F5950" Guid="{1216918B-2AEE-48BE-B956-9BF6F9AA568E}"> - <File Id="fil3AB9FDA0E3D8D0A0BD0C321E1779EC14" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt System Files.html" DiskId="1" /> + <File Id="fil3AB9FDA0E3D8D0A0BD0C321E1779EC14" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt System Files.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp62748E79EC04EBE33DC46770AD65CDCE" Guid="{6A32F378-04F7-42B4-A9B2-7A500BB34071}"> - <File Id="filB21E0ACBD1948FFB662842F1F6A86DAB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Volume Format Specification.html" DiskId="1" /> + <File Id="filB21E0ACBD1948FFB662842F1F6A86DAB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Volume Format Specification.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpE1265CF3CC5E0B487E99D9D5936BB3F4" Guid="{ADFAD315-C3D8-4084-A7F3-FA957429C5F1}"> - <File Id="filDFCE636A6439CD7F236E004E67DBCD23" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Volume.html" DiskId="1" /> + <File Id="filDFCE636A6439CD7F236E004E67DBCD23" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt Volume.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp1C162513D52824629D7C9FAF96054182" Guid="{8772B5F9-85B5-4DB9-AD86-AF6FB0FECF13}"> - <File Id="fil0CC62FF0B0565DF602BDF277B36D1696" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt128x128.png" DiskId="1" /> + <File Id="fil0CC62FF0B0565DF602BDF277B36D1696" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\VeraCrypt128x128.png" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpB5FA2A488D2C7E59E0B52D18820CE00A" Guid="{CF1BAE7D-281D-49DB-A096-51C3B3DFC40F}"> - <File Id="filCEA5B6C14C18E120FCFF7BBD6791B9FD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Volume Clones.html" DiskId="1" /> + <File Id="filCEA5B6C14C18E120FCFF7BBD6791B9FD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Volume Clones.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmpBB1A4A1EB3FBBE5B2BF2752C302CDC2D" Guid="{69F8D869-FB10-436B-8D13-DBBA92BA4B29}"> - <File Id="fil78A530A8C9B138112029FBCC58AE22E7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Wear-Leveling.html" DiskId="1" /> + <File Id="fil78A530A8C9B138112029FBCC58AE22E7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Wear-Leveling.html" Checksum="yes" DiskId="1" /> </Component> <Component Id="cmp9D908DF026E6297D51B6C4A6700092F1" Guid="{567314CF-BEA8-4AA7-A9EF-F0C776EF80E1}"> - <File Id="fil21EEF98CAEE8AF1A7263353EE9D83C38" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Whirlpool.html" DiskId="1" /> + <File Id="fil21EEF98CAEE8AF1A7263353EE9D83C38" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\Whirlpool.html" Checksum="yes" DiskId="1" /> </Component> </DirectoryRef> + <DirectoryRef Id="ENGUIDEHTMLFOLDER"> + <Component Id="cmpD07393B381E6260DBC0496E0A2B3FDA3" Guid="{C61BFF9C-4570-41C9-A145-F1B271DEB2AA}"> + <File Id="fil45D44F58FC42A92ED1B70EEBBF5E5844" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\AddNewSystemVar.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1731A59A75547D8FA04524DDC7AD2988" Guid="{2C8CB716-7D9E-4F50-B9C8-EA1C71E31D48}"> + <File Id="fil478EA0687A41B5B80BC6BF504A376432" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\CertificateCannotBeVerified.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7FFBD1C115BC0813B91129B4078705CF" Guid="{1AA16711-12DB-4B24-9BB6-3E6FB3707516}"> + <File Id="filCA6B7745E3D514309BF2980CAD6AB81A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\CertVerifyFails.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD7F278D2B4ABBD3373A66252A80FF41C" Guid="{CF6447A0-DAF5-45D9-A0A9-F2341D4A4061}"> + <File Id="fil90040C32C21366278AF4F9B0770BB25F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DistributionPackageDamaged.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA3CA3666C6CCD54031801DA1FF7D7AF3" Guid="{AF6C1FA9-6075-4792-A8B5-4F994C94DD06}"> + <File Id="filEC7C429726D3A10F5E8482C64F649E02" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVS2010.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE90376C911384CD5AE71D0E60076C55E" Guid="{09FB6D81-A013-4EC8-96C9-6F3530570555}"> + <File Id="fil9DAFD0DFC5C2FD1CA5B558445885EE11" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVS2019.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2F53ACA5C5C155121B87F5D6E8A68D40" Guid="{F9F2E740-0F1F-4A07-96FA-10A10C1132EF}"> + <File Id="fil8B115B29D371466A76CB62B7AD5560A2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\DownloadVSBuildTools.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp843B9A72B11653FC613E6888545A2914" Guid="{1E547014-186F-4925-903B-6CB62664647F}"> + <File Id="filF0BF15D8539245F90B27EEEB3133F103" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\gzipCommandLine.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5AF6BA98113B1A6C1B9EB20C78BA4ABF" Guid="{E48105F3-0AF3-4E51-B213-C3FB2DFF5D8C}"> + <File Id="fil055DE3608BF413F80BA1EC0678EDAB73" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\NasmCommandLine.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB235C44A240AB4854F159B87373D335B" Guid="{1FE23DB9-D54B-4D87-BF6A-93E617240040}"> + <File Id="fil0DB2655878FFFEDA44CEC84F76FA2FF7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-1.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6F71C2116891CBBDE64C81A41B85C674" Guid="{BE9D55D0-2777-426B-810D-3F00D7EE2A2E}"> + <File Id="fil281EAD12D3A9AA60B13D898D2B3A8A2D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-2.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9DEEBC6C9B984AFFF4F946DBE6084FB3" Guid="{758D1278-6BB5-4E45-9B5E-F6F3A34A6B23}"> + <File Id="fil853E3417AFE131726F5D73ABC94A0C9E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-3.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD474D105652697A5807E9CBF4B0A0AD0" Guid="{CA7287C0-9F39-4E87-96C3-C72B40B7047B}"> + <File Id="fil69F96FBCAB78BCA39AFF3FE63A0464A1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\RegeditPermissions-4.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp451C53B55201540C7B07BBE0A73A6F69" Guid="{7B7D3DB2-8718-44D3-83F5-CAF12773BBEE}"> + <File Id="fil5E97C4B70EB432B740CA4737AC988C13" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectAdvancedSystemSettings.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp75EA034E68DFB3C765DBA38C1EBEA351" Guid="{9DE6B724-30C2-4FD2-9E35-B8F6BF1CF8F7}"> + <File Id="filED3D1BEAF21EAB3BC54BE5C5DCB23F08" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectEnvironmentVariables.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5691E0C2C85E2E1EDE1E41214E222640" Guid="{E86BFFA0-1542-44E5-9FBD-DD986193863E}"> + <File Id="filF6B7FD6E909E158F3D20366602DCE5BA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectPathVariable.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2C05B384BC73DF32992E4B57F3F48AF5" Guid="{E76F018E-CF7B-4713-905E-C39D507AEFC9}"> + <File Id="filF451A122A259FDA8F0302673E33E393B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\SelectThisPC.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp4B12B4AD977CC6FE0C361B0C98C6A236" Guid="{9B3FB9E4-B494-47DB-BFA8-FE8D3B75DEE8}"> + <File Id="fil3FDE27E383E01656E08AE2D9260C0BD6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\upxCommandLine.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp41B2B2449677DAA52A41DC7795E8C33B" Guid="{30500157-0CFC-4CA2-BDFF-1971593C8977}"> + <File Id="filCD8D226F949DCFC55EF0A6729661BD58" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010BuildSolution.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp22F9BF579449876818B8F5773E181345" Guid="{8CE9FBF5-01EA-484E-B3EA-3C4FDC25B314}"> + <File Id="filABE76B7A556C14CD856E0633C9772570" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010Win32Config.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp82302DD1E595AFE99785A70427299C19" Guid="{FB7BBA9C-0585-4818-BCCA-B4AC014814F8}"> + <File Id="filAEE42E97BCFF0018F4B6A833F9B86C75" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2010X64Config.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp18D83E4B99481D3D79B9D2F79E287226" Guid="{4FF6ACE3-D92E-4111-B18C-414B9B4FDA70}"> + <File Id="fil11F306D0D13B2899353C15034177A76C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2019ARM64Config.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2BDF1EA1DD0D9D8D7E67AF7BA1FB0822" Guid="{6F466AFC-FF88-4B98-AEDA-4C42DC342B44}"> + <File Id="fil2AE15ED2C657441A1C5C5B533C846A70" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\VS2019BuildSolution.jpg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp817AF448E496E79AE0E03C16657AE14E" Guid="{6274C2E2-46EF-4C61-8E64-B52862B79206}"> + <File Id="filDBECC226A37181B82CA8C4E0B7C8DE8B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\CompilingGuidelineWin\YasmCommandLine.jpg" Checksum="yes" DiskId="1" /> + </Component> + </DirectoryRef> + + <DirectoryRef Id="ENRUHTMLFOLDER"> + <Component Id="cmp98E10412F1F15FEA92DA14D5D072CC76" Guid="{1E46D8C7-3B34-4500-BA58-F4568C76F8E9}"> + <File Id="filE7158AD1CC1F2BCB188A5C16A3790D24" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Acknowledgements.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA1262CC2F2086CCA8E3EE8DDA77FF086" Guid="{37CFD927-8FD8-4492-AC66-6BFA4BB30057}"> + <File Id="fil00957996E9B98730DB94A7A4B2B8EF74" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Additional Security Requirements and Precautions.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2DDBA3B10DB23CB1F8EA928B46CCA181" Guid="{D6EC8961-CA94-4CEC-BE7D-D775E5632DBF}"> + <File Id="filF02367149B3227BB79F3302B40C135FF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\AES.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp0020DEB1B692BF8C113BCDD9C35CFDAE" Guid="{243B1975-E40B-4922-B01F-E1DF79D9DCC2}"> + <File Id="filF344A4E68FC8509A979BB35B089860B8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\arrow_right.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2ED752BBF695DA0426DC658681B0246F" Guid="{BB1CFCA6-3545-4996-A247-936EF8E2436F}"> + <File Id="fil712F67BC00D210FE2DC6FE54D8330494" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Authenticity and Integrity.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC2831D4EDB2C6161E9AFFA4E118B4690" Guid="{267F1CEA-6284-404A-A515-BE8DB1297CAB}"> + <File Id="fil3994915D664715F5E1D6B8036277443E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Authors.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC8A17F149AF21481048D7258418DBDA4" Guid="{E4DCA4B4-4DD8-4226-A300-FE27FAB153B6}"> + <File Id="filE221B653D1A3D5D92DCF93954A475DCD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Avoid Third-Party File Extensions.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9D4113D4E0B7F3BA260B8B2B533E299C" Guid="{053CD221-5DEA-4B4E-8D72-D4198E8B0098}"> + <File Id="fil12D7FEE7232612FE63E08ADEC345D47A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\bank_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp84EEBEA4353C6BB7FAFBC651A3044D91" Guid="{DBFC0956-2133-4921-801F-0FF9A81C9579}"> + <File Id="fil3B8C024F8DB19366E87F3C5B4D08E1FD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\BCH_Logo_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE3AD138F57F6B7D59BEA109296613C6A" Guid="{FA3C180E-2F56-49BE-BEEA-87EBF0CF7C34}"> + <File Id="fil7F8D2098D3946F3A50507359AA79957F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\BC_Logo_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9C042008F4284C90B114419C6CAEF43C" Guid="{F7B88459-EEB2-48B4-A5A0-D78FF622604F}"> + <File Id="filA38BA4FD3CBD520C4BD1311E55B6270B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp776BD71B225596C1F5DDCBAFBEDC3D8A" Guid="{AA0FAD8B-1DA3-4231-BC21-8D976A89B747}"> + <File Id="fil95352C343D200A572CCA9B5F3216734C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_001.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp71F37A3E4D3EAAE76DDD223623EFEFF3" Guid="{EE33699A-E18F-4EA7-A3CC-7F5164D6B9AC}"> + <File Id="fil515D9625F30D9AA3341D887EB7243A15" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_002.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7B45DBB2FDDDBAAE80C9BED8518D5162" Guid="{03825687-9E7F-43A5-872D-232A6030670B}"> + <File Id="fil26CA7E302A716630C9E25D3222398391" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_003.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp11BA4D17FE816D5B509E1340905776C1" Guid="{512D95A8-5D46-4676-8BE5-8A2043F4FFB1}"> + <File Id="fil7CC8B3097101E0815AB2FAB58EFD1FAD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_004.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp030C129762387E5309D0ECB8DAF65212" Guid="{68CBF198-6F90-42DB-A610-CF6752359A04}"> + <File Id="filD847DDCA3C9A01BFCFC279CE475E38CF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_005.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAC9DB62D88BBBAE847557DB06BD10C23" Guid="{C2B39D01-686B-4628-A562-FE9CE19EE324}"> + <File Id="fil9F166ECFFD49484817A6A83F22A4EB62" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_007.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp4A6D2989B95765B61974E1E22E2ACF78" Guid="{8CC30554-7833-45CB-8F06-3C5CA07941F2}"> + <File Id="fil046DA564BF688137EBC3D8293A148A62" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_008.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD359378B1A7405FAF65C49BE76F981C5" Guid="{DD22690F-0113-4FE0-9EFA-73E0286743A7}"> + <File Id="fil445D2473E8262D0A415272A40D0F92BE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_009.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp70D8557BE97B70FD9EECAAA0EF5CD03D" Guid="{F2991DD2-1070-4268-AAE9-0A067FD4A7B3}"> + <File Id="filC97FA3E5B5F62D52A279889568A19229" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_010.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpDEBA4E7882793204DA1CC9999C05F964" Guid="{1141FB98-70E8-4537-AD6B-E3DA782DD993}"> + <File Id="fil51D1A64B9108C442EF04556269639C8C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_011.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF516F4196B3085018BC093FCBCB58A4C" Guid="{7EEF4F94-A793-4C4C-A380-5059BB91734F}"> + <File Id="fil485A1A150DC757712ED1D373271356C2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_012.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAC8162634F24C0C33B2E3C6864DA4A2A" Guid="{8D4F4D5E-6CCD-4F3A-A9D7-F86FC6678184}"> + <File Id="filB503C8CE72B1330C0F3A7832E62759B8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_013.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB081741BBB46FA24327C9DB71A7B02B8" Guid="{8BEC6350-9486-43F2-8A9F-3C957D4C76AC}"> + <File Id="fil3EE96533748DCCD69CE6AADE0015DF54" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_014.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD4723B9A6D4909DFC0E1B4B4EE660C09" Guid="{262A559D-11E1-44E0-9870-8DF73F86CFBF}"> + <File Id="filB08CDB0AE9AE7A1F9A4F57F341F8DB7B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_015.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp39E9D88B683EA4F12640DA0A65DE3549" Guid="{7BFBE955-1A72-4658-A0F5-245038DA588B}"> + <File Id="fil898074D01F195541018A9ED1241021DA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_016.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp0F2F30410D88E2533026D3C3E4744E34" Guid="{6BAD98D5-E079-4825-8D96-A266EB104820}"> + <File Id="fil6230D2280E85D4BBC55E3BA6A19F1599" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_017.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB5D683C358B00897FA9F0FF22F315D7B" Guid="{305AAA8B-927A-41F2-AB74-9582B16A78AB}"> + <File Id="fil626B6666F3D264B65D1380788A3424C4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_018.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD3CD0A2A3035277B8D5C83DDD56EEC09" Guid="{24C5AF5D-BCF1-4582-AADE-A06ED51E6016}"> + <File Id="fil1C095262FAAF04439797181DF2BCD399" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_019.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpFAF93B91B7847306F97A8F13C9237BBF" Guid="{281FA34F-4494-4EC0-A5AB-206715464D4F}"> + <File Id="fil399630611E57ED34FF5F55A58F6A6EA8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_020.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp110F96A11106F1AC7DD0DB03480BC3AD" Guid="{5328DB01-C257-4D67-A843-BB3CAF7BD6C5}"> + <File Id="fil3D26C3623F74441149A46AF79BDEFBBA" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_021.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD14CBD246BD84D409AC5C9435CB93C69" Guid="{7BF37DFB-6E5C-48C6-A5A5-49F980C62D80}"> + <File Id="fil7430394DC66200EC9A37F3EAA89C5F4B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_022.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp338A05D33900D38A2218604CA622D528" Guid="{FE1A076C-BD66-4AD3-BAFC-F4B729F27453}"> + <File Id="fil6B82AC858902DDA6B13CB462FCA8C2FC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_023.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6AE588318312858B13C37DBB81243BB4" Guid="{EBFDED23-3C6A-4D64-A975-0F5906F1DD03}"> + <File Id="fil143CBEFBDE83CBE94970CA93A007D362" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_024.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp40450814BCB759314CC3FDE6C648C0C4" Guid="{0350A675-CF91-4686-A3EF-1DEAB8F22764}"> + <File Id="fil90C779622EBB339C3AB90FCF647FB159" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Beginner's Tutorial_Image_034.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp8D0D5C8F66B9E9213FACEB65D779E93B" Guid="{823A3D60-4534-497E-88E9-A23C7DAE7B29}"> + <File Id="fil7C200F86B78E2A91BB493FF5F651CEB4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\BLAKE2s-256.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1969CFCA4E8E6853AB60C3E5E84EC96C" Guid="{0636E6EC-8C7D-477E-BF1A-85FB37C9CF76}"> + <File Id="filF963F35BD28A778D78CBD6DACA37987D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Camellia.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp0BF1FE522880BBDA428837E3B646DA5D" Guid="{74D1739C-F0C6-428E-B86B-ED6E77784B6E}"> + <File Id="fil0ACFE35E496076BAFFD2359D7E95CE6C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Cascades.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2ADCCFAA99C96B7E74D50F58AA2DDAFA" Guid="{457851C3-1FB6-4580-8D73-3761F7CF08F6}"> + <File Id="filD0542209DDFBCDFC2ABD1237FBEE184E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Changing Passwords and Keyfiles.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp0E448FAC0CED589DD138E162986FC0DE" Guid="{035ECEC0-9B4E-41FF-A4A4-8EC14B2FB947}"> + <File Id="filA793DC75E1D0F03F15CC0F4D341D43BE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Choosing Passwords and Keyfiles.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp06C8D9A3457DEA62A19ACB286B2E32EF" Guid="{400FCE30-08DD-48AF-9025-6FFFFCBE5D09}"> + <File Id="filED12CF7F85BA168570C78F70F348013F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Command Line Usage.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7447D492A3894509DC750B48E7DCF613" Guid="{9B804653-B3F6-4FCD-98E3-FB314555737B}"> + <File Id="filA6BC7A2C35BF2D2985FC723FD56D3ACF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\CompilingGuidelineLinux.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5C2B87E203BB5FCA4F77B19D3E6BA307" Guid="{7A0933C7-384F-4DAE-B571-D16D1F9EEBB1}"> + <File Id="filA3657AC1CCAAD3DD9B2B804FFC97369E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\CompilingGuidelines.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA5748D4E937680A92DBAE78CE5B2F28C" Guid="{B62CC2F2-FACD-4EBD-BDF6-7CE826624805}"> + <File Id="fil5DB2B097D4C2BADED0282CCCBB289955" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\CompilingGuidelineWin.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6FAAD943919CED1962892A80342F6791" Guid="{A9914433-E735-40E1-A95C-A5B76131C400}"> + <File Id="fil1CF8CA43DFF75AA00E095B0A70374FA3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Contact.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp948EA396F48A342F4EF23F2210CB5B4F" Guid="{7D17553E-3229-4748-99E4-429CAEF47D0A}"> + <File Id="fil9C60823BB1AA224FE34CD4D700B43BC5" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Contributed Resources.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp29F827B72EB9BA3A4BBF4135346BFB3F" Guid="{B828A496-9C99-48E6-AE06-729F28EF3E71}"> + <File Id="fil7C98F44466206CB68570E9E352608D5E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Conversion_Guide_VeraCrypt_1.26_and_Later.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA6461FAA6FF2B690A1950611770B4238" Guid="{6B5E731B-CFFF-4A5A-96AE-73868F17389C}"> + <File Id="fil342E8576E5BD6E8EC8117C02301B29AC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Converting TrueCrypt volumes and partitions.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA386DE1E79E889FA61290114537BDEE3" Guid="{5CAD6EE0-E4B0-459A-B90A-665F13BFAA9B}"> + <File Id="filE3DC8BDB3EF17E11B5B23A05E0A24779" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Converting TrueCrypt volumes and partitions_truecrypt_convertion.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF78CD517DB1E24484B5CC82B2DDD5E9C" Guid="{4E848927-689A-4649-8A22-760F5E52E679}"> + <File Id="filAA3E420FD899F39B025E177868028D1F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Creating New Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBA0D70B7A50226DCD8144689A79ABDCA" Guid="{E57A9C60-1140-4AAA-A1A0-701D1A21B053}"> + <File Id="fil5AD3CE9C014F011BC53CA40A9E6045F6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Data Leaks.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp589D4976F5CF94C27910A8F4EBF29FD5" Guid="{B4BAB52C-05BC-450A-9EAF-537FF9A46DD3}"> + <File Id="filEC6FB28FFC2CD1E5CB26F25B71BA629A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Default Mount Parameters.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpDEF5E40C0360414577A9FB6E9D209C31" Guid="{26B9A786-BA73-4666-A374-7E5CC0592203}"> + <File Id="fil5FDF31D27DD1BDB73A9E5A4C2D589A7C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Default Mount Parameters_VeraCrypt_password_using_default_parameters.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC0FF4C2C070C62B0E55BA14B329A58FD" Guid="{EB3A59EE-B573-4920-BC6A-9151B4B8AED8}"> + <File Id="fil23768A1C9C05F83DB735D9295E237A2B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Defragmenting.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5F3D5E0970DA4DCB5655AEC4AD1C94C5" Guid="{0E1D5043-3EC2-41A8-93C8-3A84310449A5}"> + <File Id="filAC9A11620C67DBAF2AD27878B9C9A2CF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Digital Signatures.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp14BBB28777FE8A9914F4BB38B50C0311" Guid="{6AB068A5-D95F-47D2-BE6B-B7F59867E192}"> + <File Id="fil0E7CF18F39AC92ACA3367FBB71E1C693" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Disclaimers.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp10C79CC28991F4E8A3E33C66D7280D88" Guid="{F6CE703A-6A93-42C1-B40D-3CAF643B5A4A}"> + <File Id="fil251DD3CBCB210AF49D6BD4EBE80CAFC3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Documentation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7E0AF9A50799D06DE12C94A60C834F5D" Guid="{A69B4D59-88C2-43E4-ADA4-9AF2EBEA1B45}"> + <File Id="fil88AE8F1D1D73320B20A12E91039B1D93" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC547B50DD1AB37E959FB18D1AFD9C051" Guid="{B998C0C8-3AB5-4A28-9775-44704A059A5C}"> + <File Id="filD0D938903C2CBD5A5C816A84B0916199" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_Bank.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp716240038B6F46034428E43768E32CA7" Guid="{3F6B140B-980E-4C77-8F23-3042F0DE1232}"> + <File Id="fil81D7649C6E479DA68C7CE5A9FAABD5B6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpEF2FE09A2E8F60EB28ECBA7BEE5E9026" Guid="{FACD44DF-1AFE-47BC-B040-7314EF8901FB}"> + <File Id="filD1253F529C397B15FE6B1C21D2E083B2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_CHF.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp4DE7E89729EE1EE9EEA042F80B412D3D" Guid="{4ED6286F-296E-454D-8C1E-B675F267F0A1}"> + <File Id="fil56E8C2BE62B8D5FBF24CAC9D2BE338F7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_Dollars.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBC866AF7B9269946668A324AD39D08A7" Guid="{2CBC09D3-3308-47D0-9DDC-8F06E1F513F3}"> + <File Id="filC467D47EEF3B27D242F8D55BEC0C3B45" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_Euros.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp59C951F15FE54CBB5EF2528D4AA6F73C" Guid="{6EB86A24-5DED-498B-BC73-7A7F1DDA3048}"> + <File Id="fil311C93950CD02E7B5C437C150B7E11D8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_GBP.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1BCCBDD405E75313F3B3CE6EE8DA86B5" Guid="{DC9B1FCE-BA6E-4B38-8FD5-3E68CEC9B122}"> + <File Id="fil1A20E57E9AE32470876005B2246B9C9D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_PLN.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp3E991C4739DF1DE5475ECE135EE98D0E" Guid="{FA9C68EB-D745-427A-982A-251CA386B625}"> + <File Id="fil5B40D49C27FF86BFF5CC8CDD9D34B25D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_donate_YEN.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF6A11C5F07AADC2DF98D1549024AA5D8" Guid="{C63CD654-EFD2-4C67-AF32-CD69ADF0CE0B}"> + <File Id="fil7804A7A2C59A4FEDB9469EBCC705C5C4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VC_BTC_Sigwit.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp92387146C4EDCAC1653A2FDD573D2695" Guid="{6E26E556-D86B-405F-8772-41B57A62CF0E}"> + <File Id="fil43B20F7F00EF4AF79D0F82FB86BDF1A3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VeraCrypt_BitcoinCash.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAD29968DFA6888826A5718FF6533D96B" Guid="{E26BF267-9896-4A32-B3B1-52FF1771DA1B}"> + <File Id="fil6997FE1AC19191CA5556C409A2B06A66" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VeraCrypt_Bitcoin_small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpECD5EF9F2075A8512411DC0C4A5249D0" Guid="{3225A53B-22E0-4BCA-99A0-E2C1604DDF74}"> + <File Id="filFBCFEB2644899D7672ED7C8B4B93583C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VeraCrypt_Ethereum.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCB8D27F16124CAAC7244A48FFA4AFB7D" Guid="{7E07BDF4-422E-4740-B2B4-D35ECE68FFFA}"> + <File Id="fil5E96F5FACBC48E4D44AF52E7017EDE2E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VeraCrypt_Litecoin.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC65A16FF1BC895E90BBB53B78E68DFD9" Guid="{F06D8C06-FFAD-41BA-9EB6-9B4152D1C5D0}"> + <File Id="fil99117693F262D29831F855AE5C5BE2FB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Donation_VeraCrypt_Monero.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp87F512AEE17E1578EAAE94230A2D42F8" Guid="{39BC9692-4381-4634-928D-1A0DF36CEF23}"> + <File Id="fil849BF471E22B7E5A8E6028B9CE71D955" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\EMV Smart Cards.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp97920FB49AE81562FA7ABFFA9A5DE439" Guid="{4CD7F374-7ABF-4818-B904-415E1ABE4C87}"> + <File Id="filB1351FC0C4B53047D98C8D2C2E74B76F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Encryption Algorithms.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC57C3FF497FC91DB80B6398E7FEE7A64" Guid="{69676767-4954-4E36-BF2C-C8C57E283809}"> + <File Id="fil999EA9470381ED95774B2F30327F42CC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Encryption Scheme.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpACDA6D0F0078725DD4A8708187C76CD3" Guid="{94D0E529-D973-4608-AED7-9BF84D153B93}"> + <File Id="filACFA702EC92AAF197E324F8A4670925F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Ethereum_Logo_19x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCEB5D33CBF8513543D361078523B750C" Guid="{B03D987A-5F64-498D-81C5-8931210167FD}"> + <File Id="fil9DF0E4F06C4CC28FE82B68EA719CA7A8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\FAQ.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5FC13AB774FAACB290717853ADC20FCD" Guid="{5D5F86EF-D567-45BB-9042-C8ACC0D1A64C}"> + <File Id="filC6B2CBE7C0D68BA11C5ABBB141BF9C13" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Favorite Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp725B9ABA14E65E9EFE49157CA4FC128B" Guid="{3F54B3BD-731F-4862-80C6-9B8610DA6C34}"> + <File Id="filF10F025AC0583B894E3286096A01D86C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-au-small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBD55DC12534E09C8553C28F5B5C0FA4E" Guid="{38080305-F2F4-4B27-9416-7D66A6778A5B}"> + <File Id="filAA95BAC6F92E0C3E60810688DFD29980" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-au.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7C45FE83120EA12DB05FC171A06B30AE" Guid="{44347474-FEB5-42B6-B784-DEA6588E94A3}"> + <File Id="fil567D7AAE5C7AD34C3E9CCD97F45A7DA9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-eu-small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA76542EBEEBAFF2C7A5BF5AB2741D4FE" Guid="{52AB5852-823F-44F8-BAAE-6E45841053A3}"> + <File Id="fil0C410338570867504C800558921DF547" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-eu.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9B9F529CBDC007E9FA5CF79E8867DA67" Guid="{660D3EB9-69E9-4C09-A80B-61B685164865}"> + <File Id="filA65F8408CB5D977DB1FB2F2D213C9C1B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-gb-small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp87244E466A2EB7ABF13AA619B977BF78" Guid="{B5D6863C-CB4D-4547-AE1A-1589D58ED59C}"> + <File Id="fil8E1098F49A784F0A7BB739B645B79486" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-gb.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp712EA51FB151C694292EA58C5A578BA6" Guid="{0690E629-B61A-4529-968E-111F8B76CC3A}"> + <File Id="fil051335FB12568EC0300D3074923E2FC7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-nz-small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp870CD5E9E23CF6C9067DEADE20C9FC35" Guid="{2C9B1C3B-A64C-4702-BF0A-6A841EA5DE07}"> + <File Id="fil58E6588D8192387A80BBC90A47D15F5A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-nz.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB006A7FF853B4EBD76D04C32E9455C4B" Guid="{0875F9DA-30F6-4C1F-B8DD-FF0F3DB5322E}"> + <File Id="fil10D204C1119D321DB710C753AE3FCD84" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-us-small.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp472CDC24D7DCA0786CBD55DD01B3C326" Guid="{C9019907-5646-477C-9C10-42E3BAEFB5D4}"> + <File Id="fil7033CEBEB76DFF2B46660583C49940C0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flag-us.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp89C6FF5C5AC2CD9880C5409B5AB83825" Guid="{06FD875A-5E07-497B-B597-6B58C380FDE0}"> + <File Id="filC477A3F4D76A8B461F5C190234398634" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\flattr-badge-large.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6C831E6A491B7EB59D88781A5BFE9F15" Guid="{EB98758E-25C9-46FC-A862-EA5D70B8F995}"> + <File Id="filA731163EA92A35C96170C2E03BB425A4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\gf2_mul.gif" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp60679C4F1990149DFE8EBD00D7C156DA" Guid="{9BD3D120-BDDF-4674-98B2-41AD9EF6AB63}"> + <File Id="filD0CC24199C304D7A8A858CBA7A654B2C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hardware Acceleration.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6382DF988EB9E433728A02875F366B29" Guid="{08193FF0-DE93-4D2D-88FD-EF79D1485504}"> + <File Id="fil190EAE3EEB7E8D6D25C505DF88F3E4A3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hash Algorithms.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6ED341130E7BC5619B617E61C4DB60A8" Guid="{EE5A73E1-801E-4D35-B003-7DD3FA395578}"> + <File Id="filF859FB60E1E6FCFE2743075386E7C44B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Header Key Derivation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp216B8D95DCCC0DBA860DA22728386441" Guid="{9DE55946-949E-4B69-ABCC-9C2CB28D0F60}"> + <File Id="fil67764638227AC03759557FA84F4E45A7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hibernation File.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE4595A43F5FE7BD7D162F3652BA6C266" Guid="{EC6DD328-04BD-40BF-82D4-352C38A83BD9}"> + <File Id="filA7C6D42B98E460E939BC11C81965F139" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hidden Operating System.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7D5BE6FDEA3DE19095769A66D0AE29A8" Guid="{730C3E41-3612-40D4-90F3-CE31171737A1}"> + <File Id="fil0781238BA710BA7239906B2C6683D2E3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hidden Volume.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp61565372125F227105B9AE44241F1967" Guid="{CB7C0BBC-C81E-40B0-B804-868BD85D7176}"> + <File Id="fil78AAC896C033D0BD64B2A21C0375B4A6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Home_facebook_veracrypt.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBC1662DFA34FC9A8F203FDC51697C8A5" Guid="{ECB71BBB-96FC-4118-B23C-15EAC0EF8201}"> + <File Id="fil87BEE86BAAA572C9FCE0B78D72488EF7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Home_reddit.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5EF5D5F4FEB4B57BF58C3046BAD8A1E1" Guid="{27F5DF12-28FB-41CC-9DA8-B2C285095A90}"> + <File Id="fil3F75AFE90F61500851F4A30816C1C0DC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Home_utilities-file-archiver-3.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE9488D44ACC744E76E072585F84C491B" Guid="{9C3FC852-677B-416B-81D0-30C50AFCC315}"> + <File Id="filFDD8D99DEF8FD2AA50A4119C26F6F020" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Home_VeraCrypt_Default_Mount_Parameters.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp4228F912DE70A8E8A341A3B3EB232186" Guid="{7B4D1332-FEF5-4C7E-9F1F-334EF1E3DF23}"> + <File Id="fil1018564094D177036DAC90EED085B81A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Home_VeraCrypt_menu_Default_Mount_Parameters.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp661A873DCAADCA5D6DE5658C1AF6238D" Guid="{7EC01292-7052-43A0-A3D2-4AFB95B17C20}"> + <File Id="filCFEB6318D5A8BE5C7567C50DA1291A8D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Hot Keys.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF8C6E0267E7995D280B8E7F4172C7F18" Guid="{4437A3A8-E9DE-4A0C-8F37-5F87FAE787F5}"> + <File Id="fil6ADBDC7868E643C76B763489C2E6A7A6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\How to Back Up Securely.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6004A52073268319FB67C09279279ACD" Guid="{643BB248-5A1A-419D-B100-35577D6977FD}"> + <File Id="fil24F63F6B8CB269B5C337242605B0CE5D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Incompatibilities.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpEEC16C2DA6C942B7F814FE2ECE9AAF65" Guid="{5FDCA6FF-29D4-4FEA-ACBA-C40632316DDB}"> + <File Id="filB96837EB023E33E1EE33E0B9FD3D2EEE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Introduction.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA116A7CF851D562952FD8F362EF4F15E" Guid="{A40EDCBA-F529-4FE3-A5FA-38443537A282}"> + <File Id="fil09B76C17ACCD566BA33B58E3783195CB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Issues and Limitations.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAA28C1518620F4CA7377132D083B5E31" Guid="{FC4C3276-6E1F-4667-A9D2-B30A5A048DC4}"> + <File Id="fil7363E637A85FB040AE31A8C10D9EA95E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Journaling File Systems.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC384B9F228D8242650A1A48FDE46FADB" Guid="{4C811F2A-F3A7-46DB-9918-1CF2DEB4A21C}"> + <File Id="fil8131C5093DE56CDE509DFC7DADB0393D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Keyfiles in VeraCrypt.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD858F6459F1D5BE26754F7B9A6B256FB" Guid="{0549963C-5BFE-471B-BF1C-3913C2AE310C}"> + <File Id="fil5ABC9680196CA5F82BE0317CCFE7AE4C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Keyfiles in VeraCrypt_Image_040.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD935A23E00BC5621253BAF554A60C48A" Guid="{C69045AC-0379-4C49-B7C7-CC595F754574}"> + <File Id="filA1D369E59AFCAD94F135D1A53959F488" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Keyfiles.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCA290469DDC2BF237F81DDD5B1767EED" Guid="{AF232DD2-C9E9-43B2-BA21-C653C3D78B17}"> + <File Id="fil707DCE82E2DB960CA32D798C9D58BFD0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Kuznyechik.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp72EE25B25C5C68F03DF9176C2D3F8BDD" Guid="{E162CD5B-C72D-4DEE-BD06-048CAB209743}"> + <File Id="fil30D8E2286343AA063BB31ADDD09E8B79" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Language Packs.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp29F705976D3FE416CA69F9A85F81E453" Guid="{6AA40E35-18C4-497A-97B8-1B5739FE9BD9}"> + <File Id="fil8F0F4FE7BE9BC18EB89888D49028E7E7" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Legal Information.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp3092B4A3F28D76A5F41FB2DC967976BF" Guid="{0C7EEAB5-C208-43A0-B276-7803E104A241}"> + <File Id="filFA23C1DA863D0B428EB6C84728997DB3" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\liberapay_donate.svg" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp05C4713E55D9E8032EF515CC96771B98" Guid="{06C44F0D-F6EC-4D04-AFB3-BCC88EF5DC0E}"> + <File Id="fil3EA3BDDE6D7CD02134F6440990EA9D22" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\LTC_Logo_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD979C33BE6277C13010EF93D9FB338C8" Guid="{598B57FA-D03A-41CF-9543-CF7C167A1C41}"> + <File Id="fil460751D6D3A89545E7ADB68946BC9E50" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Main Program Window.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBDF94D6F72E05F0E90815BA6CA48AEAA" Guid="{F3831D53-D041-4BBE-A8F5-5183E1B511C7}"> + <File Id="filB6A639CD358B2CAEC5D91CC50C4BEB6C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Malware.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5F801DCC01F26894D68A6EA08E45B76B" Guid="{ECA81186-9645-4814-A4DB-2423B3E44D50}"> + <File Id="fil5B5FD576468A05E387E8451479346039" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Memory Dump Files.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1F82E220BB2635E789DB76D708745EDD" Guid="{E46AADEA-AC47-4B33-9018-9A4B37107388}"> + <File Id="fil33F329D72F3E01B18BD0E9711CB53724" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Miscellaneous.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9FEF6DBD25CA9AFF6103A75B72D304B2" Guid="{AA5775F0-3653-4146-9CA9-8D832CB20084}"> + <File Id="fil4987E346273D390365EC2E924844B6F6" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Modes of Operation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp1710916CD3A94FB29C9213789A147AE0" Guid="{3BE0A3F7-0B98-4877-B598-F13C3D809D29}"> + <File Id="fil3B8702069522EEF4C41709CEF88CD320" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Monero_Logo_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAA303E0AEBC0E1EB8C2472B1ED65324A" Guid="{18BF4762-B5B2-44DD-809D-47E2500FF274}"> + <File Id="fil5DBD024B36EE31AE69F3FCD351434D83" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Mounting VeraCrypt Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpACAD2B0C89247F272E42D86D48ED6ECC" Guid="{29EE17AF-B34A-456D-BFBF-6CE3884EAD3F}"> + <File Id="filD2991527BE5D0C1F42F6C69FD01376B1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Multi-User Environment.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp4BC713FA989ECC8EC884548781C4F29D" Guid="{191AF27B-1811-4149-9713-2B3913422D32}"> + <File Id="filB4D109A8E9F7C159C41DA988EF4AE5BD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Normal Dismount vs Force Dismount.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2CF52C3BBF31CCD0752A49C11FF294A7" Guid="{0C07FB83-253B-4229-809C-4E1DA30C3626}"> + <File Id="fil4E4C69B10DB0A7BA934182EE4EEBE7A0" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Notation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE60FAB408B216C9ED62A362BC7EE475D" Guid="{E9977A92-ED5A-41B8-8145-A16EE57C3B9C}"> + <File Id="fil02CC195577742491580A891153510D87" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Paging File.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpAB7AC6D28286103D7E729673FEDFCD5C" Guid="{BA71446E-7917-42BE-BAFD-B60F970DE576}"> + <File Id="fil5CD332253AF628426FF803CFA3EEB00E" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Parallelization.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp3E980DF980C84895107EA078801D25F6" Guid="{8BAEEAE1-E52B-468A-8B0A-848F28F9A158}"> + <File Id="fil75BBCC1F9D06DC266552E73F1AD37E55" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\paypal_30x30.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpC84F22C32C2455E14F0833097B100309" Guid="{5B966B3C-CC2C-42CA-AD4B-3B6E61AA8CD6}"> + <File Id="filB60DDE7D449498811CB4503EBFD1627A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM).html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp13BEB53EDC29960F3AD13DEEAB9C92C1" Guid="{EF5A7914-9A73-40CC-8281-C39515F32CF6}"> + <File Id="fil9F16EA0C514E74BABDFA16FF779B2366" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step1.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6DA588A2041707855690C560C64C438D" Guid="{6E7A34E8-409E-4A6C-ABCC-A083EF0D85C8}"> + <File Id="fil0FDB5B4BB86CB0DC3DD9A47601F969E4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_Step2.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB03F168BA9DD4275F206E53CED02A12A" Guid="{0448D47D-EA99-49B9-AEF3-ECA71AAF3170}"> + <File Id="fil01744A7B2BAC5451C4CADEA956C6496F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step1.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp673ABA162209C25819DE3CACF4E612D4" Guid="{BD77BAE3-8403-4EEA-8253-53E99452BC4C}"> + <File Id="fil095B72AE4ABC141C50AFC0DFBB6FDE75" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_ChangePIM_System_Step2.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2198CDB3A37522808F3C0FE67FEE31BF" Guid="{5C718434-79C6-4A36-9872-9BBAE0E3FD5A}"> + <File Id="fil47899B71D3625A90E35636946C2F9E8A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step1.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6CEA0C62D82A3B53499C2D4EF2C3B5F0" Guid="{EE5F98B8-8F0B-4102-80EE-D019827B79DA}"> + <File Id="filF0DDC36B8AFF23D140418C8E83CC7E7F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Personal Iterations Multiplier (PIM)_VeraCrypt_UsePIM_Step2.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7FBF805189D05F4E3E1197B6024D6583" Guid="{37E0E34D-7428-4F2B-B1A5-B5A5E447A54D}"> + <File Id="fil02F7FC5545130C979CAE47352812B471" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Physical Security.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp37C51862BC6949DB6195DC1A9FC37855" Guid="{E64AAA0F-4F7C-467E-8D46-EBDF6A21B6CD}"> + <File Id="fil3388DF9F080840CA1803899800611431" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Pipelining.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB12223A6EEF742CCFB738D9C8B708ED9" Guid="{72C5B029-9A91-41B1-951A-35C2F6DE8212}"> + <File Id="fil011529FF2DB96D173D1A002C4ED91EA2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Plausible Deniability.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF4B2DDF581FADDF14E3613D517675CE0" Guid="{6244D574-96CE-49E3-9CEE-AC6BC0073C7E}"> + <File Id="fil3CBD4B3C22495E5B593AE08E3A25FAD8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Portable Mode.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpBCCD12E77FAEA515D6C1555B7823E169" Guid="{9AC6C96F-2972-465D-BA9D-27CA21657D44}"> + <File Id="fil96C282D40ED5948DB9DE6EE18087FDB1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Preface.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp32627BA5A52D1C2FD2648C6907F4A00E" Guid="{CA2EE0D9-F48F-4955-90FF-CDE3EC30A414}"> + <File Id="filF6F199A516A1E59EDAFF7B2C94125326" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Program Menu.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7A44CB40DFC859E66D7CC2582EF9948D" Guid="{7ED5946B-15C3-4319-9392-745E1993CD7E}"> + <File Id="filE29BD05D74CF7147C16015D26E0D0965" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE819E5D393DD7BCB4D1C101FFFE6FB0E" Guid="{D0ACBBAE-6836-4C13-B7DB-B0F4C7814963}"> + <File Id="filE8C345D68AC9CD17F27D1775FE52DFA8" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes_Image_027.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA29ACAD11D850472C56137504F770B8F" Guid="{92B65549-F99C-425F-AC08-B241A4D489D4}"> + <File Id="filFAE8075438DD33C16F4374B435420976" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes_Image_028.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA2581CD77714E8D6C2A4DAA258590E29" Guid="{CE7715E9-7231-45B4-A467-D9C4E57C3DC9}"> + <File Id="filCC0A38CA5F69C4A5769E47C179450A09" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes_Image_029.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp3F6C602C80B5711DE3EDD2FE8EAFD00C" Guid="{CE514A3A-3FA7-4709-BF44-9AA7983E2085}"> + <File Id="filC9627DF124341B321750B55B59E0DE93" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes_Image_030.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp30C5A7CA791767CAD2E9E124826EE047" Guid="{20BF8298-08F8-45D4-B3F8-711CCF7D232B}"> + <File Id="fil3F8845ED4FC6FB48333245942CFCF281" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Protection of Hidden Volumes_Image_031.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp770DEAD9D0C6D2439CA86800A5709567" Guid="{8E54D7E5-AD67-4821-A89E-82CD481383FE}"> + <File Id="fil53F6F8C9562DA16D04B3676A819074DE" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Random Number Generator.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF8CB44545962DB01EC6DD9DFADA36FEF" Guid="{A0BCF67F-F6BD-43AA-8621-509DC4C098FF}"> + <File Id="fil926AD3DE34292736661E4121511E2C33" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Reallocated Sectors.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp8468AE251FAE8743371ADE14FEA935F7" Guid="{1107B9A1-0CD0-42EC-BB0E-FD9B36C2B389}"> + <File Id="fil94E6A42A2F5941B37BFA7B89E0013269" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\References.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD2BCE21F32CF98AF542769B408047D4E" Guid="{0211D943-81B4-41F1-986B-BC7C1F67BB12}"> + <File Id="fil369EA0C6D2CD0395EB1867686381962B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Release Notes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA1B275EE180C48643BFF410ED187E170" Guid="{702881C1-BF01-41FF-9E2F-41B41D7DCA41}"> + <File Id="filCA203D40F4E3E621019FDB803CCAC360" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Removable Medium Volume.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2458A9EEA35AAC6F7AA66C71F2C8E500" Guid="{82D7913B-B2EB-4721-AD4F-8C6C3A0E4205}"> + <File Id="fil7B2E2AC531EAA5E908E9FFE7B78141F9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Removing Encryption.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp725AEB3BD6705908D3DDDC49D446EEDA" Guid="{FBABFED7-B8A0-4118-8E71-78BBB5C9727E}"> + <File Id="filCB5E6D9EAC9BDF471001523E6BCDE4F9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Security Model.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp84C361E84DB09C711566B58D9822B3A4" Guid="{EB330FA8-0E12-4840-AD03-7490B7A379D8}"> + <File Id="fil69B171CC7FFA1445028EBBD77CC5C07A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Security Requirements and Precautions.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpEAC38538AB52AD68B5B36DEBE9310DDE" Guid="{7A28FE9A-1921-441B-BDB5-A587A8C232B4}"> + <File Id="filFAA0F1D9008EE05BEF57A6F603A76E56" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Security Requirements for Hidden Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7B700E12FA433825A9ED08182F8CF6A6" Guid="{DC0198A1-6AA0-4D03-8BEC-6046C0619847}"> + <File Id="fil651B93A431120CEA3EC491F3C5FC86C9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Security Tokens & Smart Cards.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp8548A76FB3F15F37E8690D54D9E37153" Guid="{8334F668-DBC2-42BC-8000-B4306206F69A}"> + <File Id="filFC7609F5E8D8B008DC89C72B23DD087A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Serpent.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp84AFAC0919E0FDAB5B0C943837BB10FB" Guid="{1C918891-7177-4955-B617-01A03190C47B}"> + <File Id="fil661E94A96B6BEF3A4929BC4C817D8D61" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\SHA-256.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7E863093EB77CAFCE23926751F601D06" Guid="{C9915AF7-A108-45EB-B2D2-8DF7FFE208D6}"> + <File Id="filEA2C97401DDFC0ECF10A85463E6A9ACB" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\SHA-512.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp88CC92142E3E491F76F7BE7582508F44" Guid="{B6C13DA0-2B05-4A3F-8B47-3FD0CE40336D}"> + <File Id="fil4FD6057086DCA9E013B009CD28709AB1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Sharing over Network.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA65F33B67588CC31BC7CAE2E2C651CB6" Guid="{B68A85A8-7B2B-4A64-9ADB-C0C0172A6204}"> + <File Id="fil16376E30B9EFAD82C45D2317FC963F7B" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Source Code.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp78D7D716B5B1FE70B04CF6A10B38E34F" Guid="{AEC8783E-96C2-4655-9EF2-27B26B43DEC9}"> + <File Id="fil508F4406283C4BD07CF4DBE0DAEB7FC1" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Standard Compliance.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF86B2467041088054881E7ED51D3AA2F" Guid="{DC9E4430-E848-4FCB-BDB5-40760F9F986B}"> + <File Id="fil4AD4BCDE7BA1C473CC4B8B6D8041DE57" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Streebog.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp219FFB7AC8A9CAE559B96D663382362F" Guid="{B926CCF9-C3C8-4A62-BED8-C2AF0B7CE1F6}"> + <File Id="fil9772FD94EFCC6A8BC4FE0C976F15653C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\styles.css" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCEA5EA46BBB2A62A8D881B31198C3386" Guid="{999DF0BE-0315-4E9D-99B7-A475AD95B12A}"> + <File Id="fil893681FE743A9EAE666520EE9F91C330" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Supported Operating Systems.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp491B948F4AC657873C77A063196DE773" Guid="{8D0D4082-3C1A-442B-8FCF-215B528AE79B}"> + <File Id="fil665656A640FCE92565333BD4E2254E5D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Supported Systems for System Encryption.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpEE20C9B71CFB2E466F13C6FC9BF04E09" Guid="{F29CA5C6-3F60-456B-8B2F-59E4D98B61D2}"> + <File Id="fil94ACC853FABE497736A2E73C65A6669C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\System Encryption.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp2B15CF0AFC8F3437B3049F59B0EF7601" Guid="{0C1EBA52-CC88-4A22-A707-F231FFB26915}"> + <File Id="fil1AA50714A76A911B470753E3FD5451F9" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\System Favorite Volumes.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp785E1DB76BBDEBFD70EA4BF62650054A" Guid="{49494907-7147-465F-96CA-7BA67E2D3BE0}"> + <File Id="fil0746875D7F30D72D84AE6F83F41B3215" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Technical Details.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp5F637265DB84736905EE09ED2ECC69A6" Guid="{5FF3DAAE-0A13-4602-AED4-344CB6876831}"> + <File Id="fil10E1AD2C9A7D2F295A4DCA9818BA5B3C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Trim Operation.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCBFB249454B517E4B7449B61557EACC9" Guid="{C89253D6-DE56-4052-A7D6-11FA96A9A1BE}"> + <File Id="filCE15EF3AA58605A26EB7AAE54A24FB28" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Troubleshooting.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp81CCD244B1F892AE169DD7F2A41000C5" Guid="{D079F524-A3BE-4689-8A2D-731031B3AABB}"> + <File Id="filAEB2FE1EAE65A54C48CD0ADC3944A226" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\TrueCrypt Support.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp233B1C3979F13771F5C1FD8DFF4D4606" Guid="{16A99EC8-4714-4AAF-A5C9-382A644B2EA3}"> + <File Id="filD07969409DE262F565120CE8C0039DF4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\TrueCrypt Support_truecrypt_mode_gui.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp21805FDD48B222E6357FC4461C6F3102" Guid="{A19DAAB6-54C4-4D43-992B-2FBEF3CBC4CD}"> + <File Id="filE17C724D3B33C0C3E547D99AFF866301" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\twitter_veracrypt.PNG" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp0D80FF102A8D89F5A82D722082F11599" Guid="{5DF42C4E-903A-4738-931D-FDD1CFBB761F}"> + <File Id="fil166CE41AE74FFA92BC4E3646C557F0B2" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Twofish.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp6D7F31C4B7308F5BA7E90B1ADD7038F0" Guid="{14D2850F-3AC3-4140-AF74-A640013A6CB5}"> + <File Id="fil38CE2A927CF9846606D0621A7D6A0FDD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Unencrypted Data in RAM.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7F598B7CD8D0338B1D394D65C681B267" Guid="{C17FBA85-E06C-4B94-9752-18DED3B73621}"> + <File Id="fil17BFC70CA94E4EBC98B25B5C8BD92541" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Uninstalling VeraCrypt.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpD9A9E41D1F43ECC44D1385DAF2D8FB60" Guid="{70C90DB6-D380-4EEE-81EC-F8277951FF95}"> + <File Id="fil969A4AE7B65954FDEC10561CE141BDBF" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Using VeraCrypt Without Administrator Privileges.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp9B9A53A0C6DD95A6630C0210F3BB18E3" Guid="{0B15B80D-CBED-4819-B443-4D8E2993F489}"> + <File Id="fil84C3A46EE20192B924C3D7A490BC1D80" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Background Task.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpB930876C3A86169D30AD296E2E8C8BB5" Guid="{83162AE8-15C0-4CD8-BD2E-7443B1DCF9B6}"> + <File Id="fil6C374CD9BC01F8F027BAB95107ABF7AD" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Hidden Operating System.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp02C9FCDEDD4174BB86092C3FC74686F0" Guid="{BF81515A-3967-4F72-BDAA-E34D98889079}"> + <File Id="fil6AE74A78DE657603388F9429170F121A" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt License.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp851C5E0A0D76AE035089E9529277A1F0" Guid="{6C87B442-D74A-4337-AAB1-967B2C1E05A9}"> + <File Id="fil07431A77C5E9494D4C4B945BB32F65AC" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Memory Protection.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpE6741DB4F8619935F0A2A35131BD3237" Guid="{E2230E40-DF2F-4A1A-8C65-A0F24DC8BB9B}"> + <File Id="fil8024C54A5F73498199A9DD6A357AD5C4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt RAM Encryption.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp661B947BA59FB91045269E4D99CF8CD5" Guid="{FC919CFE-CBDF-4E2F-8D01-1084A209356A}"> + <File Id="filC33A33ED6A2F9A8C3E8E529D88698CD4" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Rescue Disk.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp7FE90DA6D2CB3D2F620DFB67DBE5FBD7" Guid="{89C70FA3-77EB-4376-BF5A-528B616529A0}"> + <File Id="filA87A6F40D58E4DCFDE65BA47AD254E7D" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt System Files.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp03CC22A1DFFB0DB0AE4FBE6BDD0EB1AD" Guid="{0B11D197-21A6-4B9D-9FA8-551891F5BEE1}"> + <File Id="fil5D04F8DF1FECF8D4F4632DDF068F5B46" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Volume Format Specification.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp747C6DC3F1F94C8C379E8894CB58CC1E" Guid="{376A3808-5C87-42B1-B99F-A66EBBAF5AF0}"> + <File Id="fil2F7DDAEFCD182B864F9EF2F68E64FF90" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt Volume.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmp568BC886045DD9FA8CF128F42A72561F" Guid="{EFF6758A-D620-4A1C-A36C-F5F85C5FB513}"> + <File Id="fil944946E61E0A28EDE45AEDF5C637842F" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\VeraCrypt128x128.png" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpF58038EF3D3DCDDB51D498784BD02F0E" Guid="{8D8C09C0-8AD6-461C-9F64-8946CEDAF6A4}"> + <File Id="fil66E62E8A04016A2B6EC83AB990C5D219" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Volume Clones.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpA10ECE6646C3403587F5EA05B65F9E07" Guid="{E55A3BBF-F1DE-451E-9479-1A4987C17F45}"> + <File Id="fil52462FF21FC5B0BD710796D4FF9CA66C" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Wear-Leveling.html" Checksum="yes" DiskId="1" /> + </Component> + <Component Id="cmpCB7AD9B47FC8C557168958B7EC0363D5" Guid="{5FC67C64-1AE4-49E0-8341-438316E349E9}"> + <File Id="fil025AA83D381AD8CED0AB1CA421211A87" KeyPath="yes" Source="$(sys.CURRENTDIR)\docs\html\en\ru\Whirlpool.html" Checksum="yes" DiskId="1" /> + </Component> + </DirectoryRef> + <!-- Refer to Desktop folder in order to install files in it (shortcut) --> <DirectoryRef Id="DesktopFolder"> <!-- Creating an advertised shortcut : enhances resiliency by verifying that all the components in the feature are installed when the shortcut is activated --> <Component Id="VCShortcutDesktop" Guid="C7EBBEFB-8E9C-48D6-8014-2BBA1C7D1957"> <Condition>INSTALLDESKTOPSHORTCUT</Condition> <Shortcut Id="VCDesktopShortcut" Name="VeraCrypt" Description="!(loc.VeraCryptDesc)" Target="[APPLICATIONROOTFOLDER]VeraCrypt.exe" WorkingDirectory="APPLICATIONROOTFOLDER" Icon="VeraCrypt.ico"> </Shortcut> <RemoveFolder Id="CleanupDesktopShortcut" On="uninstall"/> <RegistryValue Root="HKCU" Key="Software\VeraCrypt_MSI" Name="VCDesktopShortcutInstalled" Type="integer" Value="1" KeyPath="yes"/> </Component> </DirectoryRef> <!-- Refer to ApplicationProgramsFolder folder in order to install files in it (shortcut) --> @@ -1244,319 +1864,526 @@ </Feature> <Feature Id="Install_Exe" Absent="disallow" Level="1"> <!-- C:\Program Files\VeraCrypt --> <ComponentRef Id="LICENSEFile" /> <ComponentRef Id="LicenseTxt" /> <ComponentRef Id="NOTICEFile" /> <ComponentRef Id="VeraCrypt_FormatExe" /> <ComponentRef Id="veracryptCat" /> <ComponentRef Id="VeraCryptExe" /> <ComponentRef Id="veracryptInf" /> <ComponentRef Id="veracryptSys" /> <ComponentRef Id="VeraCryptExpanderExe" /> <ComponentRef Id="VeraCryptComRegExe" /> </Feature> <Feature Id="Install_Lang" Absent="disallow" Level="1"> <!-- C:\Program Files\VeraCrypt\Languages --> <ComponentRef Id="cmpF27E43A4E59E04A5B095C5101B229139" /> <ComponentRef Id="cmp4350812363930B900E24C845940DF416" /> <ComponentRef Id="cmp1DD254125CF07901EACECC70930818B0" /> <ComponentRef Id="cmp8C9E97CFD69D3BCB44B84D886720F3FC" /> + <ComponentRef Id="cmp8EEB5407564497843BCFB99ECD7450CD" /> <ComponentRef Id="cmp2BC45D6EC406DDC470E8501442A7AF68" /> <ComponentRef Id="cmp74A0CA1914A6C6FE33D76DE1C01C676D" /> <ComponentRef Id="cmpC186D3472CE1EC872FF1B0CF3682B3B6" /> <ComponentRef Id="cmp2AB0B613D25DDEF3466CBC86BD6B878B" /> <ComponentRef Id="cmpB09224EB45E097BF511CBC5DBE3E251C" /> <ComponentRef Id="cmpF24BBBEB613F893CBC5FBF6533CB48C9" /> <ComponentRef Id="cmp50E1DEF37599D2900447B13FC285B7B7" /> <ComponentRef Id="cmp46E5A0DB48A03A91267C97A664BD9BD4" /> <ComponentRef Id="cmp95BAB91FA0B7E37D5B9343478899CC75" /> <ComponentRef Id="cmpE73E4CCF9F6EC39998B9BE35E43768CC" /> + <ComponentRef Id="cmp8E5262918FDC1B2986951E925B0B9AA5" /> <ComponentRef Id="cmp28EEAA4B2230460BDDA61DEFBC71A905" /> <ComponentRef Id="cmpCFF4CB46421F1A713D45607393ED9B90" /> <ComponentRef Id="cmp31601B4199D0CD3977758A3F2B63CDE7" /> <ComponentRef Id="cmp8E2E0489348A190B00532591CE0AC325" /> <ComponentRef Id="cmpEE57E2901F12294E638E66C39F1B39BB" /> <ComponentRef Id="cmp2F1F644C870AFF8970FE18AF2CD151C4" /> <ComponentRef Id="cmp4B8E0B5A7B7A8BE4267C722B1434E4CF" /> <ComponentRef Id="cmp84BB49D30BDBB4212707D14B7A9C13F1" /> + <ComponentRef Id="cmp6097F5CB407EFCDADFEA02548151AD81" /> <ComponentRef Id="cmp406E3BE632055CDDE1E42F45E31318DC" /> <ComponentRef Id="cmp4E363AF94947A27A4E9CF57C69E6DE54" /> <ComponentRef Id="cmp562F7970AF2F9EF535AC21A84C7229D1" /> <ComponentRef Id="cmp19EF976916B5E207A32BA08C3143A281" /> <ComponentRef Id="cmp4C9B5090256B2E88D27C9CF7E6CFD9EF" /> <ComponentRef Id="cmp91165C08D5943C21F132A349F8CBAAE7" /> <ComponentRef Id="cmp4A51B27F9D8DBBABFE4581EC2B162832" /> <ComponentRef Id="cmp041827E393D8777802256FD480D377FC" /> <ComponentRef Id="cmp68CC2DB5FA70FC1F6CA959FB5E1B78BF" /> <ComponentRef Id="cmpFF128AFA659D8C2E65E0BE55E0943F83" /> <ComponentRef Id="cmp1896040764F0DF6F89280C428013ECE7" /> <ComponentRef Id="cmpA52EAD237A44CBD337E302185BE12FB2" /> <ComponentRef Id="cmpBBB82A6228B54372ACAF9B1310CB2025" /> <ComponentRef Id="cmp4A275EC29DB9B5ECD56CD9C62D358750" /> <ComponentRef Id="cmp8DF0B84F470901D8800F8CAB88A90656" /> <ComponentRef Id="cmp529250BEE557732B5B8CBC47914A0F2A" /> <ComponentRef Id="cmp38274F8F5E4F600A9AC5225A0472D656" /> </Feature> <Feature Id="Install_Help" Absent="disallow" Level="1"> <!-- C:\Program Files\VeraCrypt\docs --> <ComponentRef Id="VCUserGuideChm" /> <!-- C:\Program Files\VeraCrypt\docs\EFI-DCS --> <ComponentRef Id="dcs_tpm_owner_02_pdf" /> <ComponentRef Id="disk_encryption_v1_2_pdf" /> + <!-- C:\Program Files\VeraCrypt\docs\html\en --> <ComponentRef Id="cmp5A2505C1E4CE33EAC578A8D1C8C505D2" /> <ComponentRef Id="cmpE985CD1A96188861286D758A12A1D0A1" /> <ComponentRef Id="cmp310514F655B6D66F5308A5823B0AB691" /> <ComponentRef Id="cmp0664DF8B1FE440C02B1E20D2F23C2CDF" /> <ComponentRef Id="cmp2934E77CB835216789F88BD686160A94" /> <ComponentRef Id="cmp688E76C9A297923D616068E33A6A4F49" /> + <ComponentRef Id="cmpC40B9AEA2BA26327EDBF8EE050CB076B" /> <ComponentRef Id="cmp2ABB10C0A5AC0F1084EDF94E0FDFFD09" /> - <ComponentRef Id="cmp32E7F4F5C0F44D00B53E3946E7E1FCF9" /> + <ComponentRef Id="cmp793A7E676882B650FFCEE4F41B92CB85" /> <ComponentRef Id="cmp989B890D94671F634D04D8F945090F21" /> <ComponentRef Id="cmp109BF0667C5A7B7036CCAAD9B29D9449" /> <ComponentRef Id="cmp82ABD3094B751094F3A49CD338A3713D" /> <ComponentRef Id="cmpE6A18205CB9F847CD7C4375AED2196D5" /> <ComponentRef Id="cmpAA4D61C5E17E2A8513EC120AC9B1DB8A" /> <ComponentRef Id="cmp39251BC13DA4AD6508E18D90D86DF06D" /> <ComponentRef Id="cmpBABB0BD95FD763E9C72D2F51C325CF15" /> <ComponentRef Id="cmp2FE3B3719DCC4362AFF8BF7B4CADFF80" /> <ComponentRef Id="cmp2FC8BD312D06FEC4E244604E27117B62" /> <ComponentRef Id="cmpAE99FB30CC29DF92E71A31EC39E61EF5" /> <ComponentRef Id="cmp535B1A9BACA231F518973D620DC23779" /> <ComponentRef Id="cmpD2ED5F6D8C0A4CA0D26F9F1BB34AB8BA" /> <ComponentRef Id="cmp5F7E0D8587039E1BA0F236F228C163BD" /> <ComponentRef Id="cmpF4DA2D3DABC768C2040A67A993C53E9E" /> <ComponentRef Id="cmpC0AD9100DE0F43E8149F8D3271B02D17" /> <ComponentRef Id="cmp32646E8087D106AE2B62E5DCF2419EDD" /> <ComponentRef Id="cmpB3C777FAF214F7D304EE7CF907D7FF57" /> <ComponentRef Id="cmp338115DF524F0B412A21AB64F59240DD" /> <ComponentRef Id="cmp2F24E0C7B7175D60257F6D01231C8373" /> <ComponentRef Id="cmpAE9D52ADD94D3A2711AA79FA0C91CA00" /> <ComponentRef Id="cmp0A6270FD26128E8D1CC83E392E91A772" /> <ComponentRef Id="cmpEDB0E152195A7EB91BBB28631B689E0B" /> <ComponentRef Id="cmpFD76EB6B5546D1C38CC33FABA95FAA15" /> <ComponentRef Id="cmpDC4FD19F507A5152351B9F71C8691486" /> <ComponentRef Id="cmp9E45BE754042F9DD742A0B7B9F27E786" /> <ComponentRef Id="cmpB6AC414023A6BDBF855F4A807DAE138C" /> <ComponentRef Id="cmpA80F47C0DB1649FE99DA7D449012D2D7" /> <ComponentRef Id="cmp053692809BD5B3F5682AFCC539A767A3" /> <ComponentRef Id="cmp9049A791E9E1AB7FF01BD7F08D1CB069" /> <ComponentRef Id="cmp4E6F9484484A40645D519F688ED9C21E" /> <ComponentRef Id="cmp3CF724F2A2347A2A30C85CB76490F687" /> <ComponentRef Id="cmp3858A4BB7577362DE87F4485575DFC99" /> <ComponentRef Id="cmpA06B9542AEB64F96BB784F47800158A8" /> <ComponentRef Id="cmpACD4069DDF564A8DAB5D542BB8850131" /> - <ComponentRef Id="cmp735FE6B2F10C43019E11256864209EBC" /> - <ComponentRef Id="cmp89BB363FF83EBA271361A4208E069DA9" /> - <ComponentRef Id="cmp5115B3C02C1C0CF975E4B7C3152C163A" /> - <ComponentRef Id="cmp3E70583F999D652B21E6E2D526666F61" /> - <ComponentRef Id="cmpC2D0D30677874908C48FF8A921712958" /> - <ComponentRef Id="cmp88EB50D9762FA92B2E52313A7C92F2DD" /> - <ComponentRef Id="cmp3DABA5B6F2E779D915E1B8D680AE7855" /> - <ComponentRef Id="cmp2EA15F417E5EE9D31E028263C137695F" /> - <ComponentRef Id="cmp51D438A1152A65EAD414012A5EAEA2CA" /> - <ComponentRef Id="cmpD52CCEF7A4A330F26D3B3F7355D03646" /> - <ComponentRef Id="cmp1A9BFDDFF15FF47166075F319B97BB6E" /> - <ComponentRef Id="cmp320762048B274197D27F739096C4A23A" /> - <ComponentRef Id="cmp952051BDCF309CAEB1D62701560D8F78" /> - <ComponentRef Id="cmp6AB232B7503BC35E25CB33C789242482" /> - <ComponentRef Id="cmpE8ABDCD58C9636346FAE7E941A38CA6E" /> - <ComponentRef Id="cmp9CD73EB218D7148E55F141E31AEC9D8C" /> - <ComponentRef Id="cmpE504F295E3ED5CEBDCF231608F6757B2" /> - <ComponentRef Id="cmp84A8D3A9BF75ED8047B7DEAB02F26003" /> - <ComponentRef Id="cmp63A4BE623C0E3F77B3BFA5B467C33A1A" /> - <ComponentRef Id="cmp63CE6B664C7396B79B1B28591EEC72B9" /> - <ComponentRef Id="cmp4D6100E03DC3B05F17A7E2BA4AAF1EA1" /> - <ComponentRef Id="cmpB7641BE40D4D1642AB3647B669008A94" /> - <ComponentRef Id="cmp4DB96DA8172D79B63A7FBE08E016A280" /> - <ComponentRef Id="cmp615D3647A56F3ED6F0766CEEE9EFCF9F" /> <ComponentRef Id="cmp9FDD7E3C06564AF29700B82B19BC0501" /> <ComponentRef Id="cmp90AB4CF273108F47223E3432838CDE37" /> <ComponentRef Id="cmpB9A0461BF7CF75538111B088C986A62F" /> + <ComponentRef Id="cmp33C4617DBE37ED14B978BC4770F0C3F8" /> <ComponentRef Id="cmpD8C7B52BC03709FAB2642B93BFE4FFE8" /> <ComponentRef Id="cmpFD6EB163EA6B74C4F59FF04D2B3796CC" /> <ComponentRef Id="cmp612D2E75E857D164665BE8CA37570D04" /> <ComponentRef Id="cmpF65BF759DA7F65BAD6D74A83FEF9D205" /> <ComponentRef Id="cmpA6A249B42C89657DE664B9D88D04DB3F" /> <ComponentRef Id="cmpEE8A03DA56EF1B35979430E8711A6960" /> <ComponentRef Id="cmp628E75C5DD0F38348B6F8694D5D5149C" /> <ComponentRef Id="cmp40BDD4F3CA20DEE006E087930EF3847C" /> <ComponentRef Id="cmp7AEEABAF151FCE92735664A55F7B8FFA" /> <ComponentRef Id="cmp9380DDE2560B4D8EE9CC363AF4BC7B5F" /> <ComponentRef Id="cmp84A94F04CD486338F57C03B316145945" /> <ComponentRef Id="cmpDF544847A4B1F86B3BA3468336CD73FE" /> <ComponentRef Id="cmp9A6A861B59A23E534C7407EF95500AA5" /> <ComponentRef Id="cmp09C34B1CBDE9F2F4E897340B1C67728E" /> <ComponentRef Id="cmpD3183A7373751A19B4B7C9B041F9035D" /> <ComponentRef Id="cmp3DED9073AB120DC026C48E9CDF9283EB" /> <ComponentRef Id="cmp0FF3027C2662D967ACB4B01BA7BC85F9" /> <ComponentRef Id="cmp3FC9C0126A2074CAABCF73197358F824" /> <ComponentRef Id="cmp1830E220882FBA276350032258B478AA" /> + <ComponentRef Id="cmp433CCCF103F2A8AF57F9FC528232C836" /> <ComponentRef Id="cmpE5D6E9DF3EE1301C6D5A4F44362BCE96" /> <ComponentRef Id="cmpB7B429D414CF1DD05A4B70CE94E343F7" /> <ComponentRef Id="cmp00845B9781D5633702C834BCB4EB93D1" /> <ComponentRef Id="cmp47F92D029E335F7865F8ACB30763FED2" /> <ComponentRef Id="cmpF3B90B0C1F316854E9142B22783ACF19" /> + <ComponentRef Id="cmpBD37FB188B29DB82A15EBC9C1DB66F94" /> <ComponentRef Id="cmp2EC17F48BC15C5405D2DB40FC6E01745" /> <ComponentRef Id="cmpE00F8980768E14DF59474B5CB3D84041" /> <ComponentRef Id="cmpD17B73F5892E45458E960025558B3452" /> <ComponentRef Id="cmpF45A8248FAFA80A8DF62989C477E7C0F" /> <ComponentRef Id="cmpD066CBBD66E8CABB4AD4B928F823A5D2" /> <ComponentRef Id="cmpACFE3B967BB844C3FD0FE21C9E87EE5B" /> <ComponentRef Id="cmpFAA171DECE81EA4EA99B5570C9FF7D0E" /> <ComponentRef Id="cmp7C1E782A2C12520E4CACF0D8FD4EAA4E" /> <ComponentRef Id="cmpE9009D51D7CF4AA8BBA735E91F1D6044" /> <ComponentRef Id="cmp5D46BFDD0D54DD715695756148C22028" /> <ComponentRef Id="cmpE34BBB4D255F23D71B0143270915E6D7" /> <ComponentRef Id="cmpEB665F1BFDB30B20C90142CCD1DA7664" /> <ComponentRef Id="cmpFDCC994071E7ADACE3EB2CBACC60E34A" /> <ComponentRef Id="cmp21A3A9B1C7FAA004EF937114F0F41C61" /> <ComponentRef Id="cmpFD4A149B4654FEF0542A5ECE211A86B8" /> <ComponentRef Id="cmpE7CDDDCDA7CD20F1150F2879E0293D1D" /> <ComponentRef Id="cmp9CDBE7ACC2D5393535D2981C3DD73682" /> <ComponentRef Id="cmpF09EAA16502FCF137AAD38D70D50B200" /> <ComponentRef Id="cmp62D4B7B5DACB58D3EEA9E6D3385769A7" /> <ComponentRef Id="cmpBF36D06FA293DFD3AFA1543C43A54E17" /> <ComponentRef Id="cmp7345D3EE0CFEA227E8AA9ADADF95E623" /> <ComponentRef Id="cmpE92C5D4B774B7214B49931528F7EDCF6" /> <ComponentRef Id="cmpB6A3927A1BE4D2836C1007D3CC989C4B" /> <ComponentRef Id="cmp28666EA10A3DCEC7D2583ADD52785FDC" /> <ComponentRef Id="cmp08768A6308C114126260614CCDF6F72E" /> <ComponentRef Id="cmpF00E284DEEE43B341D12987E20DB76C5" /> <ComponentRef Id="cmpB75BD74E0F63097DC1777FF4BF440479" /> <ComponentRef Id="cmp1745256A6ECE8FB1779B0DA82CEECAB9" /> <ComponentRef Id="cmp3F248F4BDDB12D98D3CF173FEA01CE24" /> <ComponentRef Id="cmp1209E63998A1D1504B062C4ECC45EE07" /> <ComponentRef Id="cmp035C544DF9B46B9DD7871AD7898B7D36" /> <ComponentRef Id="cmpA891AF32EF72B7AC80533FC31773B604" /> <ComponentRef Id="cmp1FC684D1C3742A927228DE9A669A2895" /> <ComponentRef Id="cmp265116FC4778248E01BADFB30A2C32A7" /> <ComponentRef Id="cmpB2A3FFEE7A15E23A2835A843438E3669" /> <ComponentRef Id="cmpFC8FB415783E0AA424FBD685EFACF54E" /> <ComponentRef Id="cmp2BCEA21755E1C812ACCF15A09210FCCD" /> <ComponentRef Id="cmp9EC1750F7CD9717D3A761FC2930C509D" /> <ComponentRef Id="cmp4298A84BD6956E2A2742B5678BCFF173" /> <ComponentRef Id="cmp2D9F7D88EF1F843BDEA5A39D13330B8A" /> <ComponentRef Id="cmp58EAECCB29CB9ABDDDB72F9378E4EE77" /> <ComponentRef Id="cmp61C660976A230AD4AD8B42A90D4BCC7C" /> <ComponentRef Id="cmp29A0605ED3FB7D4E2EAC833D56411563" /> <ComponentRef Id="cmp4A0EF1CFD1E1DE8B4E7BF698E05680E9" /> <ComponentRef Id="cmp1E4F8137AD337BEA1B902E6B003AB953" /> <ComponentRef Id="cmp8D35F7D61B2B7DF0EDEAE2E56031E7CB" /> <ComponentRef Id="cmpDE2C66707086A509EABD0F9F6E8BDB1A" /> <ComponentRef Id="cmpA80443C3767E3E51F3DE88BFD0D7A33B" /> <ComponentRef Id="cmp214446AAABEBAC0C3827B8977083FAE2" /> <ComponentRef Id="cmp4AF022868FE6883520C700676C43B15D" /> + <ComponentRef Id="cmp340BBEC25292C3BE778BA8F158DB87B1" /> <ComponentRef Id="cmpC27AA2C4496C9EFA95DCD663B031B5D0" /> <ComponentRef Id="cmp9CBBC8311BBFC54C8DC1162BB17E5AED" /> <ComponentRef Id="cmp033461B0777614621A2ED7B4E2B08D55" /> <ComponentRef Id="cmp0E43CDBBAE343957423AE2907AC16883" /> <ComponentRef Id="cmp8A8526D2061A14810E1B7A8A6E527DCD" /> <ComponentRef Id="cmpAE2DADEF126C59D8CCD3A18D8CDC49C8" /> <ComponentRef Id="cmp2F972A5C99F7EE708B7C232EE8647672" /> <ComponentRef Id="cmpB21F7D781FE7B006ABCA7974A21F29E2" /> <ComponentRef Id="cmpF345174585735CD7A31AE138DDE8B439" /> <ComponentRef Id="cmp06772C03A0ECA40F11F1D5C5ACD607D8" /> <ComponentRef Id="cmp79E890B8891FA87AA5B10A67E15E7E8E" /> <ComponentRef Id="cmp89C46AE8EC4175E62A9CFE3DF9DF924A" /> <ComponentRef Id="cmpC8F860B10D41961424874F69C6D84ED3" /> <ComponentRef Id="cmp285021B8CBC8E92B1CBCE4C88731083C" /> <ComponentRef Id="cmpABE9B0A93A9B14C0732EBD8CD17A11AE" /> <ComponentRef Id="cmpD9B960879A3227B971E33222CE13BC18" /> <ComponentRef Id="cmp3B3BB414D13FDBF2B0C7A9CEBD7D98F5" /> <ComponentRef Id="cmpB39B1096387C2617720F515D24953B37" /> <ComponentRef Id="cmp493A37205039E2A3A476A1A4F5360EBF" /> <ComponentRef Id="cmpF36A771DF9B1C4CD8E82C08A6D3D0786" /> <ComponentRef Id="cmp63F6A68C5538B45661168554BC3B93D1" /> <ComponentRef Id="cmp0158A6D8BED6391AC7150B6C6AE2A9F9" /> <ComponentRef Id="cmpDE45667E9E3CD9F800EAC1E02B57AAB7" /> <ComponentRef Id="cmp632453049391BAACDD117A40EC442743" /> <ComponentRef Id="cmpCE16E453CAD75A461B4FEBF451A51B7B" /> <ComponentRef Id="cmpC741D187A28A87BD33866C9AC09A1298" /> <ComponentRef Id="cmpB313B00E647A121B2CBE47F3048A18A7" /> <ComponentRef Id="cmp400428F6494DE58618E3B92539548C39" /> <ComponentRef Id="cmpFB2313AB16EF2467366ED136C0E61CE6" /> <ComponentRef Id="cmpB4C7B1A7A3EC0CB2DE805AC5CC5FC0D7" /> <ComponentRef Id="cmp00540BF93A805E0B9996945B61E1BC2F" /> <ComponentRef Id="cmp4C46C6668AD830D543AFE593D51676B3" /> <ComponentRef Id="cmp6EE914124966E3A0F695359116413DD4" /> <ComponentRef Id="cmp28E29B4CA17AB51913B756CD9397EEFE" /> <ComponentRef Id="cmp5DF24509F284FABC600232197F803DE5" /> <ComponentRef Id="cmp09E31B885345FBEA1F473AF7A10FD88D" /> <ComponentRef Id="cmpAE05C79A35A43ECCAC995A711DC4D60B" /> <ComponentRef Id="cmpB6D91209A93313D08150643F1738DED8" /> <ComponentRef Id="cmpDB66E821EC13977824FB1069DF5DAA69" /> <ComponentRef Id="cmp159AB26E32632FC87229090B3AA89BF8" /> <ComponentRef Id="cmp5BE3E12343551B853E1B143371CBEBE6" /> <ComponentRef Id="cmp0E081D9499DA225BB788494A1D86893D" /> <ComponentRef Id="cmpBC7134AF21BAE309E9FD1A52ADF92527" /> <ComponentRef Id="cmpB586F01E9F9657C498F2AB64E1F51BD7" /> <ComponentRef Id="cmp6EB049078039C276CADA69E7B79FDFA8" /> <ComponentRef Id="cmp3135BB68A1F44DDD9FE19B7D5FB4ED7B" /> <ComponentRef Id="cmp98ECAD990DF7B535B05EF6E840B7B2DF" /> <ComponentRef Id="cmpFE417CCCB859A1C3E4FB90A9C4E132F0" /> <ComponentRef Id="cmpD91C00B1B2AACF38761B45D0574884D7" /> <ComponentRef Id="cmp590EDE3CE6E09D0D43B35287E849B75A" /> <ComponentRef Id="cmp9D6F95F912C3B9C95E92E39BA1CE6BC9" /> <ComponentRef Id="cmpAD429D8A050A0D31B661626BDCA9C952" /> <ComponentRef Id="cmp3BDE199844AB81673ABB0E5E61E9B7B5" /> <ComponentRef Id="cmp0A4AB9AEF0D351FA5E63BCD67DC00607" /> <ComponentRef Id="cmpCC25F1CB6A1C9D8B47C407B818F73B59" /> <ComponentRef Id="cmpE0F5E8A2D6FEF181686370F0E1EAC632" /> <ComponentRef Id="cmp46B2E8BCD50BD668153E793EB737BC39" /> <ComponentRef Id="cmp0305CC2824E44F697B402E56A0CD1754" /> + <ComponentRef Id="cmp9DD3085A37E22E035A65C74A5B9C209E" /> + <ComponentRef Id="cmp1FFF1F3DF3F162C4AEDA7871C7886618" /> <ComponentRef Id="cmp0E00CBDCB82A904FD6AD82E458CA6AA7" /> <ComponentRef Id="cmp594B5E68E63675F4986F6717BC1F5950" /> <ComponentRef Id="cmp62748E79EC04EBE33DC46770AD65CDCE" /> <ComponentRef Id="cmpE1265CF3CC5E0B487E99D9D5936BB3F4" /> <ComponentRef Id="cmp1C162513D52824629D7C9FAF96054182" /> <ComponentRef Id="cmpB5FA2A488D2C7E59E0B52D18820CE00A" /> <ComponentRef Id="cmpBB1A4A1EB3FBBE5B2BF2752C302CDC2D" /> <ComponentRef Id="cmp9D908DF026E6297D51B6C4A6700092F1" /> + <!-- C:\Program Files\VeraCrypt\docs\html\en\CompilingGuidelineWin --> + <ComponentRef Id="cmpD07393B381E6260DBC0496E0A2B3FDA3" /> + <ComponentRef Id="cmp1731A59A75547D8FA04524DDC7AD2988" /> + <ComponentRef Id="cmp7FFBD1C115BC0813B91129B4078705CF" /> + <ComponentRef Id="cmpD7F278D2B4ABBD3373A66252A80FF41C" /> + <ComponentRef Id="cmpA3CA3666C6CCD54031801DA1FF7D7AF3" /> + <ComponentRef Id="cmpE90376C911384CD5AE71D0E60076C55E" /> + <ComponentRef Id="cmp2F53ACA5C5C155121B87F5D6E8A68D40" /> + <ComponentRef Id="cmp843B9A72B11653FC613E6888545A2914" /> + <ComponentRef Id="cmp5AF6BA98113B1A6C1B9EB20C78BA4ABF" /> + <ComponentRef Id="cmpB235C44A240AB4854F159B87373D335B" /> + <ComponentRef Id="cmp6F71C2116891CBBDE64C81A41B85C674" /> + <ComponentRef Id="cmp9DEEBC6C9B984AFFF4F946DBE6084FB3" /> + <ComponentRef Id="cmpD474D105652697A5807E9CBF4B0A0AD0" /> + <ComponentRef Id="cmp451C53B55201540C7B07BBE0A73A6F69" /> + <ComponentRef Id="cmp75EA034E68DFB3C765DBA38C1EBEA351" /> + <ComponentRef Id="cmp5691E0C2C85E2E1EDE1E41214E222640" /> + <ComponentRef Id="cmp2C05B384BC73DF32992E4B57F3F48AF5" /> + <ComponentRef Id="cmp4B12B4AD977CC6FE0C361B0C98C6A236" /> + <ComponentRef Id="cmp41B2B2449677DAA52A41DC7795E8C33B" /> + <ComponentRef Id="cmp22F9BF579449876818B8F5773E181345" /> + <ComponentRef Id="cmp82302DD1E595AFE99785A70427299C19" /> + <ComponentRef Id="cmp18D83E4B99481D3D79B9D2F79E287226" /> + <ComponentRef Id="cmp2BDF1EA1DD0D9D8D7E67AF7BA1FB0822" /> + <ComponentRef Id="cmp817AF448E496E79AE0E03C16657AE14E" /> + + <!-- C:\Program Files\VeraCrypt\docs\html\en\ru --> + <ComponentRef Id="cmp98E10412F1F15FEA92DA14D5D072CC76" /> + <ComponentRef Id="cmpA1262CC2F2086CCA8E3EE8DDA77FF086" /> + <ComponentRef Id="cmp2DDBA3B10DB23CB1F8EA928B46CCA181" /> + <ComponentRef Id="cmp0020DEB1B692BF8C113BCDD9C35CFDAE" /> + <ComponentRef Id="cmp2ED752BBF695DA0426DC658681B0246F" /> + <ComponentRef Id="cmpC2831D4EDB2C6161E9AFFA4E118B4690" /> + <ComponentRef Id="cmpC8A17F149AF21481048D7258418DBDA4" /> + <ComponentRef Id="cmp9D4113D4E0B7F3BA260B8B2B533E299C" /> + <ComponentRef Id="cmp84EEBEA4353C6BB7FAFBC651A3044D91" /> + <ComponentRef Id="cmpE3AD138F57F6B7D59BEA109296613C6A" /> + <ComponentRef Id="cmp9C042008F4284C90B114419C6CAEF43C" /> + <ComponentRef Id="cmp776BD71B225596C1F5DDCBAFBEDC3D8A" /> + <ComponentRef Id="cmp71F37A3E4D3EAAE76DDD223623EFEFF3" /> + <ComponentRef Id="cmp7B45DBB2FDDDBAAE80C9BED8518D5162" /> + <ComponentRef Id="cmp11BA4D17FE816D5B509E1340905776C1" /> + <ComponentRef Id="cmp030C129762387E5309D0ECB8DAF65212" /> + <ComponentRef Id="cmpAC9DB62D88BBBAE847557DB06BD10C23" /> + <ComponentRef Id="cmp4A6D2989B95765B61974E1E22E2ACF78" /> + <ComponentRef Id="cmpD359378B1A7405FAF65C49BE76F981C5" /> + <ComponentRef Id="cmp70D8557BE97B70FD9EECAAA0EF5CD03D" /> + <ComponentRef Id="cmpDEBA4E7882793204DA1CC9999C05F964" /> + <ComponentRef Id="cmpF516F4196B3085018BC093FCBCB58A4C" /> + <ComponentRef Id="cmpAC8162634F24C0C33B2E3C6864DA4A2A" /> + <ComponentRef Id="cmpB081741BBB46FA24327C9DB71A7B02B8" /> + <ComponentRef Id="cmpD4723B9A6D4909DFC0E1B4B4EE660C09" /> + <ComponentRef Id="cmp39E9D88B683EA4F12640DA0A65DE3549" /> + <ComponentRef Id="cmp0F2F30410D88E2533026D3C3E4744E34" /> + <ComponentRef Id="cmpB5D683C358B00897FA9F0FF22F315D7B" /> + <ComponentRef Id="cmpD3CD0A2A3035277B8D5C83DDD56EEC09" /> + <ComponentRef Id="cmpFAF93B91B7847306F97A8F13C9237BBF" /> + <ComponentRef Id="cmp110F96A11106F1AC7DD0DB03480BC3AD" /> + <ComponentRef Id="cmpD14CBD246BD84D409AC5C9435CB93C69" /> + <ComponentRef Id="cmp338A05D33900D38A2218604CA622D528" /> + <ComponentRef Id="cmp6AE588318312858B13C37DBB81243BB4" /> + <ComponentRef Id="cmp40450814BCB759314CC3FDE6C648C0C4" /> + <ComponentRef Id="cmp8D0D5C8F66B9E9213FACEB65D779E93B" /> + <ComponentRef Id="cmp1969CFCA4E8E6853AB60C3E5E84EC96C" /> + <ComponentRef Id="cmp0BF1FE522880BBDA428837E3B646DA5D" /> + <ComponentRef Id="cmp2ADCCFAA99C96B7E74D50F58AA2DDAFA" /> + <ComponentRef Id="cmp0E448FAC0CED589DD138E162986FC0DE" /> + <ComponentRef Id="cmp06C8D9A3457DEA62A19ACB286B2E32EF" /> + <ComponentRef Id="cmp7447D492A3894509DC750B48E7DCF613" /> + <ComponentRef Id="cmp5C2B87E203BB5FCA4F77B19D3E6BA307" /> + <ComponentRef Id="cmpA5748D4E937680A92DBAE78CE5B2F28C" /> + <ComponentRef Id="cmp6FAAD943919CED1962892A80342F6791" /> + <ComponentRef Id="cmp948EA396F48A342F4EF23F2210CB5B4F" /> + <ComponentRef Id="cmp29F827B72EB9BA3A4BBF4135346BFB3F" /> + <ComponentRef Id="cmpA6461FAA6FF2B690A1950611770B4238" /> + <ComponentRef Id="cmpA386DE1E79E889FA61290114537BDEE3" /> + <ComponentRef Id="cmpF78CD517DB1E24484B5CC82B2DDD5E9C" /> + <ComponentRef Id="cmpBA0D70B7A50226DCD8144689A79ABDCA" /> + <ComponentRef Id="cmp589D4976F5CF94C27910A8F4EBF29FD5" /> + <ComponentRef Id="cmpDEF5E40C0360414577A9FB6E9D209C31" /> + <ComponentRef Id="cmpC0FF4C2C070C62B0E55BA14B329A58FD" /> + <ComponentRef Id="cmp5F3D5E0970DA4DCB5655AEC4AD1C94C5" /> + <ComponentRef Id="cmp14BBB28777FE8A9914F4BB38B50C0311" /> + <ComponentRef Id="cmp10C79CC28991F4E8A3E33C66D7280D88" /> + <ComponentRef Id="cmp7E0AF9A50799D06DE12C94A60C834F5D" /> + <ComponentRef Id="cmpC547B50DD1AB37E959FB18D1AFD9C051" /> + <ComponentRef Id="cmp716240038B6F46034428E43768E32CA7" /> + <ComponentRef Id="cmpEF2FE09A2E8F60EB28ECBA7BEE5E9026" /> + <ComponentRef Id="cmp4DE7E89729EE1EE9EEA042F80B412D3D" /> + <ComponentRef Id="cmpBC866AF7B9269946668A324AD39D08A7" /> + <ComponentRef Id="cmp59C951F15FE54CBB5EF2528D4AA6F73C" /> + <ComponentRef Id="cmp1BCCBDD405E75313F3B3CE6EE8DA86B5" /> + <ComponentRef Id="cmp3E991C4739DF1DE5475ECE135EE98D0E" /> + <ComponentRef Id="cmpF6A11C5F07AADC2DF98D1549024AA5D8" /> + <ComponentRef Id="cmp92387146C4EDCAC1653A2FDD573D2695" /> + <ComponentRef Id="cmpAD29968DFA6888826A5718FF6533D96B" /> + <ComponentRef Id="cmpECD5EF9F2075A8512411DC0C4A5249D0" /> + <ComponentRef Id="cmpCB8D27F16124CAAC7244A48FFA4AFB7D" /> + <ComponentRef Id="cmpC65A16FF1BC895E90BBB53B78E68DFD9" /> + <ComponentRef Id="cmp87F512AEE17E1578EAAE94230A2D42F8" /> + <ComponentRef Id="cmp97920FB49AE81562FA7ABFFA9A5DE439" /> + <ComponentRef Id="cmpC57C3FF497FC91DB80B6398E7FEE7A64" /> + <ComponentRef Id="cmpACDA6D0F0078725DD4A8708187C76CD3" /> + <ComponentRef Id="cmpCEB5D33CBF8513543D361078523B750C" /> + <ComponentRef Id="cmp5FC13AB774FAACB290717853ADC20FCD" /> + <ComponentRef Id="cmp725B9ABA14E65E9EFE49157CA4FC128B" /> + <ComponentRef Id="cmpBD55DC12534E09C8553C28F5B5C0FA4E" /> + <ComponentRef Id="cmp7C45FE83120EA12DB05FC171A06B30AE" /> + <ComponentRef Id="cmpA76542EBEEBAFF2C7A5BF5AB2741D4FE" /> + <ComponentRef Id="cmp9B9F529CBDC007E9FA5CF79E8867DA67" /> + <ComponentRef Id="cmp87244E466A2EB7ABF13AA619B977BF78" /> + <ComponentRef Id="cmp712EA51FB151C694292EA58C5A578BA6" /> + <ComponentRef Id="cmp870CD5E9E23CF6C9067DEADE20C9FC35" /> + <ComponentRef Id="cmpB006A7FF853B4EBD76D04C32E9455C4B" /> + <ComponentRef Id="cmp472CDC24D7DCA0786CBD55DD01B3C326" /> + <ComponentRef Id="cmp89C6FF5C5AC2CD9880C5409B5AB83825" /> + <ComponentRef Id="cmp6C831E6A491B7EB59D88781A5BFE9F15" /> + <ComponentRef Id="cmp60679C4F1990149DFE8EBD00D7C156DA" /> + <ComponentRef Id="cmp6382DF988EB9E433728A02875F366B29" /> + <ComponentRef Id="cmp6ED341130E7BC5619B617E61C4DB60A8" /> + <ComponentRef Id="cmp216B8D95DCCC0DBA860DA22728386441" /> + <ComponentRef Id="cmpE4595A43F5FE7BD7D162F3652BA6C266" /> + <ComponentRef Id="cmp7D5BE6FDEA3DE19095769A66D0AE29A8" /> + <ComponentRef Id="cmp61565372125F227105B9AE44241F1967" /> + <ComponentRef Id="cmpBC1662DFA34FC9A8F203FDC51697C8A5" /> + <ComponentRef Id="cmp5EF5D5F4FEB4B57BF58C3046BAD8A1E1" /> + <ComponentRef Id="cmpE9488D44ACC744E76E072585F84C491B" /> + <ComponentRef Id="cmp4228F912DE70A8E8A341A3B3EB232186" /> + <ComponentRef Id="cmp661A873DCAADCA5D6DE5658C1AF6238D" /> + <ComponentRef Id="cmpF8C6E0267E7995D280B8E7F4172C7F18" /> + <ComponentRef Id="cmp6004A52073268319FB67C09279279ACD" /> + <ComponentRef Id="cmpEEC16C2DA6C942B7F814FE2ECE9AAF65" /> + <ComponentRef Id="cmpA116A7CF851D562952FD8F362EF4F15E" /> + <ComponentRef Id="cmpAA28C1518620F4CA7377132D083B5E31" /> + <ComponentRef Id="cmpC384B9F228D8242650A1A48FDE46FADB" /> + <ComponentRef Id="cmpD858F6459F1D5BE26754F7B9A6B256FB" /> + <ComponentRef Id="cmpD935A23E00BC5621253BAF554A60C48A" /> + <ComponentRef Id="cmpCA290469DDC2BF237F81DDD5B1767EED" /> + <ComponentRef Id="cmp72EE25B25C5C68F03DF9176C2D3F8BDD" /> + <ComponentRef Id="cmp29F705976D3FE416CA69F9A85F81E453" /> + <ComponentRef Id="cmp3092B4A3F28D76A5F41FB2DC967976BF" /> + <ComponentRef Id="cmp05C4713E55D9E8032EF515CC96771B98" /> + <ComponentRef Id="cmpD979C33BE6277C13010EF93D9FB338C8" /> + <ComponentRef Id="cmpBDF94D6F72E05F0E90815BA6CA48AEAA" /> + <ComponentRef Id="cmp5F801DCC01F26894D68A6EA08E45B76B" /> + <ComponentRef Id="cmp1F82E220BB2635E789DB76D708745EDD" /> + <ComponentRef Id="cmp9FEF6DBD25CA9AFF6103A75B72D304B2" /> + <ComponentRef Id="cmp1710916CD3A94FB29C9213789A147AE0" /> + <ComponentRef Id="cmpAA303E0AEBC0E1EB8C2472B1ED65324A" /> + <ComponentRef Id="cmpACAD2B0C89247F272E42D86D48ED6ECC" /> + <ComponentRef Id="cmp4BC713FA989ECC8EC884548781C4F29D" /> + <ComponentRef Id="cmp2CF52C3BBF31CCD0752A49C11FF294A7" /> + <ComponentRef Id="cmpE60FAB408B216C9ED62A362BC7EE475D" /> + <ComponentRef Id="cmpAB7AC6D28286103D7E729673FEDFCD5C" /> + <ComponentRef Id="cmp3E980DF980C84895107EA078801D25F6" /> + <ComponentRef Id="cmpC84F22C32C2455E14F0833097B100309" /> + <ComponentRef Id="cmp13BEB53EDC29960F3AD13DEEAB9C92C1" /> + <ComponentRef Id="cmp6DA588A2041707855690C560C64C438D" /> + <ComponentRef Id="cmpB03F168BA9DD4275F206E53CED02A12A" /> + <ComponentRef Id="cmp673ABA162209C25819DE3CACF4E612D4" /> + <ComponentRef Id="cmp2198CDB3A37522808F3C0FE67FEE31BF" /> + <ComponentRef Id="cmp6CEA0C62D82A3B53499C2D4EF2C3B5F0" /> + <ComponentRef Id="cmp7FBF805189D05F4E3E1197B6024D6583" /> + <ComponentRef Id="cmp37C51862BC6949DB6195DC1A9FC37855" /> + <ComponentRef Id="cmpB12223A6EEF742CCFB738D9C8B708ED9" /> + <ComponentRef Id="cmpF4B2DDF581FADDF14E3613D517675CE0" /> + <ComponentRef Id="cmpBCCD12E77FAEA515D6C1555B7823E169" /> + <ComponentRef Id="cmp32627BA5A52D1C2FD2648C6907F4A00E" /> + <ComponentRef Id="cmp7A44CB40DFC859E66D7CC2582EF9948D" /> + <ComponentRef Id="cmpE819E5D393DD7BCB4D1C101FFFE6FB0E" /> + <ComponentRef Id="cmpA29ACAD11D850472C56137504F770B8F" /> + <ComponentRef Id="cmpA2581CD77714E8D6C2A4DAA258590E29" /> + <ComponentRef Id="cmp3F6C602C80B5711DE3EDD2FE8EAFD00C" /> + <ComponentRef Id="cmp30C5A7CA791767CAD2E9E124826EE047" /> + <ComponentRef Id="cmp770DEAD9D0C6D2439CA86800A5709567" /> + <ComponentRef Id="cmpF8CB44545962DB01EC6DD9DFADA36FEF" /> + <ComponentRef Id="cmp8468AE251FAE8743371ADE14FEA935F7" /> + <ComponentRef Id="cmpD2BCE21F32CF98AF542769B408047D4E" /> + <ComponentRef Id="cmpA1B275EE180C48643BFF410ED187E170" /> + <ComponentRef Id="cmp2458A9EEA35AAC6F7AA66C71F2C8E500" /> + <ComponentRef Id="cmp725AEB3BD6705908D3DDDC49D446EEDA" /> + <ComponentRef Id="cmp84C361E84DB09C711566B58D9822B3A4" /> + <ComponentRef Id="cmpEAC38538AB52AD68B5B36DEBE9310DDE" /> + <ComponentRef Id="cmp7B700E12FA433825A9ED08182F8CF6A6" /> + <ComponentRef Id="cmp8548A76FB3F15F37E8690D54D9E37153" /> + <ComponentRef Id="cmp84AFAC0919E0FDAB5B0C943837BB10FB" /> + <ComponentRef Id="cmp7E863093EB77CAFCE23926751F601D06" /> + <ComponentRef Id="cmp88CC92142E3E491F76F7BE7582508F44" /> + <ComponentRef Id="cmpA65F33B67588CC31BC7CAE2E2C651CB6" /> + <ComponentRef Id="cmp78D7D716B5B1FE70B04CF6A10B38E34F" /> + <ComponentRef Id="cmpF86B2467041088054881E7ED51D3AA2F" /> + <ComponentRef Id="cmp219FFB7AC8A9CAE559B96D663382362F" /> + <ComponentRef Id="cmpCEA5EA46BBB2A62A8D881B31198C3386" /> + <ComponentRef Id="cmp491B948F4AC657873C77A063196DE773" /> + <ComponentRef Id="cmpEE20C9B71CFB2E466F13C6FC9BF04E09" /> + <ComponentRef Id="cmp2B15CF0AFC8F3437B3049F59B0EF7601" /> + <ComponentRef Id="cmp785E1DB76BBDEBFD70EA4BF62650054A" /> + <ComponentRef Id="cmp5F637265DB84736905EE09ED2ECC69A6" /> + <ComponentRef Id="cmpCBFB249454B517E4B7449B61557EACC9" /> + <ComponentRef Id="cmp81CCD244B1F892AE169DD7F2A41000C5" /> + <ComponentRef Id="cmp233B1C3979F13771F5C1FD8DFF4D4606" /> + <ComponentRef Id="cmp21805FDD48B222E6357FC4461C6F3102" /> + <ComponentRef Id="cmp0D80FF102A8D89F5A82D722082F11599" /> + <ComponentRef Id="cmp6D7F31C4B7308F5BA7E90B1ADD7038F0" /> + <ComponentRef Id="cmp7F598B7CD8D0338B1D394D65C681B267" /> + <ComponentRef Id="cmpD9A9E41D1F43ECC44D1385DAF2D8FB60" /> + <ComponentRef Id="cmp9B9A53A0C6DD95A6630C0210F3BB18E3" /> + <ComponentRef Id="cmpB930876C3A86169D30AD296E2E8C8BB5" /> + <ComponentRef Id="cmp02C9FCDEDD4174BB86092C3FC74686F0" /> + <ComponentRef Id="cmp851C5E0A0D76AE035089E9529277A1F0" /> + <ComponentRef Id="cmpE6741DB4F8619935F0A2A35131BD3237" /> + <ComponentRef Id="cmp661B947BA59FB91045269E4D99CF8CD5" /> + <ComponentRef Id="cmp7FE90DA6D2CB3D2F620DFB67DBE5FBD7" /> + <ComponentRef Id="cmp03CC22A1DFFB0DB0AE4FBE6BDD0EB1AD" /> + <ComponentRef Id="cmp747C6DC3F1F94C8C379E8894CB58CC1E" /> + <ComponentRef Id="cmp568BC886045DD9FA8CF128F42A72561F" /> + <ComponentRef Id="cmpF58038EF3D3DCDDB51D498784BD02F0E" /> + <ComponentRef Id="cmpA10ECE6646C3403587F5EA05B65F9E07" /> + <ComponentRef Id="cmpCB7AD9B47FC8C557168958B7EC0363D5" /> + </Feature> <Feature Id="Install_Registry" Absent="disallow" Level="1"> <!-- Registry Keys and Values --> <ComponentRef Id="VeraCryptVolume_Main_64" /> <ComponentRef Id="VeraCryptVolume_DefaultIcon_64" /> <ComponentRef Id="VeraCryptVolume_Open_64" /> <ComponentRef Id="VeraCryptVolume_Extension_64" /> <ComponentRef Id="VeraCrypt_ProductGUID" /> </Feature> <Feature Id="Install_Shortcuts" Absent="disallow" Level="1"> <!-- Shortcuts : Desktop and StartMenu --> <ComponentRef Id="VCShortcutDesktop" /> <ComponentRef Id="VCShortcutStartMenu" /> <ComponentRef Id="VCExpanderShortcutStartMenu" /> <ComponentRef Id="VCWebsiteShortcutStartMenu" /> </Feature> <!-- Tell Wix that WixUILicenseRtf was overrided by our definition of var.licenseRtf --> <WixVariable Id="WixUILicenseRtf" Overridable="yes" Value="$(var.licenseRtf)"/> @@ -1787,31 +2614,31 @@ <Custom Action="PreUninst_SetData" Before="DoPreUninstall">REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE</Custom> <!-- Execute DoPreUninstall before RemoveFiles when uninstalling ONLY --> <Custom Action="DoPreUninstall" Before="RemoveFiles">REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE</Custom> <!-- Execute PostUninst_SetData after RemoveFiles action when uninstalling ONLY and before DoPostUninstall to set the DoPostUninstall's Custom Action Data --> <Custom Action="PostUninst_SetData" Before="DoPostUninstall">REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE</Custom> <!-- Execute DoPostUninstall after RemoveFiles action when uninstalling ONLY --> <Custom Action="DoPostUninstall" After="RemoveFiles">REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE</Custom> <!-- Execute DoChecks after InstallFinalize action of first installation or repair or uninstall. Since we schedule RemoveExistingProducts after InstallExecute, if we execute this CA at UPGRADINGPRODUCTCODE, it will execute it twice : once when it installs new files (NOT Installed), and then when it removes unnecessary files (actual upgrade: UPGRADINGPRODUCTCODE). Since the first time it executes, it will delete the RegKeys, the second time it executes will fail, and with it the whole upgrade. Therefore, we do not need to execute it at UPGRADINGPRODUCTCODE. --> <Custom Action="DoChecks" After="InstallFinalize">(NOT Installed AND NOT REMOVE) OR REINSTALL OR (REMOVE~="ALL" AND NOT UPGRADINGPRODUCTCODE)</Custom> <!-- Set the ARP --> <Custom Action="SetARPINSTALLLOCATION" After="InstallValidate"></Custom> <!-- ScheduleReboot only after DoChecks, which sets ISREBOOTREQUIRED --> <ScheduleReboot After="DoChecks">ISREBOOTREQUIRED = "1"</ScheduleReboot> </InstallExecuteSequence> </Product> -</Wix>
\ No newline at end of file +</Wix> diff --git a/src/Release/Setup Files/build_msi_x64.bat b/src/Release/Setup Files/build_msi_x64.bat index e610160a..8d5a5449 100644 --- a/src/Release/Setup Files/build_msi_x64.bat +++ b/src/Release/Setup Files/build_msi_x64.bat @@ -1,42 +1,44 @@ ::------------------------------------ ::Define search paths here for Wix ToolSet and SDK (and SignTool optionnally) ::------------------------------------ -@set SEARCH_WIX_PATH=C:\Program Files (x86)\WiX Toolset v3.11\bin - -@set SEARCH_VC_DIR_PLATFORMSDK_1=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86 -@set SEARCH_VC_DIR_PLATFORMSDK_2=C:\Program Files (x86)\Windows Kits\10\bin\x86 -@set SEARCH_VC_DIR_PLATFORMSDK_3=C:\Program Files\Microsoft Platform SDK\bin -@set SEARCH_VC_DIR_PLATFORMSDK_4=C:\Program Files (x86)\Windows Kits\8.1\bin\x86 -@set SEARCH_VC_DIR_PLATFORMSDK_5=C:\Program Files (x86)\Windows Kits\8.0\bin\x86 -@set SEARCH_VC_DIR_PLATFORMSDK_6=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin +@set SEARCH_WIX_PATH=C:\Program Files (x86)\WiX Toolset v3.14\bin + +@set SEARCH_VC_DIR_PLATFORMSDK_1=C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_2=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17763.0\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_3=C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_4=C:\Program Files (x86)\Windows Kits\10\bin\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_5=C:\Program Files\Microsoft Platform SDK\bin +@set SEARCH_VC_DIR_PLATFORMSDK_6=C:\Program Files (x86)\Windows Kits\8.1\bin\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_7=C:\Program Files (x86)\Windows Kits\8.0\bin\x86 +@set SEARCH_VC_DIR_PLATFORMSDK_8=C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\bin ::end of search paths set MSI_BUILDPATH=%~dp0 cd %MSI_BUILDPATH% ::------------------------------------ :: Look for msitran.exe and msidb.exe ::------------------------------------ @echo [INFO] Define default value for VC_DIR_PLATFORMSDK if not defined yet @echo [INFO] Input VC_DIR_PLATFORMSDK=%VC_DIR_PLATFORMSDK% @set FILE_TO_FIND="msitran.exe" "msidb.exe" @echo [INFO] Looking for files: %FILE_TO_FIND% @set FILE_NOT_FOUND= @for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i @if "%FILE_NOT_FOUND%"=="" goto found_mssdk @echo Not found in "%VC_DIR_PLATFORMSDK%" @set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_1% @set FILE_NOT_FOUND= @for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i @if "%FILE_NOT_FOUND%"=="" goto found_mssdk @echo Not found in "%VC_DIR_PLATFORMSDK%" @set VC_DIR_PLATFORMSDK=%SEARCH_VC_DIR_PLATFORMSDK_2% @set FILE_NOT_FOUND= @for %%i in (%FILE_TO_FIND%) do @if not exist "%VC_DIR_PLATFORMSDK%\%%~i" set FILE_NOT_FOUND=%%~i @if "%FILE_NOT_FOUND%"=="" goto found_mssdk diff --git a/src/Release/Setup Files/veracrypt-arm64.cat b/src/Release/Setup Files/veracrypt-arm64.cat Binary files differindex 58d85469..b08beb21 100644 --- a/src/Release/Setup Files/veracrypt-arm64.cat +++ b/src/Release/Setup Files/veracrypt-arm64.cat diff --git a/src/Release/Setup Files/veracrypt-arm64.sys b/src/Release/Setup Files/veracrypt-arm64.sys Binary files differindex 747a9d4b..6eb2cab6 100644 --- a/src/Release/Setup Files/veracrypt-arm64.sys +++ b/src/Release/Setup Files/veracrypt-arm64.sys diff --git a/src/Release/Setup Files/veracrypt-x64.cat b/src/Release/Setup Files/veracrypt-x64.cat Binary files differindex 05d41921..a281819d 100644 --- a/src/Release/Setup Files/veracrypt-x64.cat +++ b/src/Release/Setup Files/veracrypt-x64.cat diff --git a/src/Release/Setup Files/veracrypt-x64.sys b/src/Release/Setup Files/veracrypt-x64.sys Binary files differindex d123b388..4d6b5dca 100644 --- a/src/Release/Setup Files/veracrypt-x64.sys +++ b/src/Release/Setup Files/veracrypt-x64.sys diff --git a/src/Release/Setup Files/veracrypt.Inf b/src/Release/Setup Files/veracrypt.Inf index 4418628a..567a502e 100644 --- a/src/Release/Setup Files/veracrypt.Inf +++ b/src/Release/Setup Files/veracrypt.Inf @@ -1,43 +1,43 @@ ;;; ;;; VeraCrypt ;;; ;;; -;;; Copyright (c) 2023, IDRIX +;;; Copyright (c) 2024, IDRIX ;;; [Version] signature = "$Windows NT$" Class = "Encryption" ;This is determined by the work this filter driver does ClassGuid = {a0a701c0-a511-42ff-aa6c-06dc0395576f} ;This value is determined by the Class Provider = %ProviderString% -DriverVer = 07/22/2022,1.26.4.0 +DriverVer = 07/28/2024,1.26.13.0 CatalogFile = veracrypt.cat [DestinationDirs] DefaultDestDir = 12 veracrypt.DriverFiles = 12 ;%windir%\system32\drivers ;; ;; Default install sections ;; [DefaultInstall.NTx86] OptionDesc = %ServiceDescription% CopyFiles = veracrypt.DriverFiles AddReg = veracrypt.AddReg [DefaultInstall.NTamd64] OptionDesc = %ServiceDescription% CopyFiles = veracrypt.DriverFiles AddReg = veracrypt.AddReg [DefaultInstall.NTarm64] OptionDesc = %ServiceDescription% CopyFiles = veracrypt.DriverFiles AddReg = veracrypt.AddReg [DefaultInstall.NTx86.Services] AddService = veracrypt,,veracrypt.Service [DefaultInstall.NTamd64.Services] diff --git a/src/Release/Setup Files/veracrypt.cat b/src/Release/Setup Files/veracrypt.cat Binary files differindex d2c5ae66..61f42269 100644 --- a/src/Release/Setup Files/veracrypt.cat +++ b/src/Release/Setup Files/veracrypt.cat diff --git a/src/Release/Setup Files/veracrypt.sys b/src/Release/Setup Files/veracrypt.sys Binary files differindex cb2d9fde..9ce29478 100644 --- a/src/Release/Setup Files/veracrypt.sys +++ b/src/Release/Setup Files/veracrypt.sys diff --git a/src/Resources/Texts/License.rtf b/src/Resources/Texts/License.rtf index 2f674c98..42364349 100644 --- a/src/Resources/Texts/License.rtf +++ b/src/Resources/Texts/License.rtf @@ -237,109 +237,109 @@ If your product is distributed in binary form only, you must display on any pack 4. Nothing requires that you accept this License, as you have not signed it. However, nothing else grants you permission to modify or distribute the product or its derivative works.}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
These actions are prohibited by law if you do not accept this License.}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
5. If any of these license terms is found to be to broad in scope, and declared invalid by any court or legal process, you agree that all other terms shall not be so affected, and shall remain valid and enforceable.}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
6. THIS PROGRAM IS DISTRIBUTED FREE OF CHARGE, THEREFORE THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. UNLESS OTHERWISE STATED THE PROGRAM IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
7. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM, INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS, EVEN IF SUCH HOLDER OR OTHER PARTY HAD PREVIOUSLY BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.}{\loch
\line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
____________________________________________________________}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
Copyright (c) 1998-2008, Brian Gladman, Worcester, UK. All rights reserved.}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
LICENSE TERMS}{\loch
\line \line }{\hich\af5\loch\scaps\fs16\i0\b0\f5\loch
The free distribution and use of this software is allowed (with or without changes) provided that:}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
1.\tab source code distributions include the above copyright notice, this list of conditions and the following disclaimer;}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
2.\tab binary distributions include the above copyright notice, this list of conditions and the following disclaimer in their documentation;}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
3.\tab the name of the copyright holder is not used to endorse products built using this software without specific written permission. }
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
DISCLAIMER}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
This software is provided 'as is' with no explicit or implied warranties in respect of its properties, including, but not limited to, correctness and/or fitness for purpose.}{\loch
\line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
-Copyright (C) 1995-2017 Jean-loup Gailly and Mark Adler}{\loch
+Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
This software is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this software.}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
1.\tab The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. }
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
2.\tab Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. }
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\li707\ri0\lin707\rin0\fi-283\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
3.\tab This notice may not be removed or altered from any source distribution. }
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
-Copyright (C) 1999-2017 Dieter Baron and Thomas Klausner}
+Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
The authors can be contacted at <libzip@nih.at>}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
3. The names of the authors may not be used to endorse or promote products derived from this software without specific prior written permission.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Copyright (c) 2013, Alexey Degtyarev. All rights reserved.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Copyright (c) 2016. Disk Cryptography Services for EFI (DCS), Alex Kolotnikov}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
This program and the accompanying materials are licensed and made available under the terms and conditions of the GNU Lesser General Public License, version 3.0 (LGPL-3.0).}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
The full text of the license may be found at }{{\field{\*\fldinst HYPERLINK "https://opensource.org/licenses/LGPL-3.0" }{\fldrslt {\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
https://opensource.org/licenses/LGPL-3.0}}}}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Copyright (c) 1999-2016 Jack Lloyd. All rights reserved.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
-Copyright (c) 2013-2018 Stephan Mueller <smueller@chronox.de>}
+Copyright (c) 2013-2019 Stephan Mueller <smueller@chronox.de>}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
1. Redistributions of source code must retain the above copyright notice, and the entire permission notice in its entirety, including the disclaimer of warranties.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
3. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
ALTERNATIVELY, this product may be distributed under the terms of the GNU General Public License, in which case the provisions of the GPL2 are required INSTEAD OF the above restrictions. (This clause is necessary due to a potential bad interaction between the GPL and the restrictions contained in a BSD-style copyright.)}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283\loch
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
____________________________________________________________}
\par \pard\plain \s0\rtlch\af8\afs24\alang1081 \ltrch\lang1033\langfe2052\hich\af3\loch\ql\nowidctlpar\hyphpar0\ltrpar\cf0\f3\fs24\lang1033\kerning1\dbch\af6\langfe2052\loch\ql\sb0\sa283{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
LZMA SDK Copyright (C) 1999-20}{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
-21}{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
+23}{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Igor Pavlov}{\loch
\line \line }{\hich\af5\loch\scaps0\caps0\fs16\i0\b0\f5\loch
Public domain}
\par }
\ No newline at end of file diff --git a/src/Setup/Dir.c b/src/Setup/Dir.c index 3275567f..f0a89ced 100644 --- a/src/Setup/Dir.c +++ b/src/Setup/Dir.c @@ -38,85 +38,85 @@ mkfulldir (wchar_t *oriPath, BOOL bCheckonly) } StringCbCopyW (path, TC_MAX_PATH, oriPath); if (wcslen (path) == 3 && path[1] == L':') goto is_root; /* keep final slash in root if present */ /* strip final forward or backslash if we have one! */ uniq_file = wcsrchr (path, L'\\'); if (uniq_file && uniq_file[1] == L'\0') uniq_file[0] = L'\0'; else { uniq_file = wcsrchr (path, L'/'); if (uniq_file && uniq_file[1] == L'\0') uniq_file[0] = L'\0'; } is_root: if (bCheckonly) return _wstat (path, &st); if (_wstat (path, &st)) return mkfulldir_internal (path); else return 0; } int -mkfulldir_internal (wchar_t *path) +mkfulldir_internal(wchar_t* path) { - wchar_t *token; - struct _stat st; - static wchar_t tokpath[_MAX_PATH]; - static wchar_t trail[_MAX_PATH]; - - if (wcslen(path) >= _MAX_PATH) - { - // directory name will be truncated so return failure to avoid unexepected behavior - return -1; - } - - StringCbCopyW (tokpath, _MAX_PATH, path); - trail[0] = L'\0'; - - token = wcstok (tokpath, L"\\/"); - - if (tokpath[0] == L'\\' && tokpath[1] == L'\\') - { /* unc */ - trail[0] = tokpath[0]; - trail[1] = tokpath[1]; - trail[2] = L'\0'; - if (token) - { - StringCbCatW (trail, _MAX_PATH, token); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - if (token) - { /* get share name */ - StringCbCatW (trail, _MAX_PATH, token); - StringCbCatW (trail, _MAX_PATH, L"\\"); - } - token = wcstok (NULL, L"\\/"); - } - } - - if (tokpath[1] == L':') - { /* drive letter */ - StringCbCatW (trail, _MAX_PATH, tokpath); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - } - - while (token != NULL) - { - int x; - StringCbCatW (trail, _MAX_PATH, token); - x = _wmkdir (trail); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - } - - return _wstat (path, &st); -} + wchar_t* token; + wchar_t* next_token = NULL; + struct _stat st; + static wchar_t tokpath[_MAX_PATH]; + static wchar_t trail[_MAX_PATH]; + + if (wcslen(path) >= _MAX_PATH) + { + // directory name will be truncated so return failure to avoid unexpected behavior + return -1; + } + + StringCbCopyW(tokpath, _MAX_PATH, path); + trail[0] = L'\0'; + + token = wcstok_s(tokpath, L"\\/", &next_token); + if (tokpath[0] == L'\\' && tokpath[1] == L'\\') + { /* unc */ + trail[0] = tokpath[0]; + trail[1] = tokpath[1]; + trail[2] = L'\0'; + if (token) + { + StringCbCatW(trail, _MAX_PATH, token); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + if (token) + { /* get share name */ + StringCbCatW(trail, _MAX_PATH, token); + StringCbCatW(trail, _MAX_PATH, L"\\"); + } + token = wcstok_s(NULL, L"\\/", &next_token); + } + } + + if (tokpath[1] == L':') + { /* drive letter */ + StringCbCatW(trail, _MAX_PATH, tokpath); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + } + + while (token != NULL) + { + int x; + StringCbCatW(trail, _MAX_PATH, token); + x = _wmkdir(trail); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + } + + return _wstat(path, &st); +}
\ No newline at end of file diff --git a/src/Setup/FreeBSD/veracrypt_install_template.sh b/src/Setup/FreeBSD/veracrypt_install_template.sh index 2d5dbcf9..1ebc7672 100644 --- a/src/Setup/FreeBSD/veracrypt_install_template.sh +++ b/src/Setup/FreeBSD/veracrypt_install_template.sh @@ -66,61 +66,61 @@ then GUI=0 XMESSAGE=0 XTERM=0 GTERM=0 KTERM=0 fi show_message() { if [ $GUI -eq 1 ] then if [ $XMESSAGE -eq 1 ] then xmessage -center -buttons OK -default OK "$*" else if [ $TTY -eq 1 ] then echo "$*" else if [ $XTERM -eq 1 ] then xterm -T 'VeraCrypt Setup' -e sh -c "echo $*; read A" else if [ $GTERM -eq 1 ] then gnome-terminal --title='VeraCrypt Setup' -e "sh -c \"echo $*; read A\"" else if [ $KTERM -eq 1 ] then - konsole --title 'VeraCrypt Setup' --caption 'VeraCrypt Setup' -e sh -c "echo $*; read A" + konsole --qwindowtitle 'VeraCrypt Setup' --caption 'VeraCrypt Setup' -e sh -c "echo $*; read A" fi fi fi fi fi else echo "$*" fi } show_exit_message() { show_message "$*" if [ $XMESSAGE -eq 0 ] then printf 'Press Enter to exit... ' read A fi } # License extraction trap 'rm -f $LICENSE $PACKAGE; exit 1' HUP INT QUIT TERM LICENSE=$(mktemp) cat >$LICENSE <<_LICENSE_END VeraCrypt License Software distributed under this license is distributed on an "AS IS" BASIS WITHOUT WARRANTIES OF ANY KIND. THE AUTHORS AND @@ -1047,55 +1047,55 @@ _INFO fi show_message "$(cat <<_INFO Uninstalling VeraCrypt: ----------------------- To uninstall VeraCrypt, please run 'veracrypt-uninstall.sh'. _INFO )" [ $GUI -eq 0 ] && echo fi if [ $INSTALL -eq 1 ] then INSTALLED=0 if [ $GUI -eq 1 ] then if [ $XTERM -eq 1 ] then exec xterm -T 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" else if [ $GTERM -eq 1 ] then exec gnome-terminal --title='VeraCrypt Setup' -e "sh -c \"echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A\"" else if [ $KTERM -eq 1 ] then - exec konsole --title 'VeraCrypt Setup' --caption 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" + exec konsole --qwindowtitle 'VeraCrypt Setup' --caption 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" fi fi fi else echo 'Installing package...' $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE && INSTALLED=1 if [ $INSTALLED -eq 1 ] then show_exit_message '' fi fi rm -f $PACKAGE if [ $INSTALLED -ne 1 ] then show_exit_message 'Error: VeraCrypt installation failed' exit 1 fi else show_exit_message "Installation package '$PACKAGE_NAME' extracted and placed in '$PACKAGE_DIR'" fi exit 0 diff --git a/src/Setup/Linux/veracrypt_install_template.sh b/src/Setup/Linux/veracrypt_install_template.sh index bc84a896..e4615966 100644 --- a/src/Setup/Linux/veracrypt_install_template.sh +++ b/src/Setup/Linux/veracrypt_install_template.sh @@ -70,61 +70,61 @@ then GUI=0 XMESSAGE=0 XTERM=0 GTERM=0 KTERM=0 fi show_message() { if [ $GUI -eq 1 ] then if [ $XMESSAGE -eq 1 ] then xmessage -center -buttons OK -default OK "$*" else if [ $TTY -eq 1 ] then echo "$*" else if [ $XTERM -eq 1 ] then xterm -T 'VeraCrypt Setup' -e sh -c "echo $*; read A" else if [ $GTERM -eq 1 ] then gnome-terminal --title='VeraCrypt Setup' -e "sh -c \"echo $*; read A\"" else if [ $KTERM -eq 1 ] then - konsole --title 'VeraCrypt Setup' -e sh -c "echo $*; read A" + konsole --qwindowtitle 'VeraCrypt Setup' -e sh -c "echo $*; read A" fi fi fi fi fi else echo "$*" fi } show_exit_message() { show_message "$*" if [ $XMESSAGE -eq 0 ] then printf 'Press Enter to exit... ' read A fi } # License extraction trap 'rm -f $LICENSE $PACKAGE; exit 1' HUP INT QUIT TERM LICENSE=$(mktemp) cat >$LICENSE <<_LICENSE_END VeraCrypt License Software distributed under this license is distributed on an "AS IS" BASIS WITHOUT WARRANTIES OF ANY KIND. THE AUTHORS AND @@ -1051,55 +1051,55 @@ _INFO fi show_message "$(cat <<_INFO Uninstalling VeraCrypt: ----------------------- To uninstall VeraCrypt, please run 'veracrypt-uninstall.sh'. _INFO )" [ $GUI -eq 0 ] && echo fi if [ $INSTALL -eq 1 ] then INSTALLED=0 if [ $GUI -eq 1 ] then if [ $XTERM -eq 1 ] then exec xterm -T 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" else if [ $GTERM -eq 1 ] then exec gnome-terminal --title='VeraCrypt Setup' -e "sh -c \"echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A\"" else if [ $KTERM -eq 1 ] then - exec konsole --title 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" + exec konsole --qwindowtitle 'VeraCrypt Setup' -e sh -c "echo Installing package...; $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE; rm -f $PACKAGE; echo; echo Press Enter to exit...; read A" fi fi fi else echo 'Installing package...' $SUDO $PACKAGE_INSTALLER $PACKAGE_INSTALLER_OPTS $PACKAGE && INSTALLED=1 if [ $INSTALLED -eq 1 ] then show_exit_message '' fi fi rm -f $PACKAGE if [ $INSTALLED -ne 1 ] then show_exit_message 'Error: VeraCrypt installation failed' exit 1 fi else show_exit_message "Installation package '$PACKAGE_NAME' extracted and placed in '$PACKAGE_DIR'" fi exit 0 diff --git a/src/Setup/MacOSX/VeraCrypt.entitlements.plist b/src/Setup/MacOSX/VeraCrypt.entitlements.plist new file mode 100644 index 00000000..123d12a5 --- /dev/null +++ b/src/Setup/MacOSX/VeraCrypt.entitlements.plist @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>com.apple.security.cs.disable-library-validation</key> + <true/> +</dict> +</plist> diff --git a/src/Setup/MacOSX/notarize.sh b/src/Setup/MacOSX/notarize.sh new file mode 100755 index 00000000..c3e2ff05 --- /dev/null +++ b/src/Setup/MacOSX/notarize.sh @@ -0,0 +1,140 @@ +#!/bin/bash + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # Directory where the script is located +BUNDLE_PATH="${SCRIPT_DIR}/../../Main/VeraCrypt.app" # Path to the VeraCrypt.app bundle +APPLE_ID="appleid" # Apple ID +APP_SPECIFIC_PASSWORD="password" # app-specific password +TEAM_ID="teamid" # team ID +SIGNING_ID="signingid" # Signing ID + +# Check if VeraCrypt.app bundle exists +if [ ! -d "$BUNDLE_PATH" ]; then + echo "VeraCrypt.app bundle not found: $BUNDLE_PATH" + exit 1 +fi + +# Retrieve the version of VeraCrypt from Info.plist +VC_VERSION=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${BUNDLE_PATH}/Contents/Info.plist") + +echo "Notarizing VeraCrypt ${VC_VERSION}..." + +# Change to the script directory +cd "${SCRIPT_DIR}" + +xattr -rc "$BUNDLE_PATH" +codesign --timestamp --option runtime --deep --force --entitlements "${SCRIPT_DIR}/VeraCrypt.entitlements.plist" --sign "${SIGNING_ID}" "$BUNDLE_PATH" + +# Check dependencies of the VeraCrypt binary +VC_BINARY="$BUNDLE_PATH/Contents/MacOS/VeraCrypt" +DEPENDENCY_OUTPUT=$(otool -L "$VC_BINARY" | grep libfuse-t.dylib) + +# Determine the correct .pkgproj file based on the dependency +PKGPROJ_FILE="${SCRIPT_DIR}/veracrypt.pkgproj" +DMG_LABEL="VeraCrypt_${VC_VERSION}.dmg" +if [[ "$DEPENDENCY_OUTPUT" != "" ]]; then + echo "VeraCrypt is linked against FUSE-T." + PKGPROJ_FILE="${SCRIPT_DIR}/veracrypt_fuse-t.pkgproj" + DMG_LABEL="VeraCrypt_FUSE-T_${VC_VERSION}.dmg" +else + echo "VeraCrypt is linked against standard MacFUSE." +fi + +/usr/local/bin/packagesbuild "$PKGPROJ_FILE" + +PKG_PATH="${SCRIPT_DIR}/VeraCrypt_${VC_VERSION}.pkg" # Constructed path to the VeraCrypt pkg +productsign --sign "Developer ID Installer: IDRIX (Z933746L2S)" --timestamp "${SCRIPT_DIR}/VeraCrypt ${VC_VERSION}.pkg" "$PKG_PATH" + +if [ ! -f "$PKG_PATH" ]; then + echo "pkg file not found: $PKG_PATH" + exit 1 +fi + +# Step 1: Upload PKG to Apple for notarization +echo "Uploading PKG to Apple for notarization..." +xcrun notarytool submit "$PKG_PATH" --apple-id "$APPLE_ID" --password "$APP_SPECIFIC_PASSWORD" --team-id "$TEAM_ID" --wait --output-format json > notarization_result.json + +# Check if the notarization submission was successful +if [ $? -ne 0 ]; then + echo "Failed to submit PKG for notarization." + cat notarization_result.json + exit 1 +fi + +# Extract the notarization UUID from the result +REQUEST_UUID=$(grep -o '"id":"[^"]*' notarization_result.json | sed 's/"id":"//') +echo "Notarization Request UUID: $REQUEST_UUID" + +# Step 2: Check the notarization status +echo "Checking notarization status..." +STATUS=$(grep -o '"status":"[^"]*' notarization_result.json | sed 's/"status":"//' | sed 's/"}//') +echo "Initial status: $STATUS" + +while [ "$STATUS" == "in progress" ]; do + sleep 30 + xcrun notarytool info "$REQUEST_UUID" --apple-id "$APPLE_ID" --password "$APP_SPECIFIC_PASSWORD" --team-id "$TEAM_ID" --output-format json > notarization_status.json + + if [ ! -f notarization_status.json ]; then + echo "Failed to retrieve notarization status." + exit 1 + fi + + STATUS=$(grep -o '"status":"[^"]*' notarization_status.json | sed 's/"status":"//' | sed 's/"}//') + echo "Current status: $STATUS" +done + +# Step 3: Staple the notarization ticket to the pkg or retrieve the log +if [ "$STATUS" == "Accepted" ]; then + echo "Stapling the notarization ticket to the pkg..." + # Staple the notarization ticket to the installer package + xcrun stapler staple "$PKG_PATH" + echo "Notarization and stapling completed successfully." + + # Clean up any existing temporary files and directories + rm -f template.dmg + rm -fr VeraCrypt_dmg + + # Create a directory to mount the template DMG + echo "Creating directory to mount the template DMG..." + mkdir -p VeraCrypt_dmg + + # Decompress the template DMG file + echo "Decompressing the template DMG file..." + bunzip2 -k -f template.dmg.bz2 + + # Attach the template DMG to the system, mount it at VeraCrypt_dmg directory + echo "Attaching the template DMG to the system..." + hdiutil attach template.dmg -noautoopen -quiet -mountpoint VeraCrypt_dmg + + # Copy the notarized installer package into the mounted DMG + echo "Copying the notarized installer package into the mounted DMG..." + cp "VeraCrypt_${VC_VERSION}.pkg" VeraCrypt_dmg/VeraCrypt_Installer.pkg + + # Detach the DMG, ensuring all changes are saved and it's unmounted + echo "Detaching the DMG..." + hdiutil detach VeraCrypt_dmg -quiet -force + + # Convert the DMG back to a compressed format (UDZO) and create the final DMG file + echo "Converting the DMG back to a compressed format..." + rm -f "${DMG_LABEL}" + hdiutil convert template.dmg -quiet -format UDZO -imagekey zlib-level=9 -o "${DMG_LABEL}" + + # Sign the final DMG file + echo "Signing the final DMG file..." + codesign -s "${SIGNING_ID}" --timestamp "${DMG_LABEL}" + + # Clean up temporary files and directories + rm -f template.dmg + rm -fr VeraCrypt_dmg +else + echo "Notarization failed. Retrieving log for more details..." + # Retrieve the notarization log for details on why it failed + xcrun notarytool log "$REQUEST_UUID" --apple-id "$APPLE_ID" --password "$APP_SPECIFIC_PASSWORD" --team-id "$TEAM_ID" --output-format json > notarization_log.json + cat notarization_log.json +fi + +# Clean up temporary files +rm -f notarization_result.json +rm -f notarization_status.json +rm -f notarization_log.json + +exit 0
\ No newline at end of file diff --git a/src/Setup/MacOSX/postinstall_fuse-t.sh b/src/Setup/MacOSX/postinstall_fuse-t.sh new file mode 100755 index 00000000..fb799b91 --- /dev/null +++ b/src/Setup/MacOSX/postinstall_fuse-t.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +chmod -R go-w /Applications/VeraCrypt.app + +exit 0 diff --git a/src/Setup/MacOSX/veracrypt.pkgproj b/src/Setup/MacOSX/veracrypt.pkgproj index ff5506e7..6f027358 100755 --- a/src/Setup/MacOSX/veracrypt.pkgproj +++ b/src/Setup/MacOSX/veracrypt.pkgproj @@ -1,32 +1,31 @@ <?xml version="1.0" encoding="UTF-8"?> -<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>PACKAGES</key> <array> <dict> <key>MUST-CLOSE-APPLICATION-ITEMS</key> <array/> <key>MUST-CLOSE-APPLICATIONS</key> <false/> <key>PACKAGE_FILES</key> <dict> <key>DEFAULT_INSTALL_LOCATION</key> <string>/</string> <key>HIERARCHY</key> <dict> <key>CHILDREN</key> <array> <dict> <key>CHILDREN</key> <array> <dict> <key>CHILDREN</key> <array/> <key>GID</key> <integer>80</integer> <key>PATH</key> <string>Utilities</string> <key>PATH_TYPE</key> <integer>0</integer> @@ -531,61 +530,61 @@ <integer>0</integer> </dict> <key>RESOURCES</key> <array/> </dict> <key>PACKAGE_SETTINGS</key> <dict> <key>AUTHENTICATION</key> <integer>1</integer> <key>CONCLUSION_ACTION</key> <integer>0</integer> <key>FOLLOW_SYMBOLIC_LINKS</key> <false/> <key>IDENTIFIER</key> <string>com.idrix.pkg.veracrypt</string> <key>LOCATION</key> <integer>0</integer> <key>NAME</key> <string>veracrypt</string> <key>OVERWRITE_PERMISSIONS</key> <false/> <key>PAYLOAD_SIZE</key> <integer>-1</integer> <key>REFERENCE_PATH</key> <string></string> <key>RELOCATABLE</key> <false/> <key>USE_HFS+_COMPRESSION</key> <false/> <key>VERSION</key> - <string>1.26.4</string> + <string>1.26.15</string> </dict> <key>TYPE</key> <integer>0</integer> <key>UUID</key> <string>B14381D9-EC5F-43E4-B971-82AB3D132A64</string> </dict> </array> <key>PROJECT</key> <dict> <key>PROJECT_COMMENTS</key> <dict> <key>NOTES</key> <data> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1M IDQuMDEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDQv c3RyaWN0LmR0ZCI+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1l cXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7 IGNoYXJzZXQ9VVRGLTgiPgo8bWV0YSBodHRwLWVxdWl2PSJDb250 ZW50LVN0eWxlLVR5cGUiIGNvbnRlbnQ9InRleHQvY3NzIj4KPHRp dGxlPjwvdGl0bGU+CjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29u dGVudD0iQ29jb2EgSFRNTCBXcml0ZXIiPgo8bWV0YSBuYW1lPSJD b2NvYVZlcnNpb24iIGNvbnRlbnQ9IjExMzguNTEiPgo8c3R5bGUg dHlwZT0idGV4dC9jc3MiPgo8L3N0eWxlPgo8L2hlYWQ+Cjxib2R5 Pgo8L2JvZHk+CjwvaHRtbD4K </data> </dict> <key>PROJECT_PRESENTATION</key> <dict> <key>BACKGROUND</key> <dict> @@ -729,79 +728,79 @@ <key>LOCALIZATIONS</key> <array/> </dict> <key>TITLE</key> <dict> <key>LOCALIZATIONS</key> <array> <dict> <key>LANGUAGE</key> <string>French</string> <key>VALUE</key> <string></string> </dict> </array> </dict> </dict> <key>PROJECT_REQUIREMENTS</key> <dict> <key>LIST</key> <array> <dict> <key>BEHAVIOR</key> <integer>3</integer> <key>DICTIONARY</key> <dict> <key>IC_REQUIREMENT_OS_DISK_TYPE</key> <integer>1</integer> <key>IC_REQUIREMENT_OS_DISTRIBUTION_TYPE</key> <integer>0</integer> <key>IC_REQUIREMENT_OS_MINIMUM_VERSION</key> - <integer>100900</integer> + <integer>120001</integer> </dict> <key>IC_REQUIREMENT_CHECK_TYPE</key> <integer>0</integer> <key>IDENTIFIER</key> <string>fr.whitebox.Packages.requirement.os</string> <key>MESSAGE</key> <array> <dict> <key>LANGUAGE</key> <string>English</string> <key>VALUE</key> - <string>VeraCrypt requires MacOSX 10.9 and above.</string> + <string>VeraCrypt requires MacOSX 12 and above.</string> </dict> <dict> <key>LANGUAGE</key> <string>French</string> <key>VALUE</key> - <string>VeraCrypt nécessite MacOSX 10.9 et supérieur.</string> + <string>VeraCrypt nécessite MacOSX 12 et supérieur.</string> </dict> </array> <key>NAME</key> <string>Operating System</string> <key>STATE</key> <true/> </dict> <dict> <key>BEHAVIOR</key> <integer>3</integer> <key>DICTIONARY</key> <dict> <key>IC_REQUIREMENT_FILES_CONDITION</key> <integer>0</integer> <key>IC_REQUIREMENT_FILES_DISK_TYPE</key> <integer>1</integer> <key>IC_REQUIREMENT_FILES_LIST</key> <array> <string>/usr/local/lib/libfuse.dylib</string> <string>/usr/local/lib/libosxfuse.2.dylib</string> </array> <key>IC_REQUIREMENT_FILES_SELECTOR</key> <integer>0</integer> </dict> <key>IC_REQUIREMENT_CHECK_TYPE</key> <integer>0</integer> <key>IDENTIFIER</key> <string>fr.whitebox.Packages.requirement.files</string> <key>MESSAGE</key> <array> @@ -999,48 +998,48 @@ https://osxfuse.github.io/ <key>STATE</key> <true/> </dict> <dict> <key>PATTERNS_ARRAY</key> <array> <dict> <key>REGULAR_EXPRESSION</key> <false/> <key>STRING</key> <string>Resources Disabled</string> <key>TYPE</key> <integer>1</integer> </dict> </array> <key>PROTECTED</key> <true/> <key>PROXY_NAME</key> <string>Remove Resources Disabled folders</string> <key>PROXY_TOOLTIP</key> <string>Remove "Resources Disabled" folders.</string> <key>STATE</key> <true/> </dict> <dict> <key>SEPARATOR</key> <true/> </dict> </array> <key>NAME</key> - <string>VeraCrypt 1.26.4</string> + <string>VeraCrypt 1.26.15</string> <key>PAYLOAD_ONLY</key> <false/> <key>TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING</key> <false/> </dict> </dict> <key>SHARED_GLOBAL_DATA</key> <dict> <key>IC_REQUIREMENT_JAVASCRIPT_SHARED_SOURCE_CODE</key> <string></string> </dict> <key>TYPE</key> <integer>0</integer> <key>VERSION</key> <integer>2</integer> </dict> </plist> diff --git a/src/Setup/MacOSX/veracrypt_Legacy.pkgproj b/src/Setup/MacOSX/veracrypt_Legacy.pkgproj index 41c1f4e4..0c7d16cb 100755 --- a/src/Setup/MacOSX/veracrypt_Legacy.pkgproj +++ b/src/Setup/MacOSX/veracrypt_Legacy.pkgproj @@ -530,61 +530,61 @@ <integer>0</integer> </dict> <key>RESOURCES</key> <array/> </dict> <key>PACKAGE_SETTINGS</key> <dict> <key>AUTHENTICATION</key> <integer>1</integer> <key>CONCLUSION_ACTION</key> <integer>0</integer> <key>FOLLOW_SYMBOLIC_LINKS</key> <false/> <key>IDENTIFIER</key> <string>com.idrix.pkg.veracrypt</string> <key>LOCATION</key> <integer>0</integer> <key>NAME</key> <string>veracrypt</string> <key>OVERWRITE_PERMISSIONS</key> <false/> <key>PAYLOAD_SIZE</key> <integer>-1</integer> <key>REFERENCE_PATH</key> <string></string> <key>RELOCATABLE</key> <false/> <key>USE_HFS+_COMPRESSION</key> <false/> <key>VERSION</key> - <string>1.26.4</string> + <string>1.26.15</string> </dict> <key>TYPE</key> <integer>0</integer> <key>UUID</key> <string>B14381D9-EC5F-43E4-B971-82AB3D132A64</string> </dict> </array> <key>PROJECT</key> <dict> <key>PROJECT_COMMENTS</key> <dict> <key>NOTES</key> <data> PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1M IDQuMDEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDQv c3RyaWN0LmR0ZCI+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1l cXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7 IGNoYXJzZXQ9VVRGLTgiPgo8bWV0YSBodHRwLWVxdWl2PSJDb250 ZW50LVN0eWxlLVR5cGUiIGNvbnRlbnQ9InRleHQvY3NzIj4KPHRp dGxlPjwvdGl0bGU+CjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29u dGVudD0iQ29jb2EgSFRNTCBXcml0ZXIiPgo8bWV0YSBuYW1lPSJD b2NvYVZlcnNpb24iIGNvbnRlbnQ9IjExMzguNTEiPgo8c3R5bGUg dHlwZT0idGV4dC9jc3MiPgo8L3N0eWxlPgo8L2hlYWQ+Cjxib2R5 Pgo8L2JvZHk+CjwvaHRtbD4K </data> </dict> <key>PROJECT_PRESENTATION</key> <dict> <key>BACKGROUND</key> <dict> @@ -1035,48 +1035,48 @@ https://osxfuse.github.io/ <key>STATE</key> <true/> </dict> <dict> <key>PATTERNS_ARRAY</key> <array> <dict> <key>REGULAR_EXPRESSION</key> <false/> <key>STRING</key> <string>Resources Disabled</string> <key>TYPE</key> <integer>1</integer> </dict> </array> <key>PROTECTED</key> <true/> <key>PROXY_NAME</key> <string>Remove Resources Disabled folders</string> <key>PROXY_TOOLTIP</key> <string>Remove "Resources Disabled" folders.</string> <key>STATE</key> <true/> </dict> <dict> <key>SEPARATOR</key> <true/> </dict> </array> <key>NAME</key> - <string>VeraCrypt Legacy 1.26.4</string> + <string>VeraCrypt Legacy 10</string> <key>PAYLOAD_ONLY</key> <false/> <key>TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING</key> <false/> </dict> </dict> <key>SHARED_GLOBAL_DATA</key> <dict> <key>IC_REQUIREMENT_JAVASCRIPT_SHARED_SOURCE_CODE</key> <string></string> </dict> <key>TYPE</key> <integer>0</integer> <key>VERSION</key> <integer>2</integer> </dict> </plist> diff --git a/src/Setup/MacOSX/veracrypt_fuse-t.pkgproj b/src/Setup/MacOSX/veracrypt_fuse-t.pkgproj new file mode 100755 index 00000000..fb349daf --- /dev/null +++ b/src/Setup/MacOSX/veracrypt_fuse-t.pkgproj @@ -0,0 +1,1044 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> +<plist version="1.0"> +<dict> + <key>PACKAGES</key> + <array> + <dict> + <key>MUST-CLOSE-APPLICATION-ITEMS</key> + <array/> + <key>MUST-CLOSE-APPLICATIONS</key> + <false/> + <key>PACKAGE_FILES</key> + <dict> + <key>DEFAULT_INSTALL_LOCATION</key> + <string>/</string> + <key>HIERARCHY</key> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>Utilities</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>BUNDLE_CAN_DOWNGRADE</key> + <true/> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>../../Main/VeraCrypt.app</string> + <key>PATH_TYPE</key> + <integer>1</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>3</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>Applications</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>509</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>Application Support</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Documentation</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Filesystems</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Frameworks</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Input Methods</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Internet Plug-Ins</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>LaunchAgents</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>LaunchDaemons</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>PreferencePanes</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Preferences</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>Printers</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>PrivilegedHelperTools</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>1005</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>QuickLook</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>QuickTime</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Screen Savers</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Scripts</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Services</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Widgets</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Automator</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Extensions</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Library</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Extensions</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Library</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>System</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <dict> + <key>CHILDREN</key> + <array> + <dict> + <key>CHILDREN</key> + <array/> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>Shared</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>1023</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>80</integer> + <key>PATH</key> + <string>Users</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + </array> + <key>GID</key> + <integer>0</integer> + <key>PATH</key> + <string>/</string> + <key>PATH_TYPE</key> + <integer>0</integer> + <key>PERMISSIONS</key> + <integer>493</integer> + <key>TYPE</key> + <integer>1</integer> + <key>UID</key> + <integer>0</integer> + </dict> + <key>PAYLOAD_TYPE</key> + <integer>0</integer> + <key>PRESERVE_EXTENDED_ATTRIBUTES</key> + <false/> + <key>SHOW_INVISIBLE</key> + <false/> + <key>SPLIT_FORKS</key> + <true/> + <key>TREAT_MISSING_FILES_AS_WARNING</key> + <false/> + <key>VERSION</key> + <integer>5</integer> + </dict> + <key>PACKAGE_SCRIPTS</key> + <dict> + <key>POSTINSTALL_PATH</key> + <dict> + <key>PATH</key> + <string>postinstall_fuse-t.sh</string> + <key>PATH_TYPE</key> + <integer>1</integer> + </dict> + <key>PREINSTALL_PATH</key> + <dict> + <key>PATH_TYPE</key> + <integer>0</integer> + </dict> + <key>RESOURCES</key> + <array/> + </dict> + <key>PACKAGE_SETTINGS</key> + <dict> + <key>AUTHENTICATION</key> + <integer>1</integer> + <key>CONCLUSION_ACTION</key> + <integer>0</integer> + <key>FOLLOW_SYMBOLIC_LINKS</key> + <false/> + <key>IDENTIFIER</key> + <string>com.idrix.pkg.veracrypt</string> + <key>LOCATION</key> + <integer>0</integer> + <key>NAME</key> + <string>veracrypt</string> + <key>OVERWRITE_PERMISSIONS</key> + <false/> + <key>PAYLOAD_SIZE</key> + <integer>-1</integer> + <key>REFERENCE_PATH</key> + <string></string> + <key>RELOCATABLE</key> + <false/> + <key>USE_HFS+_COMPRESSION</key> + <false/> + <key>VERSION</key> + <string>1.26.15</string> + </dict> + <key>TYPE</key> + <integer>0</integer> + <key>UUID</key> + <string>B14381D9-EC5F-43E4-B971-82AB3D132A64</string> + </dict> + </array> + <key>PROJECT</key> + <dict> + <key>PROJECT_COMMENTS</key> + <dict> + <key>NOTES</key> + <data> + PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBIVE1M + IDQuMDEvL0VOIiAiaHR0cDovL3d3dy53My5vcmcvVFIvaHRtbDQv + c3RyaWN0LmR0ZCI+CjxodG1sPgo8aGVhZD4KPG1ldGEgaHR0cC1l + cXVpdj0iQ29udGVudC1UeXBlIiBjb250ZW50PSJ0ZXh0L2h0bWw7 + IGNoYXJzZXQ9VVRGLTgiPgo8bWV0YSBodHRwLWVxdWl2PSJDb250 + ZW50LVN0eWxlLVR5cGUiIGNvbnRlbnQ9InRleHQvY3NzIj4KPHRp + dGxlPjwvdGl0bGU+CjxtZXRhIG5hbWU9IkdlbmVyYXRvciIgY29u + dGVudD0iQ29jb2EgSFRNTCBXcml0ZXIiPgo8bWV0YSBuYW1lPSJD + b2NvYVZlcnNpb24iIGNvbnRlbnQ9IjExMzguNTEiPgo8c3R5bGUg + dHlwZT0idGV4dC9jc3MiPgo8L3N0eWxlPgo8L2hlYWQ+Cjxib2R5 + Pgo8L2JvZHk+CjwvaHRtbD4K + </data> + </dict> + <key>PROJECT_PRESENTATION</key> + <dict> + <key>BACKGROUND</key> + <dict> + <key>APPAREANCES</key> + <dict> + <key>DARK_AQUA</key> + <dict/> + <key>LIGHT_AQUA</key> + <dict/> + </dict> + <key>SHARED_SETTINGS_FOR_ALL_APPAREANCES</key> + <true/> + </dict> + <key>INSTALLATION TYPE</key> + <dict> + <key>HIERARCHIES</key> + <dict> + <key>INSTALLER</key> + <dict> + <key>LIST</key> + <array> + <dict> + <key>DESCRIPTION</key> + <array/> + <key>OPTIONS</key> + <dict> + <key>HIDDEN</key> + <false/> + <key>STATE</key> + <integer>1</integer> + </dict> + <key>PACKAGE_UUID</key> + <string>B14381D9-EC5F-43E4-B971-82AB3D132A64</string> + <key>TITLE</key> + <array/> + <key>TOOLTIP</key> + <array/> + <key>TYPE</key> + <integer>0</integer> + <key>UUID</key> + <string>4F1ACCF7-AA2A-4C80-A42F-274D410A13D1</string> + </dict> + </array> + <key>REMOVED</key> + <dict/> + </dict> + </dict> + <key>MODE</key> + <integer>0</integer> + </dict> + <key>INSTALLATION_STEPS</key> + <array> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewIntroductionController</string> + <key>INSTALLER_PLUGIN</key> + <string>Introduction</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewReadMeController</string> + <key>INSTALLER_PLUGIN</key> + <string>ReadMe</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewLicenseController</string> + <key>INSTALLER_PLUGIN</key> + <string>License</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewDestinationSelectController</string> + <key>INSTALLER_PLUGIN</key> + <string>TargetSelect</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewInstallationTypeController</string> + <key>INSTALLER_PLUGIN</key> + <string>PackageSelection</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewInstallationController</string> + <key>INSTALLER_PLUGIN</key> + <string>Install</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + <dict> + <key>ICPRESENTATION_CHAPTER_VIEW_CONTROLLER_CLASS</key> + <string>ICPresentationViewSummaryController</string> + <key>INSTALLER_PLUGIN</key> + <string>Summary</string> + <key>LIST_TITLE_KEY</key> + <string>InstallerSectionTitle</string> + </dict> + </array> + <key>INTRODUCTION</key> + <dict> + <key>LOCALIZATIONS</key> + <array/> + </dict> + <key>LICENSE</key> + <dict> + <key>LOCALIZATIONS</key> + <array> + <dict> + <key>LANGUAGE</key> + <string>English</string> + <key>VALUE</key> + <dict> + <key>PATH</key> + <string>../../License.txt</string> + <key>PATH_TYPE</key> + <integer>1</integer> + </dict> + </dict> + </array> + <key>MODE</key> + <integer>0</integer> + </dict> + <key>README</key> + <dict> + <key>LOCALIZATIONS</key> + <array/> + </dict> + <key>SUMMARY</key> + <dict> + <key>LOCALIZATIONS</key> + <array/> + </dict> + <key>TITLE</key> + <dict> + <key>LOCALIZATIONS</key> + <array> + <dict> + <key>LANGUAGE</key> + <string>French</string> + <key>VALUE</key> + <string></string> + </dict> + </array> + </dict> + </dict> + <key>PROJECT_REQUIREMENTS</key> + <dict> + <key>LIST</key> + <array> + <dict> + <key>BEHAVIOR</key> + <integer>3</integer> + <key>DICTIONARY</key> + <dict> + <key>IC_REQUIREMENT_OS_DISK_TYPE</key> + <integer>1</integer> + <key>IC_REQUIREMENT_OS_DISTRIBUTION_TYPE</key> + <integer>0</integer> + <key>IC_REQUIREMENT_OS_MINIMUM_VERSION</key> + <integer>119900</integer> + </dict> + <key>IC_REQUIREMENT_CHECK_TYPE</key> + <integer>0</integer> + <key>IDENTIFIER</key> + <string>fr.whitebox.Packages.requirement.os</string> + <key>MESSAGE</key> + <array> + <dict> + <key>LANGUAGE</key> + <string>English</string> + <key>VALUE</key> + <string>VeraCrypt requires MacOSX 12 and above.</string> + </dict> + <dict> + <key>LANGUAGE</key> + <string>French</string> + <key>VALUE</key> + <string>VeraCrypt nécessite MacOSX 12 et supérieur.</string> + </dict> + </array> + <key>NAME</key> + <string>Operating System</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>BEHAVIOR</key> + <integer>3</integer> + <key>DICTIONARY</key> + <dict> + <key>IC_REQUIREMENT_FILES_CONDITION</key> + <integer>0</integer> + <key>IC_REQUIREMENT_FILES_DISK_TYPE</key> + <integer>1</integer> + <key>IC_REQUIREMENT_FILES_LIST</key> + <array> + <string>/usr/local/lib/libfuse-t.dylib</string> + </array> + <key>IC_REQUIREMENT_FILES_SELECTOR</key> + <integer>0</integer> + </dict> + <key>IC_REQUIREMENT_CHECK_TYPE</key> + <integer>0</integer> + <key>IDENTIFIER</key> + <string>fr.whitebox.Packages.requirement.files</string> + <key>MESSAGE</key> + <array> + <dict> + <key>LANGUAGE</key> + <string>English</string> + <key>SECONDARY_VALUE</key> + <string></string> + <key>VALUE</key> + <string>FUSE-T seems to be missing on your machine. VeraCrypt requires OSXFuse 1.0 or above. +Please download the latest FUSE-T version from : +https://github.com/macos-fuse-t/fuse-t/releases</string> + </dict> + <dict> + <key>LANGUAGE</key> + <string>French</string> + <key>SECONDARY_VALUE</key> + <string></string> + <key>VALUE</key> + <string>FUSE-T semble ne pas être installé sur votre machine. VeraCrypt nécessite FUSE-T 1.0 ou supérieur. +Merci de télécharger la dernière version de OSXFuse à partir de : +https://github.com/macos-fuse-t/fuse-t/releases + +</string> + </dict> + </array> + <key>NAME</key> + <string>FUSE-T</string> + <key>STATE</key> + <true/> + </dict> + </array> + <key>RESOURCES</key> + <array/> + <key>ROOT_VOLUME_ONLY</key> + <false/> + </dict> + <key>PROJECT_SETTINGS</key> + <dict> + <key>ADVANCED_OPTIONS</key> + <dict> + <key>installer-script.options:hostArchitectures</key> + <array> + <string>x86_64,arm64</string> + </array> + </dict> + <key>BUILD_FORMAT</key> + <integer>0</integer> + <key>BUILD_PATH</key> + <dict> + <key>PATH</key> + <string>.</string> + <key>PATH_TYPE</key> + <integer>1</integer> + </dict> + <key>EXCLUDED_FILES</key> + <array> + <dict> + <key>PATTERNS_ARRAY</key> + <array> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.DS_Store</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + </array> + <key>PROTECTED</key> + <true/> + <key>PROXY_NAME</key> + <string>Remove .DS_Store files</string> + <key>PROXY_TOOLTIP</key> + <string>Remove ".DS_Store" files created by the Finder.</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>PATTERNS_ARRAY</key> + <array> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.pbdevelopment</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + </array> + <key>PROTECTED</key> + <true/> + <key>PROXY_NAME</key> + <string>Remove .pbdevelopment files</string> + <key>PROXY_TOOLTIP</key> + <string>Remove ".pbdevelopment" files created by ProjectBuilder or Xcode.</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>PATTERNS_ARRAY</key> + <array> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>CVS</string> + <key>TYPE</key> + <integer>1</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.cvsignore</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.cvspass</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.svn</string> + <key>TYPE</key> + <integer>1</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.git</string> + <key>TYPE</key> + <integer>1</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>.gitignore</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + </array> + <key>PROTECTED</key> + <true/> + <key>PROXY_NAME</key> + <string>Remove SCM metadata</string> + <key>PROXY_TOOLTIP</key> + <string>Remove helper files and folders used by the CVS, SVN or Git Source Code Management systems.</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>PATTERNS_ARRAY</key> + <array> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>classes.nib</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>designable.db</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>info.nib</string> + <key>TYPE</key> + <integer>0</integer> + </dict> + </array> + <key>PROTECTED</key> + <true/> + <key>PROXY_NAME</key> + <string>Optimize nib files</string> + <key>PROXY_TOOLTIP</key> + <string>Remove "classes.nib", "info.nib" and "designable.nib" files within .nib bundles.</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>PATTERNS_ARRAY</key> + <array> + <dict> + <key>REGULAR_EXPRESSION</key> + <false/> + <key>STRING</key> + <string>Resources Disabled</string> + <key>TYPE</key> + <integer>1</integer> + </dict> + </array> + <key>PROTECTED</key> + <true/> + <key>PROXY_NAME</key> + <string>Remove Resources Disabled folders</string> + <key>PROXY_TOOLTIP</key> + <string>Remove "Resources Disabled" folders.</string> + <key>STATE</key> + <true/> + </dict> + <dict> + <key>SEPARATOR</key> + <true/> + </dict> + </array> + <key>NAME</key> + <string>VeraCrypt 1.26.15</string> + <key>PAYLOAD_ONLY</key> + <false/> + <key>TREAT_MISSING_PRESENTATION_DOCUMENTS_AS_WARNING</key> + <false/> + </dict> + </dict> + <key>SHARED_GLOBAL_DATA</key> + <dict> + <key>IC_REQUIREMENT_JAVASCRIPT_SHARED_SOURCE_CODE</key> + <string></string> + </dict> + <key>TYPE</key> + <integer>0</integer> + <key>VERSION</key> + <integer>2</integer> +</dict> +</plist> diff --git a/src/Setup/Portable.manifest b/src/Setup/Portable.manifest index 5d4cb896..79d86799 100644 --- a/src/Setup/Portable.manifest +++ b/src/Setup/Portable.manifest @@ -1,33 +1,39 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="asInvoker" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
\ No newline at end of file diff --git a/src/Setup/Portable.rc b/src/Setup/Portable.rc index 9ccbc605..f62e9da0 100644 --- a/src/Setup/Portable.rc +++ b/src/Setup/Portable.rc @@ -1,134 +1,135 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" #include "..\\common\\resource.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (United States) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Portable" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt Portable.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END ///////////////////////////////////////////////////////////////////////////// // // HEADER // IDR_SETUP_RSRC_HEADER HEADER "resource.h" ///////////////////////////////////////////////////////////////////////////// // ///////////////////////////////////////////////////////////////////////////// // // LANGUAGES // IDR_LANG_AR LANGUAGES "..\\..\\Translations\\Language.ar.xml" IDR_LANG_CS LANGUAGES "..\\..\\Translations\\Language.cs.xml" IDR_LANG_DE LANGUAGES "..\\..\\Translations\\Language.de.xml" IDR_LANG_ES LANGUAGES "..\\..\\Translations\\Language.es.xml" IDR_LANG_FR LANGUAGES "..\\..\\Translations\\Language.fr.xml" IDR_LANG_IT LANGUAGES "..\\..\\Translations\\Language.it.xml" IDR_LANG_JA LANGUAGES "..\\..\\Translations\\Language.ja.xml" IDR_LANG_NL LANGUAGES "..\\..\\Translations\\Language.nl.xml" IDR_LANG_PL LANGUAGES "..\\..\\Translations\\Language.pl.xml" IDR_LANG_RO LANGUAGES "..\\..\\Translations\\Language.ro.xml" IDR_LANG_RU LANGUAGES "..\\..\\Translations\\Language.ru.xml" IDR_LANG_VI LANGUAGES "..\\..\\Translations\\Language.vi.xml" IDR_LANG_ZHCN LANGUAGES "..\\..\\Translations\\Language.zh-cn.xml" IDR_LANG_ZHHK LANGUAGES "..\\..\\Translations\\Language.zh-hk.xml" IDR_LANG_BE LANGUAGES "..\\..\\Translations\\Language.be.xml" IDR_LANG_BG LANGUAGES "..\\..\\Translations\\Language.bg.xml" IDR_LANG_CA LANGUAGES "..\\..\\Translations\\Language.ca.xml" IDR_LANG_CO LANGUAGES "..\\..\\Translations\\Language.co.xml" IDR_LANG_DA LANGUAGES "..\\..\\Translations\\Language.da.xml" IDR_LANG_EL LANGUAGES "..\\..\\Translations\\Language.el.xml" IDR_LANG_ET LANGUAGES "..\\..\\Translations\\Language.et.xml" IDR_LANG_EU LANGUAGES "..\\..\\Translations\\Language.eu.xml" IDR_LANG_FA LANGUAGES "..\\..\\Translations\\Language.fa.xml" IDR_LANG_FI LANGUAGES "..\\..\\Translations\\Language.fi.xml" IDR_LANG_HE LANGUAGES "..\\..\\Translations\\Language.he.xml" IDR_LANG_HU LANGUAGES "..\\..\\Translations\\Language.hu.xml" IDR_LANG_ID LANGUAGES "..\\..\\Translations\\Language.id.xml" IDR_LANG_KA LANGUAGES "..\\..\\Translations\\Language.ka.xml" IDR_LANG_KO LANGUAGES "..\\..\\Translations\\Language.ko.xml" IDR_LANG_LV LANGUAGES "..\\..\\Translations\\Language.lv.xml" +IDR_LANG_NB LANGUAGES "..\\..\\Translations\\Language.nb.xml" IDR_LANG_NN LANGUAGES "..\\..\\Translations\\Language.nn.xml" IDR_LANG_PTBR LANGUAGES "..\\..\\Translations\\Language.pt-br.xml" IDR_LANG_SK LANGUAGES "..\\..\\Translations\\Language.sk.xml" IDR_LANG_SL LANGUAGES "..\\..\\Translations\\Language.sl.xml" IDR_LANG_SV LANGUAGES "..\\..\\Translations\\Language.sv.xml" IDR_LANG_TH LANGUAGES "..\\..\\Translations\\Language.th.xml" IDR_LANG_TR LANGUAGES "..\\..\\Translations\\Language.tr.xml" IDR_LANG_UK LANGUAGES "..\\..\\Translations\\Language.uk.xml" IDR_LANG_UZ LANGUAGES "..\\..\\Translations\\Language.uz.xml" IDR_LANG_ZHTW LANGUAGES "..\\..\\Translations\\Language.zh-tw.xml" ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 217, 156 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "",IDC_BOX_HELP,0,10,217,146 END IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 346, 152 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_LICENSE_TEXT,"RichEdit20W",WS_BORDER | WS_VSCROLL | WS_TABSTOP | 0x2804,0,23,345,108 CONTROL "",IDC_AGREE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,2,137,126,10 LTEXT "",IDC_BOX_HELP,0,0,346,22 diff --git a/src/Setup/Portable.vcxproj b/src/Setup/Portable.vcxproj index 92d349bc..1c758b2b 100644 --- a/src/Setup/Portable.vcxproj +++ b/src/Setup/Portable.vcxproj @@ -81,175 +81,175 @@ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptPortable</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptPortable</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">VeraCryptPortable</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptPortable</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> <UACExecutionLevel>AsInvoker</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Portable.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy PortableDebug\VeraCryptPortable.exe "..\Debug\Setup Files\VeraCrypt Portable.exe" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> <UACExecutionLevel>AsInvoker</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;PORTABLE;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> <UACExecutionLevel>AsInvoker</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;PORTABLE;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> <UACExecutionLevel>AsInvoker</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="Dir.c" /> <ClCompile Include="SelfExtract.c" /> <ClCompile Include="Setup.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> </ClCompile> <ClCompile Include="Wizard.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> diff --git a/src/Setup/Portable_vs2019.vcxproj b/src/Setup/Portable_vs2019.vcxproj new file mode 100644 index 00000000..8b2e4cf5 --- /dev/null +++ b/src/Setup/Portable_vs2019.vcxproj @@ -0,0 +1,328 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseCustomEFI|Win32"> + <Configuration>ReleaseCustomEFI</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release_SkipOsDriverReqCheck|Win32"> + <Configuration>Release_SkipOsDriverReqCheck</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}</ProjectGuid> + <RootNamespace>Portable</RootNamespace> + <Keyword>Win32Proj</Keyword> + <ProjectName>Portable</ProjectName> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)PortableDebug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)PortableDebug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> + <EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EmbedManifest> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)PortableRelease\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">$(ProjectDir)PortableRelease\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)PortableRelease\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)PortableRelease\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">$(ProjectDir)PortableRelease\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)PortableRelease\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</GenerateManifest> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptPortable</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptPortable</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">VeraCryptPortable</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptPortable</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>libcmtd.lib;atls.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> + <UACExecutionLevel>AsInvoker</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)Portable.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> + </Link> + <Manifest> + <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>md "..\Debug\Setup Files" 2>NUL: +copy PortableDebug\VeraCryptPortable.exe "..\Debug\Setup Files\VeraCrypt Portable.exe" >NUL: +</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;PORTABLE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>atls.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> + <UACExecutionLevel>AsInvoker</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;PORTABLE;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> + <UACExecutionLevel>AsInvoker</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;PORTABLE;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptPortable.exe</OutputFile> + <UACExecutionLevel>AsInvoker</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Portable.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy PortableRelease\VeraCryptPortable.exe "..\Release\Setup Files\VeraCrypt Portable.exe"</Command> + </PostBuildEvent> + <ResourceCompile> + <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ResourceCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="Dir.c" /> + <ClCompile Include="SelfExtract.c" /> + <ClCompile Include="Setup.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="Wizard.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Xml.c" /> + <ClCompile Include="..\Common\BootEncryption.cpp" /> + <ClCompile Include="..\Common\Crc.c" /> + <ClCompile Include="..\Common\Dictionary.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Endian.c" /> + <ClCompile Include="..\Common\Language.c" /> + <ClCompile Include="..\Common\Registry.c" /> + </ItemGroup> + <ItemGroup> + <None Include="Setup.ico" /> + <None Include="..\Common\VeraCrypt.ico" /> + <None Include="VeraCrypt_setup.bmp" /> + <None Include="VeraCrypt_setup_background.bmp" /> + <None Include="..\Common\VeraCrypt_Volume.ico" /> + <None Include="..\Common\Language.xml" /> + <None Include="..\Resources\Texts\License.rtf" /> + <None Include="..\Common\Textual_logo_288dpi.bmp" /> + <None Include="..\Common\Textual_logo_96dpi.bmp" /> + <None Include="..\Common\Textual_logo_background.bmp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h" /> + <ClInclude Include="..\Common\Combo.h" /> + <ClInclude Include="ComSetup.h" /> + <ClInclude Include="..\Common\Crc.h" /> + <ClInclude Include="Dir.h" /> + <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Common\Exception.h" /> + <ClInclude Include="..\Common\Inflate.h" /> + <ClInclude Include="..\Common\Language.h" /> + <ClInclude Include="..\Common\Registry.h" /> + <ClInclude Include="..\Common\Resource.h" /> + <ClInclude Include="Resource.h" /> + <ClInclude Include="SelfExtract.h" /> + <ClInclude Include="Setup.h" /> + <ClInclude Include="..\Common\Tcdefs.h" /> + <ClInclude Include="Wizard.h" /> + </ItemGroup> + <ItemGroup> + <Manifest Include="Portable.manifest" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="..\Common\Common.rc"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</ExcludedFromBuild> + </ResourceCompile> + <ResourceCompile Include="Portable.rc" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/Setup/Portable_vs2019.vcxproj.filters b/src/Setup/Portable_vs2019.vcxproj.filters new file mode 100644 index 00000000..855ecc00 --- /dev/null +++ b/src/Setup/Portable_vs2019.vcxproj.filters @@ -0,0 +1,154 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Source Files\Common"> + <UniqueIdentifier>{876C2050-1694-4F32-AF5D-491C6A43A799}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + <Filter Include="Resource Files\Common"> + <UniqueIdentifier>{17370B4B-2D76-41A9-9828-015FB30054F6}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="Dir.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="SelfExtract.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Setup.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Wizard.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\Xml.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\BootEncryption.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Crc.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dictionary.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Language.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Registry.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Endian.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <None Include="Setup.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup_background.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt_Volume.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\Language.xml"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Resources\Texts\License.rtf"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_288dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_96dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_background.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Combo.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="ComSetup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Crc.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Dir.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Dlgcode.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Exception.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Inflate.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Language.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Registry.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="SelfExtract.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Setup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Tcdefs.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Wizard.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <Manifest Include="Portable.manifest" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="..\Common\Common.rc"> + <Filter>Resource Files\Common</Filter> + </ResourceCompile> + <ResourceCompile Include="Portable.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/Setup/Portable_vs2019.vcxproj.user b/src/Setup/Portable_vs2019.vcxproj.user new file mode 100644 index 00000000..ace9a86a --- /dev/null +++ b/src/Setup/Portable_vs2019.vcxproj.user @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +</Project>
\ No newline at end of file diff --git a/src/Setup/Resource.h b/src/Setup/Resource.h index b5b7d466..62246068 100644 --- a/src/Setup/Resource.h +++ b/src/Setup/Resource.h @@ -16,60 +16,61 @@ #define IDR_LANG_RU 30 #define IDR_LANG_VI 31 #define IDR_LANG_ZHCN 32 #define IDR_LANG_ZHHK 33 #define IDR_LANG_BE 34 #define IDR_LANG_BG 35 #define IDR_LANG_CA 36 #define IDR_LANG_CO 37 #define IDR_LANG_DA 38 #define IDR_LANG_EL 39 #define IDR_LANG_ET 40 #define IDR_LANG_EU 41 #define IDR_LANG_FA 42 #define IDR_LANG_FI 43 #define IDR_LANG_HE 44 #define IDR_LANG_HU 45 #define IDR_LANG_ID 46 #define IDR_LANG_KA 47 #define IDR_LANG_KO 48 #define IDR_LANG_LV 49 #define IDR_LANG_NN 50 #define IDR_LANG_PTBR 51 #define IDR_LANG_SK 52 #define IDR_LANG_SL 53 #define IDR_LANG_SV 54 #define IDR_LANG_TH 55 #define IDR_LANG_TR 56 #define IDR_LANG_UK 57 #define IDR_LANG_UZ 58 #define IDR_LANG_ZHTW 59 +#define IDR_LANG_NB 60 #define IDD_INSTALL 101 #define IDD_INSTALL_OPTIONS_PAGE_DLG 102 #define IDD_UNINSTALL 103 #define IDI_SETUP 104 #define IDR_SETUP_RSRC_HEADER 105 #define IDD_EXTRACTION_OPTIONS_PAGE_DLG 106 #define IDB_SETUP_WIZARD 107 #define IDD_INTRO_PAGE_DLG 108 #define IDB_SETUP_WIZARD_BKG 109 #define IDD_INFO_PAGE_DLG 110 #define IDD_INSTL_DLG 111 #define IDD_WIZARD_MODE_PAGE_DLG 112 #define IDD_PROGRESS_PAGE_DLG 113 #define IDD_DONATIONS_PAGE_DLG 114 #define IDD_INSTALL_LANGUAGE 115 #define IDC_DESTINATION 1000 #define IDC_BOX_TITLE 1001 #define IDC_BROWSE 1002 #define IDC_BOX_INFO 1003 #define IDC_LICENSE 1004 #define IDC_BOX_HELP 1005 #define IDC_LICENSE_TEXT 1006 #define IDC_BOX_HELP2 1007 #define IDC_FILE_TYPE 1008 #define IDT_UNINSTALL_DIR 1009 #define IDC_PROG_GROUP 1010 #define IDC_SYSTEM_RESTORE 1011 #define IDC_DESKTOP_ICON 1012 #define IDC_ALL_USERS 1013 #define IDT_INSTALL_DESTINATION 1014 diff --git a/src/Setup/Setup.c b/src/Setup/Setup.c index 33fcab85..43ea971b 100644 --- a/src/Setup/Setup.c +++ b/src/Setup/Setup.c @@ -47,60 +47,62 @@ using namespace VeraCrypt; #pragma warning( default : 4201 ) #pragma warning( default : 4115 ) #include <Strsafe.h> wchar_t InstallationPath[TC_MAX_PATH]; wchar_t SetupFilesDir[TC_MAX_PATH]; wchar_t UninstallBatch[MAX_PATH]; BOOL bUninstall = FALSE; BOOL bRestartRequired = FALSE; BOOL bMakePackage = FALSE; BOOL bDone = FALSE; BOOL Rollback = FALSE; BOOL bUpgrade = FALSE; BOOL bUpdateRescueDisk = FALSE; BOOL bDowngrade = FALSE; BOOL SystemEncryptionUpdate = FALSE; BOOL PortableMode = FALSE; BOOL bRepairMode = FALSE; BOOL bReinstallMode = FALSE; BOOL bChangeMode = FALSE; BOOL bDevm = FALSE; BOOL bPossiblyFirstTimeInstall = FALSE; BOOL bUninstallInProgress = FALSE; BOOL UnloadDriver = TRUE; BOOL bSystemRestore = TRUE; BOOL bDisableSwapFiles = FALSE; BOOL bForAllUsers = TRUE; +BOOL bDisableMemoryProtection = FALSE; +BOOL bOriginalDisableMemoryProtection = FALSE; BOOL bRegisterFileExt = TRUE; BOOL bAddToStartMenu = TRUE; BOOL bDesktopIcon = TRUE; BOOL bUserSetLanguage = FALSE; BOOL bDesktopIconStatusDetermined = FALSE; HMODULE volatile SystemRestoreDll = 0; extern HMODULE hcrypt32dll; void localcleanup (void) { localcleanupwiz (); cleanup (); CloseAppSetupMutex (); } #define WAIT_PERIOD 3 BOOL StartStopService (HWND hwndDlg, wchar_t *lpszService, BOOL bStart, DWORD argc, LPCWSTR* argv) { SC_HANDLE hManager, hService = NULL; BOOL bOK = FALSE, bRet; SERVICE_STATUS status = {0}; int x; DWORD dwExpectedState = bStart? SERVICE_RUNNING : SERVICE_STOPPED; @@ -543,80 +545,67 @@ HRESULT CreateLink (wchar_t *lpszPathObj, wchar_t *lpszArguments, propStore->Release(); } } /* Query IShellLink for the IPersistFile interface for saving the shortcut in persistent storage. */ hres = psl->QueryInterface (IID_IPersistFile, (void **) &ppf); if (SUCCEEDED (hres)) { /* Save the link by calling IPersistFile::Save. */ hres = ppf->Save (lpszPathLink, TRUE); ppf->Release (); } psl->Release (); } return hres; } BOOL IsSystemRestoreEnabled () { BOOL bEnabled = FALSE; HKEY hKey; DWORD dwValue = 0, cbValue = sizeof (DWORD); wchar_t szRegPath[MAX_PATH]; GetRestorePointRegKeyName (szRegPath, sizeof (szRegPath)); if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegPath, 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS) { - if (IsOSAtLeast (WIN_VISTA)) - { - if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) - && (dwValue == 1) - ) - { - bEnabled = TRUE; - } - } - else + if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) + && (dwValue == 1) + ) { - if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) - && (dwValue == 0) - ) - { - bEnabled = TRUE; - } + bEnabled = TRUE; } - RegCloseKey (hKey); } return bEnabled; } void GetProgramPath (HWND hwndDlg, wchar_t *path) { ITEMIDLIST *i; HRESULT res; if (bForAllUsers) res = SHGetSpecialFolderLocation (hwndDlg, CSIDL_COMMON_PROGRAMS, &i); else res = SHGetSpecialFolderLocation (hwndDlg, CSIDL_PROGRAMS, &i); SHGetPathFromIDList (i, path); } void StatusMessage (HWND hwndDlg, char *stringId) { if (Rollback) return; SendMessageW (GetDlgItem (hwndDlg, IDC_LOG_WINDOW), LB_ADDSTRING, 0, (LPARAM) GetString (stringId)); SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_SETTOPINDEX, SendDlgItemMessage (hwndDlg, IDC_LOG_WINDOW, LB_GETCOUNT, 0, 0) - 1, 0); } @@ -1330,67 +1319,64 @@ BOOL DoRegInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bInstallType) StringCbCopyW (szTmp, sizeof(szTmp), _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); if (RegSetValueEx (hkey, L"DisplayVersion", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; StringCbCopyW (szTmp, sizeof(szTmp), L"VeraCrypt"); if (RegSetValueEx (hkey, L"DisplayName", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; StringCbCopyW (szTmp, sizeof(szTmp), L"IDRIX"); if (RegSetValueEx (hkey, L"Publisher", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; StringCbCopyW (szTmp, sizeof(szTmp), TC_HOMEPAGE); if (RegSetValueEx (hkey, L"URLInfoAbout", 0, REG_SZ, (BYTE *) szTmp, (wcslen (szTmp) + 1) * sizeof (wchar_t)) != ERROR_SUCCESS) goto error; bOK = TRUE; error: if (hkey != 0) RegCloseKey (hkey); if (bOK == FALSE) { handleWin32Error (hwndDlg, SRC_POS); Error ("REG_INSTALL_FAILED", hwndDlg); } // Register COM servers for UAC - if (IsOSAtLeast (WIN_VISTA)) + if (!RegisterComServers (szDir)) { - if (!RegisterComServers (szDir)) - { - Error ("COM_REG_FAILED", hwndDlg); - return FALSE; - } + Error ("COM_REG_FAILED", hwndDlg); + return FALSE; } return bOK; } BOOL DoApplicationDataUninstall (HWND hwndDlg) { wchar_t path[MAX_PATH]; wchar_t path2[MAX_PATH]; BOOL bOK = TRUE; StatusMessage (hwndDlg, "REMOVING_APPDATA"); SHGetFolderPath (NULL, CSIDL_APPDATA, NULL, 0, path); StringCbCatW (path, sizeof(path), L"\\VeraCrypt\\"); // Delete favorite volumes file StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_FAVORITE_VOLUMES); RemoveMessage (hwndDlg, path2); StatDeleteFile (path2, FALSE); // Delete keyfile defaults StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_DEFAULT_KEYFILES); RemoveMessage (hwndDlg, path2); StatDeleteFile (path2, FALSE); // Delete history file StringCbPrintfW (path2, sizeof(path2), L"%s%s", path, TC_APPD_FILENAME_HISTORY); RemoveMessage (hwndDlg, path2); StatDeleteFile (path2, FALSE); @@ -1409,129 +1395,112 @@ BOOL DoApplicationDataUninstall (HWND hwndDlg) StringCbCatW (path, sizeof(path), L"\\VeraCrypt"); RemoveMessage (hwndDlg, path); if (!StatRemoveDirectory (path)) { handleWin32Error (hwndDlg, SRC_POS); bOK = FALSE; } // remove VeraCrypt under common appdata if (SUCCEEDED (SHGetFolderPath (NULL, CSIDL_COMMON_APPDATA | CSIDL_FLAG_CREATE, NULL, 0, path))) { StringCbCatW (path, sizeof(path), L"\\VeraCrypt"); // Delete original bootloader StringCbPrintfW (path2, sizeof(path2), L"%s\\%s", path, TC_SYS_BOOT_LOADER_BACKUP_NAME); RemoveMessage (hwndDlg, path2); StatDeleteFile (path2, FALSE); // remove VeraCrypt folder RemoveMessage (hwndDlg, path); StatRemoveDirectory (path); } return bOK; } BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated) { wchar_t regk [64]; - typedef LSTATUS (WINAPI *RegDeleteKeyExWFn) (HKEY hKey,LPCWSTR lpSubKey,REGSAM samDesired,WORD Reserved); - RegDeleteKeyExWFn RegDeleteKeyExWPtr = NULL; - HMODULE hAdvapiDll = LoadLibrary (L"Advapi32.dll"); - if (hAdvapiDll) - { - RegDeleteKeyExWPtr = (RegDeleteKeyExWFn) GetProcAddress(hAdvapiDll, "RegDeleteKeyExW"); - } // Unregister COM servers - if (!bRemoveDeprecated && IsOSAtLeast (WIN_VISTA)) + if (!bRemoveDeprecated) { if (!UnregisterComServers (InstallationPath)) StatusMessage (hwndDlg, "COM_DEREG_FAILED"); } if (!bRemoveDeprecated) StatusMessage (hwndDlg, "REMOVING_REG"); - if (RegDeleteKeyExWPtr) - { - RegDeleteKeyExWPtr (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", KEY_WOW64_32KEY, 0); - RegDeleteKeyExWPtr (HKEY_CURRENT_USER, L"Software\\VeraCrypt", KEY_WOW64_32KEY, 0); - } - else - { - RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt"); - RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt"); - } + RegDeleteKeyExW (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", KEY_WOW64_32KEY, 0); + RegDeleteKeyExW (HKEY_CURRENT_USER, L"Software\\VeraCrypt", KEY_WOW64_32KEY, 0); + RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open\\command"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\DefaultIcon"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume"); if (!bRemoveDeprecated) { HKEY hKey; GetStartupRegKeyName (regk, sizeof(regk)); DeleteRegistryValue (regk, L"VeraCrypt"); DeleteRegistryKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\.hc"); // enable the SE_TAKE_OWNERSHIP_NAME privilege for this operation SetPrivilege (SE_TAKE_OWNERSHIP_NAME, TRUE); // clean MuiCache list from VeraCrypt entries SearchAndDeleteRegistrySubString (HKEY_CLASSES_ROOT, L"Local Settings\\Software\\Microsoft\\Windows\\Shell\\MuiCache", L"VeraCrypt", FALSE, NULL); // clean other VeraCrypt entries from all users SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\FileExts\\.hc", NULL, TRUE, NULL); SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\AppCompatFlags\\Compatibility Assistant\\Persisted", L"VeraCrypt", TRUE, NULL); SearchAndDeleteRegistrySubString (HKEY_USERS, L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\StartPage\\NewShortcuts", L"VeraCrypt", TRUE, NULL); if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SYSTEM", 0, KEY_ALL_ACCESS | WRITE_DAC | WRITE_OWNER, &hKey) == ERROR_SUCCESS) { SearchAndDeleteRegistrySubString (hKey, L"Enum\\Root\\LEGACY_VERACRYPT", NULL, TRUE, L"ControlSet"); SearchAndDeleteRegistrySubString (hKey, L"services\\veracrypt", NULL, TRUE, L"ControlSet"); RegCloseKey(hKey); } // disable the SE_TAKE_OWNERSHIP_NAME privilege for this operation SetPrivilege (SE_TAKE_OWNERSHIP_NAME, FALSE); SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); } - if (hAdvapiDll) - FreeLibrary (hAdvapiDll); - return TRUE; } BOOL DoServiceUninstall (HWND hwndDlg, wchar_t *lpszService) { SC_HANDLE hManager, hService = NULL; BOOL bOK = FALSE, bRet; SERVICE_STATUS status; BOOL firstTry = TRUE; int x; memset (&status, 0, sizeof (status)); /* Keep VC6 quiet */ retry: hManager = OpenSCManager (NULL, NULL, SC_MANAGER_ALL_ACCESS); if (hManager == NULL) goto error; hService = OpenService (hManager, lpszService, SERVICE_ALL_ACCESS); if (hService == NULL) goto error; if (wcscmp (L"veracrypt", lpszService) == 0) { try { BootEncryption bootEnc (hwndDlg); if (bootEnc.GetDriverServiceStartType() == SERVICE_BOOT_START) @@ -2020,60 +1989,91 @@ BOOL DoShortcutsInstall (HWND hwndDlg, wchar_t *szDestDir, BOOL bProgGroup, BOOL if (szDestDir[x - 1] == L'\\') bSlash = TRUE; else bSlash = FALSE; if (bSlash == FALSE) StringCbCatW (szDir, sizeof(szDir), L"\\"); if (bForAllUsers) SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_COMMON_DESKTOPDIRECTORY, 0); else SHGetSpecialFolderPath (hwndDlg, szLinkDir, CSIDL_DESKTOPDIRECTORY, 0); StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szDir, L"VeraCrypt.exe"); StringCbPrintfW (szTmp2, sizeof(szTmp2), L"%s%s", szLinkDir, L"\\VeraCrypt.lnk"); IconMessage (hwndDlg, szTmp2); if (CreateLink (szTmp, L"", szTmp2, NULL, -1) != S_OK) goto error; } bOK = TRUE; error: OleUninitialize (); return bOK; } +void RemoveLegacyFiles (wchar_t *szDestDir) +{ + const wchar_t* oldFileNames[] = { + L"docs\\html\\en\\BCH_Logo_48x30.png", + L"docs\\html\\en\\LinuxPrepAndBuild.sh", + L"docs\\html\\en\\LinuxPrepAndBuild.zip", + L"docs\\html\\en\\RIPEMD-160.html", + L"docs\\html\\en\\ru\\BCH_Logo_48x30.png", + L"Languages\\Language.ru - Copy.xml", + }; + wchar_t szDir[TC_MAX_PATH]; + wchar_t oldPath[TC_MAX_PATH]; + BOOL bSlash; + size_t x, i; + + StringCbCopyW (szDir, sizeof(szDir), szDestDir); + x = wcslen (szDestDir); + if (szDestDir[x - 1] == L'\\') + bSlash = TRUE; + else + bSlash = FALSE; + + if (bSlash == FALSE) + StringCbCatW (szDir, sizeof(szDir), L"\\"); + + for (i = 0; i < ARRAYSIZE(oldFileNames); i++) + { + StringCbPrintfW (oldPath, sizeof(oldPath), L"%s%s", szDestDir, oldFileNames[i]); + StatDeleteFile (oldPath, FALSE); + } +} void OutcomePrompt (HWND hwndDlg, BOOL bOK) { if (bOK) { EnableWindow (GetDlgItem ((HWND) hwndDlg, IDCANCEL), FALSE); bDone = TRUE; if (bUninstall == FALSE) { if (bDevm) PostMessage (MainDlg, WM_CLOSE, 0, 0); else if (bPossiblyFirstTimeInstall || bRepairMode || (!bUpgrade && !bDowngrade)) Info ("INSTALL_OK", hwndDlg); else Info ("SETUP_UPDATE_OK", hwndDlg); } else { wchar_t str[4096]; StringCbPrintfW (str, sizeof(str), GetString ("UNINSTALL_OK"), InstallationPath); MessageBoxW (hwndDlg, str, lpszTitle, MB_ICONASTERISK); } } else { if (bUninstall == FALSE) Error ("INSTALL_FAILED", hwndDlg); @@ -2203,61 +2203,60 @@ void DoUninstall (void *arg) ); CheckFileStreamWriteErrors (hwndDlg, f, UninstallBatch); fclose (f); } } } NormalCursor (); if (Rollback) return; if (bSystemRestore && !bTempSkipSysRestore) SetSystemRestorePoint (hwndDlg, TRUE); if (bOK) PostMessage (hwndDlg, TC_APPMSG_UNINSTALL_SUCCESS, 0, 0); else bUninstallInProgress = FALSE; EnableWindow (GetDlgItem ((HWND) hwndDlg, IDC_UNINSTALL), TRUE); OutcomePrompt (hwndDlg, bOK); } void DoInstall (void *arg) { HWND hwndDlg = (HWND) arg; BOOL bOK = TRUE; wchar_t path[MAX_PATH]; - BootEncryption bootEnc (hwndDlg); // Refresh the main GUI (wizard thread) InvalidateRect (MainDlg, NULL, TRUE); ClearLogWindow (hwndDlg); if (isMsiInstalled()) { MessageBoxW (hwndDlg, GetString ("CANT_INSTALL_WITH_EXE_OVER_MSI"), lpszTitle, MB_ICONHAND); Error ("INSTALL_FAILED", hwndDlg); PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0); return; } if (mkfulldir (InstallationPath, TRUE) != 0) { if (mkfulldir (InstallationPath, FALSE) != 0) { wchar_t szTmp[TC_MAX_PATH]; handleWin32Error (hwndDlg, SRC_POS); StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CANT_CREATE_FOLDER"), InstallationPath); MessageBoxW (hwndDlg, szTmp, lpszTitle, MB_ICONHAND); Error ("INSTALL_FAILED", hwndDlg); PostMessage (MainDlg, TC_APPMSG_INSTALL_FAILURE, 0, 0); return; } } @@ -2341,60 +2340,72 @@ void DoInstall (void *arg) bOK = FALSE; } else if (UpdateProgressBarProc(85) && UnloadDriver && DoDriverInstall (hwndDlg) == FALSE) { bOK = FALSE; } else if (UpdateProgressBarProc(90) && SystemEncryptionUpdate && UpgradeBootLoader (hwndDlg) == FALSE) { bOK = FALSE; } else if (UpdateProgressBarProc(93) && DoShortcutsInstall (hwndDlg, InstallationPath, bAddToStartMenu, bDesktopIcon) == FALSE) { bOK = FALSE; } if (!UnloadDriver) bRestartRequired = TRUE; try { bootEnc.RenameDeprecatedSystemLoaderBackup(); } catch (...) { } if (bOK) UpdateProgressBarProc(97); if (bSystemRestore) SetSystemRestorePoint (hwndDlg, TRUE); + if (bOK && (bDisableMemoryProtection != bOriginalDisableMemoryProtection)) + { + WriteMemoryProtectionConfig(bDisableMemoryProtection? FALSE : TRUE); + bRestartRequired = TRUE; // Restart is required to apply the new memory protection settings + } + + if (bOK && bUpgrade) + { + // delete legacy files + RemoveLegacyFiles (InstallationPath); + } + if (bOK) { UpdateProgressBarProc(100); UninstallBatch[0] = 0; StatusMessage (hwndDlg, "INSTALL_COMPLETED"); } else { UpdateProgressBarProc(0); if (!SystemEncryptionUpdate) { bUninstall = TRUE; Rollback = TRUE; Silent = TRUE; DoUninstall (hwndDlg); bUninstall = FALSE; Rollback = FALSE; Silent = FALSE; StatusMessage (hwndDlg, "ROLLBACK"); } else { Warning ("SYS_ENC_UPGRADE_FAILED", hwndDlg); } } @@ -2576,76 +2587,77 @@ typedef struct WORD langid; LPCSTR internalId; LPCWSTR langtag; } tLanguageEntry; static tLanguageEntry g_languagesEntries[] = { {L"العربية", IDR_LANG_AR, LANG_ARABIC, "ar", NULL}, {L"БеларуÑкаÑ", IDR_LANG_BE, LANG_BELARUSIAN, "be", NULL}, {L"БългарÑки", IDR_LANG_BG, LANG_BULGARIAN, "bg", NULL}, {L"Català ", IDR_LANG_CA, LANG_CATALAN, "ca", NULL}, {L"Corsu", IDR_LANG_CO, LANG_CORSICAN, "co", NULL}, {L"ÄŒeÅ¡tina", IDR_LANG_CS, LANG_CZECH, "cs", NULL}, {L"Dansk", IDR_LANG_DA, LANG_DANISH, "da", NULL}, {L"Deutsch", IDR_LANG_DE, LANG_GERMAN, "de", NULL}, {L"Ελληνικά", IDR_LANG_EL, LANG_GREEK, "el", NULL}, {L"English", IDR_LANGUAGE, LANG_ENGLISH, "en", NULL}, {L"Español", IDR_LANG_ES, LANG_SPANISH, "es", NULL}, {L"Eesti", IDR_LANG_ET, LANG_ESTONIAN, "et", NULL}, {L"Euskara", IDR_LANG_EU, LANG_BASQUE, "eu", NULL}, {L"Ùارسي", IDR_LANG_FA, LANG_PERSIAN, "fa", NULL}, {L"Suomi", IDR_LANG_FI, LANG_FINNISH, "fi", NULL}, {L"Français", IDR_LANG_FR, LANG_FRENCH, "fr", NULL}, {L"עברית", IDR_LANG_HE, LANG_HEBREW, "he", NULL}, {L"Magyar", IDR_LANG_HU, LANG_HUNGARIAN, "hu", NULL}, {L"Bahasa Indonesia", IDR_LANG_ID, LANG_INDONESIAN, "id", NULL}, {L"Italiano", IDR_LANG_IT, LANG_ITALIAN, "it", NULL}, {L"日本語", IDR_LANG_JA, LANG_JAPANESE, "ja", NULL}, {L"ქáƒáƒ თული", IDR_LANG_KA, LANG_GEORGIAN, "ka", NULL}, {L"í•œêµì–´", IDR_LANG_KO, LANG_KOREAN, "ko", NULL}, {L"LatvieÅ¡u", IDR_LANG_LV, LANG_LATVIAN, "lv", NULL}, + {L"Norsk BokmÃ¥l", IDR_LANG_NB, LANG_NORWEGIAN, "nb", NULL}, {L"Nederlands", IDR_LANG_NL, LANG_DUTCH, "nl", NULL}, {L"Norsk Nynorsk", IDR_LANG_NN, LANG_NORWEGIAN, "nn", NULL}, {L"Polski", IDR_LANG_PL, LANG_POLISH, "pl", NULL}, {L"Română", IDR_LANG_RO, LANG_ROMANIAN, "ro", NULL}, {L"РуÑÑкий", IDR_LANG_RU, LANG_RUSSIAN, "ru", NULL}, {L"Português-Brasil", IDR_LANG_PTBR, LANG_PORTUGUESE, "pt-br", L"pt-BR"}, {L"SlovenÄina", IDR_LANG_SK, LANG_SLOVAK, "sk", NULL}, {L"SlovenÅ¡Äina", IDR_LANG_SL, LANG_SLOVENIAN, "sl", NULL}, {L"Svenska", IDR_LANG_SV, LANG_SWEDISH, "sv", NULL}, {L"ภาษาไทย", IDR_LANG_TH, LANG_THAI, "th", NULL}, {L"Türkçe", IDR_LANG_TR, LANG_TURKISH, "tr", NULL}, {L"УкраїнÑька", IDR_LANG_UK, LANG_UKRAINIAN, "uk", NULL}, {L"Ўзбекча", IDR_LANG_UZ, LANG_UZBEK, "uz", NULL}, {L"Tiếng Việt", IDR_LANG_VI, LANG_VIETNAMESE, "vi", NULL}, {L"简体ä¸æ–‡", IDR_LANG_ZHCN, LANG_CHINESE, "zh-cn", L"zh-CN"}, - {L"ç¹é«”ä¸æ–‡", IDR_LANG_ZHHK, LANG_CHINESE, "zh-hk", L"zh-HK"}, + {L"ç¹é«”ä¸æ–‡(香港)", IDR_LANG_ZHHK, LANG_CHINESE, "zh-hk", L"zh-HK"}, {L"ç¹é«”ä¸æ–‡", IDR_LANG_ZHTW, LANG_CHINESE, "zh-tw", L"zh-TW"}, }; typedef int (WINAPI *LCIDToLocaleNameFn)( LCID Locale, LPWSTR lpName, int cchName, DWORD dwFlags); static void UpdateSelectLanguageDialog (HWND hwndDlg) { HWND hLangList = GetDlgItem (hwndDlg, IDC_LANGUAGES_LIST); LPARAM nIndex = SendMessage (hLangList, CB_GETCURSEL, 0, 0); int resourceid = (int) SendMessage (hLangList, CB_GETITEMDATA, nIndex, 0); BOOL bVal; LoadLanguageFromResource (resourceid, TRUE, TRUE); bVal = LocalizationActive; LocalizationActive = TRUE; LocalizeDialog (hwndDlg, "IDD_INSTL_DLG"); InvalidateRect (hwndDlg, NULL, FALSE); LocalizationActive = bVal; } BOOL CALLBACK SelectLanguageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { WORD lw = LOWORD (wParam); switch (uMsg) @@ -2755,178 +2767,173 @@ int WINAPI wWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, wchar_t *lpsz bChangeMode = TRUE; } else #endif if (lpszCommandLine[1] == L'p') { // Create self-extracting package: /p bMakePackage = TRUE; } else if (lpszCommandLine[1] == L'd') { // Dev mode: /d bDevm = TRUE; } } #ifdef PORTABLE lpszTitle = L"VeraCrypt Portable"; #else lpszTitle = L"VeraCrypt Setup"; #endif /* Call InitApp to initialize the common code */ InitApp (hInstance, NULL); #ifndef PORTABLE if (IsAdmin () != TRUE) if (MessageBoxW (NULL, GetString ("SETUP_ADMIN"), lpszTitle, MB_YESNO | MB_ICONQUESTION) != IDYES) { - FinalizeApp (); exit (1); } #endif /* Setup directory */ { wchar_t *s; GetModuleFileName (NULL, SetupFilesDir, ARRAYSIZE (SetupFilesDir)); s = wcsrchr (SetupFilesDir, L'\\'); if (s) s[1] = 0; } if (bMakePackage) { /* Create self-extracting package */ MakeSelfExtractingPackage (NULL, SetupFilesDir, FALSE); } else { #ifndef PORTABLE SetInstallationPath (NULL); #endif if (bUninstall) { wchar_t path [TC_MAX_PATH]; GetModuleFileName (NULL, path, ARRAYSIZE (path)); if (!VerifyModuleSignature (path)) { Error ("DIST_PACKAGE_CORRUPTED", NULL); exit (1); } } else { if (IsSelfExtractingPackage()) { if (!VerifySelfPackageIntegrity()) { // Package corrupted exit (1); } bDevm = FALSE; } else if (!bDevm) { #ifndef PORTABLE MessageBox (NULL, L"Error: This installer file does not contain any compressed files.\n\nTo create a self-extracting installation package (with embedded compressed files), run:\n\"VeraCrypt Setup.exe\" /p", L"VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST); #else MessageBox (NULL, L"Error: This portable installer file does not contain any compressed files.\n\nTo create a self-extracting portable installation package (with embedded compressed files), run:\n\"VeraCrypt Portable.exe\" /p", L"VeraCrypt", MB_ICONERROR | MB_SETFOREGROUND | MB_TOPMOST); #endif - FinalizeApp (); exit (1); } #ifndef PORTABLE if (bChangeMode) { /* VeraCrypt is already installed on this system and we were launched from the Program Files folder */ char *tmpStr[] = {0, "SELECT_AN_ACTION", "REPAIR_REINSTALL", "UNINSTALL", "EXIT", 0}; // Ask the user to select either Repair or Unistallation switch (AskMultiChoice ((void **) tmpStr, FALSE, NULL)) { case 1: bRepairMode = TRUE; break; case 2: bUninstall = TRUE; break; default: - FinalizeApp (); exit (1); } } #endif } #ifndef PORTABLE // System Restore if (IsSystemRestoreEnabled ()) { wchar_t dllPath[MAX_PATH]; if (GetSystemDirectory (dllPath, MAX_PATH)) { StringCbCatW(dllPath, sizeof(dllPath), L"\\srclient.dll"); } else StringCbCopyW(dllPath, sizeof(dllPath), L"C:\\Windows\\System32\\srclient.dll"); SystemRestoreDll = LoadLibrary (dllPath); } else SystemRestoreDll = 0; #endif if (!bUninstall) { - if (!bDevm && !LocalizationActive && (nCurrentOS >= WIN_VISTA)) + if (!bDevm && !LocalizationActive) { BOOL bHasPreferredLanguage = (strlen (GetPreferredLangId ()) > 0)? TRUE : FALSE; if ((IDCANCEL == DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_INSTALL_LANGUAGE), NULL, (DLGPROC) SelectLanguageDialogProc, (LPARAM) 0 )) && !bHasPreferredLanguage ) { // Language dialog cancelled by user: exit the installer - FinalizeApp (); exit (1); } } /* Create the main dialog for install */ DialogBoxParamW (hInstance, MAKEINTRESOURCEW (IDD_INSTL_DLG), NULL, (DLGPROC) MainDialogProc, (LPARAM)lpszCommandLine); } #ifndef PORTABLE else { /* Create the main dialog for uninstall */ DialogBoxW (hInstance, MAKEINTRESOURCEW (IDD_UNINSTALL), NULL, (DLGPROC) UninstallDlgProc); if (UninstallBatch[0]) { STARTUPINFO si; PROCESS_INFORMATION pi; ZeroMemory (&si, sizeof (si)); si.cb = sizeof (si); si.dwFlags = STARTF_USESHOWWINDOW; si.wShowWindow = SW_HIDE; if (!CreateProcess (UninstallBatch, NULL, NULL, NULL, FALSE, IDLE_PRIORITY_CLASS, NULL, NULL, &si, &pi)) DeleteFile (UninstallBatch); else { CloseHandle (pi.hProcess); CloseHandle (pi.hThread); } } } #endif } - FinalizeApp (); return 0; } diff --git a/src/Setup/Setup.h b/src/Setup/Setup.h index e38dd75a..70a04555 100644 --- a/src/Setup/Setup.h +++ b/src/Setup/Setup.h @@ -93,45 +93,47 @@ void IconMessage ( HWND hwndDlg , const wchar_t *txt ); static int CALLBACK BrowseCallbackProc ( HWND hwnd , UINT uMsg , LPARAM lp , LPARAM pData ); void LoadLicense ( HWND hwndDlg ); void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersionPtr); BOOL DoFilesInstall ( HWND hwndDlg , wchar_t *szDestDir ); BOOL DoRegInstall ( HWND hwndDlg , wchar_t *szDestDir , BOOL bInstallType ); BOOL DoRegUninstall (HWND hwndDlg, BOOL bRemoveDeprecated); BOOL DoServiceUninstall ( HWND hwndDlg , wchar_t *lpszService ); BOOL DoDriverUnload ( HWND hwndDlg ); BOOL DoShortcutsInstall ( HWND hwndDlg , wchar_t *szDestDir , BOOL bProgGroup, BOOL bDesktopIcon ); BOOL DoShortcutsUninstall (HWND hwndDlg, wchar_t *szDestDir); void OutcomePrompt ( HWND hwndDlg , BOOL bOK ); void DoUninstall ( void *hwndDlg ); void DoInstall ( void *hwndDlg ); void SetInstallationPath (HWND hwndDlg); BOOL UpgradeBootLoader (HWND hwndDlg); BOOL CALLBACK InstallDlgProc ( HWND hwndDlg , UINT msg , WPARAM wParam , LPARAM lParam ); #ifdef VC_EFI_CUSTOM_MODE BOOL CheckSecureBootCompatibility (HWND hWnd); #endif extern BOOL bDevm; extern BOOL Rollback; extern BOOL bUpgrade; extern BOOL bUpdateRescueDisk; extern BOOL bPossiblyFirstTimeInstall; extern BOOL bRepairMode; extern BOOL bReinstallMode; extern BOOL bSystemRestore; extern BOOL bDisableSwapFiles; extern BOOL bForAllUsers; +extern BOOL bDisableMemoryProtection; +extern BOOL bOriginalDisableMemoryProtection; extern BOOL bRegisterFileExt; extern BOOL bAddToStartMenu; extern BOOL bDesktopIcon; extern BOOL bDesktopIconStatusDetermined; extern BOOL SystemEncryptionUpdate; extern BOOL bRestartRequired; extern HMODULE volatile SystemRestoreDll; extern wchar_t InstallationPath[TC_MAX_PATH]; extern wchar_t SetupFilesDir[TC_MAX_PATH]; #ifdef __cplusplus } #endif #endif // #ifndef SETUP_H diff --git a/src/Setup/Setup.manifest b/src/Setup/Setup.manifest index afd4c1c0..abc1ef65 100644 --- a/src/Setup/Setup.manifest +++ b/src/Setup/Setup.manifest @@ -1,33 +1,39 @@ <?xml version="1.0" encoding="utf-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> <asmv3:application> <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </asmv3:windowsSettings> </asmv3:application> <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> <application> - <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> + <!-- Windows 10 and Windows 11 --> + <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> + <!-- Windows 8.1 --> + <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> + <!-- Windows 8 --> + <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> + <!-- Windows 7 --> <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> </application> </compatibility> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> </assembly>
\ No newline at end of file diff --git a/src/Setup/Setup.rc b/src/Setup/Setup.rc index 677081e8..a0e59660 100644 --- a/src/Setup/Setup.rc +++ b/src/Setup/Setup.rc @@ -1,184 +1,188 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" #include "..\\common\\resource.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCrypt Setup" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCrypt Setup.exe" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END ///////////////////////////////////////////////////////////////////////////// // // HEADER // IDR_SETUP_RSRC_HEADER HEADER "resource.h" ///////////////////////////////////////////////////////////////////////////// // // REGISTRY // IDR_COMREG REGISTRY "ComSetup.rgs" ///////////////////////////////////////////////////////////////////////////// // // LANGUAGES // IDR_LANG_AR LANGUAGES "..\\..\\Translations\\Language.ar.xml" IDR_LANG_CS LANGUAGES "..\\..\\Translations\\Language.cs.xml" IDR_LANG_DE LANGUAGES "..\\..\\Translations\\Language.de.xml" IDR_LANG_ES LANGUAGES "..\\..\\Translations\\Language.es.xml" IDR_LANG_FR LANGUAGES "..\\..\\Translations\\Language.fr.xml" IDR_LANG_IT LANGUAGES "..\\..\\Translations\\Language.it.xml" IDR_LANG_JA LANGUAGES "..\\..\\Translations\\Language.ja.xml" IDR_LANG_NL LANGUAGES "..\\..\\Translations\\Language.nl.xml" IDR_LANG_PL LANGUAGES "..\\..\\Translations\\Language.pl.xml" IDR_LANG_RO LANGUAGES "..\\..\\Translations\\Language.ro.xml" IDR_LANG_RU LANGUAGES "..\\..\\Translations\\Language.ru.xml" IDR_LANG_VI LANGUAGES "..\\..\\Translations\\Language.vi.xml" IDR_LANG_ZHCN LANGUAGES "..\\..\\Translations\\Language.zh-cn.xml" IDR_LANG_ZHHK LANGUAGES "..\\..\\Translations\\Language.zh-hk.xml" IDR_LANG_BE LANGUAGES "..\\..\\Translations\\Language.be.xml" IDR_LANG_BG LANGUAGES "..\\..\\Translations\\Language.bg.xml" IDR_LANG_CA LANGUAGES "..\\..\\Translations\\Language.ca.xml" IDR_LANG_CO LANGUAGES "..\\..\\Translations\\Language.co.xml" IDR_LANG_DA LANGUAGES "..\\..\\Translations\\Language.da.xml" IDR_LANG_EL LANGUAGES "..\\..\\Translations\\Language.el.xml" IDR_LANG_ET LANGUAGES "..\\..\\Translations\\Language.et.xml" IDR_LANG_EU LANGUAGES "..\\..\\Translations\\Language.eu.xml" IDR_LANG_FA LANGUAGES "..\\..\\Translations\\Language.fa.xml" IDR_LANG_FI LANGUAGES "..\\..\\Translations\\Language.fi.xml" IDR_LANG_HE LANGUAGES "..\\..\\Translations\\Language.he.xml" IDR_LANG_HU LANGUAGES "..\\..\\Translations\\Language.hu.xml" IDR_LANG_ID LANGUAGES "..\\..\\Translations\\Language.id.xml" IDR_LANG_KA LANGUAGES "..\\..\\Translations\\Language.ka.xml" IDR_LANG_KO LANGUAGES "..\\..\\Translations\\Language.ko.xml" IDR_LANG_LV LANGUAGES "..\\..\\Translations\\Language.lv.xml" +IDR_LANG_NB LANGUAGES "..\\..\\Translations\\Language.nb.xml" IDR_LANG_NN LANGUAGES "..\\..\\Translations\\Language.nn.xml" IDR_LANG_PTBR LANGUAGES "..\\..\\Translations\\Language.pt-br.xml" IDR_LANG_SK LANGUAGES "..\\..\\Translations\\Language.sk.xml" IDR_LANG_SL LANGUAGES "..\\..\\Translations\\Language.sl.xml" IDR_LANG_SV LANGUAGES "..\\..\\Translations\\Language.sv.xml" IDR_LANG_TH LANGUAGES "..\\..\\Translations\\Language.th.xml" IDR_LANG_TR LANGUAGES "..\\..\\Translations\\Language.tr.xml" IDR_LANG_UK LANGUAGES "..\\..\\Translations\\Language.uk.xml" IDR_LANG_UZ LANGUAGES "..\\..\\Translations\\Language.uz.xml" IDR_LANG_ZHTW LANGUAGES "..\\..\\Translations\\Language.zh-tw.xml" ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_UNINSTALL DIALOGEX 0, 0, 349, 234 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Uninstall VeraCrypt" CLASS "VeraCryptCustomDlg" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN LTEXT "Click Uninstall to remove VeraCrypt from this system.",IDT_UNINSTALL_DIR,8,8,334,8 LISTBOX IDC_LOG_WINDOW,7,21,335,179,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL DEFPUSHBUTTON "&Uninstall",IDC_UNINSTALL,236,213,50,14 PUSHBUTTON "Cancel",IDCANCEL,292,213,50,14 CONTROL "Create System &Restore point",IDC_SYSTEM_RESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,215,194,10 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,206,347,1,WS_EX_STATICEDGE CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,1,348,1,WS_EX_STATICEDGE END IDD_INSTALL_OPTIONS_PAGE_DLG DIALOGEX 0, 0, 346, 152 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN EDITTEXT IDC_DESTINATION,11,41,260,13,ES_AUTOHSCROLL PUSHBUTTON "Bro&wse...",IDC_BROWSE,278,40,59,14 - CONTROL "Install &for all users",IDC_ALL_USERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,77,168,11 + CONTROL "Install &for all users",IDC_ALL_USERS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,68,168,11 + CONTROL "Add VeraCrypt to &Start menu",IDC_PROG_GROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,80,168,11 + CONTROL "Add VeraCrypt icon to &desktop",IDC_DESKTOP_ICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,92,168,11 CONTROL "Associate the .hc file &extension with VeraCrypt",IDC_FILE_TYPE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,113,232,11 - CONTROL "Add VeraCrypt to &Start menu",IDC_PROG_GROUP,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,89,168,11 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,104,232,11 + CONTROL "Disable memory protection for Accessibility tools compatibility",IDC_DISABLE_MEMORY_PROTECTION, + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,115,315,10 + PUSHBUTTON "?",IDC_DISABLE_MEMORY_PROTECTION_HELP,337,111,7,14 CONTROL "Create System &Restore point",IDC_SYSTEM_RESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,125,194,11 - CONTROL "Add VeraCrypt icon to &desktop",IDC_DESKTOP_ICON,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,16,101,168,11 LTEXT "Please select or type the location where you want to install the VeraCrypt program files. If the specified folder does not exist, it will be automatically created.",IDT_INSTALL_DESTINATION,11,14,319,25 END IDD_INFO_PAGE_DLG DIALOGEX 0, 0, 217, 156 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN LTEXT "",IDC_BOX_HELP,0,10,217,146 END IDD_INTRO_PAGE_DLG DIALOGEX 0, 0, 346, 152 STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN CONTROL "",IDC_LICENSE_TEXT,"RichEdit20W",ES_MULTILINE | ES_READONLY | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_TABSTOP,0,23,345,108 CONTROL "",IDC_AGREE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,2,137,126,10 LTEXT "",IDC_BOX_HELP,0,0,346,22 END IDD_INSTL_DLG DIALOGEX 0, 0, 374, 231 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "VeraCrypt Setup Wizard" CLASS "VeraCryptCustomDlg" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN PUSHBUTTON "&Help",IDHELP,150,211,50,14 PUSHBUTTON "",IDC_PREV,209,211,50,14 DEFPUSHBUTTON "",IDC_NEXT,259,211,50,14 PUSHBUTTON "Cancel",IDCANCEL,317,211,50,14 LTEXT "",IDC_BOX_TITLE,11,2,324,12,0,WS_EX_TRANSPARENT diff --git a/src/Setup/Setup.vcxproj b/src/Setup/Setup.vcxproj index 59cec036..d1159c0b 100644 --- a/src/Setup/Setup.vcxproj +++ b/src/Setup/Setup.vcxproj @@ -81,176 +81,176 @@ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptSetup</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptSetup</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">VeraCryptSetup</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptSetup</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Setup.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt Setup.exe" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe" && copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt COMReg.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="ComSetup.cpp" /> <ClCompile Include="Dir.c" /> <ClCompile Include="SelfExtract.c" /> <ClCompile Include="Setup.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> </ClCompile> <ClCompile Include="Wizard.c"> diff --git a/src/Setup/Setup_vs2019.vcxproj b/src/Setup/Setup_vs2019.vcxproj new file mode 100644 index 00000000..0c329156 --- /dev/null +++ b/src/Setup/Setup_vs2019.vcxproj @@ -0,0 +1,331 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseCustomEFI|Win32"> + <Configuration>ReleaseCustomEFI</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release_SkipOsDriverReqCheck|Win32"> + <Configuration>Release_SkipOsDriverReqCheck</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{DF5F654D-BD44-4E31-B92E-B68074DC37A8}</ProjectGuid> + <RootNamespace>Setup</RootNamespace> + <Keyword>Win32Proj</Keyword> + <ProjectName>Setup</ProjectName> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> + <EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EmbedManifest> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)Release\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">$(ProjectDir)Release\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)Release\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">$(ProjectDir)Release\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</GenerateManifest> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptSetup</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptSetup</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">VeraCryptSetup</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptSetup</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>libcmtd.lib;atls.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)Setup.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + <GenerateMapFile>true</GenerateMapFile> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>md "..\Debug\Setup Files" 2>NUL: +copy Debug\VeraCryptSetup.exe "..\Debug\Setup Files\VeraCrypt Setup.exe" >NUL: + +</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>atls.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe" && copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt COMReg.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;VC_SKIP_OS_DRIVER_REQ_CHECK;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy Release\VeraCryptSetup.exe "..\Release\Setup Files\VeraCrypt Setup.exe"</Command> + </PostBuildEvent> + <ResourceCompile> + <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ResourceCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="ComSetup.cpp" /> + <ClCompile Include="Dir.c" /> + <ClCompile Include="SelfExtract.c" /> + <ClCompile Include="Setup.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="Wizard.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Xml.c" /> + <ClCompile Include="..\Common\BootEncryption.cpp" /> + <ClCompile Include="..\Common\Crc.c" /> + <ClCompile Include="..\Common\Dictionary.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Endian.c" /> + <ClCompile Include="..\Common\Language.c" /> + <ClCompile Include="..\Common\Registry.c" /> + </ItemGroup> + <ItemGroup> + <None Include="ComSetup.rgs" /> + <None Include="Setup.ico" /> + <None Include="..\Common\VeraCrypt.ico" /> + <None Include="VeraCrypt_setup.bmp" /> + <None Include="VeraCrypt_setup_background.bmp" /> + <None Include="..\Common\VeraCrypt_Volume.ico" /> + <None Include="..\Common\Language.xml" /> + <None Include="..\Resources\Texts\License.rtf" /> + <None Include="..\Common\Textual_logo_288dpi.bmp" /> + <None Include="..\Common\Textual_logo_96dpi.bmp" /> + <None Include="..\Common\Textual_logo_background.bmp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h" /> + <ClInclude Include="..\Common\Combo.h" /> + <ClInclude Include="ComSetup.h" /> + <ClInclude Include="..\Common\Crc.h" /> + <ClInclude Include="Dir.h" /> + <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Common\Exception.h" /> + <ClInclude Include="..\Common\Inflate.h" /> + <ClInclude Include="..\Common\Language.h" /> + <ClInclude Include="..\Common\Registry.h" /> + <ClInclude Include="..\Common\Resource.h" /> + <ClInclude Include="Resource.h" /> + <ClInclude Include="SelfExtract.h" /> + <ClInclude Include="Setup.h" /> + <ClInclude Include="..\Common\Tcdefs.h" /> + <ClInclude Include="Wizard.h" /> + </ItemGroup> + <ItemGroup> + <Manifest Include="Setup.manifest" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="Setup.rc" /> + <ResourceCompile Include="..\Common\Common.rc"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_SkipOsDriverReqCheck|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</ExcludedFromBuild> + </ResourceCompile> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/Setup/Setup_vs2019.vcxproj.filters b/src/Setup/Setup_vs2019.vcxproj.filters new file mode 100644 index 00000000..d747363f --- /dev/null +++ b/src/Setup/Setup_vs2019.vcxproj.filters @@ -0,0 +1,162 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier> + <Extensions>cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions> + </Filter> + <Filter Include="Source Files\Common"> + <UniqueIdentifier>{6073052c-2d95-47a0-95d8-5960d4c1d1c0}</UniqueIdentifier> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier> + <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx</Extensions> + </Filter> + <Filter Include="Resource Files\Common"> + <UniqueIdentifier>{a540fb0a-850b-4cb9-85f9-ade0112ebb50}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="ComSetup.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Dir.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="SelfExtract.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Setup.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Wizard.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\Xml.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\BootEncryption.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Crc.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dictionary.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Language.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Registry.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Endian.c"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <None Include="ComSetup.rgs"> + <Filter>Source Files</Filter> + </None> + <None Include="Setup.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup_background.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt_Volume.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\Language.xml"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Resources\Texts\License.rtf"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_288dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_96dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_background.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Combo.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="ComSetup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Crc.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Dir.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Dlgcode.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Exception.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Inflate.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Language.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Registry.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="SelfExtract.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Setup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Tcdefs.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Wizard.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <Manifest Include="Setup.manifest"> + <Filter>Resource Files</Filter> + </Manifest> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="Setup.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + <ResourceCompile Include="..\Common\Common.rc"> + <Filter>Resource Files\Common</Filter> + </ResourceCompile> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/Setup/Setup_vs2019.vcxproj.user b/src/Setup/Setup_vs2019.vcxproj.user new file mode 100644 index 00000000..ace9a86a --- /dev/null +++ b/src/Setup/Setup_vs2019.vcxproj.user @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +</Project>
\ No newline at end of file diff --git a/src/Setup/Wizard.c b/src/Setup/Wizard.c index 7de3ef0c..abf76f69 100644 --- a/src/Setup/Wizard.c +++ b/src/Setup/Wizard.c @@ -18,62 +18,62 @@ #include <stdio.h> #include <time.h> #include "SelfExtract.h" #include "Wizard.h" #include "Dlgcode.h" #include "Language.h" #include "Common/Resource.h" #include "Resource.h" #include "Setup.h" #include "Registry.h" #include <tchar.h> #include <Strsafe.h> using namespace std; enum wizard_pages { INTRO_PAGE, #ifndef PORTABLE WIZARD_MODE_PAGE, INSTALL_OPTIONS_PAGE, INSTALL_PROGRESS_PAGE, #endif EXTRACTION_OPTIONS_PAGE, EXTRACTION_PROGRESS_PAGE, DONATIONS_PAGE }; HWND hCurPage = NULL; /* Handle to current wizard page */ int nCurPageNo = -1; /* The current wizard page */ -wchar_t WizardDestInstallPath [TC_MAX_PATH]; -wchar_t WizardDestExtractPath [TC_MAX_PATH]; +wchar_t WizardDestInstallPath [TC_MAX_PATH] = { 0 }; +wchar_t WizardDestExtractPath [TC_MAX_PATH] = { 0 }; wchar_t SelfFile [TC_MAX_PATH]; HBITMAP hbmWizardBitmapRescaled = NULL; BOOL bExtractOnly = FALSE; BOOL bLicenseAccepted = FALSE; BOOL bOpenContainingFolder = TRUE; BOOL bExtractionSuccessful = FALSE; BOOL bStartInstall = FALSE; BOOL bStartExtraction = FALSE; BOOL bInProgress = FALSE; BOOL bPromptTutorial = FALSE; BOOL bPromptReleaseNotes = FALSE; BOOL bPromptFastStartup = FALSE; extern BOOL bUserSetLanguage; int nPbar = 0; /* Control ID of progress bar */ static HFONT hDonTextFont; static BOOL OsPrngAvailable; static HCRYPTPROV hCryptProv; static int DonColorSchemeId; static COLORREF DonTextColor; static COLORREF DonBkgColor; wstring DonText = L""; void localcleanupwiz (void) { @@ -185,60 +185,61 @@ void LoadPage (HWND hwndDlg, int nPageNo) static int GetDonVal (int minVal, int maxVal) { static BOOL prngInitialized = FALSE; static unsigned __int8 buffer [2]; if (!prngInitialized) { if (!CryptAcquireContext (&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) OsPrngAvailable = FALSE; else OsPrngAvailable = TRUE; prngInitialized = TRUE; } if (OsPrngAvailable && CryptGenRandom (hCryptProv, sizeof (buffer), buffer) != 0) { return ((int) ((double) *((uint16 *) buffer) / (0xFFFF+1) * (maxVal + 1 - minVal)) + minVal); } else return maxVal; } /* Except in response to the WM_INITDIALOG message, the dialog box procedure should return nonzero if it processes the message, and zero if it does not. - see DialogProc */ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) { static char PageDebugId[128]; + static HWND hDisableMemProtectionTooltipWnd = NULL; WORD lw = LOWORD (wParam); WORD hw = HIWORD (wParam); hCurPage = hwndDlg; switch (uMsg) { case WM_INITDIALOG: LocalizeDialog (hwndDlg, "IDD_INSTL_DLG"); StringCbPrintfA (PageDebugId, sizeof(PageDebugId), "SETUP_WIZARD_PAGE_%d", nCurPageNo); LastDialogId = PageDebugId; switch (nCurPageNo) { case INTRO_PAGE: { char *licenseText = NULL; #ifdef PORTABLE bExtractOnly = TRUE; #endif // increase size limit of rich edit control SendMessage (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), EM_EXLIMITTEXT, 0, -1); // Left margin for license text SendMessage (GetDlgItem (hwndDlg, IDC_LICENSE_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4)); licenseText = GetLegalNotices (); if (licenseText != NULL) @@ -412,63 +413,70 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_OPTIONS_TITLE")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_OPTIONS_INFO")); SetWindowTextW (GetDlgItem (hwndDlg, IDC_BOX_HELP), GetString ("AUTO_FOLDER_CREATION")); InitWizardDestInstallPath (); SendMessage (GetDlgItem (hwndDlg, IDC_DESTINATION), EM_LIMITTEXT, TC_MAX_PATH - 1, 0); SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath); if (bUpgrade) { SetWindowTextW (GetDlgItem (hwndDlg, IDT_INSTALL_DESTINATION), GetString ("SETUP_UPGRADE_DESTINATION")); EnableWindow (GetDlgItem (hwndDlg, IDC_DESTINATION), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_BROWSE), FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_ALL_USERS), FALSE); wchar_t path[MAX_PATH]; SHGetSpecialFolderPath (hwndDlg, path, CSIDL_COMMON_PROGRAMS, 0); bForAllUsers = (_waccess ((wstring (path) + L"\\" _T(TC_APP_NAME)).c_str(), 0) == 0); } // System Restore SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, bSystemRestore); if (SystemRestoreDll == 0) { SetCheckBox (hwndDlg, IDC_SYSTEM_RESTORE, FALSE); EnableWindow (GetDlgItem (hwndDlg, IDC_SYSTEM_RESTORE), FALSE); } + hDisableMemProtectionTooltipWnd = CreateToolTip (IDC_DISABLE_MEMORY_PROTECTION, hwndDlg, "DISABLE_MEMORY_PROTECTION_WARNING"); + // make IDC_DISABLE_MEMORY_PROTECTION control fit the text so that the tooltip is shown only when mouse is over the text + AccommodateCheckBoxTextWidth(hwndDlg, IDC_DISABLE_MEMORY_PROTECTION); + // make the help button adjacent to the checkbox + MakeControlsContiguous(hwndDlg, IDC_DISABLE_MEMORY_PROTECTION, IDC_DISABLE_MEMORY_PROTECTION_HELP); + SetCheckBox (hwndDlg, IDC_ALL_USERS, bForAllUsers); SetCheckBox (hwndDlg, IDC_FILE_TYPE, bRegisterFileExt); SetCheckBox (hwndDlg, IDC_PROG_GROUP, bAddToStartMenu); + SetCheckBox (hwndDlg, IDC_DISABLE_MEMORY_PROTECTION, bDisableMemoryProtection); SetCheckBox (hwndDlg, IDC_DESKTOP_ICON, bDesktopIcon); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString (bUpgrade ? "UPGRADE" : "INSTALL")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), TRUE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDCANCEL), TRUE); } return 1; case INSTALL_PROGRESS_PAGE: SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_TITLE), GetString ("SETUP_PROGRESS_TITLE")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_BOX_INFO), GetString ("SETUP_PROGRESS_INFO")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_PREV), GetString ("PREV")); if (bStartInstall) { /* Start install */ LastDialogId = "INSTALL_IN_PROGRESS"; SetWindowTextW (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), GetString ("NEXT")); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_PREV), FALSE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDC_NEXT), FALSE); EnableWindow (GetDlgItem (GetParent (hwndDlg), IDHELP), FALSE); @@ -619,99 +627,111 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa #ifndef PORTABLE if (lw == IDC_WIZARD_MODE_EXTRACT_ONLY && nCurPageNo == WIZARD_MODE_PAGE) { bExtractOnly = TRUE; return 1; } if (lw == IDC_WIZARD_MODE_INSTALL && nCurPageNo == WIZARD_MODE_PAGE) { bExtractOnly = FALSE; return 1; } #endif if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE && hw == EN_CHANGE ) { EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1)); return 1; } #ifndef PORTABLE if ( nCurPageNo == INSTALL_OPTIONS_PAGE && hw == EN_CHANGE ) { EnableWindow (GetDlgItem (MainDlg, IDC_NEXT), (GetWindowTextLength (GetDlgItem (hCurPage, IDC_DESTINATION)) > 1)); return 1; } #endif if ( nCurPageNo == EXTRACTION_OPTIONS_PAGE ) { switch (lw) { case IDC_BROWSE: - if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath)) + if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestExtractPath, WizardDestExtractPath)) { if (WizardDestExtractPath [wcslen(WizardDestExtractPath)-1] != L'\\') { StringCbCatW (WizardDestExtractPath, sizeof(WizardDestExtractPath), L"\\"); } SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestExtractPath); } return 1; case IDC_OPEN_CONTAINING_FOLDER: bOpenContainingFolder = IsButtonChecked (GetDlgItem (hCurPage, IDC_OPEN_CONTAINING_FOLDER)); return 1; } } #ifndef PORTABLE if ( nCurPageNo == INSTALL_OPTIONS_PAGE ) { switch (lw) { case IDC_BROWSE: - if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath)) + if (BrowseDirectories (hwndDlg, "SELECT_DEST_DIR", WizardDestInstallPath, WizardDestInstallPath)) { if (WizardDestInstallPath [wcslen(WizardDestInstallPath)-1] != L'\\') { StringCbCatW (WizardDestInstallPath, sizeof(WizardDestInstallPath), L"\\"); } SetDlgItemText (hwndDlg, IDC_DESTINATION, WizardDestInstallPath); } return 1; case IDC_SYSTEM_RESTORE: bSystemRestore = IsButtonChecked (GetDlgItem (hCurPage, IDC_SYSTEM_RESTORE)); return 1; case IDC_ALL_USERS: bForAllUsers = IsButtonChecked (GetDlgItem (hCurPage, IDC_ALL_USERS)); return 1; + case IDC_DISABLE_MEMORY_PROTECTION: + bDisableMemoryProtection = IsButtonChecked (GetDlgItem (hCurPage, IDC_DISABLE_MEMORY_PROTECTION)); + if (bDisableMemoryProtection) + { + Warning ("DISABLE_MEMORY_PROTECTION_WARNING", hwndDlg); + } + return 1; + + case IDC_DISABLE_MEMORY_PROTECTION_HELP: + Applink("memoryprotection"); + return 1; + case IDC_FILE_TYPE: bRegisterFileExt = IsButtonChecked (GetDlgItem (hCurPage, IDC_FILE_TYPE)); return 1; case IDC_PROG_GROUP: bAddToStartMenu = IsButtonChecked (GetDlgItem (hCurPage, IDC_PROG_GROUP)); return 1; case IDC_DESKTOP_ICON: bDesktopIcon = IsButtonChecked (GetDlgItem (hCurPage, IDC_DESKTOP_ICON)); return 1; } } #endif if (nCurPageNo == DONATIONS_PAGE) { switch (lw) { case IDC_DONATE: { Applink ("donate"); } return 1; } } return 0; @@ -733,60 +753,70 @@ BOOL CALLBACK PageDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (tmpBrush == NULL) AbortProcessSilent (); RECT trect; trect.left = 0; trect.right = CompensateXDPI (526); trect.top = 0; trect.bottom = CompensateYDPI (246); FillRect (hdc, &trect, tmpBrush); SetTextColor (hdc, DonTextColor); SetBkColor (hdc, DonBkgColor); } SetTextAlign(hdc, TA_CENTER); TextOutW (hdc, CompensateXDPI (258), CompensateYDPI (70), DonText.c_str(), DonText.length()); EndPaint (hCurPage, &tmpPaintStruct); ReleaseDC (hCurPage, hdc); } return 0; + case WM_DESTROY: + + if (hDisableMemProtectionTooltipWnd != NULL) + { + DestroyWindow (hDisableMemProtectionTooltipWnd); + hDisableMemProtectionTooltipWnd = NULL; + } + + break; + } return 0; } void InitProgressBar (void) { HWND hProgressBar = GetDlgItem (hCurPage, nPbar); SendMessage (hProgressBar, PBM_SETRANGE32, 0, 100); SendMessage (hProgressBar, PBM_SETSTEP, 1, 0); InvalidateRect (hProgressBar, NULL, TRUE); } // Must always return TRUE BOOL UpdateProgressBarProc (int nPercent) { HWND hProgressBar = GetDlgItem (hCurPage, nPbar); SendMessage (hProgressBar, PBM_SETPOS, (int) (100.0 * nPercent / 100), 0); InvalidateRect (hProgressBar, NULL, TRUE); ShowWindow(hProgressBar, SW_HIDE); ShowWindow(hProgressBar, SW_SHOW); // Prevent the IDC_LOG_WINDOW item from partially disappearing at higher DPIs ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_HIDE); ShowWindow(GetDlgItem (hCurPage, IDC_LOG_WINDOW), SW_SHOW); RefreshUIGFX(); return TRUE; } void RefreshUIGFX (void) { @@ -826,60 +856,63 @@ BOOL CALLBACK MainDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lPa if (!CreateAppSetupMutex ()) AbortProcess ("TC_INSTALLER_IS_RUNNING"); InitDialog (hwndDlg); LocalizeDialog (hwndDlg, "IDD_INSTL_DLG"); // Resize the bitmap if the user has a non-default DPI if (ScreenDPI != USER_DEFAULT_SCREEN_DPI) { hbmWizardBitmapRescaled = RenderBitmap (MAKEINTRESOURCE (IDB_SETUP_WIZARD), GetDlgItem (hwndDlg, IDC_BITMAP_SETUP_WIZARD), 0, 0, 0, 0, FALSE, TRUE); } // Gfx area background (must not keep aspect ratio; must retain Windows-imposed distortion) GetClientRect (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_GFX_AREA), &rec); SetWindowPos (GetDlgItem (hwndDlg, IDC_SETUP_WIZARD_BKG), HWND_TOP, 0, 0, rec.right, rec.bottom, SWP_NOMOVE); nPbar = IDC_PROGRESS_BAR; SendMessage (GetDlgItem (hwndDlg, IDC_BOX_TITLE), WM_SETFONT, (WPARAM) hUserBoldFont, (LPARAM) TRUE); #ifndef PORTABLE SetWindowText (hwndDlg, L"VeraCrypt Setup " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); #else SetWindowText (hwndDlg, L"VeraCrypt Portable " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); #endif DonColorSchemeId = GetDonVal (2, 9); + // get the initial value of bDisableMemoryProtection by reading the registry + bDisableMemoryProtection = bOriginalDisableMemoryProtection = ReadMemoryProtectionConfig()? FALSE : TRUE; + if (bDevm) { InitWizardDestInstallPath (); bSystemRestore = FALSE; bRegisterFileExt = FALSE; bAddToStartMenu = FALSE; bDesktopIcon = TRUE; bLicenseAccepted = TRUE; bStartInstall = TRUE; #ifdef PORTABLE bExtractOnly = TRUE; LoadPage (hwndDlg, EXTRACTION_PROGRESS_PAGE); #else LoadPage (hwndDlg, INSTALL_PROGRESS_PAGE); #endif } else LoadPage (hwndDlg, INTRO_PAGE); } return 0; case WM_SYSCOMMAND: if (lw == IDC_ABOUT) { if (bLicenseAccepted) DialogBoxW (hInst, MAKEINTRESOURCEW (IDD_ABOUT_DLG), hwndDlg, (DLGPROC) AboutDlgProc); return 1; } diff --git a/src/SetupDLL/Dir.c b/src/SetupDLL/Dir.c index 3275567f..e6a5f153 100644 --- a/src/SetupDLL/Dir.c +++ b/src/SetupDLL/Dir.c @@ -38,85 +38,85 @@ mkfulldir (wchar_t *oriPath, BOOL bCheckonly) } StringCbCopyW (path, TC_MAX_PATH, oriPath); if (wcslen (path) == 3 && path[1] == L':') goto is_root; /* keep final slash in root if present */ /* strip final forward or backslash if we have one! */ uniq_file = wcsrchr (path, L'\\'); if (uniq_file && uniq_file[1] == L'\0') uniq_file[0] = L'\0'; else { uniq_file = wcsrchr (path, L'/'); if (uniq_file && uniq_file[1] == L'\0') uniq_file[0] = L'\0'; } is_root: if (bCheckonly) return _wstat (path, &st); if (_wstat (path, &st)) return mkfulldir_internal (path); else return 0; } int -mkfulldir_internal (wchar_t *path) +mkfulldir_internal(wchar_t* path) { - wchar_t *token; - struct _stat st; - static wchar_t tokpath[_MAX_PATH]; - static wchar_t trail[_MAX_PATH]; - - if (wcslen(path) >= _MAX_PATH) - { - // directory name will be truncated so return failure to avoid unexepected behavior - return -1; - } - - StringCbCopyW (tokpath, _MAX_PATH, path); - trail[0] = L'\0'; - - token = wcstok (tokpath, L"\\/"); - - if (tokpath[0] == L'\\' && tokpath[1] == L'\\') - { /* unc */ - trail[0] = tokpath[0]; - trail[1] = tokpath[1]; - trail[2] = L'\0'; - if (token) - { - StringCbCatW (trail, _MAX_PATH, token); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - if (token) - { /* get share name */ - StringCbCatW (trail, _MAX_PATH, token); - StringCbCatW (trail, _MAX_PATH, L"\\"); - } - token = wcstok (NULL, L"\\/"); - } - } - - if (tokpath[1] == L':') - { /* drive letter */ - StringCbCatW (trail, _MAX_PATH, tokpath); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - } - - while (token != NULL) - { - int x; - StringCbCatW (trail, _MAX_PATH, token); - x = _wmkdir (trail); - StringCbCatW (trail, _MAX_PATH, L"\\"); - token = wcstok (NULL, L"\\/"); - } - - return _wstat (path, &st); + wchar_t* token; + wchar_t* next_token = NULL; + struct _stat st; + static wchar_t tokpath[_MAX_PATH]; + static wchar_t trail[_MAX_PATH]; + + if (wcslen(path) >= _MAX_PATH) + { + // directory name will be truncated so return failure to avoid unexpected behavior + return -1; + } + + StringCbCopyW(tokpath, _MAX_PATH, path); + trail[0] = L'\0'; + + token = wcstok_s(tokpath, L"\\/", &next_token); + if (tokpath[0] == L'\\' && tokpath[1] == L'\\') + { /* unc */ + trail[0] = tokpath[0]; + trail[1] = tokpath[1]; + trail[2] = L'\0'; + if (token) + { + StringCbCatW(trail, _MAX_PATH, token); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + if (token) + { /* get share name */ + StringCbCatW(trail, _MAX_PATH, token); + StringCbCatW(trail, _MAX_PATH, L"\\"); + } + token = wcstok_s(NULL, L"\\/", &next_token); + } + } + + if (tokpath[1] == L':') + { /* drive letter */ + StringCbCatW(trail, _MAX_PATH, tokpath); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + } + + while (token != NULL) + { + int x; + StringCbCatW(trail, _MAX_PATH, token); + x = _wmkdir(trail); + StringCbCatW(trail, _MAX_PATH, L"\\"); + token = wcstok_s(NULL, L"\\/", &next_token); + } + + return _wstat(path, &st); } diff --git a/src/SetupDLL/Resource.h b/src/SetupDLL/Resource.h index b5b7d466..62246068 100644 --- a/src/SetupDLL/Resource.h +++ b/src/SetupDLL/Resource.h @@ -16,60 +16,61 @@ #define IDR_LANG_RU 30 #define IDR_LANG_VI 31 #define IDR_LANG_ZHCN 32 #define IDR_LANG_ZHHK 33 #define IDR_LANG_BE 34 #define IDR_LANG_BG 35 #define IDR_LANG_CA 36 #define IDR_LANG_CO 37 #define IDR_LANG_DA 38 #define IDR_LANG_EL 39 #define IDR_LANG_ET 40 #define IDR_LANG_EU 41 #define IDR_LANG_FA 42 #define IDR_LANG_FI 43 #define IDR_LANG_HE 44 #define IDR_LANG_HU 45 #define IDR_LANG_ID 46 #define IDR_LANG_KA 47 #define IDR_LANG_KO 48 #define IDR_LANG_LV 49 #define IDR_LANG_NN 50 #define IDR_LANG_PTBR 51 #define IDR_LANG_SK 52 #define IDR_LANG_SL 53 #define IDR_LANG_SV 54 #define IDR_LANG_TH 55 #define IDR_LANG_TR 56 #define IDR_LANG_UK 57 #define IDR_LANG_UZ 58 #define IDR_LANG_ZHTW 59 +#define IDR_LANG_NB 60 #define IDD_INSTALL 101 #define IDD_INSTALL_OPTIONS_PAGE_DLG 102 #define IDD_UNINSTALL 103 #define IDI_SETUP 104 #define IDR_SETUP_RSRC_HEADER 105 #define IDD_EXTRACTION_OPTIONS_PAGE_DLG 106 #define IDB_SETUP_WIZARD 107 #define IDD_INTRO_PAGE_DLG 108 #define IDB_SETUP_WIZARD_BKG 109 #define IDD_INFO_PAGE_DLG 110 #define IDD_INSTL_DLG 111 #define IDD_WIZARD_MODE_PAGE_DLG 112 #define IDD_PROGRESS_PAGE_DLG 113 #define IDD_DONATIONS_PAGE_DLG 114 #define IDD_INSTALL_LANGUAGE 115 #define IDC_DESTINATION 1000 #define IDC_BOX_TITLE 1001 #define IDC_BROWSE 1002 #define IDC_BOX_INFO 1003 #define IDC_LICENSE 1004 #define IDC_BOX_HELP 1005 #define IDC_LICENSE_TEXT 1006 #define IDC_BOX_HELP2 1007 #define IDC_FILE_TYPE 1008 #define IDT_UNINSTALL_DIR 1009 #define IDC_PROG_GROUP 1010 #define IDC_SYSTEM_RESTORE 1011 #define IDC_DESKTOP_ICON 1012 #define IDC_ALL_USERS 1013 #define IDT_INSTALL_DESTINATION 1014 diff --git a/src/SetupDLL/Setup.c b/src/SetupDLL/Setup.c index f7c04315..d0300c7e 100644 --- a/src/SetupDLL/Setup.c +++ b/src/SetupDLL/Setup.c @@ -41,162 +41,60 @@ using namespace VeraCrypt; #pragma warning( disable : 4201 ) #pragma warning( disable : 4115 ) #include <shlobj.h> #pragma warning( default : 4201 ) #pragma warning( default : 4115 ) #include <Strsafe.h> #include <Msi.h> #include <MsiQuery.h> #include <wtsapi32.h> #include <cstdarg> #if !defined(va_copy) #define va_copy(d, s) ((d) = (s)) #endif typedef enum { MSI_INFO_LEVEL = 0, MSI_WARNING_LEVEL, MSI_ERROR_LEVEL } eMSILogLevel; #define WAIT_PERIOD 3 -extern HMODULE hRichEditDll; -extern HMODULE hComctl32Dll; -extern HMODULE hSetupDll; -extern HMODULE hShlwapiDll; -extern HMODULE hProfApiDll; -extern HMODULE hUsp10Dll; -extern HMODULE hCryptSpDll; -extern HMODULE hUXThemeDll; -extern HMODULE hUserenvDll; -extern HMODULE hRsaenhDll; -extern HMODULE himm32dll; -extern HMODULE hMSCTFdll; -extern HMODULE hfltlibdll; -extern HMODULE hframedyndll; -extern HMODULE hpsapidll; -extern HMODULE hsecur32dll; -extern HMODULE hnetapi32dll; -extern HMODULE hauthzdll; -extern HMODULE hxmllitedll; -extern HMODULE hmprdll; -extern HMODULE hsppdll; -extern HMODULE vssapidll; -extern HMODULE hvsstracedll; -extern HMODULE hcfgmgr32dll; -extern HMODULE hdevobjdll; -extern HMODULE hpowrprofdll; -extern HMODULE hsspiclidll; -extern HMODULE hcryptbasedll; -extern HMODULE hdwmapidll; -extern HMODULE hmsasn1dll; -extern HMODULE hcrypt32dll; -extern HMODULE hbcryptdll; -extern HMODULE hbcryptprimitivesdll; -extern HMODULE hMsls31; -extern HMODULE hntmartadll; -extern HMODULE hwinscarddll; -extern HMODULE hmsvcrtdll; -extern HMODULE hWinTrustLib; -extern HMODULE hAdvapi32Dll; - -#define FREE_DLL(h) if (h) { FreeLibrary (h); h = NULL;} - -#ifndef BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE -#define BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE 0x00000001 -#endif - -#ifndef BASE_SEARCH_PATH_PERMANENT -#define BASE_SEARCH_PATH_PERMANENT 0x00008000 -#endif - -#ifndef LOAD_LIBRARY_SEARCH_SYSTEM32 -#define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 -#endif - -typedef BOOL (WINAPI *SetDllDirectoryPtr)(LPCWSTR lpPathName); -typedef BOOL (WINAPI *SetSearchPathModePtr)(DWORD Flags); -typedef BOOL (WINAPI *SetDefaultDllDirectoriesPtr)(DWORD DirectoryFlags); - -typedef void (WINAPI *InitCommonControlsPtr)(void); -typedef HIMAGELIST (WINAPI *ImageList_CreatePtr)(int cx, int cy, UINT flags, int cInitial, int cGrow); -typedef int (WINAPI *ImageList_AddPtr)(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask); - -typedef VOID (WINAPI *SetupCloseInfFilePtr)(HINF InfHandle); -typedef HKEY (WINAPI *SetupDiOpenClassRegKeyPtr)(CONST GUID *ClassGuid,REGSAM samDesired); -typedef BOOL (WINAPI *SetupInstallFromInfSectionWPtr)(HWND,HINF,PCWSTR,UINT,HKEY,PCWSTR,UINT,PSP_FILE_CALLBACK_W,PVOID,HDEVINFO,PSP_DEVINFO_DATA); -typedef HINF (WINAPI *SetupOpenInfFileWPtr)(PCWSTR FileName,PCWSTR InfClass,DWORD InfStyle,PUINT ErrorLine); - -typedef LSTATUS (STDAPICALLTYPE *SHDeleteKeyWPtr)(HKEY hkey, LPCWSTR pszSubKey); - -typedef HRESULT (STDAPICALLTYPE *SHStrDupWPtr)(LPCWSTR psz, LPWSTR *ppwsz); - -// ChangeWindowMessageFilter -typedef BOOL (WINAPI *ChangeWindowMessageFilterPtr) (UINT, DWORD); - -typedef BOOL (WINAPI *CreateProcessWithTokenWFn)( - __in HANDLE hToken, - __in DWORD dwLogonFlags, - __in_opt LPCWSTR lpApplicationName, - __inout_opt LPWSTR lpCommandLine, - __in DWORD dwCreationFlags, - __in_opt LPVOID lpEnvironment, - __in_opt LPCWSTR lpCurrentDirectory, - __in LPSTARTUPINFOW lpStartupInfo, - __out LPPROCESS_INFORMATION lpProcessInformation - ); - -extern SetDllDirectoryPtr SetDllDirectoryFn; -extern SetSearchPathModePtr SetSearchPathModeFn; -extern SetDefaultDllDirectoriesPtr SetDefaultDllDirectoriesFn; - -extern ImageList_CreatePtr ImageList_CreateFn; -extern ImageList_AddPtr ImageList_AddFn; - -extern SetupCloseInfFilePtr SetupCloseInfFileFn; -extern SetupDiOpenClassRegKeyPtr SetupDiOpenClassRegKeyFn; -extern SetupInstallFromInfSectionWPtr SetupInstallFromInfSectionWFn; -extern SetupOpenInfFileWPtr SetupOpenInfFileWFn; -extern SHDeleteKeyWPtr SHDeleteKeyWFn; -extern SHStrDupWPtr SHStrDupWFn; -extern ChangeWindowMessageFilterPtr ChangeWindowMessageFilterFn; -extern CreateProcessWithTokenWFn CreateProcessWithTokenWPtr; - wchar_t InstallationPath[TC_MAX_PATH]; BOOL bUninstall = FALSE; BOOL bDowngrade = FALSE; BOOL bUninstallInProgress = FALSE; BOOL PortableMode = FALSE; BOOL UnloadDriver = TRUE; BOOL Rollback = FALSE; BOOL bReinstallMode = FALSE; BOOL bUpgrade = FALSE; BOOL bPossiblyFirstTimeInstall = FALSE; BOOL bDevm = FALSE; BOOL SystemEncryptionUpdate = FALSE; BOOL bRestartRequired = FALSE; BOOL bDisableSwapFiles = FALSE; BOOL bSystemRestore = TRUE; HMODULE volatile SystemRestoreDll = 0; BOOL bPromptFastStartup = FALSE; BOOL bPromptReleaseNotes = FALSE; BOOL bPromptTutorial = FALSE; BOOL bUpdateRescueDisk = FALSE; BOOL bRepairMode = FALSE; BOOL bUserSetLanguage = FALSE; /* BOOL bMakePackage = FALSE; BOOL bDone = FALSE; @@ -329,80 +227,67 @@ void DetermineUpgradeDowngradeStatus (BOOL bCloseDriverHandle, LONG *driverVersi BOOL bResult = DeviceIoControl (hDriver, TC_IOCTL_GET_DRIVER_VERSION, NULL, 0, &driverVersion, sizeof (driverVersion), &dwResult, NULL); bUpgrade = (bResult && driverVersion <= VERSION_NUM); bDowngrade = (bResult && driverVersion > VERSION_NUM); bReinstallMode = (bResult && driverVersion == VERSION_NUM); PortableMode = DeviceIoControl (hDriver, TC_IOCTL_GET_PORTABLE_MODE_STATUS, NULL, 0, NULL, 0, &dwResult, NULL); if (bCloseDriverHandle) { CloseHandle (hDriver); hDriver = INVALID_HANDLE_VALUE; } } *driverVersionPtr = driverVersion; } /* * Same as in Setup.c */ BOOL IsSystemRestoreEnabled () { BOOL bEnabled = FALSE; HKEY hKey; DWORD dwValue = 0, cbValue = sizeof (DWORD); wchar_t szRegPath[MAX_PATH]; GetRestorePointRegKeyName (szRegPath, sizeof (szRegPath)); if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, szRegPath, 0, KEY_READ | KEY_WOW64_64KEY, &hKey) == ERROR_SUCCESS) { - if (IsOSAtLeast (WIN_VISTA)) - { - if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) - && (dwValue == 1) - ) - { - bEnabled = TRUE; - } - } - else + if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"RPSessionInterval", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) + && (dwValue == 1) + ) { - if ( (ERROR_SUCCESS == RegQueryValueEx (hKey, L"DisableSR", NULL, NULL, (LPBYTE) &dwValue, &cbValue)) - && (dwValue == 0) - ) - { - bEnabled = TRUE; - } + bEnabled = TRUE; } - RegCloseKey (hKey); } return bEnabled; } /* * Same as in Setup.c */ static void RecursiveSetOwner (HKEY hKey, PSECURITY_DESCRIPTOR pSD) { LSTATUS status = 0; DWORD dwIndex = 0, dwMaxNameLen = 0, dwNameLen = 0, numberSubKeys = 0; HKEY hSubKey; if ( (ERROR_SUCCESS == status) && (ERROR_SUCCESS == RegQueryInfoKey(hKey, NULL, NULL, NULL, &numberSubKeys, &dwMaxNameLen, NULL, NULL, NULL, NULL, NULL, NULL)) && (numberSubKeys >= 1) ) { dwMaxNameLen++; wchar_t* szNameValue = new wchar_t[dwMaxNameLen]; while (true) { dwNameLen = dwMaxNameLen; status = RegEnumKeyExW (hKey, dwIndex++, szNameValue, &dwNameLen, NULL, NULL, NULL, NULL); if (status == ERROR_SUCCESS) { status = RegOpenKeyExW (hKey, szNameValue, 0, WRITE_OWNER | KEY_READ , &hSubKey); if (ERROR_SUCCESS == status) { @@ -957,62 +842,60 @@ BOOL CheckCapsLock_Dll (MSIHANDLE hInstaller, BOOL quiet) std::wstring GetWrongPasswordErrorMessage_Dll (MSIHANDLE hInstaller) { WCHAR szTmp[8192]; StringCbPrintfW (szTmp, sizeof(szTmp), GetString (KeyFilesEnable ? "PASSWORD_OR_KEYFILE_WRONG" : "PASSWORD_WRONG")); if (CheckCapsLock_Dll (hInstaller, TRUE)) StringCbCatW (szTmp, sizeof(szTmp), GetString ("PASSWORD_WRONG_CAPSLOCK_ON")); wstring msg = szTmp; return msg; } /* * Same as in Dlgcode.c, HandleDriveNotReadyError(), but * replaced Warning() with MSILogAndShow(). */ void HandleDriveNotReadyError_Dll (MSIHANDLE hInstaller) { HKEY hkey = 0; DWORD value = 0, size = sizeof (DWORD); if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SYSTEM\\CurrentControlSet\\Services\\MountMgr", 0, KEY_READ, &hkey) != ERROR_SUCCESS) return; if (RegQueryValueEx (hkey, L"NoAutoMount", 0, 0, (LPBYTE) &value, &size) == ERROR_SUCCESS && value != 0) { MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("SYS_AUTOMOUNT_DISABLED")); } - else if (nCurrentOS == WIN_VISTA && CurrentOSServicePack < 1) - MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("SYS_ASSIGN_DRIVE_LETTER")); else MSILogAndShow (hInstaller, MSI_WARNING_LEVEL, GetString("DEVICE_NOT_READY_ERROR")); RegCloseKey (hkey); } /* * Same as in Dlgcode.c, handleWin32Error(), but * replaced ErrorDirect(), Error() and MessageBoxW with MSILogAndShow(), * replaced HandleDriveNotReadyError() with HandleDriveNotReadyError_Dll(). */ DWORD handleWin32Error_Dll (MSIHANDLE hInstaller, const char* srcPos) { PWSTR lpMsgBuf; DWORD dwError = GetLastError (); wchar_t szErrorValue[32]; wchar_t* pszDesc; if (dwError == 0 || dwError == ERROR_INVALID_WINDOW_HANDLE) return dwError; // Access denied if (dwError == ERROR_ACCESS_DENIED && !IsAdmin ()) { MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, AppendSrcPos (GetString ("ERR_ACCESS_DENIED"), srcPos).c_str ()); SetLastError (dwError); // Preserve the original error code return dwError; } FormatMessageW ( @@ -1792,61 +1675,61 @@ error: if (hService != NULL) CloseServiceHandle (hService); if (hManager != NULL) CloseServiceHandle (hManager); MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoServiceUninstall_Dll"); return bOK; } /* * Same as in Setup.c, DoRegUninstall(), but * replaced StatusMessage() with MSILog(), * removed unnecessary code that is done by MSI. */ BOOL DoRegUninstall_Dll (MSIHANDLE hInstaller, BOOL bRemoveDeprecated) { MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin DoRegUninstall_Dll"); wchar_t regk [64]; typedef LSTATUS (WINAPI *RegDeleteKeyExWFn) (HKEY hKey,LPCWSTR lpSubKey,REGSAM samDesired,WORD Reserved); RegDeleteKeyExWFn RegDeleteKeyExWPtr = NULL; HMODULE hAdvapiDll = LoadLibrary (L"Advapi32.dll"); if (hAdvapiDll) { RegDeleteKeyExWPtr = (RegDeleteKeyExWFn) GetProcAddress(hAdvapiDll, "RegDeleteKeyExW"); } // Unregister COM servers - if (!bRemoveDeprecated && IsOSAtLeast (WIN_VISTA)) + if (!bRemoveDeprecated) { if (!UnregisterComServers (InstallationPath)) MSILog (hInstaller, MSI_ERROR_LEVEL, GetString("COM_DEREG_FAILED")); } if (!bRemoveDeprecated) MSILog (hInstaller, MSI_INFO_LEVEL, GetString("REMOVING_REG")); /* The following is done by MSI, so we skip it */ /* if (RegDeleteKeyExWPtr) { RegDeleteKeyExWPtr (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt", KEY_WOW64_32KEY, 0); RegDeleteKeyExWPtr (HKEY_CURRENT_USER, L"Software\\VeraCrypt", KEY_WOW64_32KEY, 0); } else { RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\VeraCrypt"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\VeraCrypt"); } RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open\\command"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell\\open"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\Shell"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume\\DefaultIcon"); RegDeleteKey (HKEY_LOCAL_MACHINE, L"Software\\Classes\\VeraCryptVolume"); */ if (!bRemoveDeprecated) { HKEY hKey; @@ -2079,206 +1962,76 @@ BOOL DoUninstall_Dll (MSIHANDLE hInstaller, HWND hwndDlg) DoServiceUninstall_Dll (hInstaller, hwndDlg, L"VeraCryptService"); } } if (Rollback) goto end; if (bSystemRestore && !bTempSkipSysRestore) SetSystemRestorePoint_Dll (hInstaller, TRUE); if (!bOK) bUninstallInProgress = FALSE; end: MSILog(hInstaller, MSI_INFO_LEVEL, L"End DoUninstall_Dll"); return bOK; } /* * Same as Setup.c, function InitApp(), but * replaced unnecessary calls, * forced english as language, * replaced LoadLanguageFile() with LoadLanguageFromResource() to be able to set bForceSilent. */ BOOL InitDll (MSIHANDLE hInstaller) { MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin InitDll"); BOOL bOK = TRUE; - InitCommonControlsPtr InitCommonControlsFn = NULL; - - /* remove current directory from dll search path */ - SetDllDirectoryFn = (SetDllDirectoryPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDllDirectoryW"); - SetSearchPathModeFn = (SetSearchPathModePtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetSearchPathMode"); - SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories"); - if (SetDllDirectoryFn) - SetDllDirectoryFn (L""); - if (SetSearchPathModeFn) - SetSearchPathModeFn (BASE_SEARCH_PATH_ENABLE_SAFE_SEARCHMODE | BASE_SEARCH_PATH_PERMANENT); - if (SetDefaultDllDirectoriesFn) - SetDefaultDllDirectoriesFn (LOAD_LIBRARY_SEARCH_SYSTEM32); InitOSVersionInfo(); InitGlobalLocks (); - LoadSystemDll_Dll (hInstaller, L"msvcrt.dll", &hmsvcrtdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"ntmarta.dll", &hntmartadll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"MPR.DLL", &hmprdll, TRUE, SRC_POS); - if (IsOSAtLeast (WIN_7)) - { - LoadSystemDll_Dll (hInstaller, L"ProfApi.DLL", &hProfApiDll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"cryptbase.dll", &hcryptbasedll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"sspicli.dll", &hsspiclidll, TRUE, SRC_POS); - } - LoadSystemDll_Dll (hInstaller, L"psapi.dll", &hpsapidll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"secur32.dll", &hsecur32dll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"msasn1.dll", &hmsasn1dll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"Usp10.DLL", &hUsp10Dll, TRUE, SRC_POS); - if (IsOSAtLeast (WIN_7)) - LoadSystemDll_Dll (hInstaller, L"dwmapi.dll", &hdwmapidll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"UXTheme.dll", &hUXThemeDll, TRUE, SRC_POS); - - LoadSystemDll_Dll (hInstaller, L"msls31.dll", &hMsls31, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"SETUPAPI.DLL", &hSetupDll, FALSE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"SHLWAPI.DLL", &hShlwapiDll, FALSE, SRC_POS); - - LoadSystemDll_Dll (hInstaller, L"userenv.dll", &hUserenvDll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"rsaenh.dll", &hRsaenhDll, TRUE, SRC_POS); - - if (nCurrentOS < WIN_7) - { - if (nCurrentOS == WIN_XP) - { - LoadSystemDll_Dll (hInstaller, L"imm32.dll", &himm32dll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"MSCTF.dll", &hMSCTFdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"fltlib.dll", &hfltlibdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"wbem\\framedyn.dll", &hframedyndll, TRUE, SRC_POS); - } - - if (IsOSAtLeast (WIN_VISTA)) - { - LoadSystemDll_Dll (hInstaller, L"netapi32.dll", &hnetapi32dll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"authz.dll", &hauthzdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"xmllite.dll", &hxmllitedll, TRUE, SRC_POS); - } - } - - if (IsOSAtLeast (WIN_VISTA)) - { - LoadSystemDll_Dll (hInstaller, L"atl.dll", &hsppdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"vsstrace.dll", &hvsstracedll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"vssapi.dll", &vssapidll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"spp.dll", &hsppdll, TRUE, SRC_POS); - } - - LoadSystemDll_Dll (hInstaller, L"crypt32.dll", &hcrypt32dll, TRUE, SRC_POS); - - if (IsOSAtLeast (WIN_7)) - { - LoadSystemDll_Dll (hInstaller, L"CryptSP.dll", &hCryptSpDll, TRUE, SRC_POS); - - LoadSystemDll_Dll (hInstaller, L"cfgmgr32.dll", &hcfgmgr32dll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"devobj.dll", &hdevobjdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"powrprof.dll", &hpowrprofdll, TRUE, SRC_POS); - - LoadSystemDll_Dll (hInstaller, L"bcrypt.dll", &hbcryptdll, TRUE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"bcryptprimitives.dll", &hbcryptprimitivesdll, TRUE, SRC_POS); - } - - LoadSystemDll_Dll (hInstaller, L"COMCTL32.DLL", &hComctl32Dll, FALSE, SRC_POS); - - // call InitCommonControls function - InitCommonControlsFn = (InitCommonControlsPtr) GetProcAddress (hComctl32Dll, "InitCommonControls"); - ImageList_AddFn = (ImageList_AddPtr) GetProcAddress (hComctl32Dll, "ImageList_Add"); - ImageList_CreateFn = (ImageList_CreatePtr) GetProcAddress (hComctl32Dll, "ImageList_Create"); - - if (InitCommonControlsFn && ImageList_AddFn && ImageList_CreateFn) - { - InitCommonControlsFn(); - } - else - { - MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL")); - bOK = FALSE; - goto end; - } - - LoadSystemDll_Dll (hInstaller, L"Riched20.dll", &hRichEditDll, FALSE, SRC_POS); - LoadSystemDll_Dll (hInstaller, L"Advapi32.dll", &hAdvapi32Dll, FALSE, SRC_POS); - - // Get SetupAPI functions pointers - SetupCloseInfFileFn = (SetupCloseInfFilePtr) GetProcAddress (hSetupDll, "SetupCloseInfFile"); - SetupDiOpenClassRegKeyFn = (SetupDiOpenClassRegKeyPtr) GetProcAddress (hSetupDll, "SetupDiOpenClassRegKey"); - SetupInstallFromInfSectionWFn = (SetupInstallFromInfSectionWPtr) GetProcAddress (hSetupDll, "SetupInstallFromInfSectionW"); - SetupOpenInfFileWFn = (SetupOpenInfFileWPtr) GetProcAddress (hSetupDll, "SetupOpenInfFileW"); - - if (!SetupCloseInfFileFn || !SetupDiOpenClassRegKeyFn || !SetupInstallFromInfSectionWFn || !SetupOpenInfFileWFn) - { - MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL")); - bOK = FALSE; - goto end; - } - - // Get SHDeleteKeyW function pointer - SHDeleteKeyWFn = (SHDeleteKeyWPtr) GetProcAddress (hShlwapiDll, "SHDeleteKeyW"); - SHStrDupWFn = (SHStrDupWPtr) GetProcAddress (hShlwapiDll, "SHStrDupW"); - if (!SHDeleteKeyWFn || !SHStrDupWFn) - { - MSILog(hInstaller, MSI_ERROR_LEVEL, GetString("INIT_DLL")); - bOK = FALSE; - goto end; - } - - if (IsOSAtLeast (WIN_VISTA)) - { - /* Get ChangeWindowMessageFilter used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */ - ChangeWindowMessageFilterFn = (ChangeWindowMessageFilterPtr) GetProcAddress (GetModuleHandle (L"user32.dll"), "ChangeWindowMessageFilter"); - } - - // Get CreateProcessWithTokenW function pointer - CreateProcessWithTokenWPtr = (CreateProcessWithTokenWFn) GetProcAddress(hAdvapi32Dll, "CreateProcessWithTokenW"); - SetErrorMode (SetErrorMode (0) | SEM_FAILCRITICALERRORS | SEM_NOOPENFILEERRORBOX); - CoInitialize (NULL); + CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); // Force language to english to read strings from the default Language.xml embedded in the DLL. SetPreferredLangId ("en"); bUserSetLanguage = TRUE; LoadLanguageFromResource (0, FALSE, TRUE); SetUnhandledExceptionFilter (ExceptionHandler); _set_invalid_parameter_handler (InvalidParameterHandler); RemoteSession = GetSystemMetrics (SM_REMOTESESSION) != 0; -end: MSILog(hInstaller, MSI_INFO_LEVEL, L"End InitDll"); return bOK; } /* **************************************************************************** */ /* * Same as Setup.c, function wWinMain(), but * replaced unnecessary calls. * This should be called at the beginning of each operation (install, uninstall...), * before atexit(VC_CustomAction_Cleanup()) call. */ BOOL VC_CustomAction_Init(MSIHANDLE hInstaller, const wchar_t* szInstallDir) { MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_Init"); BOOL bOK = TRUE; if (!InitDll(hInstaller)) { bOK = FALSE; goto end; } // System Restore if (IsSystemRestoreEnabled ()) { MSILog(hInstaller, MSI_INFO_LEVEL, L"System Restore is enabled"); wchar_t dllPath[MAX_PATH]; @@ -2338,100 +2091,60 @@ void VC_CustomAction_Cleanup () { // If a dismount was forced in the lifetime of the driver, Windows may later prevent it to be loaded again from // the same path. Therefore, the driver will not be unloaded even though it was loaded in non-install mode. int driverUnloadDisabled; DWORD dwResult; if (!DeviceIoControl (hDriver, TC_IOCTL_IS_DRIVER_UNLOAD_DISABLED, NULL, 0, &driverUnloadDisabled, sizeof (driverUnloadDisabled), &dwResult, NULL)) driverUnloadDisabled = 0; if (!driverUnloadDisabled) DriverUnload (); else { CloseHandle (hDriver); hDriver = INVALID_HANDLE_VALUE; } } else { CloseHandle (hDriver); hDriver = INVALID_HANDLE_VALUE; } } CoUninitialize (); CloseSysEncMutex (); FinalizeGlobalLocks (); - FREE_DLL (hRichEditDll); - FREE_DLL (hComctl32Dll); - FREE_DLL (hSetupDll); - FREE_DLL (hShlwapiDll); - FREE_DLL (hProfApiDll); - FREE_DLL (hUsp10Dll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hUXThemeDll); - FREE_DLL (hUserenvDll); - FREE_DLL (hRsaenhDll); - FREE_DLL (himm32dll); - FREE_DLL (hMSCTFdll); - FREE_DLL (hfltlibdll); - FREE_DLL (hframedyndll); - FREE_DLL (hpsapidll); - FREE_DLL (hsecur32dll); - FREE_DLL (hnetapi32dll); - FREE_DLL (hauthzdll); - FREE_DLL (hxmllitedll); - FREE_DLL (hmprdll); - FREE_DLL (hsppdll); - FREE_DLL (vssapidll); - FREE_DLL (hvsstracedll); - FREE_DLL (hCryptSpDll); - FREE_DLL (hcfgmgr32dll); - FREE_DLL (hdevobjdll); - FREE_DLL (hpowrprofdll); - FREE_DLL (hsspiclidll); - FREE_DLL (hcryptbasedll); - FREE_DLL (hdwmapidll); - FREE_DLL (hmsasn1dll); - FREE_DLL (hcrypt32dll); - FREE_DLL (hbcryptdll); - FREE_DLL (hbcryptprimitivesdll); - FREE_DLL (hMsls31); - FREE_DLL (hntmartadll); - FREE_DLL (hwinscarddll); - FREE_DLL (hmsvcrtdll); - FREE_DLL (hAdvapi32Dll); - //MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_Cleanup"); } void Tokenize(const wchar_t* szInput, std::vector<std::wstring>& szTokens) { std::wstringstream check(szInput); std::wstring intermediate; while(std::getline(check, intermediate, L'?')) { szTokens.push_back(intermediate); } } /* * Same as Setup.c, function DoInstall(), but * without the actual installation, it only prepares the system * before the installation (before DoFilesInstall). * It runs as a Deferred CA. */ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PreInstall(MSIHANDLE hInstaller) { HWND hwndDlg = NULL; std::wstring szValueBuf = L""; DWORD cchValueBuf = 0; UINT uiStat = 0; HKEY hkey = 0; DWORD dw = 0; BootEncryption bootEnc(NULL); std::wstring szInstallDir = L""; UINT uiRet = ERROR_INSTALL_FAILURE; @@ -2596,60 +2309,92 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PreInstall(MSIHANDLE hInstaller) } } end: MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PreInstall"); return uiRet; } /* * Same as Setup.c, function DoInstall(), but * without the actual installation, it only performs * post install operations (after DoRegInstall and last parts * of DoFilesInstall / DoRegInstall). * It also does the Fast Startup check, shows Release Notes and * Beginner's Tutorial if needed and sets regkey accordingly. * It runs as a Deferred CA. */ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller) { HWND hwndDlg = NULL; std::wstring szValueBuf = L""; DWORD cchValueBuf = 0; UINT uiStat = 0; HKEY hkey = 0; DWORD dw = 0; BootEncryption bootEnc(NULL); std::wstring szInstallDir = L""; UINT uiRet = ERROR_INSTALL_FAILURE; BOOL bOK = TRUE; WCHAR szCurrentDir[MAX_PATH]; + const wchar_t* oldFileNames[] = { + L"docs\\html\\en\\AddNewSystemVar.jpg", + L"docs\\html\\en\\CertificateCannotBeVerified.jpg", + L"docs\\html\\en\\CertVerifyFails.jpg", + L"docs\\html\\en\\DistributionPackageDamaged.jpg", + L"docs\\html\\en\\DownloadVS2010.jpg", + L"docs\\html\\en\\DownloadVS2019.jpg", + L"docs\\html\\en\\DownloadVSBuildTools.jpg", + L"docs\\html\\en\\gzipCommandLine.jpg", + L"docs\\html\\en\\NasmCommandLine.jpg", + L"docs\\html\\en\\RegeditPermissions-1.jpg", + L"docs\\html\\en\\RegeditPermissions-2.jpg", + L"docs\\html\\en\\RegeditPermissions-3.jpg", + L"docs\\html\\en\\RegeditPermissions-4.jpg", + L"docs\\html\\en\\SelectAdvancedSystemSettings.jpg", + L"docs\\html\\en\\SelectEnvironmentVariables.jpg", + L"docs\\html\\en\\SelectPathVariable.jpg", + L"docs\\html\\en\\SelectThisPC.jpg", + L"docs\\html\\en\\upxCommandLine.jpg", + L"docs\\html\\en\\VS2010BuildSolution.jpg", + L"docs\\html\\en\\VS2010Win32Config.jpg", + L"docs\\html\\en\\VS2010X64Config.jpg", + L"docs\\html\\en\\VS2019ARM64Config.jpg", + L"docs\\html\\en\\VS2019BuildSolution.jpg", + L"docs\\html\\en\\YasmCommandLine.jpg", + L"docs\\html\\en\\BCH_Logo_48x30.png", + L"docs\\html\\en\\LinuxPrepAndBuild.sh", + L"docs\\html\\en\\LinuxPrepAndBuild.zip", + L"docs\\html\\en\\RIPEMD-160.html", + L"docs\\html\\en\\ru\\BCH_Logo_48x30.png", + L"Languages\\Language.ru - Copy.xml", + }; MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PostInstall"); // Get INSTALLDIR to see where we're being installed. uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf); if (ERROR_MORE_DATA == uiStat) { ++cchValueBuf; // add 1 for null termination szValueBuf.resize(cchValueBuf); uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), &szValueBuf[0], &cchValueBuf); if ((ERROR_SUCCESS == uiStat)) { MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostInstall: CustomActionData = '%s'", szValueBuf.c_str()); if (wcsncmp(szValueBuf.c_str(), L"INSTALLDIR=", wcslen(L"INSTALLDIR=")) == 0) { size_t index0 = szValueBuf.find_first_of(L"="); if (index0 != std::wstring::npos) { szInstallDir = szValueBuf.substr(index0 + 1); MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_PostInstall: INSTALLDIR = '%s'", szInstallDir.c_str()); } } } } // Read RegKeys previously setup by PreInstall if (RegOpenKeyExW (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, KEY_READ, &hkey) == ERROR_SUCCESS) { DWORD cbValue = sizeof(DWORD); DWORD dwValue = 0; @@ -2706,68 +2451,79 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller) MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PostInstall: Could not read from registry"); goto end; } // Get this MSI Installer HWND. // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours. // This is only possible in case of non silent install. hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL); if (!hwndDlg && !Silent) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: MsiDialogCloseClass not found"); goto end; } /* Start actual work */ if (!VC_CustomAction_Init(hInstaller, szInstallDir.c_str())) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: VC_CustomAction_Init() failed"); goto end; } atexit(VC_CustomAction_Cleanup); bootEnc.SetParentWindow(hwndDlg); // Last part of DoFilesInstall() { BOOL bResult = FALSE; WIN32_FIND_DATA f; HANDLE h; wchar_t szTmp[TC_MAX_PATH]; + size_t i; // delete "VeraCrypt Setup.exe" if it exists StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szInstallDir.c_str(), L"VeraCrypt Setup.exe"); if (FileExists(szTmp)) { ForceDeleteFile(szTmp); } + // delete files wrongly installed by previous versions in installation folder + for (i = 0; i < ARRAYSIZE(oldFileNames); i++) + { + StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szInstallDir.c_str(), oldFileNames[i]); + if (FileExists(szTmp)) + { + ForceDeleteFile(szTmp); + } + } + StringCbPrintfW (szTmp, sizeof(szTmp), L"%s%s", szInstallDir.c_str(), L"VeraCrypt.exe"); if (Is64BitOs ()) EnableWow64FsRedirection (FALSE); wstring servicePath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", false); wstring serviceLegacyPath = GetServiceConfigPath (_T(TC_APP_NAME) L".exe", true); wstring favoritesFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, false); wstring favoritesLegacyFile = GetServiceConfigPath (TC_APPD_FILENAME_SYSTEM_FAVORITE_VOLUMES, true); if (Is64BitOs () && FileExists (favoritesLegacyFile.c_str()) && !FileExists (favoritesFile.c_str())) { // copy the favorites XML file to the native system directory bResult = CopyFile (favoritesLegacyFile.c_str(), favoritesFile.c_str(), FALSE); } else { bResult = TRUE; } if (bResult) { // Update the path of the service BootEncryption BootEncObj (hwndDlg); try { if (BootEncObj.GetDriverServiceStartType() == SERVICE_BOOT_START) @@ -2883,67 +2639,64 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostInstall(MSIHANDLE hInstaller) FindClose (h); } // remove language XML files from previous version if any h = FindFirstFile (L"Language*.xml", &f); if (h != INVALID_HANDLE_VALUE) { do { StatDeleteFile (f.cFileName, TRUE); } while (FindNextFile(h, &f) != 0); FindClose (h); } // remvove legacy files that are not needed anymore for (int i = 0; i < sizeof (szLegacyFiles) / sizeof (szLegacyFiles[0]); i++) { StatDeleteFile (szLegacyFiles [i], TRUE); } SetCurrentDirectory(szCurrentDir); } } // Last part of DoRegInstall() { // Register COM servers for UAC - if (IsOSAtLeast (WIN_VISTA)) + if (!RegisterComServers ((wchar_t*)szInstallDir.c_str())) { - if (!RegisterComServers ((wchar_t*)szInstallDir.c_str())) - { - MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("COM_REG_FAILED")); - goto end; - } + MSILogAndShow (hInstaller, MSI_ERROR_LEVEL, GetString("COM_REG_FAILED")); + goto end; } } if (UnloadDriver && DoDriverInstall_Dll(hInstaller) == FALSE) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: DoDriverInstall_Dll() failed"); bOK = FALSE; } else if (SystemEncryptionUpdate && UpgradeBootLoader_Dll(hInstaller, hwndDlg) == FALSE) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostInstall: UpgradeBootLoader_Dll() failed"); bOK = FALSE; } // Shortcuts are installed by MSI, so we skip that. if (!UnloadDriver) bRestartRequired = TRUE; try { bootEnc.RenameDeprecatedSystemLoaderBackup(); } catch (...) { } if (bSystemRestore) SetSystemRestorePoint_Dll (hInstaller, TRUE); if (bOK) { @@ -3240,60 +2993,124 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PreUninstall(MSIHANDLE hInstaller) RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL)); RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL)); RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL)); RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL)); RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL)); RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL)); RegSetValueEx (hkey, L"bSystemRestore", 0, REG_DWORD, (const BYTE*)(&bSystemRestore), sizeof(BOOL)); RegSetValueEx (hkey, L"bPromptFastStartup", 0, REG_DWORD, (const BYTE*)(&bPromptFastStartup), sizeof(BOOL)); RegSetValueEx (hkey, L"bPromptReleaseNotes", 0, REG_DWORD, (const BYTE*)(&bPromptReleaseNotes), sizeof(BOOL)); RegSetValueEx (hkey, L"bPromptTutorial", 0, REG_DWORD, (const BYTE*)(&bPromptTutorial), sizeof(BOOL)); RegSetValueEx (hkey, L"bUpdateRescueDisk", 0, REG_DWORD, (const BYTE*)(&bUpdateRescueDisk), sizeof(BOOL)); RegSetValueEx (hkey, L"bRepairMode", 0, REG_DWORD, (const BYTE*)(&bRepairMode), sizeof(BOOL)); RegSetValueEx (hkey, L"bUserSetLanguage", 0, REG_DWORD, (const BYTE*)(&bUserSetLanguage), sizeof(BOOL)); RegCloseKey (hkey); uiRet = ERROR_SUCCESS; } else { MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_PreUninstall: Could not write to registry"); } } end: MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_PreUninstall"); return uiRet; } +static BOOL DirectoryExists (const wchar_t *dirName) +{ + DWORD attrib = GetFileAttributes (dirName); + return (attrib != INVALID_FILE_ATTRIBUTES && (attrib & FILE_ATTRIBUTE_DIRECTORY)); +} + +static BOOL DeleteContentsOnReboot(LPCTSTR pszDir) { + TCHAR szPath[MAX_PATH]; + TCHAR szSubPath[MAX_PATH]; + WIN32_FIND_DATA FindFileData; + HANDLE hFind; + BOOL bHasBackslash = FALSE; + // check if pszDir ends with a backslash + if (pszDir[_tcslen(pszDir) - 1] == '\\') + { + bHasBackslash = TRUE; + } + + // Prepare the path for FindFirstFile + if (bHasBackslash) + StringCchPrintf(szPath, MAX_PATH, TEXT("%s*"), pszDir); + else + StringCchPrintf(szPath, MAX_PATH, TEXT("%s\\*"), pszDir); + + hFind = FindFirstFile(szPath, &FindFileData); + if (hFind == INVALID_HANDLE_VALUE) { + return FALSE; + } + + BOOL result = TRUE; + + do { + if (_tcscmp(FindFileData.cFileName, TEXT(".")) != 0 && + _tcscmp(FindFileData.cFileName, TEXT("..")) != 0) { + + if (bHasBackslash) + StringCchPrintf(szSubPath, MAX_PATH, TEXT("%s%s"), pszDir, FindFileData.cFileName); + else + StringCchPrintf(szSubPath, MAX_PATH, TEXT("%s\\%s"), pszDir, FindFileData.cFileName); + + if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { + // Recursive call to handle subdirectories + if (!DeleteContentsOnReboot(szSubPath)) { + result = FALSE; // Track failures but attempt to continue + } + } else { + // Schedule the file for deletion + if (!MoveFileEx(szSubPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { + result = FALSE; // Track failures + } + } + } + } while (FindNextFile(hFind, &FindFileData) != 0); + + FindClose(hFind); + + // Schedule the root directory for deletion, only if not done already + if (!MoveFileEx(pszDir, NULL, MOVEFILE_DELAY_UNTIL_REBOOT)) { + result = FALSE; + } + + return result; +} + /* * Same as Setup.c, function DoUninstall(), but * without the actual installation, it only performs * post install operations (after DoFilesInstall and last parts * of DoFilesInstall / DoRegUninstall). * It also sets regkey accordingly. * It runs as a Deferred CA. */ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostUninstall(MSIHANDLE hInstaller) { HWND hwndDlg = NULL; std::wstring szValueBuf = L""; DWORD cchValueBuf = 0; UINT uiStat = 0; HKEY hkey = 0; DWORD dw = 0; BootEncryption bootEnc(NULL); std::wstring szInstallDir = L""; UINT uiRet = ERROR_INSTALL_FAILURE; BOOL bTempSkipSysRestore = FALSE; BOOL bOK = TRUE; MSILog(hInstaller, MSI_INFO_LEVEL, L"Begin VC_CustomAction_PostUninstall"); // Get INSTALLDIR to see where we're being installed. uiStat = MsiGetProperty(hInstaller, TEXT("CustomActionData"), (LPWSTR)TEXT(""), &cchValueBuf); if (ERROR_MORE_DATA == uiStat) { ++cchValueBuf; // add 1 for null termination szValueBuf.resize(cchValueBuf); @@ -3416,60 +3233,87 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_PostUninstall(MSIHANDLE hInstaller) // delete all files related to system favorites service if (FileExists (favoritesFile.c_str())) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", favoritesFile.c_str()); ForceDeleteFile (favoritesFile.c_str()); } if (FileExists (servicePath.c_str())) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", servicePath.c_str()); ForceDeleteFile (servicePath.c_str()); } if (Is64BitOs ()) { if (FileExists (favoritesLegacyFile.c_str())) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", favoritesLegacyFile.c_str()); ForceDeleteFile (favoritesLegacyFile.c_str()); } if (FileExists (serviceLegacyPath.c_str())) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", serviceLegacyPath.c_str()); ForceDeleteFile (serviceLegacyPath.c_str()); } EnableWow64FsRedirection (TRUE); } + + // remove the installation folder is case it remains after uninstall + if (DirectoryExists (szInstallDir.c_str())) + { + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: REMOVING %s", szInstallDir.c_str()); + if(DeleteDirectory (szInstallDir.c_str())) + { + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: %s removed", szInstallDir.c_str()); + } + else + { + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: %s could not be removed. Scheduling removal on reboot", szInstallDir.c_str()); + if (DeleteContentsOnReboot(szInstallDir.c_str())) + { + bRestartRequired = TRUE; + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: %s scheduled for removal on reboot", szInstallDir.c_str()); + } + else + { + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: %s could not be scheduled for removal on reboot", szInstallDir.c_str()); + } + } + } + else + { + MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_PostUninstall: %s does not exist", szInstallDir.c_str()); + } } if (bSystemRestore && !bTempSkipSysRestore) SetSystemRestorePoint_Dll (hInstaller, TRUE); if (bOK) { // uiRet = MsiSetProperty(hInstaller, TEXT("ISREBOOTREQUIRED"), TEXT("1")); // Cannot do this because this is a Deferred CA (we need Deferred so that it runs with admin privileges). // MsiGetProperty and MsiSetProperty properties cannot be used for deferred InstallScript custom actions, // which do not have access to the active .msi database and do not recognize any Windows Installer properties. // They can access only the information that has been written into the execution script (CustomActionData). // Therefore, we set the values in RegKeys that are volatile. if (RegCreateKeyEx (HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt\\Values", 0, NULL, REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey, &dw) == ERROR_SUCCESS) { RegSetValueEx (hkey, L"Silent", 0, REG_DWORD, (const BYTE*)(&Silent), sizeof(BOOL)); RegSetValueEx (hkey, L"bUninstall", 0, REG_DWORD, (const BYTE*)(&bUninstall), sizeof(BOOL)); RegSetValueEx (hkey, L"bDowngrade", 0, REG_DWORD, (const BYTE*)(&bDowngrade), sizeof(BOOL)); RegSetValueEx (hkey, L"bUninstallInProgress", 0, REG_DWORD, (const BYTE*)(&bUninstallInProgress), sizeof(BOOL)); RegSetValueEx (hkey, L"PortableMode", 0, REG_DWORD, (const BYTE*)(&PortableMode), sizeof(BOOL)); RegSetValueEx (hkey, L"UnloadDriver", 0, REG_DWORD, (const BYTE*)(&UnloadDriver), sizeof(BOOL)); RegSetValueEx (hkey, L"Rollback", 0, REG_DWORD, (const BYTE*)(&Rollback), sizeof(BOOL)); RegSetValueEx (hkey, L"bReinstallMode", 0, REG_DWORD, (const BYTE*)(&bReinstallMode), sizeof(BOOL)); RegSetValueEx (hkey, L"bUpgrade", 0, REG_DWORD, (const BYTE*)(&bUpgrade), sizeof(BOOL)); RegSetValueEx (hkey, L"bPossiblyFirstTimeInstall", 0, REG_DWORD, (const BYTE*)(&bPossiblyFirstTimeInstall), sizeof(BOOL)); RegSetValueEx (hkey, L"bDevm", 0, REG_DWORD, (const BYTE*)(&bDevm), sizeof(BOOL)); RegSetValueEx (hkey, L"SystemEncryptionUpdate", 0, REG_DWORD, (const BYTE*)(&SystemEncryptionUpdate), sizeof(BOOL)); RegSetValueEx (hkey, L"bRestartRequired", 0, REG_DWORD, (const BYTE*)(&bRestartRequired), sizeof(BOOL)); RegSetValueEx (hkey, L"bDisableSwapFiles", 0, REG_DWORD, (const BYTE*)(&bDisableSwapFiles), sizeof(BOOL)); @@ -3619,60 +3463,61 @@ EXTERN_C UINT STDAPICALLTYPE VC_CustomAction_DoChecks(MSIHANDLE hInstaller) else { MSILog(hInstaller, MSI_ERROR_LEVEL, L"End VC_CustomAction_DoChecks: Could not read from registry"); goto end; } // Get this MSI Installer HWND. // There cannot be 2 MSIs or more running at the same time, so we're sure we'll get ours. // This is only possible in case of non silent install. hwndDlg = FindWindow(L"MsiDialogCloseClass", NULL); if (!hwndDlg && !Silent) { MSILog(hInstaller, MSI_ERROR_LEVEL, L"VC_CustomAction_DoChecks: MsiDialogCloseClass not found"); goto end; } /* Start actual work */ if (bRefreshExts) { MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: Will refresh file extensions"); SHChangeNotify (SHCNE_ASSOCCHANGED, SHCNF_IDLIST, NULL, NULL); } // Check if reboot was required by the pre/post-install and set Wix property ISREBOOTREQUIRED accordingly. if (bRestartRequired) { if (bDisableReboot) { MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: reboot is required but it is disabled because \"REBOOT\" specifies ReallySuppress"); + uiRet = ERROR_SUCCESS; } else { MSILog(hInstaller, MSI_INFO_LEVEL, L"VC_CustomAction_DoChecks: reboot is required"); uiRet = MsiSetProperty(hInstaller, L"ISREBOOTREQUIRED", L"1"); } } else { uiRet = ERROR_SUCCESS; } // Remove volatile regkeys SHDeleteKey(HKEY_LOCAL_MACHINE, L"Software\\.VeraCrypt"); end: MSILog(hInstaller, MSI_INFO_LEVEL, L"End VC_CustomAction_DoChecks"); return uiRet; } BOOL WINAPI DllMain( HMODULE hInstDLL, DWORD dwReason, LPVOID lpvReserved) { UNREFERENCED_PARAMETER(lpvReserved); /* Save the instance handle for later, diff --git a/src/SetupDLL/Setup.rc b/src/SetupDLL/Setup.rc index fb316a60..5d260186 100644 --- a/src/SetupDLL/Setup.rc +++ b/src/SetupDLL/Setup.rc @@ -1,141 +1,142 @@ // Microsoft Visual C++ generated resource script. // #include "resource.h" #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // // Generated from the TEXTINCLUDE 2 resource. // #include "winres.h" #include "..\\common\\resource.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // English (U.S.) resources #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) #ifdef _WIN32 LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) #endif //_WIN32 ///////////////////////////////////////////////////////////////////////////// // // Version // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,26,4,0 - PRODUCTVERSION 1,26,4,0 + FILEVERSION 1,26,15,0 + PRODUCTVERSION 1,26,15,0 FILEFLAGSMASK 0x17L #ifdef _DEBUG FILEFLAGS 0x1L #else FILEFLAGS 0x0L #endif FILEOS 0x4L FILETYPE 0x1L FILESUBTYPE 0x0L BEGIN BLOCK "StringFileInfo" BEGIN BLOCK "040904b0" BEGIN VALUE "CompanyName", "IDRIX" VALUE "FileDescription", "VeraCryptSetup" - VALUE "FileVersion", "1.26.4" + VALUE "FileVersion", "1.26.15" VALUE "LegalTrademarks", "VeraCrypt" VALUE "OriginalFilename", "VeraCryptSetup.dll" VALUE "ProductName", "VeraCrypt" - VALUE "ProductVersion", "1.26.4" + VALUE "ProductVersion", "1.26.15" END END BLOCK "VarFileInfo" BEGIN VALUE "Translation", 0x409, 1200 END END ///////////////////////////////////////////////////////////////////////////// // // HEADER // IDR_SETUP_RSRC_HEADER HEADER "resource.h" ///////////////////////////////////////////////////////////////////////////// // // REGISTRY // IDR_COMREG REGISTRY "ComSetup.rgs" ///////////////////////////////////////////////////////////////////////////// // // LANGUAGES // IDR_LANG_AR LANGUAGES "..\\..\\Translations\\Language.ar.xml" IDR_LANG_CS LANGUAGES "..\\..\\Translations\\Language.cs.xml" IDR_LANG_DE LANGUAGES "..\\..\\Translations\\Language.de.xml" IDR_LANG_ES LANGUAGES "..\\..\\Translations\\Language.es.xml" IDR_LANG_FR LANGUAGES "..\\..\\Translations\\Language.fr.xml" IDR_LANG_IT LANGUAGES "..\\..\\Translations\\Language.it.xml" IDR_LANG_JA LANGUAGES "..\\..\\Translations\\Language.ja.xml" IDR_LANG_NL LANGUAGES "..\\..\\Translations\\Language.nl.xml" IDR_LANG_PL LANGUAGES "..\\..\\Translations\\Language.pl.xml" IDR_LANG_RO LANGUAGES "..\\..\\Translations\\Language.ro.xml" IDR_LANG_RU LANGUAGES "..\\..\\Translations\\Language.ru.xml" IDR_LANG_VI LANGUAGES "..\\..\\Translations\\Language.vi.xml" IDR_LANG_ZHCN LANGUAGES "..\\..\\Translations\\Language.zh-cn.xml" IDR_LANG_ZHHK LANGUAGES "..\\..\\Translations\\Language.zh-hk.xml" IDR_LANG_BE LANGUAGES "..\\..\\Translations\\Language.be.xml" IDR_LANG_BG LANGUAGES "..\\..\\Translations\\Language.bg.xml" IDR_LANG_CA LANGUAGES "..\\..\\Translations\\Language.ca.xml" IDR_LANG_CO LANGUAGES "..\\..\\Translations\\Language.co.xml" IDR_LANG_DA LANGUAGES "..\\..\\Translations\\Language.da.xml" IDR_LANG_EL LANGUAGES "..\\..\\Translations\\Language.el.xml" IDR_LANG_ET LANGUAGES "..\\..\\Translations\\Language.et.xml" IDR_LANG_EU LANGUAGES "..\\..\\Translations\\Language.eu.xml" IDR_LANG_FA LANGUAGES "..\\..\\Translations\\Language.fa.xml" IDR_LANG_FI LANGUAGES "..\\..\\Translations\\Language.fi.xml" IDR_LANG_HE LANGUAGES "..\\..\\Translations\\Language.he.xml" IDR_LANG_HU LANGUAGES "..\\..\\Translations\\Language.hu.xml" IDR_LANG_ID LANGUAGES "..\\..\\Translations\\Language.id.xml" IDR_LANG_KA LANGUAGES "..\\..\\Translations\\Language.ka.xml" IDR_LANG_KO LANGUAGES "..\\..\\Translations\\Language.ko.xml" IDR_LANG_LV LANGUAGES "..\\..\\Translations\\Language.lv.xml" +IDR_LANG_NB LANGUAGES "..\\..\\Translations\\Language.nb.xml" IDR_LANG_NN LANGUAGES "..\\..\\Translations\\Language.nn.xml" IDR_LANG_PTBR LANGUAGES "..\\..\\Translations\\Language.pt-br.xml" IDR_LANG_SK LANGUAGES "..\\..\\Translations\\Language.sk.xml" IDR_LANG_SL LANGUAGES "..\\..\\Translations\\Language.sl.xml" IDR_LANG_SV LANGUAGES "..\\..\\Translations\\Language.sv.xml" IDR_LANG_TH LANGUAGES "..\\..\\Translations\\Language.th.xml" IDR_LANG_TR LANGUAGES "..\\..\\Translations\\Language.tr.xml" IDR_LANG_UK LANGUAGES "..\\..\\Translations\\Language.uk.xml" IDR_LANG_UZ LANGUAGES "..\\..\\Translations\\Language.uz.xml" IDR_LANG_ZHTW LANGUAGES "..\\..\\Translations\\Language.zh-tw.xml" ///////////////////////////////////////////////////////////////////////////// // // Dialog // IDD_UNINSTALL DIALOGEX 0, 0, 349, 234 STYLE DS_SETFONT | DS_SETFOREGROUND | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU CAPTION "Uninstall VeraCrypt" CLASS "VeraCryptCustomDlg" FONT 8, "MS Shell Dlg", 0, 0, 0x0 BEGIN LTEXT "Click Uninstall to remove VeraCrypt from this system.",IDT_UNINSTALL_DIR,8,8,334,8 LISTBOX IDC_LOG_WINDOW,7,21,335,179,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | WS_VSCROLL DEFPUSHBUTTON "&Uninstall",IDC_UNINSTALL,236,213,50,14 PUSHBUTTON "Cancel",IDCANCEL,292,213,50,14 CONTROL "Create System &Restore point",IDC_SYSTEM_RESTORE,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,215,194,10 CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,2,206,347,1,WS_EX_STATICEDGE CONTROL "",IDC_STATIC,"Static",SS_ETCHEDHORZ,1,1,348,1,WS_EX_STATICEDGE END diff --git a/src/SetupDLL/SetupDLL.vcxproj b/src/SetupDLL/SetupDLL.vcxproj index 74f86276..7eb24a66 100644 --- a/src/SetupDLL/SetupDLL.vcxproj +++ b/src/SetupDLL/SetupDLL.vcxproj @@ -64,139 +64,139 @@ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir> <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">Release\</IntDir> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptSetup</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptSetup</TargetName> <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptSetup</TargetName> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <Optimization>Disabled</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <MinimalRebuild>true</MinimalRebuild> <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>EditAndContinue</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>version.lib;msi.lib;libcmtd.lib;atlsd.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.dll</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <ProgramDatabaseFile>$(OutDir)Setup.pdb</ProgramDatabaseFile> <SubSystem>Windows</SubSystem> <RandomizedBaseAddress>false</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <ModuleDefinitionFile>SetupDLL.def</ModuleDefinitionFile> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>md "..\Debug\Setup Files" 2>NUL: copy Debug\VeraCryptSetup.dll "..\Debug\Setup Files\VeraCryptSetup.dll" >NUL: </Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4995;4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>version.lib;msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.dll</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> <ModuleDefinitionFile>SetupDLL.def</ModuleDefinitionFile> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"</Command> </PostBuildEvent> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> <ClCompile> <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> <Optimization>MaxSpeed</Optimization> <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> <PreprocessorDefinitions>SETUP;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> <BufferSecurityCheck>true</BufferSecurityCheck> <PrecompiledHeader> </PrecompiledHeader> <AssemblerOutput>All</AssemblerOutput> <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> <WarningLevel>Level4</WarningLevel> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> </ClCompile> <Link> <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> <AdditionalDependencies>version.lib;msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> - <DelayLoadDLLs>user32.dll;gdi32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;mpr.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <GenerateDebugInformation>true</GenerateDebugInformation> <GenerateMapFile>true</GenerateMapFile> <SubSystem>Windows</SubSystem> <OptimizeReferences>true</OptimizeReferences> <EnableCOMDATFolding>true</EnableCOMDATFolding> <RandomizedBaseAddress>true</RandomizedBaseAddress> <DataExecutionPrevention>true</DataExecutionPrevention> <TargetMachine>MachineX86</TargetMachine> </Link> <Manifest> <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> </Manifest> <PostBuildEvent> <Command>copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"</Command> </PostBuildEvent> <ResourceCompile> <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ResourceCompile> </ItemDefinitionGroup> <ItemGroup> <ClCompile Include="ComSetup.cpp" /> <ClCompile Include="Dir.c" /> <ClCompile Include="Setup.c"> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> </ClCompile> <ClCompile Include="..\Common\Xml.c" /> <ClCompile Include="..\Common\BootEncryption.cpp" /> <ClCompile Include="..\Common\Crc.c" /> diff --git a/src/SetupDLL/SetupDLL_vs2019.vcxproj b/src/SetupDLL/SetupDLL_vs2019.vcxproj new file mode 100644 index 00000000..a7c2703c --- /dev/null +++ b/src/SetupDLL/SetupDLL_vs2019.vcxproj @@ -0,0 +1,264 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="ReleaseCustomEFI|Win32"> + <Configuration>ReleaseCustomEFI</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{ADD324E2-ADC8-402E-87EB-03E4E26B1B49}</ProjectGuid> + <RootNamespace>Setup</RootNamespace> + <Keyword>Win32Proj</Keyword> + <ProjectName>SetupDLL</ProjectName> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>DynamicLibrary</ConfigurationType> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v142</PlatformToolset> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.40219.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(ProjectDir)Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</GenerateManifest> + <EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</EmbedManifest> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)Release\</OutDir> + <OutDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(ProjectDir)Release\</IntDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">$(ProjectDir)Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">false</LinkIncremental> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</GenerateManifest> + <GenerateManifest Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</GenerateManifest> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">VeraCryptSetup</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">VeraCryptSetup</TargetName> + <TargetName Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">VeraCryptSetup</TargetName> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;DEBUG;_DEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <MinimalRebuild>true</MinimalRebuild> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/NODEFAULTLIB:LIBCMTD %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>version.lib;msi.lib;libcmtd.lib;atls.lib;mpr.lib;..\Common\Debug\Zip.lib;..\Crypto\Debug\crypto.lib;..\Common\Debug\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.dll</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>$(OutDir)Setup.pdb</ProgramDatabaseFile> + <SubSystem>Windows</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + <ModuleDefinitionFile>SetupDLL.def</ModuleDefinitionFile> + <GenerateMapFile>true</GenerateMapFile> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>md "..\Debug\Setup Files" 2>NUL: +copy Debug\VeraCryptSetup.dll "..\Debug\Setup Files\VeraCryptSetup.dll" >NUL: +</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;SETUP_DLL;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4995;4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + <ControlFlowGuard>Guard</ControlFlowGuard> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>version.lib;atls.lib;msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.dll</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + <ModuleDefinitionFile>SetupDLL.def</ModuleDefinitionFile> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"</Command> + </PostBuildEvent> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'"> + <ClCompile> + <AdditionalOptions>/w34189 %(AdditionalOptions)</AdditionalOptions> + <Optimization>MaxSpeed</Optimization> + <AdditionalIncludeDirectories>..\Common;..\Crypto;..\;..\PKCS11;..\Common\zlib;..\Common\libzip;..\Common\lzma;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>SETUP;VC_EFI_CUSTOM_MODE;WIN32;HAVE_CONFIG_H;ZIP_STATIC;NDEBUG;_WINDOWS;_CRT_SECURE_NO_DEPRECATE;_CRT_NON_CONFORMING_SWPRINTFS;_ATL_NO_DEFAULT_LIBS;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <BufferSecurityCheck>true</BufferSecurityCheck> + <PrecompiledHeader> + </PrecompiledHeader> + <AssemblerOutput>All</AssemblerOutput> + <AssemblerListingLocation>$(IntDir)</AssemblerListingLocation> + <WarningLevel>Level4</WarningLevel> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <DisableSpecificWarnings>4057;4100;4127;4201;4505;4701;4706;4131;%(DisableSpecificWarnings)</DisableSpecificWarnings> + </ClCompile> + <Link> + <AdditionalOptions>/IGNORE:4089 %(AdditionalOptions)</AdditionalOptions> + <AdditionalDependencies>version.lib;msi.lib;mpr.lib;..\Common\Release\Zip.lib;..\Crypto\Release\crypto.lib;..\Common\Release\lzma.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>$(OutDir)VeraCryptSetup.exe</OutputFile> + <UACExecutionLevel>RequireAdministrator</UACExecutionLevel> + <DelayLoadDLLs>mpr.dll;bcrypt.dll;user32.dll;gdi32.dll;comdlg32.dll;advapi32.dll;shell32.dll;ole32.dll;oleaut32.dll;shlwapi.dll;setupapi.dll;wintrust.dll;comctl32.dll;%(DelayLoadDLLs)</DelayLoadDLLs> + <GenerateDebugInformation>true</GenerateDebugInformation> + <GenerateMapFile>true</GenerateMapFile> + <SubSystem>Windows</SubSystem> + <OptimizeReferences>true</OptimizeReferences> + <EnableCOMDATFolding>true</EnableCOMDATFolding> + <RandomizedBaseAddress>true</RandomizedBaseAddress> + <DataExecutionPrevention>true</DataExecutionPrevention> + <TargetMachine>MachineX86</TargetMachine> + </Link> + <Manifest> + <AdditionalManifestFiles>Setup.manifest;%(AdditionalManifestFiles)</AdditionalManifestFiles> + </Manifest> + <PostBuildEvent> + <Command>copy Release\VeraCryptSetup.dll "..\Release\Setup Files\VeraCryptSetup.dll"</Command> + </PostBuildEvent> + <ResourceCompile> + <PreprocessorDefinitions>VC_EFI_CUSTOM_MODE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + </ResourceCompile> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="ComSetup.cpp" /> + <ClCompile Include="Dir.c" /> + <ClCompile Include="Setup.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Xml.c" /> + <ClCompile Include="..\Common\BootEncryption.cpp" /> + <ClCompile Include="..\Common\Crc.c" /> + <ClCompile Include="..\Common\Dictionary.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">CompileAsCpp</CompileAs> + <CompileAs Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">CompileAsCpp</CompileAs> + </ClCompile> + <ClCompile Include="..\Common\Endian.c" /> + <ClCompile Include="..\Common\Language.c" /> + <ClCompile Include="..\Common\Registry.c" /> + </ItemGroup> + <ItemGroup> + <None Include="ComSetup.rgs" /> + <None Include="Setup.ico" /> + <None Include="..\Common\VeraCrypt.ico" /> + <None Include="SetupDLL.def" /> + <None Include="VeraCrypt_setup.bmp" /> + <None Include="VeraCrypt_setup_background.bmp" /> + <None Include="..\Common\VeraCrypt_Volume.ico" /> + <None Include="..\Common\Language.xml" /> + <None Include="..\Resources\Texts\License.rtf" /> + <None Include="..\Common\Textual_logo_288dpi.bmp" /> + <None Include="..\Common\Textual_logo_96dpi.bmp" /> + <None Include="..\Common\Textual_logo_background.bmp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h" /> + <ClInclude Include="..\Common\Combo.h" /> + <ClInclude Include="ComSetup.h" /> + <ClInclude Include="..\Common\Crc.h" /> + <ClInclude Include="Dir.h" /> + <ClInclude Include="..\Common\Dlgcode.h" /> + <ClInclude Include="..\Common\Exception.h" /> + <ClInclude Include="..\Common\Inflate.h" /> + <ClInclude Include="..\Common\Language.h" /> + <ClInclude Include="..\Common\Registry.h" /> + <ClInclude Include="..\Common\Resource.h" /> + <ClInclude Include="Resource.h" /> + <ClInclude Include="Setup.h" /> + <ClInclude Include="..\Common\Tcdefs.h" /> + </ItemGroup> + <ItemGroup> + <Manifest Include="Setup.manifest" /> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="Setup.rc" /> + <ResourceCompile Include="..\Common\Common.rc"> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild> + <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='ReleaseCustomEFI|Win32'">true</ExcludedFromBuild> + </ResourceCompile> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project>
\ No newline at end of file diff --git a/src/SetupDLL/SetupDLL_vs2019.vcxproj.filters b/src/SetupDLL/SetupDLL_vs2019.vcxproj.filters new file mode 100644 index 00000000..e0429539 --- /dev/null +++ b/src/SetupDLL/SetupDLL_vs2019.vcxproj.filters @@ -0,0 +1,150 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <ClCompile Include="..\Common\Xml.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="ComSetup.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Dir.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\Endian.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="Setup.c"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="..\Common\BootEncryption.cpp"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dictionary.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Dlgcode.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Language.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Registry.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + <ClCompile Include="..\Common\Crc.c"> + <Filter>Source Files\Common</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="..\Common\Apidrvr.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Combo.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="ComSetup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Crc.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Dir.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Dlgcode.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Exception.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Inflate.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Language.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Registry.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Resource.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="Setup.h"> + <Filter>Header Files</Filter> + </ClInclude> + <ClInclude Include="..\Common\Tcdefs.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> + <ItemGroup> + <ResourceCompile Include="Setup.rc"> + <Filter>Resource Files</Filter> + </ResourceCompile> + <ResourceCompile Include="..\Common\Common.rc"> + <Filter>Resource Files\Common</Filter> + </ResourceCompile> + </ItemGroup> + <ItemGroup> + <None Include="Setup.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="VeraCrypt_setup_background.bmp"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\VeraCrypt_Volume.ico"> + <Filter>Resource Files</Filter> + </None> + <None Include="..\Common\Language.xml"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Resources\Texts\License.rtf"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_288dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_96dpi.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="..\Common\Textual_logo_background.bmp"> + <Filter>Resource Files\Common</Filter> + </None> + <None Include="ComSetup.rgs"> + <Filter>Source Files</Filter> + </None> + <None Include="SetupDLL.def"> + <Filter>Source Files</Filter> + </None> + </ItemGroup> + <ItemGroup> + <Filter Include="Header Files"> + <UniqueIdentifier>{abfa03d7-3de7-4832-b36d-5b45cd0fc304}</UniqueIdentifier> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{d912b4b9-7f5e-4063-8af7-4d544dde2233}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files"> + <UniqueIdentifier>{5a0efac0-b028-4388-a278-1fe6dc479d79}</UniqueIdentifier> + </Filter> + <Filter Include="Resource Files\Common"> + <UniqueIdentifier>{3cb669f1-3949-43f4-a1e5-3b5d0fd75f76}</UniqueIdentifier> + </Filter> + <Filter Include="Source Files\Common"> + <UniqueIdentifier>{92f9499e-670d-464b-9edf-c1a2c56fb813}</UniqueIdentifier> + </Filter> + </ItemGroup> + <ItemGroup> + <Manifest Include="Setup.manifest"> + <Filter>Resource Files</Filter> + </Manifest> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/src/SetupDLL/SetupDLL_vs2019.vcxproj.user b/src/SetupDLL/SetupDLL_vs2019.vcxproj.user new file mode 100644 index 00000000..ace9a86a --- /dev/null +++ b/src/SetupDLL/SetupDLL_vs2019.vcxproj.user @@ -0,0 +1,3 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +</Project>
\ No newline at end of file diff --git a/src/Signing/sign.bat b/src/Signing/sign.bat index 1165be22..7205849d 100644 --- a/src/Signing/sign.bat +++ b/src/Signing/sign.bat @@ -1,58 +1,74 @@ -PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip +PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip;C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86 -set VC_VERSION=1.26.4 -set VC_VERSION_NBRE=1.26.4 +set VC_VERSION=1.26.15 +set VC_VERSION_NBRE=1.26.15 set SIGNINGPATH=%~dp0 cd %SIGNINGPATH% call "..\..\doc\chm\create_chm.bat" cd %SIGNINGPATH% rem sign using SHA-256 signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt-arm64.exe" "..\Release\Setup Files\VeraCrypt Format-arm64.exe" "..\Release\Setup Files\VeraCryptExpander-arm64.exe" "..\Release\Setup Files\VeraCryptSetup.dll" rem create setup and MSI cd "..\Release\Setup Files\" copy ..\..\LICENSE . copy ..\..\License.txt . copy ..\..\NOTICE . copy ..\..\Resources\Texts\License.rtf . copy ..\..\Common\VeraCrypt.ico . copy ..\..\Setup\VeraCrypt_setup_background.bmp . copy ..\..\Setup\VeraCrypt_setup.bmp . copy ..\..\Setup\Setup.ico . del *.xml rmdir /S /Q Languages mkdir Languages -copy /V /Y ..\..\..\Translations\*.xml Languages\. + +@echo off +setlocal + +rem Define the source and target directories +set "SOURCE_DIR=..\..\..\Translations" +set "TARGET_DIR=Languages" + +rem Copy files matching Language.xx.xml where xx is any two characters +copy /V /Y "%SOURCE_DIR%\Language.??.xml" "%TARGET_DIR%\." + +rem Copy files matching Language.xx-yy.xml where xx and yy are any two characters +copy /V /Y "%SOURCE_DIR%\Language.??-??.xml" "%TARGET_DIR%\." + +endlocal +@echo on + del Languages.zip 7z a -y Languages.zip Languages rmdir /S /Q docs mkdir docs\html\en mkdir docs\EFI-DCS xcopy /E /V /Y ..\..\..\doc\html\* docs\html\en\. copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\. copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\. del docs.zip 7z a -y docs.zip docs "VeraCrypt Setup.exe" /p "VeraCrypt Portable.exe" /p VeraCryptCOMRegBase.exe /p cd %SIGNINGPATH% signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt COMReg.exe" cd "..\Release\Setup Files\" call build_msi_x64.bat %VC_VERSION_NBRE% del LICENSE del License.txt del NOTICE del License.rtf del VeraCrypt.ico del VeraCrypt_setup_background.bmp del VeraCrypt_setup.bmp del Setup.ico del "VeraCrypt User Guide.chm" del Languages.zip del docs.zip diff --git a/src/Signing/sign_TESTSIGNING.bat b/src/Signing/sign_TESTSIGNING.bat index 858fa442..ac8d8390 100644 --- a/src/Signing/sign_TESTSIGNING.bat +++ b/src/Signing/sign_TESTSIGNING.bat @@ -1,34 +1,34 @@ PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip -set VC_VERSION=1.26-TESTSIGNING -set VC_VERSION_NBRE=1.26.0 +set VC_VERSION=1.26.15 +set VC_VERSION_NBRE=1.26.15 set SIGNINGPATH=%~dp0 cd %SIGNINGPATH% rem sign using SHA-256 signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" signtool sign /v /sha1 88c1ff4b7469ea3915bd8e7635a7567d34f43202 /ac GlobalSign_SHA256_EV_CodeSigning_CA.cer /fd sha256 /tr http://timestamp.digicert.com /td SHA256 "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt-arm64.exe" "..\Release\Setup Files\VeraCrypt Format-arm64.exe" "..\Release\Setup Files\VeraCryptExpander-arm64.exe" "..\Release\Setup Files\VeraCrypt COMReg.exe" "..\Release\Setup Files\VeraCryptSetup.dll" rem create setup and MSI cd "..\Release\Setup Files\" copy ..\..\LICENSE . copy ..\..\License.txt . copy ..\..\NOTICE . copy ..\..\Resources\Texts\License.rtf . copy ..\..\Common\VeraCrypt.ico . copy ..\..\Setup\VeraCrypt_setup_background.bmp . copy ..\..\Setup\VeraCrypt_setup.bmp . copy ..\..\Setup\Setup.ico . del *.xml rmdir /S /Q Languages mkdir Languages copy /V /Y ..\..\..\Translations\*.xml Languages\. del Languages.zip 7z a -y Languages.zip Languages rmdir /S /Q docs mkdir docs\html\en mkdir docs\EFI-DCS copy /V /Y ..\..\..\doc\html\* docs\html\en\. copy "..\..\..\doc\chm\VeraCrypt User Guide.chm" docs\. copy "..\..\..\doc\EFI-DCS\*.pdf" docs\EFI-DCS\. diff --git a/src/Signing/sign_test.bat b/src/Signing/sign_test.bat index 8fbc2fa6..c3e89a9f 100644 --- a/src/Signing/sign_test.bat +++ b/src/Signing/sign_test.bat @@ -1,33 +1,33 @@ PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip -set VC_VERSION=1.26.4 -set VC_VERSION_NBRE=1.26.4 +set VC_VERSION=1.26.15 +set VC_VERSION_NBRE=1.26.15 set PFXNAME=TestCertificate\idrix_codeSign.pfx set PFXPASSWORD=idrix set PFXCA=TestCertificate\idrix_TestRootCA.crt set SHA256PFXNAME=TestCertificate\idrix_Sha256CodeSign.pfx set SHA256PFXPASSWORD=idrix set SHA256PFXCA=TestCertificate\idrix_SHA256TestRootCA.crt set SIGNINGPATH=%~dp0 cd %SIGNINGPATH% call "..\..\doc\chm\create_chm.bat" cd %SIGNINGPATH% rem sign using SHA-1 signtool sign /v /a /f %PFXNAME% /p %PFXPASSWORD% /ac %PFXCA% /fd sha1 /t http://timestamp.digicert.com "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt COMReg.exe" timeout /t 10 rem sign using SHA-256 signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /as /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Release\Setup Files\veracrypt.sys" "..\Release\Setup Files\veracrypt-x64.sys" "..\Release\Setup Files\veracrypt-arm64.sys" "..\Release\Setup Files\VeraCrypt.exe" "..\Release\Setup Files\VeraCrypt Format.exe" "..\Release\Setup Files\VeraCryptExpander.exe" "..\Release\Setup Files\VeraCrypt-x64.exe" "..\Release\Setup Files\VeraCrypt Format-x64.exe" "..\Release\Setup Files\VeraCryptExpander-x64.exe" "..\Release\Setup Files\VeraCrypt-arm64.exe" "..\Release\Setup Files\VeraCrypt Format-arm64.exe" "..\Release\Setup Files\VeraCryptExpander-arm64.exe" "..\Release\Setup Files\VeraCrypt COMReg.exe" rem create setup and MSI cd "..\Release\Setup Files\" copy ..\..\LICENSE . copy ..\..\License.txt . copy ..\..\NOTICE . copy ..\..\Resources\Texts\License.rtf . copy ..\..\Common\VeraCrypt.ico . copy ..\..\Setup\VeraCrypt_setup_background.bmp . diff --git a/src/Signing/sign_test_debug.bat b/src/Signing/sign_test_debug.bat index 6fe07866..fa701681 100644 --- a/src/Signing/sign_test_debug.bat +++ b/src/Signing/sign_test_debug.bat @@ -1,33 +1,33 @@ PATH=%PATH%;%WSDK81%\bin\x86;C:\Program Files\7-Zip;C:\Program Files (x86)\7-Zip -set VC_VERSION=1.26 -set VC_VERSION_NBRE=1.26.0 +set VC_VERSION=1.26.15 +set VC_VERSION_NBRE=1.26.15 set PFXNAME=TestCertificate\idrix_codeSign.pfx set PFXPASSWORD=idrix set PFXCA=TestCertificate\idrix_TestRootCA.crt set SHA256PFXNAME=TestCertificate\idrix_Sha256CodeSign.pfx set SHA256PFXPASSWORD=idrix set SHA256PFXCA=TestCertificate\idrix_SHA256TestRootCA.crt set SIGNINGPATH=%~dp0 cd %SIGNINGPATH% call "..\..\doc\chm\create_chm.bat" cd %SIGNINGPATH% rem sign using SHA-256 signtool sign /v /a /f %SHA256PFXNAME% /p %SHA256PFXPASSWORD% /ac %SHA256PFXCA% /fd sha256 /tr http://rfc3161timestamp.globalsign.com/advanced /td SHA256 "..\Debug\Setup Files\veracrypt.sys" "..\Debug\Setup Files\veracrypt-x64.sys" "..\Debug\Setup Files\veracrypt-arm64.sys" "..\Debug\Setup Files\VeraCrypt.exe" "..\Debug\Setup Files\VeraCrypt Format.exe" "..\Debug\Setup Files\VeraCryptExpander.exe" "..\Debug\Setup Files\VeraCrypt-x64.exe" "..\Debug\Setup Files\VeraCrypt Format-x64.exe" "..\Debug\Setup Files\VeraCryptExpander-x64.exe" "..\Debug\Setup Files\VeraCrypt-arm64.exe" "..\Debug\Setup Files\VeraCrypt Format-arm64.exe" "..\Debug\Setup Files\VeraCryptExpander-arm64.exe" "..\Debug\Setup Files\VeraCrypt COMReg.exe" rem create setup and MSI cd "..\Debug\Setup Files\" copy ..\..\LICENSE . copy ..\..\License.txt . copy ..\..\NOTICE . copy ..\..\Resources\Texts\License.rtf . copy ..\..\Common\VeraCrypt.ico . copy ..\..\Setup\VeraCrypt_setup_background.bmp . copy ..\..\Setup\VeraCrypt_setup.bmp . copy ..\..\Setup\Setup.ico . del *.xml rmdir /S /Q Languages diff --git a/src/VeraCrypt_vs2019.sln b/src/VeraCrypt_vs2019.sln index 5c440480..e8d70246 100644 --- a/src/VeraCrypt_vs2019.sln +++ b/src/VeraCrypt_vs2019.sln @@ -1,119 +1,156 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30711.63 MinimumVisualStudioVersion = 10.0.40219.1 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Crypto", "Crypto\Crypto_vs2019.vcxproj", "{993245CF-6B70-47EE-91BB-39F8FC6DC0E7}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Format", "Format\Format_vs2019.vcxproj", "{9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}" ProjectSection(ProjectDependencies) = postProject {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mount", "Mount\Mount_vs2019.vcxproj", "{E4C40F94-E7F9-4981-86E4-186B46F993F3}" ProjectSection(ProjectDependencies) = postProject {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ExpandVolume", "ExpandVolume\ExpandVolume_vs2019.vcxproj", "{9715FF1D-599B-4BBC-AD96-BEF6E08FF827}" ProjectSection(ProjectDependencies) = postProject {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Zip", "Common\Zip_vs2019.vcxproj", "{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "driver", "Driver\veracrypt_vs2019.vcxproj", "{4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Lzma", "Common\Lzma_vs2019.vcxproj", "{B896FE1F-6BF3-4F75-9148-F841829073D9}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Setup", "Setup\Setup_vs2019.vcxproj", "{DF5F654D-BD44-4E31-B92E-B68074DC37A8}" + ProjectSection(ProjectDependencies) = postProject + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} = {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} + {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} + {E4C40F94-E7F9-4981-86E4-186B46F993F3} = {E4C40F94-E7F9-4981-86E4-186B46F993F3} + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} = {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Portable", "Setup\Portable_vs2019.vcxproj", "{60698D56-DB83-4D19-9C87-9DFB6A6F8C87}" + ProjectSection(ProjectDependencies) = postProject + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} = {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} + {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} + {E4C40F94-E7F9-4981-86E4-186B46F993F3} = {E4C40F94-E7F9-4981-86E4-186B46F993F3} + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} = {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SetupDLL", "SetupDLL\SetupDLL_vs2019.vcxproj", "{ADD324E2-ADC8-402E-87EB-03E4E26B1B49}" + ProjectSection(ProjectDependencies) = postProject + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} = {9715FF1D-599B-4BBC-AD96-BEF6E08FF827} + {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} = {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC} + {E4C40F94-E7F9-4981-86E4-186B46F993F3} = {E4C40F94-E7F9-4981-86E4-186B46F993F3} + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} = {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "COMReg", "COMReg\COMReg_vs2019.vcxproj", "{C8914211-32AC-4F48-ACD9-8212E8DE53F3}" + ProjectSection(ProjectDependencies) = postProject + {B896FE1F-6BF3-4F75-9148-F841829073D9} = {B896FE1F-6BF3-4F75-9148-F841829073D9} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution All CustomEFI|ARM64 = All CustomEFI|ARM64 All CustomEFI|Win32 = All CustomEFI|Win32 All CustomEFI|x64 = All CustomEFI|x64 All Debug|ARM64 = All Debug|ARM64 All Debug|Win32 = All Debug|Win32 All Debug|x64 = All Debug|x64 All|ARM64 = All|ARM64 All|Win32 = All|Win32 All|x64 = All|x64 Boot Loader|ARM64 = Boot Loader|ARM64 Boot Loader|Win32 = Boot Loader|Win32 Boot Loader|x64 = Boot Loader|x64 Boot|ARM64 = Boot|ARM64 Boot|Win32 = Boot|Win32 Boot|x64 = Boot|x64 Debug|ARM64 = Debug|ARM64 Debug|Win32 = Debug|Win32 Debug|x64 = Debug|x64 Driver Debug|ARM64 = Driver Debug|ARM64 Driver Debug|Win32 = Driver Debug|Win32 Driver Debug|x64 = Driver Debug|x64 Driver x64 Debug|ARM64 = Driver x64 Debug|ARM64 Driver x64 Debug|Win32 = Driver x64 Debug|Win32 Driver x64 Debug|x64 = Driver x64 Debug|x64 Driver x64|ARM64 = Driver x64|ARM64 Driver x64|Win32 = Driver x64|Win32 Driver x64|x64 = Driver x64|x64 Driver x86 Debug|ARM64 = Driver x86 Debug|ARM64 Driver x86 Debug|Win32 = Driver x86 Debug|Win32 Driver x86 Debug|x64 = Driver x86 Debug|x64 Driver x86|ARM64 = Driver x86|ARM64 Driver x86|Win32 = Driver x86|Win32 Driver x86|x64 = Driver x86|x64 Driver|ARM64 = Driver|ARM64 Driver|Win32 = Driver|Win32 Driver|x64 = Driver|x64 Format Debug|ARM64 = Format Debug|ARM64 Format Debug|Win32 = Format Debug|Win32 Format Debug|x64 = Format Debug|x64 Format|ARM64 = Format|ARM64 Format|Win32 = Format|Win32 Format|x64 = Format|x64 Mount Debug|ARM64 = Mount Debug|ARM64 Mount Debug|Win32 = Mount Debug|Win32 Mount Debug|x64 = Mount Debug|x64 Mount|ARM64 = Mount|ARM64 Mount|Win32 = Mount|Win32 Mount|x64 = Mount|x64 Portable Debug|ARM64 = Portable Debug|ARM64 Portable Debug|Win32 = Portable Debug|Win32 Portable Debug|x64 = Portable Debug|x64 Portable|ARM64 = Portable|ARM64 Portable|Win32 = Portable|Win32 Portable|x64 = Portable|x64 + Release_SkipOsDriverReqCheck|ARM64 = Release_SkipOsDriverReqCheck|ARM64 + Release_SkipOsDriverReqCheck|Win32 = Release_SkipOsDriverReqCheck|Win32 + Release_SkipOsDriverReqCheck|x64 = Release_SkipOsDriverReqCheck|x64 Release|ARM64 = Release|ARM64 Release|Win32 = Release|Win32 Release|x64 = Release|x64 + ReleaseCustomEFI|ARM64 = ReleaseCustomEFI|ARM64 + ReleaseCustomEFI|Win32 = ReleaseCustomEFI|Win32 + ReleaseCustomEFI|x64 = ReleaseCustomEFI|x64 Setup Debug|ARM64 = Setup Debug|ARM64 Setup Debug|Win32 = Setup Debug|Win32 Setup Debug|x64 = Setup Debug|x64 Setup|ARM64 = Setup|ARM64 Setup|Win32 = Setup|Win32 Setup|x64 = Setup|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|Win32.Build.0 = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All CustomEFI|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|Win32.ActiveCfg = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|Win32.Build.0 = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|x64.ActiveCfg = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All Debug|x64.Build.0 = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|ARM64.ActiveCfg = Release|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|ARM64.Build.0 = Release|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|ARM64.Deploy.0 = Release|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|Win32.Build.0 = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.All|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Boot Loader|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Boot Loader|ARM64.Build.0 = Debug|ARM64 @@ -183,66 +220,78 @@ Global {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Format|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Format|Win32.Build.0 = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Format|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Format|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|Win32.Build.0 = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|x64.ActiveCfg = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount Debug|x64.Build.0 = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|Win32.Build.0 = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Mount|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|x64.ActiveCfg = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable Debug|x64.Build.0 = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Portable|x64.Build.0 = Release|x64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|ARM64.ActiveCfg = Release|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|ARM64.Build.0 = Release|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|Win32.Build.0 = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Release|x64.Build.0 = Release|x64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|ARM64.ActiveCfg = Release|ARM64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|ARM64.Build.0 = Release|ARM64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64 + {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.ReleaseCustomEFI|x64.Build.0 = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|x64.ActiveCfg = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup Debug|x64.Build.0 = Debug|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|ARM64.ActiveCfg = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|ARM64.Build.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|ARM64.Deploy.0 = Debug|ARM64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|Win32.ActiveCfg = Release|Win32 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|x64.ActiveCfg = Release|x64 {993245CF-6B70-47EE-91BB-39F8FC6DC0E7}.Setup|x64.Build.0 = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All CustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All CustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All CustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All CustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All CustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|ARM64.Build.0 = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|Win32.ActiveCfg = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|Win32.Build.0 = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|x64.ActiveCfg = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All Debug|x64.Build.0 = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|ARM64.ActiveCfg = Release|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|ARM64.Build.0 = Release|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|Win32.Build.0 = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.All|x64.Build.0 = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Boot Loader|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 @@ -296,66 +345,78 @@ Global {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format Debug|Win32.ActiveCfg = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format Debug|Win32.Build.0 = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format Debug|x64.ActiveCfg = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format Debug|x64.Build.0 = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|Win32.Build.0 = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Format|x64.Build.0 = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|x64.ActiveCfg = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount Debug|x64.Build.0 = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Mount|x64.Build.0 = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable Debug|x64.ActiveCfg = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable Debug|x64.Build.0 = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Portable|x64.Build.0 = Release|x64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|ARM64.ActiveCfg = Release|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|ARM64.Build.0 = Release|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|Win32.Build.0 = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Release|x64.Build.0 = Release|x64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|ARM64.Build.0 = ReleaseCustomEFI|ARM64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 + {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|x64.ActiveCfg = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup Debug|x64.Build.0 = Debug|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|Win32.ActiveCfg = Release|Win32 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|x64.ActiveCfg = Release|x64 {9DC1ABE2-D18B-48FB-81D2-8C50ADC57BCF}.Setup|x64.Build.0 = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All CustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All CustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All CustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All CustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All CustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|ARM64.Build.0 = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|Win32.ActiveCfg = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|Win32.Build.0 = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|x64.ActiveCfg = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All Debug|x64.Build.0 = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|ARM64.ActiveCfg = Release|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|ARM64.Build.0 = Release|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|Win32.Build.0 = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.All|x64.Build.0 = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Boot Loader|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Boot Loader|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Boot Loader|Win32.ActiveCfg = Release|Win32 @@ -407,66 +468,78 @@ Global {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format Debug|Win32.ActiveCfg = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format Debug|x64.ActiveCfg = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format Debug|x64.Build.0 = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Format|x64.Build.0 = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|Win32.Build.0 = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|x64.ActiveCfg = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount Debug|x64.Build.0 = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|Win32.Build.0 = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Mount|x64.Build.0 = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable Debug|x64.ActiveCfg = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable Debug|x64.Build.0 = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Portable|x64.Build.0 = Release|x64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|ARM64.ActiveCfg = Release|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|ARM64.Build.0 = Release|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|Win32.Build.0 = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Release|x64.Build.0 = Release|x64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|ARM64.Build.0 = ReleaseCustomEFI|ARM64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 + {E4C40F94-E7F9-4981-86E4-186B46F993F3}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|x64.ActiveCfg = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup Debug|x64.Build.0 = Debug|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|Win32.ActiveCfg = Release|Win32 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|x64.ActiveCfg = Release|x64 {E4C40F94-E7F9-4981-86E4-186B46F993F3}.Setup|x64.Build.0 = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All CustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All CustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All CustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All CustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All CustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|ARM64.Build.0 = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|Win32.ActiveCfg = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|Win32.Build.0 = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|x64.ActiveCfg = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All Debug|x64.Build.0 = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|ARM64.ActiveCfg = Release|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|ARM64.Build.0 = Release|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|Win32.Build.0 = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.All|x64.Build.0 = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot Loader|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot Loader|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Boot Loader|Win32.ActiveCfg = Release|Win32 @@ -528,66 +601,78 @@ Global {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format Debug|x64.Build.0 = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|Win32.Build.0 = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Format|x64.Build.0 = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|Win32.Build.0 = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|x64.ActiveCfg = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount Debug|x64.Build.0 = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|Win32.Build.0 = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Mount|x64.Build.0 = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|Win32.Build.0 = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|x64.ActiveCfg = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable Debug|x64.Build.0 = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Portable|x64.Build.0 = Release|x64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|ARM64.ActiveCfg = Release|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|ARM64.Build.0 = Release|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|Win32.Build.0 = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Release|x64.Build.0 = Release|x64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|ARM64.Build.0 = ReleaseCustomEFI|ARM64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|x64 + {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.ReleaseCustomEFI|x64.Build.0 = ReleaseCustomEFI|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|Win32.Build.0 = Debug|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|x64.ActiveCfg = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup Debug|x64.Build.0 = Debug|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|ARM64.ActiveCfg = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|ARM64.Build.0 = ReleaseCustomEFI|ARM64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|Win32.ActiveCfg = Release|Win32 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|x64.ActiveCfg = Release|x64 {9715FF1D-599B-4BBC-AD96-BEF6E08FF827}.Setup|x64.Build.0 = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All CustomEFI|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All CustomEFI|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All CustomEFI|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All CustomEFI|x64.ActiveCfg = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All CustomEFI|x64.Build.0 = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|Win32.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|Win32.Build.0 = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|x64.ActiveCfg = Debug|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All Debug|x64.Build.0 = Debug|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|ARM64.ActiveCfg = Release|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|ARM64.Build.0 = Release|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|x64.ActiveCfg = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.All|x64.Build.0 = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Boot Loader|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Boot Loader|ARM64.Build.0 = Debug|ARM64 @@ -637,65 +722,77 @@ Global {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format Debug|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format Debug|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format Debug|Win32.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format Debug|Win32.Build.0 = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format Debug|x64.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Format|x64.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount Debug|Win32.Build.0 = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount Debug|x64.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Mount|x64.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable Debug|Win32.Build.0 = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable Debug|x64.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Portable|x64.ActiveCfg = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|ARM64.ActiveCfg = Release|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|ARM64.Build.0 = Release|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Release|x64.ActiveCfg = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|ARM64.ActiveCfg = Release|ARM64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|ARM64.Build.0 = Release|ARM64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64 + {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.ReleaseCustomEFI|x64.Build.0 = Release|x64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|Win32.Build.0 = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup Debug|x64.ActiveCfg = Debug|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup|ARM64.ActiveCfg = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup|ARM64.Build.0 = Debug|ARM64 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup|Win32.ActiveCfg = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup|Win32.Build.0 = Release|Win32 {6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}.Setup|x64.ActiveCfg = Release|Win32 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All CustomEFI|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All CustomEFI|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All CustomEFI|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All Debug|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All Debug|Win32.ActiveCfg = Debug|Win32 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All Debug|x64.ActiveCfg = Debug|x64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All|ARM64.ActiveCfg = Release|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All|Win32.ActiveCfg = Release|Win32 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.All|x64.ActiveCfg = Release|x64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot Loader|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot Loader|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot Loader|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot Loader|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot Loader|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Boot|x64.ActiveCfg = Debug|ARM64 @@ -737,65 +834,83 @@ Global {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format Debug|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format Debug|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format Debug|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format Debug|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format Debug|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Format|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount Debug|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount Debug|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount Debug|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount Debug|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount Debug|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Mount|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable Debug|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable Debug|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable Debug|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable Debug|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable Debug|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Portable|x64.ActiveCfg = Debug|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|ARM64.Deploy.0 = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|Win32.Deploy.0 = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release_SkipOsDriverReqCheck|x64.Deploy.0 = Release|x64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release|ARM64.ActiveCfg = Release|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release|ARM64.Build.0 = Release|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release|ARM64.Deploy.0 = Release|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release|Win32.ActiveCfg = Release|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Release|x64.ActiveCfg = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|ARM64.ActiveCfg = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|ARM64.Build.0 = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|ARM64.Deploy.0 = Release|ARM64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|Win32.Deploy.0 = Release|Win32 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|x64.Build.0 = Release|x64 + {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.ReleaseCustomEFI|x64.Deploy.0 = Release|x64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup Debug|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup Debug|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup Debug|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup Debug|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup Debug|x64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup|ARM64.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup|ARM64.Build.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup|ARM64.Deploy.0 = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup|Win32.ActiveCfg = Debug|ARM64 {4B41C7B5-75C6-40A2-AF4D-55BC1E012BCD}.Setup|x64.ActiveCfg = Debug|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All CustomEFI|ARM64.ActiveCfg = Release|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All CustomEFI|Win32.ActiveCfg = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All CustomEFI|Win32.Build.0 = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All CustomEFI|x64.ActiveCfg = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All CustomEFI|x64.Build.0 = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|ARM64.ActiveCfg = Debug|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|ARM64.Build.0 = Debug|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All Debug|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|ARM64.ActiveCfg = Release|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|ARM64.Build.0 = Release|ARM64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|Win32.ActiveCfg = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|Win32.Build.0 = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|x64.ActiveCfg = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.All|x64.Build.0 = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Boot Loader|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Boot Loader|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Boot Loader|Win32.ActiveCfg = Debug|Win32 @@ -858,55 +973,575 @@ Global {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Format|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount Debug|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Mount|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable Debug|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Portable|x64.Build.0 = Debug|x64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release|ARM64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Release|ARM64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release|x64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release_SkipOsDriverReqCheck|x64.Build.0 = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release|ARM64.ActiveCfg = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release|Win32.ActiveCfg = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release|Win32.Build.0 = Release|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release|x64.ActiveCfg = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Release|x64.Build.0 = Release|x64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|ARM64.ActiveCfg = Release|ARM64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|ARM64.Build.0 = Release|ARM64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|x64.ActiveCfg = Release|x64 + {B896FE1F-6BF3-4F75-9148-F841829073D9}.ReleaseCustomEFI|x64.Build.0 = Release|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup Debug|x64.Build.0 = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|ARM64.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|ARM64.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|Win32.ActiveCfg = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|Win32.Build.0 = Debug|Win32 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|x64.ActiveCfg = Debug|x64 {B896FE1F-6BF3-4F75-9148-F841829073D9}.Setup|x64.Build.0 = Debug|x64 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All CustomEFI|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All CustomEFI|Win32.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All CustomEFI|Win32.Build.0 = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All CustomEFI|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All|ARM64.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All|Win32.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All|Win32.Build.0 = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.All|x64.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot Loader|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Boot|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64 Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x64|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86 Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver x86|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|Win32.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|Win32.Build.0 = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Driver|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Format|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Mount|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Portable|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|ARM64.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|Win32.Build.0 = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Release|x64.ActiveCfg = Release|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup Debug|x64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|ARM64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|ARM64.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|Win32.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|Win32.Build.0 = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|x64.ActiveCfg = Debug|Win32 + {DF5F654D-BD44-4E31-B92E-B68074DC37A8}.Setup|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All CustomEFI|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All CustomEFI|Win32.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All CustomEFI|Win32.Build.0 = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All CustomEFI|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All|ARM64.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All|Win32.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All|Win32.Build.0 = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.All|x64.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot Loader|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Boot|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64 Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x64|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86 Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver x86|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|Win32.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|Win32.Build.0 = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Driver|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Format|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Mount|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Portable|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Release_SkipOsDriverReqCheck|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|ARM64.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|Win32.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|Win32.Build.0 = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Release|x64.ActiveCfg = Release|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup Debug|x64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|ARM64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|ARM64.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|Win32.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|Win32.Build.0 = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|x64.ActiveCfg = Debug|Win32 + {60698D56-DB83-4D19-9C87-9DFB6A6F8C87}.Setup|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|Win32.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|Win32.Build.0 = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All CustomEFI|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|ARM64.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|Win32.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|Win32.Build.0 = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.All|x64.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot Loader|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Boot|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64 Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x64|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86 Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver x86|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Driver|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Format|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Mount|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Portable|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|Win32.Build.0 = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release_SkipOsDriverReqCheck|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|ARM64.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|Win32.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|Win32.Build.0 = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Release|x64.ActiveCfg = Release|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|ARM64.ActiveCfg = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|Win32.ActiveCfg = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|Win32.Build.0 = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.ReleaseCustomEFI|x64.ActiveCfg = ReleaseCustomEFI|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup Debug|x64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|ARM64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|ARM64.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|Win32.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|Win32.Build.0 = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|x64.ActiveCfg = Debug|Win32 + {ADD324E2-ADC8-402E-87EB-03E4E26B1B49}.Setup|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|Win32.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|Win32.Build.0 = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All CustomEFI|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|Win32.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|Win32.Build.0 = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.All|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot Loader|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Boot|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64 Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x64|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86 Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver x86|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Driver|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Format|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Mount|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Portable|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|Win32.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|Win32.Build.0 = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release_SkipOsDriverReqCheck|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release|ARM64.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release|Win32.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release|Win32.Build.0 = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Release|x64.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|Win32.ActiveCfg = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|Win32.Build.0 = Release|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.ReleaseCustomEFI|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup Debug|x64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|ARM64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|ARM64.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|Win32.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|Win32.Build.0 = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|x64.ActiveCfg = Debug|Win32 + {C8914211-32AC-4F48-ACD9-8212E8DE53F3}.Setup|x64.Build.0 = Debug|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {9318E49F-7067-4C2C-BE24-6EB573800B7D} EndGlobalSection EndGlobal diff --git a/src/Volume/Cipher.cpp b/src/Volume/Cipher.cpp index 8c6ce390..de240544 100644 --- a/src/Volume/Cipher.cpp +++ b/src/Volume/Cipher.cpp @@ -22,448 +22,502 @@ # include "Crypto/Aes_hw_cpu.h" #endif extern "C" int IsAesHwCpuSupported () { #ifdef TC_AES_HW_CPU static bool state = false; static bool stateValid = false; if (!stateValid) { state = HasAESNI() ? true : false; stateValid = true; } return state && VeraCrypt::Cipher::IsHwSupportEnabled(); #else return false; #endif } namespace VeraCrypt { Cipher::Cipher () : Initialized (false) { } Cipher::~Cipher () { } - void Cipher::DecryptBlock (byte *data) const + void Cipher::DecryptBlock (uint8 *data) const { if (!Initialized) throw NotInitialized (SRC_POS); Decrypt (data); } - void Cipher::DecryptBlocks (byte *data, size_t blockCount) const + void Cipher::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); while (blockCount-- > 0) { Decrypt (data); data += GetBlockSize(); } } - void Cipher::EncryptBlock (byte *data) const + void Cipher::EncryptBlock (uint8 *data) const { if (!Initialized) throw NotInitialized (SRC_POS); Encrypt (data); } - void Cipher::EncryptBlocks (byte *data, size_t blockCount) const + void Cipher::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); while (blockCount-- > 0) { Encrypt (data); data += GetBlockSize(); } } CipherList Cipher::GetAvailableCiphers () { CipherList l; l.push_back (shared_ptr <Cipher> (new CipherAES ())); + #ifndef WOLFCRYPT_BACKEND l.push_back (shared_ptr <Cipher> (new CipherSerpent ())); l.push_back (shared_ptr <Cipher> (new CipherTwofish ())); l.push_back (shared_ptr <Cipher> (new CipherCamellia ())); l.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); - + #endif return l; } void Cipher::SetKey (const ConstBufferPtr &key) { if (key.Size() != GetKeySize ()) throw ParameterIncorrect (SRC_POS); if (!Initialized) ScheduledKey.Allocate (GetScheduledKeySize ()); SetCipherKey (key); Key.CopyFrom (key); Initialized = true; } + #ifdef WOLFCRYPT_BACKEND + void Cipher::SetKeyXTS (const ConstBufferPtr &key) + { + if (key.Size() != GetKeySize ()) + throw ParameterIncorrect (SRC_POS); + + if (!Initialized) + ScheduledKey.Allocate (GetScheduledKeySize ()); + + SetCipherKeyXTS (key); + Key.CopyFrom (key); + Initialized = true; + } + + void Cipher::EncryptBlockXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + if (!Initialized) + throw NotInitialized (SRC_POS); + + EncryptXTS (data, length, startDataUnitNo); + } + + void Cipher::DecryptBlockXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + if (!Initialized) + throw NotInitialized (SRC_POS); + + DecryptXTS (data, length, startDataUnitNo); + } + #endif + #define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) #undef TC_EXCEPTION_NODECL #define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET (CipherException); // AES - void CipherAES::Decrypt (byte *data) const + void CipherAES::Decrypt (uint8 *data) const { #ifdef TC_AES_HW_CPU if (IsHwSupportAvailable()) aes_hw_cpu_decrypt (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx), data); else #endif aes_decrypt (data, data, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))); } - void CipherAES::DecryptBlocks (byte *data, size_t blockCount) const + void CipherAES::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #ifdef TC_AES_HW_CPU if ((blockCount & (32 - 1)) == 0 && IsHwSupportAvailable()) { while (blockCount > 0) { aes_hw_cpu_decrypt_32_blocks (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx), data); data += 32 * GetBlockSize(); blockCount -= 32; } } else #endif Cipher::DecryptBlocks (data, blockCount); } - void CipherAES::Encrypt (byte *data) const + void CipherAES::Encrypt (uint8 *data) const { #ifdef TC_AES_HW_CPU if (IsHwSupportAvailable()) aes_hw_cpu_encrypt (ScheduledKey.Ptr(), data); else #endif aes_encrypt (data, data, (aes_encrypt_ctx *) ScheduledKey.Ptr()); } - void CipherAES::EncryptBlocks (byte *data, size_t blockCount) const + void CipherAES::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #ifdef TC_AES_HW_CPU if ((blockCount & (32 - 1)) == 0 && IsHwSupportAvailable()) { while (blockCount > 0) { aes_hw_cpu_encrypt_32_blocks (ScheduledKey.Ptr(), data); data += 32 * GetBlockSize(); blockCount -= 32; } } else #endif Cipher::EncryptBlocks (data, blockCount); } + #ifdef WOLFCRYPT_BACKEND + void CipherAES::EncryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + xts_encrypt (data, data, length, startDataUnitNo, (aes_encrypt_ctx *) ScheduledKey.Ptr()); + } + + void CipherAES::DecryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + xts_decrypt (data, data, length, startDataUnitNo, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))); + } + + void CipherAES::SetCipherKeyXTS (const uint8 *key) + { + if (xts_encrypt_key256 (key, (aes_encrypt_ctx *) ScheduledKey.Ptr()) != EXIT_SUCCESS) + throw CipherInitError (SRC_POS); + + if (xts_decrypt_key256 (key, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))) != EXIT_SUCCESS) + throw CipherInitError (SRC_POS); + } + #endif size_t CipherAES::GetScheduledKeySize () const { return sizeof(aes_encrypt_ctx) + sizeof(aes_decrypt_ctx); } bool CipherAES::IsHwSupportAvailable () const { #ifdef TC_AES_HW_CPU static bool state = false; static bool stateValid = false; if (!stateValid) { state = HasAESNI() ? true : false; stateValid = true; } return state && HwSupportEnabled; #else return false; #endif } - void CipherAES::SetCipherKey (const byte *key) + void CipherAES::SetCipherKey (const uint8 *key) { if (aes_encrypt_key256 (key, (aes_encrypt_ctx *) ScheduledKey.Ptr()) != EXIT_SUCCESS) throw CipherInitError (SRC_POS); if (aes_decrypt_key256 (key, (aes_decrypt_ctx *) (ScheduledKey.Ptr() + sizeof (aes_encrypt_ctx))) != EXIT_SUCCESS) throw CipherInitError (SRC_POS); } + #ifndef WOLFCRYPT_BACKEND // Serpent - void CipherSerpent::Decrypt (byte *data) const + void CipherSerpent::Decrypt (uint8 *data) const { serpent_decrypt (data, data, ScheduledKey); } - void CipherSerpent::Encrypt (byte *data) const + void CipherSerpent::Encrypt (uint8 *data) const { serpent_encrypt (data, data, ScheduledKey); } size_t CipherSerpent::GetScheduledKeySize () const { return 140*4; } - void CipherSerpent::SetCipherKey (const byte *key) + void CipherSerpent::SetCipherKey (const uint8 *key) { serpent_set_key (key, ScheduledKey); } - void CipherSerpent::EncryptBlocks (byte *data, size_t blockCount) const + void CipherSerpent::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(CRYPTOPP_DISABLE_ASM) if ((blockCount >= 4) && IsHwSupportAvailable()) { serpent_encrypt_blocks (data, data, blockCount, ScheduledKey.Ptr()); } else #endif Cipher::EncryptBlocks (data, blockCount); } - void CipherSerpent::DecryptBlocks (byte *data, size_t blockCount) const + void CipherSerpent::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined(CRYPTOPP_DISABLE_ASM) if ((blockCount >= 4) && IsHwSupportAvailable()) { serpent_decrypt_blocks (data, data, blockCount, ScheduledKey.Ptr()); } else #endif Cipher::DecryptBlocks (data, blockCount); } bool CipherSerpent::IsHwSupportAvailable () const { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE static bool state = false; static bool stateValid = false; if (!stateValid) { state = HasSSE2() ? true : false; stateValid = true; } return state; #else return false; #endif } // Twofish - void CipherTwofish::Decrypt (byte *data) const + void CipherTwofish::Decrypt (uint8 *data) const { twofish_decrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data); } - void CipherTwofish::Encrypt (byte *data) const + void CipherTwofish::Encrypt (uint8 *data) const { twofish_encrypt ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *)data, (unsigned int *)data); } size_t CipherTwofish::GetScheduledKeySize () const { return TWOFISH_KS; } - void CipherTwofish::SetCipherKey (const byte *key) + void CipherTwofish::SetCipherKey (const uint8 *key) { twofish_set_key ((TwofishInstance *) ScheduledKey.Ptr(), (unsigned int *) key); } - void CipherTwofish::EncryptBlocks (byte *data, size_t blockCount) const + void CipherTwofish::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) twofish_encrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount); #else Cipher::EncryptBlocks (data, blockCount); #endif } - void CipherTwofish::DecryptBlocks (byte *data, size_t blockCount) const + void CipherTwofish::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) twofish_decrypt_blocks ( (TwofishInstance *) ScheduledKey.Ptr(), data, data, blockCount); #else Cipher::DecryptBlocks (data, blockCount); #endif } bool CipherTwofish::IsHwSupportAvailable () const { #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) return true; #else return false; #endif } // Camellia - void CipherCamellia::Decrypt (byte *data) const + void CipherCamellia::Decrypt (uint8 *data) const { camellia_decrypt (data, data, ScheduledKey.Ptr()); } - void CipherCamellia::Encrypt (byte *data) const + void CipherCamellia::Encrypt (uint8 *data) const { camellia_encrypt (data, data, ScheduledKey.Ptr()); } size_t CipherCamellia::GetScheduledKeySize () const { return CAMELLIA_KS; } - void CipherCamellia::SetCipherKey (const byte *key) + void CipherCamellia::SetCipherKey (const uint8 *key) { camellia_set_key (key, ScheduledKey.Ptr()); } - void CipherCamellia::EncryptBlocks (byte *data, size_t blockCount) const + void CipherCamellia::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) camellia_encrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount); #else Cipher::EncryptBlocks (data, blockCount); #endif } - void CipherCamellia::DecryptBlocks (byte *data, size_t blockCount) const + void CipherCamellia::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) camellia_decrypt_blocks ( ScheduledKey.Ptr(), data, data, blockCount); #else Cipher::DecryptBlocks (data, blockCount); #endif } bool CipherCamellia::IsHwSupportAvailable () const { #if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM) return true; #else return false; #endif } // Kuznyechik - void CipherKuznyechik::Decrypt (byte *data) const + void CipherKuznyechik::Decrypt (uint8 *data) const { kuznyechik_decrypt_block (data, data, (kuznyechik_kds *) ScheduledKey.Ptr()); } - void CipherKuznyechik::Encrypt (byte *data) const + void CipherKuznyechik::Encrypt (uint8 *data) const { kuznyechik_encrypt_block (data, data, (kuznyechik_kds *) ScheduledKey.Ptr()); } size_t CipherKuznyechik::GetScheduledKeySize () const { return KUZNYECHIK_KS; } - void CipherKuznyechik::SetCipherKey (const byte *key) + void CipherKuznyechik::SetCipherKey (const uint8 *key) { kuznyechik_set_key (key, (kuznyechik_kds *) ScheduledKey.Ptr()); } - void CipherKuznyechik::EncryptBlocks (byte *data, size_t blockCount) const + void CipherKuznyechik::EncryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE if ((blockCount >= 4) && IsHwSupportAvailable()) { kuznyechik_encrypt_blocks (data, data, blockCount, (kuznyechik_kds *) ScheduledKey.Ptr()); } else #endif Cipher::EncryptBlocks (data, blockCount); } - void CipherKuznyechik::DecryptBlocks (byte *data, size_t blockCount) const + void CipherKuznyechik::DecryptBlocks (uint8 *data, size_t blockCount) const { if (!Initialized) throw NotInitialized (SRC_POS); #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE if ((blockCount >= 4) && IsHwSupportAvailable()) { kuznyechik_decrypt_blocks (data, data, blockCount, (kuznyechik_kds *) ScheduledKey.Ptr()); } else #endif Cipher::DecryptBlocks (data, blockCount); } bool CipherKuznyechik::IsHwSupportAvailable () const { #if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE static bool state = false; static bool stateValid = false; if (!stateValid) { state = HasSSE2() ? true : false; stateValid = true; } return state; #else return false; #endif } - bool Cipher::HwSupportEnabled = true; + #endif + bool Cipher::HwSupportEnabled = true; } diff --git a/src/Volume/Cipher.h b/src/Volume/Cipher.h index 31a519a5..c53cfbd9 100644 --- a/src/Volume/Cipher.h +++ b/src/Volume/Cipher.h @@ -1,127 +1,171 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_Ciphers #define TC_HEADER_Encryption_Ciphers #include "Platform/Platform.h" #include "Crypto/cpu.h" namespace VeraCrypt { class Cipher; typedef vector < shared_ptr <Cipher> > CipherList; class Cipher { public: virtual ~Cipher (); - virtual void DecryptBlock (byte *data) const; - virtual void DecryptBlocks (byte *data, size_t blockCount) const; - static void EnableHwSupport (bool enable) { HwSupportEnabled = enable; } - virtual void EncryptBlock (byte *data) const; - virtual void EncryptBlocks (byte *data, size_t blockCount) const; + virtual void DecryptBlock (uint8 *data) const; + virtual void DecryptBlocks (uint8 *data, size_t blockCount) const; + #ifndef WOLFCRYPT_BACKEND + static void EnableHwSupport (bool enable) { HwSupportEnabled = enable; } + #else + static void EnableHwSupport (bool enable) { HwSupportEnabled = false; } + virtual void EncryptBlockXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + virtual void DecryptBlockXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + virtual void SetKeyXTS (const ConstBufferPtr &key); + #endif + virtual void EncryptBlock (uint8 *data) const; + virtual void EncryptBlocks (uint8 *data, size_t blockCount) const; static CipherList GetAvailableCiphers (); virtual size_t GetBlockSize () const = 0; virtual const SecureBuffer &GetKey () const { return Key; } virtual size_t GetKeySize () const = 0; virtual wstring GetName () const = 0; virtual shared_ptr <Cipher> GetNew () const = 0; virtual bool IsHwSupportAvailable () const { return false; } static bool IsHwSupportEnabled () { return HwSupportEnabled; } virtual void SetKey (const ConstBufferPtr &key); static const int MaxBlockSize = 16; protected: Cipher (); - virtual void Decrypt (byte *data) const = 0; - virtual void Encrypt (byte *data) const = 0; + virtual void Decrypt (uint8 *data) const = 0; + virtual void Encrypt (uint8 *data) const = 0; virtual size_t GetScheduledKeySize () const = 0; - virtual void SetCipherKey (const byte *key) = 0; + virtual void SetCipherKey (const uint8 *key) = 0; + #ifdef WOLFCRYPT_BACKEND + virtual void DecryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const = 0; + virtual void EncryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const = 0; + virtual void SetCipherKeyXTS (const uint8 *key) = 0; + #endif static bool HwSupportEnabled; bool Initialized; SecureBuffer Key; SecureBuffer ScheduledKey; private: Cipher (const Cipher &); Cipher &operator= (const Cipher &); }; struct CipherException : public Exception { protected: CipherException () { } CipherException (const string &message) : Exception (message) { } CipherException (const string &message, const wstring &subject) : Exception (message, subject) { } }; +#ifdef WOLFCRYPT_BACKEND #define TC_CIPHER(NAME, BLOCK_SIZE, KEY_SIZE) \ class TC_JOIN (Cipher,NAME) : public Cipher \ { \ public: \ TC_JOIN (Cipher,NAME) () { } \ virtual ~TC_JOIN (Cipher,NAME) () { } \ \ virtual size_t GetBlockSize () const { return BLOCK_SIZE; }; \ virtual size_t GetKeySize () const { return KEY_SIZE; }; \ virtual wstring GetName () const { return L###NAME; }; \ virtual shared_ptr <Cipher> GetNew () const { return shared_ptr <Cipher> (new TC_JOIN (Cipher,NAME)()); } \ TC_CIPHER_ADD_METHODS \ \ protected: \ - virtual void Decrypt (byte *data) const; \ - virtual void Encrypt (byte *data) const; \ + virtual void Decrypt (uint8 *data) const; \ + virtual void Encrypt (uint8 *data) const; \ virtual size_t GetScheduledKeySize () const; \ - virtual void SetCipherKey (const byte *key); \ + virtual void SetCipherKey (const uint8 *key); \ + virtual void DecryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const; \ + virtual void SetCipherKeyXTS (const uint8 *key); \ + virtual void EncryptXTS (uint8 *data, uint64 length, uint64 startDataUnitNo) const; \ \ private: \ TC_JOIN (Cipher,NAME) (const TC_JOIN (Cipher,NAME) &); \ TC_JOIN (Cipher,NAME) &operator= (const TC_JOIN (Cipher,NAME) &); \ } +#else + +#define TC_CIPHER(NAME, BLOCK_SIZE, KEY_SIZE) \ + class TC_JOIN (Cipher,NAME) : public Cipher \ + { \ + public: \ + TC_JOIN (Cipher,NAME) () { } \ + virtual ~TC_JOIN (Cipher,NAME) () { } \ +\ + virtual size_t GetBlockSize () const { return BLOCK_SIZE; }; \ + virtual size_t GetKeySize () const { return KEY_SIZE; }; \ + virtual wstring GetName () const { return L###NAME; }; \ + virtual shared_ptr <Cipher> GetNew () const { return shared_ptr <Cipher> (new TC_JOIN (Cipher,NAME)()); } \ + TC_CIPHER_ADD_METHODS \ +\ + protected: \ + virtual void Decrypt (uint8 *data) const; \ + virtual void Encrypt (uint8 *data) const; \ + virtual size_t GetScheduledKeySize () const; \ + virtual void SetCipherKey (const uint8 *key); \ +\ + private: \ + TC_JOIN (Cipher,NAME) (const TC_JOIN (Cipher,NAME) &); \ + TC_JOIN (Cipher,NAME) &operator= (const TC_JOIN (Cipher,NAME) &); \ + } + +#endif + #define TC_CIPHER_ADD_METHODS \ - virtual void DecryptBlocks (byte *data, size_t blockCount) const; \ - virtual void EncryptBlocks (byte *data, size_t blockCount) const; \ + virtual void DecryptBlocks (uint8 *data, size_t blockCount) const; \ + virtual void EncryptBlocks (uint8 *data, size_t blockCount) const; \ virtual bool IsHwSupportAvailable () const; TC_CIPHER (AES, 16, 32); TC_CIPHER (Serpent, 16, 32); TC_CIPHER (Twofish, 16, 32); TC_CIPHER (Camellia, 16, 32); TC_CIPHER (Kuznyechik, 16, 32); #undef TC_CIPHER_ADD_METHODS #define TC_CIPHER_ADD_METHODS #undef TC_CIPHER #define TC_EXCEPTION(NAME) TC_EXCEPTION_DECL(NAME,CipherException) #undef TC_EXCEPTION_SET #define TC_EXCEPTION_SET \ TC_EXCEPTION (CipherInitError); \ TC_EXCEPTION (WeakKeyDetected); TC_EXCEPTION_SET; #undef TC_EXCEPTION } #endif // TC_HEADER_Encryption_Ciphers diff --git a/src/Volume/Crc32.h b/src/Volume/Crc32.h index ced20457..ebe7aa83 100644 --- a/src/Volume/Crc32.h +++ b/src/Volume/Crc32.h @@ -1,48 +1,48 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_Crc32 #define TC_HEADER_Encryption_Crc32 #include "Platform/Platform.h" #include "Common/Crc.h" namespace VeraCrypt { class Crc32 { public: Crc32 () : CrcValue (0xffffFFFF) { }; virtual ~Crc32 () { }; uint32 Get () const { return CrcValue ^ 0xffffFFFF; } - uint32 Process (byte data) + uint32 Process (uint8 data) { - return CrcValue = crc_32_tab[(byte) (CrcValue ^ data)] ^ (CrcValue >> 8); + return CrcValue = crc_32_tab[(uint8) (CrcValue ^ data)] ^ (CrcValue >> 8); } static uint32 ProcessBuffer (const ConstBufferPtr &buffer) { - return ::GetCrc32 (const_cast<byte *> (buffer.Get()), static_cast<int> (buffer.Size())); + return ::GetCrc32 (const_cast<uint8 *> (buffer.Get()), static_cast<int> (buffer.Size())); } protected: uint32 CrcValue; private: Crc32 (const Crc32 &); Crc32 &operator= (const Crc32 &); }; } #endif // TC_HEADER_Encryption_Crc32 diff --git a/src/Volume/EncryptionAlgorithm.cpp b/src/Volume/EncryptionAlgorithm.cpp index 85d9be1c..4a325fe3 100644 --- a/src/Volume/EncryptionAlgorithm.cpp +++ b/src/Volume/EncryptionAlgorithm.cpp @@ -1,109 +1,113 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "EncryptionAlgorithm.h" #include "EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "EncryptionModeWolfCryptXTS.h" +#endif namespace VeraCrypt { EncryptionAlgorithm::EncryptionAlgorithm () : Deprecated (false) { } EncryptionAlgorithm::~EncryptionAlgorithm () { } - void EncryptionAlgorithm::Decrypt (byte *data, uint64 length) const + void EncryptionAlgorithm::Decrypt (uint8 *data, uint64 length) const { if_debug (ValidateState ()); Mode->Decrypt (data, length); } void EncryptionAlgorithm::Decrypt (const BufferPtr &data) const { Decrypt (data, data.Size()); } - void EncryptionAlgorithm::DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionAlgorithm::DecryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { if_debug (ValidateState()); Mode->DecryptSectors (data, sectorIndex, sectorCount, sectorSize); } - void EncryptionAlgorithm::Encrypt (byte *data, uint64 length) const + void EncryptionAlgorithm::Encrypt (uint8 *data, uint64 length) const { if_debug (ValidateState()); Mode->Encrypt (data, length); } void EncryptionAlgorithm::Encrypt (const BufferPtr &data) const { Encrypt (data, data.Size()); } - void EncryptionAlgorithm::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionAlgorithm::EncryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { if_debug (ValidateState ()); Mode->EncryptSectors (data, sectorIndex, sectorCount, sectorSize); } EncryptionAlgorithmList EncryptionAlgorithm::GetAvailableAlgorithms () { EncryptionAlgorithmList l; l.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND l.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new Kuznyechik ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaKuznyechik ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaSerpent ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikSerpentCamellia ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikTwofish ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); l.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - + #endif return l; } size_t EncryptionAlgorithm::GetLargestKeySize (const EncryptionAlgorithmList &algorithms) { size_t largestKeySize = 0; foreach_ref (const EncryptionAlgorithm &ea, algorithms) { if (ea.GetKeySize() > largestKeySize) largestKeySize = ea.GetKeySize(); } return largestKeySize; } size_t EncryptionAlgorithm::GetKeySize () const { if (Ciphers.size() < 1) throw NotInitialized (SRC_POS); size_t keySize = 0; foreach_ref (const Cipher &c, Ciphers) keySize += c.GetKeySize(); return keySize; } size_t EncryptionAlgorithm::GetMaxBlockSize () const @@ -188,74 +192,97 @@ namespace VeraCrypt bool EncryptionAlgorithm::IsModeSupported (const shared_ptr <EncryptionMode> mode) const { return IsModeSupported (*mode); } void EncryptionAlgorithm::SetMode (shared_ptr <EncryptionMode> mode) { if (!IsModeSupported (*mode)) throw ParameterIncorrect (SRC_POS); mode->SetCiphers (Ciphers); Mode = mode; } void EncryptionAlgorithm::SetKey (const ConstBufferPtr &key) { if (Ciphers.size() < 1) throw NotInitialized (SRC_POS); if (GetKeySize() != key.Size()) throw ParameterIncorrect (SRC_POS); size_t keyOffset = 0; foreach_ref (Cipher &c, Ciphers) { c.SetKey (key.GetRange (keyOffset, c.GetKeySize())); keyOffset += c.GetKeySize(); } } - void EncryptionAlgorithm::ValidateState () const + #ifdef WOLFCRYPT_BACKEND + void EncryptionAlgorithm::SetKeyXTS (const ConstBufferPtr &key) + { + if (Ciphers.size() < 1) + throw NotInitialized (SRC_POS); + + if (GetKeySize() != key.Size()) + throw ParameterIncorrect (SRC_POS); + + size_t keyOffset = 0; + foreach_ref (Cipher &c, Ciphers) + { + c.SetKeyXTS (key.GetRange (keyOffset, c.GetKeySize())); + keyOffset += c.GetKeySize(); + } + } + #endif + + void EncryptionAlgorithm::ValidateState () const { if (Ciphers.size() < 1 || Mode.get() == nullptr) throw NotInitialized (SRC_POS); } // AES AES::AES () { Ciphers.push_back (shared_ptr <Cipher> (new CipherAES())); + #ifdef WOLFCRYPT_BACKEND + SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #else SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - } + #endif + } +#ifndef WOLFCRYPT_BACKEND // AES-Twofish AESTwofish::AESTwofish () { Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // AES-Twofish-Serpent AESTwofishSerpent::AESTwofishSerpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherTwofish ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherAES ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // Serpent Serpent::Serpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // Serpent-AES SerpentAES::SerpentAES () { @@ -326,31 +353,32 @@ namespace VeraCrypt SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // Kuznyechik-Serpent-Camellia KuznyechikSerpentCamellia::KuznyechikSerpentCamellia () { Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // Camellia-Kuznyechik CamelliaKuznyechik::CamelliaKuznyechik () { Ciphers.push_back (shared_ptr <Cipher> (new CipherKuznyechik ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } // Camellia-Serpent CamelliaSerpent::CamelliaSerpent () { Ciphers.push_back (shared_ptr <Cipher> (new CipherSerpent ())); Ciphers.push_back (shared_ptr <Cipher> (new CipherCamellia ())); SupportedModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); } +#endif } diff --git a/src/Volume/EncryptionAlgorithm.h b/src/Volume/EncryptionAlgorithm.h index 56642146..e9f9b9ef 100644 --- a/src/Volume/EncryptionAlgorithm.h +++ b/src/Volume/EncryptionAlgorithm.h @@ -1,79 +1,82 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_EncryptionAlgorithm #define TC_HEADER_Encryption_EncryptionAlgorithm #include "Platform/Platform.h" #include "Cipher.h" #include "EncryptionMode.h" namespace VeraCrypt { class EncryptionAlgorithm; typedef list < shared_ptr <EncryptionAlgorithm> > EncryptionAlgorithmList; class EncryptionAlgorithm { public: virtual ~EncryptionAlgorithm (); - virtual void Decrypt (byte *data, uint64 length) const; + virtual void Decrypt (uint8 *data, uint64 length) const; virtual void Decrypt (const BufferPtr &data) const; - virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void Encrypt (byte *data, uint64 length) const; + virtual void DecryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void Encrypt (uint8 *data, uint64 length) const; virtual void Encrypt (const BufferPtr &data) const; - virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void EncryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; static EncryptionAlgorithmList GetAvailableAlgorithms (); virtual const CipherList &GetCiphers () const { return Ciphers; } virtual shared_ptr <EncryptionAlgorithm> GetNew () const = 0; virtual size_t GetMaxBlockSize () const; virtual size_t GetMinBlockSize () const; static size_t GetLargestKeySize (const EncryptionAlgorithmList &algorithms); virtual size_t GetKeySize () const; virtual shared_ptr <EncryptionMode> GetMode () const; virtual wstring GetName (bool forGuiDisplay = false) const; bool IsDeprecated () const { return Deprecated; } virtual bool IsModeSupported (const EncryptionMode &mode) const; virtual bool IsModeSupported (const shared_ptr <EncryptionMode> mode) const; virtual void SetKey (const ConstBufferPtr &key); - virtual void SetMode (shared_ptr <EncryptionMode> mode); + #ifdef WOLFCRYPT_BACKEND + virtual void SetKeyXTS (const ConstBufferPtr &key); + #endif + virtual void SetMode (shared_ptr <EncryptionMode> mode); protected: EncryptionAlgorithm (); void ValidateState () const; CipherList Ciphers; bool Deprecated; shared_ptr <EncryptionMode> Mode; EncryptionModeList SupportedModes; private: EncryptionAlgorithm (const EncryptionAlgorithm &); EncryptionAlgorithm &operator= (const EncryptionAlgorithm &); }; #define TC_ENCRYPTION_ALGORITHM(NAME) \ class NAME : public EncryptionAlgorithm \ { \ public: \ NAME (); \ virtual ~NAME () { } \ \ virtual shared_ptr <EncryptionAlgorithm> GetNew () const { return shared_ptr <EncryptionAlgorithm> (new NAME()); } \ \ private: \ NAME (const NAME &); \ NAME &operator= (const NAME &); \ } diff --git a/src/Volume/EncryptionMode.cpp b/src/Volume/EncryptionMode.cpp index b7e5cc02..6a63efe5 100644 --- a/src/Volume/EncryptionMode.cpp +++ b/src/Volume/EncryptionMode.cpp @@ -1,63 +1,70 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "EncryptionMode.h" #include "EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "EncryptionModeWolfCryptXTS.h" +#endif #include "EncryptionThreadPool.h" namespace VeraCrypt { EncryptionMode::EncryptionMode () : KeySet (false), SectorOffset (0) { } EncryptionMode::~EncryptionMode () { } - void EncryptionMode::DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionMode::DecryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::DecryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize); } - void EncryptionMode::EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionMode::EncryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { EncryptionThreadPool::DoWork (EncryptionThreadPool::WorkType::EncryptDataUnits, this, data, sectorIndex, sectorCount, sectorSize); } EncryptionModeList EncryptionMode::GetAvailableModes () { EncryptionModeList l; + #ifdef WOLFCRYPT_BACKEND + l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #else l.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + #endif return l; } void EncryptionMode::ValidateState () const { if (!KeySet || Ciphers.size() < 1) throw NotInitialized (SRC_POS); } - void EncryptionMode::ValidateParameters (byte *data, uint64 length) const + void EncryptionMode::ValidateParameters (uint8 *data, uint64 length) const { if ((Ciphers.size() > 0 && (length % Ciphers.front()->GetBlockSize()) != 0)) throw ParameterIncorrect (SRC_POS); } - void EncryptionMode::ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const + void EncryptionMode::ValidateParameters (uint8 *data, uint64 sectorCount, size_t sectorSize) const { if (sectorCount == 0 || sectorSize == 0 || (sectorSize % EncryptionDataUnitSize) != 0) throw ParameterIncorrect (SRC_POS); } } diff --git a/src/Volume/EncryptionMode.h b/src/Volume/EncryptionMode.h index a629d6b7..0da28fa7 100644 --- a/src/Volume/EncryptionMode.h +++ b/src/Volume/EncryptionMode.h @@ -1,66 +1,66 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_EncryptionMode #define TC_HEADER_Encryption_EncryptionMode #include "Platform/Platform.h" #include "Common/Crypto.h" #include "Cipher.h" namespace VeraCrypt { class EncryptionMode; typedef list < shared_ptr <EncryptionMode> > EncryptionModeList; class EncryptionMode { public: virtual ~EncryptionMode (); - virtual void Decrypt (byte *data, uint64 length) const = 0; - virtual void DecryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0; - virtual void Encrypt (byte *data, uint64 length) const = 0; - virtual void EncryptSectors (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0; + virtual void Decrypt (uint8 *data, uint64 length) const = 0; + virtual void DecryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void DecryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0; + virtual void Encrypt (uint8 *data, uint64 length) const = 0; + virtual void EncryptSectors (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void EncryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const = 0; static EncryptionModeList GetAvailableModes (); virtual const SecureBuffer &GetKey () const { throw NotApplicable (SRC_POS); } virtual size_t GetKeySize () const = 0; virtual wstring GetName () const = 0; virtual shared_ptr <EncryptionMode> GetNew () const = 0; virtual uint64 GetSectorOffset () const { return SectorOffset; } virtual bool IsKeySet () const { return KeySet; } virtual void SetKey (const ConstBufferPtr &key) = 0; virtual void SetCiphers (const CipherList &ciphers) { Ciphers = ciphers; } virtual void SetSectorOffset (int64 offset) { SectorOffset = offset; } protected: EncryptionMode (); virtual void ValidateState () const; - void ValidateParameters (byte *data, uint64 length) const; - virtual void ValidateParameters (byte *data, uint64 sectorCount, size_t sectorSize) const; + void ValidateParameters (uint8 *data, uint64 length) const; + virtual void ValidateParameters (uint8 *data, uint64 sectorCount, size_t sectorSize) const; static const size_t EncryptionDataUnitSize = ENCRYPTION_DATA_UNIT_SIZE; CipherList Ciphers; bool KeySet; uint64 SectorOffset; private: EncryptionMode (const EncryptionMode &); EncryptionMode &operator= (const EncryptionMode &); }; } #endif // TC_HEADER_Encryption_EncryptionMode diff --git a/src/Volume/EncryptionModeWolfCryptXTS.cpp b/src/Volume/EncryptionModeWolfCryptXTS.cpp new file mode 100644 index 00000000..878ad042 --- /dev/null +++ b/src/Volume/EncryptionModeWolfCryptXTS.cpp @@ -0,0 +1,119 @@ + +#include "Crypto/cpu.h" +#include "Crypto/misc.h" +#include "EncryptionModeWolfCryptXTS.h" +#include "Common/Crypto.h" + +namespace VeraCrypt +{ + void EncryptionModeWolfCryptXTS::Encrypt (uint8 *data, uint64 length) const + { + EncryptBuffer (data, length, 0); + } + + void EncryptionModeWolfCryptXTS::EncryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + if_debug (ValidateState()); + + CipherList::const_iterator iSecondaryCipher = SecondaryCiphers.begin(); + + for (CipherList::const_iterator iCipher = Ciphers.begin(); iCipher != Ciphers.end(); ++iCipher) + { + EncryptBufferXTS (**iCipher, **iSecondaryCipher, data, length, startDataUnitNo, 0); + ++iSecondaryCipher; + } + + assert (iSecondaryCipher == SecondaryCiphers.end()); + } + + void EncryptionModeWolfCryptXTS::EncryptBufferXTS (Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const + { + cipher.EncryptBlockXTS(buffer, length, startDataUnitNo); + } + + void EncryptionModeWolfCryptXTS::EncryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + { + EncryptBuffer (data, sectorCount * sectorSize, sectorIndex * sectorSize / ENCRYPTION_DATA_UNIT_SIZE); + } + + size_t EncryptionModeWolfCryptXTS::GetKeySize () const + { + if (Ciphers.empty()) + throw NotInitialized (SRC_POS); + + size_t keySize = 0; + foreach_ref (const Cipher &cipher, SecondaryCiphers) + { + keySize += cipher.GetKeySize(); + } + + return keySize; + } + + void EncryptionModeWolfCryptXTS::Decrypt (uint8 *data, uint64 length) const + { + DecryptBuffer (data, length, 0); + } + + void EncryptionModeWolfCryptXTS::DecryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const + { + if_debug (ValidateState()); + + CipherList::const_iterator iSecondaryCipher = SecondaryCiphers.end(); + + for (CipherList::const_reverse_iterator iCipher = Ciphers.rbegin(); iCipher != Ciphers.rend(); ++iCipher) + { + --iSecondaryCipher; + DecryptBufferXTS (**iCipher, **iSecondaryCipher, data, length, startDataUnitNo, 0); + } + + assert (iSecondaryCipher == SecondaryCiphers.begin()); + } + + void EncryptionModeWolfCryptXTS::DecryptBufferXTS (Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const + { + cipher.DecryptBlockXTS(buffer, length, startDataUnitNo); + } + + void EncryptionModeWolfCryptXTS::DecryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + { + DecryptBuffer (data, sectorCount * sectorSize, sectorIndex * sectorSize / ENCRYPTION_DATA_UNIT_SIZE); + } + + void EncryptionModeWolfCryptXTS::SetCiphers (const CipherList &ciphers) + { + EncryptionMode::SetCiphers (ciphers); + + SecondaryCiphers.clear(); + + foreach_ref (const Cipher &cipher, ciphers) + { + SecondaryCiphers.push_back (cipher.GetNew()); + } + + if (SecondaryKey.Size() > 0) + SetSecondaryCipherKeys(); + } + + void EncryptionModeWolfCryptXTS::SetKey (const ConstBufferPtr &key) + { + SecondaryKey.Allocate (key.Size()); + SecondaryKey.CopyFrom (key); + + if (!SecondaryCiphers.empty()) + SetSecondaryCipherKeys(); + + } + + void EncryptionModeWolfCryptXTS::SetSecondaryCipherKeys () + { + size_t keyOffset = 0; + foreach_ref (Cipher &cipher, SecondaryCiphers) + { + cipher.SetKeyXTS (SecondaryKey.GetRange (keyOffset, cipher.GetKeySize())); + keyOffset += cipher.GetKeySize(); + } + + KeySet = true; + } +} diff --git a/src/Volume/EncryptionModeWolfCryptXTS.h b/src/Volume/EncryptionModeWolfCryptXTS.h new file mode 100644 index 00000000..c9f2d59f --- /dev/null +++ b/src/Volume/EncryptionModeWolfCryptXTS.h @@ -0,0 +1,54 @@ +/* + Derived from source code of TrueCrypt 7.1a, which is + 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) + and all other portions of this file are Copyright (c) 2013-2017 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. +*/ + +#ifndef TC_HEADER_Volume_EncryptionModeWolfCryptXTS +#define TC_HEADER_Volume_EncryptionModeWolfCryptXTS + +#include "Platform/Platform.h" +#include "EncryptionMode.h" + +namespace VeraCrypt +{ + class EncryptionModeWolfCryptXTS : public EncryptionMode + { + public: + EncryptionModeWolfCryptXTS () { } + virtual ~EncryptionModeWolfCryptXTS () { } + + virtual void Decrypt (uint8 *data, uint64 length) const; + virtual void DecryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void Encrypt (uint8 *data, uint64 length) const; + virtual void EncryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual const SecureBuffer &GetKey () const { return SecondaryKey; } + virtual size_t GetKeySize () const; + virtual wstring GetName () const { return L"XTS"; }; + virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS); } + virtual void SetCiphers (const CipherList &ciphers); + virtual void SetKey (const ConstBufferPtr &key); + + protected: + void DecryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + void DecryptBufferXTS (Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; + void EncryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + void EncryptBufferXTS (Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; + void SetSecondaryCipherKeys (); + + SecureBuffer SecondaryKey; + CipherList SecondaryCiphers; + + private: + EncryptionModeWolfCryptXTS (const EncryptionModeWolfCryptXTS &); + EncryptionModeWolfCryptXTS &operator= (const EncryptionModeWolfCryptXTS &); + }; +} + +#endif // TC_HEADER_Volume_EncryptionModeWolfCryptXTS diff --git a/src/Volume/EncryptionModeXTS.cpp b/src/Volume/EncryptionModeXTS.cpp index 66f0ff62..001bfcf8 100644 --- a/src/Volume/EncryptionModeXTS.cpp +++ b/src/Volume/EncryptionModeXTS.cpp @@ -20,86 +20,86 @@ #define XorBlocks(result,ptr,len,start,end) \ while (len >= 2) \ { \ __m128i xmm1 = _mm_loadu_si128((const __m128i*) ptr); \ __m128i xmm2 = _mm_loadu_si128((__m128i*)result); \ __m128i xmm3 = _mm_loadu_si128((const __m128i*) (ptr + 2)); \ __m128i xmm4 = _mm_loadu_si128((__m128i*)(result + 2)); \ \ _mm_storeu_si128((__m128i*)result, _mm_xor_si128(xmm1, xmm2)); \ _mm_storeu_si128((__m128i*)(result + 2), _mm_xor_si128(xmm3, xmm4)); \ ptr+= 4; \ result+= 4; \ len -= 2; \ } \ \ if (len) \ { \ __m128i xmm1 = _mm_loadu_si128((const __m128i*)ptr); \ __m128i xmm2 = _mm_loadu_si128((__m128i*)result); \ \ _mm_storeu_si128((__m128i*)result, _mm_xor_si128(xmm1, xmm2)); \ ptr+= 2; \ result+= 2; \ } \ len = end - start; #endif namespace VeraCrypt { - void EncryptionModeXTS::Encrypt (byte *data, uint64 length) const + void EncryptionModeXTS::Encrypt (uint8 *data, uint64 length) const { EncryptBuffer (data, length, 0); } - void EncryptionModeXTS::EncryptBuffer (byte *data, uint64 length, uint64 startDataUnitNo) const + void EncryptionModeXTS::EncryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const { if_debug (ValidateState()); CipherList::const_iterator iSecondaryCipher = SecondaryCiphers.begin(); for (CipherList::const_iterator iCipher = Ciphers.begin(); iCipher != Ciphers.end(); ++iCipher) { EncryptBufferXTS (**iCipher, **iSecondaryCipher, data, length, startDataUnitNo, 0); ++iSecondaryCipher; } assert (iSecondaryCipher == SecondaryCiphers.end()); } - void EncryptionModeXTS::EncryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, byte *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const + void EncryptionModeXTS::EncryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const { - byte finalCarry; - byte whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; - byte whiteningValue [BYTES_PER_XTS_BLOCK]; - byte byteBufUnitNo [BYTES_PER_XTS_BLOCK]; + uint8 finalCarry; + uint8 whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; + uint8 whiteningValue [BYTES_PER_XTS_BLOCK]; + uint8 byteBufUnitNo [BYTES_PER_XTS_BLOCK]; uint64 *whiteningValuesPtr64 = (uint64 *) whiteningValues; uint64 *whiteningValuePtr64 = (uint64 *) whiteningValue; uint64 *bufPtr = (uint64 *) buffer; uint64 *dataUnitBufPtr; unsigned int startBlock = startCipherBlockNo, endBlock, block, countBlock; uint64 remainingBlocks, dataUnitNo; startDataUnitNo += SectorOffset; /* The encrypted data unit number (i.e. the resultant ciphertext block) is to be multiplied in the finite field GF(2^128) by j-th power of n, where j is the sequential plaintext/ciphertext block number and n is 2, a primitive element of GF(2^128). This can be (and is) simplified and implemented as a left shift of the preceding whitening value by one bit (with carry propagating). In addition, if 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. // 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; *((uint64 *) byteBufUnitNo) = Endian::Little (dataUnitNo); *((uint64 *) byteBufUnitNo + 1) = 0; if (length % BYTES_PER_XTS_BLOCK) TC_THROW_FATAL_EXCEPTION; remainingBlocks = length / BYTES_PER_XTS_BLOCK; // Process all blocks in the buffer while (remainingBlocks > 0) { @@ -155,130 +155,130 @@ namespace VeraCrypt 135 : 0; *whiteningValuePtr64 = Endian::Little (Endian::Little (*whiteningValuePtr64) << 1); whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) *(whiteningValuePtr64 + 1) |= 0x0100000000000000ULL; *whiteningValuePtr64 = Endian::Little (Endian::Little (*whiteningValuePtr64) << 1); #endif whiteningValue[0] ^= finalCarry; } dataUnitBufPtr = bufPtr; whiteningValuesPtr64 = (uint64 *) whiteningValues; // Encrypt all blocks in this data unit #if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64) XorBlocks (bufPtr, whiteningValuesPtr64, countBlock, startBlock, endBlock); #else for (block = 0; block < countBlock; block++) { // Pre-whitening *bufPtr++ ^= *whiteningValuesPtr64++; *bufPtr++ ^= *whiteningValuesPtr64++; } #endif // Actual encryption - cipher.EncryptBlocks ((byte *) dataUnitBufPtr, countBlock); + cipher.EncryptBlocks ((uint8 *) dataUnitBufPtr, countBlock); bufPtr = dataUnitBufPtr; whiteningValuesPtr64 = (uint64 *) whiteningValues; #if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64) XorBlocks (bufPtr, whiteningValuesPtr64, countBlock, startBlock, endBlock); #else for (block = 0; block < countBlock; block++) { // Post-whitening *bufPtr++ ^= *whiteningValuesPtr64++; *bufPtr++ ^= *whiteningValuesPtr64++; } #endif remainingBlocks -= countBlock; startBlock = 0; dataUnitNo++; *((uint64 *) byteBufUnitNo) = Endian::Little (dataUnitNo); } FAST_ERASE64 (whiteningValue, sizeof (whiteningValue)); FAST_ERASE64 (whiteningValues, sizeof (whiteningValues)); } - void EncryptionModeXTS::EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionModeXTS::EncryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { EncryptBuffer (data, sectorCount * sectorSize, sectorIndex * sectorSize / ENCRYPTION_DATA_UNIT_SIZE); } size_t EncryptionModeXTS::GetKeySize () const { if (Ciphers.empty()) throw NotInitialized (SRC_POS); size_t keySize = 0; foreach_ref (const Cipher &cipher, SecondaryCiphers) { keySize += cipher.GetKeySize(); } return keySize; } - void EncryptionModeXTS::Decrypt (byte *data, uint64 length) const + void EncryptionModeXTS::Decrypt (uint8 *data, uint64 length) const { DecryptBuffer (data, length, 0); } - void EncryptionModeXTS::DecryptBuffer (byte *data, uint64 length, uint64 startDataUnitNo) const + void EncryptionModeXTS::DecryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const { if_debug (ValidateState()); CipherList::const_iterator iSecondaryCipher = SecondaryCiphers.end(); for (CipherList::const_reverse_iterator iCipher = Ciphers.rbegin(); iCipher != Ciphers.rend(); ++iCipher) { --iSecondaryCipher; DecryptBufferXTS (**iCipher, **iSecondaryCipher, data, length, startDataUnitNo, 0); } assert (iSecondaryCipher == SecondaryCiphers.begin()); } - void EncryptionModeXTS::DecryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, byte *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const + void EncryptionModeXTS::DecryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const { - byte finalCarry; - byte whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; - byte whiteningValue [BYTES_PER_XTS_BLOCK]; - byte byteBufUnitNo [BYTES_PER_XTS_BLOCK]; + uint8 finalCarry; + uint8 whiteningValues [ENCRYPTION_DATA_UNIT_SIZE]; + uint8 whiteningValue [BYTES_PER_XTS_BLOCK]; + uint8 byteBufUnitNo [BYTES_PER_XTS_BLOCK]; uint64 *whiteningValuesPtr64 = (uint64 *) whiteningValues; uint64 *whiteningValuePtr64 = (uint64 *) whiteningValue; uint64 *bufPtr = (uint64 *) buffer; uint64 *dataUnitBufPtr; unsigned int startBlock = startCipherBlockNo, endBlock, block, countBlock; uint64 remainingBlocks, dataUnitNo; startDataUnitNo += SectorOffset; // 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; *((uint64 *) byteBufUnitNo) = Endian::Little (dataUnitNo); *((uint64 *) byteBufUnitNo + 1) = 0; if (length % BYTES_PER_XTS_BLOCK) TC_THROW_FATAL_EXCEPTION; remainingBlocks = length / BYTES_PER_XTS_BLOCK; // Process all blocks in the buffer while (remainingBlocks > 0) { if (remainingBlocks < BLOCKS_PER_XTS_DATA_UNIT) endBlock = startBlock + (unsigned int) remainingBlocks; else endBlock = BLOCKS_PER_XTS_DATA_UNIT; countBlock = endBlock - startBlock; whiteningValuesPtr64 = (uint64 *) whiteningValues; @@ -325,95 +325,95 @@ namespace VeraCrypt finalCarry = (*whiteningValuePtr64 & 0x80) ? 135 : 0; *whiteningValuePtr64 = Endian::Little (Endian::Little (*whiteningValuePtr64) << 1); whiteningValuePtr64--; if (*whiteningValuePtr64 & 0x80) *(whiteningValuePtr64 + 1) |= 0x0100000000000000ULL; *whiteningValuePtr64 = Endian::Little (Endian::Little (*whiteningValuePtr64) << 1); #endif whiteningValue[0] ^= finalCarry; } dataUnitBufPtr = bufPtr; whiteningValuesPtr64 = (uint64 *) whiteningValues; // Decrypt blocks in this data unit #if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64) XorBlocks (bufPtr, whiteningValuesPtr64, countBlock, startBlock, endBlock); #else for (block = 0; block < countBlock; block++) { *bufPtr++ ^= *whiteningValuesPtr64++; *bufPtr++ ^= *whiteningValuesPtr64++; } #endif - cipher.DecryptBlocks ((byte *) dataUnitBufPtr, countBlock); + cipher.DecryptBlocks ((uint8 *) dataUnitBufPtr, countBlock); bufPtr = dataUnitBufPtr; whiteningValuesPtr64 = (uint64 *) whiteningValues; #if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64) XorBlocks (bufPtr, whiteningValuesPtr64, countBlock, startBlock, endBlock); #else for (block = 0; block < countBlock; block++) { *bufPtr++ ^= *whiteningValuesPtr64++; *bufPtr++ ^= *whiteningValuesPtr64++; } #endif remainingBlocks -= countBlock; startBlock = 0; dataUnitNo++; *((uint64 *) byteBufUnitNo) = Endian::Little (dataUnitNo); } FAST_ERASE64 (whiteningValue, sizeof (whiteningValue)); FAST_ERASE64 (whiteningValues, sizeof (whiteningValues)); - } + } - void EncryptionModeXTS::DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const + void EncryptionModeXTS::DecryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const { DecryptBuffer (data, sectorCount * sectorSize, sectorIndex * sectorSize / ENCRYPTION_DATA_UNIT_SIZE); } void EncryptionModeXTS::SetCiphers (const CipherList &ciphers) { EncryptionMode::SetCiphers (ciphers); SecondaryCiphers.clear(); foreach_ref (const Cipher &cipher, ciphers) { SecondaryCiphers.push_back (cipher.GetNew()); } if (SecondaryKey.Size() > 0) SetSecondaryCipherKeys(); } void EncryptionModeXTS::SetKey (const ConstBufferPtr &key) { SecondaryKey.Allocate (key.Size()); SecondaryKey.CopyFrom (key); if (!SecondaryCiphers.empty()) SetSecondaryCipherKeys(); } void EncryptionModeXTS::SetSecondaryCipherKeys () { size_t keyOffset = 0; foreach_ref (Cipher &cipher, SecondaryCiphers) { cipher.SetKey (SecondaryKey.GetRange (keyOffset, cipher.GetKeySize())); - keyOffset += cipher.GetKeySize(); + keyOffset += cipher.GetKeySize(); } KeySet = true; } } diff --git a/src/Volume/EncryptionModeXTS.h b/src/Volume/EncryptionModeXTS.h index 6f674073..cbed0d33 100644 --- a/src/Volume/EncryptionModeXTS.h +++ b/src/Volume/EncryptionModeXTS.h @@ -1,54 +1,54 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Volume_EncryptionModeXTS #define TC_HEADER_Volume_EncryptionModeXTS #include "Platform/Platform.h" #include "EncryptionMode.h" namespace VeraCrypt { class EncryptionModeXTS : public EncryptionMode { public: EncryptionModeXTS () { } virtual ~EncryptionModeXTS () { } - virtual void Decrypt (byte *data, uint64 length) const; - virtual void DecryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; - virtual void Encrypt (byte *data, uint64 length) const; - virtual void EncryptSectorsCurrentThread (byte *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void Decrypt (uint8 *data, uint64 length) const; + virtual void DecryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; + virtual void Encrypt (uint8 *data, uint64 length) const; + virtual void EncryptSectorsCurrentThread (uint8 *data, uint64 sectorIndex, uint64 sectorCount, size_t sectorSize) const; virtual const SecureBuffer &GetKey () const { return SecondaryKey; } virtual size_t GetKeySize () const; virtual wstring GetName () const { return L"XTS"; }; virtual shared_ptr <EncryptionMode> GetNew () const { return shared_ptr <EncryptionMode> (new EncryptionModeXTS); } virtual void SetCiphers (const CipherList &ciphers); virtual void SetKey (const ConstBufferPtr &key); protected: - void DecryptBuffer (byte *data, uint64 length, uint64 startDataUnitNo) const; - void DecryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, byte *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; - void EncryptBuffer (byte *data, uint64 length, uint64 startDataUnitNo) const; - void EncryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, byte *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; + void DecryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + void DecryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; + void EncryptBuffer (uint8 *data, uint64 length, uint64 startDataUnitNo) const; + void EncryptBufferXTS (const Cipher &cipher, const Cipher &secondaryCipher, uint8 *buffer, uint64 length, uint64 startDataUnitNo, unsigned int startCipherBlockNo) const; void SetSecondaryCipherKeys (); SecureBuffer SecondaryKey; CipherList SecondaryCiphers; private: EncryptionModeXTS (const EncryptionModeXTS &); EncryptionModeXTS &operator= (const EncryptionModeXTS &); }; } #endif // TC_HEADER_Volume_EncryptionModeXTS diff --git a/src/Volume/EncryptionTest.cpp b/src/Volume/EncryptionTest.cpp index bb9c3a0b..9009be66 100644 --- a/src/Volume/EncryptionTest.cpp +++ b/src/Volume/EncryptionTest.cpp @@ -1,96 +1,100 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Cipher.h" #include "Common/Crc.h" #include "Crc32.h" #include "EncryptionAlgorithm.h" #include "EncryptionMode.h" #include "EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "EncryptionModeWolfCryptXTS.h" +#endif #include "EncryptionTest.h" #include "Pkcs5Kdf.h" namespace VeraCrypt { void EncryptionTest::TestAll () { TestAll (false); TestAll (true); } void EncryptionTest::TestAll (bool enableCpuEncryptionSupport) { bool hwSupportEnabled = Cipher::IsHwSupportEnabled(); finally_do_arg (bool, hwSupportEnabled, { Cipher::EnableHwSupport (finally_arg); }); Cipher::EnableHwSupport (enableCpuEncryptionSupport); TestCiphers(); TestXtsAES(); TestXts(); TestPkcs5(); } struct CipherTestVector { - byte Key[32]; - byte Plaintext[16]; - byte Ciphertext[16]; + uint8 Key[32]; + uint8 Plaintext[16]; + uint8 Ciphertext[16]; }; static const CipherTestVector AESTestVectors[] = { { { 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, }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }, { 0x8e, 0xa2, 0xb7, 0xca, 0x51, 0x67, 0x45, 0xbf, 0xea, 0xfc, 0x49, 0x90, 0x4b, 0x49, 0x60, 0x89 } } }; + #ifndef WOLFCRYPT_BACKEND static const CipherTestVector SerpentTestVectors[] = { { { 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 }, { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f }, { 0xde, 0x26, 0x9f, 0xf8, 0x33, 0xe4, 0x32, 0xb8, 0x5b, 0x2e, 0x88, 0xd2, 0x70, 0x1c, 0xe7, 0x5c } } }; static const CipherTestVector TwofishTestVectors[] = { { { 0xD4, 0x3B, 0xB7, 0x55, 0x6E, 0xA3, 0x2E, 0x46, 0xF2, 0xA2, 0x82, 0xB7, 0xD4, 0x5B, 0x4E, 0x0D, 0x57, 0xFF, 0x73, 0x9D, 0x4D, 0xC9, 0x2C, 0x1B, 0xD7, 0xFC, 0x01, 0x70, 0x0C, 0xC8, 0x21, 0x6F }, { 0x90, 0xAF, 0xE9, 0x1B, 0xB2, 0x88, 0x54, 0x4F, 0x2C, 0x32, 0xDC, 0x23, 0x9B, 0x26, 0x35, 0xE6 }, { 0x6C, 0xB4, 0x56, 0x1C, 0x40, 0xBF, 0x0A, 0x97, 0x05, 0x93, 0x1C, 0xB6, 0xD4, 0x08, 0xE7, 0xFA } } @@ -124,110 +128,113 @@ namespace VeraCrypt } }; static const CipherTestVector KuznyechikTestVectors[] = { { { 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x00, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA, 0x99, 0x88 }, { 0x7F, 0x67, 0x9D, 0x90, 0xBE, 0xBC, 0x24, 0x30, 0x5A, 0x46, 0x8D, 0x42, 0xB9, 0xD4, 0xED, 0xCD } }, { { 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0xFE, 0xDC, 0xBA, 0x98, 0x76, 0x54, 0x32, 0x10, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF }, { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xEE, 0xFF, 0x0A }, { 0xB4, 0x29, 0x91, 0x2C, 0x6E, 0x00, 0x32, 0xF9, 0x28, 0x54, 0x52, 0xD7, 0x67, 0x18, 0xD0, 0x8B } } }; + #endif static void TestCipher (Cipher &cipher, const CipherTestVector *testVector, size_t testVectorCount) { Buffer buffer (cipher.GetBlockSize()); for (size_t i = 0; i < testVectorCount; ++i) { cipher.SetKey (ConstBufferPtr (testVector[i].Key, sizeof (testVector[i].Key))); buffer.CopyFrom (ConstBufferPtr (testVector[i].Plaintext, sizeof (testVector[i].Plaintext))); cipher.EncryptBlock (buffer); if (memcmp (buffer, testVector[i].Ciphertext, buffer.Size()) != 0) throw TestFailed (SRC_POS); } } void EncryptionTest::TestCiphers () { CipherAES aes; TestCipher (aes, AESTestVectors, array_capacity (AESTestVectors)); Buffer testData (1024); for (size_t i = 0; i < testData.Size(); ++i) { - testData[i] = (byte) i; + testData[i] = (uint8) i; } uint32 origCrc = Crc32::ProcessBuffer (testData); aes.SetKey (ConstBufferPtr (testData, aes.GetKeySize())); aes.EncryptBlocks (testData, testData.Size() / aes.GetBlockSize()); if (Crc32::ProcessBuffer (testData) != 0xb5cd5631) throw TestFailed (SRC_POS); aes.DecryptBlocks (testData, testData.Size() / aes.GetBlockSize()); if (origCrc != Crc32::ProcessBuffer (testData)) throw TestFailed (SRC_POS); + #ifndef WOLFCRYPT_BACKEND CipherSerpent serpent; TestCipher (serpent, SerpentTestVectors, array_capacity (SerpentTestVectors)); CipherTwofish twofish; TestCipher (twofish, TwofishTestVectors, array_capacity (TwofishTestVectors)); CipherCamellia camellia; TestCipher (camellia, CamelliaTestVectors, array_capacity (CamelliaTestVectors)); CipherKuznyechik kuznyechik; TestCipher (kuznyechik, KuznyechikTestVectors, array_capacity (KuznyechikTestVectors)); + #endif } const EncryptionTest::XtsTestVector EncryptionTest::XtsTestVectors[] = { /* XTS-AES-256 */ { // IEEE 1619 - Vector 10 { 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, 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, 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, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 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, 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, 0xad, 0xae, 0xaf, 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 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 }, @@ -410,179 +417,194 @@ namespace VeraCrypt { 0x64, 0x49, 0x7e, 0x5a, 0x83, 0x1e, 0x4a, 0x93, 0x2c, 0x09, 0xbe, 0x3e, 0x53, 0x93, 0x37, 0x6d, 0xaa, 0x59, 0x95, 0x48, 0xb8, 0x16, 0x03, 0x1d, 0x22, 0x4b, 0xbf, 0x50, 0xa8, 0x18, 0xed, 0x23, 0x50, 0xea, 0xe7, 0xe9, 0x60, 0x87, 0xc8, 0xa0, 0xdb, 0x51, 0xad, 0x29, 0x0b, 0xd0, 0x0c, 0x1a, 0xc1, 0x62, 0x08, 0x57, 0x63, 0x5b, 0xf2, 0x46, 0xc1, 0x76, 0xab, 0x46, 0x3b, 0xe3, 0x0b, 0x80, 0x8d, 0xa5, 0x48, 0x08, 0x1a, 0xc8, 0x47, 0xb1, 0x58, 0xe1, 0x26, 0x4b, 0xe2, 0x5b, 0xb0, 0x91, 0x0b, 0xbc, 0x92, 0x64, 0x71, 0x08, 0x08, 0x94, 0x15, 0xd4, 0x5f, 0xab, 0x1b, 0x3d, 0x26, 0x04, 0xe8, 0xa8, 0xef, 0xf1, 0xae, 0x40, 0x20, 0xcf, 0xa3, 0x99, 0x36, 0xb6, 0x68, 0x27, 0xb2, 0x3f, 0x37, 0x1b, 0x92, 0x20, 0x0b, 0xe9, 0x02, 0x51, 0xe6, 0xd7, 0x3c, 0x5f, 0x86, 0xde, 0x5f, 0xd4, 0xa9, 0x50, 0x78, 0x19, 0x33, 0xd7, 0x9a, 0x28, 0x27, 0x2b, 0x78, 0x2a, 0x2e, 0xc3, 0x13, 0xef, 0xdf, 0xcc, 0x06, 0x28, 0xf4, 0x3d, 0x74, 0x4c, 0x2d, 0xc2, 0xff, 0x3d, 0xcb, 0x66, 0x99, 0x9b, 0x50, 0xc7, 0xca, 0x89, 0x5b, 0x0c, 0x64, 0x79, 0x1e, 0xea, 0xa5, 0xf2, 0x94, 0x99, 0xfb, 0x1c, 0x02, 0x6f, 0x84, 0xce, 0x5b, 0x5c, 0x72, 0xba, 0x10, 0x83, 0xcd, 0xdb, 0x5c, 0xe4, 0x54, 0x34, 0x63, 0x16, 0x65, 0xc3, 0x33, 0xb6, 0x0b, 0x11, 0x59, 0x3f, 0xb2, 0x53, 0xc5, 0x17, 0x9a, 0x2c, 0x8d, 0xb8, 0x13, 0x78, 0x2a, 0x00, 0x48, 0x56, 0xa1, 0x65, 0x30, 0x11, 0xe9, 0x3f, 0xb6, 0xd8, 0x76, 0xc1, 0x83, 0x66, 0xdd, 0x86, 0x83, 0xf5, 0x34, 0x12, 0xc0, 0xc1, 0x80, 0xf9, 0xc8, 0x48, 0x59, 0x2d, 0x59, 0x3f, 0x86, 0x09, 0xca, 0x73, 0x63, 0x17, 0xd3, 0x56, 0xe1, 0x3e, 0x2b, 0xff, 0x3a, 0x9f, 0x59, 0xcd, 0x9a, 0xeb, 0x19, 0xcd, 0x48, 0x25, 0x93, 0xd8, 0xc4, 0x61, 0x28, 0xbb, 0x32, 0x42, 0x3b, 0x37, 0xa9, 0xad, 0xfb, 0x48, 0x2b, 0x99, 0x45, 0x3f, 0xbe, 0x25, 0xa4, 0x1b, 0xf6, 0xfe, 0xb4, 0xaa, 0x0b, 0xef, 0x5e, 0xd2, 0x4b, 0xf7, 0x3c, 0x76, 0x29, 0x78, 0x02, 0x54, 0x82, 0xc1, 0x31, 0x15, 0xe4, 0x01, 0x5a, 0xac, 0x99, 0x2e, 0x56, 0x13, 0xa3, 0xb5, 0xc2, 0xf6, 0x85, 0xb8, 0x47, 0x95, 0xcb, 0x6e, 0x9b, 0x26, 0x56, 0xd8, 0xc8, 0x81, 0x57, 0xe5, 0x2c, 0x42, 0xf9, 0x78, 0xd8, 0x63, 0x4c, 0x43, 0xd0, 0x6f, 0xea, 0x92, 0x8f, 0x28, 0x22, 0xe4, 0x65, 0xaa, 0x65, 0x76, 0xe9, 0xbf, 0x41, 0x93, 0x84, 0x50, 0x6c, 0xc3, 0xce, 0x3c, 0x54, 0xac, 0x1a, 0x6f, 0x67, 0xdc, 0x66, 0xf3, 0xb3, 0x01, 0x91, 0xe6, 0x98, 0x38, 0x0b, 0xc9, 0x99, 0xb0, 0x5a, 0xbc, 0xe1, 0x9d, 0xc0, 0xc6, 0xdc, 0xc2, 0xdd, 0x00, 0x1e, 0xc5, 0x35, 0xba, 0x18, 0xde, 0xb2, 0xdf, 0x1a, 0x10, 0x10, 0x23, 0x10, 0x83, 0x18, 0xc7, 0x5d, 0xc9, 0x86, 0x11, 0xa0, 0x9d, 0xc4, 0x8a, 0x0a, 0xcd, 0xec, 0x67, 0x6f, 0xab, 0xdf, 0x22, 0x2f, 0x07, 0xe0, 0x26, 0xf0, 0x59, 0xb6, 0x72, 0xb5, 0x6e, 0x5c, 0xbc, 0x8e, 0x1d, 0x21, 0xbb, 0xd8, 0x67, 0xdd, 0x92, 0x72, 0x12, 0x05, 0x46, 0x81, 0xd7, 0x0e, 0xa7, 0x37, 0x13, 0x4c, 0xdf, 0xce, 0x93, 0xb6, 0xf8, 0x2a, 0xe2, 0x24, 0x23, 0x27, 0x4e, 0x58, 0xa0, 0x82, 0x1c, 0xc5, 0x50, 0x2e, 0x2d, 0x0a, 0xb4, 0x58, 0x5e, 0x94, 0xde, 0x69, 0x75, 0xbe, 0x5e, 0x0b, 0x4e, 0xfc, 0xe5, 0x1c, 0xd3, 0xe7, 0x0c, 0x25, 0xa1, 0xfb, 0xbb, 0xd6, 0x09, 0xd2, 0x73, 0xad, 0x5b, 0x0d, 0x59, 0x63, 0x1c, 0x53, 0x1f, 0x6a, 0x0a, 0x57, 0xb9 } } }; void EncryptionTest::TestXtsAES () { unsigned __int8 p[ENCRYPTION_DATA_UNIT_SIZE]; uint64 dataUnitNo; size_t i; for (i = 0; i < array_capacity (XtsTestVectors); i++) { AES aes; - shared_ptr <EncryptionMode> xts (new EncryptionModeXTS); - - aes.SetKey (ConstBufferPtr (XtsTestVectors[i].key1, sizeof (XtsTestVectors[i].key1))); + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> xts (new EncryptionModeWolfCryptXTS); + #else + shared_ptr <EncryptionMode> xts (new EncryptionModeXTS); + #endif + + aes.SetKey (ConstBufferPtr (XtsTestVectors[i].key1, sizeof (XtsTestVectors[i].key1))); + #ifdef WOLFCRYPT_BACKEND + aes.SetKeyXTS (ConstBufferPtr (XtsTestVectors[i].key2, sizeof (XtsTestVectors[i].key2))); + #endif xts->SetKey (ConstBufferPtr (XtsTestVectors[i].key2, sizeof (XtsTestVectors[i].key2))); aes.SetMode (xts); memcpy (p, XtsTestVectors[i].plaintext, sizeof (p)); dataUnitNo = Endian::Big (*((uint64 *) XtsTestVectors[i].dataUnitNo)); aes.EncryptSectors (p, dataUnitNo, sizeof (p) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); aes.DecryptSectors (p, dataUnitNo, sizeof (p) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); if (memcmp (XtsTestVectors[i].ciphertext, p, sizeof (p)) == 0) throw TestFailed (SRC_POS); aes.EncryptSectors (p, dataUnitNo, sizeof (p) / ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE); if (memcmp (XtsTestVectors[i].ciphertext, p, sizeof (p)) != 0) throw TestFailed (SRC_POS); } } void EncryptionTest::TestXts () { unsigned char buf [ENCRYPTION_DATA_UNIT_SIZE * 4]; unsigned int i; uint32 crc; uint64 unitNo; uint64 nbrUnits; uint64 writeOffset; int testCase = 0; int nTestsPerformed = 0; - static const byte testKey[] = + static const uint8 testKey[] = { 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 }; /* Encryption/decryption of data units (typically, volume data sectors) */ nbrUnits = sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE; /* 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 = 562949953420800LL; writeOffset > 562949953420800LL - nbrUnits * ENCRYPTION_DATA_UNIT_SIZE; writeOffset -= ENCRYPTION_DATA_UNIT_SIZE) { unitNo = writeOffset / ENCRYPTION_DATA_UNIT_SIZE; // Test all EAs that support this mode of operation foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms()) { - shared_ptr <EncryptionMode> mode (new EncryptionModeXTS); + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> mode (new EncryptionModeWolfCryptXTS); + #else + shared_ptr <EncryptionMode> mode (new EncryptionModeXTS); + #endif if (!ea.IsModeSupported (mode)) continue; ea.SetKey (ConstBufferPtr (testKey, ea.GetKeySize())); Buffer modeKey (ea.GetKeySize()); for (size_t mi = 0; mi < modeKey.Size(); mi++) - modeKey[mi] = (byte) mi; + modeKey[mi] = (uint8) mi; modeKey.CopyFrom (ConstBufferPtr (XtsTestVectors[array_capacity (XtsTestVectors)-1].key2, sizeof (XtsTestVectors[array_capacity (XtsTestVectors)-1].key2))); mode->SetKey (modeKey); ea.SetMode (mode); + #ifdef WOLFCRYPT_BACKEND + ea.SetKeyXTS (modeKey); + #endif - // Each data unit will contain the same plaintext + // Each data unit will contain the same plaintext for (i = 0; i < nbrUnits; i++) { memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, XtsTestVectors[array_capacity (XtsTestVectors)-1].plaintext, ENCRYPTION_DATA_UNIT_SIZE); } ea.EncryptSectors (buf, unitNo, nbrUnits, ENCRYPTION_DATA_UNIT_SIZE); crc = GetCrc32 (buf, sizeof (buf)); if (typeid (ea) == typeid (AES)) { // Verify the ciphertext of the "moving" data unit using the IEEE test vector #14 if (memcmp (XtsTestVectors[array_capacity (XtsTestVectors)-1].ciphertext, (unsigned char *) buf + testCase * ENCRYPTION_DATA_UNIT_SIZE, ENCRYPTION_DATA_UNIT_SIZE) != 0) { throw TestFailed (SRC_POS); } // CRC of all data units in the buffer for each test case switch (testCase) { case 0: if (crc != 0x888f2990) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 1: if (crc != 0xea28ea34) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 2: if (crc != 0xe058f5a2) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 3: if (crc != 0x10473dc9) throw TestFailed (SRC_POS); nTestsPerformed++; break; } } + #ifndef WOLFCRYPT_BACKEND else if (typeid (ea) == typeid (Serpent)) { switch (testCase) { case 0: if (crc != 0x7edfecb3) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 1: if (crc != 0x357baaaa) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 2: if (crc != 0xc7b9fca5) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 3: if (crc != 0xb5263e0c) throw TestFailed (SRC_POS); nTestsPerformed++; break; } } else if (typeid (ea) == typeid (Twofish)) { switch (testCase) { @@ -893,114 +915,122 @@ namespace VeraCrypt nTestsPerformed++; break; } } else if (typeid (ea) == typeid (KuznyechikSerpentCamellia)) { switch (testCase) { case 0: if (crc != 0x9d8ac7ee) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 1: if (crc != 0x5d7d347f) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 2: if (crc != 0x884b62ee) throw TestFailed (SRC_POS); nTestsPerformed++; break; case 3: if (crc != 0x5c6c3997) throw TestFailed (SRC_POS); nTestsPerformed++; break; } } - + #endif if (crc == 0x9f5edd58) throw TestFailed (SRC_POS); ea.DecryptSectors (buf, unitNo, nbrUnits, ENCRYPTION_DATA_UNIT_SIZE); if (GetCrc32 (buf, sizeof (buf)) != 0x9f5edd58) throw TestFailed (SRC_POS); nTestsPerformed++; } testCase++; } /* Encryption/decryption of a buffer (typically, a volume header) */ nbrUnits = sizeof (buf) / ENCRYPTION_DATA_UNIT_SIZE; // Test all EAs that support this mode of operation foreach_ref (EncryptionAlgorithm &ea, EncryptionAlgorithm::GetAvailableAlgorithms()) { + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> mode (new EncryptionModeWolfCryptXTS); + #else shared_ptr <EncryptionMode> mode (new EncryptionModeXTS); + #endif if (!ea.IsModeSupported (mode)) continue; ea.SetKey (ConstBufferPtr (testKey, ea.GetKeySize())); Buffer modeKey (ea.GetKeySize()); for (size_t mi = 0; mi < modeKey.Size(); mi++) - modeKey[mi] = (byte) mi; + modeKey[mi] = (uint8) mi; modeKey.CopyFrom (ConstBufferPtr (XtsTestVectors[array_capacity (XtsTestVectors)-1].key2, sizeof (XtsTestVectors[array_capacity (XtsTestVectors)-1].key2))); mode->SetKey (modeKey); ea.SetMode (mode); + #ifdef WOLFCRYPT_BACKEND + ea.SetKeyXTS (modeKey); + #endif // Each data unit will contain the same plaintext for (i = 0; i < nbrUnits; i++) { memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE, XtsTestVectors[array_capacity (XtsTestVectors)-1].plaintext, ENCRYPTION_DATA_UNIT_SIZE); } ea.Encrypt (buf, sizeof (buf)); crc = GetCrc32 (buf, sizeof (buf)); if (typeid (ea) == typeid (AES)) { if (crc != 0x33b91fab) throw TestFailed (SRC_POS); nTestsPerformed++; } + #ifndef WOLFCRYPT_BACKEND else if (typeid (ea) == typeid (Serpent)) { if (crc != 0x3494d480) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (Twofish)) { if (crc != 0xc4d65b46) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (Camellia)) { if (crc != 0x8176b223) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (Kuznyechik)) { if (crc != 0xd6d39cdb) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (AESTwofish)) { if (crc != 0x14ce7385) throw TestFailed (SRC_POS); nTestsPerformed++; } @@ -1031,79 +1061,95 @@ namespace VeraCrypt else if (typeid (ea) == typeid (CamelliaKuznyechik)) { if (crc != 0xe69d680d) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (KuznyechikTwofish)) { if (crc != 0xe0aef0d1) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (CamelliaSerpent)) { if (crc != 0x58aad727) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (KuznyechikAES)) { if (crc != 0x4641234a) throw TestFailed (SRC_POS); nTestsPerformed++; } else if (typeid (ea) == typeid (KuznyechikSerpentCamellia)) { if (crc != 0x755dad72) throw TestFailed (SRC_POS); nTestsPerformed++; } + #endif if (crc == 0x9f5edd58) throw TestFailed (SRC_POS); ea.Decrypt (buf, sizeof (buf)); if (GetCrc32 (buf, sizeof (buf)) != 0x9f5edd58) throw TestFailed (SRC_POS); nTestsPerformed++; } - + #ifndef WOLFCRYPT_BACKEND if (nTestsPerformed != 150) + #else + if (nTestsPerformed != 10) + #endif throw TestFailed (SRC_POS); } void EncryptionTest::TestPkcs5 () { - VolumePassword password ((byte*) "password", 8); - static const byte saltData[] = { 0x12, 0x34, 0x56, 0x78 }; + VolumePassword password ((uint8*) "password", 8); + static const uint8 saltData[] = { 0x12, 0x34, 0x56, 0x78 }; ConstBufferPtr salt (saltData, sizeof (saltData)); Buffer derivedKey (4); + #ifndef WOLFCRYPT_BACKEND Pkcs5HmacBlake2s pkcs5HmacBlake2s; pkcs5HmacBlake2s.DeriveKey (derivedKey, password, salt, 5); if (memcmp (derivedKey.Ptr(), "\x8d\x51\xfa\x31", 4) != 0) throw TestFailed (SRC_POS); Pkcs5HmacSha512 pkcs5HmacSha512; pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5); if (memcmp (derivedKey.Ptr(), "\x13\x64\xae\xf8", 4) != 0) throw TestFailed (SRC_POS); Pkcs5HmacWhirlpool pkcs5HmacWhirlpool; pkcs5HmacWhirlpool.DeriveKey (derivedKey, password, salt, 5); if (memcmp (derivedKey.Ptr(), "\x50\x7c\x36\x6f", 4) != 0) throw TestFailed (SRC_POS); Pkcs5HmacSha256 pkcs5HmacSha256; pkcs5HmacSha256.DeriveKey (derivedKey, password, salt, 5); if (memcmp (derivedKey.Ptr(), "\xf2\xa0\x4f\xb2", 4) != 0) throw TestFailed (SRC_POS); Pkcs5HmacStreebog pkcs5HmacStreebog; pkcs5HmacStreebog.DeriveKey (derivedKey, password, salt, 5); if (memcmp (derivedKey.Ptr(), "\xd0\x53\xa2\x30", 4) != 0) throw TestFailed (SRC_POS); - } + #else + Pkcs5HmacSha256 pkcs5HmacSha256; + pkcs5HmacSha256.DeriveKey (derivedKey, password, salt, 5); + if (memcmp (derivedKey.Ptr(), "\x64\xf3\xa5\xa3", 4) != 0) + throw TestFailed (SRC_POS); + + Pkcs5HmacSha512 pkcs5HmacSha512; + pkcs5HmacSha512.DeriveKey (derivedKey, password, salt, 5); + if (memcmp (derivedKey.Ptr(), "\x55\xa1\x76\xbb", 4) != 0) + throw TestFailed (SRC_POS); + #endif + } } diff --git a/src/Volume/EncryptionTest.h b/src/Volume/EncryptionTest.h index 17e14fd7..fae07cb2 100644 --- a/src/Volume/EncryptionTest.h +++ b/src/Volume/EncryptionTest.h @@ -6,49 +6,49 @@ Modifications and additions to the original source code (contained in this file) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_EncryptionTest #define TC_HEADER_Encryption_EncryptionTest #include "Platform/Platform.h" #include "Common/Crypto.h" namespace VeraCrypt { class EncryptionTest { public: static void TestAll (); static void TestAll (bool enableCpuEncryptionSupport); protected: static void TestCiphers (); static void TestLegacyModes (); static void TestPkcs5 (); static void TestXts (); static void TestXtsAES (); struct XtsTestVector { - byte key1[32]; - byte key2[32]; - byte dataUnitNo[8]; + uint8 key1[32]; + uint8 key2[32]; + uint8 dataUnitNo[8]; unsigned int blockNo; - byte plaintext[ENCRYPTION_DATA_UNIT_SIZE]; - byte ciphertext[ENCRYPTION_DATA_UNIT_SIZE]; + uint8 plaintext[ENCRYPTION_DATA_UNIT_SIZE]; + uint8 ciphertext[ENCRYPTION_DATA_UNIT_SIZE]; }; static const XtsTestVector XtsTestVectors[]; private: EncryptionTest (); virtual ~EncryptionTest (); EncryptionTest (const EncryptionTest &); EncryptionTest &operator= (const EncryptionTest &); }; } #endif // TC_HEADER_Encryption_EncryptionTest diff --git a/src/Volume/EncryptionThreadPool.cpp b/src/Volume/EncryptionThreadPool.cpp index 7c86bf49..36f8a622 100644 --- a/src/Volume/EncryptionThreadPool.cpp +++ b/src/Volume/EncryptionThreadPool.cpp @@ -1,65 +1,65 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifdef TC_UNIX # include <unistd.h> #endif #ifdef TC_MACOSX # include <sys/types.h> # include <sys/sysctl.h> #endif #include "Platform/SyncEvent.h" #include "Platform/SystemLog.h" #include "Common/Crypto.h" #include "EncryptionThreadPool.h" namespace VeraCrypt { - void EncryptionThreadPool::DoWork (WorkType::Enum type, const EncryptionMode *encryptionMode, byte *data, uint64 startUnitNo, uint64 unitCount, size_t sectorSize) + void EncryptionThreadPool::DoWork (WorkType::Enum type, const EncryptionMode *encryptionMode, uint8 *data, uint64 startUnitNo, uint64 unitCount, size_t sectorSize) { size_t fragmentCount; size_t unitsPerFragment; size_t remainder; - byte *fragmentData; + uint8 *fragmentData; uint64 fragmentStartUnitNo; WorkItem *workItem; WorkItem *firstFragmentWorkItem; if (unitCount == 0) return; if (!ThreadPoolRunning || unitCount == 1) { switch (type) { case WorkType::DecryptDataUnits: encryptionMode->DecryptSectorsCurrentThread (data, startUnitNo, unitCount, sectorSize); break; case WorkType::EncryptDataUnits: encryptionMode->EncryptSectorsCurrentThread (data, startUnitNo, unitCount, sectorSize); break; default: throw ParameterIncorrect (SRC_POS); } return; } if (unitCount <= ThreadCount) { fragmentCount = (size_t) unitCount; diff --git a/src/Volume/EncryptionThreadPool.h b/src/Volume/EncryptionThreadPool.h index baf31e23..a78aee75 100644 --- a/src/Volume/EncryptionThreadPool.h +++ b/src/Volume/EncryptionThreadPool.h @@ -28,64 +28,64 @@ namespace VeraCrypt EncryptDataUnits, DecryptDataUnits, DeriveKey }; }; struct WorkItem { struct State { enum Enum { Free, Ready, Busy }; }; struct WorkItem *FirstFragment; unique_ptr <Exception> ItemException; SyncEvent ItemCompletedEvent; SharedVal <size_t> OutstandingFragmentCount; SharedVal <State::Enum> State; WorkType::Enum Type; union { struct { const EncryptionMode *Mode; - byte *Data; + uint8 *Data; uint64 StartUnitNo; uint64 UnitCount; size_t SectorSize; } Encryption; }; }; - static void DoWork (WorkType::Enum type, const EncryptionMode *mode, byte *data, uint64 startUnitNo, uint64 unitCount, size_t sectorSize); + static void DoWork (WorkType::Enum type, const EncryptionMode *mode, uint8 *data, uint64 startUnitNo, uint64 unitCount, size_t sectorSize); static bool IsRunning () { return ThreadPoolRunning; } static void Start (); static void Stop (); protected: static void WorkThreadProc (); static const size_t MaxThreadCount = 32; static const size_t QueueSize = MaxThreadCount * 2; static Mutex DequeueMutex; static volatile size_t DequeuePosition; static volatile size_t EnqueuePosition; static Mutex EnqueueMutex; static list < shared_ptr <Thread> > RunningThreads; static volatile bool StopPending; static size_t ThreadCount; static volatile bool ThreadPoolRunning; static SyncEvent WorkItemCompletedEvent; static WorkItem WorkItemQueue[QueueSize]; static SyncEvent WorkItemReadyEvent; }; } #endif // TC_HEADER_Volume_EncryptionThreadPool diff --git a/src/Volume/Hash.cpp b/src/Volume/Hash.cpp index aad900c1..d2e3e649 100644 --- a/src/Volume/Hash.cpp +++ b/src/Volume/Hash.cpp @@ -1,166 +1,171 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Hash.h" #include "Crypto/blake2.h" #include "Crypto/Sha2.h" #include "Crypto/Whirlpool.h" #include "Crypto/Streebog.h" namespace VeraCrypt { HashList Hash::GetAvailableAlgorithms () { HashList l; l.push_back (shared_ptr <Hash> (new Sha512 ())); - l.push_back (shared_ptr <Hash> (new Whirlpool ())); - l.push_back (shared_ptr <Hash> (new Blake2s ())); l.push_back (shared_ptr <Hash> (new Sha256 ())); + #ifndef WOLFCRYPT_BACKEND + l.push_back (shared_ptr <Hash> (new Blake2s ())); + l.push_back (shared_ptr <Hash> (new Whirlpool ())); l.push_back (shared_ptr <Hash> (new Streebog ())); - + #endif return l; } void Hash::ValidateDataParameters (const ConstBufferPtr &data) const { if (data.Size() < 1) throw ParameterIncorrect (SRC_POS); } void Hash::ValidateDigestParameters (const BufferPtr &buffer) const { if (buffer.Size() < GetDigestSize ()) throw ParameterIncorrect (SRC_POS); } + #ifndef WOLFCRYPT_BACKEND // RIPEMD-160 Blake2s::Blake2s () { Context.Allocate (sizeof (blake2s_state), 32); Init(); } void Blake2s::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); blake2s_final ((blake2s_state *) Context.Ptr(), buffer); } void Blake2s::Init () { blake2s_init ((blake2s_state *) Context.Ptr()); } void Blake2s::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); blake2s_update ((blake2s_state *) Context.Ptr(), data.Get(), data.Size()); } + #endif // SHA-256 Sha256::Sha256 () { Context.Allocate (sizeof (sha256_ctx), 32); Init(); } void Sha256::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); sha256_end (buffer, (sha256_ctx *) Context.Ptr()); } void Sha256::Init () { sha256_begin ((sha256_ctx *) Context.Ptr()); } void Sha256::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); sha256_hash (data.Get(), (int) data.Size(), (sha256_ctx *) Context.Ptr()); } // SHA-512 Sha512::Sha512 () { Context.Allocate (sizeof (sha512_ctx), 32); Init(); } void Sha512::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); sha512_end (buffer, (sha512_ctx *) Context.Ptr()); } void Sha512::Init () { sha512_begin ((sha512_ctx *) Context.Ptr()); } void Sha512::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); sha512_hash (data.Get(), (int) data.Size(), (sha512_ctx *) Context.Ptr()); } + #ifndef WOLFCRYPT_BACKEND // Whirlpool Whirlpool::Whirlpool () { Context.Allocate (sizeof (WHIRLPOOL_CTX), 32); Init(); } void Whirlpool::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); WHIRLPOOL_finalize ((WHIRLPOOL_CTX *) Context.Ptr(), buffer); } void Whirlpool::Init () { WHIRLPOOL_init ((WHIRLPOOL_CTX *) Context.Ptr()); } void Whirlpool::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); WHIRLPOOL_add (data.Get(), (int) data.Size(), (WHIRLPOOL_CTX *) Context.Ptr()); } // Streebog Streebog::Streebog () { Context.Allocate (sizeof (STREEBOG_CTX), 32); Init(); } void Streebog::GetDigest (const BufferPtr &buffer) { if_debug (ValidateDigestParameters (buffer)); STREEBOG_finalize ((STREEBOG_CTX *) Context.Ptr(), buffer); } void Streebog::Init () { STREEBOG_init ((STREEBOG_CTX *) Context.Ptr()); } void Streebog::ProcessData (const ConstBufferPtr &data) { if_debug (ValidateDataParameters (data)); STREEBOG_add ((STREEBOG_CTX *) Context.Ptr(), data.Get(), (int) data.Size()); } + #endif } diff --git a/src/Volume/Hash.h b/src/Volume/Hash.h index 0e464b37..5720eb50 100644 --- a/src/Volume/Hash.h +++ b/src/Volume/Hash.h @@ -21,147 +21,151 @@ namespace VeraCrypt typedef list < shared_ptr <Hash> > HashList; class Hash { public: Hash () : Deprecated (false) { } virtual ~Hash () { } static HashList GetAvailableAlgorithms (); virtual void GetDigest (const BufferPtr &buffer) = 0; virtual size_t GetBlockSize () const = 0; virtual size_t GetDigestSize () const = 0; virtual wstring GetName () const = 0; virtual wstring GetAltName () const = 0; virtual shared_ptr <Hash> GetNew () const = 0; virtual void Init () = 0; bool IsDeprecated () const { return Deprecated; } virtual void ProcessData (const ConstBufferPtr &data) = 0; virtual void ValidateDataParameters (const ConstBufferPtr &data) const; virtual void ValidateDigestParameters (const BufferPtr &buffer) const; protected: SecureBuffer Context; bool Deprecated; private: Hash (const Hash &); Hash &operator= (const Hash &); }; + #ifndef WOLFCRYPT_BACKEND // Blake2s class Blake2s : public Hash { public: Blake2s (); virtual ~Blake2s () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 64; } virtual size_t GetDigestSize () const { return 32; } virtual wstring GetName () const { return L"BLAKE2s-256"; } virtual wstring GetAltName () const { return L"BLAKE2s"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Blake2s); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Blake2s (const Blake2s &); Blake2s &operator= (const Blake2s &); }; + #endif // SHA-256 class Sha256 : public Hash { public: Sha256 (); virtual ~Sha256 () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 64; } virtual size_t GetDigestSize () const { return 256 / 8; } virtual wstring GetName () const { return L"SHA-256"; } virtual wstring GetAltName () const { return L"SHA256"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha256); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Sha256 (const Sha256 &); Sha256 &operator= (const Sha256 &); }; // SHA-512 class Sha512 : public Hash { public: Sha512 (); virtual ~Sha512 () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 128; } virtual size_t GetDigestSize () const { return 512 / 8; } virtual wstring GetName () const { return L"SHA-512"; } virtual wstring GetAltName () const { return L"SHA512"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Sha512); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Sha512 (const Sha512 &); Sha512 &operator= (const Sha512 &); }; + #ifndef WOLFCRYPT_BACKEND // Whirlpool class Whirlpool : public Hash { public: Whirlpool (); virtual ~Whirlpool () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 64; } virtual size_t GetDigestSize () const { return 512 / 8; } virtual wstring GetName () const { return L"Whirlpool"; } virtual wstring GetAltName () const { return L"Whirlpool"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Whirlpool); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Whirlpool (const Whirlpool &); Whirlpool &operator= (const Whirlpool &); }; // Streebog class Streebog : public Hash { public: Streebog (); virtual ~Streebog () { } virtual void GetDigest (const BufferPtr &buffer); virtual size_t GetBlockSize () const { return 64; } virtual size_t GetDigestSize () const { return 512 / 8; } virtual wstring GetName () const { return L"Streebog"; } virtual wstring GetAltName () const { return L"Streebog"; } virtual shared_ptr <Hash> GetNew () const { return shared_ptr <Hash> (new Streebog); } virtual void Init (); virtual void ProcessData (const ConstBufferPtr &data); protected: private: Streebog (const Streebog &); Streebog &operator= (const Streebog &); }; + #endif } #endif // TC_HEADER_Encryption_Hash diff --git a/src/Volume/Keyfile.cpp b/src/Volume/Keyfile.cpp index 24b40709..e756cdf1 100644 --- a/src/Volume/Keyfile.cpp +++ b/src/Volume/Keyfile.cpp @@ -8,98 +8,98 @@ 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. */ #include "Platform/Serializer.h" #include "Common/SecurityToken.h" #include "Common/EMVToken.h" #include "Crc32.h" #include "Keyfile.h" #include "VolumeException.h" namespace VeraCrypt { void Keyfile::Apply (const BufferPtr &pool, bool emvSupportEnabled) const { if (Path.IsDirectory()) throw ParameterIncorrect (SRC_POS); File file; Crc32 crc32; size_t poolPos = 0; uint64 totalLength = 0; uint64 readLength; SecureBuffer keyfileBuf (File::GetOptimalReadSize()); if (Token::IsKeyfilePathValid (Path, emvSupportEnabled)) { // Apply keyfile generated by a security token - vector <byte> keyfileData; + vector <uint8> keyfileData; Token::getTokenKeyfile(wstring(Path))->GetKeyfileData(keyfileData); if (keyfileData.size() < MinProcessedLength) throw InsufficientData(SRC_POS, Path); for (size_t i = 0; i < keyfileData.size(); i++) { uint32 crc = crc32.Process(keyfileData[i]); - pool[poolPos++] += (byte)(crc >> 24); - pool[poolPos++] += (byte)(crc >> 16); - pool[poolPos++] += (byte)(crc >> 8); - pool[poolPos++] += (byte) crc; + pool[poolPos++] += (uint8)(crc >> 24); + pool[poolPos++] += (uint8)(crc >> 16); + pool[poolPos++] += (uint8)(crc >> 8); + pool[poolPos++] += (uint8) crc; if (poolPos >= pool.Size()) poolPos = 0; if (++totalLength >= MaxProcessedLength) break; } burn(&keyfileData.front(), keyfileData.size()); goto done; } file.Open (Path, File::OpenRead, File::ShareRead); while ((readLength = file.Read (keyfileBuf)) > 0) { for (size_t i = 0; i < readLength; i++) { uint32 crc = crc32.Process(keyfileBuf[i]); - pool[poolPos++] += (byte)(crc >> 24); - pool[poolPos++] += (byte)(crc >> 16); - pool[poolPos++] += (byte)(crc >> 8); - pool[poolPos++] += (byte) crc; + pool[poolPos++] += (uint8)(crc >> 24); + pool[poolPos++] += (uint8)(crc >> 16); + pool[poolPos++] += (uint8)(crc >> 8); + pool[poolPos++] += (uint8) crc; if (poolPos >= pool.Size()) poolPos = 0; if (++totalLength >= MaxProcessedLength) goto done; } } done: if (totalLength < MinProcessedLength) throw InsufficientData (SRC_POS, Path); } shared_ptr <VolumePassword> Keyfile::ApplyListToPassword (shared_ptr <KeyfileList> keyfiles, shared_ptr <VolumePassword> password, bool emvSupportEnabled) { if (!password) password.reset (new VolumePassword); if (!keyfiles || keyfiles->size() < 1) return password; KeyfileList keyfilesExp; HiddenFileWasPresentInKeyfilePath = false; // Enumerate directories foreach (shared_ptr <Keyfile> keyfile, *keyfiles) { if (FilesystemPath (*keyfile).IsDirectory()) { size_t keyfileCount = 0; foreach_ref (const FilePath &path, Directory::GetFilePaths (*keyfile)) diff --git a/src/Volume/Pkcs5Kdf.cpp b/src/Volume/Pkcs5Kdf.cpp index ff49cefe..820f1121 100644 --- a/src/Volume/Pkcs5Kdf.cpp +++ b/src/Volume/Pkcs5Kdf.cpp @@ -29,91 +29,96 @@ namespace VeraCrypt DeriveKey (key, password, salt, GetIterationCount(pim)); } shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const wstring &name) { foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms()) { if (kdf->GetName() == name) return kdf; } throw ParameterIncorrect (SRC_POS); } shared_ptr <Pkcs5Kdf> Pkcs5Kdf::GetAlgorithm (const Hash &hash) { foreach (shared_ptr <Pkcs5Kdf> kdf, GetAvailableAlgorithms()) { if (typeid (*kdf->GetHash()) == typeid (hash)) return kdf; } throw ParameterIncorrect (SRC_POS); } Pkcs5KdfList Pkcs5Kdf::GetAvailableAlgorithms () { Pkcs5KdfList l; l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256 ())); + #ifndef WOLFCRYPT_BACKEND l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s ())); - l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ())); + l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ())); - + #endif return l; } void Pkcs5Kdf::ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { if (key.Size() < 1 || password.Size() < 1 || salt.Size() < 1 || iterationCount < 1) throw ParameterIncorrect (SRC_POS); } + #ifndef WOLFCRYPT_BACKEND void Pkcs5HmacBlake2s_Boot::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_blake2s ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacBlake2s::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_blake2s ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } + #endif void Pkcs5HmacSha256_Boot::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_sha256 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacSha256::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_sha256 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacSha512::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_sha512 ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } + #ifndef WOLFCRYPT_BACKEND void Pkcs5HmacWhirlpool::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_whirlpool ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacStreebog::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_streebog ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } void Pkcs5HmacStreebog_Boot::DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const { ValidateParameters (key, password, salt, iterationCount); derive_key_streebog ((char *) password.DataPtr(), (int) password.Size(), (char *) salt.Get(), (int) salt.Size(), iterationCount, (char *) key.Get(), (int) key.Size()); } + #endif } diff --git a/src/Volume/Pkcs5Kdf.h b/src/Volume/Pkcs5Kdf.h index 9071caf0..fc83eb06 100644 --- a/src/Volume/Pkcs5Kdf.h +++ b/src/Volume/Pkcs5Kdf.h @@ -21,168 +21,171 @@ namespace VeraCrypt { class Pkcs5Kdf; typedef list < shared_ptr <Pkcs5Kdf> > Pkcs5KdfList; class Pkcs5Kdf { public: virtual ~Pkcs5Kdf (); virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, int pim, const ConstBufferPtr &salt) const; virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const = 0; static shared_ptr <Pkcs5Kdf> GetAlgorithm (const wstring &name); static shared_ptr <Pkcs5Kdf> GetAlgorithm (const Hash &hash); static Pkcs5KdfList GetAvailableAlgorithms (); virtual shared_ptr <Hash> GetHash () const = 0; virtual int GetIterationCount (int pim) const = 0; virtual wstring GetName () const = 0; virtual Pkcs5Kdf* Clone () const = 0; virtual bool IsDeprecated () const { return GetHash()->IsDeprecated(); } protected: Pkcs5Kdf (); void ValidateParameters (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; private: Pkcs5Kdf (const Pkcs5Kdf &); Pkcs5Kdf &operator= (const Pkcs5Kdf &); }; + #ifndef WOLFCRYPT_BACKEND class Pkcs5HmacBlake2s_Boot : public Pkcs5Kdf { public: Pkcs5HmacBlake2s_Boot () : Pkcs5Kdf() { } virtual ~Pkcs5HmacBlake2s_Boot () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Blake2s); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 200000 : (pim * 2048); } virtual wstring GetName () const { return L"HMAC-BLAKE2s-256"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacBlake2s_Boot(); } private: Pkcs5HmacBlake2s_Boot (const Pkcs5HmacBlake2s_Boot &); Pkcs5HmacBlake2s_Boot &operator= (const Pkcs5HmacBlake2s_Boot &); }; class Pkcs5HmacBlake2s : public Pkcs5Kdf { public: Pkcs5HmacBlake2s () : Pkcs5Kdf() { } virtual ~Pkcs5HmacBlake2s () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Blake2s); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 500000 : (15000 + (pim * 1000)); } virtual wstring GetName () const { return L"HMAC-BLAKE2s-256"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacBlake2s(); } private: Pkcs5HmacBlake2s (const Pkcs5HmacBlake2s &); Pkcs5HmacBlake2s &operator= (const Pkcs5HmacBlake2s &); }; + #endif class Pkcs5HmacSha256_Boot : public Pkcs5Kdf { public: Pkcs5HmacSha256_Boot () : Pkcs5Kdf() { } virtual ~Pkcs5HmacSha256_Boot () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha256); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 200000 : (pim * 2048); } virtual wstring GetName () const { return L"HMAC-SHA-256"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha256_Boot(); } private: Pkcs5HmacSha256_Boot (const Pkcs5HmacSha256_Boot &); Pkcs5HmacSha256_Boot &operator= (const Pkcs5HmacSha256_Boot &); }; class Pkcs5HmacSha256 : public Pkcs5Kdf { public: Pkcs5HmacSha256 () : Pkcs5Kdf() { } virtual ~Pkcs5HmacSha256 () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha256); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 500000 : (15000 + (pim * 1000)); } virtual wstring GetName () const { return L"HMAC-SHA-256"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha256(); } private: Pkcs5HmacSha256 (const Pkcs5HmacSha256 &); Pkcs5HmacSha256 &operator= (const Pkcs5HmacSha256 &); }; class Pkcs5HmacSha512 : public Pkcs5Kdf { public: Pkcs5HmacSha512 () : Pkcs5Kdf() { } virtual ~Pkcs5HmacSha512 () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Sha512); } virtual int GetIterationCount (int pim) const { return (pim <= 0 ? 500000 : (15000 + (pim * 1000))); } virtual wstring GetName () const { return L"HMAC-SHA-512"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacSha512(); } private: Pkcs5HmacSha512 (const Pkcs5HmacSha512 &); Pkcs5HmacSha512 &operator= (const Pkcs5HmacSha512 &); }; - + #ifndef WOLFCRYPT_BACKEND class Pkcs5HmacWhirlpool : public Pkcs5Kdf { public: Pkcs5HmacWhirlpool () : Pkcs5Kdf() { } virtual ~Pkcs5HmacWhirlpool () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Whirlpool); } virtual int GetIterationCount (int pim) const { return (pim <= 0 ? 500000 : (15000 + (pim * 1000))); } virtual wstring GetName () const { return L"HMAC-Whirlpool"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacWhirlpool(); } private: Pkcs5HmacWhirlpool (const Pkcs5HmacWhirlpool &); Pkcs5HmacWhirlpool &operator= (const Pkcs5HmacWhirlpool &); }; class Pkcs5HmacStreebog : public Pkcs5Kdf { public: Pkcs5HmacStreebog () : Pkcs5Kdf() { } virtual ~Pkcs5HmacStreebog () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Streebog); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 500000 : (15000 + (pim * 1000)); } virtual wstring GetName () const { return L"HMAC-Streebog"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacStreebog(); } private: Pkcs5HmacStreebog (const Pkcs5HmacStreebog &); Pkcs5HmacStreebog &operator= (const Pkcs5HmacStreebog &); }; class Pkcs5HmacStreebog_Boot : public Pkcs5Kdf { public: Pkcs5HmacStreebog_Boot () : Pkcs5Kdf() { } virtual ~Pkcs5HmacStreebog_Boot () { } virtual void DeriveKey (const BufferPtr &key, const VolumePassword &password, const ConstBufferPtr &salt, int iterationCount) const; virtual shared_ptr <Hash> GetHash () const { return shared_ptr <Hash> (new Streebog); } virtual int GetIterationCount (int pim) const { return pim <= 0 ? 200000 : pim * 2048; } virtual wstring GetName () const { return L"HMAC-Streebog"; } virtual Pkcs5Kdf* Clone () const { return new Pkcs5HmacStreebog_Boot(); } private: Pkcs5HmacStreebog_Boot (const Pkcs5HmacStreebog_Boot &); Pkcs5HmacStreebog_Boot &operator= (const Pkcs5HmacStreebog_Boot &); }; + #endif } #endif // TC_HEADER_Encryption_Pkcs5 diff --git a/src/Volume/Volume.h b/src/Volume/Volume.h index c816da58..4b91e435 100644 --- a/src/Volume/Volume.h +++ b/src/Volume/Volume.h @@ -87,60 +87,61 @@ namespace VeraCrypt void Close (); shared_ptr <EncryptionAlgorithm> GetEncryptionAlgorithm () const; shared_ptr <EncryptionMode> GetEncryptionMode () const; shared_ptr <File> GetFile () const { return VolumeFile; } shared_ptr <VolumeHeader> GetHeader () const { return Header; } uint64 GetHeaderCreationTime () const { return Header->GetHeaderCreationTime(); } uint64 GetHostSize () const { return VolumeHostSize; } shared_ptr <VolumeLayout> GetLayout () const { return Layout; } VolumePath GetPath () const { return VolumeFile->GetPath(); } VolumeProtection::Enum GetProtectionType () const { return Protection; } shared_ptr <Pkcs5Kdf> GetPkcs5Kdf () const { return Header->GetPkcs5Kdf(); } uint32 GetSaltSize () const { return Header->GetSaltSize(); } size_t GetSectorSize () const { return SectorSize; } uint64 GetSize () const { return VolumeDataSize; } uint64 GetEncryptedSize () const { return EncryptedDataSize; } uint64 GetTopWriteOffset () const { return TopWriteOffset; } uint64 GetTotalDataRead () const { return TotalDataRead; } uint64 GetTotalDataWritten () const { return TotalDataWritten; } VolumeType::Enum GetType () const { return Type; } int GetPim() const { return Pim;} uint64 GetVolumeCreationTime () const { return Header->GetVolumeCreationTime(); } bool IsHiddenVolumeProtectionTriggered () const { return HiddenVolumeProtectionTriggered; } bool IsInSystemEncryptionScope () const { return SystemEncryption; } void Open (const VolumePath &volumePath, bool preserveTimestamps, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (),shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), bool sharedAccessAllowed = false, VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false); void Open (shared_ptr <File> volumeFile, shared_ptr <VolumePassword> password, int pim, shared_ptr <Pkcs5Kdf> kdf, shared_ptr <KeyfileList> keyfiles, bool emvSupportEnabled, VolumeProtection::Enum protection = VolumeProtection::None, shared_ptr <VolumePassword> protectionPassword = shared_ptr <VolumePassword> (), int protectionPim = 0, shared_ptr <Pkcs5Kdf> protectionKdf = shared_ptr <Pkcs5Kdf> (), shared_ptr <KeyfileList> protectionKeyfiles = shared_ptr <KeyfileList> (), VolumeType::Enum volumeType = VolumeType::Unknown, bool useBackupHeaders = false, bool partitionInSystemEncryptionScope = false); void ReadSectors (const BufferPtr &buffer, uint64 byteOffset); void ReEncryptHeader (bool backupHeader, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf); void WriteSectors (const ConstBufferPtr &buffer, uint64 byteOffset); bool IsEncryptionNotCompleted () const { return EncryptionNotCompleted; } + bool IsMasterKeyVulnerable() const { return Header && Header->IsMasterKeyVulnerable(); } protected: void CheckProtectedRange (uint64 writeHostOffset, uint64 writeLength); void ValidateState () const; shared_ptr <EncryptionAlgorithm> EA; shared_ptr <VolumeHeader> Header; bool HiddenVolumeProtectionTriggered; shared_ptr <VolumeLayout> Layout; uint64 ProtectedRangeStart; uint64 ProtectedRangeEnd; VolumeProtection::Enum Protection; size_t SectorSize; bool SystemEncryption; VolumeType::Enum Type; shared_ptr <File> VolumeFile; uint64 VolumeHostSize; uint64 VolumeDataOffset; uint64 VolumeDataSize; uint64 EncryptedDataSize; uint64 TopWriteOffset; uint64 TotalDataRead; uint64 TotalDataWritten; int Pim; bool EncryptionNotCompleted; private: Volume (const Volume &); Volume &operator= (const Volume &); }; diff --git a/src/Volume/Volume.make b/src/Volume/Volume.make index d69ec135..708f28c5 100644 --- a/src/Volume/Volume.make +++ b/src/Volume/Volume.make @@ -1,163 +1,181 @@ # # Derived from source code of TrueCrypt 7.1a, which is # 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) # and all other portions of this file are Copyright (c) 2013-2017 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. # OBJS := OBJSEX := OBJSNOOPT := OBJS += Cipher.o OBJS += EncryptionAlgorithm.o OBJS += EncryptionMode.o -OBJS += EncryptionModeXTS.o OBJS += EncryptionTest.o OBJS += EncryptionThreadPool.o OBJS += Hash.o OBJS += Keyfile.o OBJS += Pkcs5Kdf.o OBJS += Volume.o OBJS += VolumeException.o OBJS += VolumeHeader.o OBJS += VolumeInfo.o OBJS += VolumeLayout.o OBJS += VolumePassword.o OBJS += VolumePasswordCache.o +ifeq "$(ENABLE_WOLFCRYPT)" "0" +OBJS += EncryptionModeXTS.o +else +OBJS += EncryptionModeWolfCryptXTS.o +endif + +ifeq "$(ENABLE_WOLFCRYPT)" "0" ifeq "$(PLATFORM)" "MacOSX" - OBJSEX += ../Crypto/Aes_asm.oo - OBJS += ../Crypto/Aes_hw_cpu.o - OBJS += ../Crypto/Aescrypt.o - OBJSEX += ../Crypto/Twofish_asm.oo - OBJSEX += ../Crypto/Camellia_asm.oo +ifneq "$(COMPILE_ASM)" "false" + OBJSEX += ../Crypto/Aes_asm.oo + OBJS += ../Crypto/Aes_hw_cpu.o + OBJS += ../Crypto/Aescrypt.o + OBJSEX += ../Crypto/Twofish_asm.oo + OBJSEX += ../Crypto/Camellia_asm.oo OBJSEX += ../Crypto/Camellia_aesni_asm.oo OBJSEX += ../Crypto/sha256-nayuki.oo OBJSEX += ../Crypto/sha512-nayuki.oo OBJSEX += ../Crypto/sha256_avx1.oo OBJSEX += ../Crypto/sha256_avx2.oo OBJSEX += ../Crypto/sha256_sse4.oo OBJSEX += ../Crypto/sha512_avx1.oo OBJSEX += ../Crypto/sha512_avx2.oo OBJSEX += ../Crypto/sha512_sse4.oo +endif else ifeq "$(CPU_ARCH)" "x86" OBJS += ../Crypto/Aes_x86.o -ifeq "$(DISABLE_AESNI)" "0" - OBJS += ../Crypto/Aes_hw_cpu.o -endif + ifeq "$(DISABLE_AESNI)" "0" + OBJS += ../Crypto/Aes_hw_cpu.o + endif OBJS += ../Crypto/sha256-x86-nayuki.o OBJS += ../Crypto/sha512-x86-nayuki.o else ifeq "$(CPU_ARCH)" "x64" OBJS += ../Crypto/Aes_x64.o -ifeq "$(DISABLE_AESNI)" "0" - OBJS += ../Crypto/Aes_hw_cpu.o -endif + ifeq "$(DISABLE_AESNI)" "0" + OBJS += ../Crypto/Aes_hw_cpu.o + endif OBJS += ../Crypto/Twofish_x64.o OBJS += ../Crypto/Camellia_x64.o OBJS += ../Crypto/Camellia_aesni_x64.o OBJS += ../Crypto/sha512-x64-nayuki.o OBJS += ../Crypto/sha256_avx1_x64.o OBJS += ../Crypto/sha256_avx2_x64.o OBJS += ../Crypto/sha256_sse4_x64.o OBJS += ../Crypto/sha512_avx1_x64.o OBJS += ../Crypto/sha512_avx2_x64.o OBJS += ../Crypto/sha512_sse4_x64.o else OBJS += ../Crypto/Aescrypt.o endif ifeq "$(GCC_GTEQ_430)" "1" -OBJSSSE41 += ../Crypto/blake2s_SSE41.osse41 -OBJSSSSE3 += ../Crypto/blake2s_SSSE3.ossse3 + OBJSSSE41 += ../Crypto/blake2s_SSE41.osse41 + OBJSSSSE3 += ../Crypto/blake2s_SSSE3.ossse3 +else + OBJS += ../Crypto/blake2s_SSE41.o + OBJS += ../Crypto/blake2s_SSSE3.o +endif else -OBJS += ../Crypto/blake2s_SSE41.o -OBJS += ../Crypto/blake2s_SSSE3.o +OBJS += ../Crypto/wolfCrypt.o endif +ifeq "$(ENABLE_WOLFCRYPT)" "0" OBJS += ../Crypto/Aeskey.o OBJS += ../Crypto/Aestab.o -OBJS += ../Crypto/cpu.o OBJS += ../Crypto/blake2s.o OBJS += ../Crypto/blake2s_SSE2.o OBJS += ../Crypto/SerpentFast.o OBJS += ../Crypto/SerpentFast_simd.o OBJS += ../Crypto/Sha2.o OBJS += ../Crypto/Twofish.o OBJS += ../Crypto/Whirlpool.o OBJS += ../Crypto/Camellia.o OBJS += ../Crypto/Streebog.o OBJS += ../Crypto/kuznyechik.o OBJS += ../Crypto/kuznyechik_simd.o +OBJS += ../Common/Pkcs5.o +endif + +OBJS += ../Crypto/cpu.o OBJSNOOPT += ../Crypto/jitterentropy-base.o0 OBJS += ../Common/CommandAPDU.o OBJS += ../Common/PCSCException.o OBJS += ../Common/ResponseAPDU.o OBJS += ../Common/SCard.o OBJS += ../Common/SCardLoader.o OBJS += ../Common/SCardManager.o OBJS += ../Common/SCardReader.o OBJS += ../Common/Token.o OBJS += ../Common/Crc.o OBJS += ../Common/TLVParser.o OBJS += ../Common/EMVCard.o OBJS += ../Common/EMVToken.o OBJS += ../Common/Endian.o OBJS += ../Common/GfMul.o -OBJS += ../Common/Pkcs5.o OBJS += ../Common/SecurityToken.o VolumeLibrary: Volume.a +ifeq "$(ENABLE_WOLFCRYPT)" "0" ifeq "$(PLATFORM)" "MacOSX" +ifneq "$(COMPILE_ASM)" "false" ../Crypto/Aes_asm.oo: ../Crypto/Aes_x86.asm ../Crypto/Aes_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS32) -o ../Crypto/Aes_x86.o ../Crypto/Aes_x86.asm $(AS) $(ASFLAGS64) -o ../Crypto/Aes_x64.o ../Crypto/Aes_x64.asm lipo -create ../Crypto/Aes_x86.o ../Crypto/Aes_x64.o -output ../Crypto/Aes_asm.oo rm -fr ../Crypto/Aes_x86.o ../Crypto/Aes_x64.o ../Crypto/Twofish_asm.oo: ../Crypto/Twofish_x64.S @echo Assembling $(<F) - $(AS) $(ASFLAGS64) -p gas -o ../Crypto/Twofish_asm.oo ../Crypto/Twofish_x64.S + $(AS) $(ASFLAGS64) -p gas -o ../Crypto/Twofish_asm.oo ../Crypto/Twofish_x64.S ../Crypto/Camellia_asm.oo: ../Crypto/Camellia_x64.S @echo Assembling $(<F) $(AS) $(ASFLAGS64) -p gas -o ../Crypto/Camellia_asm.oo ../Crypto/Camellia_x64.S ../Crypto/Camellia_aesni_asm.oo: ../Crypto/Camellia_aesni_x64.S @echo Assembling $(<F) $(AS) $(ASFLAGS64) -p gas -o ../Crypto/Camellia_aesni_asm.oo ../Crypto/Camellia_aesni_x64.S ../Crypto/sha256-nayuki.oo: ../Crypto/sha256-x86-nayuki.S @echo Assembling $(<F) $(AS) $(ASFLAGS32) -p gas -o ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x86-nayuki.S $(AS) $(ASFLAGS64) -p gas -o ../Crypto/sha256-x64-nayuki.o ../Crypto/sha256-x64-nayuki.S lipo -create ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x64-nayuki.o -output ../Crypto/sha256-nayuki.oo rm -fr ../Crypto/sha256-x86-nayuki.o ../Crypto/sha256-x64-nayuki.o ../Crypto/sha256_avx1.oo: ../Crypto/sha256_avx1_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha256_avx1.oo ../Crypto/sha256_avx1_x64.asm ../Crypto/sha256_avx2.oo: ../Crypto/sha256_avx2_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha256_avx2.oo ../Crypto/sha256_avx2_x64.asm ../Crypto/sha256_sse4.oo: ../Crypto/sha256_sse4_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha256_sse4.oo ../Crypto/sha256_sse4_x64.asm ../Crypto/sha512-nayuki.oo: ../Crypto/sha512-x64-nayuki.S @echo Assembling $(<F) $(AS) -p gas $(ASFLAGS64) -o ../Crypto/sha512-nayuki.oo ../Crypto/sha512-x64-nayuki.S ../Crypto/sha512_avx1.oo: ../Crypto/sha512_avx1_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha512_avx1.oo ../Crypto/sha512_avx1_x64.asm ../Crypto/sha512_avx2.oo: ../Crypto/sha512_avx2_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha512_avx2.oo ../Crypto/sha512_avx2_x64.asm ../Crypto/sha512_sse4.oo: ../Crypto/sha512_sse4_x64.asm @echo Assembling $(<F) $(AS) $(ASFLAGS64) -o ../Crypto/sha512_sse4.oo ../Crypto/sha512_sse4_x64.asm endif +endif +endif include $(BUILD_INC)/Makefile.inc diff --git a/src/Volume/VolumeHeader.cpp b/src/Volume/VolumeHeader.cpp index d8527ed5..2b8699a3 100644 --- a/src/Volume/VolumeHeader.cpp +++ b/src/Volume/VolumeHeader.cpp @@ -1,143 +1,165 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Crc32.h" #include "EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "EncryptionModeWolfCryptXTS.h" +#endif #include "Pkcs5Kdf.h" #include "Pkcs5Kdf.h" #include "VolumeHeader.h" #include "VolumeException.h" #include "Common/Crypto.h" namespace VeraCrypt { VolumeHeader::VolumeHeader (uint32 size) { Init(); HeaderSize = size; EncryptedHeaderDataSize = size - EncryptedHeaderDataOffset; } VolumeHeader::~VolumeHeader () { Init(); } void VolumeHeader::Init () { VolumeKeyAreaCrc32 = 0; VolumeCreationTime = 0; HeaderCreationTime = 0; mVolumeType = VolumeType::Unknown; HiddenVolumeDataSize = 0; VolumeDataSize = 0; EncryptedAreaStart = 0; EncryptedAreaLength = 0; Flags = 0; SectorSize = 0; + XtsKeyVulnerable = false; } void VolumeHeader::Create (const BufferPtr &headerBuffer, VolumeHeaderCreationOptions &options) { if (options.DataKey.Size() != options.EA->GetKeySize() * 2 || options.Salt.Size() != GetSaltSize()) throw ParameterIncorrect (SRC_POS); headerBuffer.Zero(); HeaderVersion = CurrentHeaderVersion; RequiredMinProgramVersion = CurrentRequiredMinProgramVersion; DataAreaKey.Zero(); DataAreaKey.CopyFrom (options.DataKey); + // check if the XTS key is vulnerable by comparing the two parts of the key + XtsKeyVulnerable = (memcmp (options.DataKey.Get() + options.EA->GetKeySize(), options.DataKey.Get(), options.EA->GetKeySize()) == 0); + VolumeCreationTime = 0; HiddenVolumeDataSize = (options.Type == VolumeType::Hidden ? options.VolumeDataSize : 0); VolumeDataSize = options.VolumeDataSize; EncryptedAreaStart = options.VolumeDataStart; EncryptedAreaLength = options.VolumeDataSize; SectorSize = options.SectorSize; if (SectorSize < TC_MIN_VOLUME_SECTOR_SIZE || SectorSize > TC_MAX_VOLUME_SECTOR_SIZE || SectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0) { throw ParameterIncorrect (SRC_POS); } EA = options.EA; - shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ()); - EA->SetMode (mode); + #ifdef WOLFCRYPT_BACKEND + shared_ptr <EncryptionMode> mode (new EncryptionModeWolfCryptXTS ()); + #else + shared_ptr <EncryptionMode> mode (new EncryptionModeXTS ()); + #endif + EA->SetMode (mode); EncryptNew (headerBuffer, options.Salt, options.HeaderKey, options.Kdf); } bool VolumeHeader::Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes) { if (password.Size() < 1) throw PasswordEmpty (SRC_POS); ConstBufferPtr salt (encryptedData.GetRange (SaltOffset, SaltSize)); SecureBuffer header (EncryptedHeaderDataSize); SecureBuffer headerKey (GetLargestSerializedKeySize()); foreach (shared_ptr <Pkcs5Kdf> pkcs5, keyDerivationFunctions) { if (kdf && (kdf->GetName() != pkcs5->GetName())) continue; pkcs5->DeriveKey (headerKey, password, pim, salt); foreach (shared_ptr <EncryptionMode> mode, encryptionModes) { - if (typeid (*mode) != typeid (EncryptionModeXTS)) - mode->SetKey (headerKey.GetRange (0, mode->GetKeySize())); + #ifdef WOLFCRYPT_BACKEND + if (typeid (*mode) != typeid (EncryptionModeWolfCryptXTS)) + #else + if (typeid (*mode) != typeid (EncryptionModeXTS)) + #endif + mode->SetKey (headerKey.GetRange (0, mode->GetKeySize())); foreach (shared_ptr <EncryptionAlgorithm> ea, encryptionAlgorithms) { if (!ea->IsModeSupported (mode)) continue; + #ifndef WOLFCRYPT_BACKEND if (typeid (*mode) == typeid (EncryptionModeXTS)) { - ea->SetKey (headerKey.GetRange (0, ea->GetKeySize())); + ea->SetKey (headerKey.GetRange (0, ea->GetKeySize())); + #else + if (typeid (*mode) == typeid (EncryptionModeWolfCryptXTS)) + { + ea->SetKey (headerKey.GetRange (0, ea->GetKeySize())); + ea->SetKeyXTS (headerKey.GetRange (ea->GetKeySize(), ea->GetKeySize())); + #endif mode = mode->GetNew(); mode->SetKey (headerKey.GetRange (ea->GetKeySize(), ea->GetKeySize())); } else { ea->SetKey (headerKey.GetRange (LegacyEncryptionModeKeyAreaSize, ea->GetKeySize())); } ea->SetMode (mode); header.CopyFrom (encryptedData.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize)); ea->Decrypt (header); if (Deserialize (header, ea, mode)) { EA = ea; Pkcs5 = pkcs5; return true; } } } } return false; } bool VolumeHeader::Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode) { if (header.Size() != EncryptedHeaderDataSize) @@ -179,108 +201,125 @@ namespace VeraCrypt EncryptedAreaStart = DeserializeEntry <uint64> (header, offset); EncryptedAreaLength = DeserializeEntry <uint64> (header, offset); Flags = DeserializeEntry <uint32> (header, offset); SectorSize = DeserializeEntry <uint32> (header, offset); if (HeaderVersion < 5) SectorSize = TC_SECTOR_SIZE_LEGACY; if (SectorSize < TC_MIN_VOLUME_SECTOR_SIZE || SectorSize > TC_MAX_VOLUME_SECTOR_SIZE || SectorSize % ENCRYPTION_DATA_UNIT_SIZE != 0) { throw ParameterIncorrect (SRC_POS); } #if !(defined (TC_WINDOWS) || defined (TC_LINUX) || defined (TC_MACOSX)) if (SectorSize != TC_SECTOR_SIZE_LEGACY) throw UnsupportedSectorSize (SRC_POS); #endif offset = DataAreaKeyOffset; if (VolumeKeyAreaCrc32 != Crc32::ProcessBuffer (header.GetRange (offset, DataKeyAreaMaxSize))) return false; DataAreaKey.CopyFrom (header.GetRange (offset, DataKeyAreaMaxSize)); ea = ea->GetNew(); mode = mode->GetNew(); + #ifndef WOLFCRYPT_BACKEND if (typeid (*mode) == typeid (EncryptionModeXTS)) { - ea->SetKey (header.GetRange (offset, ea->GetKeySize())); + ea->SetKey (header.GetRange (offset, ea->GetKeySize())); + #else + if (typeid (*mode) == typeid (EncryptionModeWolfCryptXTS)) + { + ea->SetKey (header.GetRange (offset, ea->GetKeySize())); + ea->SetKeyXTS (header.GetRange (offset + ea->GetKeySize(), ea->GetKeySize())); + #endif mode->SetKey (header.GetRange (offset + ea->GetKeySize(), ea->GetKeySize())); + + // check if the XTS key is vulnerable by comparing the two parts of the key + XtsKeyVulnerable = (memcmp (DataAreaKey.Ptr() + ea->GetKeySize(), DataAreaKey.Ptr(), ea->GetKeySize()) == 0); } else { mode->SetKey (header.GetRange (offset, mode->GetKeySize())); ea->SetKey (header.GetRange (offset + LegacyEncryptionModeKeyAreaSize, ea->GetKeySize())); } ea->SetMode (mode); return true; } template <typename T> T VolumeHeader::DeserializeEntry (const ConstBufferPtr &header, size_t &offset) const { offset += sizeof (T); if (offset > header.Size()) throw ParameterIncorrect (SRC_POS); return Endian::Big (*reinterpret_cast<const T *> (header.Get() + offset - sizeof (T))); } template <typename T> T VolumeHeader::DeserializeEntryAt (const ConstBufferPtr &header, const size_t &offset) const { if (offset > header.Size()) throw ParameterIncorrect (SRC_POS); return Endian::Big (*reinterpret_cast<const T *> (header.Get() + offset)); } void VolumeHeader::EncryptNew (const BufferPtr &newHeaderBuffer, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf) { if (newHeaderBuffer.Size() != HeaderSize || newSalt.Size() != SaltSize) throw ParameterIncorrect (SRC_POS); shared_ptr <EncryptionMode> mode = EA->GetMode()->GetNew(); shared_ptr <EncryptionAlgorithm> ea = EA->GetNew(); + #ifndef WOLFCRYPT_BACKEND if (typeid (*mode) == typeid (EncryptionModeXTS)) { - mode->SetKey (newHeaderKey.GetRange (EA->GetKeySize(), EA->GetKeySize())); - ea->SetKey (newHeaderKey.GetRange (0, ea->GetKeySize())); + ea->SetKey (newHeaderKey.GetRange (0, ea->GetKeySize())); + #else + if (typeid (*mode) == typeid (EncryptionModeWolfCryptXTS)) + { + ea->SetKey (newHeaderKey.GetRange (0, ea->GetKeySize())); + ea->SetKeyXTS (newHeaderKey.GetRange (EA->GetKeySize(), EA->GetKeySize())); + #endif + mode->SetKey (newHeaderKey.GetRange (EA->GetKeySize(), EA->GetKeySize())); } else { mode->SetKey (newHeaderKey.GetRange (0, mode->GetKeySize())); ea->SetKey (newHeaderKey.GetRange (LegacyEncryptionModeKeyAreaSize, ea->GetKeySize())); } ea->SetMode (mode); newHeaderBuffer.CopyFrom (newSalt); BufferPtr headerData = newHeaderBuffer.GetRange (EncryptedHeaderDataOffset, EncryptedHeaderDataSize); Serialize (headerData); ea->Encrypt (headerData); if (newPkcs5Kdf) Pkcs5 = newPkcs5Kdf; } size_t VolumeHeader::GetLargestSerializedKeySize () { size_t largestKey = EncryptionAlgorithm::GetLargestKeySize (EncryptionAlgorithm::GetAvailableAlgorithms()); // XTS mode requires the same key size as the encryption algorithm. // Legacy modes may require larger key than XTS. if (LegacyEncryptionModeKeyAreaSize + largestKey > largestKey * 2) return LegacyEncryptionModeKeyAreaSize + largestKey; return largestKey * 2; } diff --git a/src/Volume/VolumeHeader.h b/src/Volume/VolumeHeader.h index 85908711..18a52950 100644 --- a/src/Volume/VolumeHeader.h +++ b/src/Volume/VolumeHeader.h @@ -49,82 +49,84 @@ namespace VeraCrypt ConstBufferPtr Salt; uint32 SectorSize; uint64 VolumeDataSize; uint64 VolumeDataStart; VolumeType::Enum Type; }; class VolumeHeader { public: VolumeHeader (uint32 HeaderSize); virtual ~VolumeHeader (); void Create (const BufferPtr &headerBuffer, VolumeHeaderCreationOptions &options); bool Decrypt (const ConstBufferPtr &encryptedData, const VolumePassword &password, int pim, shared_ptr <Pkcs5Kdf> kdf, const Pkcs5KdfList &keyDerivationFunctions, const EncryptionAlgorithmList &encryptionAlgorithms, const EncryptionModeList &encryptionModes); void EncryptNew (const BufferPtr &newHeaderBuffer, const ConstBufferPtr &newSalt, const ConstBufferPtr &newHeaderKey, shared_ptr <Pkcs5Kdf> newPkcs5Kdf); uint64 GetEncryptedAreaStart () const { return EncryptedAreaStart; } uint64 GetEncryptedAreaLength () const { return EncryptedAreaLength; } shared_ptr <EncryptionAlgorithm> GetEncryptionAlgorithm () const { return EA; } uint32 GetFlags () const { return Flags; } VolumeTime GetHeaderCreationTime () const { return HeaderCreationTime; } uint64 GetHiddenVolumeDataSize () const { return HiddenVolumeDataSize; } static size_t GetLargestSerializedKeySize (); shared_ptr <Pkcs5Kdf> GetPkcs5Kdf () const { return Pkcs5; } uint16 GetRequiredMinProgramVersion () const { return RequiredMinProgramVersion; } size_t GetSectorSize () const { return SectorSize; } static uint32 GetSaltSize () { return SaltSize; } uint64 GetVolumeDataSize () const { return VolumeDataSize; } VolumeTime GetVolumeCreationTime () const { return VolumeCreationTime; } void SetSize (uint32 headerSize); + bool IsMasterKeyVulnerable () const { return XtsKeyVulnerable; } protected: bool Deserialize (const ConstBufferPtr &header, shared_ptr <EncryptionAlgorithm> &ea, shared_ptr <EncryptionMode> &mode); template <typename T> T DeserializeEntry (const ConstBufferPtr &header, size_t &offset) const; template <typename T> T DeserializeEntryAt (const ConstBufferPtr &header, const size_t &offset) const; void Init (); void Serialize (const BufferPtr &header) const; template <typename T> void SerializeEntry (const T &entry, const BufferPtr &header, size_t &offset) const; uint32 HeaderSize; static const uint16 CurrentHeaderVersion = VOLUME_HEADER_VERSION; static const uint16 CurrentRequiredMinProgramVersion = TC_VOLUME_MIN_REQUIRED_PROGRAM_VERSION; static const uint16 MinAllowedHeaderVersion = 1; static const int SaltOffset = 0; static const uint32 SaltSize = 64; static const int EncryptedHeaderDataOffset = SaltOffset + SaltSize; uint32 EncryptedHeaderDataSize; static const uint32 LegacyEncryptionModeKeyAreaSize = 32; static const int DataKeyAreaMaxSize = 256; static const uint32 DataAreaKeyOffset = DataKeyAreaMaxSize - EncryptedHeaderDataOffset; shared_ptr <EncryptionAlgorithm> EA; shared_ptr <Pkcs5Kdf> Pkcs5; uint16 HeaderVersion; uint16 RequiredMinProgramVersion; uint32 VolumeKeyAreaCrc32; VolumeTime VolumeCreationTime; VolumeTime HeaderCreationTime; VolumeType::Enum mVolumeType; uint64 HiddenVolumeDataSize; uint64 VolumeDataSize; uint64 EncryptedAreaStart; uint64 EncryptedAreaLength; uint32 Flags; uint32 SectorSize; SecureBuffer DataAreaKey; + bool XtsKeyVulnerable; private: VolumeHeader (const VolumeHeader &); VolumeHeader &operator= (const VolumeHeader &); }; } #endif // TC_HEADER_Volume_VolumeHeader diff --git a/src/Volume/VolumeInfo.cpp b/src/Volume/VolumeInfo.cpp index 699e203f..f3b044b7 100644 --- a/src/Volume/VolumeInfo.cpp +++ b/src/Volume/VolumeInfo.cpp @@ -28,98 +28,101 @@ namespace VeraCrypt EncryptionAlgorithmName = sr.DeserializeWString ("EncryptionAlgorithmName"); EncryptionModeName = sr.DeserializeWString ("EncryptionModeName"); sr.Deserialize ("HeaderCreationTime", HeaderCreationTime); sr.Deserialize ("HiddenVolumeProtectionTriggered", HiddenVolumeProtectionTriggered); LoopDevice = sr.DeserializeWString ("LoopDevice"); if (ProgramVersion >= 0x10b) sr.Deserialize ("MinRequiredProgramVersion", MinRequiredProgramVersion); MountPoint = sr.DeserializeWString ("MountPoint"); Path = sr.DeserializeWString ("Path"); sr.Deserialize ("Pkcs5IterationCount", Pkcs5IterationCount); Pkcs5PrfName = sr.DeserializeWString ("Pkcs5PrfName"); Protection = static_cast <VolumeProtection::Enum> (sr.DeserializeInt32 ("Protection")); sr.Deserialize ("SerialInstanceNumber", SerialInstanceNumber); sr.Deserialize ("Size", Size); sr.Deserialize ("SlotNumber", SlotNumber); if (ProgramVersion >= 0x10b) sr.Deserialize ("SystemEncryption", SystemEncryption); if (ProgramVersion >= 0x10b) sr.Deserialize ("TopWriteOffset", TopWriteOffset); sr.Deserialize ("TotalDataRead", TotalDataRead); sr.Deserialize ("TotalDataWritten", TotalDataWritten); Type = static_cast <VolumeType::Enum> (sr.DeserializeInt32 ("Type")); VirtualDevice = sr.DeserializeWString ("VirtualDevice"); sr.Deserialize ("VolumeCreationTime", VolumeCreationTime); sr.Deserialize ("Pim", Pim); + sr.Deserialize ("MasterKeyVulnerable", MasterKeyVulnerable); } bool VolumeInfo::FirstVolumeMountedAfterSecond (shared_ptr <VolumeInfo> first, shared_ptr <VolumeInfo> second) { return first->SerialInstanceNumber > second->SerialInstanceNumber; } void VolumeInfo::Serialize (shared_ptr <Stream> stream) const { Serializable::Serialize (stream); Serializer sr (stream); const uint32 version = VERSION_NUM; sr.Serialize ("ProgramVersion", version); sr.Serialize ("AuxMountPoint", wstring (AuxMountPoint)); sr.Serialize ("EncryptionAlgorithmBlockSize", EncryptionAlgorithmBlockSize); sr.Serialize ("EncryptionAlgorithmKeySize", EncryptionAlgorithmKeySize); sr.Serialize ("EncryptionAlgorithmMinBlockSize", EncryptionAlgorithmMinBlockSize); sr.Serialize ("EncryptionAlgorithmName", EncryptionAlgorithmName); sr.Serialize ("EncryptionModeName", EncryptionModeName); sr.Serialize ("HeaderCreationTime", HeaderCreationTime); sr.Serialize ("HiddenVolumeProtectionTriggered", HiddenVolumeProtectionTriggered); sr.Serialize ("LoopDevice", wstring (LoopDevice)); sr.Serialize ("MinRequiredProgramVersion", MinRequiredProgramVersion); sr.Serialize ("MountPoint", wstring (MountPoint)); sr.Serialize ("Path", wstring (Path)); sr.Serialize ("Pkcs5IterationCount", Pkcs5IterationCount); sr.Serialize ("Pkcs5PrfName", Pkcs5PrfName); sr.Serialize ("Protection", static_cast <uint32> (Protection)); sr.Serialize ("SerialInstanceNumber", SerialInstanceNumber); sr.Serialize ("Size", Size); sr.Serialize ("SlotNumber", SlotNumber); sr.Serialize ("SystemEncryption", SystemEncryption); sr.Serialize ("TopWriteOffset", TopWriteOffset); sr.Serialize ("TotalDataRead", TotalDataRead); sr.Serialize ("TotalDataWritten", TotalDataWritten); sr.Serialize ("Type", static_cast <uint32> (Type)); sr.Serialize ("VirtualDevice", wstring (VirtualDevice)); sr.Serialize ("VolumeCreationTime", VolumeCreationTime); sr.Serialize ("Pim", Pim); + sr.Serialize ("MasterKeyVulnerable", MasterKeyVulnerable); } void VolumeInfo::Set (const Volume &volume) { EncryptionAlgorithmBlockSize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetMaxBlockSize()); EncryptionAlgorithmKeySize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetKeySize()); EncryptionAlgorithmMinBlockSize = static_cast <uint32> (volume.GetEncryptionAlgorithm()->GetMinBlockSize()); EncryptionAlgorithmName = volume.GetEncryptionAlgorithm()->GetName(); EncryptionModeName = volume.GetEncryptionMode()->GetName(); HeaderCreationTime = volume.GetHeaderCreationTime(); VolumeCreationTime = volume.GetVolumeCreationTime(); HiddenVolumeProtectionTriggered = volume.IsHiddenVolumeProtectionTriggered(); MinRequiredProgramVersion = volume.GetHeader()->GetRequiredMinProgramVersion(); Path = volume.GetPath(); Pkcs5IterationCount = volume.GetPkcs5Kdf()->GetIterationCount(volume.GetPim ()); Pkcs5PrfName = volume.GetPkcs5Kdf()->GetName(); Protection = volume.GetProtectionType(); Size = volume.GetSize(); SystemEncryption = volume.IsInSystemEncryptionScope(); Type = volume.GetType(); TopWriteOffset = volume.GetTopWriteOffset(); TotalDataRead = volume.GetTotalDataRead(); TotalDataWritten = volume.GetTotalDataWritten(); Pim = volume.GetPim (); + MasterKeyVulnerable = volume.IsMasterKeyVulnerable(); } TC_SERIALIZER_FACTORY_ADD_CLASS (VolumeInfo); } diff --git a/src/Volume/VolumeInfo.h b/src/Volume/VolumeInfo.h index 1adc87e3..ad6c2ca4 100644 --- a/src/Volume/VolumeInfo.h +++ b/src/Volume/VolumeInfo.h @@ -34,38 +34,38 @@ namespace VeraCrypt void Set (const Volume &volume); // Modifying this structure can introduce incompatibility with previous versions DirectoryPath AuxMountPoint; uint32 EncryptionAlgorithmBlockSize; uint32 EncryptionAlgorithmKeySize; uint32 EncryptionAlgorithmMinBlockSize; wstring EncryptionAlgorithmName; wstring EncryptionModeName; VolumeTime HeaderCreationTime; bool HiddenVolumeProtectionTriggered; DevicePath LoopDevice; uint32 MinRequiredProgramVersion; DirectoryPath MountPoint; VolumePath Path; uint32 Pkcs5IterationCount; wstring Pkcs5PrfName; uint32 ProgramVersion; VolumeProtection::Enum Protection; uint64 SerialInstanceNumber; uint64 Size; VolumeSlotNumber SlotNumber; bool SystemEncryption; uint64 TopWriteOffset; uint64 TotalDataRead; uint64 TotalDataWritten; VolumeType::Enum Type; DevicePath VirtualDevice; VolumeTime VolumeCreationTime; int Pim; - + bool MasterKeyVulnerable; private: VolumeInfo (const VolumeInfo &); VolumeInfo &operator= (const VolumeInfo &); }; } #endif // TC_HEADER_Volume_VolumeInfo diff --git a/src/Volume/VolumeLayout.cpp b/src/Volume/VolumeLayout.cpp index efb77649..3600d76f 100644 --- a/src/Volume/VolumeLayout.cpp +++ b/src/Volume/VolumeLayout.cpp @@ -1,235 +1,257 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #include "Volume/EncryptionMode.h" #include "Volume/EncryptionModeXTS.h" +#ifdef WOLFCRYPT_BACKEND +#include "Volume/EncryptionModeWolfCryptXTS.h" +#endif #include "VolumeLayout.h" #include "Boot/Windows/BootCommon.h" namespace VeraCrypt { VolumeLayout::VolumeLayout () { } VolumeLayout::~VolumeLayout () { } VolumeLayoutList VolumeLayout::GetAvailableLayouts (VolumeType::Enum type) { VolumeLayoutList layouts; layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Normal ())); layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV1Normal ())); layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutV2Hidden ())); layouts.push_back (shared_ptr <VolumeLayout> (new VolumeLayoutSystemEncryption ())); if (type != VolumeType::Unknown) { VolumeLayoutList l; foreach (shared_ptr <VolumeLayout> vl, layouts) { if (vl->GetType() == type) l.push_back (vl); } layouts = l; } return layouts; } shared_ptr <VolumeHeader> VolumeLayout::GetHeader () { if (Header.get() == nullptr) Header.reset (new VolumeHeader (GetHeaderSize())); return Header; } VolumeLayoutV1Normal::VolumeLayoutV1Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE_LEGACY; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + #else + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #endif } uint64 VolumeLayoutV1Normal::GetDataOffset (uint64 volumeHostSize) const { return HeaderSize; } uint64 VolumeLayoutV1Normal::GetDataSize (uint64 volumeHostSize) const { return volumeHostSize - GetHeaderSize(); } VolumeLayoutV2Normal::VolumeLayoutV2Normal () { Type = VolumeType::Normal; HeaderOffset = TC_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE; BackupHeaderOffset = -TC_VOLUME_HEADER_GROUP_SIZE; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaKuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikSerpentCamellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - } + #else + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #endif + + } uint64 VolumeLayoutV2Normal::GetDataOffset (uint64 volumeHostSize) const { return Header->GetEncryptedAreaStart(); } uint64 VolumeLayoutV2Normal::GetDataSize (uint64 volumeHostSize) const { return Header->GetVolumeDataSize(); } uint64 VolumeLayoutV2Normal::GetMaxDataSize (uint64 volumeSize) const { if (volumeSize < TC_TOTAL_VOLUME_HEADERS_SIZE) return 0; return volumeSize - TC_TOTAL_VOLUME_HEADERS_SIZE; } VolumeLayoutV2Hidden::VolumeLayoutV2Hidden () { Type = VolumeType::Hidden; HeaderOffset = TC_HIDDEN_VOLUME_HEADER_OFFSET; HeaderSize = TC_VOLUME_HEADER_SIZE; BackupHeaderOffset = -TC_HIDDEN_VOLUME_HEADER_OFFSET; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaKuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikSerpentCamellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + #else + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #endif } uint64 VolumeLayoutV2Hidden::GetDataOffset (uint64 volumeHostSize) const { return Header->GetEncryptedAreaStart(); } uint64 VolumeLayoutV2Hidden::GetDataSize (uint64 volumeHostSize) const { return Header->GetVolumeDataSize(); } uint64 VolumeLayoutV2Hidden::GetMaxDataSize (uint64 volumeSize) const { // Reserve free space at the end of the host filesystem uint64 reservedSize; if (volumeSize < TC_VOLUME_SMALL_SIZE_THRESHOLD) reservedSize = TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE; else reservedSize = TC_HIDDEN_VOLUME_HOST_FS_RESERVED_END_AREA_SIZE_HIGH; // Ensure size of a hidden volume larger than TC_VOLUME_SMALL_SIZE_THRESHOLD is a multiple of the maximum supported sector size if (volumeSize < reservedSize) return 0; return volumeSize - reservedSize; } VolumeLayoutSystemEncryption::VolumeLayoutSystemEncryption () { Type = VolumeType::Normal; HeaderOffset = TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET; HeaderSize = TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE; SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AES ())); + #ifndef WOLFCRYPT_BACKEND SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Serpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Twofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Camellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new Kuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new AESTwofishSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaKuznyechik ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new CamelliaSerpent ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikSerpentCamellia ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new KuznyechikTwofish ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new SerpentTwofishAES ())); SupportedEncryptionAlgorithms.push_back (shared_ptr <EncryptionAlgorithm> (new TwofishSerpent ())); - - SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); - } + + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeXTS ())); + #else + SupportedEncryptionModes.push_back (shared_ptr <EncryptionMode> (new EncryptionModeWolfCryptXTS ())); + #endif + + } uint64 VolumeLayoutSystemEncryption::GetDataOffset (uint64 volumeHostSize) const { return 0; } uint64 VolumeLayoutSystemEncryption::GetDataSize (uint64 volumeHostSize) const { return volumeHostSize; } Pkcs5KdfList VolumeLayoutSystemEncryption::GetSupportedKeyDerivationFunctions () const { Pkcs5KdfList l; l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha256_Boot ())); - l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s_Boot ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacSha512 ())); + #ifndef WOLFCRYPT_BACKEND + l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacBlake2s_Boot ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacWhirlpool ())); l.push_back (shared_ptr <Pkcs5Kdf> (new Pkcs5HmacStreebog ())); - return l; + #endif + return l; } } diff --git a/src/Volume/VolumePassword.cpp b/src/Volume/VolumePassword.cpp index a22c9388..9ba3ebce 100644 --- a/src/Volume/VolumePassword.cpp +++ b/src/Volume/VolumePassword.cpp @@ -33,57 +33,57 @@ namespace VeraCrypt { if (!PasswordBuffer.IsAllocated ()) PasswordBuffer.Allocate (MaxSize); } void VolumePassword::Deserialize (shared_ptr <Stream> stream) { Serializer sr (stream); uint64 passwordSize; sr.Deserialize ("PasswordSize", passwordSize); PasswordSize = static_cast <size_t> (passwordSize); sr.Deserialize ("PasswordBuffer", BufferPtr (PasswordBuffer)); Buffer wipeBuffer (128 * 1024); sr.Deserialize ("WipeData", wipeBuffer); } void VolumePassword::Serialize (shared_ptr <Stream> stream) const { Serializable::Serialize (stream); Serializer sr (stream); sr.Serialize ("PasswordSize", static_cast <uint64> (PasswordSize)); sr.Serialize ("PasswordBuffer", ConstBufferPtr (PasswordBuffer)); // Wipe password from an eventual pipe buffer Buffer wipeBuffer (128 * 1024); wipeBuffer.Zero(); sr.Serialize ("WipeData", ConstBufferPtr (wipeBuffer)); } - void VolumePassword::Set (const byte *password, size_t size) + void VolumePassword::Set (const uint8 *password, size_t size) { AllocateBuffer (); if (size > MaxSize) throw PasswordTooLong (SRC_POS); PasswordBuffer.Erase (); if (size > 0) PasswordBuffer.CopyFrom (ConstBufferPtr (password, size)); PasswordSize = size; } void VolumePassword::Set (const VolumePassword &password) { Set (password.DataPtr(), password.Size()); } TC_SERIALIZER_FACTORY_ADD_CLASS (VolumePassword); #define TC_EXCEPTION(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) #undef TC_EXCEPTION_NODECL #define TC_EXCEPTION_NODECL(TYPE) TC_SERIALIZER_FACTORY_ADD(TYPE) TC_SERIALIZER_FACTORY_ADD_EXCEPTION_SET (PasswordException); } diff --git a/src/Volume/VolumePassword.h b/src/Volume/VolumePassword.h index f4a3ccbe..c1e6b9b6 100644 --- a/src/Volume/VolumePassword.h +++ b/src/Volume/VolumePassword.h @@ -1,69 +1,69 @@ /* Derived from source code of TrueCrypt 7.1a, which is 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) and all other portions of this file are Copyright (c) 2013-2017 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. */ #ifndef TC_HEADER_Encryption_Password #define TC_HEADER_Encryption_Password #include "Platform/Platform.h" #include "Platform/Serializable.h" namespace VeraCrypt { class VolumePassword : public Serializable { public: VolumePassword (); - VolumePassword (const byte *password, size_t size) { Set (password, size); } + VolumePassword (const uint8 *password, size_t size) { Set (password, size); } VolumePassword (const SecureBuffer &password) { Set (password.Ptr (), password.Size ()); } VolumePassword (const VolumePassword &password) { Set (password); } virtual ~VolumePassword (); bool operator== (const VolumePassword &other) const { return ConstBufferPtr (DataPtr(), Size()).IsDataEqual (ConstBufferPtr (other.DataPtr(), other.Size())); } bool operator!= (const VolumePassword &other) const { return !(*this == other); } VolumePassword &operator= (const VolumePassword &password) { Set (password); return *this; } operator BufferPtr () const { return BufferPtr (PasswordBuffer); } - byte *DataPtr () const { return PasswordBuffer; } + uint8 *DataPtr () const { return PasswordBuffer; } bool IsEmpty () const { return PasswordSize == 0; } size_t Size () const { return PasswordSize; } - void Set (const byte *password, size_t size); + void Set (const uint8 *password, size_t size); void Set (const VolumePassword &password); TC_SERIALIZABLE (VolumePassword); static const size_t MaxLegacySize; static const size_t MaxSize; static const size_t WarningSizeThreshold; protected: void AllocateBuffer (); SecureBuffer PasswordBuffer; size_t PasswordSize; }; struct PasswordException : public Exception { protected: PasswordException () { } PasswordException (const string &message) : Exception (message) { } PasswordException (const string &message, const wstring &subject) : Exception (message, subject) { } }; TC_EXCEPTION_DECL (PasswordIncorrect, PasswordException); TC_EXCEPTION_DECL (PasswordKeyfilesIncorrect, PasswordIncorrect); TC_EXCEPTION_DECL (PasswordOrKeyboardLayoutIncorrect, PasswordException); TC_EXCEPTION_DECL (PasswordOrMountOptionsIncorrect, PasswordException); TC_EXCEPTION_DECL (ProtectionPasswordIncorrect, PasswordIncorrect); TC_EXCEPTION_DECL (ProtectionPasswordKeyfilesIncorrect, PasswordIncorrect); |