diff options
Diffstat (limited to 'src/Common')
37 files changed, 1005 insertions, 1738 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h index 04d69c05..955286da 100644 --- a/src/Common/Apidrvr.h +++ b/src/Common/Apidrvr.h @@ -396,6 +396,7 @@ typedef struct int EncryptionIoRequestCount; int EncryptionItemCount; int EncryptionFragmentSize; + int EncryptionMaxWorkItems; } EncryptionQueueParameters; #pragma pack (pop) @@ -418,6 +419,7 @@ typedef struct #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_ENCRYPTION_MAX_WORK_ITEMS DRIVER_STR("VeraCryptEncryptionMaxWorkItems") #define VC_ERASE_KEYS_SHUTDOWN DRIVER_STR("VeraCryptEraseKeysShutdown") diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp index c9b275dc..e6e36f12 100644 --- a/src/Common/BootEncryption.cpp +++ b/src/Common/BootEncryption.cpp @@ -773,11 +773,13 @@ namespace VeraCrypt else { LastError = GetLastError(); +#ifndef SETUP if (LastError == ERROR_ACCESS_DENIED && IsUacSupported()) { Elevated = true; FileOpen = true; } +#endif } FilePointerPosition = 0; @@ -806,12 +808,14 @@ namespace VeraCrypt throw SystemException (SRC_POS); } +#ifndef SETUP if (Elevated) { Elevator::ReadWriteFile (false, IsDevice, Path, buffer, FilePointerPosition, size, &bytesRead); FilePointerPosition += bytesRead; return bytesRead; } +#endif if (!ReadFile (Handle, buffer, size, &bytesRead, NULL)) { @@ -913,6 +917,7 @@ namespace VeraCrypt try { +#ifndef SETUP if (Elevated) { Elevator::ReadWriteFile (true, IsDevice, Path, buffer, FilePointerPosition, size, &bytesWritten); @@ -920,6 +925,7 @@ namespace VeraCrypt throw_sys_if (bytesWritten != size); } else +#endif { if (!WriteFile (Handle, buffer, size, &bytesWritten, NULL)) { @@ -1046,11 +1052,13 @@ namespace VeraCrypt else { LastError = GetLastError (); +#ifndef SETUP if (LastError == ERROR_ACCESS_DENIED && IsUacSupported()) { Elevated = true; FileOpen = true; } +#endif } FilePointerPosition = 0; @@ -1141,7 +1149,7 @@ namespace VeraCrypt // 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) + for (const Partition& partition : config.Partitions) { if (partition.Info.BootIndicator) { @@ -1154,13 +1162,13 @@ namespace VeraCrypt Partition bootPartition = partition; Partition partitionBehindBoot; - foreach (const Partition &partition, config.Partitions) + for (const Partition &otherPartition : config.Partitions) { - if (partition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart - && partition.Info.StartingOffset.QuadPart < minOffsetFound) + if (otherPartition.Info.StartingOffset.QuadPart > bootPartition.Info.StartingOffset.QuadPart + && otherPartition.Info.StartingOffset.QuadPart < minOffsetFound) { - minOffsetFound = partition.Info.StartingOffset.QuadPart; - partitionBehindBoot = partition; + minOffsetFound = otherPartition.Info.StartingOffset.QuadPart; + partitionBehindBoot = otherPartition; } } @@ -1351,11 +1359,11 @@ namespace VeraCrypt part.IsGPT = diskPartInfo.IsGPT; // Mount point - int driveNumber = GetDiskDeviceDriveLetter ((wchar_t *) partPath.str().c_str()); + int driveLetter = GetDiskDeviceDriveLetter ((wchar_t *) partPath.str().c_str()); - if (driveNumber >= 0) + if (driveLetter >= 0) { - part.MountPoint += (wchar_t) (driveNumber + L'A'); + part.MountPoint += (wchar_t) (driveLetter + L'A'); part.MountPoint += L":"; } @@ -2441,7 +2449,8 @@ namespace VeraCrypt if (!fieldValue.empty() && strlen (fieldValue.c_str())) { string copieValue = fieldValue; - std::transform(copieValue.begin(), copieValue.end(), copieValue.begin(), ::tolower); + std::transform(copieValue.begin(), copieValue.end(), copieValue.begin(), + [](unsigned char c) { return static_cast<char>(std::tolower(c)); }); if (strstr (copieValue.c_str(), "postexec") && strstr (copieValue.c_str(), "file(")) { @@ -2636,7 +2645,7 @@ namespace VeraCrypt 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) { @@ -2651,16 +2660,9 @@ namespace VeraCrypt } // Check EFI if (!IsEfiBoot()) { - dwLastError = GetLastError(); - if (dwLastError != ERROR_SUCCESS) - { - if (!bPrivilegesSet) - SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); - // format message to append the error code to the exception message - wchar_t szMsg[128]; - StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to detect EFI environment (error code 0x%.8X)", dwLastError); - throw ErrorException(szMsg, 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); @@ -2720,16 +2722,9 @@ namespace VeraCrypt } // Check EFI if (!IsEfiBoot()) { - dwLastError = GetLastError(); - if (dwLastError != ERROR_SUCCESS) - { - if (!bPrivilegesSet) - SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE); - // format message to append the error code to the exception message - wchar_t szMsg[1024]; - StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to detect EFI environment (error code 0x%.8X)", dwLastError); - throw ErrorException(szMsg, 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) @@ -3337,53 +3332,29 @@ namespace VeraCrypt } } DWORD sizeDcsBoot; -#ifdef _WIN64 uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); -#else - 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 uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); -#else - 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 uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); -#else - 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 uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); -#else - 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 uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); -#else - 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 uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); -#else - 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); @@ -3395,8 +3366,8 @@ namespace VeraCrypt 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"; + const wchar_t * szStdEfiBootloader = L"\\EFI\\Boot\\bootx64.efi"; + const wchar_t * szBackupEfiBootloader = L"\\EFI\\Boot\\original_bootx64.vc_backup"; if (preserveUserConfig) { @@ -3552,10 +3523,7 @@ namespace VeraCrypt // 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); + EfiBootInst.RenameFile (L"\\EFI\\Boot\\original_bootx64_vc_backup.efi", L"\\EFI\\Boot\\original_bootx64.vc_backup", FALSE); // Clean beta9 EfiBootInst.DelFile(L"\\DcsBoot.efi"); @@ -3734,61 +3702,33 @@ namespace VeraCrypt { // create EFI disk structure DWORD sizeDcsBoot; -#ifdef _WIN64 uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot); -#else - uint8 *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot); -#endif if (!dcsBootImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsInt; -#ifdef _WIN64 uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt); -#else - uint8 *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt); -#endif if (!dcsIntImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsCfg; -#ifdef _WIN64 uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg); -#else - uint8 *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg); -#endif if (!dcsCfgImg) throw ParameterIncorrect (SRC_POS); DWORD sizeLegacySpeaker; -#ifdef _WIN64 uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker); -#else - 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 uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker); -#else - 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 uint8 *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue); -#else - uint8 *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue); -#endif if (!DcsRescueImg) throw ParameterIncorrect (SRC_POS); DWORD sizeDcsInfo; -#ifdef _WIN64 uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo); -#else - uint8 *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo); -#endif if (!DcsInfoImg) throw ParameterIncorrect (SRC_POS); @@ -3814,7 +3754,7 @@ namespace VeraCrypt 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)) + if (!ZipAdd (z, "EFI/Boot/bootx64.efi", DcsRescueImg, sizeDcsRescue)) throw ParameterIncorrect (SRC_POS); #ifdef VC_EFI_CUSTOM_MODE if (!ZipAdd (z, "EFI/VeraCrypt/DcsBml.dcs", BootMenuLockerImg, sizeBootMenuLocker)) @@ -3863,7 +3803,7 @@ namespace VeraCrypt sysBakFile.GetFileSize(fileSize); fileBuf.Resize ((DWORD) fileSize); DWORD sizeLoader = sysBakFile.Read (fileBuf.Ptr (), fileSize); - bLoadAdded = ZipAdd (z, Is64BitOs()? "EFI/Boot/original_bootx64.vc_backup": "EFI/Boot/original_bootia32.vc_backup", fileBuf.Ptr (), sizeLoader); + bLoadAdded = ZipAdd (z, "EFI/Boot/original_bootx64.vc_backup", fileBuf.Ptr (), sizeLoader); } catch (Exception &e) { @@ -4090,19 +4030,6 @@ namespace VeraCrypt L"EFI/VeraCrypt/svh_bak", L"EFI/Boot/original_bootx64.vc_backup" }; - - const wchar_t* efi32Files[] = { - L"EFI/Boot/bootia32.efi", -#ifdef VC_EFI_CUSTOM_MODE - L"EFI/VeraCrypt/DcsBml.dcs", -#endif - L"EFI/VeraCrypt/DcsBoot.efi", - L"EFI/VeraCrypt/DcsCfg.dcs", - L"EFI/VeraCrypt/DcsInt.dcs", - L"EFI/VeraCrypt/LegacySpeaker.dcs", - L"EFI/VeraCrypt/svh_bak", - L"EFI/Boot/original_bootia32.vc_backup" - }; zip_error_t zerr; zip_source_t* zsrc = zip_source_buffer_create (RescueZipData, RescueZipSize, 0, &zerr); @@ -4131,8 +4058,8 @@ namespace VeraCrypt && !wcsncmp (szNameBuffer, L"FAT", 3)) { int i; - const wchar_t** efiFiles = Is64BitOs()? efi64Files: efi32Files; - int efiFilesSize = Is64BitOs()? ARRAYSIZE(efi64Files): ARRAYSIZE(efi32Files); + const wchar_t** efiFiles = efi64Files; + int efiFilesSize = ARRAYSIZE(efi64Files); for (i = 0; i < efiFilesSize; i++) { bool bMatch = false; @@ -4285,25 +4212,12 @@ namespace VeraCrypt L"EFI/VeraCrypt/svh_bak", L"EFI/Boot/original_bootx64.vc_backup" }; - - const wchar_t* efi32Files[] = { - L"EFI/Boot/bootia32.efi", -#ifdef VC_EFI_CUSTOM_MODE - L"EFI/VeraCrypt/DcsBml.dcs", -#endif - L"EFI/VeraCrypt/DcsBoot.efi", - L"EFI/VeraCrypt/DcsCfg.dcs", - L"EFI/VeraCrypt/DcsInt.dcs", - L"EFI/VeraCrypt/LegacySpeaker.dcs", - L"EFI/VeraCrypt/svh_bak", - L"EFI/Boot/original_bootia32.vc_backup" - }; int i; zip_stat_t statMem, statFile; zip_int64_t indexMem, indexFile; - const wchar_t** efiFiles = Is64BitOs()? efi64Files: efi32Files; - int efiFilesSize = Is64BitOs()? ARRAYSIZE(efi64Files): ARRAYSIZE(efi32Files); + const wchar_t** efiFiles = efi64Files; + int efiFilesSize = ARRAYSIZE(efi64Files); for (i = 0; i < efiFilesSize; i++) { bool bMatch = false; @@ -4396,14 +4310,14 @@ namespace VeraCrypt if (!IsRandomNumberGeneratorStarted()) throw ParameterIncorrect (SRC_POS); - throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, pim, NULL, &cryptoInfo, + throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, 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)) + if (0 != ReadVolumeHeader (TRUE, RescueVolumeHeader, password, pkcs5, pim, NULL, cryptoInfo)) throw ParameterIncorrect (SRC_POS); DecryptBuffer (RescueVolumeHeader + HEADER_ENCRYPTED_DATA_OFFSET, HEADER_ENCRYPTED_DATA_SIZE, cryptoInfo); @@ -4578,10 +4492,7 @@ namespace VeraCrypt 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); + EfiBootInst.RenameFile(L"\\EFI\\Boot\\original_bootx64.vc_backup", L"\\EFI\\Boot\\bootx64.efi", TRUE); if (!EfiBootInst.RenameFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc", L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", TRUE)) { @@ -5405,7 +5316,7 @@ namespace VeraCrypt SystemDriveConfiguration config = GetSystemDriveConfiguration (); - char header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; + unsigned char header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE]; Device device (config.DevicePath); device.CheckOpened (SRC_POS); @@ -5435,7 +5346,7 @@ namespace VeraCrypt } device.SeekAt (headerOffset); - device.Read ((uint8 *) header, sizeof (header)); + device.Read (header, sizeof (header)); PCRYPTO_INFO cryptoInfo = NULL; diff --git a/src/Common/Cache.c b/src/Common/Cache.c index 46249b9c..60b2f04a 100644 --- a/src/Common/Cache.c +++ b/src/Common/Cache.c @@ -24,8 +24,6 @@ int CachedPim[CACHE_SIZE]; int cacheEmpty = 1; static int nPasswordIdx = 0; -#ifdef _WIN64 - uint64 VcGetPasswordEncryptionID (Password* pPassword) { return ((uint64) pPassword->Text) + ((uint64) pPassword); @@ -41,9 +39,7 @@ void VcUnprotectPassword (Password* pPassword, uint64 encID) VcProtectPassword (pPassword, encID); } -#endif - -int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *header, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo) +int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, unsigned char *header, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo) { int nReturnCode = ERR_PASSWORD_WRONG; int i, effectivePim; @@ -56,37 +52,29 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade /* Save mount passwords back into cache if asked to do so */ if (bCache && (nReturnCode == 0 || nReturnCode == ERR_CIPHER_INIT_WEAK_KEY)) { -#ifdef _WIN64 Password tmpPass; -#endif for (i = 0; i < CACHE_SIZE; i++) { Password* pCurrentPassword = &CachedPasswords[i]; -#ifdef _WIN64 if (IsRamEncryptionEnabled()) { memcpy (&tmpPass, pCurrentPassword, sizeof (Password)); VcUnprotectPassword (&tmpPass, VcGetPasswordEncryptionID (pCurrentPassword)); pCurrentPassword = &tmpPass; } -#endif if (memcmp (pCurrentPassword, password, sizeof (Password)) == 0) break; } -#ifdef _WIN64 if (IsRamEncryptionEnabled()) burn (&tmpPass, sizeof (Password)); -#endif if (i == CACHE_SIZE) { /* Store the password */ CachedPasswords[nPasswordIdx] = *password; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectPassword (&CachedPasswords[nPasswordIdx], VcGetPasswordEncryptionID (&CachedPasswords[nPasswordIdx])); -#endif /* Store also PIM if requested, otherwise set to default */ if (bCachePim && (pim > 0)) @@ -107,21 +95,18 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade } else if (!cacheEmpty) { -#ifdef _WIN64 Password tmpPass; -#endif /* Attempt to recognize volume using cached passwords */ for (i = 0; i < CACHE_SIZE; i++) { Password* pCurrentPassword = &CachedPasswords[i]; -#ifdef _WIN64 if (IsRamEncryptionEnabled()) { memcpy (&tmpPass, pCurrentPassword, sizeof (Password)); VcUnprotectPassword (&tmpPass, VcGetPasswordEncryptionID (pCurrentPassword)); pCurrentPassword = &tmpPass; } -#endif + if ((pCurrentPassword->Length > 0) && (pCurrentPassword->Length <= (unsigned int) ((bBoot? MAX_LEGACY_PASSWORD: MAX_PASSWORD)))) { if (pim == -1) @@ -134,10 +119,10 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade break; } } -#ifdef _WIN64 + if (IsRamEncryptionEnabled()) burn (&tmpPass, sizeof (Password)); -#endif + } return nReturnCode; @@ -146,21 +131,18 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade void AddPasswordToCache (Password *password, int pim, BOOL bCachePim) { -#ifdef _WIN64 Password tmpPass; -#endif int i; for (i = 0; i < CACHE_SIZE; i++) { Password* pCurrentPassword = &CachedPasswords[i]; -#ifdef _WIN64 if (IsRamEncryptionEnabled()) { memcpy (&tmpPass, pCurrentPassword, sizeof (Password)); VcUnprotectPassword (&tmpPass, VcGetPasswordEncryptionID (pCurrentPassword)); pCurrentPassword = &tmpPass; } -#endif + if (memcmp (pCurrentPassword, password, sizeof (Password)) == 0) break; } @@ -168,10 +150,9 @@ void AddPasswordToCache (Password *password, int pim, BOOL bCachePim) if (i == CACHE_SIZE) { CachedPasswords[nPasswordIdx] = *password; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectPassword (&CachedPasswords[nPasswordIdx], VcGetPasswordEncryptionID (&CachedPasswords[nPasswordIdx])); -#endif + /* Store also PIM if requested, otherwise set to default */ if (bCachePim && (pim > 0)) CachedPim[nPasswordIdx] = pim; @@ -184,13 +165,12 @@ void AddPasswordToCache (Password *password, int pim, BOOL bCachePim) { CachedPim[i] = pim > 0? pim : 0; } -#ifdef _WIN64 + if (IsRamEncryptionEnabled()) burn (&tmpPass, sizeof (Password)); -#endif } -void AddLegacyPasswordToCache (PasswordLegacy *password, int pim) +void AddLegacyPasswordToCache (__unaligned PasswordLegacy *password, int pim) { Password inputPass = {0}; inputPass.Length = password->Length; diff --git a/src/Common/Cache.h b/src/Common/Cache.h index 0988bf29..cfab6f4f 100644 --- a/src/Common/Cache.h +++ b/src/Common/Cache.h @@ -21,6 +21,6 @@ extern int cacheEmpty; void AddPasswordToCache (Password *password, int pim, BOOL bCachePim); -void AddLegacyPasswordToCache (PasswordLegacy *password, int pim); -int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim,char *header, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo); +void AddLegacyPasswordToCache (__unaligned PasswordLegacy *password, int pim); +int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, unsigned char *header, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo); void WipeCache (void); diff --git a/src/Common/Cmdline.c b/src/Common/Cmdline.c index f0dcf7cf..f34b3bfb 100644 --- a/src/Common/Cmdline.c +++ b/src/Common/Cmdline.c @@ -51,12 +51,7 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM *tmp = 0; - StringCchCopyW (tmp, 8192, L"VeraCrypt " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX)); -#ifdef _WIN64 - StringCchCatW (tmp, 8192, L" (64-bit)"); -#else - StringCchCatW (tmp, 8192, L" (32-bit)"); -#endif + StringCchCopyW (tmp, 8192, L"VeraCrypt " _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX) L" (64-bit)"); #if (defined(_DEBUG) || defined(DEBUG)) StringCchCatW (tmp, 8192, L" (debug)"); #endif diff --git a/src/Common/Common.rc b/src/Common/Common.rc index cbd401d8..12570e94 100644 --- a/src/Common/Common.rc +++ b/src/Common/Common.rc @@ -344,9 +344,9 @@ 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 @@ -565,17 +565,6 @@ IDR_EFI_DCSBML BIN "..\\Boot\\EFI\\DcsBml.efi" #endif IDR_EFI_DCSRE BIN "..\\Boot\\EFI\\DcsRe.efi" IDR_EFI_DCSINFO BIN "..\\Boot\\EFI\\DcsInfo.efi" -#ifndef WIN64 -IDR_EFI_DCSBOOT32 BIN "..\\Boot\\EFI\\DcsBoot32.efi" -IDR_EFI_DCSINT32 BIN "..\\Boot\\EFI\\DcsInt32.efi" -IDR_EFI_DCSCFG32 BIN "..\\Boot\\EFI\\DcsCfg32.efi" -IDR_EFI_LEGACYSPEAKER32 BIN "..\\Boot\\EFI\\LegacySpeaker32.efi" -#ifdef VC_EFI_CUSTOM_MODE -IDR_EFI_DCSBML32 BIN "..\\Boot\\EFI\\DcsBml32.efi" -#endif -IDR_EFI_DCSRE32 BIN "..\\Boot\\EFI\\DcsRe32.efi" -IDR_EFI_DCSINFO32 BIN "..\\Boot\\EFI\\DcsInfo32.efi" -#endif #endif ///////////////////////////////////////////////////////////////////////////// // diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c index 9c4ee5a3..9ae841eb 100644 --- a/src/Common/Crypto.c +++ b/src/Common/Crypto.c @@ -26,6 +26,7 @@ #else #include <strsafe.h> #endif +#include "Crypto/t1ha.h" #include "EncryptionThreadPool.h" #endif #endif @@ -192,8 +193,7 @@ 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 !defined (TC_WINDOWS_BOOT) if (IsAesHwCpuSupported()) aes_hw_cpu_encrypt (ks, data); else @@ -220,16 +220,10 @@ void EncipherBlock(int cipher, void *data, void *ks) void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) { 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) @@ -240,24 +234,15 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) 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) @@ -271,15 +256,9 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) #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 @@ -315,11 +294,9 @@ void DecipherBlock(int cipher, void *data, void *ks) #ifndef TC_WINDOWS_BOOT case AES: -#if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER) if (IsAesHwCpuSupported()) 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; @@ -335,16 +312,10 @@ void DecipherBlock(int cipher, void *data, void *ks) void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) { 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) @@ -355,24 +326,15 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) 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) @@ -386,15 +348,9 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount) #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 @@ -659,8 +615,8 @@ int EAGetNextMode (int ea, int previousModeId) return 0; } -// Returns the name of the mode of operation of the whole EA -wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters) +// Returns the name of the mode of operation +const wchar_t *EAGetModeName (int mode) { switch (mode) { @@ -669,7 +625,7 @@ wchar_t *EAGetModeName (int ea, int mode, BOOL capitalLetters) return L"XTS"; } - return L"[unknown]"; + return L"[UNKNOWN]"; } #endif // TC_WINDOWS_BOOT @@ -891,7 +847,7 @@ PCRYPTO_INFO crypto_open () } #ifndef TC_WINDOWS_BOOT -void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen) +void crypto_loadkey (PKEY_INFO keyInfo, unsigned char *lpszUserKey, int nUserKeyLen) { keyInfo->keyLength = nUserKeyLen; burn (keyInfo->userKey, sizeof (keyInfo->userKey)); @@ -1239,9 +1195,11 @@ static BOOL RamEncryptionEnabled = FALSE; BOOL IsCpuRngSupported () { +#ifndef _M_ARM64 if (HasRDSEED() || HasRDRAND()) return TRUE; else +#endif return FALSE; } @@ -1257,14 +1215,10 @@ BOOL IsCpuRngEnabled () BOOL IsRamEncryptionSupported () { -#ifdef _WIN64 if (t1ha_selfcheck__t1ha2() == 0) return TRUE; else return FALSE; -#else - return FALSE; -#endif } void EnableRamEncryption (BOOL enable) @@ -1313,7 +1267,7 @@ uint8 GetRandomIndex (ChaCha20RngCtx* pCtx, uint8 elementsCount) return index; } -#if defined(_WIN64) && !defined (_UEFI) +#if !defined (_UEFI) /* declaration of variables and functions used for RAM encryption on 64-bit build */ static uint8* pbKeyDerivationArea = NULL; static ULONG cbKeyDerivationArea = 0; diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h index 89d22f0e..03921da3 100644 --- a/src/Common/Crypto.h +++ b/src/Common/Crypto.h @@ -208,9 +208,7 @@ typedef struct # include "Camellia.h" #if !defined (_UEFI) # include "chachaRng.h" -# ifdef _WIN64 # include "t1ha.h" -# endif #endif #else # include "CamelliaSmall.h" @@ -228,9 +226,9 @@ typedef struct keyInfo_t int noIterations; /* Number of times to iterate (PKCS-5) */ int keyLength; /* Length of the key */ uint64 dummy; /* Dummy field to ensure 16-byte alignment of this structure */ - __int8 salt[PKCS5_SALT_SIZE]; /* PKCS-5 salt */ - CRYPTOPP_ALIGN_DATA(16) __int8 master_keydata[MASTER_KEYDATA_SIZE]; /* Concatenated master primary 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) __int8 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */ + unsigned __int8 salt[PKCS5_SALT_SIZE]; /* PKCS-5 salt */ + CRYPTOPP_ALIGN_DATA(16) unsigned __int8 master_keydata[MASTER_KEYDATA_SIZE]; /* Concatenated master primary 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 userKey[MAX_PASSWORD]; /* Password (to which keyfiles may have been applied). WITHOUT +1 for the null terminator. */ } KEY_INFO, *PKEY_INFO; #endif @@ -309,7 +307,7 @@ typedef struct BOOT_CRYPTO_HEADER_t PCRYPTO_INFO crypto_open (void); #ifndef TC_WINDOWS_BOOT -void crypto_loadkey (PKEY_INFO keyInfo, char *lpszUserKey, int nUserKeyLen); +void crypto_loadkey (PKEY_INFO keyInfo, unsigned char *lpszUserKey, int nUserKeyLen); void crypto_eraseKeys (PCRYPTO_INFO cryptoInfo); #endif void crypto_close (PCRYPTO_INFO cryptoInfo); @@ -348,7 +346,7 @@ int EAGetKeySize (int ea); int EAGetFirstMode (int ea); int EAGetNextMode (int ea, int previousModeId); #ifndef TC_WINDOWS_BOOT -wchar_t * EAGetModeName (int ea, int mode, BOOL capitalLetters); +const wchar_t * EAGetModeName (int mode); #endif int EAGetKeyScheduleSize (int ea); int EAGetLargestKey (); @@ -386,7 +384,7 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s void EncryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo); void DecryptBuffer (unsigned __int8 *buf, TC_LARGEST_COMPILER_UINT len, PCRYPTO_INFO cryptoInfo); -#if defined(_WIN64) && !defined (_UEFI) +#if !defined (TC_WINDOWS_BOOT) && !defined (_UEFI) BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback); void ClearSecurityParameters(); #ifdef TC_WINDOWS_DRIVER diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c index 269817d8..ee3630c0 100644 --- a/src/Common/Dlgcode.c +++ b/src/Common/Dlgcode.c @@ -14,6 +14,7 @@ #include "Tcdefs.h" #include <windowsx.h> +#include <versionhelpers.h> #include <dbghelp.h> #include <dbt.h> #include <Setupapi.h> @@ -590,18 +591,27 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, DWORD bytesWritten; BOOL res = TRUE; DWORD dwLastError = 0; +#if defined(SETUP) && !defined (PORTABLE) + BOOL securityModified = FALSE; + SECURITY_INFO_BACKUP secBackup = { 0 }; + const wchar_t* existingFile = destinationFile; +#endif dst = CreateFile (destinationFile, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, bAppend ? OPEN_EXISTING : CREATE_ALWAYS, 0, NULL); dwLastError = GetLastError(); - if (!bAppend && bRenameIfFailed && (dst == INVALID_HANDLE_VALUE) && (GetLastError () == ERROR_SHARING_VIOLATION)) + if (!bAppend && bRenameIfFailed && (dst == INVALID_HANDLE_VALUE) && (GetLastError () == ERROR_SHARING_VIOLATION || GetLastError() == ERROR_ACCESS_DENIED)) { wchar_t renamedPath[TC_MAX_PATH + 1]; StringCbCopyW (renamedPath, sizeof(renamedPath), destinationFile); StringCbCatW (renamedPath, sizeof(renamedPath), VC_FILENAME_RENAMED_SUFFIX); +#if defined(SETUP) && !defined (PORTABLE) + // Take ownership of the file + securityModified = ModifyFileSecurityPermissions(destinationFile, &secBackup); +#endif /* rename the locked file in order to be able to create a new one */ if (MoveFileEx (destinationFile, renamedPath, MOVEFILE_REPLACE_EXISTING)) { @@ -616,10 +626,20 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile, } else { +#if defined(SETUP) && !defined (PORTABLE) + existingFile = renamedPath; +#endif /* delete the renamed file when the machine reboots */ MoveFileEx (renamedPath, NULL, MOVEFILE_DELAY_UNTIL_REBOOT); } } +#if defined(SETUP) && !defined (PORTABLE) + if (securityModified) + { + RestoreSecurityInfo(existingFile, &secBackup); + FreeSecurityBackup(&secBackup); + } +#endif } if (dst == INVALID_HANDLE_VALUE) @@ -859,11 +879,6 @@ BOOL VerifyModuleSignature (const wchar_t* path) 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'"') { @@ -1088,9 +1103,6 @@ static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation) bRet = TRUE; } - if (!bRet) - bRet = GetVersionExW (lpVersionInformation); - #ifdef SETUP_DLL // we get real version from Kernel32.dll version since MSI always sets current version to 6.0 // https://stackoverflow.com/questions/49335885/windows-10-not-detecting-on-installshield/49343826#49343826 @@ -2133,12 +2145,8 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam // 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 + StringCbPrintfW (szTmp, sizeof(szTmp), L"VeraCrypt %s", _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX) L" (64-bit)"); + #if (defined(_DEBUG) || defined(DEBUG)) StringCbCatW (szTmp, sizeof(szTmp), L" (debug)"); #endif @@ -3171,7 +3179,7 @@ BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_ StringCbCopyW (newCmdLine, sizeof(newCmdLine), L"/q UAC "); StringCbCatW (newCmdLine, sizeof (newCmdLine), args); - if ((int)ShellExecuteW (hWnd, L"runas", szModPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32) + if ((INT_PTR)ShellExecuteW (hWnd, L"runas", szModPath, newCmdLine, NULL, SW_SHOWNORMAL) <= 32) { if (hwndDlg) handleWin32Error (hwndDlg, SRC_POS); @@ -3603,10 +3611,16 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) InitOSVersionInfo(); - if (!IsOSAtLeast (WIN_7)) + if (!IsOSAtLeast (WIN_10)) { - // 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."); + // abort using a message that says that VeraCrypt can run only on Windows 10 and later + AbortProcessDirect(L"VeraCrypt requires at least Windows 10 to run."); + } + + if (!Is64BitOs()) + { + // abort using a message that says that VeraCrypt can run only on 64-bit Windows + AbortProcessDirect(L"VeraCrypt requires a 64-bit version of Windows to run."); } SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories"); @@ -3794,14 +3808,14 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine) InitHelpFileName (); #ifndef SETUP -#ifdef _WIN64 + EnableRamEncryption ((ReadDriverConfigurationFlags() & VC_DRIVER_CONFIG_ENABLE_RAM_ENCRYPTION) ? TRUE : FALSE); if (IsRamEncryptionEnabled()) { if (!InitializeSecurityParameters(GetAppRandomSeed)) AbortProcess("OUTOFMEMORY"); } -#endif + if (!EncryptionThreadPoolStart (ReadEncryptionThreadPoolFreeCpuCountLimit())) { handleWin32Error (NULL, SRC_POS); @@ -3916,7 +3930,7 @@ void NotifyDriverOfPortableMode (void) BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize) { DWORD fileSystemFlags; - wchar_t root[] = { L'A' + (wchar_t) driveNo, L':', L'\\', 0 }; + wchar_t root[] = { (wchar_t) (L'A' + driveNo), L':', L'\\', 0 }; return GetVolumeInformationW (root, label, labelSize / 2, NULL, NULL, &fileSystemFlags, NULL, 0); } @@ -3946,11 +3960,12 @@ BOOL GetSysDevicePaths (HWND hwndDlg) } // Find extra boot partition - foreach (const HostDevice &drive, GetAvailableHostDevices (false, false)) + std::vector <HostDevice> devices = GetAvailableHostDevices(false, false); + for (const HostDevice& drive : devices) { if (drive.ContainsSystem) { - foreach (const HostDevice &sysDrivePartition, drive.Partitions) + for (const HostDevice &sysDrivePartition : drive.Partitions) { if (sysDrivePartition.Bootable) { @@ -4165,6 +4180,7 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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); @@ -4175,9 +4191,43 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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); @@ -4189,8 +4239,12 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa { 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); @@ -4207,7 +4261,8 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa 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; @@ -4830,7 +4885,7 @@ static int DriverLoad () else *tmp = 0; - StringCbCatW (driverPath, sizeof(driverPath), !Is64BitOs () ? L"\\veracrypt.sys" : IsARM()? L"\\veracrypt-arm64.sys" : L"\\veracrypt-x64.sys"); + StringCbCatW (driverPath, sizeof(driverPath), IsARM()? L"\\veracrypt-arm64.sys" : L"\\veracrypt-x64.sys"); file = FindFirstFile (driverPath, &find); @@ -5354,7 +5409,7 @@ BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, s return status; } -BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wchar_t *initialDir) +BOOL BrowseDirectories(HWND hwndDlg, char *lpszDlgTitle, wchar_t *dirName, const wchar_t *initialDir) { IFileDialog *pfd = NULL; HRESULT hr; @@ -5379,9 +5434,9 @@ BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wc } // Set the title. - if (lpszTitle) + if (lpszDlgTitle) { - pfd->SetTitle(GetString(lpszTitle)); + pfd->SetTitle(GetString(lpszDlgTitle)); } IShellItem *psi; @@ -5719,7 +5774,7 @@ BOOL CloseVolumeExplorerWindows (HWND hwnd, int driveNo) BOOL UpdateDriveCustomLabel (int driveNo, wchar_t* effectiveLabel, BOOL bSetValue) { wchar_t wszRegPath[MAX_PATH]; - wchar_t driveStr[] = {L'A' + (wchar_t) driveNo, 0}; + wchar_t driveStr[] = { (wchar_t) (L'A' + driveNo), 0}; HKEY hKey; LSTATUS lStatus; DWORD cbLabelLen = (DWORD) ((wcslen (effectiveLabel) + 1) * sizeof (wchar_t)); @@ -6226,7 +6281,7 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) */ { int thid, i; - char dk[MASTER_KEYDATA_SIZE]; + unsigned 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++) @@ -6244,27 +6299,27 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) 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); + derive_key_sha512 ((unsigned char*) "passphrase-1234567890", 21, (unsigned char*) 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); + derive_key_sha256 ((unsigned char*)"passphrase-1234567890", 21, (unsigned char*) 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); + derive_key_blake2s ((unsigned char*)"passphrase-1234567890", 21, (unsigned char*) 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); + derive_key_whirlpool ((unsigned char*)"passphrase-1234567890", 21, (unsigned char*) 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); + derive_key_streebog((unsigned char*)"passphrase-1234567890", 21, (unsigned char*) tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE); break; } #endif @@ -6288,19 +6343,11 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) { 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 - benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 18) / 5; -#endif } } } @@ -6323,10 +6370,8 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) if (EAInitMode (ci, ci->k2)) { int i; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectKeys (ci, VcGetEncryptionID (ci)); -#endif for (i = 0; i < 10; i++) { @@ -6348,10 +6393,8 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg) if (!EAInitMode (ci, ci->k2)) goto counter_error; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectKeys (ci, VcGetEncryptionID (ci)); -#endif if (QueryPerformanceCounter (&performanceCountStart) == 0) goto counter_error; @@ -7599,7 +7642,7 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) else { - CipherInit2(idTestCipher, key, ks_tmp, ks); + CipherInit2(idTestCipher, key, ks_tmp); if (bEncrypt) { @@ -8221,7 +8264,7 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap) { if (driveMap & (1 << i)) { - wchar_t root[] = { (wchar_t) i + L'A', L':', L'\\', 0 }; + wchar_t root[] = { (wchar_t) (i + L'A'), L':', L'\\', 0 }; SHChangeNotify (eventId, SHCNF_PATH, root, NULL); @@ -8778,12 +8821,12 @@ retry: wstring drivePath = L"\\\\.\\X:"; HANDLE dev = INVALID_HANDLE_VALUE; VOLUME_DISK_EXTENTS extents = {0}; - DWORD dwResult = 0; + DWORD cbReturnedBytes = 0; drivePath[4] = root[0]; 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), &cbReturnedBytes, NULL)) { if (extents.NumberOfDiskExtents > 0) { @@ -8920,18 +8963,18 @@ retry: if (bDevice && mount.bProtectHiddenVolume) { - int driveNo; + int diskNo; - if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &driveNo) == 1) + if (swscanf (volumePath, L"\\Device\\Harddisk%d\\Partition", &diskNo) == 1) { OPEN_TEST_STRUCT openTestStruct; memset (&openTestStruct, 0, sizeof (openTestStruct)); openTestStruct.bDetectTCBootLoader = TRUE; - StringCchPrintfW ((wchar_t *) openTestStruct.wszFileName, array_capacity (openTestStruct.wszFileName), L"\\Device\\Harddisk%d\\Partition0", driveNo); + StringCchPrintfW ((wchar_t *) openTestStruct.wszFileName, array_capacity (openTestStruct.wszFileName), L"\\Device\\Harddisk%d\\Partition0", diskNo); - DWORD dwResult; - if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &dwResult, NULL) && openTestStruct.TCBootLoaderDetected) + DWORD cbBytesReturned; + if (DeviceIoControl (hDriver, TC_IOCTL_OPEN_TEST, &openTestStruct, sizeof (OPEN_TEST_STRUCT), &openTestStruct, sizeof (OPEN_TEST_STRUCT), &cbBytesReturned, 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); @@ -8970,7 +9013,7 @@ retry: if (mount.FilesystemDirty) { wchar_t msg[1024]; - wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint); if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES) @@ -8984,7 +9027,7 @@ retry: && !IsFileOnReadOnlyFilesystem (volumePath)) { wchar_t msg[1024]; - wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_CONTAINER_FORCED_READ_ONLY"), mountPoint); WarningDirect (msg, hwndDlg); @@ -8995,7 +9038,7 @@ retry: && bDevice) { wchar_t msg[1024]; - wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + wchar_t mountPoint[] = { (wchar_t)(L'A' + driveNo), L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY"), mountPoint); WarningDirect (msg, hwndDlg); @@ -9006,7 +9049,7 @@ retry: && wcsstr (volumePath, L"\\Device\\Harddisk") == volumePath) { wchar_t msg[1024]; - wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION"), mountPoint); WarningDirect (msg, hwndDlg); @@ -9024,7 +9067,7 @@ retry: && bDevice) { wchar_t msg[1024]; - wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 }; + wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 }; StringCbPrintfW (msg, sizeof(msg), GetString ("PARTIAL_SYSENC_MOUNT_READONLY"), mountPoint); WarningDirect (msg, hwndDlg); @@ -9117,7 +9160,7 @@ retry: } // Undo SHCNE_DRIVEREMOVED - wchar_t root[] = { (wchar_t) nDosDriveNo + L'A', L':', L'\\', 0 }; + wchar_t root[] = { (wchar_t) (nDosDriveNo + L'A'), L':', L'\\', 0 }; SHChangeNotify (SHCNE_DRIVEADD, SHCNF_PATH, root, NULL); return FALSE; @@ -9471,7 +9514,7 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName) for (i = 0; i < 26; i++) { - WCHAR drive[] = { (WCHAR) i + L'A', L':', 0 }; + WCHAR drive[] = { (WCHAR) (i + L'A'), L':', 0 }; StringCchCopyW (link, MAX_PATH, L"\\DosDevices\\"); StringCchCatW (link, MAX_PATH, drive); @@ -10164,7 +10207,7 @@ std::wstring GetServiceConfigPath (const wchar_t *fileName, bool useLegacy) { wchar_t sysPath[TC_MAX_PATH]; - if (Is64BitOs() && useLegacy) + if (useLegacy) { typedef UINT (WINAPI *GetSystemWow64Directory_t) (LPWSTR lpBuffer, UINT uSize); @@ -10669,12 +10712,12 @@ void OpenPageHelp (HWND hwndDlg, int nPage) } else { - int r = (int)ShellExecuteW (NULL, L"open", szHelpFile, NULL, NULL, SW_SHOWNORMAL); + INT_PTR r = (INT_PTR)ShellExecuteW (NULL, L"open", szHelpFile, NULL, NULL, SW_SHOWNORMAL); if (r == ERROR_FILE_NOT_FOUND) { // Try the secondary help file - r = (int)ShellExecuteW (NULL, L"open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL); + r = (INT_PTR)ShellExecuteW (NULL, L"open", szHelpFile2, NULL, NULL, SW_SHOWNORMAL); if (r == ERROR_FILE_NOT_FOUND) { @@ -10901,14 +10944,11 @@ BOOL IsARM() BOOL IsServerOS () { - OSVERSIONINFOEXW osVer; - osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); - GetVersionExW ((LPOSVERSIONINFOW) &osVer); - - return (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); + return IsWindowsServer()? TRUE : FALSE; } + // Returns TRUE, if the currently running operating system is installed in a hidden volume. If it's not, or if // there's an error, returns FALSE. BOOL IsHiddenOSRunning (void) @@ -10983,100 +11023,105 @@ std::wstring GetWindowsEdition () { wstring osname = L"win"; - OSVERSIONINFOEXW osVer; + OSVERSIONINFOEXW osVer = { 0 }; osVer.dwOSVersionInfoSize = sizeof (OSVERSIONINFOEXW); - GetVersionExW ((LPOSVERSIONINFOW) &osVer); + if (GetWindowsVersion((LPOSVERSIONINFOW)&osVer)) + { - BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL); - BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); + BOOL home = (osVer.wSuiteMask & VER_SUITE_PERSONAL); + BOOL server = (osVer.wProductType == VER_NT_SERVER || osVer.wProductType == VER_NT_DOMAIN_CONTROLLER); - HKEY hkey; - wchar_t productName[300] = {0}; - DWORD productNameSize = sizeof (productName); - if (RegOpenKeyEx (HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) - { - if (RegQueryValueEx (hkey, L"ProductName", 0, 0, (LPBYTE) &productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1) - productName[0] = 0; + HKEY hkey; + wchar_t productName[300] = { 0 }; + DWORD productNameSize = sizeof(productName); + if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, KEY_QUERY_VALUE, &hkey) == ERROR_SUCCESS) + { + if (RegQueryValueEx(hkey, L"ProductName", 0, 0, (LPBYTE)&productName, &productNameSize) != ERROR_SUCCESS || productNameSize < 1) + productName[0] = 0; - RegCloseKey (hkey); - } + RegCloseKey(hkey); + } - switch (nCurrentOS) - { - case WIN_2000: - osname += L"2000"; - break; + switch (nCurrentOS) + { + case WIN_2000: + osname += L"2000"; + break; - case WIN_XP: - case WIN_XP64: - osname += L"xp"; - osname += home ? L"-home" : L"-pro"; - break; + case WIN_XP: + case WIN_XP64: + osname += L"xp"; + osname += home ? L"-home" : L"-pro"; + break; - case WIN_SERVER_2003: - osname += L"2003"; - break; + case WIN_SERVER_2003: + osname += L"2003"; + break; - case WIN_VISTA: - osname += L"vista"; - break; + case WIN_VISTA: + osname += L"vista"; + break; - case WIN_SERVER_2008: - osname += L"2008"; - break; + case WIN_SERVER_2008: + osname += L"2008"; + break; - case WIN_7: - osname += L"7"; - break; + case WIN_7: + osname += L"7"; + break; - case WIN_SERVER_2008_R2: - osname += L"2008r2"; - break; + case WIN_SERVER_2008_R2: + osname += L"2008r2"; + break; - default: - wstringstream s; - s << CurrentOSMajor << L"." << CurrentOSMinor; - osname += s.str(); - break; - } + default: + wstringstream s; + s << CurrentOSMajor << L"." << CurrentOSMinor; + osname += s.str(); + break; + } - if (server) - osname += L"-server"; + if (server) + osname += L"-server"; - if (IsOSAtLeast (WIN_VISTA)) - { - if (home) - osname += L"-home"; - else if (wcsstr (productName, L"Standard") != 0) - osname += L"-standard"; - else if (wcsstr (productName, L"Professional") != 0) - osname += L"-pro"; - else if (wcsstr (productName, L"Business") != 0) - osname += L"-business"; - else if (wcsstr (productName, L"Enterprise") != 0) - osname += L"-enterprise"; - else if (wcsstr (productName, L"Datacenter") != 0) - osname += L"-datacenter"; - else if (wcsstr (productName, L"Ultimate") != 0) - osname += L"-ultimate"; - } + if (IsOSAtLeast(WIN_VISTA)) + { + if (home) + osname += L"-home"; + else if (wcsstr(productName, L"Standard") != 0) + osname += L"-standard"; + else if (wcsstr(productName, L"Professional") != 0) + osname += L"-pro"; + else if (wcsstr(productName, L"Business") != 0) + osname += L"-business"; + else if (wcsstr(productName, L"Enterprise") != 0) + osname += L"-enterprise"; + else if (wcsstr(productName, L"Datacenter") != 0) + osname += L"-datacenter"; + else if (wcsstr(productName, L"Ultimate") != 0) + osname += L"-ultimate"; + } - if (GetSystemMetrics (SM_STARTER)) - osname += L"-starter"; - else if (wcsstr (productName, L"Basic") != 0) - osname += L"-basic"; + if (GetSystemMetrics(SM_STARTER)) + osname += L"-starter"; + else if (wcsstr(productName, L"Basic") != 0) + osname += L"-basic"; - if (Is64BitOs()) - osname += IsARM()? L"-arm64" : L"-x64"; + osname += IsARM() ? L"-arm64" : L"-x64"; - if (CurrentOSServicePack > 0) + if (CurrentOSServicePack > 0) + { + wstringstream s; + s << L"-sp" << CurrentOSServicePack; + osname += s.str(); + } + + return osname; + } + else { - wstringstream s; - s << L"-sp" << CurrentOSServicePack; - osname += s.str(); + return L""; } - - return osname; } #ifdef SETUP @@ -11089,7 +11134,7 @@ void Applink (const char *dest) wchar_t page[TC_MAX_PATH] = {0}; wchar_t installDir[TC_MAX_PATH] = {0}; BOOL buildUrl = TRUE; - int r; + INT_PTR r; ArrowWaitCursor (); @@ -11293,7 +11338,7 @@ void Applink (const char *dest) } else { - r = (int) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); + r = (INT_PTR) ShellExecuteW (NULL, L"open", url, NULL, NULL, SW_SHOWNORMAL); if (((r == ERROR_FILE_NOT_FOUND) || (r == ERROR_PATH_NOT_FOUND)) && buildUrl) { @@ -11440,7 +11485,7 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password int volumeType; wchar_t szDiskFile[TC_MAX_PATH], szCFDevice[TC_MAX_PATH]; wchar_t szDosDevice[TC_MAX_PATH]; - char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; + unsigned char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; LARGE_INTEGER headerOffset; DWORD dwResult; DISK_GEOMETRY_EX deviceGeometry; @@ -11654,7 +11699,7 @@ void CloseVolume (OpenVolumeContext *context) } -int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode) +int ReEncryptVolumeHeader (HWND hwndDlg, unsigned char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode) { CRYPTO_INFO *newCryptoInfo = NULL; @@ -13019,7 +13064,7 @@ BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path) 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 }; + wchar_t driveRoot[] = { (wchar_t) (L'A' + driveNo), L':', 0 }; if (fixErrors && AskWarnYesNo ("FILESYS_REPAIR_CONFIRM_BACKUP", hwndDlg) == IDNO) return; @@ -13265,18 +13310,18 @@ BOOL IsWindowsIsoBurnerAvailable () BOOL LaunchWindowsIsoBurner (HWND hwnd, const wchar_t *isoPath) { wchar_t path[MAX_PATH*2] = { 0 }; - int r; + INT_PTR 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); + r = (INT_PTR) ShellExecute (hwnd, L"open", path, (wstring (L"\"") + isoPath + L"\"").c_str(), NULL, SW_SHOWNORMAL); if (r <= 32) { - SetLastError (r); + SetLastError ((DWORD) r); handleWin32Error (hwnd, SRC_POS); return FALSE; @@ -14200,17 +14245,14 @@ void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, B SHGetSpecialFolderLocation (hwndDlg, CSIDL_PROGRAM_FILES, &itemList); SHGetPathFromIDList (itemList, path); - 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) { - // 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()); - } + 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\\"); @@ -14783,7 +14825,7 @@ void SafeOpenURL (LPCWSTR szUrl) } } -#if !defined(SETUP) && defined(_WIN64) +#if !defined(SETUP) #define RtlGenRandom SystemFunction036 extern "C" BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength); @@ -15224,7 +15266,7 @@ void PasswordEditDropTarget::GotLeave(void) DWORD PasswordEditDropTarget::GotEnter(void) { TCHAR szClassName[64]; - DWORD dwStyles; + DWORD_PTR dwStyles; int maxLen; HWND hChild = WindowFromPoint (m_DropPoint); // check that we are on password edit control (we use maximum length to correctly identify password fields since they don't always have ES_PASSWORD style (if the the user checked show password) @@ -15250,7 +15292,7 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format) if(m_Data) { TCHAR szClassName[64]; - DWORD dwStyles; + DWORD_PTR dwStyles; int maxLen; HWND hChild = WindowFromPoint (m_DropPoint); if (hChild && GetClassName (hChild, szClassName, ARRAYSIZE (szClassName)) && (0 == _tcsicmp (szClassName, _T("EDIT"))) @@ -15739,3 +15781,191 @@ DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize) return dwRet; } #endif // VC_COMREG + +#if defined(SETUP) && !defined (PORTABLE) + +// Helper function to save the current state of the required privileges +BOOL SaveCurrentPrivilegeState(PPRIVILEGE_STATE state) { + if (!state) return FALSE; + + state->takeOwnership = IsPrivilegeEnabled(SE_TAKE_OWNERSHIP_NAME); + state->backup = IsPrivilegeEnabled(SE_BACKUP_NAME); + state->restore = IsPrivilegeEnabled(SE_RESTORE_NAME); + + return TRUE; +} + +// Helper function to restore the saved state of the required privileges +BOOL RestorePrivilegeState(const PPRIVILEGE_STATE state) { + if (!state) return FALSE; + + BOOL result = TRUE; + result &= SetPrivilege(SE_TAKE_OWNERSHIP_NAME, state->takeOwnership); + result &= SetPrivilege(SE_BACKUP_NAME, state->backup); + result &= SetPrivilege(SE_RESTORE_NAME, state->restore); + + return result; +} + +// Helper function to enable required privileges for file operations +BOOL EnableRequiredSetupPrivileges(PPRIVILEGE_STATE currentState) +{ + BOOL result = TRUE; + + // save the current state of the required privileges + ZeroMemory(currentState, sizeof(PRIVILEGE_STATE)); + SaveCurrentPrivilegeState(currentState); + + // Enable required privileges using the existing SetPrivilege function + result &= SetPrivilege(SE_TAKE_OWNERSHIP_NAME, TRUE); + result &= SetPrivilege(SE_BACKUP_NAME, TRUE); + result &= SetPrivilege(SE_RESTORE_NAME, TRUE); + + return result; +} + +// Helper function to backup security information +BOOL BackupSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup) +{ + BOOL result = FALSE; + DWORD dwRes; + + ZeroMemory(pBackup, sizeof(SECURITY_INFO_BACKUP)); + + // Get the security descriptor + dwRes = GetNamedSecurityInfoW( + (LPWSTR)filePath, + SE_FILE_OBJECT, + OWNER_SECURITY_INFORMATION | GROUP_SECURITY_INFORMATION | + DACL_SECURITY_INFORMATION | SACL_SECURITY_INFORMATION, + &pBackup->pOrigOwner, + &pBackup->pOrigGroup, + &pBackup->pOrigDacl, + &pBackup->pOrigSacl, + &pBackup->pOrigSD); + + if (dwRes == ERROR_SUCCESS) + { + // The individual pointers (pOrigOwner, etc.) are now valid + // and point to the copied data + result = TRUE; + } + + return result; +} + +// Helper function to restore security information +BOOL RestoreSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup) +{ + DWORD dwRes; + SECURITY_INFORMATION secInfo = 0; + + if (pBackup->pOrigOwner) + secInfo |= OWNER_SECURITY_INFORMATION; + if (pBackup->pOrigGroup) + secInfo |= GROUP_SECURITY_INFORMATION; + if (pBackup->pOrigDacl) + secInfo |= DACL_SECURITY_INFORMATION; + if (pBackup->pOrigSacl) + secInfo |= SACL_SECURITY_INFORMATION; + + if (secInfo == 0) + return TRUE; // Nothing to restore + + dwRes = SetNamedSecurityInfoW( + (LPWSTR)filePath, + SE_FILE_OBJECT, + secInfo, + pBackup->pOrigOwner, + pBackup->pOrigGroup, + pBackup->pOrigDacl, + pBackup->pOrigSacl); + + return (dwRes == ERROR_SUCCESS); +} + +// Helper function to free security backup +void FreeSecurityBackup(PSECURITY_INFO_BACKUP pBackup) +{ + if (pBackup->pOrigSD) + LocalFree(pBackup->pOrigSD); + ZeroMemory(pBackup, sizeof(SECURITY_INFO_BACKUP)); +} + +// Helper function to take ownership and modify file permissions +BOOL ModifyFileSecurityPermissions(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup) +{ + BOOL result = FALSE; + PSID pAdminSID = NULL; + PACL pNewDACL = NULL; + BOOL bBackupDone = FALSE; + + // Get Administrator SID + SID_IDENTIFIER_AUTHORITY SIDAuthNT = SECURITY_NT_AUTHORITY; + if (!AllocateAndInitializeSid(&SIDAuthNT, 2, + SECURITY_BUILTIN_DOMAIN_RID, + DOMAIN_ALIAS_RID_ADMINS, + 0, 0, 0, 0, 0, 0, + &pAdminSID)) + { + goto cleanup; + } + + // Backup original security info + if (!BackupSecurityInfo(filePath, pBackup)) + goto cleanup; + + bBackupDone = TRUE; + + // Take ownership + DWORD dwRes = SetNamedSecurityInfoW( + (LPWSTR)filePath, + SE_FILE_OBJECT, + OWNER_SECURITY_INFORMATION, + pAdminSID, + NULL, + NULL, + NULL); + + if (dwRes != ERROR_SUCCESS) + goto cleanup; + + // Modify DACL + EXPLICIT_ACCESS ea; + ZeroMemory(&ea, sizeof(EXPLICIT_ACCESS)); + ea.grfAccessPermissions = GENERIC_ALL; + ea.grfAccessMode = SET_ACCESS; + ea.grfInheritance = NO_INHERITANCE; + ea.Trustee.TrusteeForm = TRUSTEE_IS_SID; + ea.Trustee.TrusteeType = TRUSTEE_IS_GROUP; + ea.Trustee.ptstrName = (LPTSTR)pAdminSID; + + dwRes = SetEntriesInAcl(1, &ea, NULL, &pNewDACL); + if (dwRes != ERROR_SUCCESS) + goto cleanup; + + // Apply new DACL + dwRes = SetNamedSecurityInfoW( + (LPWSTR)filePath, + SE_FILE_OBJECT, + DACL_SECURITY_INFORMATION, + NULL, + NULL, + pNewDACL, + NULL); + + result = (dwRes == ERROR_SUCCESS); + +cleanup: + if (!result && bBackupDone) + { + FreeSecurityBackup(pBackup); + } + if (pNewDACL) + LocalFree(pNewDACL); + if (pAdminSID) + FreeSid(pAdminSID); + + return result; +} +#endif
\ No newline at end of file diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h index 288daecd..4dfae20f 100644 --- a/src/Common/Dlgcode.h +++ b/src/Common/Dlgcode.h @@ -540,7 +540,7 @@ 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); +int ReEncryptVolumeHeader (HWND hwndDlg, unsigned char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode); BOOL IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly); BOOL IsPagingFileWildcardActive (); BOOL DisablePagingFile (); @@ -594,10 +594,32 @@ BitLockerEncryptionStatus GetBitLockerEncryptionStatus(WCHAR driveLetter); BOOL IsTestSigningModeEnabled (); DWORD SendServiceNotification (DWORD dwNotificationCmd); DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize); -#ifdef _WIN64 +#if !defined(SETUP) void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed); #endif BOOL IsInternetConnected(); +#if defined(SETUP) && !defined (PORTABLE) +typedef struct _SECURITY_INFO_BACKUP { + PSID pOrigOwner; + PSID pOrigGroup; + PACL pOrigDacl; + PACL pOrigSacl; + PSECURITY_DESCRIPTOR pOrigSD; +} SECURITY_INFO_BACKUP, * PSECURITY_INFO_BACKUP; + +typedef struct _PRIVILEGE_STATE { + BOOL takeOwnership; + BOOL backup; + BOOL restore; +} PRIVILEGE_STATE, * PPRIVILEGE_STATE; + +BOOL RestoreSecurityInfo(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup); +void FreeSecurityBackup(PSECURITY_INFO_BACKUP pBackup); +BOOL SaveCurrentPrivilegeState(PPRIVILEGE_STATE state); +BOOL RestorePrivilegeState(const PPRIVILEGE_STATE state); +BOOL EnableRequiredSetupPrivileges(PPRIVILEGE_STATE currentState); +BOOL ModifyFileSecurityPermissions(const wchar_t* filePath, PSECURITY_INFO_BACKUP pBackup); +#endif #ifdef __cplusplus } diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c index 79f1c890..8a0c6e78 100644 --- a/src/Common/EncryptionThreadPool.c +++ b/src/Common/EncryptionThreadPool.c @@ -98,14 +98,14 @@ typedef struct EncryptionThreadPoolWorkItemStruct { TC_EVENT *CompletionEvent; LONG *CompletionFlag; - char *DerivedKey; + unsigned char *DerivedKey; int IterationCount; TC_EVENT *NoOutstandingWorkItemEvent; LONG *OutstandingWorkItemCount; - char *Password; + unsigned char *Password; int PasswordLength; int Pkcs5Prf; - char *Salt; + unsigned char *Salt; } KeyDerivation; @@ -143,7 +143,6 @@ static TC_MUTEX DequeueMutex; static TC_EVENT WorkItemReadyEvent; static TC_EVENT WorkItemCompletedEvent; -#if defined(_WIN64) void EncryptDataUnitsCurrentThreadEx (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci) { if (IsRamEncryptionEnabled()) @@ -176,11 +175,6 @@ void DecryptDataUnitsCurrentThreadEx (unsigned __int8 *buf, const UINT64_STRUCT DecryptDataUnitsCurrentThread (buf, structUnitNo, nbrUnits, ci); } -#else -#define EncryptDataUnitsCurrentThreadEx EncryptDataUnitsCurrentThread -#define DecryptDataUnitsCurrentThreadEx DecryptDataUnitsCurrentThread -#endif - static WorkItemState GetWorkItemState (EncryptionThreadPoolWorkItem *workItem) { return InterlockedExchangeAdd ((LONG *) &workItem->State, 0); @@ -533,7 +527,7 @@ void EncryptionThreadPoolStop () } -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 EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, unsigned char *derivedKey) { EncryptionThreadPoolWorkItem *workItem; diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h index 71df4e4d..2e727a74 100644 --- a/src/Common/EncryptionThreadPool.h +++ b/src/Common/EncryptionThreadPool.h @@ -32,7 +32,7 @@ typedef enum 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 EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, unsigned char *password, int passwordLength, unsigned char *salt, int iterationCount, unsigned char *derivedKey); void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivationCompletedEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG* outstandingWorkItemCount, void* keyInfoBuffer, int keyInfoBufferSize, void* keyDerivationWorkItems, int keyDerivationWorkItemsSize); void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo); BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount); diff --git a/src/Common/Fat.c b/src/Common/Fat.c index 19720b17..dec2ccee 100644 --- a/src/Common/Fat.c +++ b/src/Common/Fat.c @@ -445,10 +445,8 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void return ERR_MODE_INIT_FAILED; } -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo)); -#endif x = ft->num_sectors - ft->reserved - ft->size_root_dir / ft->sector_size - ft->fat_length * 2; while (x--) diff --git a/src/Common/Format.c b/src/Common/Format.c index 7eff80e6..f1550e6b 100644 --- a/src/Common/Format.c +++ b/src/Common/Format.c @@ -84,7 +84,7 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) PCRYPTO_INFO cryptoInfo = NULL; HANDLE dev = INVALID_HANDLE_VALUE; DWORD dwError; - char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; + unsigned char header[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; unsigned __int64 num_sectors, startSector; fatparams ft; FILETIME ftCreationTime; @@ -100,10 +100,8 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) LARGE_INTEGER offset; BOOL bFailedRequiredDASD = FALSE; HWND hwndDlg = volParams->hwndDlg; -#ifdef _WIN64 CRYPTO_INFO tmpCI; PCRYPTO_INFO cryptoInfoBackup = NULL; -#endif FormatSectorSize = volParams->sectorSize; @@ -175,12 +173,10 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams) return nStatus? nStatus : ERR_OUTOFMEMORY; } -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo)); } -#endif begin_format: @@ -511,9 +507,9 @@ begin_format: // 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)) + LARGE_INTEGER volDataOffset; + volDataOffset.QuadPart = TC_VOLUME_DATA_OFFSET; + if (!SetFilePointerEx ((HANDLE) dev, volDataOffset, NULL, FILE_BEGIN)) { nStatus = ERR_OS_ERROR; goto error; @@ -640,7 +636,6 @@ begin_format: goto error; } -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { VirtualLock (&tmpCI, sizeof (tmpCI)); @@ -649,7 +644,6 @@ begin_format: cryptoInfoBackup = cryptoInfo; cryptoInfo = &tmpCI; } -#endif nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE, header, @@ -669,14 +663,12 @@ begin_format: FormatSectorSize, FALSE); -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { cryptoInfo = cryptoInfoBackup; burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof (tmpCI)); } -#endif if (!WriteEffectiveVolumeHeader (volParams->bDevice, dev, header)) { @@ -689,7 +681,6 @@ begin_format: { BOOL bUpdateBackup = FALSE; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { VirtualLock (&tmpCI, sizeof (tmpCI)); @@ -698,18 +689,15 @@ begin_format: cryptoInfoBackup = cryptoInfo; cryptoInfo = &tmpCI; } -#endif nStatus = WriteRandomDataToReservedHeaderAreas (hwndDlg, dev, cryptoInfo, dataAreaSize, FALSE, FALSE); -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { cryptoInfo = cryptoInfoBackup; burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof (tmpCI)); } -#endif if (nStatus != ERR_SUCCESS) goto error; @@ -915,9 +903,7 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num LARGE_INTEGER startOffset; LARGE_INTEGER newOffset; -#ifdef _WIN64 CRYPTO_INFO tmpCI; -#endif // Seek to start sector startOffset.QuadPart = startSector * FormatSectorSize; @@ -936,7 +922,6 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num memset (sector, 0, sizeof (sector)); -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { VirtualLock (&tmpCI, sizeof (tmpCI)); @@ -944,7 +929,6 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num VcUnprotectKeys (&tmpCI, VcGetEncryptionID (cryptoInfo)); cryptoInfo = &tmpCI; } -#endif // Remember the original secondary key (XTS mode) before generating a temporary one memcpy (originalK2, cryptoInfo->k2, sizeof (cryptoInfo->k2)); @@ -975,10 +959,8 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num goto fail; } -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo)); -#endif while (num_sectors--) { @@ -1051,13 +1033,11 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num VirtualUnlock (temporaryKey, sizeof (temporaryKey)); VirtualUnlock (originalK2, sizeof (originalK2)); TCfree (write_buf); -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof (tmpCI)); } -#endif return 0; @@ -1069,13 +1049,11 @@ fail: VirtualUnlock (temporaryKey, sizeof (temporaryKey)); VirtualUnlock (originalK2, sizeof (originalK2)); TCfree (write_buf); -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) { burn (&tmpCI, sizeof (CRYPTO_INFO)); VirtualUnlock (&tmpCI, sizeof (tmpCI)); } -#endif SetLastError (err); return (retVal ? retVal : ERR_OS_ERROR); diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c index 6d9907cd..b21e371d 100644 --- a/src/Common/Keyfiles.c +++ b/src/Common/Keyfiles.c @@ -270,7 +270,7 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con unsigned __int32 writePos = 0; size_t totalRead = 0; - for (size_t i = 0; i < keyfileData.size(); i++) + for (i = 0; i < keyfileData.size(); i++) { crc = UPDC32 (keyfileData[i], crc); @@ -496,7 +496,7 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa // set the text colour in (HDC)wParam SetBkMode((HDC)wParam,TRANSPARENT); SetTextColor((HDC)wParam, RGB(255,0,0)); - return (BOOL)GetSysColorBrush(COLOR_MENU); + return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU); } } return 0; diff --git a/src/Common/Language.c b/src/Common/Language.c index a6bc9891..11c791d8 100644 --- a/src/Common/Language.c +++ b/src/Common/Language.c @@ -342,7 +342,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B xml = (char *) res; while (xml = XmlFindElement (xml, xmlElements[i])) { - void *key; + void *pkey; void *text; XmlGetAttributeText (xml, "lang", attr, sizeof (attr)); @@ -351,8 +351,8 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B { if (XmlGetAttributeText (xml, "key", attr, sizeof (attr))) { - key = AddPoolData (attr, strlen (attr) + 1); - if (key == NULL) return FALSE; + pkey = AddPoolData (attr, strlen (attr) + 1); + if (pkey == NULL) return FALSE; XmlGetNodeText (xml, attr, sizeof (attr)); @@ -371,7 +371,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B case 'n': *out++ = 13; *out++ = 10; break; default: if (!bForceSilent) - MessageBoxA (0, key, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR); + MessageBoxA (0, pkey, "VeraCrypt: Unknown '\\' escape sequence in string", MB_ICONERROR); return FALSE; } } @@ -386,7 +386,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B if (len == 0) { if (!bForceSilent) - MessageBoxA (0, key, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR); + MessageBoxA (0, pkey, "VeraCrypt: Error while decoding UTF-8 string", MB_ICONERROR); return FALSE; } @@ -394,7 +394,7 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B text = AddPoolData ((void *) wattr, len * 2); if (text == NULL) return FALSE; - AddDictionaryEntry ((char *) key, 0, text); + AddDictionaryEntry ((char *)pkey, 0, text); } } diff --git a/src/Common/Lzma.vcxproj b/src/Common/Lzma.vcxproj index a34390aa..d09a39bd 100644 --- a/src/Common/Lzma.vcxproj +++ b/src/Common/Lzma.vcxproj @@ -1,6 +1,10 @@ <?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|ARM64"> + <Configuration>Debug</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> @@ -9,6 +13,10 @@ <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> @@ -52,20 +60,29 @@ <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>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>false</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> @@ -73,14 +90,21 @@ <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v143</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -91,24 +115,42 @@ <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)\lzma\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\lzma\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\lzma\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\lzma\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\lzma\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\lzma\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> @@ -138,6 +180,20 @@ <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> @@ -148,6 +204,7 @@ <IntrinsicFunctions>true</IntrinsicFunctions> <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions> <RuntimeLibrary>MultiThreaded</RuntimeLibrary> + <ControlFlowGuard>Guard</ControlFlowGuard> </ClCompile> <Link> <SubSystem>Windows</SubSystem> @@ -166,6 +223,26 @@ <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> diff --git a/src/Common/Lzma_vs2019.vcxproj b/src/Common/Lzma_vs2019.vcxproj deleted file mode 100644 index 9f640dc5..00000000 --- a/src/Common/Lzma_vs2019.vcxproj +++ /dev/null @@ -1,257 +0,0 @@ -<?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|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> - <None Include="lzma\lzma-history.txt" /> - <None Include="lzma\lzma-sdk.txt" /> - </ItemGroup> - <ItemGroup> - <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> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v142</PlatformToolset> - </PropertyGroup> - <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>$(ProjectDir)$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> - <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> - <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(ProjectDir)$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> - <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/Lzma_vs2019.vcxproj.filters b/src/Common/Lzma_vs2019.vcxproj.filters deleted file mode 100644 index 82fc24ec..00000000 --- a/src/Common/Lzma_vs2019.vcxproj.filters +++ /dev/null @@ -1,87 +0,0 @@ -<?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="Header Files"> - <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier> - <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions> - </Filter> - </ItemGroup> - <ItemGroup> - <None Include="lzma\lzma-history.txt" /> - <None Include="lzma\lzma-sdk.txt" /> - </ItemGroup> - <ItemGroup> - <ClCompile Include="lzma\Alloc.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\CpuArch.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzFind.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzFindMt.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzFindOpt.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzmaDec.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzmaEnc.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\LzmaLib.c"> - <Filter>Source Files</Filter> - </ClCompile> - <ClCompile Include="lzma\Threads.c"> - <Filter>Source Files</Filter> - </ClCompile> - </ItemGroup> - <ItemGroup> - <ClInclude Include="lzma\7zTypes.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\Alloc.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\Compiler.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\CpuArch.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzFind.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzFindMt.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzHash.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzmaDec.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzmaEnc.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\LzmaLib.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\Precomp.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\Threads.h"> - <Filter>Header Files</Filter> - </ClInclude> - <ClInclude Include="lzma\7zWindows.h"> - <Filter>Header Files</Filter> - </ClInclude> - </ItemGroup> -</Project>
\ No newline at end of file diff --git a/src/Common/Lzma_vs2019.vcxproj.user b/src/Common/Lzma_vs2019.vcxproj.user deleted file mode 100644 index ace9a86a..00000000 --- a/src/Common/Lzma_vs2019.vcxproj.user +++ /dev/null @@ -1,3 +0,0 @@ -<?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/Common/Password.c b/src/Common/Password.c index c0247207..aed7cfb9 100644 --- a/src/Common/Password.c +++ b/src/Common/Password.c @@ -173,7 +173,7 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, 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]; + unsigned char buffer[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; PCRYPTO_INFO cryptoInfo = NULL, ci = NULL; void *dev = INVALID_HANDLE_VALUE; DWORD dwError; diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c index d81078e8..6d8ce08a 100644 --- a/src/Common/Pkcs5.c +++ b/src/Common/Pkcs5.c @@ -43,13 +43,13 @@ typedef struct hmac_sha256_ctx_struct sha256_ctx ctx; sha256_ctx inner_digest_ctx; /*pre-computed inner digest context */ sha256_ctx outer_digest_ctx; /*pre-computed outer digest context */ - char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the SHA256 hash */ - char u[SHA256_DIGESTSIZE]; + unsigned char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the SHA256 hash */ + unsigned char u[SHA256_DIGESTSIZE]; } hmac_sha256_ctx; void hmac_sha256_internal ( - char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ + unsigned char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ int ld, /* length of input data in bytes */ hmac_sha256_ctx* hmac /* HMAC-SHA256 context which holds temporary variables */ ) @@ -60,44 +60,38 @@ void hmac_sha256_internal memcpy (ctx, &(hmac->inner_digest_ctx), sizeof (sha256_ctx)); - sha256_hash ((unsigned char *) d, ld, ctx); + sha256_hash (d, ld, ctx); - sha256_end ((unsigned char *) d, ctx); /* d = inner digest */ + sha256_end (d, ctx); /* d = inner digest */ /**** Restore Precomputed Outer Digest Context ****/ memcpy (ctx, &(hmac->outer_digest_ctx), sizeof (sha256_ctx)); - sha256_hash ((unsigned char *) d, SHA256_DIGESTSIZE, ctx); + sha256_hash (d, SHA256_DIGESTSIZE, ctx); - sha256_end ((unsigned char *) d, ctx); /* d = outer digest */ + sha256_end (d, ctx); /* d = outer digest */ } #ifndef TC_WINDOWS_BOOT void hmac_sha256 ( - char *k, /* secret key */ + unsigned char *k, /* secret key */ int lk, /* length of the key in bytes */ - char *d, /* data */ + unsigned char *d, /* data */ int ld /* length of data in bytes */ ) { hmac_sha256_ctx hmac; sha256_ctx* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b; - char key[SHA256_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[SHA256_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSE2()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the key is longer than the hash algorithm block size, let key = sha256(key), as per HMAC specifications. */ @@ -106,8 +100,8 @@ void hmac_sha256 sha256_ctx tctx; sha256_begin (&tctx); - sha256_hash ((unsigned char *) k, lk, &tctx); - sha256_end ((unsigned char *) key, &tctx); + sha256_hash (k, lk, &tctx); + sha256_end (key, &tctx); k = key; lk = SHA256_DIGESTSIZE; @@ -122,10 +116,10 @@ void hmac_sha256 /* Pad the key for inner digest */ for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x36); + buf[b] = (unsigned char) (k[b] ^ 0x36); memset (&buf[lk], 0x36, SHA256_BLOCKSIZE - lk); - sha256_hash ((unsigned char *) buf, SHA256_BLOCKSIZE, ctx); + sha256_hash (buf, SHA256_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -133,20 +127,16 @@ void hmac_sha256 sha256_begin (ctx); for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x5C); + buf[b] = (unsigned char) (k[b] ^ 0x5C); memset (&buf[lk], 0x5C, SHA256_BLOCKSIZE - lk); - sha256_hash ((unsigned char *) buf, SHA256_BLOCKSIZE, ctx); + sha256_hash (buf, SHA256_BLOCKSIZE, ctx); hmac_sha256_internal(d, ld, &hmac); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent leaks */ @@ -155,10 +145,10 @@ void hmac_sha256 } #endif -static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b, hmac_sha256_ctx* hmac) +static void derive_u_sha256 (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha256_ctx* hmac) { - char* k = hmac->k; - char* u = hmac->u; + unsigned char* k = hmac->k; + unsigned char* u = hmac->u; uint32 c; int i; @@ -184,7 +174,7 @@ static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b, #ifdef TC_WINDOWS_BOOT /* specific case of 16-bit bootloader: b is a 16-bit integer that is always < 256 */ memset (&k[salt_len], 0, 3); - k[salt_len + 3] = (char) b; + k[salt_len + 3] = (unsigned char) b; #else b = bswap_32 (b); memcpy (&k[salt_len], &b, 4); @@ -206,25 +196,19 @@ static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b, } -void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) +void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen) { hmac_sha256_ctx hmac; sha256_ctx* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b, l, r; #ifndef TC_WINDOWS_BOOT - char key[SHA256_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[SHA256_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSE2()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the password is longer than the hash algorithm block size, let pwd = sha256(pwd), as per HMAC specifications. */ @@ -233,8 +217,8 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 sha256_ctx tctx; sha256_begin (&tctx); - sha256_hash ((unsigned char *) pwd, pwd_len, &tctx); - sha256_end ((unsigned char *) key, &tctx); + sha256_hash (pwd, pwd_len, &tctx); + sha256_end (key, &tctx); pwd = key; pwd_len = SHA256_DIGESTSIZE; @@ -261,10 +245,10 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 /* Pad the key for inner digest */ for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x36); + buf[b] = (unsigned char) (pwd[b] ^ 0x36); memset (&buf[pwd_len], 0x36, SHA256_BLOCKSIZE - pwd_len); - sha256_hash ((unsigned char *) buf, SHA256_BLOCKSIZE, ctx); + sha256_hash (buf, SHA256_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -272,10 +256,10 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 sha256_begin (ctx); for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x5C); + buf[b] = (unsigned char) (pwd[b] ^ 0x5C); memset (&buf[pwd_len], 0x5C, SHA256_BLOCKSIZE - pwd_len); - sha256_hash ((unsigned char *) buf, SHA256_BLOCKSIZE, ctx); + sha256_hash (buf, SHA256_BLOCKSIZE, ctx); /* first l - 1 blocks */ for (b = 1; b < l; b++) @@ -289,13 +273,9 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 derive_u_sha256 (salt, salt_len, iterations, b, &hmac); memcpy (dk, hmac.u, r); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent possible leaks. */ @@ -314,13 +294,13 @@ typedef struct hmac_sha512_ctx_struct sha512_ctx ctx; sha512_ctx inner_digest_ctx; /*pre-computed inner digest context */ sha512_ctx outer_digest_ctx; /*pre-computed outer digest context */ - char k[SHA512_BLOCKSIZE]; /* enough to hold (salt_len + 4) and also the SHA512 hash */ - char u[SHA512_DIGESTSIZE]; + unsigned char k[SHA512_BLOCKSIZE]; /* enough to hold (salt_len + 4) and also the SHA512 hash */ + unsigned char u[SHA512_DIGESTSIZE]; } hmac_sha512_ctx; void hmac_sha512_internal ( - char *d, /* data and also output buffer of at least 64 bytes */ + unsigned char *d, /* data and also output buffer of at least 64 bytes */ int ld, /* length of data in bytes */ hmac_sha512_ctx* hmac ) @@ -331,43 +311,37 @@ void hmac_sha512_internal memcpy (ctx, &(hmac->inner_digest_ctx), sizeof (sha512_ctx)); - sha512_hash ((unsigned char *) d, ld, ctx); + sha512_hash (d, ld, ctx); - sha512_end ((unsigned char *) d, ctx); + sha512_end (d, ctx); /**** Restore Precomputed Outer Digest Context ****/ memcpy (ctx, &(hmac->outer_digest_ctx), sizeof (sha512_ctx)); - sha512_hash ((unsigned char *) d, SHA512_DIGESTSIZE, ctx); + sha512_hash (d, SHA512_DIGESTSIZE, ctx); - sha512_end ((unsigned char *) d, ctx); + sha512_end (d, ctx); } void hmac_sha512 ( - char *k, /* secret key */ + unsigned char *k, /* secret key */ int lk, /* length of the key in bytes */ - char *d, /* data and also output buffer of at least 64 bytes */ + unsigned char *d, /* data and also output buffer of at least 64 bytes */ int ld /* length of data in bytes */ ) { hmac_sha512_ctx hmac; sha512_ctx* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b; - char key[SHA512_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[SHA512_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSSE3() && HasMMX()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the key is longer than the hash algorithm block size, @@ -377,8 +351,8 @@ void hmac_sha512 sha512_ctx tctx; sha512_begin (&tctx); - sha512_hash ((unsigned char *) k, lk, &tctx); - sha512_end ((unsigned char *) key, &tctx); + sha512_hash (k, lk, &tctx); + sha512_end (key, &tctx); k = key; lk = SHA512_DIGESTSIZE; @@ -393,10 +367,10 @@ void hmac_sha512 /* Pad the key for inner digest */ for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x36); + buf[b] = (unsigned char) (k[b] ^ 0x36); memset (&buf[lk], 0x36, SHA512_BLOCKSIZE - lk); - sha512_hash ((unsigned char *) buf, SHA512_BLOCKSIZE, ctx); + sha512_hash (buf, SHA512_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -404,20 +378,16 @@ void hmac_sha512 sha512_begin (ctx); for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x5C); + buf[b] = (unsigned char) (k[b] ^ 0x5C); memset (&buf[lk], 0x5C, SHA512_BLOCKSIZE - lk); - sha512_hash ((unsigned char *) buf, SHA512_BLOCKSIZE, ctx); + sha512_hash (buf, SHA512_BLOCKSIZE, ctx); hmac_sha512_internal (d, ld, &hmac); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent leaks */ @@ -425,10 +395,10 @@ void hmac_sha512 burn (key, sizeof(key)); } -static void derive_u_sha512 (char *salt, int salt_len, uint32 iterations, int b, hmac_sha512_ctx* hmac) +static void derive_u_sha512 (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_sha512_ctx* hmac) { - char* k = hmac->k; - char* u = hmac->u; + unsigned char* k = hmac->k; + unsigned char* u = hmac->u; uint32 c, i; /* iteration 1 */ @@ -452,24 +422,18 @@ static void derive_u_sha512 (char *salt, int salt_len, uint32 iterations, int b, } -void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) +void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen) { hmac_sha512_ctx hmac; sha512_ctx* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b, l, r; - char key[SHA512_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[SHA512_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSSE3() && HasMMX()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the password is longer than the hash algorithm block size, @@ -479,8 +443,8 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 sha512_ctx tctx; sha512_begin (&tctx); - sha512_hash ((unsigned char *) pwd, pwd_len, &tctx); - sha512_end ((unsigned char *) key, &tctx); + sha512_hash (pwd, pwd_len, &tctx); + sha512_end (key, &tctx); pwd = key; pwd_len = SHA512_DIGESTSIZE; @@ -506,10 +470,10 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 /* Pad the key for inner digest */ for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x36); + buf[b] = (unsigned char) (pwd[b] ^ 0x36); memset (&buf[pwd_len], 0x36, SHA512_BLOCKSIZE - pwd_len); - sha512_hash ((unsigned char *) buf, SHA512_BLOCKSIZE, ctx); + sha512_hash (buf, SHA512_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -517,10 +481,10 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 sha512_begin (ctx); for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x5C); + buf[b] = (unsigned char) (pwd[b] ^ 0x5C); memset (&buf[pwd_len], 0x5C, SHA512_BLOCKSIZE - pwd_len); - sha512_hash ((unsigned char *) buf, SHA512_BLOCKSIZE, ctx); + sha512_hash (buf, SHA512_BLOCKSIZE, ctx); /* first l - 1 blocks */ for (b = 1; b < l; b++) @@ -534,13 +498,9 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 derive_u_sha512 (salt, salt_len, iterations, b, &hmac); memcpy (dk, hmac.u, r); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent possible leaks. */ @@ -557,13 +517,13 @@ typedef struct hmac_blake2s_ctx_struct blake2s_state ctx; blake2s_state inner_digest_ctx; /*pre-computed inner digest context */ blake2s_state outer_digest_ctx; /*pre-computed outer digest context */ - char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Blake2s hash */ - char u[BLAKE2S_DIGESTSIZE]; + unsigned char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Blake2s hash */ + unsigned char u[BLAKE2S_DIGESTSIZE]; } hmac_blake2s_ctx; void hmac_blake2s_internal ( - char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ + unsigned char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ int ld, /* length of input data in bytes */ hmac_blake2s_ctx* hmac /* HMAC-BLAKE2S context which holds temporary variables */ ) @@ -576,7 +536,7 @@ void hmac_blake2s_internal blake2s_update (ctx, d, ld); - blake2s_final (ctx, (unsigned char*) d); /* d = inner digest */ + blake2s_final (ctx, d); /* d = inner digest */ /**** Restore Precomputed Outer Digest Context ****/ @@ -584,34 +544,28 @@ void hmac_blake2s_internal blake2s_update (ctx, d, BLAKE2S_DIGESTSIZE); - blake2s_final (ctx, (unsigned char *) d); /* d = outer digest */ + blake2s_final (ctx, d); /* d = outer digest */ } #ifndef TC_WINDOWS_BOOT void hmac_blake2s ( - char *k, /* secret key */ + unsigned char *k, /* secret key */ int lk, /* length of the key in bytes */ - char *d, /* data */ + unsigned char *d, /* data */ int ld /* length of data in bytes */ ) { hmac_blake2s_ctx hmac; blake2s_state* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b; - char key[BLAKE2S_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[BLAKE2S_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSE2()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the key is longer than the hash algorithm block size, let key = blake2s(key), as per HMAC specifications. */ @@ -621,7 +575,7 @@ void hmac_blake2s blake2s_init (&tctx); blake2s_update (&tctx, k, lk); - blake2s_final (&tctx, (unsigned char *) key); + blake2s_final (&tctx, key); k = key; lk = BLAKE2S_DIGESTSIZE; @@ -636,10 +590,10 @@ void hmac_blake2s /* Pad the key for inner digest */ for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x36); + buf[b] = (unsigned char) (k[b] ^ 0x36); memset (&buf[lk], 0x36, BLAKE2S_BLOCKSIZE - lk); - blake2s_update (ctx, (unsigned char *) buf, BLAKE2S_BLOCKSIZE); + blake2s_update (ctx, buf, BLAKE2S_BLOCKSIZE); /**** Precompute HMAC Outer Digest ****/ @@ -647,20 +601,16 @@ void hmac_blake2s blake2s_init (ctx); for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x5C); + buf[b] = (unsigned char) (k[b] ^ 0x5C); memset (&buf[lk], 0x5C, BLAKE2S_BLOCKSIZE - lk); - blake2s_update (ctx, (unsigned char *) buf, BLAKE2S_BLOCKSIZE); + blake2s_update (ctx, buf, BLAKE2S_BLOCKSIZE); hmac_blake2s_internal(d, ld, &hmac); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent leaks */ @@ -669,10 +619,10 @@ void hmac_blake2s } #endif -static void derive_u_blake2s (char *salt, int salt_len, uint32 iterations, int b, hmac_blake2s_ctx* hmac) +static void derive_u_blake2s (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_blake2s_ctx* hmac) { - char* k = hmac->k; - char* u = hmac->u; + unsigned char* k = hmac->k; + unsigned char* u = hmac->u; uint32 c; int i; @@ -698,7 +648,7 @@ static void derive_u_blake2s (char *salt, int salt_len, uint32 iterations, int b #ifdef TC_WINDOWS_BOOT /* specific case of 16-bit bootloader: b is a 16-bit integer that is always < 256 */ memset (&k[salt_len], 0, 3); - k[salt_len + 3] = (char) b; + k[salt_len + 3] = (unsigned char) b; #else b = bswap_32 (b); memcpy (&k[salt_len], &b, 4); @@ -720,25 +670,19 @@ static void derive_u_blake2s (char *salt, int salt_len, uint32 iterations, int b } -void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) +void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen) { hmac_blake2s_ctx hmac; blake2s_state* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b, l, r; #ifndef TC_WINDOWS_BOOT - char key[BLAKE2S_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) + unsigned char key[BLAKE2S_DIGESTSIZE]; +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; -#ifdef _WIN64 XSTATE_SAVE SaveState; if (IsCpuIntel() && HasSAVX()) - saveStatus = KeSaveExtendedProcessorStateVC(XSTATE_MASK_GSSE, &SaveState); -#else - KFLOATING_SAVE floatingPointState; - if (HasSSE2()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + saveStatus = KeSaveExtendedProcessorState(XSTATE_MASK_GSSE, &SaveState); #endif /* If the password is longer than the hash algorithm block size, let pwd = blake2s(pwd), as per HMAC specifications. */ @@ -748,7 +692,7 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3 blake2s_init (&tctx); blake2s_update (&tctx, pwd, pwd_len); - blake2s_final (&tctx, (unsigned char *) key); + blake2s_final (&tctx, key); pwd = key; pwd_len = BLAKE2S_DIGESTSIZE; @@ -775,7 +719,7 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3 /* Pad the key for inner digest */ for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x36); + buf[b] = (unsigned char) (pwd[b] ^ 0x36); memset (&buf[pwd_len], 0x36, BLAKE2S_BLOCKSIZE - pwd_len); blake2s_update (ctx, buf, BLAKE2S_BLOCKSIZE); @@ -786,7 +730,7 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3 blake2s_init (ctx); for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x5C); + buf[b] = (unsigned char) (pwd[b] ^ 0x5C); memset (&buf[pwd_len], 0x5C, BLAKE2S_BLOCKSIZE - pwd_len); blake2s_update (ctx, buf, BLAKE2S_BLOCKSIZE); @@ -803,13 +747,9 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3 derive_u_blake2s (salt, salt_len, iterations, b, &hmac); memcpy (dk, hmac.u, r); -#if defined (DEVICE_DRIVER) +#if defined (DEVICE_DRIVER) && !defined(_M_ARM64) if (NT_SUCCESS (saveStatus)) -#ifdef _WIN64 - KeRestoreExtendedProcessorStateVC(&SaveState); -#else - KeRestoreFloatingPointState (&floatingPointState); -#endif + KeRestoreExtendedProcessorState(&SaveState); #endif /* Prevent possible leaks. */ @@ -828,13 +768,13 @@ typedef struct hmac_whirlpool_ctx_struct WHIRLPOOL_CTX ctx; WHIRLPOOL_CTX inner_digest_ctx; /*pre-computed inner digest context */ WHIRLPOOL_CTX outer_digest_ctx; /*pre-computed outer digest context */ - CRYPTOPP_ALIGN_DATA(16) char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Whirlpool hash */ - char u[WHIRLPOOL_DIGESTSIZE]; + CRYPTOPP_ALIGN_DATA(16) unsigned char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Whirlpool hash */ + unsigned char u[WHIRLPOOL_DIGESTSIZE]; } hmac_whirlpool_ctx; void hmac_whirlpool_internal ( - char *d, /* input/output data. d pointer is guaranteed to be at least 64-bytes long */ + unsigned char *d, /* input/output data. d pointer is guaranteed to be at least 64-bytes long */ int ld, /* length of input data in bytes */ hmac_whirlpool_ctx* hmac /* HMAC-Whirlpool context which holds temporary variables */ ) @@ -845,38 +785,32 @@ void hmac_whirlpool_internal memcpy (ctx, &(hmac->inner_digest_ctx), sizeof (WHIRLPOOL_CTX)); - WHIRLPOOL_add ((unsigned char *) d, ld, ctx); + WHIRLPOOL_add (d, ld, ctx); - WHIRLPOOL_finalize (ctx, (unsigned char *) d); + WHIRLPOOL_finalize (ctx, d); /**** Restore Precomputed Outer Digest Context ****/ memcpy (ctx, &(hmac->outer_digest_ctx), sizeof (WHIRLPOOL_CTX)); - WHIRLPOOL_add ((unsigned char *) d, WHIRLPOOL_DIGESTSIZE, ctx); + WHIRLPOOL_add (d, WHIRLPOOL_DIGESTSIZE, ctx); - WHIRLPOOL_finalize (ctx, (unsigned char *) d); + WHIRLPOOL_finalize (ctx, d); } void hmac_whirlpool ( - char *k, /* secret key */ + unsigned char *k, /* secret key */ int lk, /* length of the key in bytes */ - char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ + unsigned char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ int ld /* length of data in bytes */ ) { hmac_whirlpool_ctx hmac; WHIRLPOOL_CTX* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b; - char key[WHIRLPOOL_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - KFLOATING_SAVE floatingPointState; - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - if (HasISSE()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + unsigned char key[WHIRLPOOL_DIGESTSIZE]; /* If the key is longer than the hash algorithm block size, let key = whirlpool(key), as per HMAC specifications. */ if (lk > WHIRLPOOL_BLOCKSIZE) @@ -884,8 +818,8 @@ void hmac_whirlpool WHIRLPOOL_CTX tctx; WHIRLPOOL_init (&tctx); - WHIRLPOOL_add ((unsigned char *) k, lk, &tctx); - WHIRLPOOL_finalize (&tctx, (unsigned char *) key); + WHIRLPOOL_add (k, lk, &tctx); + WHIRLPOOL_finalize (&tctx, key); k = key; lk = WHIRLPOOL_DIGESTSIZE; @@ -900,10 +834,10 @@ void hmac_whirlpool /* Pad the key for inner digest */ for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x36); + buf[b] = (unsigned char) (k[b] ^ 0x36); memset (&buf[lk], 0x36, WHIRLPOOL_BLOCKSIZE - lk); - WHIRLPOOL_add ((unsigned char *) buf, WHIRLPOOL_BLOCKSIZE, ctx); + WHIRLPOOL_add (buf, WHIRLPOOL_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -911,25 +845,21 @@ void hmac_whirlpool WHIRLPOOL_init (ctx); for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x5C); + buf[b] = (unsigned char) (k[b] ^ 0x5C); memset (&buf[lk], 0x5C, WHIRLPOOL_BLOCKSIZE - lk); - WHIRLPOOL_add ((unsigned char *) buf, WHIRLPOOL_BLOCKSIZE, ctx); + WHIRLPOOL_add (buf, WHIRLPOOL_BLOCKSIZE, ctx); hmac_whirlpool_internal(d, ld, &hmac); -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - if (NT_SUCCESS (saveStatus)) - KeRestoreFloatingPointState (&floatingPointState); -#endif /* Prevent leaks */ burn(&hmac, sizeof(hmac)); } -static void derive_u_whirlpool (char *salt, int salt_len, uint32 iterations, int b, hmac_whirlpool_ctx* hmac) +static void derive_u_whirlpool (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_whirlpool_ctx* hmac) { - char* u = hmac->u; - char* k = hmac->k; + unsigned char* u = hmac->u; + unsigned char* k = hmac->k; uint32 c, i; /* iteration 1 */ @@ -952,19 +882,13 @@ static void derive_u_whirlpool (char *salt, int salt_len, uint32 iterations, int } } -void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) +void derive_key_whirlpool (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen) { hmac_whirlpool_ctx hmac; WHIRLPOOL_CTX* ctx; - char* buf = hmac.k; - char key[WHIRLPOOL_DIGESTSIZE]; + unsigned char* buf = hmac.k; + unsigned char key[WHIRLPOOL_DIGESTSIZE]; int b, l, r; -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - KFLOATING_SAVE floatingPointState; - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - if (HasISSE()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif /* If the password is longer than the hash algorithm block size, let pwd = whirlpool(pwd), as per HMAC specifications. */ if (pwd_len > WHIRLPOOL_BLOCKSIZE) @@ -972,8 +896,8 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin WHIRLPOOL_CTX tctx; WHIRLPOOL_init (&tctx); - WHIRLPOOL_add ((unsigned char *) pwd, pwd_len, &tctx); - WHIRLPOOL_finalize (&tctx, (unsigned char *) key); + WHIRLPOOL_add (pwd, pwd_len, &tctx); + WHIRLPOOL_finalize (&tctx, key); pwd = key; pwd_len = WHIRLPOOL_DIGESTSIZE; @@ -999,10 +923,10 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin /* Pad the key for inner digest */ for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x36); + buf[b] = (unsigned char) (pwd[b] ^ 0x36); memset (&buf[pwd_len], 0x36, WHIRLPOOL_BLOCKSIZE - pwd_len); - WHIRLPOOL_add ((unsigned char *) buf, WHIRLPOOL_BLOCKSIZE, ctx); + WHIRLPOOL_add (buf, WHIRLPOOL_BLOCKSIZE, ctx); /**** Precompute HMAC Outer Digest ****/ @@ -1010,10 +934,10 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin WHIRLPOOL_init (ctx); for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x5C); + buf[b] = (unsigned char) (pwd[b] ^ 0x5C); memset (&buf[pwd_len], 0x5C, WHIRLPOOL_BLOCKSIZE - pwd_len); - WHIRLPOOL_add ((unsigned char *) buf, WHIRLPOOL_BLOCKSIZE, ctx); + WHIRLPOOL_add (buf, WHIRLPOOL_BLOCKSIZE, ctx); /* first l - 1 blocks */ for (b = 1; b < l; b++) @@ -1027,11 +951,6 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin derive_u_whirlpool (salt, salt_len, iterations, b, &hmac); memcpy (dk, hmac.u, r); -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - if (NT_SUCCESS (saveStatus)) - KeRestoreFloatingPointState (&floatingPointState); -#endif - /* Prevent possible leaks. */ burn (&hmac, sizeof(hmac)); burn (key, sizeof(key)); @@ -1043,13 +962,13 @@ typedef struct hmac_streebog_ctx_struct STREEBOG_CTX ctx; STREEBOG_CTX inner_digest_ctx; /*pre-computed inner digest context */ STREEBOG_CTX outer_digest_ctx; /*pre-computed outer digest context */ - CRYPTOPP_ALIGN_DATA(16) char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Streebog hash */ - char u[STREEBOG_DIGESTSIZE]; + CRYPTOPP_ALIGN_DATA(16) unsigned char k[PKCS5_SALT_SIZE + 4]; /* enough to hold (salt_len + 4) and also the Streebog hash */ + unsigned char u[STREEBOG_DIGESTSIZE]; } hmac_streebog_ctx; void hmac_streebog_internal ( - char *d, /* input/output data. d pointer is guaranteed to be at least 64-bytes long */ + unsigned char *d, /* input/output data. d pointer is guaranteed to be at least 64-bytes long */ int ld, /* length of input data in bytes */ hmac_streebog_ctx* hmac /* HMAC-Whirlpool context which holds temporary variables */ ) @@ -1060,38 +979,32 @@ void hmac_streebog_internal memcpy (ctx, &(hmac->inner_digest_ctx), sizeof (STREEBOG_CTX)); - STREEBOG_add (ctx, (unsigned char *) d, ld); + STREEBOG_add (ctx, d, ld); - STREEBOG_finalize (ctx, (unsigned char *) d); + STREEBOG_finalize (ctx, d); /**** Restore Precomputed Outer Digest Context ****/ memcpy (ctx, &(hmac->outer_digest_ctx), sizeof (STREEBOG_CTX)); - STREEBOG_add (ctx, (unsigned char *) d, STREEBOG_DIGESTSIZE); + STREEBOG_add (ctx, d, STREEBOG_DIGESTSIZE); - STREEBOG_finalize (ctx, (unsigned char *) d); + STREEBOG_finalize (ctx, d); } void hmac_streebog ( - char *k, /* secret key */ + unsigned char *k, /* secret key */ int lk, /* length of the key in bytes */ - char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ + unsigned char *d, /* input data. d pointer is guaranteed to be at least 32-bytes long */ int ld /* length of data in bytes */ ) { hmac_streebog_ctx hmac; STREEBOG_CTX* ctx; - char* buf = hmac.k; + unsigned char* buf = hmac.k; int b; - CRYPTOPP_ALIGN_DATA(16) char key[STREEBOG_DIGESTSIZE]; -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - KFLOATING_SAVE floatingPointState; - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - if (HasSSE2() || HasSSE41()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif + CRYPTOPP_ALIGN_DATA(16) unsigned char key[STREEBOG_DIGESTSIZE]; /* If the key is longer than the hash algorithm block size, let key = streebog(key), as per HMAC specifications. */ if (lk > STREEBOG_BLOCKSIZE) @@ -1099,8 +1012,8 @@ void hmac_streebog STREEBOG_CTX tctx; STREEBOG_init (&tctx); - STREEBOG_add (&tctx, (unsigned char *) k, lk); - STREEBOG_finalize (&tctx, (unsigned char *) key); + STREEBOG_add (&tctx, k, lk); + STREEBOG_finalize (&tctx, key); k = key; lk = STREEBOG_DIGESTSIZE; @@ -1115,10 +1028,10 @@ void hmac_streebog /* Pad the key for inner digest */ for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x36); + buf[b] = (unsigned char) (k[b] ^ 0x36); memset (&buf[lk], 0x36, STREEBOG_BLOCKSIZE - lk); - STREEBOG_add (ctx, (unsigned char *) buf, STREEBOG_BLOCKSIZE); + STREEBOG_add (ctx, buf, STREEBOG_BLOCKSIZE); /**** Precompute HMAC Outer Digest ****/ @@ -1126,25 +1039,21 @@ void hmac_streebog STREEBOG_init (ctx); for (b = 0; b < lk; ++b) - buf[b] = (char) (k[b] ^ 0x5C); + buf[b] = (unsigned char) (k[b] ^ 0x5C); memset (&buf[lk], 0x5C, STREEBOG_BLOCKSIZE - lk); - STREEBOG_add (ctx, (unsigned char *) buf, STREEBOG_BLOCKSIZE); + STREEBOG_add (ctx, buf, STREEBOG_BLOCKSIZE); hmac_streebog_internal(d, ld, &hmac); -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - if (NT_SUCCESS (saveStatus)) - KeRestoreFloatingPointState (&floatingPointState); -#endif /* Prevent leaks */ burn(&hmac, sizeof(hmac)); } -static void derive_u_streebog (char *salt, int salt_len, uint32 iterations, int b, hmac_streebog_ctx* hmac) +static void derive_u_streebog (const unsigned char *salt, int salt_len, uint32 iterations, int b, hmac_streebog_ctx* hmac) { - char* u = hmac->u; - char* k = hmac->k; + unsigned char* u = hmac->u; + unsigned char* k = hmac->k; uint32 c, i; /* iteration 1 */ @@ -1167,19 +1076,13 @@ static void derive_u_streebog (char *salt, int salt_len, uint32 iterations, int } } -void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen) +void derive_key_streebog (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen) { hmac_streebog_ctx hmac; STREEBOG_CTX* ctx; - char* buf = hmac.k; - char key[STREEBOG_DIGESTSIZE]; + unsigned char* buf = hmac.k; + unsigned char key[STREEBOG_DIGESTSIZE]; int b, l, r; -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - KFLOATING_SAVE floatingPointState; - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - if (HasSSE2() || HasSSE41()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif /* If the password is longer than the hash algorithm block size, let pwd = streebog(pwd), as per HMAC specifications. */ if (pwd_len > STREEBOG_BLOCKSIZE) @@ -1187,8 +1090,8 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint STREEBOG_CTX tctx; STREEBOG_init (&tctx); - STREEBOG_add (&tctx, (unsigned char *) pwd, pwd_len); - STREEBOG_finalize (&tctx, (unsigned char *) key); + STREEBOG_add (&tctx, pwd, pwd_len); + STREEBOG_finalize (&tctx, key); pwd = key; pwd_len = STREEBOG_DIGESTSIZE; @@ -1214,10 +1117,10 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint /* Pad the key for inner digest */ for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x36); + buf[b] = (unsigned char) (pwd[b] ^ 0x36); memset (&buf[pwd_len], 0x36, STREEBOG_BLOCKSIZE - pwd_len); - STREEBOG_add (ctx, (unsigned char *) buf, STREEBOG_BLOCKSIZE); + STREEBOG_add (ctx, buf, STREEBOG_BLOCKSIZE); /**** Precompute HMAC Outer Digest ****/ @@ -1225,10 +1128,10 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint STREEBOG_init (ctx); for (b = 0; b < pwd_len; ++b) - buf[b] = (char) (pwd[b] ^ 0x5C); + buf[b] = (unsigned char) (pwd[b] ^ 0x5C); memset (&buf[pwd_len], 0x5C, STREEBOG_BLOCKSIZE - pwd_len); - STREEBOG_add (ctx, (unsigned char *) buf, STREEBOG_BLOCKSIZE); + STREEBOG_add (ctx, buf, STREEBOG_BLOCKSIZE); /* first l - 1 blocks */ for (b = 1; b < l; b++) @@ -1242,11 +1145,6 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint derive_u_streebog (salt, salt_len, iterations, b, &hmac); memcpy (dk, hmac.u, r); -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - if (NT_SUCCESS (saveStatus)) - KeRestoreFloatingPointState (&floatingPointState); -#endif - /* Prevent possible leaks. */ burn (&hmac, sizeof(hmac)); burn (key, sizeof(key)); @@ -1278,53 +1176,49 @@ wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id) -int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot) +int get_pkcs5_iteration_count(int pkcs5_prf_id, int pim, BOOL bBoot) { - if ( (pim < 0) - ) - { - return 0; - } + int iteration_count = 0; - switch (pkcs5_prf_id) + if (pim >= 0) { - - case BLAKE2S: - if (pim == 0) - return bBoot? 200000 : 500000; - else - { - return bBoot? pim * 2048 : 15000 + pim * 1000; - } - - case SHA512: - return ((pim == 0)? 500000 : 15000 + pim * 1000); - - case WHIRLPOOL: - return ((pim == 0)? 500000 : 15000 + pim * 1000); - - case SHA256: - if (pim == 0) - return bBoot? 200000 : 500000; - else - { - return bBoot? pim * 2048 : 15000 + pim * 1000; - } - - case STREEBOG: - if (pim == 0) - return bBoot? 200000 : 500000; - else + switch (pkcs5_prf_id) { - return bBoot? pim * 2048 : 15000 + pim * 1000; + case BLAKE2S: + if (pim == 0) + iteration_count = bBoot ? 200000 : 500000; + else + iteration_count = bBoot ? pim * 2048 : 15000 + pim * 1000; + break; + + case SHA512: + iteration_count = (pim == 0) ? 500000 : 15000 + pim * 1000; + break; + + case WHIRLPOOL: + iteration_count = (pim == 0) ? 500000 : 15000 + pim * 1000; + break; + + case SHA256: + if (pim == 0) + iteration_count = bBoot ? 200000 : 500000; + else + iteration_count = bBoot ? pim * 2048 : 15000 + pim * 1000; + break; + + case STREEBOG: + if (pim == 0) + iteration_count = bBoot ? 200000 : 500000; + else + iteration_count = bBoot ? pim * 2048 : 15000 + pim * 1000; + break; + + default: + TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } - - default: - TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID } -#if _MSC_VER < 1900 - return 0; -#endif + + return iteration_count; } int is_pkcs5_prf_supported (int pkcs5_prf_id, PRF_BOOT_TYPE bootType) diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h index a9abeec5..65fad038 100644 --- a/src/Common/Pkcs5.h +++ b/src/Common/Pkcs5.h @@ -21,24 +21,24 @@ extern "C" { #endif /* output written to input_digest which must be at lease 32 bytes long */ -void hmac_blake2s (char *key, int keylen, char *input_digest, int len); -void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); +void hmac_blake2s (unsigned char *key, int keylen, unsigned char *input_digest, int len); +void derive_key_blake2s (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen); /* output written to d which must be at lease 32 bytes long */ -void hmac_sha256 (char *k, int lk, char *d, int ld); -void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); +void hmac_sha256 (unsigned char *k, int lk, unsigned char *d, int ld); +void derive_key_sha256 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen); #ifndef TC_WINDOWS_BOOT /* output written to d which must be at lease 64 bytes long */ -void hmac_sha512 (char *k, int lk, char *d, int ld); -void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); +void hmac_sha512 (unsigned char *k, int lk, unsigned char *d, int ld); +void derive_key_sha512 (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen); /* output written to d which must be at lease 64 bytes long */ -void hmac_whirlpool (char *k, int lk, char *d, int ld); -void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); +void hmac_whirlpool (unsigned char *k, int lk, unsigned char *d, int ld); +void derive_key_whirlpool (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen); -void hmac_streebog (char *k, int32 lk, char *d, int32 ld); -void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint32 iterations, char *dk, int dklen); +void hmac_streebog (unsigned char *k, int lk, unsigned char *d, int ld); +void derive_key_streebog (const unsigned char *pwd, int pwd_len, const unsigned char *salt, int salt_len, uint32 iterations, unsigned char *dk, int dklen); int get_pkcs5_iteration_count (int pkcs5_prf_id, int pim, BOOL bBoot); wchar_t *get_pkcs5_prf_name (int pkcs5_prf_id); diff --git a/src/Common/Progress.c b/src/Common/Progress.c index 2619b173..24efcad5 100644 --- a/src/Common/Progress.c +++ b/src/Common/Progress.c @@ -36,9 +36,9 @@ static wchar_t *seconds, *minutes, *hours, *days; // the speed of the "transform cursor"). void InitProgressBar (__int64 totalBytes, __int64 bytesDone, BOOL bReverse, BOOL bIOThroughput, BOOL bDisplayStatus, BOOL bShowPercent) { - HWND hProgressBar = GetDlgItem (hCurPage, nPbar); - SendMessage (hProgressBar, PBM_SETRANGE32, 0, 10000); - SendMessage (hProgressBar, PBM_SETSTEP, 1, 0); + HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar); + SendMessage (hCurProgressBar, PBM_SETRANGE32, 0, 10000); + SendMessage (hCurProgressBar, PBM_SETSTEP, 1, 0); bProgressBarReverse = bReverse; bRWThroughput = bIOThroughput; @@ -66,7 +66,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) { wchar_t text[100]; wchar_t speed[100]; - HWND hProgressBar = GetDlgItem (hCurPage, nPbar); + HWND hCurProgressBar = GetDlgItem (hCurPage, nPbar); int time = GetTickCount (); int elapsed = (time - startTime) / 1000; @@ -126,7 +126,7 @@ BOOL UpdateProgressBarProc (__int64 byteOffset) prevTime = time; - SendMessage (hProgressBar, PBM_SETPOS, + SendMessage (hCurProgressBar, PBM_SETPOS, (int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)), 0); diff --git a/src/Common/Random.c b/src/Common/Random.c index ee3fcf53..0cd6bfa0 100644 --- a/src/Common/Random.c +++ b/src/Common/Random.c @@ -19,6 +19,7 @@ #include "Crypto\jitterentropy.h" #include "Crypto\rdrand.h" #include <Strsafe.h> +#include <bcrypt.h> static unsigned __int8 buffer[RNG_POOL_SIZE]; static unsigned char *pRandPool = NULL; @@ -42,11 +43,7 @@ static HANDLE PeriodicFastPollThreadHandle = NULL; /* Macro to add four bytes to the pool */ #define RandaddInt32(x) RandAddInt((unsigned __int32)x); -#ifdef _WIN64 #define RandaddIntPtr(x) RandAddInt64((unsigned __int64)x); -#else -#define RandaddIntPtr(x) RandAddInt((unsigned __int32)x); -#endif void RandAddInt (unsigned __int32 x) { @@ -89,16 +86,17 @@ BOOL volatile bThreadTerminate = FALSE; /* This variable is shared among thread' HANDLE hNetAPI32 = NULL; // CryptoAPI -BOOL CryptoAPIAvailable = FALSE; DWORD CryptoAPILastError = ERROR_SUCCESS; -HCRYPTPROV hCryptProv; +typedef DWORD (WINAPI *RtlNtStatusToDosError_t)(NTSTATUS); +RtlNtStatusToDosError_t pRtlNtStatusToDosError = NULL; /* Init the random number generator, setup the hooks, and start the thread */ int RandinitWithCheck ( int* pAlreadyInitialized) { BOOL bIgnoreHookError = FALSE; DWORD dwLastError = ERROR_SUCCESS; + HMODULE ntdll; if (GetMaxPkcs5OutSize() > RNG_POOL_SIZE) TC_THROW_FATAL_EXCEPTION; @@ -143,14 +141,14 @@ int RandinitWithCheck ( int* pAlreadyInitialized) goto error; } - if (!CryptAcquireContext (&hCryptProv, NULL, MS_ENHANCED_PROV, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT)) - { - CryptoAPIAvailable = FALSE; - CryptoAPILastError = GetLastError (); + ntdll = GetModuleHandleW(L"ntdll.dll"); + if (!ntdll) { + // If ntdll.dll is not found, return a fallback error code + CryptoAPILastError = ERROR_MOD_NOT_FOUND; goto error; } else - CryptoAPIAvailable = TRUE; + pRtlNtStatusToDosError = (RtlNtStatusToDosError_t)GetProcAddress(ntdll, "RtlNtStatusToDosError"); if (!(PeriodicFastPollThreadHandle = (HANDLE) _beginthreadex (NULL, 0, PeriodicFastPollThreadProc, NULL, 0, NULL))) goto error; @@ -199,12 +197,6 @@ void RandStop (BOOL freePool) hNetAPI32 = NULL; } - if (CryptoAPIAvailable) - { - CryptReleaseContext (hCryptProv, 0); - CryptoAPIAvailable = FALSE; - CryptoAPILastError = ERROR_SUCCESS; - } hMouse = NULL; hKeyboard = NULL; @@ -675,6 +667,7 @@ BOOL SlowPoll (void) DWORD dwSize, status; LPWSTR lpszLanW, lpszLanS; int nDrive; + NTSTATUS bStatus = 0; /* Find out whether this is an NT server or workstation if necessary */ if (isWorkstation == -1) @@ -783,18 +776,16 @@ BOOL SlowPoll (void) CloseHandle (hDevice); } - // CryptoAPI: We always have a valid CryptoAPI context when we arrive here but - // we keep the check for clarity purpose - if ( !CryptoAPIAvailable ) - return FALSE; - if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) + + bStatus = BCryptGenRandom(NULL, buffer, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG); + if (NT_SUCCESS(bStatus)) { RandaddBuf (buffer, sizeof (buffer)); } else { - /* return error in case CryptGenRandom fails */ - CryptoAPILastError = GetLastError (); + /* return error in case BCryptGenRandom fails */ + CryptoAPILastError = pRtlNtStatusToDosError (bStatus); return FALSE; } @@ -838,6 +829,7 @@ BOOL FastPoll (void) MEMORYSTATUSEX memoryStatus; HANDLE handle; POINT point; + NTSTATUS bStatus = 0; /* Get various basic pieces of system information */ RandaddIntPtr (GetActiveWindow ()); /* Handle of active window */ @@ -928,18 +920,16 @@ BOOL FastPoll (void) RandaddBuf ((unsigned char *) &dwTicks, sizeof (dwTicks)); } - // CryptoAPI: We always have a valid CryptoAPI context when we arrive here but - // we keep the check for clarity purpose - if ( !CryptoAPIAvailable ) - return FALSE; - if (CryptGenRandom (hCryptProv, sizeof (buffer), buffer)) + + bStatus = BCryptGenRandom(NULL, buffer, sizeof(buffer), BCRYPT_USE_SYSTEM_PREFERRED_RNG); + if (NT_SUCCESS(bStatus)) { RandaddBuf (buffer, sizeof (buffer)); } else { - /* return error in case CryptGenRandom fails */ - CryptoAPILastError = GetLastError (); + /* return error in case BCryptGenRandom fails */ + CryptoAPILastError = pRtlNtStatusToDosError (bStatus); return FALSE; } diff --git a/src/Common/Resource.h b/src/Common/Resource.h index 0098542e..bc9fd94b 100644 --- a/src/Common/Resource.h +++ b/src/Common/Resource.h @@ -73,14 +73,7 @@ #define IDR_EFI_LEGACYSPEAKER 569 #define IDR_EFI_DCSBML 570 #define IDR_EFI_DCSRE 571 -#define IDR_EFI_DCSBOOT32 572 -#define IDR_EFI_DCSINT32 573 -#define IDR_EFI_DCSCFG32 574 -#define IDR_EFI_LEGACYSPEAKER32 575 -#define IDR_EFI_DCSBML32 576 -#define IDR_EFI_DCSRE32 577 #define IDR_EFI_DCSINFO 578 -#define IDR_EFI_DCSINFO32 579 #define IDC_HW_AES_LABEL_LINK 5000 #define IDC_HW_AES 5001 #define IDC_PARALLELIZATION_LABEL_LINK 5002 diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp index 2a8222e6..cd4926a0 100644 --- a/src/Common/SecurityToken.cpp +++ b/src/Common/SecurityToken.cpp @@ -220,7 +220,7 @@ namespace VeraCrypt throw; } - foreach(const CK_OBJECT_HANDLE & dataHandle, GetObjects(slotId, CKO_DATA)) + for(const CK_OBJECT_HANDLE & dataHandle: GetObjects(slotId, CKO_DATA)) { SecurityTokenKeyfile keyfile; keyfile.Handle = dataHandle; @@ -348,7 +348,7 @@ namespace VeraCrypt while (true) { CK_OBJECT_HANDLE object; - CK_RV status = Pkcs11Functions->C_FindObjects(Sessions[slotId].Handle, &object, 1, &objectCount); + status = Pkcs11Functions->C_FindObjects(Sessions[slotId].Handle, &object, 1, &objectCount); if (status != CKR_OK) throw Pkcs11Exception(status); diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h index 8e6750a4..0051dba2 100644 --- a/src/Common/Tcdefs.h +++ b/src/Common/Tcdefs.h @@ -59,7 +59,7 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift); #define TC_APP_NAME "VeraCrypt" // Version displayed to user -#define VERSION_STRING "1.26.15" +#define VERSION_STRING "1.26.17" #ifdef VC_EFI_CUSTOM_MODE #define VERSION_STRING_SUFFIX "-CustomEFI" @@ -73,9 +73,9 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift); #define VERSION_NUM 0x0126 // Release date -#define TC_STR_RELEASE_DATE L"September 2, 2024" +#define TC_STR_RELEASE_DATE L"November 24, 2024" #define TC_RELEASE_DATE_YEAR 2024 -#define TC_RELEASE_DATE_MONTH 9 +#define TC_RELEASE_DATE_MONTH 11 #define BYTES_PER_KB 1024LL #define BYTES_PER_MB 1048576LL @@ -157,6 +157,8 @@ typedef uint64 TC_LARGEST_COMPILER_UINT; #define TRUE 1 #endif +#define VC_CDECL + #endif // !_MSC_VER #define TC_INT_TYPES_DEFINED @@ -238,6 +240,9 @@ void ThrowFatalException(int line); || (defined(__GNUC__ ) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))) \ || (__has_builtin(__builtin_trap)) # define TC_THROW_FATAL_EXCEPTION __builtin_trap() +#elif defined(_MSC_VER) +#include <intrin.h> +# define TC_THROW_FATAL_EXCEPTION __fastfail(FAST_FAIL_FATAL_APP_EXIT) #else # define TC_THROW_FATAL_EXCEPTION *(char *) 0 = 0 #endif @@ -253,20 +258,10 @@ void ThrowFatalException(int line); #include <ntddk.h> /* Standard header file for nt drivers */ #include <ntdddisk.h> /* Standard I/O control codes */ -/* defines needed for using enhanced protection of NX pool under Windows 8 and later */ -#define NonPagedPoolNx 512 -#define MdlMappingNoExecute 0x40000000 -/* variables used in the implementation of enhanced protection of NX pool under Windows 8 and later */ -extern POOL_TYPE ExDefaultNonPagedPoolType; -extern ULONG ExDefaultMdlProtection; -#ifdef _WIN64 extern ULONG AllocTag; -#else -#define AllocTag 'MMCV' -#endif -#define TCalloc(size) ((void *) ExAllocatePoolWithTag( ExDefaultNonPagedPoolType, size, AllocTag )) +#define TCalloc(size) ((void *) ExAllocatePool2( POOL_FLAG_NON_PAGED, size, AllocTag )) #define TCfree(memblock) ExFreePoolWithTag( memblock, AllocTag ) #define DEVICE_DRIVER @@ -291,53 +286,6 @@ typedef unsigned char BOOLEAN; #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) diff --git a/src/Common/Tests.c b/src/Common/Tests.c index 530e7577..1f4178c6 100644 --- a/src/Common/Tests.c +++ b/src/Common/Tests.c @@ -567,19 +567,13 @@ unsigned long HexStringToByteArray(const char* hexStr, unsigned char* pbData) return count; } -BOOL RunHashTest (HashFunction fn, HashTestVector* vector, BOOL bUseSSE) +BOOL RunHashTest (HashFunction fn, HashTestVector* vector) { CRYPTOPP_ALIGN_DATA (16) unsigned char input[256]; unsigned char output[64]; unsigned char digest[64]; unsigned long i = 0, inputLen, outputLen, digestLen; BOOL bRet = TRUE; -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - KFLOATING_SAVE floatingPointState; - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - if (bUseSSE) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif while (vector[i].hexInput && vector[i].hexOutput) { inputLen = HexStringToByteArray (vector[i].hexInput, input); @@ -593,11 +587,6 @@ BOOL RunHashTest (HashFunction fn, HashTestVector* vector, BOOL bUseSSE) i++; } -#if defined (DEVICE_DRIVER) && !defined (_WIN64) - if (NT_SUCCESS (saveStatus)) - KeRestoreFloatingPointState (&floatingPointState); -#endif - return bRet; } @@ -651,7 +640,7 @@ HashTestVector Blake2sTestVectors[] = { unsigned char ks_tmp[MAX_EXPANDED_KEY]; -void CipherInit2(int cipher, void* key, void* ks, int key_len) +void CipherInit2(int cipher, void* key, void* ks) { switch (cipher) { @@ -736,10 +725,8 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) if (!EAInitMode (ci, key2)) return FALSE; -#ifdef _WIN64 if (IsRamEncryptionEnabled ()) VcProtectKeys (ci, VcGetEncryptionID (ci)); -#endif // Each data unit will contain the same plaintext for (i = 0; i < nbrUnits; i++) @@ -1307,7 +1294,7 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci) static BOOL DoAutoTestAlgorithms (void) { PCRYPTO_INFO ci; - CRYPTOPP_ALIGN_DATA(16) char key[32]; + CRYPTOPP_ALIGN_DATA(16) unsigned char key[32]; unsigned char tmp[16]; BOOL bFailed = FALSE; int i; @@ -1342,7 +1329,6 @@ static BOOL DoAutoTestAlgorithms (void) { uint8 testData[1024]; uint32 origCrc; - size_t i; for (i = 0; i < sizeof (testData); ++i) { @@ -1526,12 +1512,12 @@ BOOL test_hmac_sha256 () for (i = 0; i < sizeof (hmac_sha256_test_data) / sizeof(char *); i++) { - char digest[1024]; /* large enough to hold digets and test vector inputs */ + unsigned char digest[1024]; /* large enough to hold digets and test vector inputs */ size_t dataLen = strlen (hmac_sha256_test_data[i]); if (dataLen <= sizeof(digest)) { memcpy (digest, hmac_sha256_test_data[i], dataLen); - hmac_sha256 (hmac_sha256_test_keys[i], (int) strlen (hmac_sha256_test_keys[i]), digest, (int) dataLen); + hmac_sha256 ((unsigned char*) hmac_sha256_test_keys[i], (int) strlen (hmac_sha256_test_keys[i]), digest, (int) dataLen); if (memcmp (digest, hmac_sha256_test_vectors[i], SHA256_DIGESTSIZE) != 0) return FALSE; else @@ -1553,12 +1539,12 @@ BOOL test_hmac_sha512 () for (i = 0; i < sizeof (hmac_sha512_test_data) / sizeof(char *); i++) { - char digest[1024]; /* large enough to hold digets and test vector inputs */ + unsigned 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); + hmac_sha512 ((unsigned char*) 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 @@ -1581,12 +1567,12 @@ BOOL test_hmac_blake2s () for (i = 0; i < sizeof (hmac_blake2s_test_data) / sizeof(char *); i++) { - char digest[1024]; /* large enough to hold digets and test vector inputs */ + unsigned 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); + hmac_blake2s ((unsigned char*)(unsigned char*)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 @@ -1612,7 +1598,7 @@ 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)); + hmac_whirlpool ((unsigned char*) hmac_whirlpool_test_key, 64, digest, (int) strlen (hmac_whirlpool_test_data)); if (memcmp (digest, hmac_whirlpool_test_vectors, WHIRLPOOL_DIGESTSIZE) != 0) return FALSE; @@ -1646,10 +1632,10 @@ static const unsigned char gost3411_2012_hmac_r1[] = { #ifndef WOLFCRYPT_BACKEND BOOL test_hmac_streebog () { - CRYPTOPP_ALIGN_DATA(16) char digest[64]; /* large enough to hold digets and test vector inputs */ + CRYPTOPP_ALIGN_DATA(16) unsigned 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)); + hmac_streebog ((unsigned 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; @@ -1668,7 +1654,7 @@ int __cdecl StreebogHash (unsigned char* input, unsigned long inputLen, unsigned BOOL test_pkcs5 () { - char dk[144]; + unsigned char dk[144]; /* HMAC-SHA-256 tests */ if (!test_hmac_sha256()) @@ -1684,7 +1670,7 @@ BOOL test_pkcs5 () return FALSE; /* Blake2s hash tests */ - if (RunHashTest (Blake2sHash, Blake2sTestVectors, (HasSSE2())? TRUE : FALSE) == FALSE) + if (RunHashTest (Blake2sHash, Blake2sTestVectors) == FALSE) return FALSE; /* HMAC-Whirlpool tests */ @@ -1696,68 +1682,68 @@ BOOL test_pkcs5 () return FALSE; /* STREEBOG hash tests */ - if (RunHashTest (StreebogHash, Streebog512TestVectors, (HasSSE2() || HasSSE41())? TRUE : FALSE) == FALSE) + if (RunHashTest (StreebogHash, Streebog512TestVectors) == 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); + derive_key_sha256 ((unsigned char*) "passwd", 6, (unsigned char*) "\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); + derive_key_sha256 ((unsigned char*) "password", 8, (unsigned char*) "\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); + derive_key_sha256 ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_sha256 ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_sha512 ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_sha512 ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_blake2s ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_blake2s ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_whirlpool ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_whirlpool ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_streebog ((unsigned char*)"password", 8, (unsigned char*)"\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); + derive_key_streebog ((unsigned char*)"password", 8, (unsigned char*)"\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 diff --git a/src/Common/Tests.h b/src/Common/Tests.h index 356d54f4..bfdf7c40 100644 --- a/src/Common/Tests.h +++ b/src/Common/Tests.h @@ -17,7 +17,7 @@ extern "C" { extern unsigned char ks_tmp[MAX_EXPANDED_KEY]; -void CipherInit2(int cipher, void* key, void* ks, int key_len); +void CipherInit2(int cipher, void* key, void* ks); BOOL test_hmac_sha512 (void); BOOL test_hmac_blake2s (void); BOOL test_hmac_whirlpool (void); diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c index 7ee519f6..60d1b417 100644 --- a/src/Common/Volumes.c +++ b/src/Common/Volumes.c @@ -160,7 +160,7 @@ UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset) typedef struct { - char DerivedKey[MASTER_KEYDATA_SIZE]; + unsigned char DerivedKey[MASTER_KEYDATA_SIZE]; BOOL Free; LONG KeyReady; int Pkcs5Prf; @@ -169,15 +169,15 @@ typedef struct BOOL ReadVolumeHeaderRecoveryMode = FALSE; -int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) +int ReadVolumeHeader (BOOL bBoot, unsigned 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 header[TC_VOLUME_HEADER_EFFECTIVE_SIZE]; unsigned char* keyInfoBuffer = NULL; int keyInfoBufferSize = sizeof (KEY_INFO) + 16; size_t keyInfoBufferOffset; PKEY_INFO keyInfo; PCRYPTO_INFO cryptoInfo; - CRYPTOPP_ALIGN_DATA(16) char dk[MASTER_KEYDATA_SIZE]; + CRYPTOPP_ALIGN_DATA(16) unsigned char dk[MASTER_KEYDATA_SIZE]; int enqPkcs5Prf, pkcs5_prf; uint16 headerVersion; int status = ERR_PARAMETER_INCORRECT; @@ -559,21 +559,11 @@ KeyReady: ; #ifdef TC_WINDOWS_DRIVER { blake2s_state ctx; -#ifndef _WIN64 - NTSTATUS saveStatus = STATUS_INVALID_PARAMETER; - KFLOATING_SAVE floatingPointState; - if (HasSSE2()) - saveStatus = KeSaveFloatingPointState (&floatingPointState); -#endif blake2s_init (&ctx); blake2s_update (&ctx, keyInfo->master_keydata, MASTER_KEYDATA_SIZE); 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); @@ -704,12 +694,12 @@ void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoader #else // TC_WINDOWS_BOOT -int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo) +int ReadVolumeHeader (BOOL bBoot, unsigned 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 + unsigned char dk[32 * 2]; // 2 * 256-bit key #else - char dk[32 * 2 * 3]; // 6 * 256-bit key + unsigned char dk[32 * 2 * 3]; // 6 * 256-bit key #endif PCRYPTO_INFO cryptoInfo; @@ -882,18 +872,18 @@ ret: // Creates a volume header in memory #if defined(_UEFI) -int CreateVolumeHeaderInMemory(BOOL bBoot, char *header, int ea, int mode, Password *password, +int CreateVolumeHeaderInMemory(BOOL bBoot, unsigned char *header, 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) #else -int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea, int mode, Password *password, +int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, unsigned char *header, 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) #endif // !defined(_UEFI) { - unsigned char *p = (unsigned char *) header; + unsigned char *p = header; static CRYPTOPP_ALIGN_DATA(16) KEY_INFO keyInfo; int nUserKeyLen = password? password->Length : 0; diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h index daad25e3..07ed0fe8 100644 --- a/src/Common/Volumes.h +++ b/src/Common/Volumes.h @@ -133,20 +133,20 @@ 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); +int ReadVolumeHeader (BOOL bBoot, unsigned 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); +int ReadVolumeHeader(BOOL bBoot, unsigned char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); +int CreateVolumeHeaderInMemory(BOOL bBoot, unsigned 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); +int ReadVolumeHeader (BOOL bBoot, unsigned char *encryptedHeader, Password *password, int pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo); #if defined(_WIN32) && !defined(_UEFI) 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); +int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, unsigned 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, 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); diff --git a/src/Common/Wipe.c b/src/Common/Wipe.c index d68b517b..af3d15db 100644 --- a/src/Common/Wipe.c +++ b/src/Common/Wipe.c @@ -14,11 +14,6 @@ #include "Wipe.h" -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 @@ -173,7 +168,7 @@ BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_CO { case TC_WIPE_1_RAND: case TC_WIPE_256: - return Wipe1PseudoRandom (pass, buffer, size); + return FALSE; // Delegate buffer filling to the caller case TC_WIPE_3_DOD_5220: return Wipe3Dod5220 (pass, buffer, size); diff --git a/src/Common/Zip.vcxproj b/src/Common/Zip.vcxproj index 11a971b2..6674ef34 100644 --- a/src/Common/Zip.vcxproj +++ b/src/Common/Zip.vcxproj @@ -1,6 +1,10 @@ <?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|ARM64"> + <Configuration>Debug</Configuration> + <Platform>ARM64</Platform> + </ProjectConfiguration> <ProjectConfiguration Include="Debug|Win32"> <Configuration>Debug</Configuration> <Platform>Win32</Platform> @@ -9,6 +13,10 @@ <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> @@ -175,20 +183,29 @@ <ProjectGuid>{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}</ProjectGuid> <Keyword>Win32Proj</Keyword> <RootNamespace>Zip</RootNamespace> + <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> + <ProjectName>Zip</ProjectName> </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>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> + <WholeProgramOptimization>false</WholeProgramOptimization> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>true</UseDebugLibraries> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>true</UseDebugLibraries> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> <WholeProgramOptimization>false</WholeProgramOptimization> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> @@ -196,14 +213,21 @@ <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> + <ConfigurationType>StaticLibrary</ConfigurationType> + <UseDebugLibraries>false</UseDebugLibraries> + <WholeProgramOptimization>false</WholeProgramOptimization> + <CharacterSet>Unicode</CharacterSet> + <PlatformToolset>v143</PlatformToolset> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <ConfigurationType>StaticLibrary</ConfigurationType> <UseDebugLibraries>false</UseDebugLibraries> <WholeProgramOptimization>false</WholeProgramOptimization> <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>Windows7.1SDK</PlatformToolset> + <PlatformToolset>v143</PlatformToolset> </PropertyGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <ImportGroup Label="ExtensionSettings"> @@ -211,27 +235,45 @@ <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)\Zip\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(Platform)\$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\Zip\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\Zip\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\Zip\</IntDir> </PropertyGroup> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(Configuration)\</OutDir> + <OutDir>$(ProjectDir)$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Configuration)\Zip\</IntDir> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> + <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> + <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\Zip\</IntDir> </PropertyGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> @@ -247,6 +289,29 @@ <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> + <Link> + <SubSystem>Windows</SubSystem> + <GenerateDebugInformation>true</GenerateDebugInformation> + </Link> + <Lib> + <AdditionalDependencies> + </AdditionalDependencies> + </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> @@ -262,6 +327,10 @@ <SubSystem>Windows</SubSystem> <GenerateDebugInformation>true</GenerateDebugInformation> </Link> + <Lib> + <AdditionalDependencies> + </AdditionalDependencies> + </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> @@ -274,6 +343,31 @@ <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> @@ -281,6 +375,10 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> + <Lib> + <AdditionalDependencies> + </AdditionalDependencies> + </Lib> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <ClCompile> @@ -293,6 +391,7 @@ <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> @@ -300,6 +399,10 @@ <EnableCOMDATFolding>true</EnableCOMDATFolding> <OptimizeReferences>true</OptimizeReferences> </Link> + <Lib> + <AdditionalDependencies> + </AdditionalDependencies> + </Lib> </ItemDefinitionGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/src/Common/Zip.vcxproj.user b/src/Common/Zip.vcxproj.user index ace9a86a..88a55094 100644 --- a/src/Common/Zip.vcxproj.user +++ b/src/Common/Zip.vcxproj.user @@ -1,3 +1,4 @@ <?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup /> </Project>
\ No newline at end of file diff --git a/src/Common/Zip_vs2019.vcxproj b/src/Common/Zip_vs2019.vcxproj deleted file mode 100644 index b68dcab8..00000000 --- a/src/Common/Zip_vs2019.vcxproj +++ /dev/null @@ -1,410 +0,0 @@ -<?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|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="libzip\zip_add.c" /> - <ClCompile Include="libzip\zip_add_dir.c" /> - <ClCompile Include="libzip\zip_add_entry.c" /> - <ClCompile Include="libzip\zip_algorithm_deflate.c" /> - <ClCompile Include="libzip\zip_buffer.c" /> - <ClCompile Include="libzip\zip_close.c" /> - <ClCompile Include="libzip\zip_crypto_win.c" /> - <ClCompile Include="libzip\zip_delete.c" /> - <ClCompile Include="libzip\zip_dirent.c" /> - <ClCompile Include="libzip\zip_dir_add.c" /> - <ClCompile Include="libzip\zip_discard.c" /> - <ClCompile Include="libzip\zip_entry.c" /> - <ClCompile Include="libzip\zip_error.c" /> - <ClCompile Include="libzip\zip_error_clear.c" /> - <ClCompile Include="libzip\zip_error_get.c" /> - <ClCompile Include="libzip\zip_error_get_sys_type.c" /> - <ClCompile Include="libzip\zip_error_strerror.c" /> - <ClCompile Include="libzip\zip_error_to_str.c" /> - <ClCompile Include="libzip\zip_err_str.c" /> - <ClCompile Include="libzip\zip_extra_field.c" /> - <ClCompile Include="libzip\zip_extra_field_api.c" /> - <ClCompile Include="libzip\zip_fclose.c" /> - <ClCompile Include="libzip\zip_fdopen.c" /> - <ClCompile Include="libzip\zip_file_add.c" /> - <ClCompile Include="libzip\zip_file_error_clear.c" /> - <ClCompile Include="libzip\zip_file_error_get.c" /> - <ClCompile Include="libzip\zip_file_get_comment.c" /> - <ClCompile Include="libzip\zip_file_get_external_attributes.c" /> - <ClCompile Include="libzip\zip_file_get_offset.c" /> - <ClCompile Include="libzip\zip_file_rename.c" /> - <ClCompile Include="libzip\zip_file_replace.c" /> - <ClCompile Include="libzip\zip_file_set_comment.c" /> - <ClCompile Include="libzip\zip_file_set_encryption.c" /> - <ClCompile Include="libzip\zip_file_set_external_attributes.c" /> - <ClCompile Include="libzip\zip_file_set_mtime.c" /> - <ClCompile Include="libzip\zip_file_strerror.c" /> - <ClCompile Include="libzip\zip_fopen.c" /> - <ClCompile Include="libzip\zip_fopen_encrypted.c" /> - <ClCompile Include="libzip\zip_fopen_index.c" /> - <ClCompile Include="libzip\zip_fopen_index_encrypted.c" /> - <ClCompile Include="libzip\zip_fread.c" /> - <ClCompile Include="libzip\zip_fseek.c" /> - <ClCompile Include="libzip\zip_ftell.c" /> - <ClCompile Include="libzip\zip_get_archive_comment.c" /> - <ClCompile Include="libzip\zip_get_archive_flag.c" /> - <ClCompile Include="libzip\zip_get_encryption_implementation.c" /> - <ClCompile Include="libzip\zip_get_file_comment.c" /> - <ClCompile Include="libzip\zip_get_name.c" /> - <ClCompile Include="libzip\zip_get_num_entries.c" /> - <ClCompile Include="libzip\zip_get_num_files.c" /> - <ClCompile Include="libzip\zip_hash.c" /> - <ClCompile Include="libzip\zip_io_util.c" /> - <ClCompile Include="libzip\zip_libzip_version.c" /> - <ClCompile Include="libzip\zip_memdup.c" /> - <ClCompile Include="libzip\zip_name_locate.c" /> - <ClCompile Include="libzip\zip_new.c" /> - <ClCompile Include="libzip\zip_open.c" /> - <ClCompile Include="libzip\zip_pkware.c" /> - <ClCompile Include="libzip\zip_progress.c" /> - <ClCompile Include="libzip\zip_random_win32.c" /> - <ClCompile Include="libzip\zip_rename.c" /> - <ClCompile Include="libzip\zip_replace.c" /> - <ClCompile Include="libzip\zip_set_archive_comment.c" /> - <ClCompile Include="libzip\zip_set_archive_flag.c" /> - <ClCompile Include="libzip\zip_set_default_password.c" /> - <ClCompile Include="libzip\zip_set_file_comment.c" /> - <ClCompile Include="libzip\zip_set_file_compression.c" /> - <ClCompile Include="libzip\zip_set_name.c" /> - <ClCompile Include="libzip\zip_source_accept_empty.c" /> - <ClCompile Include="libzip\zip_source_begin_write.c" /> - <ClCompile Include="libzip\zip_source_begin_write_cloning.c" /> - <ClCompile Include="libzip\zip_source_buffer.c" /> - <ClCompile Include="libzip\zip_source_call.c" /> - <ClCompile Include="libzip\zip_source_close.c" /> - <ClCompile Include="libzip\zip_source_commit_write.c" /> - <ClCompile Include="libzip\zip_source_compress.c" /> - <ClCompile Include="libzip\zip_source_crc.c" /> - <ClCompile Include="libzip\zip_source_error.c" /> - <ClCompile Include="libzip\zip_source_file_common.c" /> - <ClCompile Include="libzip\zip_source_file_stdio.c" /> - <ClCompile Include="libzip\zip_source_file_win32.c" /> - <ClCompile Include="libzip\zip_source_file_win32_ansi.c" /> - <ClCompile Include="libzip\zip_source_file_win32_named.c" /> - <ClCompile Include="libzip\zip_source_file_win32_utf16.c" /> - <ClCompile Include="libzip\zip_source_file_win32_utf8.c" /> - <ClCompile Include="libzip\zip_source_free.c" /> - <ClCompile Include="libzip\zip_source_function.c" /> - <ClCompile Include="libzip\zip_source_get_file_attributes.c" /> - <ClCompile Include="libzip\zip_source_is_deleted.c" /> - <ClCompile Include="libzip\zip_source_layered.c" /> - <ClCompile Include="libzip\zip_source_open.c" /> - <ClCompile Include="libzip\zip_source_pass_to_lower_layer.c" /> - <ClCompile Include="libzip\zip_source_pkware_decode.c" /> - <ClCompile Include="libzip\zip_source_pkware_encode.c" /> - <ClCompile Include="libzip\zip_source_read.c" /> - <ClCompile Include="libzip\zip_source_remove.c" /> - <ClCompile Include="libzip\zip_source_rollback_write.c" /> - <ClCompile Include="libzip\zip_source_seek.c" /> - <ClCompile Include="libzip\zip_source_seek_write.c" /> - <ClCompile Include="libzip\zip_source_stat.c" /> - <ClCompile Include="libzip\zip_source_supports.c" /> - <ClCompile Include="libzip\zip_source_tell.c" /> - <ClCompile Include="libzip\zip_source_tell_write.c" /> - <ClCompile Include="libzip\zip_source_window.c" /> - <ClCompile Include="libzip\zip_source_winzip_aes_decode.c" /> - <ClCompile Include="libzip\zip_source_winzip_aes_encode.c" /> - <ClCompile Include="libzip\zip_source_write.c" /> - <ClCompile Include="libzip\zip_source_zip.c" /> - <ClCompile Include="libzip\zip_source_zip_new.c" /> - <ClCompile Include="libzip\zip_stat.c" /> - <ClCompile Include="libzip\zip_stat_index.c" /> - <ClCompile Include="libzip\zip_stat_init.c" /> - <ClCompile Include="libzip\zip_strerror.c" /> - <ClCompile Include="libzip\zip_string.c" /> - <ClCompile Include="libzip\zip_unchange.c" /> - <ClCompile Include="libzip\zip_unchange_all.c" /> - <ClCompile Include="libzip\zip_unchange_archive.c" /> - <ClCompile Include="libzip\zip_unchange_data.c" /> - <ClCompile Include="libzip\zip_utf-8.c" /> - <ClCompile Include="libzip\zip_winzip_aes.c" /> - <ClCompile Include="zlib\adler32.c" /> - <ClCompile Include="zlib\compress.c" /> - <ClCompile Include="zlib\crc32.c" /> - <ClCompile Include="zlib\deflate.c" /> - <ClCompile Include="zlib\inffast.c" /> - <ClCompile Include="zlib\inflate.c" /> - <ClCompile Include="zlib\inftrees.c" /> - <ClCompile Include="zlib\trees.c" /> - <ClCompile Include="zlib\uncompr.c" /> - <ClCompile Include="zlib\zutil.c" /> - </ItemGroup> - <ItemGroup> - <ClInclude Include="libzip\compat.h" /> - <ClInclude Include="libzip\config.h" /> - <ClInclude Include="libzip\zconf.h" /> - <ClInclude Include="libzip\zip.h" /> - <ClInclude Include="libzip\zipconf.h" /> - <ClInclude Include="libzip\zipint.h" /> - <ClInclude Include="libzip\zip_source_file.h" /> - <ClInclude Include="libzip\zip_source_file_stdio.h" /> - <ClInclude Include="libzip\zip_source_file_win32.h" /> - <ClInclude Include="zlib\crc32.h" /> - <ClInclude Include="zlib\deflate.h" /> - <ClInclude Include="zlib\inffast.h" /> - <ClInclude Include="zlib\inffixed.h" /> - <ClInclude Include="zlib\inflate.h" /> - <ClInclude Include="zlib\inftrees.h" /> - <ClInclude Include="zlib\trees.h" /> - <ClInclude Include="zlib\zconf.h" /> - <ClInclude Include="zlib\zlib.h" /> - <ClInclude Include="zlib\zutil.h" /> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>{6316EE71-0210-4CA4-BCC7-CFB7A3C090FC}</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <RootNamespace>Zip</RootNamespace> - <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion> - <ProjectName>Zip</ProjectName> - </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|ARM64'" 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)'=='Release|Win32'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v142</PlatformToolset> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="Configuration"> - <ConfigurationType>StaticLibrary</ConfigurationType> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>false</WholeProgramOptimization> - <CharacterSet>Unicode</CharacterSet> - <PlatformToolset>v142</PlatformToolset> - </PropertyGroup> - <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>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> - <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> - <OutDir>$(ProjectDir)$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'"> - <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> - <OutDir>$(ProjectDir)$(Configuration)\</OutDir> - <IntDir>$(ProjectDir)$(Configuration)\</IntDir> - </PropertyGroup> - <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'"> - <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> - <Link> - <SubSystem>Windows</SubSystem> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - <Lib> - <AdditionalDependencies> - </AdditionalDependencies> - </Lib> - </ItemDefinitionGroup> - <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/Zip_vs2019.vcxproj.user b/src/Common/Zip_vs2019.vcxproj.user deleted file mode 100644 index 88a55094..00000000 --- a/src/Common/Zip_vs2019.vcxproj.user +++ /dev/null @@ -1,4 +0,0 @@ -<?xml version="1.0" encoding="utf-8"?> -<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <PropertyGroup /> -</Project>
\ No newline at end of file |