VeraCrypt
aboutsummaryrefslogtreecommitdiff
path: root/src/Common
diff options
context:
space:
mode:
Diffstat (limited to 'src/Common')
-rw-r--r--src/Common/Apidrvr.h21
-rw-r--r--src/Common/BaseCom.cpp4
-rw-r--r--src/Common/BaseCom.h2
-rw-r--r--src/Common/BootEncryption.cpp391
-rw-r--r--src/Common/BootEncryption.h64
-rw-r--r--src/Common/Cache.c38
-rw-r--r--src/Common/Cache.h6
-rw-r--r--src/Common/Cmdline.c11
-rw-r--r--src/Common/Cmdline.h2
-rw-r--r--src/Common/Combo.c2
-rw-r--r--src/Common/Combo.h2
-rw-r--r--src/Common/CommandAPDU.cpp66
-rw-r--r--src/Common/CommandAPDU.h32
-rw-r--r--src/Common/Common.h2
-rw-r--r--src/Common/Common.rc15
-rw-r--r--src/Common/Crc.c2
-rw-r--r--src/Common/Crc.h2
-rw-r--r--src/Common/Crypto.c176
-rw-r--r--src/Common/Crypto.h18
-rw-r--r--src/Common/Dictionary.c2
-rw-r--r--src/Common/Dictionary.h2
-rw-r--r--src/Common/Dlgcode.c854
-rw-r--r--src/Common/Dlgcode.h42
-rw-r--r--src/Common/EMVCard.cpp54
-rw-r--r--src/Common/EMVCard.h22
-rw-r--r--src/Common/EMVToken.cpp10
-rw-r--r--src/Common/EMVToken.h4
-rw-r--r--src/Common/EncryptionThreadPool.c22
-rw-r--r--src/Common/EncryptionThreadPool.h6
-rw-r--r--src/Common/Endian.c2
-rw-r--r--src/Common/Endian.h2
-rw-r--r--src/Common/Exception.h2
-rw-r--r--src/Common/Fat.c4
-rw-r--r--src/Common/Fat.h4
-rw-r--r--src/Common/Format.c44
-rw-r--r--src/Common/Format.h2
-rw-r--r--src/Common/GfMul.c6
-rw-r--r--src/Common/Keyfiles.c8
-rw-r--r--src/Common/Keyfiles.h2
-rw-r--r--src/Common/Language.c58
-rw-r--r--src/Common/Language.h2
-rw-r--r--src/Common/Language.xml159
-rw-r--r--src/Common/Lzma.vcxproj93
-rw-r--r--src/Common/Lzma_vs2019.vcxproj247
-rw-r--r--src/Common/Lzma_vs2019.vcxproj.filters87
-rw-r--r--src/Common/Lzma_vs2019.vcxproj.user3
-rw-r--r--src/Common/Password.c8
-rw-r--r--src/Common/Password.h2
-rw-r--r--src/Common/Pkcs5.c512
-rw-r--r--src/Common/Pkcs5.h22
-rw-r--r--src/Common/Progress.c12
-rw-r--r--src/Common/Progress.h2
-rw-r--r--src/Common/Random.c103
-rw-r--r--src/Common/Random.h2
-rw-r--r--src/Common/Registry.c2
-rw-r--r--src/Common/Registry.h2
-rw-r--r--src/Common/Resource.h7
-rw-r--r--src/Common/ResponseAPDU.cpp32
-rw-r--r--src/Common/ResponseAPDU.h18
-rw-r--r--src/Common/SCard.cpp2
-rw-r--r--src/Common/SCardLoader.cpp4
-rw-r--r--src/Common/SCardLoader.h9
-rw-r--r--src/Common/SCardReader.cpp22
-rw-r--r--src/Common/SCardReader.h114
-rw-r--r--src/Common/SecurityToken.cpp22
-rw-r--r--src/Common/SecurityToken.h10
-rw-r--r--src/Common/TLVParser.cpp20
-rw-r--r--src/Common/TLVParser.h14
-rw-r--r--src/Common/Tcdefs.h94
-rw-r--r--src/Common/Tests.c98
-rw-r--r--src/Common/Tests.h4
-rw-r--r--src/Common/Token.h2
-rw-r--r--src/Common/Volumes.c131
-rw-r--r--src/Common/Volumes.h24
-rw-r--r--src/Common/Wipe.c23
-rw-r--r--src/Common/Wipe.h4
-rw-r--r--src/Common/Xml.c2
-rw-r--r--src/Common/Xml.h2
-rw-r--r--src/Common/Xts.c12
-rw-r--r--src/Common/Xts.h2
-rw-r--r--src/Common/Zip.vcxproj120
-rw-r--r--src/Common/Zip.vcxproj.filters3
-rw-r--r--src/Common/Zip.vcxproj.user3
-rw-r--r--src/Common/Zip_vs2019.vcxproj401
-rw-r--r--src/Common/Zip_vs2019.vcxproj.user4
-rw-r--r--src/Common/libzip/NEWS.md17
-rw-r--r--src/Common/libzip/compat.h78
-rw-r--r--src/Common/libzip/config.h6
-rw-r--r--src/Common/libzip/zip.h6
-rw-r--r--src/Common/libzip/zip_add.c2
-rw-r--r--src/Common/libzip/zip_add_dir.c2
-rw-r--r--src/Common/libzip/zip_add_entry.c4
-rw-r--r--src/Common/libzip/zip_algorithm_bzip2.c2
-rw-r--r--src/Common/libzip/zip_algorithm_deflate.c2
-rw-r--r--src/Common/libzip/zip_algorithm_xz.c2
-rw-r--r--src/Common/libzip/zip_algorithm_zstd.c2
-rw-r--r--src/Common/libzip/zip_buffer.c5
-rw-r--r--src/Common/libzip/zip_close.c45
-rw-r--r--src/Common/libzip/zip_crypto.h2
-rw-r--r--src/Common/libzip/zip_crypto_commoncrypto.c2
-rw-r--r--src/Common/libzip/zip_crypto_commoncrypto.h2
-rw-r--r--src/Common/libzip/zip_crypto_gnutls.c2
-rw-r--r--src/Common/libzip/zip_crypto_gnutls.h2
-rw-r--r--src/Common/libzip/zip_crypto_mbedtls.c2
-rw-r--r--src/Common/libzip/zip_crypto_mbedtls.h2
-rw-r--r--src/Common/libzip/zip_crypto_openssl.c13
-rw-r--r--src/Common/libzip/zip_crypto_openssl.h2
-rw-r--r--src/Common/libzip/zip_crypto_win.c5
-rw-r--r--src/Common/libzip/zip_crypto_win.h2
-rw-r--r--src/Common/libzip/zip_delete.c2
-rw-r--r--src/Common/libzip/zip_dir_add.c2
-rw-r--r--src/Common/libzip/zip_dirent.c202
-rw-r--r--src/Common/libzip/zip_discard.c2
-rw-r--r--src/Common/libzip/zip_entry.c2
-rw-r--r--src/Common/libzip/zip_err_str.c6
-rw-r--r--src/Common/libzip/zip_error.c2
-rw-r--r--src/Common/libzip/zip_error_clear.c2
-rw-r--r--src/Common/libzip/zip_error_get.c2
-rw-r--r--src/Common/libzip/zip_error_get_sys_type.c2
-rw-r--r--src/Common/libzip/zip_error_strerror.c14
-rw-r--r--src/Common/libzip/zip_error_to_str.c2
-rw-r--r--src/Common/libzip/zip_extra_field.c2
-rw-r--r--src/Common/libzip/zip_extra_field_api.c6
-rw-r--r--src/Common/libzip/zip_fclose.c2
-rw-r--r--src/Common/libzip/zip_fdopen.c2
-rw-r--r--src/Common/libzip/zip_file_add.c2
-rw-r--r--src/Common/libzip/zip_file_error_clear.c2
-rw-r--r--src/Common/libzip/zip_file_error_get.c2
-rw-r--r--src/Common/libzip/zip_file_get_comment.c2
-rw-r--r--src/Common/libzip/zip_file_get_external_attributes.c2
-rw-r--r--src/Common/libzip/zip_file_get_offset.c2
-rw-r--r--src/Common/libzip/zip_file_rename.c2
-rw-r--r--src/Common/libzip/zip_file_replace.c8
-rw-r--r--src/Common/libzip/zip_file_set_comment.c2
-rw-r--r--src/Common/libzip/zip_file_set_encryption.c2
-rw-r--r--src/Common/libzip/zip_file_set_external_attributes.c2
-rw-r--r--src/Common/libzip/zip_file_set_mtime.c40
-rw-r--r--src/Common/libzip/zip_file_strerror.c2
-rw-r--r--src/Common/libzip/zip_fopen.c2
-rw-r--r--src/Common/libzip/zip_fopen_encrypted.c2
-rw-r--r--src/Common/libzip/zip_fopen_index.c2
-rw-r--r--src/Common/libzip/zip_fopen_index_encrypted.c2
-rw-r--r--src/Common/libzip/zip_fread.c8
-rw-r--r--src/Common/libzip/zip_fseek.c10
-rw-r--r--src/Common/libzip/zip_ftell.c8
-rw-r--r--src/Common/libzip/zip_get_archive_comment.c2
-rw-r--r--src/Common/libzip/zip_get_archive_flag.c2
-rw-r--r--src/Common/libzip/zip_get_encryption_implementation.c2
-rw-r--r--src/Common/libzip/zip_get_file_comment.c2
-rw-r--r--src/Common/libzip/zip_get_name.c2
-rw-r--r--src/Common/libzip/zip_get_num_entries.c2
-rw-r--r--src/Common/libzip/zip_get_num_files.c2
-rw-r--r--src/Common/libzip/zip_hash.c2
-rw-r--r--src/Common/libzip/zip_io_util.c10
-rw-r--r--src/Common/libzip/zip_libzip_version.c2
-rw-r--r--src/Common/libzip/zip_memdup.c4
-rw-r--r--src/Common/libzip/zip_new.c5
-rw-r--r--src/Common/libzip/zip_open.c491
-rw-r--r--src/Common/libzip/zip_pkware.c2
-rw-r--r--src/Common/libzip/zip_progress.c4
-rw-r--r--src/Common/libzip/zip_random_unix.c2
-rw-r--r--src/Common/libzip/zip_random_uwp.c2
-rw-r--r--src/Common/libzip/zip_random_win32.c2
-rw-r--r--src/Common/libzip/zip_rename.c2
-rw-r--r--src/Common/libzip/zip_replace.c2
-rw-r--r--src/Common/libzip/zip_set_archive_comment.c2
-rw-r--r--src/Common/libzip/zip_set_archive_flag.c2
-rw-r--r--src/Common/libzip/zip_set_default_password.c2
-rw-r--r--src/Common/libzip/zip_set_file_comment.c2
-rw-r--r--src/Common/libzip/zip_set_file_compression.c2
-rw-r--r--src/Common/libzip/zip_set_name.c2
-rw-r--r--src/Common/libzip/zip_source_accept_empty.c2
-rw-r--r--src/Common/libzip/zip_source_begin_write.c2
-rw-r--r--src/Common/libzip/zip_source_begin_write_cloning.c2
-rw-r--r--src/Common/libzip/zip_source_buffer.c2
-rw-r--r--src/Common/libzip/zip_source_call.c2
-rw-r--r--src/Common/libzip/zip_source_close.c2
-rw-r--r--src/Common/libzip/zip_source_commit_write.c2
-rw-r--r--src/Common/libzip/zip_source_compress.c2
-rw-r--r--src/Common/libzip/zip_source_crc.c2
-rw-r--r--src/Common/libzip/zip_source_error.c2
-rw-r--r--src/Common/libzip/zip_source_file.h7
-rw-r--r--src/Common/libzip/zip_source_file_common.c2
-rw-r--r--src/Common/libzip/zip_source_file_stdio.c12
-rw-r--r--src/Common/libzip/zip_source_file_stdio.h2
-rw-r--r--src/Common/libzip/zip_source_file_stdio_named.c14
-rw-r--r--src/Common/libzip/zip_source_file_win32.c2
-rw-r--r--src/Common/libzip/zip_source_file_win32.h11
-rw-r--r--src/Common/libzip/zip_source_file_win32_ansi.c69
-rw-r--r--src/Common/libzip/zip_source_file_win32_named.c29
-rw-r--r--src/Common/libzip/zip_source_file_win32_utf16.c65
-rw-r--r--src/Common/libzip/zip_source_file_win32_utf8.c2
-rw-r--r--src/Common/libzip/zip_source_free.c2
-rw-r--r--src/Common/libzip/zip_source_get_dostime.c72
-rw-r--r--src/Common/libzip/zip_source_get_file_attributes.c2
-rw-r--r--src/Common/libzip/zip_source_is_deleted.c2
-rw-r--r--src/Common/libzip/zip_source_layered.c2
-rw-r--r--src/Common/libzip/zip_source_open.c2
-rw-r--r--src/Common/libzip/zip_source_pass_to_lower_layer.c4
-rw-r--r--src/Common/libzip/zip_source_pkware_decode.c43
-rw-r--r--src/Common/libzip/zip_source_pkware_encode.c63
-rw-r--r--src/Common/libzip/zip_source_read.c2
-rw-r--r--src/Common/libzip/zip_source_remove.c2
-rw-r--r--src/Common/libzip/zip_source_rollback_write.c2
-rw-r--r--src/Common/libzip/zip_source_seek.c2
-rw-r--r--src/Common/libzip/zip_source_seek_write.c2
-rw-r--r--src/Common/libzip/zip_source_stat.c2
-rw-r--r--src/Common/libzip/zip_source_supports.c2
-rw-r--r--src/Common/libzip/zip_source_tell.c2
-rw-r--r--src/Common/libzip/zip_source_tell_write.c2
-rw-r--r--src/Common/libzip/zip_source_window.c30
-rw-r--r--src/Common/libzip/zip_source_winzip_aes_decode.c2
-rw-r--r--src/Common/libzip/zip_source_winzip_aes_encode.c2
-rw-r--r--src/Common/libzip/zip_source_write.c2
-rw-r--r--src/Common/libzip/zip_source_zip.c2
-rw-r--r--src/Common/libzip/zip_source_zip_new.c11
-rw-r--r--src/Common/libzip/zip_stat.c2
-rw-r--r--src/Common/libzip/zip_stat_index.c12
-rw-r--r--src/Common/libzip/zip_stat_init.c2
-rw-r--r--src/Common/libzip/zip_strerror.c2
-rw-r--r--src/Common/libzip/zip_string.c22
-rw-r--r--src/Common/libzip/zip_unchange_all.c2
-rw-r--r--src/Common/libzip/zip_unchange_archive.c2
-rw-r--r--src/Common/libzip/zip_unchange_data.c2
-rw-r--r--src/Common/libzip/zip_utf-8.c146
-rw-r--r--src/Common/libzip/zip_winzip_aes.c2
-rw-r--r--src/Common/libzip/zipconf.h6
-rw-r--r--src/Common/libzip/zipint.h54
-rw-r--r--src/Common/lzma/7zTypes.h14
-rw-r--r--src/Common/lzma/Alloc.c174
-rw-r--r--src/Common/lzma/Alloc.h15
-rw-r--r--src/Common/lzma/Compiler.h91
-rw-r--r--src/Common/lzma/CpuArch.c217
-rw-r--r--src/Common/lzma/CpuArch.h177
-rw-r--r--src/Common/lzma/LzFind.c127
-rw-r--r--src/Common/lzma/LzFind.h5
-rw-r--r--src/Common/lzma/LzFindMt.c58
-rw-r--r--src/Common/lzma/LzFindMt.h9
-rw-r--r--src/Common/lzma/LzmaEnc.c40
-rw-r--r--src/Common/lzma/Precomp.h123
-rw-r--r--src/Common/lzma/Threads.c53
-rw-r--r--src/Common/lzma/Threads.h20
-rw-r--r--src/Common/lzma/lzma-history.txt74
-rw-r--r--src/Common/lzma/lzma-sdk.txt17
-rw-r--r--src/Common/zlib/ChangeLog1618
-rw-r--r--src/Common/zlib/README6
-rw-r--r--src/Common/zlib/deflate.c47
-rw-r--r--src/Common/zlib/deflate.h35
-rw-r--r--src/Common/zlib/gzguts.h8
-rw-r--r--src/Common/zlib/gzlib.c12
-rw-r--r--src/Common/zlib/inflate.c2
-rw-r--r--src/Common/zlib/inftrees.c6
-rw-r--r--src/Common/zlib/inftrees.h4
-rw-r--r--src/Common/zlib/trees.c20
-rw-r--r--src/Common/zlib/zconf.h10
-rw-r--r--src/Common/zlib/zlib.h22
-rw-r--r--src/Common/zlib/zutil.h27
257 files changed, 5953 insertions, 3416 deletions
diff --git a/src/Common/Apidrvr.h b/src/Common/Apidrvr.h
index 463d4fa6..84a3de91 100644
--- a/src/Common/Apidrvr.h
+++ b/src/Common/Apidrvr.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#pragma once
@@ -40,15 +40,15 @@
// IN OUT - MOUNT_STRUCT
#define TC_IOCTL_MOUNT_VOLUME TC_IOCTL (3)
// Dismount volume
// IN OUT - UNMOUNT_STRUCT
-#define TC_IOCTL_DISMOUNT_VOLUME TC_IOCTL (4)
+#define TC_IOCTL_UNMOUNT_VOLUME TC_IOCTL (4)
// Dismount all volumes
// IN OUT - UNMOUNT_STRUCT
-#define TC_IOCTL_DISMOUNT_ALL_VOLUMES TC_IOCTL (5)
+#define TC_IOCTL_UNMOUNT_ALL_VOLUMES TC_IOCTL (5)
// Get list of all mounted volumes
// IN OUT - MOUNT_LIST_STRUCT (only 26 volumes possible)
#define TC_IOCTL_GET_MOUNTED_VOLUMES TC_IOCTL (6)
@@ -175,10 +175,11 @@ typedef struct
BOOL bDriverSetLabel;
BOOL bCachePim;
ULONG MaximumTransferLength;
ULONG MaximumPhysicalPages;
ULONG AlignmentMask;
+ BOOL VolumeMasterKeyVulnerable;
} MOUNT_STRUCT;
typedef struct
{
int nDosDriveNo; /* Drive letter to unmount */
@@ -314,10 +315,12 @@ typedef struct
// Number of times the filter driver answered that an unencrypted volume
// is read-only (or mounted an outer/normal TrueCrypt volume as read only)
uint32 HiddenSysLeakProtectionCount;
+ BOOL MasterKeyVulnerable;
+
} BootEncryptionStatus;
typedef struct
{
@@ -342,27 +345,27 @@ typedef struct
char BootPrfAlgorithmName[256];
} GetBootEncryptionAlgorithmNameRequest;
typedef struct
{
- byte Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 Fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
} BootLoaderFingerprintRequest;
typedef struct
{
wchar_t DevicePath[TC_MAX_PATH];
- byte Configuration;
+ uint8 Configuration;
BOOL DriveIsDynamic;
uint16 BootLoaderVersion;
- byte UserConfiguration;
+ uint8 UserConfiguration;
char CustomUserMessage[TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH + 1];
} GetSystemDriveConfigurationRequest;
typedef struct
{
WipeAlgorithmId WipeAlgorithm;
- CRYPTOPP_ALIGN_DATA(16) byte WipeKey[MASTER_KEYDATA_SIZE];
+ CRYPTOPP_ALIGN_DATA(16) uint8 WipeKey[MASTER_KEYDATA_SIZE];
} WipeDecoySystemRequest;
typedef struct
{
BOOL WipeInProgress;
@@ -371,11 +374,11 @@ typedef struct
} DecoySystemWipeStatus;
typedef struct
{
LARGE_INTEGER Offset;
- byte Data[TC_SECTOR_SIZE_BIOS];
+ uint8 Data[TC_SECTOR_SIZE_BIOS];
} WriteBootDriveSectorRequest;
typedef struct
{
BOOL PagingFileCreationPrevented;
@@ -391,10 +394,11 @@ typedef struct
typedef struct
{
int EncryptionIoRequestCount;
int EncryptionItemCount;
int EncryptionFragmentSize;
+ int EncryptionMaxWorkItems;
} EncryptionQueueParameters;
#pragma pack (pop)
#define DRIVER_STR WIDE
@@ -413,10 +417,11 @@ typedef struct
#define TC_ENCRYPTION_FREE_CPU_COUNT_REG_VALUE_NAME DRIVER_STR("VeraCryptEncryptionFreeCpuCount")
#define VC_ENCRYPTION_IO_REQUEST_COUNT DRIVER_STR("VeraCryptEncryptionIoRequestCount")
#define VC_ENCRYPTION_ITEM_COUNT DRIVER_STR("VeraCryptEncryptionItemCount")
#define VC_ENCRYPTION_FRAGMENT_SIZE DRIVER_STR("VeraCryptEncryptionFragmentSize")
+#define VC_ENCRYPTION_MAX_WORK_ITEMS DRIVER_STR("VeraCryptEncryptionMaxWorkItems")
#define VC_ERASE_KEYS_SHUTDOWN DRIVER_STR("VeraCryptEraseKeysShutdown")
#define VC_ENABLE_MEMORY_PROTECTION DRIVER_STR("VeraCryptEnableMemoryProtection")
diff --git a/src/Common/BaseCom.cpp b/src/Common/BaseCom.cpp
index 3eaaf809..3b502ef0 100644
--- a/src/Common/BaseCom.cpp
+++ b/src/Common/BaseCom.cpp
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -448,11 +448,11 @@ DWORD BaseCom::WriteEfiBootSectorUserConfig (DWORD userConfig, BSTR customUserMe
char* msg = (char*) *customUserMessage;
if (maxSize > 0)
msg [maxSize - 1] = 0;
std::string msgStr = maxSize > 0 ? msg : "";
BootEncryption bootEnc (NULL);
- bootEnc.WriteEfiBootSectorUserConfig ((byte) userConfig, msgStr, pim, hashAlg);
+ bootEnc.WriteEfiBootSectorUserConfig ((uint8) userConfig, msgStr, pim, hashAlg);
}
catch (SystemException &)
{
return GetLastError();
}
diff --git a/src/Common/BaseCom.h b/src/Common/BaseCom.h
index 431b0257..1a7b68d2 100644
--- a/src/Common/BaseCom.h
+++ b/src/Common/BaseCom.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/BootEncryption.cpp b/src/Common/BootEncryption.cpp
index d3dc249e..833a67fd 100644
--- a/src/Common/BootEncryption.cpp
+++ b/src/Common/BootEncryption.cpp
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -273,14 +273,14 @@ bool ZipAdd (zip_t *z, const char* name, const unsigned char* pbData, DWORD cbDa
}
return true;
}
-static BOOL IsWindowsMBR (const byte *buffer, size_t bufferSize)
+static BOOL IsWindowsMBR (const uint8 *buffer, size_t bufferSize)
{
BOOL bRet = FALSE;
- byte g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0};
+ uint8 g_pbMsSignature[4] = {0x33, 0xc0, 0x8e, 0xd0};
const char* g_szStr1 = "Invalid partition table";
const char* g_szStr2 = "Error loading operating system";
const char* g_szStr3 = "Missing operating system";
if ((0 == memcmp (buffer, g_pbMsSignature, 4)) &&
@@ -388,11 +388,11 @@ namespace VeraCrypt
SetLastError (result);
throw SystemException(SRC_POS);
}
}
- static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone)
{
Elevate();
DWORD result;
CComBSTR bufferBstr, fileBstr;
@@ -629,11 +629,11 @@ namespace VeraCrypt
SetLastError (result);
throw SystemException(SRC_POS);
}
}
- static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
Elevate();
DWORD result;
CComBSTR customUserMessageBstr;
@@ -740,21 +740,21 @@ namespace VeraCrypt
class Elevator
{
public:
static void AddReference () { }
static void CallDriver (DWORD ioctl, void *input, DWORD inputSize, void *output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); }
- static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, byte *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
+ static void ReadWriteFile (BOOL write, BOOL device, const wstring &filePath, uint8 *buffer, uint64 offset, uint32 size, DWORD *sizeDone) { throw ParameterIncorrect (SRC_POS); }
static void RegisterFilterDriver (bool registerDriver, BootEncryption::FilterType filterType) { throw ParameterIncorrect (SRC_POS); }
static void Release () { }
static void SetDriverServiceStartType (DWORD startType) { throw ParameterIncorrect (SRC_POS); }
static void GetFileSize (const wstring &filePath, unsigned __int64 *pSize) { throw ParameterIncorrect (SRC_POS); }
static BOOL DeviceIoControl (BOOL readOnly, BOOL device, const wstring &filePath, DWORD dwIoControlCode, LPVOID input, DWORD inputSize, LPVOID output, DWORD outputSize) { throw ParameterIncorrect (SRC_POS); }
static void InstallEfiBootLoader (bool preserveUserConfig, bool hiddenOSCreation, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
static void BackupEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void RestoreEfiSystemLoader () { throw ParameterIncorrect (SRC_POS); }
static void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn) { throw ParameterIncorrect (SRC_POS); }
- static void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
+ static void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg) { throw ParameterIncorrect (SRC_POS); }
static void UpdateSetupConfigFile (bool bForInstall) { throw ParameterIncorrect (SRC_POS); }
static void GetSecureBootConfig (BOOL* pSecureBootEnabled, BOOL *pVeraCryptKeysLoaded) { throw ParameterIncorrect (SRC_POS); }
};
#endif // SETUP
@@ -771,15 +771,17 @@ namespace VeraCrypt
FileOpen = true;
}
else
{
LastError = GetLastError();
+#ifndef SETUP
if (LastError == ERROR_ACCESS_DENIED && IsUacSupported())
{
Elevated = true;
FileOpen = true;
}
+#endif
}
FilePointerPosition = 0;
IsDevice = false;
Path = path;
@@ -794,26 +796,28 @@ namespace VeraCrypt
}
FileOpen = false;
}
- DWORD File::Read (byte *buffer, DWORD size)
+ DWORD File::Read (uint8 *buffer, DWORD size)
{
DWORD bytesRead;
if (!FileOpen)
{
SetLastError (LastError);
throw SystemException (SRC_POS);
}
+#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))
{
DWORD dwLastError = GetLastError();
if ((dwLastError == ERROR_INVALID_PARAMETER) && IsDevice && (size % 4096))
@@ -899,11 +903,11 @@ namespace VeraCrypt
unsigned __int64 size64;
GetFileSize (size64);
dwSize = (DWORD) size64;
}
- void File::Write (byte *buffer, DWORD size)
+ void File::Write (uint8 *buffer, DWORD size)
{
DWORD bytesWritten;
if (!FileOpen)
{
@@ -911,17 +915,19 @@ namespace VeraCrypt
throw SystemException (SRC_POS);
}
try
{
+#ifndef SETUP
if (Elevated)
{
Elevator::ReadWriteFile (true, IsDevice, Path, buffer, FilePointerPosition, size, &bytesWritten);
FilePointerPosition += bytesWritten;
throw_sys_if (bytesWritten != size);
}
else
+#endif
{
if (!WriteFile (Handle, buffer, size, &bytesWritten, NULL))
{
DWORD dwLastError = GetLastError ();
if ((ERROR_INVALID_PARAMETER == dwLastError) && IsDevice && !ReadOnly && (size % 4096))
@@ -1044,15 +1050,17 @@ namespace VeraCrypt
FileOpen = true;
}
else
{
LastError = GetLastError ();
+#ifndef SETUP
if (LastError == ERROR_ACCESS_DENIED && IsUacSupported())
{
Elevated = true;
FileOpen = true;
}
+#endif
}
FilePointerPosition = 0;
IsDevice = true;
Path = path;
@@ -1139,11 +1147,11 @@ namespace VeraCrypt
if (!config.SystemPartition.IsGPT)
{
// throw ParameterIncorrect (SRC_POS); // It is assumed that CheckRequirements() had been called
// Find the first active partition on the system drive
- foreach (const Partition &partition, config.Partitions)
+ for (const Partition& partition : config.Partitions)
{
if (partition.Info.BootIndicator)
{
if (partition.Info.PartitionNumber != config.SystemPartition.Number)
{
@@ -1152,17 +1160,17 @@ namespace VeraCrypt
{
int64 minOffsetFound = config.DrivePartition.Info.PartitionLength.QuadPart;
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;
}
}
if (minOffsetFound != config.DrivePartition.Info.PartitionLength.QuadPart
&& partitionBehindBoot.Number == config.SystemPartition.Number)
@@ -1349,15 +1357,15 @@ namespace VeraCrypt
part.Number = partNumber;
part.Info = diskPartInfo.partInfo;
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":";
}
// Volume ID
wchar_t volumePath[TC_MAX_PATH];
@@ -1421,11 +1429,11 @@ namespace VeraCrypt
uint16 version;
CallDriver (TC_IOCTL_GET_BOOT_LOADER_VERSION, NULL, 0, &version, sizeof (version));
return version;
}
- void BootEncryption::GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE])
+ void BootEncryption::GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE])
{
BootLoaderFingerprintRequest request;
CallDriver (VC_IOCTL_GET_BOOT_LOADER_FINGERPRINT, NULL, 0, &request, sizeof (request));
memcpy (fingerprint, request.Fingerprint, sizeof (request.Fingerprint));
}
@@ -1460,10 +1468,11 @@ namespace VeraCrypt
BootEncryptionStatus BootEncryption::GetStatus ()
{
/* IMPORTANT: Do NOT add any potentially time-consuming operations to this function. */
BootEncryptionStatus status;
+ memset (&status, 0, sizeof(status));
CallDriver (TC_IOCTL_GET_BOOT_ENCRYPTION_STATUS, NULL, 0, &status, sizeof (status));
return status;
}
@@ -1483,16 +1492,16 @@ namespace VeraCrypt
CallDriver (TC_IOCTL_IS_HIDDEN_SYSTEM_RUNNING, nullptr, 0, &hiddenSystemStatus, sizeof (hiddenSystemStatus));
return hiddenSystemStatus != 0;
}
- bool BootEncryption::SystemDriveContainsPartitionType (byte type)
+ bool BootEncryption::SystemDriveContainsPartitionType (uint8 type)
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS);
- byte mbrBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrBuf, sizeof (mbrBuf));
MBR *mbr = reinterpret_cast <MBR *> (mbrBuf);
if (mbr->Signature != 0xaa55)
@@ -1530,11 +1539,11 @@ namespace VeraCrypt
case PARTITION_XINT13:
case PARTITION_XINT13_EXTENDED:
continue;
}
- if (SystemDriveContainsPartitionType ((byte) partitionType))
+ if (SystemDriveContainsPartitionType ((uint8) partitionType))
return true;
}
return false;
}
@@ -1648,11 +1657,11 @@ namespace VeraCrypt
return config.Partitions.size() == 1
&& config.DrivePartition.Info.PartitionLength.QuadPart - config.SystemPartition.Info.PartitionLength.QuadPart < 64 * BYTES_PER_MB;
}
- uint32 BootEncryption::GetChecksum (byte *data, size_t size)
+ uint32 BootEncryption::GetChecksum (uint8 *data, size_t size)
{
uint32 sum = 0;
while (size-- > 0)
{
@@ -1662,11 +1671,11 @@ namespace VeraCrypt
return sum;
}
- void BootEncryption::CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation)
+ void BootEncryption::CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation)
{
if (bufferSize < TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE)
throw ParameterIncorrect (SRC_POS);
ZeroMemory (buffer, bufferSize);
@@ -1685,27 +1694,30 @@ namespace VeraCrypt
ZeroMemory(&request, sizeof(request));
CallDriver (TC_IOCTL_GET_BOOT_ENCRYPTION_ALGORITHM_NAME, NULL, 0, &request, sizeof (request));
if (_stricmp (request.BootEncryptionAlgorithmName, "AES") == 0)
ea = AES;
- else if (_stricmp (request.BootEncryptionAlgorithmName, "Serpent") == 0)
+ #ifndef WOLFCRYPT_BACKEND
+ else if (_stricmp (request.BootEncryptionAlgorithmName, "Camellia") == 0)
+ ea = CAMELLIA;
+ else if (_stricmp (request.BootEncryptionAlgorithmName, "Serpent") == 0)
ea = SERPENT;
else if (_stricmp (request.BootEncryptionAlgorithmName, "Twofish") == 0)
ea = TWOFISH;
- else if (_stricmp (request.BootEncryptionAlgorithmName, "Camellia") == 0)
- ea = CAMELLIA;
-
+ #endif
if (_stricmp(request.BootPrfAlgorithmName, "SHA-256") == 0)
pkcs5_prf = SHA256;
- else if (_stricmp(request.BootPrfAlgorithmName, "BLAKE2s-256") == 0)
- pkcs5_prf = BLAKE2S;
- else if (_stricmp(request.BootPrfAlgorithmName, "SHA-512") == 0)
+ else if (_stricmp(request.BootPrfAlgorithmName, "SHA-512") == 0)
pkcs5_prf = SHA512;
+ #ifndef WOLFCRYPT_BACKEND
+ else if (_stricmp(request.BootPrfAlgorithmName, "BLAKE2s-256") == 0)
+ pkcs5_prf = BLAKE2S;
else if (_stricmp(request.BootPrfAlgorithmName, "Whirlpool") == 0)
pkcs5_prf = WHIRLPOOL;
else if (_stricmp(request.BootPrfAlgorithmName, "Streebog") == 0)
pkcs5_prf = STREEBOG;
+ #endif
else if (strlen(request.BootPrfAlgorithmName) == 0) // case of version < 1.0f
pkcs5_prf = BLAKE2S;
}
catch (...)
{
@@ -1804,11 +1816,11 @@ namespace VeraCrypt
break;
}
// Boot sector
DWORD size;
- byte *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
+ uint8 *bootSecResourceImg = MapResource (L"BIN", bootSectorId, &size);
if (!bootSecResourceImg || size != TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
memcpy (buffer, bootSecResourceImg, size);
@@ -1822,27 +1834,27 @@ namespace VeraCrypt
// Checksum of the backup header of the outer volume for the hidden system
if (hiddenOSCreation)
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte headerSector[TC_SECTOR_SIZE_BIOS];
+ uint8 headerSector[TC_SECTOR_SIZE_BIOS];
device.SeekAt (HiddenOSCandidatePartition.Info.StartingOffset.QuadPart + HiddenOSCandidatePartition.Info.PartitionLength.QuadPart - TC_VOLUME_HEADER_GROUP_SIZE + TC_VOLUME_HEADER_EFFECTIVE_SIZE);
device.Read (headerSector, sizeof (headerSector));
*(uint32 *) (buffer + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET) = GetCrc32 (headerSector, sizeof (headerSector));
}
// Decompressor
- byte *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
+ uint8 *decompressor = MapResource (L"BIN", IDR_BOOT_LOADER_DECOMPRESSOR, &size);
if (!decompressor || size > TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
memcpy (buffer + TC_SECTOR_SIZE_BIOS, decompressor, size);
// Compressed boot loader
- byte *bootLoader = MapResource (L"BIN", bootLoaderId, &size);
+ uint8 *bootLoader = MapResource (L"BIN", bootLoaderId, &size);
if (!bootLoader || size > TC_MAX_BOOT_LOADER_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS)
throw ParameterIncorrect (SRC_POS);
memcpy (buffer + TC_SECTOR_SIZE_BIOS + TC_BOOT_LOADER_DECOMPRESSOR_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS, bootLoader, size);
@@ -1864,11 +1876,11 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
}
}
// return false when the user cancel an elevation request
- bool BootEncryption::ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig, string *customUserMessage, uint16 *bootLoaderVersion)
+ bool BootEncryption::ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig, string *customUserMessage, uint16 *bootLoaderVersion)
{
bool bCanceled = false, bExceptionOccured = false;
try
{
if (GetSystemDriveConfiguration().SystemPartition.IsGPT)
@@ -1957,33 +1969,33 @@ namespace VeraCrypt
return !bCanceled;
}
- void BootEncryption::WriteBootSectorConfig (const byte newConfig[])
+ void BootEncryption::WriteBootSectorConfig (const uint8 newConfig[])
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
memcpy (mbr + TC_BOOT_SECTOR_CONFIG_OFFSET, newConfig, TC_BOOT_CFG_FLAG_AREA_SIZE);
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
}
- void BootEncryption::WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ void BootEncryption::WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
if (!IsAdmin() && IsUacSupported())
{
Elevator::WriteEfiBootSectorUserConfig (userConfig, customUserMessage, pim, hashAlg);
}
@@ -1998,21 +2010,21 @@ namespace VeraCrypt
EfiBootInst.UpdateConfig (L"\\EFI\\VeraCrypt\\DcsProp", pim, hashAlg, ParentWindow);
}
}
- void BootEncryption::WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg)
+ void BootEncryption::WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg)
{
if (GetSystemDriveConfiguration().SystemPartition.IsGPT)
{
WriteEfiBootSectorUserConfig (userConfig, customUserMessage, pim, hashAlg);
}
else
{
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
if (!BufferContainsString (mbr, sizeof (mbr), TC_APP_NAME)
@@ -2043,11 +2055,11 @@ namespace VeraCrypt
memset (mbr + TC_BOOT_SECTOR_PIM_VALUE_OFFSET, 0, TC_BOOT_SECTOR_PIM_VALUE_SIZE);
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
@@ -2055,11 +2067,11 @@ namespace VeraCrypt
}
unsigned int BootEncryption::GetHiddenOSCreationPhase ()
{
- byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
+ uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags));
return (configFlags[0] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE);
}
@@ -2068,15 +2080,15 @@ namespace VeraCrypt
void BootEncryption::SetHiddenOSCreationPhase (unsigned int newPhase)
{
#if TC_BOOT_CFG_FLAG_AREA_SIZE != 1
# error TC_BOOT_CFG_FLAG_AREA_SIZE != 1; revise GetHiddenOSCreationPhase() and SetHiddenOSCreationPhase()
#endif
- byte configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
+ uint8 configFlags [TC_BOOT_CFG_FLAG_AREA_SIZE];
ReadBootSectorConfig (configFlags, sizeof(configFlags));
- configFlags[0] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
+ configFlags[0] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
configFlags[0] |= newPhase;
WriteBootSectorConfig (configFlags);
}
@@ -2149,11 +2161,11 @@ namespace VeraCrypt
throw CryptoApiFailed (SRC_POS, CryptoAPILastError);
}
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened(SRC_POS);
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
finally_do_arg (BootEncryption *, this,
@@ -2166,22 +2178,22 @@ namespace VeraCrypt
#if PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE
# error PRAND_DISK_WIPE_PASSES > RNG_POOL_SIZE
#endif
- byte randData[PRAND_DISK_WIPE_PASSES];
+ uint8 randData[PRAND_DISK_WIPE_PASSES];
if (!RandgetBytes (ParentWindow, randData, sizeof (randData), FALSE))
throw ParameterIncorrect (SRC_POS);
for (int wipePass = 0; wipePass < PRAND_DISK_WIPE_PASSES; wipePass++)
{
for (int i = 0; i < TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE; ++i)
{
mbr[TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + i] = randData[wipePass];
}
- mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (byte) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
+ mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] &= (uint8) ~TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
mbr[TC_BOOT_SECTOR_CONFIG_OFFSET] |= randData[wipePass] & TC_BOOT_CFG_MASK_HIDDEN_OS_CREATION_PHASE;
if (wipePass == PRAND_DISK_WIPE_PASSES - 1)
memset (mbr + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET, 0, TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE);
@@ -2379,11 +2391,11 @@ namespace VeraCrypt
bool bModifiedMsBoot = true;
EfiBootInst.GetFileSize(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", loaderSize);
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
const char* g_szMsBootString = "bootmgfw.pdb";
@@ -2435,11 +2447,12 @@ namespace VeraCrypt
filePath = "";
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("))
{
char c;
const char* ptr = strstr (copieValue.c_str(), "file(");
@@ -2630,18 +2643,28 @@ 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) {
- SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE);
+ DWORD dwLastError;
+ BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_SYSTEM_ENVIRONMENT_NAME);
+ if (!bPrivilegesSet && !SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE))
+ {
+ dwLastError = GetLastError();
+ wchar_t szMsg[128];
+ StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to set SE_SYSTEM_ENVIRONMENT_NAME privilege (error code 0x%.8X)", dwLastError);
+ throw ErrorException(szMsg, SRC_POS);
+ }
// Check EFI
if (!IsEfiBoot()) {
- throw ErrorException(L"can not detect EFI environment", SRC_POS);
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
+ throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
}
wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
SetFirmwareEnvironmentVariable(varName, EfiVarGuid, NULL, 0);
@@ -2680,26 +2703,39 @@ namespace VeraCrypt
)
{
SetFirmwareEnvironmentVariable(next.c_str(), EfiVarGuid, startOrder, 0);
}
}
+
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
}
void EfiBoot::SetStartExec(wstring description, wstring execPath, bool setBootEntry, bool forceFirstBootEntry, bool setBootNext, uint16 statrtOrderNum , wchar_t* type, uint32 attr) {
- SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE);
+ DWORD dwLastError;
+ BOOL bPrivilegesSet = IsPrivilegeEnabled (SE_SYSTEM_ENVIRONMENT_NAME);
+ if (!bPrivilegesSet && !SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, TRUE))
+ {
+ dwLastError = GetLastError();
+ wchar_t szMsg[128];
+ StringCchPrintfW(szMsg, ARRAYSIZE(szMsg), L"Failed to set SE_SYSTEM_ENVIRONMENT_NAME privilege (error code 0x%.8X)", dwLastError);
+ throw ErrorException(szMsg, SRC_POS);
+ }
// Check EFI
if (!IsEfiBoot()) {
- throw ErrorException(L"can not detect EFI environment", SRC_POS);
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
+ throw ErrorException(L"Failed to detect EFI environment (error ERROR_INVALID_FUNCTION)", SRC_POS);
}
if (bDeviceInfoValid)
{
uint32 varSize = 56;
varSize += ((uint32) description.length()) * 2 + 2;
varSize += ((uint32) execPath.length()) * 2 + 2;
- byte *startVar = new byte[varSize];
- byte *pVar = startVar;
+ uint8 *startVar = new uint8[varSize];
+ uint8 *pVar = startVar;
// Attributes (1b Active, 1000b - Hidden)
*(uint32 *)pVar = attr;
pVar += sizeof(uint32);
@@ -2716,16 +2752,16 @@ namespace VeraCrypt
pVar += sizeof(uint16);
/* EFI_DEVICE_PATH_PROTOCOL (HARDDRIVE_DEVICE_PATH \ FILE_PATH \ END) */
// Type
- *(byte *)pVar = 0x04;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x04;
+ pVar += sizeof(uint8);
// SubType
- *(byte *)pVar = 0x01;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x01;
+ pVar += sizeof(uint8);
// HDD dev path length
*(uint16 *)pVar = 0x2A; // 42
pVar += sizeof(uint16);
@@ -2744,16 +2780,16 @@ namespace VeraCrypt
// GptGuid
memcpy(pVar, &partInfo.Gpt.PartitionId, 16);
pVar += 16;
// MbrType
- *(byte *)pVar = 0x02;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x02;
+ pVar += sizeof(uint8);
// SigType
- *(byte *)pVar = 0x02;
- pVar += sizeof(byte);
+ *(uint8 *)pVar = 0x02;
+ pVar += sizeof(uint8);
// Type and sub type 04 04 (file path)
*(uint16 *)pVar = 0x0404;
pVar += sizeof(uint16);
@@ -2776,11 +2812,11 @@ namespace VeraCrypt
// Set variable
wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, statrtOrderNum);
// only set value if it doesn't already exist
- byte* existingVar = new byte[varSize];
+ uint8* existingVar = new uint8[varSize];
DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, varSize);
if ((existingVarLen != varSize) || (0 != memcmp (existingVar, startVar, varSize)))
SetFirmwareEnvironmentVariable(varName, EfiVarGuid, startVar, varSize);
delete [] startVar;
delete [] existingVar;
@@ -2808,11 +2844,11 @@ namespace VeraCrypt
if (startOrderNumPos != 0)
{
wchar_t varName[256];
StringCchPrintfW(varName, ARRAYSIZE (varName), L"%s%04X", type == NULL ? L"Boot" : type, startOrder[0]);
- byte* existingVar = new byte[512];
+ uint8* existingVar = new uint8[512];
DWORD existingVarLen = GetFirmwareEnvironmentVariableW (varName, EfiVarGuid, existingVar, 512);
if (existingVarLen > 0)
{
if (BufferContainsWideString (existingVar, existingVarLen, L"EFI\\Microsoft\\Boot\\bootmgfw.efi"))
bFirstEntryIsWindows = true;
@@ -2860,10 +2896,13 @@ namespace VeraCrypt
next.insert(0, type == NULL ? L"Boot" : type);
SetFirmwareEnvironmentVariable(next.c_str(), EfiVarGuid, &statrtOrderNum, 2);
}
+
+ if (!bPrivilegesSet)
+ SetPrivilege(SE_SYSTEM_ENVIRONMENT_NAME, FALSE);
}
bool EfiBoot::CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2)
{
bool bRet = false;
@@ -2879,12 +2918,12 @@ namespace VeraCrypt
f2.GetFileSize (size2);
if (size1 == size2)
{
// same size, so now we compare content
- std::vector<byte> file1Buf (8096);
- std::vector<byte> file2Buf (8096);
+ std::vector<uint8> file1Buf (8096);
+ std::vector<uint8> file2Buf (8096);
DWORD remainingBytes = size1, dataToRead;
while (remainingBytes)
{
dataToRead = VC_MIN (remainingBytes, (DWORD) file1Buf.size());
@@ -2915,11 +2954,11 @@ namespace VeraCrypt
f2.Close();
return bRet;
}
- bool EfiBoot::CompareFileData (const wchar_t* fileName, const byte* data, DWORD size)
+ bool EfiBoot::CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size)
{
bool bRet = false;
File f(fileName, true);
if (f.IsOpened ())
@@ -2932,11 +2971,11 @@ namespace VeraCrypt
f.GetFileSize(existingSize);
if (existingSize == size)
{
- std::vector<byte> fileBuf (8096);
+ std::vector<uint8> fileBuf (8096);
DWORD remainingBytes = size, dataOffset = 0, dataToRead;
while (remainingBytes)
{
dataToRead = VC_MIN (remainingBytes, (DWORD) fileBuf.size());
@@ -2966,11 +3005,11 @@ namespace VeraCrypt
f.Close();
return bRet;
}
- void EfiBoot::SaveFile(const wchar_t* name, byte* data, DWORD size) {
+ void EfiBoot::SaveFile(const wchar_t* name, uint8* data, DWORD size) {
wstring path = EfiBootPartPath;
path += name;
if (!CompareFileData (path.c_str(), data, size))
{
@@ -2995,11 +3034,11 @@ namespace VeraCrypt
File f(path, true);
f.GetFileSize(size);
f.Close();
}
- void EfiBoot::ReadFile(const wchar_t* name, byte* data, DWORD size) {
+ void EfiBoot::ReadFile(const wchar_t* name, uint8* data, DWORD size) {
wstring path = EfiBootPartPath;
path += name;
File f(path, true);
f.Read(data, size);
f.Close();
@@ -3161,11 +3200,11 @@ namespace VeraCrypt
}
void BootEncryption::UpdateSetupConfigFile (bool bForInstall)
{
// starting from Windows 10 1607 (Build 14393), ReflectDrivers in Setupconfig.ini is supported
- if (IsOSVersionAtLeast (WIN_10, 0) && CurrentOSBuildNumber >= 14393)
+ if (IsWin10BuildAtLeast(WIN_10_1607_BUILD))
{
wchar_t szInstallPath [TC_MAX_PATH];
wchar_t szSetupconfigLocation [TC_MAX_PATH + 20];
if (bForInstall)
@@ -3291,57 +3330,33 @@ namespace VeraCrypt
{
Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", ParentWindow);
}
}
DWORD sizeDcsBoot;
-#ifdef _WIN64
- byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
-#else
- byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
-#endif
+ uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
if (!dcsBootImg)
throw ErrorException(L"Out of resource DcsBoot", SRC_POS);
DWORD sizeDcsInt;
-#ifdef _WIN64
- byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
-#else
- byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
-#endif
+ uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
if (!dcsIntImg)
throw ErrorException(L"Out of resource DcsInt", SRC_POS);
DWORD sizeDcsCfg;
-#ifdef _WIN64
- byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
-#else
- byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
-#endif
+ uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
if (!dcsCfgImg)
throw ErrorException(L"Out of resource DcsCfg", SRC_POS);
DWORD sizeLegacySpeaker;
-#ifdef _WIN64
- byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
-#else
- byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
-#endif
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
if (!LegacySpeakerImg)
throw ErrorException(L"Out of resource LegacySpeaker", SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker;
-#ifdef _WIN64
- byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
-#else
- byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
-#endif
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
if (!BootMenuLockerImg)
throw ErrorException(L"Out of resource DcsBml", SRC_POS);
#endif
DWORD sizeDcsInfo;
-#ifdef _WIN64
- byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
-#else
- byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
-#endif
+ uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
if (!DcsInfoImg)
throw ErrorException(L"Out of resource DcsInfo", SRC_POS);
EfiBootInst.PrepareBootPartition(PostOOBEMode);
@@ -3349,12 +3364,12 @@ namespace VeraCrypt
{
// Save modules
bool bAlreadyExist;
const char* g_szMsBootString = "bootmgfw.pdb";
unsigned __int64 loaderSize = 0;
- const wchar_t * szStdEfiBootloader = Is64BitOs()? L"\\EFI\\Boot\\bootx64.efi": L"\\EFI\\Boot\\bootia32.efi";
- const wchar_t * szBackupEfiBootloader = Is64BitOs()? L"\\EFI\\Boot\\original_bootx64.vc_backup": L"\\EFI\\Boot\\original_bootia32.vc_backup";
+ const wchar_t * szStdEfiBootloader = L"\\EFI\\Boot\\bootx64.efi";
+ const wchar_t * szBackupEfiBootloader = L"\\EFI\\Boot\\original_bootx64.vc_backup";
if (preserveUserConfig)
{
bool bModifiedMsBoot = true, bMissingMsBoot = false;;
if (EfiBootInst.FileExists (L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi"))
@@ -3368,11 +3383,11 @@ namespace VeraCrypt
if (EfiBootInst.FileExists (L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc"))
{
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
@@ -3386,11 +3401,11 @@ namespace VeraCrypt
else
{
// DcsBoot.efi is always smaller than 32KB
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi", &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
@@ -3415,11 +3430,11 @@ namespace VeraCrypt
&& (EfiBootInst.FileExists (loaderPath.c_str()))
)
{
// look for bootmgfw.efi identifiant string
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
@@ -3448,11 +3463,11 @@ namespace VeraCrypt
// check if standard bootloader under EFI\Boot has been set to Microsoft version
// if yes, replace it with our bootloader
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize);
if (loaderSize > 32768)
{
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
@@ -3482,11 +3497,11 @@ namespace VeraCrypt
if (EfiBootInst.FileExists (szStdEfiBootloader))
{
// check if standard bootloader under EFI\Boot is Microsoft one or if it is ours
// if both cases, replace it with our bootloader otherwise do nothing
EfiBootInst.GetFileSize(szStdEfiBootloader, loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(szStdEfiBootloader, &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi or VeraCrypt identifiant strings
if ( ((loaderSize > 32768) && BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
)
@@ -3506,14 +3521,11 @@ namespace VeraCrypt
EfiBootInst.RenameFile (L"\\DcsProp", L"\\EFI\\VeraCrypt\\DcsProp", FALSE);
EfiBootInst.RenameFile (L"\\DcsBoot", L"\\EFI\\VeraCrypt\\DcsBoot", FALSE);
// move the original bootloader backup from old location (if it exists) to new location
// we don't force the move operation if the new location already exists
- if (Is64BitOs())
- EfiBootInst.RenameFile (L"\\EFI\\Boot\\original_bootx64_vc_backup.efi", L"\\EFI\\Boot\\original_bootx64.vc_backup", FALSE);
- else
- EfiBootInst.RenameFile (L"\\EFI\\Boot\\original_bootia32_vc_backup.efi", L"\\EFI\\Boot\\original_bootia32.vc_backup", FALSE);
+ 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");
EfiBootInst.DelFile(L"\\DcsInt.efi");
EfiBootInst.DelFile(L"\\DcsCfg.efi");
@@ -3534,15 +3546,15 @@ namespace VeraCrypt
}
else
{
try
{
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
CreateBootLoaderInMemory (bootLoaderBuf, sizeof (bootLoaderBuf), false, hiddenOSCreation);
// Write MBR
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
if (preserveUserConfig && BufferContainsString (mbr, sizeof (mbr), TC_APP_NAME))
@@ -3573,11 +3585,11 @@ namespace VeraCrypt
memcpy (mbr, bootLoaderBuf, TC_MAX_MBR_BOOT_CODE_SIZE);
device.SeekAt (0);
device.Write (mbr, sizeof (mbr));
- byte mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
+ uint8 mbrVerificationBuf[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbrVerificationBuf, sizeof (mbr));
if (memcmp (mbr, mbrVerificationBuf, sizeof (mbr)) != 0)
throw ErrorException ("ERROR_MBR_PROTECTED", SRC_POS);
@@ -3615,13 +3627,13 @@ namespace VeraCrypt
// return true for now when EFI system encryption is used until we implement
// a dedicated EFI fingerprinting mechanism in VeraCrypt driver
if (config.SystemPartition.IsGPT)
return true;
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
- byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
- byte expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SIZE - TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE] = {0};
+ uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
+ uint8 expectedFingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE];
bool bRet = false;
try
{
// read bootloader fingerprint
@@ -3688,65 +3700,37 @@ namespace VeraCrypt
BOOL bIsGPT = GetSystemDriveConfiguration().SystemPartition.IsGPT;
if (bIsGPT)
{
// create EFI disk structure
DWORD sizeDcsBoot;
-#ifdef _WIN64
- byte *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
-#else
- byte *dcsBootImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBOOT : IDR_EFI_DCSBOOT32, &sizeDcsBoot);
-#endif
+ uint8 *dcsBootImg = MapResource(L"BIN", IDR_EFI_DCSBOOT, &sizeDcsBoot);
if (!dcsBootImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInt;
-#ifdef _WIN64
- byte *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
-#else
- byte *dcsIntImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINT: IDR_EFI_DCSINT32, &sizeDcsInt);
-#endif
+ uint8 *dcsIntImg = MapResource(L"BIN", IDR_EFI_DCSINT, &sizeDcsInt);
if (!dcsIntImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsCfg;
-#ifdef _WIN64
- byte *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
-#else
- byte *dcsCfgImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSCFG: IDR_EFI_DCSCFG32, &sizeDcsCfg);
-#endif
+ uint8 *dcsCfgImg = MapResource(L"BIN", IDR_EFI_DCSCFG, &sizeDcsCfg);
if (!dcsCfgImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeLegacySpeaker;
-#ifdef _WIN64
- byte *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
-#else
- byte *LegacySpeakerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_LEGACYSPEAKER: IDR_EFI_LEGACYSPEAKER32, &sizeLegacySpeaker);
-#endif
+ uint8 *LegacySpeakerImg = MapResource(L"BIN", IDR_EFI_LEGACYSPEAKER, &sizeLegacySpeaker);
if (!LegacySpeakerImg)
throw ParameterIncorrect (SRC_POS);
#ifdef VC_EFI_CUSTOM_MODE
DWORD sizeBootMenuLocker;
-#ifdef _WIN64
- byte *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
-#else
- byte *BootMenuLockerImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSBML: IDR_EFI_DCSBML32, &sizeBootMenuLocker);
-#endif
+ uint8 *BootMenuLockerImg = MapResource(L"BIN", IDR_EFI_DCSBML, &sizeBootMenuLocker);
if (!BootMenuLockerImg)
throw ParameterIncorrect (SRC_POS);
#endif
DWORD sizeDcsRescue;
-#ifdef _WIN64
- byte *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue);
-#else
- byte *DcsRescueImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSRE: IDR_EFI_DCSRE32, &sizeDcsRescue);
-#endif
+ uint8 *DcsRescueImg = MapResource(L"BIN", IDR_EFI_DCSRE, &sizeDcsRescue);
if (!DcsRescueImg)
throw ParameterIncorrect (SRC_POS);
DWORD sizeDcsInfo;
-#ifdef _WIN64
- byte *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
-#else
- byte *DcsInfoImg = MapResource(L"BIN", Is64BitOs()? IDR_EFI_DCSINFO: IDR_EFI_DCSINFO32, &sizeDcsInfo);
-#endif
+ uint8 *DcsInfoImg = MapResource(L"BIN", IDR_EFI_DCSINFO, &sizeDcsInfo);
if (!DcsInfoImg)
throw ParameterIncorrect (SRC_POS);
WCHAR szTmpPath[MAX_PATH + 1], szTmpFilePath[MAX_PATH + 1];
if (!GetTempPathW (MAX_PATH, szTmpPath))
@@ -3768,11 +3752,11 @@ namespace VeraCrypt
if (!z)
throw ParameterIncorrect (SRC_POS);
finally_do_arg (zip_t**, &z, { if (*finally_arg) zip_discard (*finally_arg);});
- if (!ZipAdd (z, Is64BitOs()? "EFI/Boot/bootx64.efi": "EFI/Boot/bootia32.efi", DcsRescueImg, sizeDcsRescue))
+ 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))
throw ParameterIncorrect (SRC_POS);
#endif
@@ -3817,11 +3801,11 @@ namespace VeraCrypt
File sysBakFile (GetSystemLoaderBackupPath(), true);
sysBakFile.CheckOpened (SRC_POS);
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)
{
e.Show (ParentWindow);
Warning ("SYS_LOADER_UNAVAILABLE_FOR_RESCUE_DISK", ParentWindow);
@@ -3861,11 +3845,11 @@ namespace VeraCrypt
throw ParameterIncorrect (SRC_POS);
finally_do_arg (FILE*, ftmpFile, { fclose (finally_arg); });
unsigned long ulZipSize = (unsigned long) _filelength (_fileno (ftmpFile));
- RescueZipData = new byte[ulZipSize];
+ RescueZipData = new uint8[ulZipSize];
if (!RescueZipData)
throw bad_alloc();
if (ulZipSize != fread (RescueZipData, 1, ulZipSize, ftmpFile))
{
@@ -3884,11 +3868,11 @@ namespace VeraCrypt
}
else
{
Buffer imageBuf (RescueIsoImageSize);
- byte *image = imageBuf.Ptr();
+ uint8 *image = imageBuf.Ptr();
memset (image, 0, RescueIsoImageSize);
// Primary volume descriptor
const char* szPrimVolDesc = "\001CD001\001";
const char* szPrimVolLabel = "VeraCrypt Rescue Disk ";
@@ -3992,11 +3976,11 @@ namespace VeraCrypt
}
// Boot loader backup
CreateBootLoaderInMemory (image + TC_CD_BOOTSECTOR_OFFSET + TC_BOOT_LOADER_BACKUP_RESCUE_DISK_SECTOR_OFFSET, TC_BOOT_LOADER_AREA_SIZE, false);
- RescueIsoImage = new byte[RescueIsoImageSize];
+ RescueIsoImage = new uint8[RescueIsoImageSize];
if (!RescueIsoImage)
throw bad_alloc();
memcpy (RescueIsoImage, image, RescueIsoImageSize);
if (!isoImagePath.empty())
@@ -4044,23 +4028,10 @@ namespace VeraCrypt
L"EFI/VeraCrypt/DcsInt.dcs",
L"EFI/VeraCrypt/LegacySpeaker.dcs",
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);
if (!zsrc)
throw ParameterIncorrect (SRC_POS);
@@ -4085,12 +4056,12 @@ namespace VeraCrypt
WCHAR szNameBuffer[TC_MAX_PATH];
if (GetVolumeInformationW (rootPath, NULL, 0, NULL, NULL, NULL, szNameBuffer, ARRAYSIZE(szNameBuffer))
&& !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;
zip_int64_t index = zip_name_locate (z, WideToUtf8String (efiFiles[i]).c_str(), ZIP_FL_NOCASE);
if (index >= 0)
@@ -4239,29 +4210,16 @@ namespace VeraCrypt
L"EFI/VeraCrypt/DcsInt.dcs",
L"EFI/VeraCrypt/LegacySpeaker.dcs",
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;
indexMem = zip_name_locate (zMem, WideToUtf8String (efiFiles[i]).c_str(), ZIP_FL_NOCASE);
if (indexMem >= 0)
@@ -4350,26 +4308,26 @@ namespace VeraCrypt
PCRYPTO_INFO cryptoInfo = NULL;
if (!IsRandomNumberGeneratorStarted())
throw ParameterIncorrect (SRC_POS);
- throw_sys_if (CreateVolumeHeaderInMemory (ParentWindow, TRUE, (char *) VolumeHeader, ea, mode, password, pkcs5, pim, NULL, &cryptoInfo,
+ 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);
if (GetHeaderField32 (RescueVolumeHeader, TC_HEADER_OFFSET_MAGIC) != 0x56455241)
throw ParameterIncorrect (SRC_POS);
- byte *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH;
+ uint8 *fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_ENCRYPTED_AREA_LENGTH;
mputInt64 (fieldPos, volumeSize);
// CRC of the header fields
uint32 crc = GetCrc32 (RescueVolumeHeader + TC_HEADER_OFFSET_MAGIC, TC_HEADER_OFFSET_HEADER_CRC - TC_HEADER_OFFSET_MAGIC);
fieldPos = RescueVolumeHeader + TC_HEADER_OFFSET_HEADER_CRC;
@@ -4389,11 +4347,11 @@ namespace VeraCrypt
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
device.SeekAt (TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
- device.Write ((byte *) VolumeHeader, sizeof (VolumeHeader));
+ device.Write ((uint8 *) VolumeHeader, sizeof (VolumeHeader));
}
// For synchronous operations use AbortSetupWait()
void BootEncryption::AbortSetup ()
@@ -4430,11 +4388,11 @@ namespace VeraCrypt
{
Warning ("ADMIN_PRIVILEGES_WARN_DEVICES", ParentWindow);
}
}
unsigned __int64 loaderSize = 0;
- std::vector<byte> bootLoaderBuf;
+ std::vector<uint8> bootLoaderBuf;
const wchar_t * szStdMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw.efi";
const wchar_t * szBackupMsBootloader = L"\\EFI\\Microsoft\\Boot\\bootmgfw_ms.vc";
const char* g_szMsBootString = "bootmgfw.pdb";
bool bModifiedMsBoot = true;
@@ -4490,11 +4448,11 @@ namespace VeraCrypt
}
else
{
Device device (GetSystemDriveConfiguration().DevicePath, true);
device.CheckOpened (SRC_POS);
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (bootLoaderBuf, sizeof (bootLoaderBuf));
// Prevent TrueCrypt loader from being backed up
@@ -4532,14 +4490,11 @@ namespace VeraCrypt
EfiBootInst.PrepareBootPartition();
EfiBootInst.DeleteStartExec();
EfiBootInst.DeleteStartExec(0xDC5B, L"Driver"); // remove DcsBml boot driver it was installed
- if (Is64BitOs())
- EfiBootInst.RenameFile(L"\\EFI\\Boot\\original_bootx64.vc_backup", L"\\EFI\\Boot\\bootx64.efi", TRUE);
- else
- EfiBootInst.RenameFile(L"\\EFI\\Boot\\original_bootia32.vc_backup", L"\\EFI\\Boot\\bootia32.efi", TRUE);
+ 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))
{
EfiBootConf conf;
if (EfiBootInst.ReadConfig (L"\\EFI\\VeraCrypt\\DcsProp", conf) && strlen (conf.actionSuccessValue.c_str()))
@@ -4553,11 +4508,11 @@ namespace VeraCrypt
)
{
const char* g_szMsBootString = "bootmgfw.pdb";
unsigned __int64 loaderSize = 0;
EfiBootInst.GetFileSize(loaderPath.c_str(), loaderSize);
- std::vector<byte> bootLoaderBuf ((size_t) loaderSize);
+ std::vector<uint8> bootLoaderBuf ((size_t) loaderSize);
EfiBootInst.ReadFile(loaderPath.c_str(), &bootLoaderBuf[0], (DWORD) loaderSize);
// look for bootmgfw.efi identifiant string
if (BufferHasPattern (bootLoaderBuf.data (), (size_t) loaderSize, g_szMsBootString, strlen (g_szMsBootString)))
@@ -4587,22 +4542,22 @@ namespace VeraCrypt
EfiBootInst.DelFile(L"\\EFI\\VeraCrypt\\DcsProp");
EfiBootInst.DelDir (L"\\EFI\\VeraCrypt");
}
else
{
- byte bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
+ uint8 bootLoaderBuf[TC_BOOT_LOADER_AREA_SECTOR_COUNT * TC_SECTOR_SIZE_BIOS];
File backupFile (GetSystemLoaderBackupPath(), true);
backupFile.CheckOpened(SRC_POS);
if (backupFile.Read (bootLoaderBuf, sizeof (bootLoaderBuf)) != sizeof (bootLoaderBuf))
throw ParameterIncorrect (SRC_POS);
Device device (GetSystemDriveConfiguration().DevicePath);
device.CheckOpened (SRC_POS);
// Preserve current partition table
- byte mbr[TC_SECTOR_SIZE_BIOS];
+ uint8 mbr[TC_SECTOR_SIZE_BIOS];
device.SeekAt (0);
device.Read (mbr, sizeof (mbr));
memcpy (bootLoaderBuf + TC_MAX_MBR_BOOT_CODE_SIZE, mbr + TC_MAX_MBR_BOOT_CODE_SIZE, sizeof (mbr) - TC_MAX_MBR_BOOT_CODE_SIZE);
device.SeekAt (0);
@@ -4738,11 +4693,11 @@ namespace VeraCrypt
if (filterType != DumpFilter)
{
// Register class filter below all other filters in the stack
size_t strSize = filter.size() + 1;
- byte regKeyBuf[65536];
+ uint8 regKeyBuf[65536];
DWORD size = (DWORD) (sizeof (regKeyBuf) - strSize);
// SetupInstallFromInfSection() does not support prepending of values so we have to modify the registry directly
StringCchCopyA ((char *) regKeyBuf, ARRAYSIZE(regKeyBuf), filter.c_str());
@@ -4756,12 +4711,12 @@ namespace VeraCrypt
{
// workaround rare SetupInstallFromInfSection which overwrite value instead of appending new value
// read initial value
DWORD strSize = (DWORD) filter.size() + 1, expectedSize;
Buffer expectedRegKeyBuf(65536), outputRegKeyBuf(65536);
- byte* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr ();
- byte* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr ();
+ uint8* pbExpectedRegKeyBuf = expectedRegKeyBuf.Ptr ();
+ uint8* pbOutputRegKeyBuf = outputRegKeyBuf.Ptr ();
DWORD initialSize = (DWORD) (expectedRegKeyBuf.Size() - strSize - 2);
if (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbExpectedRegKeyBuf, &initialSize) != ERROR_SUCCESS)
{
StringCchCopyA ((char *) pbExpectedRegKeyBuf, expectedRegKeyBuf.Size(), filter.c_str());
@@ -4809,11 +4764,11 @@ namespace VeraCrypt
{
RegisterDriverInf (registerFilter, filter, filterReg, ParentWindow, regKey);
// remove value in case it was not done properly
Buffer regKeyBuf(65536);
- byte* pbRegKeyBuf = regKeyBuf.Ptr ();
+ uint8* pbRegKeyBuf = regKeyBuf.Ptr ();
DWORD initialSize = (DWORD) regKeyBuf.Size() - 2;
if ( (RegQueryValueExA (regKey, filterReg.c_str(), NULL, NULL, pbRegKeyBuf, &initialSize) == ERROR_SUCCESS)
&& (initialSize >= ((DWORD) filter.size()))
@@ -5297,16 +5252,16 @@ namespace VeraCrypt
if (encStatus.VolumeHeaderPresent)
{
// Verify CRC of header salt
Device device(config.DevicePath, true);
device.CheckOpened(SRC_POS);
- byte header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 header[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
device.SeekAt(TC_BOOT_VOLUME_HEADER_SECTOR_OFFSET);
device.Read(header, sizeof(header));
- if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((byte *)header, PKCS5_SALT_SIZE))
+ if (encStatus.VolumeHeaderSaltCrc32 != GetCrc32((uint8 *)header, PKCS5_SALT_SIZE))
throw ParameterIncorrect(SRC_POS);
}
}
try
@@ -5359,11 +5314,11 @@ namespace VeraCrypt
if (encStatus.SetupInProgress || (wipePassCount <= 0))
throw ParameterIncorrect (SRC_POS);
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);
// Only one algorithm is currently supported
if (pkcs5 != 0)
@@ -5389,17 +5344,21 @@ namespace VeraCrypt
if (backupHeaderOffset == -1)
throw ParameterIncorrect (SRC_POS);
}
device.SeekAt (headerOffset);
- device.Read ((byte *) header, sizeof (header));
+ device.Read (header, sizeof (header));
PCRYPTO_INFO cryptoInfo = NULL;
int status = ReadVolumeHeader (!encStatus.HiddenSystem, header, oldPassword, old_pkcs5, old_pim, &cryptoInfo, NULL);
finally_do_arg (PCRYPTO_INFO, cryptoInfo, { if (finally_arg) crypto_close (finally_arg); });
+ // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed
+ if ((status == 0) && cryptoInfo->bVulnerableMasterKey)
+ status = ERR_SYSENC_XTS_MASTERKEY_VULNERABLE;
+
if (status != 0)
{
handleError (hwndDlg, status, SRC_POS);
return status;
}
@@ -5477,11 +5436,11 @@ namespace VeraCrypt
handleError (hwndDlg, status, SRC_POS);
return status;
}
device.SeekAt (headerOffset);
- device.Write ((byte *) header, sizeof (header));
+ device.Write ((uint8 *) header, sizeof (header));
headerUpdated = true;
}
if (!encStatus.HiddenSystem || backupHeader)
break;
@@ -5508,11 +5467,11 @@ namespace VeraCrypt
if (old_pim != pim)
{
try
{
// check if PIM is stored in MBR
- byte userConfig = 0;
+ uint8 userConfig = 0;
if ( ReadBootSectorConfig (nullptr, 0, &userConfig)
&& (userConfig & TC_BOOT_USER_CFG_FLAG_DISABLE_PIM)
)
{
storedPimUpdateNeeded = true;
@@ -5785,11 +5744,11 @@ namespace VeraCrypt
configMap = 0;
return configMap;
}
- void BootEncryption::WriteBootDriveSector (uint64 offset, byte *data)
+ void BootEncryption::WriteBootDriveSector (uint64 offset, uint8 *data)
{
WriteBootDriveSectorRequest request;
request.Offset.QuadPart = offset;
memcpy (request.Data, data, sizeof (request.Data));
diff --git a/src/Common/BootEncryption.h b/src/Common/BootEncryption.h
index ddf6f3e5..432d10a9 100644
--- a/src/Common/BootEncryption.h
+++ b/src/Common/BootEncryption.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -35,12 +35,12 @@ namespace VeraCrypt
virtual ~File () { Close(); }
bool IsOpened () const { return FileOpen;}
void CheckOpened (const char* srcPos) { if (!FileOpen) { SetLastError (LastError); throw SystemException (srcPos);} }
void Close ();
- DWORD Read (byte *buffer, DWORD size);
- void Write (byte *buffer, DWORD size);
+ DWORD Read (uint8 *buffer, DWORD size);
+ void Write (uint8 *buffer, DWORD size);
void SeekAt (int64 position);
void GetFileSize (unsigned __int64& size);
void GetFileSize (DWORD& dwSize);
bool IoCtl(DWORD code, void* inBuf, DWORD inBufSize, void* outBuf, DWORD outBufSize);
@@ -68,34 +68,34 @@ namespace VeraCrypt
class Buffer
{
public:
Buffer (size_t size) : DataSize (size)
{
- DataPtr = new byte[size];
+ DataPtr = new uint8[size];
if (!DataPtr)
throw bad_alloc();
}
~Buffer () { delete[] DataPtr; }
- byte *Ptr () const { return DataPtr; }
+ uint8 *Ptr () const { return DataPtr; }
size_t Size () const { return DataSize; }
void Resize (size_t newSize)
{
if (newSize > DataSize)
{
- byte *tmp = new byte[newSize];
+ uint8 *tmp = new uint8[newSize];
if (!tmp)
throw bad_alloc();
memcpy (tmp, DataPtr, DataSize);
delete [] DataPtr;
DataPtr = tmp;
}
DataSize = newSize;
}
protected:
- byte *DataPtr;
+ uint8 *DataPtr;
size_t DataSize;
};
struct Partition
@@ -113,29 +113,29 @@ namespace VeraCrypt
#pragma pack (push)
#pragma pack(1)
struct PartitionEntryMBR
{
- byte BootIndicator;
+ uint8 BootIndicator;
- byte StartHead;
- byte StartCylSector;
- byte StartCylinder;
+ uint8 StartHead;
+ uint8 StartCylSector;
+ uint8 StartCylinder;
- byte Type;
+ uint8 Type;
- byte EndHead;
- byte EndSector;
- byte EndCylinder;
+ uint8 EndHead;
+ uint8 EndSector;
+ uint8 EndCylinder;
uint32 StartLBA;
uint32 SectorCountLBA;
};
struct MBR
{
- byte Code[446];
+ uint8 Code[446];
PartitionEntryMBR Partitions[4];
uint16 Signature;
};
#pragma pack (pop)
@@ -198,17 +198,17 @@ namespace VeraCrypt
void PrepareBootPartition(bool bDisableException = false);
bool IsEfiBoot();
void DeleteStartExec(uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL);
void SetStartExec(wstring description, wstring execPath, bool setBootEntry = true, bool forceFirstBootEntry = true, bool setBootNext = true, uint16 statrtOrderNum = 0xDC5B, wchar_t* type = NULL, uint32 attr = 1);
- void SaveFile(const wchar_t* name, byte* data, DWORD size);
+ void SaveFile(const wchar_t* name, uint8* data, DWORD size);
void GetFileSize(const wchar_t* name, unsigned __int64& size);
- void ReadFile(const wchar_t* name, byte* data, DWORD size);
+ void ReadFile(const wchar_t* name, uint8* data, DWORD size);
void CopyFile(const wchar_t* name, const wchar_t* targetName);
bool FileExists(const wchar_t* name);
static bool CompareFiles (const wchar_t* fileName1, const wchar_t* fileName2);
- static bool CompareFileData (const wchar_t* fileName, const byte* data, DWORD size);
+ static bool CompareFileData (const wchar_t* fileName, const uint8* data, DWORD size);
BOOL RenameFile(const wchar_t* name, const wchar_t* nameNew, BOOL bForce);
BOOL DelFile(const wchar_t* name);
BOOL MkDir(const wchar_t* name, bool& bAlreadyExists);
BOOL ReadConfig (const wchar_t* name, EfiBootConf& conf);
@@ -256,11 +256,11 @@ namespace VeraCrypt
void DeleteFileAdmin (const wstring &file);
DecoySystemWipeStatus GetDecoyOSWipeStatus ();
DWORD GetDriverServiceStartType ();
unsigned int GetHiddenOSCreationPhase ();
uint16 GetInstalledBootLoaderVersion ();
- void GetInstalledBootLoaderFingerprint (byte fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
+ void GetInstalledBootLoaderFingerprint (uint8 fingerprint[WHIRLPOOL_DIGESTSIZE + SHA512_DIGESTSIZE]);
Partition GetPartitionForHiddenOS ();
bool IsBootLoaderOnDrive (wchar_t *devicePath);
BootEncryptionStatus GetStatus ();
void GetVolumeProperties (VOLUME_PROPERTIES_STRUCT *properties);
SystemDriveConfiguration GetSystemDriveConfiguration ();
@@ -273,11 +273,11 @@ namespace VeraCrypt
bool IsHiddenSystemRunning ();
bool IsPagingFileActive (BOOL checkNonWindowsPartitionsOnly);
void PrepareHiddenOSCreation (int ea, int mode, int pkcs5);
void PrepareInstallation (bool systemPartitionOnly, Password &password, int ea, int mode, int pkcs5, int pim, const wstring &rescueIsoImagePath);
void ProbeRealSystemDriveSize ();
- bool ReadBootSectorConfig (byte *config, size_t bufLength, byte *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
+ bool ReadBootSectorConfig (uint8 *config, size_t bufLength, uint8 *userConfig = nullptr, string *customUserMessage = nullptr, uint16 *bootLoaderVersion = nullptr);
uint32 ReadDriverConfigurationFlags ();
uint32 ReadServiceConfigurationFlags ();
void RegisterBootDriver (bool hiddenSystem);
void RegisterFilterDriver (bool registerDriver, FilterType filterType);
void RegisterSystemFavoritesService (BOOL registerService);
@@ -293,22 +293,22 @@ namespace VeraCrypt
void SetDriverServiceStartType (DWORD startType);
void SetHiddenOSCreationPhase (unsigned int newPhase);
void StartDecryption (BOOL discardUnreadableEncryptedSectors);
void StartDecoyOSWipe (WipeAlgorithmId wipeAlgorithm);
void StartEncryption (WipeAlgorithmId wipeAlgorithm, bool zeroUnreadableSectors);
- bool SystemDriveContainsPartitionType (byte type);
+ bool SystemDriveContainsPartitionType (uint8 type);
bool SystemDriveContainsExtendedPartition ();
bool SystemDriveContainsNonStandardPartitions ();
bool SystemPartitionCoversWholeDrive ();
bool SystemDriveIsDynamic ();
bool VerifyRescueDisk ();
bool VerifyRescueDiskImage (const wchar_t* imageFile);
void WipeHiddenOSCreationConfig ();
- void WriteBootDriveSector (uint64 offset, byte *data);
- void WriteBootSectorConfig (const byte newConfig[]);
- void WriteBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg);
- void WriteEfiBootSectorUserConfig (byte userConfig, const string &customUserMessage, int pim, int hashAlg);
+ void WriteBootDriveSector (uint64 offset, uint8 *data);
+ void WriteBootSectorConfig (const uint8 newConfig[]);
+ void WriteBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg);
+ void WriteEfiBootSectorUserConfig (uint8 userConfig, const string &customUserMessage, int pim, int hashAlg);
void WriteLocalMachineRegistryDwordValue (wchar_t *keyPath, wchar_t *valueName, DWORD value);
void GetEfiBootDeviceNumber (PSTORAGE_DEVICE_NUMBER pSdn);
void BackupSystemLoader ();
void RestoreSystemLoader ();
static void UpdateSetupConfigFile (bool bForInstall);
@@ -316,14 +316,14 @@ namespace VeraCrypt
bool IsUsingUnsupportedAlgorithm(LONG driverVersion);
void NotifyService (DWORD dwNotifyCmd);
protected:
static const uint32 RescueIsoImageSize = 1835008; // Size of ISO9660 image with bootable emulated 1.44MB floppy disk image
- void CreateBootLoaderInMemory (byte *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
+ void CreateBootLoaderInMemory (uint8 *buffer, size_t bufferSize, bool rescueDisk, bool hiddenOSCreation = false);
void CreateVolumeHeader (uint64 volumeSize, uint64 encryptedAreaStart, Password *password, int ea, int mode, int pkcs5, int pim);
wstring GetSystemLoaderBackupPath ();
- uint32 GetChecksum (byte *data, size_t size);
+ uint32 GetChecksum (uint8 *data, size_t size);
DISK_GEOMETRY_EX GetDriveGeometry (int driveNumber);
PartitionList GetDrivePartitions (int driveNumber);
wstring GetRemarksOnHiddenOS ();
wstring GetWindowsDirectory ();
void RegisterFilter (bool registerFilter, FilterType filterType, const GUID *deviceClassGuid = nullptr);
@@ -332,15 +332,15 @@ namespace VeraCrypt
HWND ParentWindow;
SystemDriveConfiguration DriveConfig;
int SelectedEncryptionAlgorithmId;
int SelectedPrfAlgorithmId;
Partition HiddenOSCandidatePartition;
- byte *RescueIsoImage;
- byte *RescueZipData;
+ uint8 *RescueIsoImage;
+ uint8 *RescueZipData;
unsigned long RescueZipSize;
- byte RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
- byte VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 RescueVolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
+ uint8 VolumeHeader[TC_BOOT_ENCRYPTION_VOLUME_HEADER_SIZE];
bool DriveConfigValid;
bool RealSystemDriveSizeValid;
bool RescueVolumeHeaderValid;
bool VolumeHeaderValid;
bool PostOOBEMode;
diff --git a/src/Common/Cache.c b/src/Common/Cache.c
index 46249b9c..4826673e 100644
--- a/src/Common/Cache.c
+++ b/src/Common/Cache.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -22,12 +22,10 @@
Password CachedPasswords[CACHE_SIZE];
int CachedPim[CACHE_SIZE];
int cacheEmpty = 1;
static int nPasswordIdx = 0;
-#ifdef _WIN64
-
uint64 VcGetPasswordEncryptionID (Password* pPassword)
{
return ((uint64) pPassword->Text) + ((uint64) pPassword);
}
@@ -39,13 +37,11 @@ void VcProtectPassword (Password* pPassword, uint64 encID)
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;
/* Attempt to recognize volume using mount password */
@@ -54,41 +50,33 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade
nReturnCode = ReadVolumeHeader (bBoot, header, password, pkcs5_prf, pim, retInfo, NULL);
/* 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))
CachedPim[nPasswordIdx] = pim;
else
@@ -105,25 +93,22 @@ 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)
effectivePim = CachedPim[i];
else
@@ -132,48 +117,44 @@ int ReadVolumeHeaderWCache (BOOL bBoot, BOOL bCache, BOOL bCachePim, char *heade
if (nReturnCode != ERR_PASSWORD_WRONG)
break;
}
}
-#ifdef _WIN64
+
if (IsRamEncryptionEnabled())
burn (&tmpPass, sizeof (Password));
-#endif
+
}
return nReturnCode;
}
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;
}
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;
else
CachedPim[nPasswordIdx] = 0;
@@ -182,17 +163,16 @@ void AddPasswordToCache (Password *password, int pim, BOOL bCachePim)
}
else if (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;
memcpy (inputPass.Text, password->Text, password->Length);
diff --git a/src/Common/Cache.h b/src/Common/Cache.h
index 0988bf29..f629d8b8 100644
--- a/src/Common/Cache.h
+++ b/src/Common/Cache.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Common.h"
@@ -19,8 +19,8 @@
#endif
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..ff19b76a 100644
--- a/src/Common/Cmdline.c
+++ b/src/Common/Cmdline.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -49,16 +49,11 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
as = (argumentspec*) 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
StringCchCatW (tmp, 8192, L"\n\nCommand line options:\n\n");
@@ -69,11 +64,11 @@ BOOL CALLBACK CommandHelpDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM
StringCchPrintfW(tmp2, MAX_PATH * 2, L"%s\t%s\n", as->args[i].short_name, as->args[i].long_name);
StringCchCatW(tmp, 8192, tmp2);
}
}
#if defined(TCMOUNT) && !defined(VCEXPANDER)
- StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nDismount a volume X:\tveracrypt.exe /q /d X");
+ StringCchCatW (tmp, 8192, L"\nExamples:\n\nMount a volume as X:\tveracrypt.exe /q /v volume.hc /l X\nUnmount a volume X:\tveracrypt.exe /q /u X");
#endif
SetWindowTextW (GetDlgItem (hwndDlg, IDC_COMMANDHELP_TEXT), tmp);
TCfree(tmp);
return 1;
diff --git a/src/Common/Cmdline.h b/src/Common/Cmdline.h
index 5e0f3509..f1e1fd59 100644
--- a/src/Common/Cmdline.h
+++ b/src/Common/Cmdline.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifdef __cplusplus
diff --git a/src/Common/Combo.c b/src/Common/Combo.c
index 880f0b7a..fec4c0df 100644
--- a/src/Common/Combo.c
+++ b/src/Common/Combo.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
diff --git a/src/Common/Combo.h b/src/Common/Combo.h
index 604395b5..73072b96 100644
--- a/src/Common/Combo.h
+++ b/src/Common/Combo.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifdef __cplusplus
diff --git a/src/Common/CommandAPDU.cpp b/src/Common/CommandAPDU.cpp
index b202cb13..46aab465 100644
--- a/src/Common/CommandAPDU.cpp
+++ b/src/Common/CommandAPDU.cpp
@@ -114,11 +114,11 @@ namespace VeraCrypt
failure:
clear();
}
- void CommandAPDU::init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
+ void CommandAPDU::init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
{
m_nc = 0;
m_ne = 0;
m_dataOffset = 0;
m_isExtendedAPDU = false;
@@ -154,29 +154,29 @@ namespace VeraCrypt
// case 2s or 2e
if (ne <= 256)
{
// case 2s
// 256 is encoded as 0x00
- byte len = (m_ne != 256) ? (byte)m_ne : 0;
+ uint8 len = (m_ne != 256) ? (uint8)m_ne : 0;
m_apdu.resize(5, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = len;
}
else
{
// case 2e
- byte l1, l2;
+ uint8 l1, l2;
// 65536 is encoded as 0x00 0x00
if (m_ne == 65536)
{
l1 = 0;
l2 = 0;
}
else
{
- l1 = (byte)(m_ne >> 8);
- l2 = (byte)m_ne;
+ l1 = (uint8)(m_ne >> 8);
+ l2 = (uint8)m_ne;
}
m_apdu.resize(7, 0);
setHeader(cla, ins, p1, p2);
m_apdu[5] = l1;
m_apdu[6] = l2;
@@ -192,22 +192,22 @@ namespace VeraCrypt
if (dataLength <= 255)
{
// case 3s
m_apdu.resize(4 + 1 + dataLength, 0);
setHeader(cla, ins, p1, p2);
- m_apdu[4] = (byte)dataLength;
+ m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength);
}
else
{
// case 3e
m_apdu.resize(4 + 3 + dataLength, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = 0;
- m_apdu[5] = (byte)(dataLength >> 8);
- m_apdu[6] = (byte)dataLength;
+ m_apdu[5] = (uint8)(dataLength >> 8);
+ m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
m_isExtendedAPDU = true;
}
}
@@ -217,119 +217,119 @@ namespace VeraCrypt
if ((dataLength <= 255) && (m_ne <= 256))
{
// case 4s
m_apdu.resize(4 + 2 + dataLength, 0);
setHeader(cla, ins, p1, p2);
- m_apdu[4] = (byte)dataLength;
+ m_apdu[4] = (uint8)dataLength;
m_dataOffset = 5;
memcpy(m_apdu.data() + 5, data + dataOffset, dataLength);
- m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (byte)m_ne : 0;
+ m_apdu[m_apdu.size() - 1] = (m_ne != 256) ? (uint8)m_ne : 0;
}
else
{
// case 4e
m_apdu.resize(4 + 5 + dataLength, 0);
setHeader(cla, ins, p1, p2);
m_apdu[4] = 0;
- m_apdu[5] = (byte)(dataLength >> 8);
- m_apdu[6] = (byte)dataLength;
+ m_apdu[5] = (uint8)(dataLength >> 8);
+ m_apdu[6] = (uint8)dataLength;
m_dataOffset = 7;
memcpy(m_apdu.data() + 7, data + dataOffset, dataLength);
if (ne != 65536)
{
size_t leOfs = m_apdu.size() - 2;
- m_apdu[leOfs] = (byte)(m_ne >> 8);
- m_apdu[leOfs + 1] = (byte)m_ne;
+ m_apdu[leOfs] = (uint8)(m_ne >> 8);
+ m_apdu[leOfs + 1] = (uint8)m_ne;
} // else le == 65536: no need to fill in, encoded as 0
m_isExtendedAPDU = true;
}
}
}
m_parsedSuccessfully = true;
}
- void CommandAPDU::setHeader(byte cla, byte ins, byte p1, byte p2)
+ void CommandAPDU::setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2)
{
- m_apdu[0] = (byte)cla;
- m_apdu[1] = (byte)ins;
- m_apdu[2] = (byte)p1;
- m_apdu[3] = (byte)p2;
+ m_apdu[0] = (uint8)cla;
+ m_apdu[1] = (uint8)ins;
+ m_apdu[2] = (uint8)p1;
+ m_apdu[3] = (uint8)p2;
}
void CommandAPDU::clear()
{
m_apdu.clear();
m_nc = 0;
m_ne = 0;
m_dataOffset = 0;
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne)
{
init(cla, ins, p1, p2, data, dataOffset, dataLength, ne);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2)
{
init(cla, ins, p1, p2, NULL, 0, 0, 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne)
{
init(cla, ins, p1, p2, NULL, 0, 0, ne);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data)
{
init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength)
{
init(cla, ins, p1, p2, data, dataOffset, dataLength, 0);
}
- CommandAPDU::CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne)
+ CommandAPDU::CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne)
{
init(cla, ins, p1, p2, data.data(), 0, (uint32)data.size(), ne);
}
- CommandAPDU::CommandAPDU(const vector<byte>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false)
+ CommandAPDU::CommandAPDU(const vector<uint8>& apdu) : m_nc(0), m_ne(0), m_dataOffset(0), m_isExtendedAPDU(false)
{
m_apdu = apdu;
parse();
}
- byte CommandAPDU::getCLA()
+ uint8 CommandAPDU::getCLA()
{
return m_apdu[0] & 0xff;
}
- byte CommandAPDU::getINS()
+ uint8 CommandAPDU::getINS()
{
return m_apdu[1] & 0xff;
}
- byte CommandAPDU::getP1()
+ uint8 CommandAPDU::getP1()
{
return m_apdu[2] & 0xff;
}
- byte CommandAPDU::getP2()
+ uint8 CommandAPDU::getP2()
{
return m_apdu[3] & 0xff;
}
uint32 CommandAPDU::getNc()
{
return m_nc;
}
- const vector<byte> CommandAPDU::getData()
+ const vector<uint8> CommandAPDU::getData()
{
- vector<byte> data;
+ vector<uint8> data;
if (m_nc > 0)
{
data.resize(m_nc, 0);
memcpy(data.data(), m_apdu.data() + m_dataOffset, data.size());
@@ -341,11 +341,11 @@ namespace VeraCrypt
uint32 CommandAPDU::getNe()
{
return m_ne;
}
- const vector<byte> CommandAPDU::getAPDU()
+ const vector<uint8> CommandAPDU::getAPDU()
{
return m_apdu;
}
bool CommandAPDU::isExtended()
diff --git a/src/Common/CommandAPDU.h b/src/Common/CommandAPDU.h
index 98825faa..f1adf176 100644
--- a/src/Common/CommandAPDU.h
+++ b/src/Common/CommandAPDU.h
@@ -32,57 +32,57 @@ namespace VeraCrypt
class CommandAPDU
{
protected:
- vector<byte> m_apdu;
+ vector<uint8> m_apdu;
uint32 m_nc;
uint32 m_ne;
uint32 m_dataOffset;
bool m_isExtendedAPDU;
std::string m_parsingErrorStr;
bool m_parsedSuccessfully;
void parse();
- void init(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
- void setHeader(byte cla, byte ins, byte p1, byte p2);
+ void init(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
+ void setHeader(uint8 cla, uint8 ins, uint8 p1, uint8 p2);
public:
void clear();
CommandAPDU();
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength, uint32 ne);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, uint32 ne);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const byte* data, uint32 dataOffset, uint32 dataLength);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const uint8* data, uint32 dataOffset, uint32 dataLength);
- CommandAPDU(byte cla, byte ins, byte p1, byte p2, const vector<byte>& data, uint32 ne);
+ CommandAPDU(uint8 cla, uint8 ins, uint8 p1, uint8 p2, const vector<uint8>& data, uint32 ne);
- CommandAPDU(const vector<byte>& apdu);
+ CommandAPDU(const vector<uint8>& apdu);
- byte getCLA();
+ uint8 getCLA();
- byte getINS();
+ uint8 getINS();
- byte getP1();
+ uint8 getP1();
- byte getP2();
+ uint8 getP2();
uint32 getNc();
- const vector<byte> getData();
+ const vector<uint8> getData();
uint32 getNe();
- const vector<byte> getAPDU();
+ const vector<uint8> getAPDU();
bool isValid();
std::string getErrorStr();
diff --git a/src/Common/Common.h b/src/Common/Common.h
index 62ee3d65..88e034e2 100644
--- a/src/Common/Common.h
+++ b/src/Common/Common.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
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
@@ -342,13 +342,13 @@ END
IDD_TEXT_EDIT_DLG DIALOGEX 0, 0, 372, 220
STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
FONT 8, "MS Shell Dlg", 0, 0, 0x0
BEGIN
- PUSHBUTTON "OK",IDOK,306,201,58,14
+ PUSHBUTTON "OK",IDOK,244,201,58,14
CONTROL "",IDC_INFO_BOX_TEXT,"RichEdit20W",ES_MULTILINE | ES_WANTRETURN | ES_NUMBER | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP,5,6,361,188
- DEFPUSHBUTTON "Cancel",IDCANCEL,240,201,58,14
+ DEFPUSHBUTTON "Cancel",IDCANCEL,308,201,58,14
END
/////////////////////////////////////////////////////////////////////////////
//
@@ -563,21 +563,10 @@ IDR_EFI_LEGACYSPEAKER BIN "..\\Boot\\EFI\\LegacySpeaker.ef
#ifdef VC_EFI_CUSTOM_MODE
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
/////////////////////////////////////////////////////////////////////////////
//
// XML
//
diff --git a/src/Common/Crc.c b/src/Common/Crc.c
index 7e18cb4f..2cda3794 100644
--- a/src/Common/Crc.c
+++ b/src/Common/Crc.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
diff --git a/src/Common/Crc.h b/src/Common/Crc.h
index 53960a79..c59fc823 100644
--- a/src/Common/Crc.h
+++ b/src/Common/Crc.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_CRC
diff --git a/src/Common/Crypto.c b/src/Common/Crypto.c
index 38af7fe5..2f4e447f 100644
--- a/src/Common/Crypto.c
+++ b/src/Common/Crypto.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -24,10 +24,11 @@
#define StringCchCatW RtlStringCchCatW
#define StringCchCopyW RtlStringCchCopyW
#else
#include <strsafe.h>
#endif
+#include "Crypto/t1ha.h"
#include "EncryptionThreadPool.h"
#endif
#endif
#include "Volumes.h"
#include "cpu.h"
@@ -55,19 +56,23 @@ static Cipher Ciphers[] =
{
// Block Size Key Size Key Schedule Size
// ID Name (Bytes) (Bytes) (Bytes)
#ifdef TC_WINDOWS_BOOT
{ AES, "AES", 16, 32, AES_KS },
- { SERPENT, "Serpent", 16, 32, 140*4 },
+#ifndef WOLFCRYPT_BACKEND
+ { SERPENT, "Serpent", 16, 32, 140*4 },
{ TWOFISH, "Twofish", 16, 32, TWOFISH_KS },
+#endif
#else
{ AES, L"AES", 16, 32, AES_KS },
+#ifndef WOLFCRYPT_BACKEND
{ SERPENT, L"Serpent", 16, 32, 140*4 },
{ TWOFISH, L"Twofish", 16, 32, TWOFISH_KS },
{ CAMELLIA, L"Camellia", 16, 32, CAMELLIA_KS },
{ KUZNYECHIK, L"Kuznyechik",16, 32, KUZNYECHIK_KS },
#endif
+#endif
{ 0, 0, 0, 0, 0 }
};
// Encryption algorithm configuration
@@ -77,10 +82,11 @@ static EncryptionAlgorithm EncryptionAlgorithms[] =
#ifndef TC_WINDOWS_BOOT
{ { 0, 0 }, { 0, 0}, 0, 0 }, // Must be all-zero
{ { AES, 0 }, { XTS, 0 }, 1, 1 },
+#ifndef WOLFCRYPT_BACKEND
{ { SERPENT, 0 }, { XTS, 0 }, 1, 1 },
{ { TWOFISH, 0 }, { XTS, 0 }, 1, 1 },
{ { CAMELLIA, 0 }, { XTS, 0 }, 1, 1 },
{ { KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 },
{ { TWOFISH, AES, 0 }, { XTS, 0 }, 1, 1 },
@@ -91,24 +97,27 @@ static EncryptionAlgorithm EncryptionAlgorithms[] =
{ { KUZNYECHIK, CAMELLIA, 0 }, { XTS, 0 }, 0, 1 },
{ { TWOFISH, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 },
{ { SERPENT, CAMELLIA, 0 }, { XTS, 0 }, 0, 1 },
{ { AES, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 },
{ { CAMELLIA, SERPENT, KUZNYECHIK, 0 }, { XTS, 0 }, 0, 1 },
+#endif
{ { 0, 0 }, { 0, 0}, 0, 0 } // Must be all-zero
#else // TC_WINDOWS_BOOT
// Encryption algorithms available for boot drive encryption
{ { 0, 0 }, { 0, 0 }, 0 }, // Must be all-zero
{ { AES, 0 }, { XTS, 0 }, 1 },
+#ifndef WOLFCRYPT_BACKEND
{ { SERPENT, 0 }, { XTS, 0 }, 1 },
{ { TWOFISH, 0 }, { XTS, 0 }, 1 },
{ { TWOFISH, AES, 0 }, { XTS, 0 }, 1 },
{ { SERPENT, TWOFISH, AES, 0 }, { XTS, 0 }, 1 },
{ { AES, SERPENT, 0 }, { XTS, 0 }, 1 },
{ { AES, TWOFISH, SERPENT, 0 }, { XTS, 0 }, 1 },
{ { SERPENT, TWOFISH, 0 }, { XTS, 0 }, 1 },
+#endif
{ { 0, 0 }, { 0, 0 }, 0 }, // Must be all-zero
#endif
};
@@ -117,15 +126,17 @@ static EncryptionAlgorithm EncryptionAlgorithms[] =
#ifndef TC_WINDOWS_BOOT
// Hash algorithms
static Hash Hashes[] =
{ // ID Name Deprecated System Encryption
{ SHA512, L"SHA-512", FALSE, FALSE },
- { WHIRLPOOL, L"Whirlpool", FALSE, FALSE },
- { BLAKE2S, L"BLAKE2s-256", FALSE, TRUE },
{ SHA256, L"SHA-256", FALSE, TRUE },
+ #ifndef WOLFCRYPT_BACKEND
+ { BLAKE2S, L"BLAKE2s-256", FALSE, TRUE },
+ { WHIRLPOOL, L"Whirlpool", FALSE, FALSE },
{ STREEBOG, L"Streebog", FALSE, FALSE },
- { 0, 0, 0 }
+ #endif
+ { 0, 0, 0 }
};
#endif
/* Return values: 0 = success, ERR_CIPHER_INIT_FAILURE (fatal), ERR_CIPHER_INIT_WEAK_KEY (non-fatal) */
int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks)
@@ -145,10 +156,11 @@ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks)
if (aes_set_key (key, (length_type) CipherGetKeySize(AES), (aes_context *) ks) != 0)
return ERR_CIPHER_INIT_FAILURE;
#endif
break;
+#ifndef WOLFCRYPT_BACKEND
case SERPENT:
serpent_set_key (key, ks);
break;
case TWOFISH:
@@ -165,10 +177,11 @@ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks)
case KUZNYECHIK:
kuznyechik_set_key(key, (kuznyechik_kds*)ks);
break;
#endif // !defined(TC_WINDOWS_BOOT)
+#endif
default:
// Unknown/wrong cipher ID
return ERR_CIPHER_INIT_FAILURE;
}
@@ -178,73 +191,60 @@ int CipherInit (int cipher, unsigned char *key, unsigned __int8 *ks)
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
#endif
aes_encrypt (data, data, ks);
break;
+#ifndef WOLFCRYPT_BACKEND
case TWOFISH: twofish_encrypt (ks, data, data); break;
case SERPENT: serpent_encrypt (data, data, ks); break;
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_CAMELLIA)
case CAMELLIA: camellia_encrypt (data, data, ks); break;
#endif
#if !defined(TC_WINDOWS_BOOT)
case KUZNYECHIK: kuznyechik_encrypt_block(data, data, ks); break;
#endif // !defined(TC_WINDOWS_BOOT)
+#endif
default: TC_THROW_FATAL_EXCEPTION; // Unknown/wrong ID
}
}
#ifndef TC_WINDOWS_BOOT
void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{
- byte *data = dataPtr;
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KFLOATING_SAVE floatingPointState;
-#endif
+ uint8 *data = dataPtr;
if (cipher == AES
&& (blockCount & (32 - 1)) == 0
&& IsAesHwCpuSupported()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
while (blockCount > 0)
{
aes_hw_cpu_encrypt_32_blocks (ks, data);
data += 32 * 16;
blockCount -= 32;
}
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
+#ifndef WOLFCRYPT_BACKEND
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
else if (cipher == SERPENT
&& (blockCount >= 4)
&& HasSSE2()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
serpent_encrypt_blocks (data, data, blockCount, ks);
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
#endif
#if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
else if (cipher == TWOFISH) {
twofish_encrypt_blocks(ks, data, data, (uint32) blockCount);
@@ -254,21 +254,16 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
}
#endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
else if (cipher == KUZNYECHIK
&& HasSSE2()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
kuznyechik_encrypt_blocks (data, data, blockCount, ks);
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
#endif
+#endif
else
{
size_t blockSize = CipherGetBlockSize (cipher);
while (blockCount-- > 0)
{
@@ -282,28 +277,28 @@ void EncipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
void DecipherBlock(int cipher, void *data, void *ks)
{
switch (cipher)
{
+#ifndef WOLFCRYPT_BACKEND
case SERPENT: serpent_decrypt (data, data, ks); break;
case TWOFISH: twofish_decrypt (ks, data, data); break;
#if !defined (TC_WINDOWS_BOOT) || defined (TC_WINDOWS_BOOT_CAMELLIA)
case CAMELLIA: camellia_decrypt (data, data, ks); break;
#endif
#if !defined(TC_WINDOWS_BOOT)
case KUZNYECHIK: kuznyechik_decrypt_block(data, data, ks); break;
#endif // !defined(TC_WINDOWS_BOOT)
+#endif
#ifndef TC_WINDOWS_BOOT
case AES:
-#if defined (_WIN64) || !defined (TC_WINDOWS_DRIVER)
if (IsAesHwCpuSupported())
- aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx), data);
+ aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx), data);
else
-#endif
aes_decrypt (data, data, (void *) ((char *) ks + sizeof(aes_encrypt_ctx)));
break;
#else
case AES: aes_decrypt (data, data, ks); break;
@@ -314,48 +309,34 @@ void DecipherBlock(int cipher, void *data, void *ks)
#ifndef TC_WINDOWS_BOOT
void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
{
- byte *data = dataPtr;
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KFLOATING_SAVE floatingPointState;
-#endif
+ uint8 *data = dataPtr;
if (cipher == AES
&& (blockCount & (32 - 1)) == 0
&& IsAesHwCpuSupported()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
while (blockCount > 0)
{
- aes_hw_cpu_decrypt_32_blocks ((byte *) ks + sizeof (aes_encrypt_ctx), data);
+ aes_hw_cpu_decrypt_32_blocks ((uint8 *) ks + sizeof (aes_encrypt_ctx), data);
data += 32 * 16;
blockCount -= 32;
}
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
+#ifndef WOLFCRYPT_BACKEND
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
else if (cipher == SERPENT
&& (blockCount >= 4)
&& HasSSE2()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
serpent_decrypt_blocks (data, data, blockCount, ks);
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
#endif
#if CRYPTOPP_BOOL_X64 && !defined(CRYPTOPP_DISABLE_ASM)
else if (cipher == TWOFISH) {
twofish_decrypt_blocks(ks, data, data, (uint32) blockCount);
@@ -365,21 +346,16 @@ void DecipherBlocks (int cipher, void *dataPtr, void *ks, size_t blockCount)
}
#endif
#if CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && !defined (_UEFI)
else if (cipher == KUZNYECHIK
&& HasSSE2()
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- && (blockCount >= 4) && NT_SUCCESS (KeSaveFloatingPointState (&floatingPointState))
-#endif
)
{
kuznyechik_decrypt_blocks (data, data, blockCount, ks);
-#if defined (TC_WINDOWS_DRIVER) && !defined (_WIN64)
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
}
#endif
+#endif
else
{
size_t blockSize = CipherGetBlockSize (cipher);
while (blockCount-- > 0)
{
@@ -521,12 +497,20 @@ BOOL EAInitMode (PCRYPTO_INFO ci, unsigned char* key2)
{
case XTS:
// Secondary key schedule
if (EAInit (ci->ea, key2, ci->ks2) != ERR_SUCCESS)
return FALSE;
+
+ #ifdef WOLFCRYPT_BACKEND
+ if (xts_encrypt_key256 (key2, (aes_encrypt_ctx *) ci->ks) != EXIT_SUCCESS)
+ return ERR_CIPHER_INIT_FAILURE;
- /* Note: XTS mode could potentially be initialized with a weak key causing all blocks in one data unit
+ if (xts_decrypt_key256 (key2, (aes_decrypt_ctx *) (ci->ks + sizeof(aes_encrypt_ctx))) != EXIT_SUCCESS)
+ return ERR_CIPHER_INIT_FAILURE;
+ #endif
+
+ /* Note: XTS mode could potentially be initialized with a weak key causing all blocks in one data unit
on the volume to be tweaked with zero tweaks (i.e. 512 bytes of the volume would be encrypted in ECB
mode). However, to create a TrueCrypt volume with such a weak key, each human being on Earth would have
to create approximately 11,378,125,361,078,862 (about eleven quadrillion) TrueCrypt volumes (provided
that the size of each of the volumes is 1024 terabytes). */
break;
@@ -629,21 +613,21 @@ 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)
{
case XTS:
return L"XTS";
}
- return L"[unknown]";
+ return L"[UNKNOWN]";
}
#endif // TC_WINDOWS_BOOT
@@ -825,11 +809,11 @@ int GetMaxPkcs5OutSize (void)
#endif // TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
#ifdef TC_WINDOWS_BOOT
-static byte CryptoInfoBufferInUse = 0;
+static uint8 CryptoInfoBufferInUse = 0;
CRYPTO_INFO CryptoInfoBuffer;
#endif
PCRYPTO_INFO crypto_open ()
@@ -861,11 +845,11 @@ PCRYPTO_INFO crypto_open ()
#endif // TC_WINDOWS_BOOT
}
#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));
memcpy (keyInfo->userKey, lpszUserKey, nUserKeyLen);
}
@@ -1088,34 +1072,34 @@ void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s
void EncipherBlock(int cipher, void *data, void *ks)
{
#ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported())
- aes_hw_cpu_encrypt ((byte *) ks, data);
+ aes_hw_cpu_encrypt ((uint8 *) ks, data);
else
aes_encrypt (data, data, ks);
-#elif defined (TC_WINDOWS_BOOT_SERPENT)
+#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_encrypt (data, data, ks);
-#elif defined (TC_WINDOWS_BOOT_TWOFISH)
+#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_encrypt (ks, data, data);
-#elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+#elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_encrypt (data, data, ks);
#endif
}
void DecipherBlock(int cipher, void *data, void *ks)
{
#ifdef TC_WINDOWS_BOOT_AES
if (IsAesHwCpuSupported())
- aes_hw_cpu_decrypt ((byte *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data);
+ aes_hw_cpu_decrypt ((uint8 *) ks + sizeof (aes_encrypt_ctx) + 14 * 16, data);
else
- aes_decrypt (data, data, (aes_decrypt_ctx *) ((byte *) ks + sizeof(aes_encrypt_ctx)));
-#elif defined (TC_WINDOWS_BOOT_SERPENT)
+ aes_decrypt (data, data, (aes_decrypt_ctx *) ((uint8 *) ks + sizeof(aes_encrypt_ctx)));
+#elif defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_decrypt (data, data, ks);
-#elif defined (TC_WINDOWS_BOOT_TWOFISH)
+#elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_decrypt (ks, data, data);
-#elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+#elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_decrypt (data, data, ks);
#endif
}
@@ -1178,12 +1162,10 @@ BOOL IsAesHwCpuSupported ()
state = is_aes_hw_cpu_supported() ? TRUE : FALSE;
stateValid = TRUE;
}
return state && !HwEncryptionDisabled;
-#elif defined (_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
- return 0;
#else
return (HasAESNI() && !HwEncryptionDisabled)? TRUE : FALSE;
#endif
}
@@ -1209,13 +1191,15 @@ BOOL IsHwEncryptionEnabled ()
static BOOL CpuRngDisabled = TRUE;
static BOOL RamEncryptionEnabled = FALSE;
BOOL IsCpuRngSupported ()
{
+#ifndef _M_ARM64
if (HasRDSEED() || HasRDRAND())
return TRUE;
else
+#endif
return FALSE;
}
void EnableCpuRng (BOOL enable)
{
@@ -1227,18 +1211,14 @@ BOOL IsCpuRngEnabled ()
return !CpuRngDisabled;
}
BOOL IsRamEncryptionSupported ()
{
-#ifdef _WIN64
if (t1ha_selfcheck__t1ha2() == 0)
return TRUE;
else
return FALSE;
-#else
- return FALSE;
-#endif
}
void EnableRamEncryption (BOOL enable)
{
RamEncryptionEnabled = enable;
@@ -1248,11 +1228,11 @@ BOOL IsRamEncryptionEnabled ()
{
return RamEncryptionEnabled;
}
/* masking for random index to remove bias */
-byte GetRngMask (byte count)
+uint8 GetRngMask (uint8 count)
{
if (count >= 128)
return 0xFF;
if (count >= 64)
return 0x7F;
@@ -1267,14 +1247,14 @@ byte GetRngMask (byte count)
if (count >= 2)
return 0x03;
return 1;
}
-byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte elementsCount)
+uint8 GetRandomIndex (ChaCha20RngCtx* pCtx, uint8 elementsCount)
{
- byte index = 0;
- byte mask = GetRngMask (elementsCount);
+ uint8 index = 0;
+ uint8 mask = GetRngMask (elementsCount);
while (TRUE)
{
ChaCha20RngGetBytes (pCtx, &index, 1);
index &= mask;
@@ -1283,13 +1263,13 @@ byte GetRandomIndex (ChaCha20RngCtx* pCtx, byte 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 byte* pbKeyDerivationArea = NULL;
+static uint8* pbKeyDerivationArea = NULL;
static ULONG cbKeyDerivationArea = 0;
static uint64 HashSeedMask = 0;
static uint64 CipherIVMask = 0;
#ifdef TC_WINDOWS_DRIVER
@@ -1301,13 +1281,13 @@ ULONG AllocTag = 'MMCV';
#endif
BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
{
ChaCha20RngCtx ctx;
- byte pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
+ uint8 pbSeed[CHACHA20RNG_KEYSZ + CHACHA20RNG_IVSZ];
#ifdef TC_WINDOWS_DRIVER
- byte i;
+ uint8 i;
char randomStr[4];
Dump ("InitializeSecurityParameters BEGIN\n");
#endif
rngCallback (pbSeed, sizeof (pbSeed));
@@ -1360,11 +1340,11 @@ BOOL InitializeSecurityParameters(GetRandSeedFn rngCallback)
#endif
cbKeyDerivationArea = 1024 * 1024;
do
{
- pbKeyDerivationArea = (byte*) TCalloc(cbKeyDerivationArea);
+ pbKeyDerivationArea = (uint8*) TCalloc(cbKeyDerivationArea);
if (!pbKeyDerivationArea)
cbKeyDerivationArea >>= 1;
} while (!pbKeyDerivationArea && (cbKeyDerivationArea >= (2*PAGE_SIZE)));
if (!pbKeyDerivationArea)
@@ -1499,31 +1479,5 @@ void VcUnprotectKeys (PCRYPTO_INFO pCryptoInfo, uint64 encID)
}
#endif
#endif
-#if defined(_M_ARM64) || defined(__arm__) || defined (__arm64__) || defined (__aarch64__)
-/* dummy implementation that should never be called */
-void aes_hw_cpu_decrypt(const byte* ks, byte* data)
-{
- ks = ks;
- data = data;
-}
-
-void aes_hw_cpu_decrypt_32_blocks(const byte* ks, byte* data)
-{
- ks = ks;
- data = data;
-}
-
-void aes_hw_cpu_encrypt(const byte* ks, byte* data)
-{
- ks = ks;
- data = data;
-}
-
-void aes_hw_cpu_encrypt_32_blocks(const byte* ks, byte* data)
-{
- ks = ks;
- data = data;
-}
-#endif
diff --git a/src/Common/Crypto.h b/src/Common/Crypto.h
index 178e08e1..81ec791e 100644
--- a/src/Common/Crypto.h
+++ b/src/Common/Crypto.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
/* Update the following when adding a new cipher or EA:
@@ -206,13 +206,11 @@ typedef struct
# include "Streebog.h"
# include "kuznyechik.h"
# include "Camellia.h"
#if !defined (_UEFI)
# include "chachaRng.h"
-# ifdef _WIN64
# include "t1ha.h"
-# endif
#endif
#else
# include "CamelliaSmall.h"
#endif
@@ -226,13 +224,13 @@ typedef struct
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
typedef struct CRYPTO_INFO_t
@@ -275,10 +273,12 @@ typedef struct CRYPTO_INFO_t
uint16 RequiredProgramVersion;
BOOL LegacyVolume;
uint32 SectorSize;
+ BOOL bVulnerableMasterKey; // TRUE if XTS primary key is identical to secondary key (i.e. the volume is vulnerable to attack on XTS mode)
+
#endif // !TC_WINDOWS_BOOT
UINT64_STRUCT VolumeSize;
UINT64_STRUCT EncryptedAreaStart;
@@ -305,11 +305,11 @@ typedef struct BOOT_CRYPTO_HEADER_t
#endif
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);
int CipherGetBlockSize (int cipher);
@@ -344,11 +344,11 @@ int EAGetByName (wchar_t *name);
#endif
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 ();
int EAGetLargestKeyForMode (int mode);
@@ -382,11 +382,11 @@ void EncryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *s
void DecryptDataUnits (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, uint32 nbrUnits, PCRYPTO_INFO ci);
void DecryptDataUnitsCurrentThread (unsigned __int8 *buf, const UINT64_STRUCT *structUnitNo, TC_LARGEST_COMPILER_UINT nbrUnits, PCRYPTO_INFO ci);
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
void VcProtectMemory (uint64 encID, unsigned char* pbData, size_t cbData, unsigned char* pbData2, size_t cbData2);
#else
diff --git a/src/Common/Dictionary.c b/src/Common/Dictionary.c
index 47dcb0a4..5915760c 100644
--- a/src/Common/Dictionary.c
+++ b/src/Common/Dictionary.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Dictionary.h b/src/Common/Dictionary.h
index f0be2183..972ec832 100644
--- a/src/Common/Dictionary.h
+++ b/src/Common/Dictionary.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Dlgcode.c b/src/Common/Dlgcode.c
index 7ad0fdb0..6c98b4d7 100644
--- a/src/Common/Dlgcode.c
+++ b/src/Common/Dlgcode.c
@@ -4,18 +4,19 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
#include <windowsx.h>
+#include <versionhelpers.h>
#include <dbghelp.h>
#include <dbt.h>
#include <Setupapi.h>
#include <aclapi.h>
#include <Netlistmgr.h>
@@ -308,16 +309,16 @@ static unsigned char gpbSha512CodeSignCertFingerprint[64] = {
0xA4, 0x37, 0xD6, 0xDB, 0x26, 0xBA, 0xDC, 0x8F, 0x86, 0x96, 0x55, 0x96,
0xDB, 0x6F, 0xC0, 0x62
};
static unsigned char gpbSha512MSCodeSignCertFingerprint[64] = {
- 0xEB, 0x76, 0x2E, 0xD3, 0x5B, 0x4A, 0xB1, 0x0E, 0xF5, 0x3B, 0x99, 0x4E,
- 0xC1, 0xF7, 0x48, 0x88, 0xF6, 0xA0, 0xE9, 0xAC, 0x32, 0x69, 0xCF, 0x20,
- 0xE1, 0x60, 0xC4, 0x0C, 0xEF, 0x01, 0x1F, 0xCB, 0x41, 0x95, 0x72, 0xB9,
- 0xED, 0x63, 0x0C, 0x6B, 0xB9, 0xE9, 0xA2, 0x72, 0xA6, 0x78, 0x96, 0x4C,
- 0x69, 0x9F, 0x90, 0x3F, 0xB1, 0x3C, 0x64, 0xF2, 0xAB, 0xCF, 0x14, 0x1D,
- 0xEC, 0x7C, 0xB0, 0xC7
+ 0x17, 0x8C, 0x1B, 0x37, 0x70, 0xBF, 0x8B, 0xDF, 0x84, 0x55, 0xC5, 0x18,
+ 0x13, 0x64, 0xE9, 0x65, 0x6D, 0x67, 0xCA, 0x0C, 0xD6, 0x3B, 0x9E, 0x7B,
+ 0x9B, 0x6A, 0x63, 0xD6, 0x19, 0xAE, 0xD7, 0xBA, 0xBE, 0x5C, 0xCB, 0xD1,
+ 0x07, 0x89, 0x07, 0xFB, 0x12, 0xC0, 0x2C, 0x94, 0x86, 0xEB, 0x67, 0x0B,
+ 0x9C, 0x97, 0xEB, 0x20, 0x38, 0x13, 0x9C, 0x0F, 0x56, 0x93, 0x1B, 0x19,
+ 0x6F, 0x8F, 0x6A, 0x39
};
/* Windows dialog class */
#define WINDOWS_DIALOG_CLASS L"#32770"
@@ -588,22 +589,31 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile,
{
HANDLE dst;
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))
{
dst = CreateFile (destinationFile,
GENERIC_WRITE,
@@ -614,14 +624,24 @@ BOOL SaveBufferToFile (const char *inputBuffer, const wchar_t *destinationFile,
/* restore the original file name */
MoveFileEx (renamedPath, destinationFile, MOVEFILE_REPLACE_EXISTING);
}
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)
{
SetLastError (dwLastError);
@@ -846,10 +866,79 @@ BOOL TCCopyFile (wchar_t *sourceFileName, wchar_t *destinationFile)
}
return TCCopyFileBase (src, dst);
}
+#if !defined(_WIN64) && defined(NDEBUG) && !defined (VC_SKIP_OS_DRIVER_REQ_CHECK)
+// in 32-bit build, Crypto project is not compiled so we need to provide this function here
+
+#pragma comment(lib, "bcrypt.lib")
+
+void sha512(unsigned char* result, const unsigned char* source, uint64_t sourceLen)
+{
+ BCRYPT_ALG_HANDLE hAlg = NULL;
+ BCRYPT_HASH_HANDLE hHash = NULL;
+ NTSTATUS status = 0;
+
+ // Open an algorithm provider for SHA512.
+ status = BCryptOpenAlgorithmProvider(
+ &hAlg,
+ BCRYPT_SHA512_ALGORITHM,
+ NULL,
+ 0);
+ if (!BCRYPT_SUCCESS(status))
+ {
+ goto cleanup;
+ }
+
+ // Create a hash handle.
+ status = BCryptCreateHash(
+ hAlg,
+ &hHash,
+ NULL,
+ 0,
+ NULL, // Optional secret, not needed for SHA512
+ 0,
+ 0);
+ if (!BCRYPT_SUCCESS(status))
+ {
+ goto cleanup;
+ }
+
+ // Hash the data. Note: BCryptHashData takes an ULONG for the length.
+ status = BCryptHashData(
+ hHash,
+ (PUCHAR)source,
+ (ULONG)sourceLen,
+ 0);
+ if (!BCRYPT_SUCCESS(status))
+ {
+ goto cleanup;
+ }
+
+ // Finalize the hash computation and write the result.
+ status = BCryptFinishHash(
+ hHash,
+ result,
+ SHA512_DIGESTSIZE,
+ 0);
+ if (!BCRYPT_SUCCESS(status))
+ {
+ goto cleanup;
+ }
+
+cleanup:
+ if (hHash)
+ {
+ BCryptDestroyHash(hHash);
+ }
+ if (hAlg)
+ {
+ BCryptCloseAlgorithmProvider(hAlg, 0);
+ }
+}
+#endif
BOOL VerifyModuleSignature (const wchar_t* path)
{
#if defined(NDEBUG) && !defined (VC_SKIP_OS_DRIVER_REQ_CHECK)
BOOL bResult = FALSE;
@@ -857,15 +946,10 @@ BOOL VerifyModuleSignature (const wchar_t* path)
GUID gActionID = WINTRUST_ACTION_GENERIC_VERIFY_V2;
WINTRUST_FILE_INFO fileInfo = {0};
WINTRUST_DATA WVTData = {0};
wchar_t filePath [TC_MAX_PATH + 1024];
- // we check our own authenticode signature only starting from Windows 10 since this is
- // the minimal supported OS apart from XP where we can't verify SHA256 signatures
- if (!IsOSAtLeast (WIN_10))
- return TRUE;
-
// Strip quotation marks (if any)
if (path [0] == L'"')
{
StringCbCopyW (filePath, sizeof(filePath), path + 1);
}
@@ -1029,10 +1113,24 @@ BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack)
return ((CurrentOSMajor << 16 | CurrentOSMinor << 8 | CurrentOSServicePack)
>= (major << 16 | minor << 8 | reqMinServicePack));
}
+BOOL IsWin10BuildAtLeast(int minBuild)
+{
+ // Must first be recognized as Windows 10 or higher
+ if (nCurrentOS < WIN_10)
+ return FALSE;
+
+ // If we’re on Windows 10, check build number
+ if (nCurrentOS == WIN_10 && CurrentOSBuildNumber < minBuild)
+ return FALSE;
+
+ // If we are on a higher version of Windows, we are good to go
+ return TRUE;
+}
+
#ifdef SETUP_DLL
static BOOL GetWindowVersionFromFile(DWORD* pdwMajor, DWORD* pdwMinor, DWORD* pdwBuildNumber)
{
wchar_t dllPath[MAX_PATH];
BOOL bRet = FALSE;
@@ -1086,13 +1184,10 @@ static BOOL GetWindowsVersion(LPOSVERSIONINFOW lpVersionInformation)
{
if (ERROR_SUCCESS == RtlGetVersionFn (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
if (GetWindowVersionFromFile(&dwMajor, &dwMinor, &dwBuildNumber))
{
@@ -2131,16 +2226,12 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
SetWindowPos (GetDlgItem (hwndDlg, IDC_ABOUT_BKG), HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
}
// Version
SendMessage (GetDlgItem (hwndDlg, IDT_ABOUT_VERSION), WM_SETFONT, (WPARAM) hUserBoldFont, 0);
- StringCbPrintfW (szTmp, sizeof(szTmp), L"VeraCrypt %s", _T(VERSION_STRING) _T(VERSION_STRING_SUFFIX));
-#ifdef _WIN64
- StringCbCatW (szTmp, sizeof(szTmp), L" (64-bit)");
-#else
- StringCbCatW (szTmp, sizeof(szTmp), L" (32-bit)");
-#endif
+ 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
SetDlgItemText (hwndDlg, IDT_ABOUT_VERSION, szTmp);
SetDlgItemText (hwndDlg, IDT_ABOUT_RELEASE, TC_STR_RELEASED_BY);
@@ -2154,11 +2245,11 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
case WM_APP:
SetWindowText (GetDlgItem (hwndDlg, IDC_ABOUT_CREDITS),
L"Based on TrueCrypt 7.1a, freely available at http://www.truecrypt.org/ .\r\n\r\n"
L"Portions of this software:\r\n"
- L"Copyright \xA9 2013-2023 IDRIX. All rights reserved.\r\n"
+ L"Copyright \xA9 2013-2025 IDRIX. All rights reserved.\r\n"
L"Copyright \xA9 2003-2012 TrueCrypt Developers Association. All Rights Reserved.\r\n"
L"Copyright \xA9 1998-2000 Paul Le Roux. All Rights Reserved.\r\n"
L"Copyright \xA9 1998-2008 Brian Gladman. All Rights Reserved.\r\n"
L"Copyright \xA9 1995-2023 Jean-loup Gailly and Mark Adler.\r\n"
L"Copyright \xA9 2016 Disk Cryptography Services for EFI (DCS), Alex Kolotnikov.\r\n"
@@ -2167,11 +2258,11 @@ BOOL CALLBACK AboutDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam
L"Copyright \xA9 1999-2016 Jack Lloyd. All rights reserved.\r\n"
L"Copyright \xA9 2013-2019 Stephan Mueller <smueller@chronox.de>\r\n"
L"Copyright \xA9 1999-2023 Igor Pavlov\r\n\r\n"
L"This software as a whole:\r\n"
- L"Copyright \xA9 2013-2023 IDRIX. All rights reserved.\r\n\r\n"
+ L"Copyright \xA9 2013-2025 IDRIX. All rights reserved.\r\n\r\n"
L"An IDRIX Release");
return 1;
@@ -2882,11 +2973,11 @@ LRESULT CALLBACK CustomDlgProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lPar
/*
static BOOL IsReturnAddress (DWORD64 address)
{
static size_t codeEnd = 0;
- byte *sp = (byte *) address;
+ uint8 *sp = (uint8 *) address;
if (codeEnd == 0)
{
MEMORY_BASIC_INFORMATION mi;
if (VirtualQuery ((LPCVOID) 0x401000, &mi, sizeof (mi)) >= sizeof (mi))
@@ -3016,11 +3107,11 @@ void ExceptionHandlerThread (void *threadArg)
retAddrs.push_back (0);
MEMORY_BASIC_INFORMATION mi;
VirtualQuery (sp, &mi, sizeof (mi));
- PDWORD stackTop = (PDWORD)((byte *) mi.BaseAddress + mi.RegionSize);
+ PDWORD stackTop = (PDWORD)((uint8 *) mi.BaseAddress + mi.RegionSize);
int i = 0;
while (retAddrs.size() < 16 && &sp[i] < stackTop)
{
if (IsReturnAddress (sp[i]))
@@ -3169,11 +3260,11 @@ BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_
ShowWindow (hWnd, SW_SHOWNORMAL);
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);
return FALSE;
}
@@ -3601,14 +3692,20 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
#endif
INITCOMMONCONTROLSEX InitCtrls;
InitOSVersionInfo();
- if (!IsOSAtLeast (WIN_7))
+ if (!IsWin10BuildAtLeast(WIN_10_1809_BUILD))
+ {
+ // abort using a message that says that VeraCrypt can run only on Windows 10 version 1809 or later
+ AbortProcessDirect(L"VeraCrypt requires at least Windows 10 version 1809 (October 2018 Update) to run.");
+ }
+
+ if (!Is64BitOs())
{
- // 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 64-bit Windows
+ AbortProcessDirect(L"VeraCrypt requires a 64-bit version of Windows to run.");
}
SetDefaultDllDirectoriesFn = (SetDefaultDllDirectoriesPtr) GetProcAddress (GetModuleHandle(L"kernel32.dll"), "SetDefaultDllDirectories");
if (!SetDefaultDllDirectoriesFn)
{
@@ -3792,18 +3889,18 @@ void InitApp (HINSTANCE hInstance, wchar_t *lpszCommandLine)
(DLGPROC) AuxiliaryDlgProc, (LPARAM) 1);
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);
exit (1);
}
@@ -3914,11 +4011,11 @@ 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);
}
#ifndef SETUP
@@ -3944,15 +4041,16 @@ BOOL GetSysDevicePaths (HWND hwndDlg)
if (device.ContainsSystem)
StringCchCopyW (device.IsPartition ? SysPartitionDevicePath : SysDriveDevicePath, TC_MAX_PATH, device.Path.c_str());
}
// 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)
{
if (sysDrivePartition.Size <= TC_MAX_EXTRA_BOOT_PARTITION_SIZE)
ExtraBootPartitionDevicePath = sysDrivePartition.Path;
@@ -4163,23 +4261,58 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
switch (msg)
{
case WM_INITDIALOG:
{
prm = (TEXT_INFO_DIALOG_PARAM_PTR)lParam;
+ LocalizeDialog (hwndDlg, NULL);
// increase size limit of rich edit control
SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_EXLIMITTEXT, 0, -1);
SetWindowTextW (hwndDlg, prm->Title);
// Left margin for rich edit text field
SendMessage (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETMARGINS, (WPARAM) EC_LEFTMARGIN, (LPARAM) CompensateXDPI (4));
if (prm->ReadOnly)
{
// switch rich edit control to ReadOnly
- SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), ES_READONLY, TRUE, 0);
+ SendMessage(GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), EM_SETREADONLY , TRUE, 0);
// hide cancel button
- ShowWindow(GetDlgItem(hwndDlg, IDCANCEL), SW_HIDE);
+ HWND hwndCancel = GetDlgItem(hwndDlg, IDCANCEL);
+ ShowWindow(hwndCancel, SW_HIDE);
+
+ // Reposition OK button to Cancel button's position
+ HWND hwndOK = GetDlgItem(hwndDlg, IDOK);
+ if (hwndOK && hwndCancel)
+ {
+ // Get Cancel button's position in screen coordinates
+ RECT rectCancel;
+ if (GetWindowRect(hwndCancel, &rectCancel))
+ {
+ // Convert Cancel button's position to dialog's client coordinates
+ POINT ptCancel = { rectCancel.left, rectCancel.top };
+ ScreenToClient(hwndDlg, &ptCancel);
+
+ // Get OK button's current size
+ RECT rectOK;
+ if (GetWindowRect(hwndOK, &rectOK))
+ {
+ int width = rectOK.right - rectOK.left;
+ int height = rectOK.bottom - rectOK.top;
+
+ // Move OK button to Cancel button's position
+ SetWindowPos(
+ hwndOK,
+ NULL,
+ ptCancel.x,
+ ptCancel.y,
+ width,
+ height,
+ SWP_NOZORDER | SWP_NOACTIVATE
+ );
+ }
+ }
+ }
}
SendMessage (hwndDlg, TC_APPMSG_LOAD_TEXT_BOX_CONTENT, 0, 0);
}
return 0;
@@ -4187,12 +4320,16 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
case WM_COMMAND:
if (lw == IDOK )
{
if (!prm->ReadOnly)
{
- prm->Text.resize(GetWindowTextLengthA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT)) + 1);
- GetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), &(prm->Text)[0], (int) prm->Text.size());
+ // read content of the text box as UTF16 and then convert it to UTF8
+ HWND hEdit = GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT);
+ int size = GetWindowTextLengthW(hEdit);
+ std::vector<WCHAR> buffer(size + 1);
+ GetWindowTextW(hEdit, buffer.data(), size + 1);
+ prm->Text = WideToUtf8String(buffer.data());
}
NormalCursor ();
EndDialog (hwndDlg, IDOK);
return 1;
}
@@ -4205,11 +4342,12 @@ BOOL CALLBACK TextEditDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
}
return 0;
case TC_APPMSG_LOAD_TEXT_BOX_CONTENT:
{
- SetWindowTextA (GetDlgItem (hwndDlg, IDC_INFO_BOX_TEXT), prm->Text.c_str());
+ // convert prm->Text to UTF16 using Utf8StringToWide
+ SetWindowTextW(GetDlgItem(hwndDlg, IDC_INFO_BOX_TEXT), Utf8StringToWide(prm->Text).c_str());
}
return 0;
case WM_CLOSE:
NormalCursor ();
@@ -4828,11 +4966,11 @@ static int DriverLoad ()
driverPath[1] = 0;
}
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);
if (file == INVALID_HANDLE_VALUE)
{
@@ -5352,11 +5490,11 @@ BOOL SelectMultipleFiles(HWND hwndDlg, const char *stringId, BOOL keepHistory, s
CoUninitialize();
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;
BOOL bOK = FALSE;
@@ -5377,13 +5515,13 @@ BOOL BrowseDirectories(HWND hwndDlg, char *lpszTitle, wchar_t *dirName, const wc
dwFlags |= FOS_PICKFOLDERS | FOS_FORCEFILESYSTEM | FOS_NOCHANGEDIR; // Important to enable folder-picking mode
hr = pfd->SetOptions(dwFlags);
}
// Set the title.
- if (lpszTitle)
+ if (lpszDlgTitle)
{
- pfd->SetTitle(GetString(lpszTitle));
+ pfd->SetTitle(GetString(lpszDlgTitle));
}
IShellItem *psi;
if (initialDir)
{
@@ -5575,10 +5713,18 @@ void handleError (HWND hwndDlg, int code, const char* srcPos)
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("CAPI_RAND"), SRC_POS, CryptoAPILastError);
MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, MB_ICONERROR);
break;
#endif
+ case ERR_XTS_MASTERKEY_VULNERABLE:
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_XTS_MASTERKEY_VULNERABLE"), srcPos).c_str(), lpszTitle, ICON_HAND);
+ break;
+
+ case ERR_SYSENC_XTS_MASTERKEY_VULNERABLE:
+ MessageBoxW (hwndDlg, AppendSrcPos (GetString ("ERR_SYSENC_XTS_MASTERKEY_VULNERABLE"), srcPos).c_str(), lpszTitle, ICON_HAND);
+ break;
+
default:
StringCbPrintfW (szTmp, sizeof(szTmp), GetString ("ERR_UNKNOWN"), code);
MessageBoxW (hwndDlg, AppendSrcPos (szTmp, srcPos).c_str(), lpszTitle, ICON_HAND);
}
}
@@ -5709,11 +5855,11 @@ 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));
BOOL bToBeDeleted = FALSE;
@@ -5794,28 +5940,28 @@ wstring ArrayToHexWideString (const unsigned char* pbData, int cbData)
}
return result;
}
-bool HexToByte (wchar_t c, byte& b)
+bool HexToByte (wchar_t c, uint8& b)
{
bool bRet = true;
if (c >= L'0' && c <= L'9')
- b = (byte) (c - L'0');
+ b = (uint8) (c - L'0');
else if (c >= L'a' && c <= L'z')
- b = (byte) (c - L'a' + 10);
+ b = (uint8) (c - L'a' + 10);
else if (c >= L'A' && c <= L'Z')
- b = (byte) (c - L'A' + 10);
+ b = (uint8) (c - L'A' + 10);
else
bRet = false;
return bRet;
}
-bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr)
+bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr)
{
- byte b1, b2;
+ uint8 b1, b2;
size_t i, len = wcslen (hexStr);
arr.clear();
if (len %2)
return false;
@@ -6141,15 +6287,17 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
/* Measures the speed at which each of the hash algorithms processes the message to produce
a single digest.
*/
{
BYTE digest [MAX_DIGESTSIZE];
- WHIRLPOOL_CTX wctx;
- blake2s_state bctx;
+ #ifndef WOLFCRYPT_BACKEND
+ WHIRLPOOL_CTX wctx;
+ STREEBOG_CTX stctx;
+ blake2s_state bctx;
+ #endif
sha512_ctx s2ctx;
sha256_ctx s256ctx;
- STREEBOG_CTX stctx;
int hid, i;
for (hid = FIRST_PRF_ID; hid <= LAST_PRF_ID; hid++)
{
@@ -6170,11 +6318,11 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
case SHA256:
sha256_begin (&s256ctx);
sha256_hash (lpTestBuffer, benchmarkBufferSize, &s256ctx);
sha256_end ((unsigned char *) digest, &s256ctx);
break;
-
+ #ifndef WOLFCRYPT_BACKEND
case BLAKE2S:
blake2s_init(&bctx);
blake2s_update(&bctx, lpTestBuffer, benchmarkBufferSize);
blake2s_final(&bctx, (unsigned char *) digest);
break;
@@ -6190,11 +6338,12 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
STREEBOG_add(&stctx, lpTestBuffer, benchmarkBufferSize);
STREEBOG_finalize(&stctx, (unsigned char *)digest);
break;
}
- }
+ #endif
+ }
if (QueryPerformanceCounter (&performanceCountEnd) == 0)
goto counter_error;
benchmarkTable[benchmarkTotalItems].encSpeed = performanceCountEnd.QuadPart - performanceCountStart.QuadPart;
@@ -6213,11 +6362,11 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
/* Measures the time that it takes for the PKCS-5 routine to derive a header key using
each of the implemented PRF algorithms.
*/
{
int thid, i;
- char dk[MASTER_KEYDATA_SIZE];
+ 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++)
{
if (benchmarkPreBoot && !benchmarkGPT && !HashForSystemEncryption (thid))
@@ -6231,34 +6380,35 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
switch (thid)
{
case SHA512:
/* PKCS-5 test with HMAC-SHA-512 used as the PRF */
- derive_key_sha512 ("passphrase-1234567890", 21, tmp_salt, 64, get_pkcs5_iteration_count(thid, benchmarkPim, benchmarkPreBoot), dk, MASTER_KEYDATA_SIZE);
+ 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
+ }
if (QueryPerformanceCounter (&performanceCountEnd) == 0)
goto counter_error;
benchmarkTable[benchmarkTotalItems].encSpeed = performanceCountEnd.QuadPart - performanceCountStart.QuadPart;
@@ -6274,23 +6424,15 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
}
else
{
if (thid == SHA256)
{
-#ifdef _WIN64
benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 26);
-#else
- benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 24);
-#endif
}
else
{
-#ifdef _WIN64
benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 21) / 5;
-#else
- benchmarkTable[benchmarkTotalItems].meanBytesPerSec = (benchmarkTable[benchmarkTotalItems].meanBytesPerSec * 18) / 5;
-#endif
}
}
}
StringCbPrintfW (benchmarkTable[benchmarkTotalItems].name, sizeof(benchmarkTable[benchmarkTotalItems].name),L"%s", get_pkcs5_prf_name (thid));
@@ -6309,14 +6451,12 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
{
ci->mode = FIRST_MODE_OF_OPERATION_ID;
if (EAInitMode (ci, ci->k2))
{
int i;
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
VcProtectKeys (ci, VcGetEncryptionID (ci));
-#endif
for (i = 0; i < 10; i++)
{
EncryptDataUnits (lpTestBuffer, &startDataUnitNo, (TC_LARGEST_COMPILER_UINT) benchmarkBufferSize / ENCRYPTION_DATA_UNIT_SIZE, ci);
DecryptDataUnits (lpTestBuffer, &startDataUnitNo, (TC_LARGEST_COMPILER_UINT) benchmarkBufferSize / ENCRYPTION_DATA_UNIT_SIZE, ci);
@@ -6334,14 +6474,12 @@ static BOOL PerformBenchmark(HWND hBenchDlg, HWND hwndDlg)
ci->mode = FIRST_MODE_OF_OPERATION_ID;
if (!EAInitMode (ci, ci->k2))
goto counter_error;
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
VcProtectKeys (ci, VcGetEncryptionID (ci));
-#endif
if (QueryPerformanceCounter (&performanceCountStart) == 0)
goto counter_error;
EncryptDataUnits (lpTestBuffer, &startDataUnitNo, (TC_LARGEST_COMPILER_UINT) benchmarkBufferSize / ENCRYPTION_DATA_UNIT_SIZE, ci);
@@ -7585,11 +7723,11 @@ CipherTestDialogProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
crypto_close (ci);
}
else
{
- CipherInit2(idTestCipher, key, ks_tmp, ks);
+ CipherInit2(idTestCipher, key, ks_tmp);
if (bEncrypt)
{
EncipherBlock(idTestCipher, tmp, ks_tmp);
}
@@ -8149,11 +8287,11 @@ int DriverUnmountVolume (HWND hwndDlg, int nDosDriveNo, BOOL forced)
}
unmount.nDosDriveNo = nDosDriveNo;
unmount.ignoreOpenFiles = forced;
- bResult = DeviceIoControl (hDriver, TC_IOCTL_DISMOUNT_VOLUME, &unmount,
+ bResult = DeviceIoControl (hDriver, TC_IOCTL_UNMOUNT_VOLUME, &unmount,
sizeof (unmount), &unmount, sizeof (unmount), &dwResult, NULL);
if (bResult == FALSE)
{
handleWin32Error (hwndDlg, SRC_POS);
@@ -8207,11 +8345,11 @@ void BroadcastDeviceChange (WPARAM message, int nDosDriveNo, DWORD driveMap)
{
for (i = 0; i < 26; i++)
{
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);
}
}
@@ -8710,11 +8848,11 @@ retry:
StringCchCopyW (volumePath, TC_MAX_PATH, resolvedPath.c_str());
}
if ((path.length () >= 3) && (_wcsnicmp (path.c_str(), L"ID:", 3) == 0))
{
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if ( (path.length() == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (path.c_str() + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE)
)
{
@@ -8764,16 +8902,16 @@ 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)
{
STORAGE_ACCESS_ALIGNMENT_DESCRIPTOR accessDesc;
STORAGE_ADAPTER_DESCRIPTOR adapterDesc;
@@ -8906,22 +9044,22 @@ retry:
goto 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);
}
}
@@ -8947,14 +9085,20 @@ retry:
Warning ("HEADER_DAMAGED_AUTO_USED_HEADER_BAK", hwndDlg);
}
LastMountedVolumeDirty = mount.FilesystemDirty;
+ if (mount.VolumeMasterKeyVulnerable
+ && !Silent)
+ {
+ Warning ("ERR_XTS_MASTERKEY_VULNERABLE", hwndDlg);
+ }
+
if (mount.FilesystemDirty)
{
wchar_t msg[1024];
- wchar_t mountPoint[] = { L'A' + (wchar_t) driveNo, L':', 0 };
+ wchar_t mountPoint[] = { (wchar_t) (L'A' + driveNo), L':', 0 };
StringCbPrintfW (msg, sizeof(msg), GetString ("MOUNTED_VOLUME_DIRTY"), mountPoint);
if (AskWarnYesNoStringTopmost (msg, hwndDlg) == IDYES)
CheckFilesystem (hwndDlg, driveNo, TRUE);
}
@@ -8964,33 +9108,33 @@ retry:
&& !bDevice
&& !FileHasReadOnlyAttribute (volumePath)
&& !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);
}
if (mount.VolumeMountedReadOnlyAfterAccessDenied
&& !Silent
&& 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);
}
if (mount.VolumeMountedReadOnlyAfterDeviceWriteProtected
&& !Silent
&& 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);
if (CurrentOSMajor >= 6
@@ -9004,11 +9148,11 @@ retry:
if (mount.VolumeMountedReadOnlyAfterPartialSysEnc
&& !Silent
&& 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);
}
@@ -9097,11 +9241,11 @@ retry:
forced = TRUE;
goto 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;
}
@@ -9162,11 +9306,11 @@ BOOL IsMountedVolumeID (BYTE volumeID[VOLUME_ID_SIZE])
BOOL IsMountedVolume (const wchar_t *volname)
{
if ((wcslen (volname) == (3 + 2*VOLUME_ID_SIZE)) && _wcsnicmp (volname, L"ID:", 3) == 0)
{
/* Volume ID specified. Use it for matching mounted volumes. */
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if (HexWideStringToArray (&volname[3], arr) && (arr.size() == VOLUME_ID_SIZE))
{
return IsMountedVolumeID (&arr[0]);
}
}
@@ -9451,11 +9595,11 @@ int GetDiskDeviceDriveLetter (PWSTR deviceName)
if (!ResolveSymbolicLink (deviceName, device, sizeof(device)))
StringCchCopyW (device, MAX_PATH, 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);
if ( ResolveSymbolicLink (link, target, sizeof(target))
@@ -10144,11 +10288,11 @@ wchar_t *GetProgramConfigPath (wchar_t *fileName)
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);
GetSystemWow64Directory_t getSystemWow64Directory = (GetSystemWow64Directory_t) GetProcAddress (GetModuleHandle (L"kernel32"), "GetSystemWow64DirectoryW");
getSystemWow64Directory (sysPath, ARRAYSIZE (sysPath));
@@ -10649,16 +10793,16 @@ void OpenPageHelp (HWND hwndDlg, int nPage)
else
Applink ("help");
}
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)
{
// Open local HTML help. It will fallback to online help if not found.
Applink ("help");
@@ -10881,18 +11025,15 @@ BOOL IsARM()
#endif
}
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)
{
static BOOL statusCached = FALSE;
@@ -10963,104 +11104,109 @@ BOOL RestartComputer (BOOL bShutdown)
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
extern wchar_t InstallationPath[TC_MAX_PATH];
#endif
@@ -11069,11 +11215,11 @@ void Applink (const char *dest)
{
wchar_t url [MAX_URL_LENGTH] = {0};
wchar_t page[TC_MAX_PATH] = {0};
wchar_t installDir[TC_MAX_PATH] = {0};
BOOL buildUrl = TRUE;
- int r;
+ INT_PTR r;
ArrowWaitCursor ();
#ifdef SETUP
StringCbCopyW (installDir, sizeof (installDir), InstallationPath);
@@ -11273,11 +11419,11 @@ void Applink (const char *dest)
SafeOpenURL (url);
}
}
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)
{
// fallback to online resources
StringCbPrintfW (url, sizeof (url), L"https://www.veracrypt.fr/en/%s", page);
@@ -11420,11 +11566,11 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password
{
int status = ERR_PARAMETER_INCORRECT;
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;
context->VolumeIsOpen = FALSE;
@@ -11571,11 +11717,11 @@ int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password
goto error;
}
// Read volume header
DWORD bytesRead;
- if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (byte *) buffer, &bytesRead))
+ if (!ReadEffectiveVolumeHeader (context->IsDevice, context->HostFileHandle, (uint8 *) buffer, &bytesRead))
{
status = ERR_OS_ERROR;
goto error;
}
@@ -11634,11 +11780,11 @@ void CloseVolume (OpenVolumeContext *context)
context->VolumeIsOpen = FALSE;
}
-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;
RandSetHashFunction (cryptoInfo->pkcs5);
@@ -12156,11 +12302,11 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
wchar_t keyfilePath[TC_MAX_PATH];
if (BrowseFiles (hwndDlg, "SELECT_KEYFILE", keyfilePath, bHistory, FALSE))
{
DWORD keyfileSize;
- byte *keyfileData = (byte *) LoadFile (keyfilePath, &keyfileSize);
+ uint8 *keyfileData = (uint8 *) LoadFile (keyfilePath, &keyfileSize);
if (!keyfileData)
{
handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
@@ -12174,11 +12320,11 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
if (lastBackSlash != string::npos)
newParams.Name = newParams.Name.substr (lastBackSlash + 1);
if (DialogBoxParamW (hInst, MAKEINTRESOURCEW (IDD_NEW_TOKEN_KEYFILE), hwndDlg, (DLGPROC) NewSecurityTokenKeyfileDlgProc, (LPARAM) &newParams) == IDOK)
{
- vector <byte> keyfileDataVector (keyfileSize);
+ vector <uint8> keyfileDataVector (keyfileSize);
memcpy (&keyfileDataVector.front(), keyfileData, keyfileSize);
try
{
WaitCursor();
@@ -12223,22 +12369,22 @@ BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam
{
WaitCursor();
finally_do ({ NormalCursor(); });
- vector <byte> keyfileData;
+ vector <uint8> keyfileData;
keyfile->GetKeyfileData (keyfileData);
if (keyfileData.empty())
{
SetLastError (ERROR_HANDLE_EOF);
handleWin32Error (hwndDlg, SRC_POS);
return 1;
}
- finally_do_arg (vector <byte> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
+ finally_do_arg (vector <uint8> *, &keyfileData, { burn (&finally_arg->front(), finally_arg->size()); });
if (!SaveBufferToFile ((char *) &keyfileData.front(), keyfilePath, (DWORD) keyfileData.size(), FALSE, FALSE))
throw SystemException (SRC_POS);
}
@@ -12999,11 +13145,11 @@ 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;
StringCbPrintfW (msg, sizeof(msg), GetString (fixErrors ? "REPAIRING_FS" : "CHECKING_FS"), driveRoot);
@@ -13017,11 +13163,11 @@ void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors)
StringCbCopyW(cmdPath, sizeof(cmdPath), L"C:\\Windows\\System32\\cmd.exe");
ShellExecuteW (NULL, (!IsAdmin() && IsUacSupported()) ? L"runas" : L"open", cmdPath, param, NULL, SW_SHOW);
}
-BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize)
+BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize)
{
if (bufferSize < patternSize)
return FALSE;
bufferSize -= patternSize;
@@ -13034,18 +13180,18 @@ BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *p
return FALSE;
}
-BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str)
+BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str)
{
- return BufferContainsPattern (buffer, bufferSize, (const byte*) str, strlen (str));
+ return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, strlen (str));
}
-BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str)
+BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str)
{
- return BufferContainsPattern (buffer, bufferSize, (const byte*) str, 2 * wcslen (str));
+ return BufferContainsPattern (buffer, bufferSize, (const uint8*) str, 2 * wcslen (str));
}
#ifndef SETUP
@@ -13245,22 +13391,22 @@ 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;
}
@@ -13501,11 +13647,11 @@ void RegisterDriverInf (bool registerFilter, const string& filter, const string&
string infTxt = "[veracrypt]\r\n"
+ string (registerFilter ? "Add" : "Del") + "Reg=veracrypt_reg\r\n\r\n"
"[veracrypt_reg]\r\n"
"HKR,,\"" + filterReg + "\",0x0001" + string (registerFilter ? "0008" : "8002") + ",\"" + filter + "\"\r\n";
- infFile.Write ((byte *) infTxt.c_str(), (DWORD) infTxt.size());
+ infFile.Write ((uint8 *) infTxt.c_str(), (DWORD) infTxt.size());
infFile.Close();
HINF hInf = SetupOpenInfFileW (infFileName.c_str(), NULL, INF_STYLE_OLDNT | INF_STYLE_WIN4, NULL);
throw_sys_if (hInf == INVALID_HANDLE_VALUE);
finally_do_arg (HINF, hInf, { SetupCloseInfFile (finally_arg); });
@@ -13576,11 +13722,11 @@ void AllowMessageInUIPI (UINT msg)
{
/* ChangeWindowMessageFilter is used to enable some messages bypasss UIPI (User Interface Privilege Isolation) */
ChangeWindowMessageFilter (msg, MSGFLT_ADD);
}
-BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize)
+BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize)
{
if (buffer && bufferSize)
{
size_t i;
for (i = 0; i < bufferSize; i++)
@@ -13600,11 +13746,11 @@ BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue)
{
BOOL bRet = TRUE;
size_t pathLen = pathValue? wcslen (pathValue) : 0;
if ((pathLen >= 3) && (_wcsnicmp (pathValue, L"ID:", 3) == 0))
{
- std::vector<byte> arr;
+ std::vector<uint8> arr;
if ( (pathLen == (3 + 2*VOLUME_ID_SIZE))
&& HexWideStringToArray (pathValue + 3, arr)
&& (arr.size() == VOLUME_ID_SIZE)
)
{
@@ -13686,15 +13832,15 @@ BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable)
{
if (LookupPrivilegeValue(NULL, szPrivilegeName,
&tkp.Privileges[0].Luid))
{
tkp.PrivilegeCount = 1;
- tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : SE_PRIVILEGE_REMOVED;
+ tkp.Privileges[0].Attributes = bEnable? SE_PRIVILEGE_ENABLED : 0;
bRet = AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, NULL, NULL);
dwLastError = GetLastError ();
- if ( ERROR_SUCCESS != dwLastError)
+ if (bRet && (ERROR_NOT_ALL_ASSIGNED == dwLastError))
{
bRet = FALSE;
}
}
else
@@ -13901,24 +14047,37 @@ static unsigned int __stdcall SecureDesktopThread( LPVOID lpThreadParameter )
}
StringCbCopy(SecureDesktopName, sizeof (SecureDesktopName), pParam->szDesktopName);
pParam->hDesk = hSecureDesk;
- // wait for SwitchDesktop to succeed before using it for current thread
- while (true)
+ bNewDesktopSet = SetThreadDesktop (hSecureDesk);
+
+ if (bNewDesktopSet)
{
- if (SwitchDesktop (hSecureDesk))
+ // call ImmDisableIME from imm32.dll to disable IME since it can create issue with secure desktop
+ // cf: https://keepass.info/help/kb/sec_desk.html#ime
+ HMODULE hImmDll = LoadLibraryEx (L"imm32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
+ if (hImmDll)
{
- break;
+ typedef BOOL (WINAPI *ImmDisableIME_t)(DWORD);
+ ImmDisableIME_t ImmDisableIME = (ImmDisableIME_t) GetProcAddress (hImmDll, "ImmDisableIME");
+ if (ImmDisableIME)
+ {
+ ImmDisableIME (0);
+ }
}
- Sleep (SECUREDESKTOP_MONOTIR_PERIOD);
- }
- bNewDesktopSet = SetThreadDesktop (hSecureDesk);
+ // wait for SwitchDesktop to succeed before using it for current thread
+ while (true)
+ {
+ if (SwitchDesktop (hSecureDesk))
+ {
+ break;
+ }
+ Sleep (SECUREDESKTOP_MONOTIR_PERIOD);
+ }
- if (bNewDesktopSet)
- {
// create the thread that will ensure that VeraCrypt secure desktop has always user input
// this is done only if the stop event is created successfully
HANDLE hStopEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
if (hStopEvent)
{
@@ -13944,10 +14103,16 @@ static unsigned int __stdcall SecureDesktopThread( LPVOID lpThreadParameter )
{
CloseHandle (hStopEvent);
}
pParam->bDlgDisplayed = TRUE;
+
+ // free imm32.dll handle
+ if (hImmDll)
+ {
+ FreeLibrary (hImmDll);
+ }
}
else
{
pParam->bDlgDisplayed = FALSE;
}
@@ -14064,23 +14229,24 @@ INT_PTR SecureDesktopDialogBoxParam(
if (param.bDlgDisplayed)
{
// dialog box was indeed displayed in Secure Desktop
retValue = param.retValue;
bSuccess = TRUE;
+
+ // switch back to the original desktop
+ while (!SwitchDesktop (hOriginalDesk))
+ {
+ Sleep (SECUREDESKTOP_MONOTIR_PERIOD);
+ }
+
+ SetThreadDesktop (hOriginalDesk);
}
- }
- if (param.hDesk)
- {
- while (!SwitchDesktop (hOriginalDesk))
+ if (param.hDesk)
{
- Sleep (SECUREDESKTOP_MONOTIR_PERIOD);
+ CloseDesktop (param.hDesk);
}
-
- SetThreadDesktop (hOriginalDesk);
-
- CloseDesktop (param.hDesk);
}
// get the new list of ctfmon.exe processes in order to find the ID of the
// ctfmon.exe instance that corresponds to the desktop we create so that
// we can kill it, otherwise it would remain running
@@ -14160,21 +14326,18 @@ void GetInstallationPath (HWND hwndDlg, wchar_t* szInstallPath, DWORD cchSize, B
// Default "Program Files" path.
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\\");
StringCbCopyW (szInstallPath, cchSize, path);
}
@@ -14234,22 +14397,26 @@ BOOL BufferHasPattern (const unsigned char* buffer, size_t bufferLen, const void
}
return bRet;
}
-/* Implementation borrowed from KeePassXC source code (https://github.com/keepassxreboot/keepassxc/blob/release/2.4.0/src/core/Bootstrap.cpp#L150)
+/* Implementation borrowed from KeePassXC source code (https://github.com/keepassxreboot/keepassxc/blob/2.7.8/src/core/Bootstrap.cpp#L121)
*
* Reduce current user acess rights for this process to the minimum in order to forbid non-admin users from reading the process memory.
+ * Restrict access to changing DACL's after the process is started. This prevents the creator of veracrypt process from simply adding
+ * the permission to read memory back to the DACL list.
*/
BOOL ActivateMemoryProtection()
{
BOOL bSuccess = FALSE;
// Process token and user
HANDLE hToken = NULL;
PTOKEN_USER pTokenUser = NULL;
DWORD cbBufferSize = 0;
+ PSID pOwnerRightsSid = NULL;
+ DWORD pOwnerRightsSidSize = SECURITY_MAX_SID_SIZE;
// Access control list
PACL pACL = NULL;
DWORD cbACL = 0;
@@ -14286,12 +14453,23 @@ BOOL ActivateMemoryProtection()
if (!IsValidSid(pTokenUser->User.Sid)) {
goto Cleanup;
}
+ // Retrieve CreaterOwnerRights SID
+ pOwnerRightsSid = (PSID) HeapAlloc(GetProcessHeap(), 0, pOwnerRightsSidSize);
+ if (pOwnerRightsSid == NULL) {
+ goto Cleanup;
+ }
+
+ if (!CreateWellKnownSid(WinCreatorOwnerRightsSid, NULL, pOwnerRightsSid, &pOwnerRightsSidSize)) {
+ goto Cleanup;
+ }
+
// Calculate the amount of memory that must be allocated for the DACL
- cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid);
+ cbACL = sizeof(ACL) + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pTokenUser->User.Sid)
+ + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(pOwnerRightsSid);
// Create and initialize an ACL
pACL = (PACL) HeapAlloc(GetProcessHeap(), 0, cbACL);
if (pACL == NULL) {
goto Cleanup;
@@ -14309,10 +14487,21 @@ BOOL ActivateMemoryProtection()
pTokenUser->User.Sid // pointer to the trustee's SID
)) {
goto Cleanup;
}
+ // Explicitly set "Process Owner" rights to Read Only. The default is Full Control.
+ if (!AddAccessAllowedAce(
+ pACL,
+ ACL_REVISION,
+ READ_CONTROL,
+ pOwnerRightsSid
+ )) {
+ goto Cleanup;
+ }
+
+
// Set discretionary access control list
bSuccess = (ERROR_SUCCESS == SetSecurityInfo(GetCurrentProcess(), // object handle
SE_KERNEL_OBJECT, // type of object
DACL_SECURITY_INFORMATION, // change only the objects DACL
NULL,
@@ -14327,10 +14516,13 @@ BOOL ActivateMemoryProtection()
Cleanup:
if (pACL != NULL) {
HeapFree(GetProcessHeap(), 0, pACL);
}
+ if (pOwnerRightsSid != NULL) {
+ HeapFree(GetProcessHeap(), 0, pOwnerRightsSid);
+ }
if (pTokenUser != NULL) {
HeapFree(GetProcessHeap(), 0, pTokenUser);
}
if (hToken != NULL) {
CloseHandle(hToken);
@@ -14714,20 +14906,20 @@ void SafeOpenURL (LPCWSTR szUrl)
{
ShellExecuteW (NULL, L"open", szUrl, NULL, NULL, SW_SHOWNORMAL);
}
}
-#if !defined(SETUP) && defined(_WIN64)
+#if !defined(SETUP)
#define RtlGenRandom SystemFunction036
extern "C" BOOLEAN NTAPI RtlGenRandom(PVOID RandomBuffer, ULONG RandomBufferLength);
void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
{
LARGE_INTEGER iSeed;
SYSTEMTIME sysTime;
- byte digest[WHIRLPOOL_DIGESTSIZE];
+ uint8 digest[WHIRLPOOL_DIGESTSIZE];
WHIRLPOOL_CTX tctx;
size_t count;
while (cbRandSeed)
{
@@ -14758,18 +14950,20 @@ void GetAppRandomSeed (unsigned char* pbRandSeed, size_t cbRandSeed)
WHIRLPOOL_add (digest, (unsigned int) rndLen, &tctx);
jent_entropy_collector_free (ec);
}
}
+#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if enabled
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (digest, sizeof (digest)))
|| (HasRDRAND() && RDRAND_getBytes (digest, sizeof (digest)))
))
{
WHIRLPOOL_add (digest, sizeof(digest), &tctx);
}
+#endif
WHIRLPOOL_finalize (&tctx, digest);
count = VC_MIN (cbRandSeed, sizeof (digest));
// copy digest value to seed buffer
@@ -15155,11 +15349,11 @@ void PasswordEditDropTarget::GotLeave(void)
// GotEnter
// ************************************************************
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)
if (hChild && GetClassName (hChild, szClassName, ARRAYSIZE (szClassName)) && (0 == _tcsicmp (szClassName, _T("EDIT")))
&& (dwStyles = GetWindowLongPtr (hChild, GWL_STYLE)) && !(dwStyles & ES_NUMBER)
@@ -15181,11 +15375,11 @@ void PasswordEditDropTarget::GotDrop(CLIPFORMAT format)
{
// value contains the material itself
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")))
&& (dwStyles = GetWindowLongPtr (hChild, GWL_STYLE)) && !(dwStyles & ES_NUMBER)
&& (maxLen = (int) SendMessage (hChild, EM_GETLIMITTEXT, 0, 0)) && (maxLen == MAX_PASSWORD || maxLen == MAX_LEGACY_PASSWORD)
@@ -15669,6 +15863,194 @@ DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize)
}
}
return dwRet;
}
-#endif // VC_COMREG \ No newline at end of file
+#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
diff --git a/src/Common/Dlgcode.h b/src/Common/Dlgcode.h
index 750b4dc7..aaaad97e 100644
--- a/src/Common/Dlgcode.h
+++ b/src/Common/Dlgcode.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_DLGCODE
@@ -284,10 +284,13 @@ typedef NTSTATUS (WINAPI *NtQuerySystemInformationFn)(
#define YES_NO MB_YESNO
#define ISO_BURNER_TOOL L"isoburn.exe"
#define PRINT_TOOL L"notepad.exe"
+#define WIN_10_1607_BUILD 14393 // Windows 10 version 1607 corresponds to build 14393
+#define WIN_10_1809_BUILD 17763 // Windows 10 version 1809 corresponds to build 17763
+
void InitGlobalLocks ();
void FinalizeGlobalLocks ();
void cleanup ( void );
void LowerCaseCopy ( wchar_t *lpszDest , const wchar_t *lpszSource );
void UpperCaseCopy ( wchar_t *lpszDest , size_t cbDest, const wchar_t *lpszSource );
@@ -498,10 +501,11 @@ void RestoreDefaultKeyFilesParam (void);
BOOL LoadDefaultKeyFilesParam (void);
void Debug (char *format, ...);
void DebugMsgBox (char *format, ...);
BOOL IsOSAtLeast (OSVersionEnum reqMinOS);
BOOL IsOSVersionAtLeast (OSVersionEnum reqMinOS, int reqMinServicePack);
+BOOL IsWin10BuildAtLeast(int minBuild);
BOOL IsSupportedOS ();
BOOL Is64BitOs ();
BOOL IsARM();
BOOL IsServerOS ();
BOOL IsHiddenOSRunning (void);
@@ -538,23 +542,23 @@ void MakeControlsContiguous(HWND hwndDlg, UINT ctrl1ID, UINT ctrl2ID);
BOOL GetDriveLabel (int driveNo, wchar_t *label, int labelSize);
BOOL GetSysDevicePaths (HWND hwndDlg);
BOOL DoDriverInstall (HWND hwndDlg);
int OpenVolume (OpenVolumeContext *context, const wchar_t *volumePath, Password *password, int pkcs5_prf, int pim, BOOL write, BOOL preserveTimestamps, BOOL useBackupHeader);
void CloseVolume (OpenVolumeContext *context);
-int ReEncryptVolumeHeader (HWND hwndDlg, char *buffer, BOOL bBoot, CRYPTO_INFO *cryptoInfo, Password *password, int pim, BOOL wipeMode);
+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 ();
BOOL CALLBACK SecurityTokenPasswordDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL CALLBACK SecurityTokenKeyfileDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam);
BOOL InitSecurityTokenLibrary (HWND hwndDlg);
BOOL FileHasReadOnlyAttribute (const wchar_t *path);
BOOL IsFileOnReadOnlyFilesystem (const wchar_t *path);
void CheckFilesystem (HWND hwndDlg, int driveNo, BOOL fixErrors);
-BOOL BufferContainsPattern (const byte *buffer, size_t bufferSize, const byte *pattern, size_t patternSize);
-BOOL BufferContainsString (const byte *buffer, size_t bufferSize, const char *str);
-BOOL BufferContainsWideString (const byte *buffer, size_t bufferSize, const wchar_t *str);
+BOOL BufferContainsPattern (const uint8 *buffer, size_t bufferSize, const uint8 *pattern, size_t patternSize);
+BOOL BufferContainsString (const uint8 *buffer, size_t bufferSize, const char *str);
+BOOL BufferContainsWideString (const uint8 *buffer, size_t bufferSize, const wchar_t *str);
int AskNonSysInPlaceEncryptionResume (HWND hwndDlg, BOOL* pbDecrypt);
BOOL RemoveDeviceWriteProtection (HWND hwndDlg, wchar_t *devicePath);
void EnableElevatedCursorChange (HWND parent);
BOOL DisableFileCompression (HANDLE file);
BOOL VolumePathExists (const wchar_t *volumePath);
@@ -571,11 +575,11 @@ LSTATUS DeleteRegistryKey (HKEY, LPCTSTR);
HIMAGELIST CreateImageList(int cx, int cy, UINT flags, int cInitial, int cGrow);
int AddBitmapToImageList(HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask);
HRESULT VCStrDupW(LPCWSTR psz, LPWSTR *ppwsz);
void ProcessEntropyEstimate (HWND hProgress, DWORD* pdwInitialValue, DWORD dwCounter, DWORD dwMaxLevel, DWORD* pdwEntropy);
void AllowMessageInUIPI (UINT msg);
-BOOL IsRepeatedByteArray (byte value, const byte* buffer, size_t bufferSize);
+BOOL IsRepeatedByteArray (uint8 value, const uint8* buffer, size_t bufferSize);
BOOL TranslateVolumeID (HWND hwndDlg, wchar_t* pathValue, size_t cchPathValue);
BOOL CopyTextToClipboard (const wchar_t* txtValue);
BOOL LaunchElevatedProcess (HWND hwndDlg, const wchar_t* szModPath, const wchar_t* args);
BOOL GetFreeDriveLetter(WCHAR* pCh);
BOOL SetPrivilege(LPTSTR szPrivilegeName, BOOL bEnable);
@@ -592,14 +596,36 @@ BOOL ActivateMemoryProtection();
void SafeOpenURL (LPCWSTR szUrl);
BitLockerEncryptionStatus GetBitLockerEncryptionStatus(WCHAR driveLetter);
BOOL IsTestSigningModeEnabled ();
DWORD SendServiceNotification (DWORD dwNotificationCmd);
DWORD FastResizeFile (const wchar_t* filePath, __int64 fileSize);
-#ifdef _WIN64
+#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
}
#include <vector>
#include <string>
@@ -712,11 +738,11 @@ std::wstring VolumeGuidPathToDevicePath (std::wstring volumeGuidPath);
std::wstring HarddiskVolumePathToPartitionPath (const std::wstring &harddiskVolumePath);
std::wstring FindLatestFileOrDirectory (const std::wstring &directory, const wchar_t *namePattern, bool findDirectory, bool findFile);
std::wstring GetUserFriendlyVersionString (int version);
std::wstring IntToWideString (int val);
std::wstring ArrayToHexWideString (const unsigned char* pbData, int cbData);
-bool HexWideStringToArray (const wchar_t* hexStr, std::vector<byte>& arr);
+bool HexWideStringToArray (const wchar_t* hexStr, std::vector<uint8>& arr);
std::wstring FindDeviceByVolumeID (const BYTE volumeID [VOLUME_ID_SIZE], BOOL bFromService);
void RegisterDriverInf (bool registerFilter, const std::string& filter, const std::string& filterReg, HWND ParentWindow, HKEY regKey);
std::wstring GetTempPathString ();
void CorrectFileName (std::wstring& fileName);
inline std::wstring AppendSrcPos (const wchar_t* msg, const char* srcPos)
diff --git a/src/Common/EMVCard.cpp b/src/Common/EMVCard.cpp
index e96422b1..59dc3cf0 100644
--- a/src/Common/EMVCard.cpp
+++ b/src/Common/EMVCard.cpp
@@ -38,23 +38,23 @@ namespace VeraCrypt
return result;
}
#endif
- map<EMVCardType, vector<byte>> InitializeSupportedAIDs()
+ map<EMVCardType, vector<uint8>> InitializeSupportedAIDs()
{
- map<EMVCardType, vector<byte>> supportedAIDs;
- supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<byte>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + sizeof(EMVCard::AMEX_AID))));
- supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<byte>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + sizeof(EMVCard::MASTERCARD_AID))));
- supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<byte>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID))));
+ map<EMVCardType, vector<uint8>> supportedAIDs;
+ supportedAIDs.insert(std::make_pair(EMVCardType::AMEX, vector<uint8>(EMVCard::AMEX_AID, EMVCard::AMEX_AID + sizeof(EMVCard::AMEX_AID))));
+ supportedAIDs.insert(std::make_pair(EMVCardType::MASTERCARD, vector<uint8>(EMVCard::MASTERCARD_AID, EMVCard::MASTERCARD_AID + sizeof(EMVCard::MASTERCARD_AID))));
+ supportedAIDs.insert(std::make_pair(EMVCardType::VISA, vector<uint8>(EMVCard::VISA_AID, EMVCard::VISA_AID + sizeof(EMVCard::VISA_AID))));
return supportedAIDs;
}
- const byte EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10};
- const byte EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10};
- const byte EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10};
- const map<EMVCardType, vector<byte>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs();
+ const uint8 EMVCard::AMEX_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x00, 0x25, 0x10};
+ const uint8 EMVCard::MASTERCARD_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x04, 0x10, 0x10};
+ const uint8 EMVCard::VISA_AID[7] = {0xA0, 0x00, 0x00, 0x00, 0x03, 0x10, 0x10};
+ const map<EMVCardType, vector<uint8>> EMVCard::SUPPORTED_AIDS = InitializeSupportedAIDs();
EMVCard::EMVCard() : SCard(), m_lastPANDigits(L"")
{
}
@@ -128,30 +128,30 @@ namespace VeraCrypt
m_issuerCert.clear();
m_cplcData.clear();
m_lastPANDigits.clear();
}
- vector<byte> EMVCard::GetCardAID(bool forceContactless)
+ vector<uint8> EMVCard::GetCardAID(bool forceContactless)
{
- vector<vector<byte>> supportedAIDs;
- vector<byte> supportedAIDsPriorities;
- vector<pair<byte, vector<byte>>> supportedAIDsSorted;
+ vector<vector<uint8>> supportedAIDs;
+ vector<uint8> supportedAIDsPriorities;
+ vector<pair<uint8, vector<uint8>>> supportedAIDsSorted;
bool hasBeenReset = false;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> fciNode;
shared_ptr<TLVNode> dfNameNode;
shared_ptr<TLVNode> sfiNode;
shared_ptr<TLVNode> fciIssuerNode;
shared_ptr<TLVNode> fciIssuerDiscretionaryDataNode;
shared_ptr<TLVNode> templateNode;
vector<shared_ptr<TLVNode>> pseDirectoryNodes;
unsigned char sfi;
bool usingContactless = false;
- vector<byte> tokenAID;
+ vector<uint8> tokenAID;
if (m_aid.size())
return m_aid;
if (m_reader)
@@ -239,11 +239,11 @@ namespace VeraCrypt
sfiNode = TLVParser::TLV_Find(fciIssuerNode, EMV_SFI_TAG);
if (sfiNode && sfiNode->Value->size() == 1)
{
sfi = sfiNode->Value->at(0);
- byte rec = 1;
+ uint8 rec = 1;
do
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec++, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response);
if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0)
@@ -314,24 +314,24 @@ namespace VeraCrypt
}
return tokenAID;
}
- void EMVCard::GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData)
+ void EMVCard::GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData)
{
bool hasBeenReset = false;
bool aidSelected = false;
bool iccFound = false;
bool issuerFound = false;
bool cplcFound = false;
- vector<byte> emvCardAid;
+ vector<uint8> emvCardAid;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> iccPublicKeyCertNode;
shared_ptr<TLVNode> issuerPublicKeyCertNode;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
iccCert.clear();
issuerCert.clear();
cplcData.clear();
@@ -372,13 +372,13 @@ namespace VeraCrypt
{
aidSelected = true;
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL,
// which will then be used to get the actual start and end of sfi and rec.
- for (byte sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++)
+ for (uint8 sfi = 1; sfi < 32 && (!iccFound || !issuerFound); sfi++)
{
- for (byte rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++)
+ for (uint8 rec = 1; rec < 17 && (!iccFound || !issuerFound); rec++)
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response);
if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0)
{
@@ -434,17 +434,17 @@ namespace VeraCrypt
void EMVCard::GetCardPAN(wstring& lastPANDigits)
{
bool hasBeenReset = false;
bool panFound = false;
bool aidSelected = false;
- vector<byte> EMVCardAid;
- vector<byte> panData;
+ vector<uint8> EMVCardAid;
+ vector<uint8> panData;
shared_ptr<TLVNode> rootNode;
shared_ptr<TLVNode> panNode;
CommandAPDU command;
ResponseAPDU response;
- vector<byte> responseData;
+ vector<uint8> responseData;
lastPANDigits = L"";
if (m_lastPANDigits != L"")
{
@@ -472,13 +472,13 @@ namespace VeraCrypt
{
aidSelected = true;
// TODO: Send GET PROCESSING OPTIONS to get the AIL and AFL,
// which will then be used to get the actual start and end of sfi and rec.
- for (byte sfi = 1; sfi < 32 && !panFound; sfi++)
+ for (uint8 sfi = 1; sfi < 32 && !panFound; sfi++)
{
- for (byte rec = 1; rec < 17 && !panFound; rec++)
+ for (uint8 rec = 1; rec < 17 && !panFound; rec++)
{
command = CommandAPDU(CLA_ISO7816, INS_READ_RECORD, rec, (sfi << 3) | 4, SCardReader::shortAPDUMaxTransSize);
m_reader->ApduProcessData(command, response);
if (response.getSW() == SW_NO_ERROR && response.getData().size() > 0)
{
@@ -496,11 +496,11 @@ namespace VeraCrypt
panNode = TLVParser::TLV_Find(rootNode, EMV_PAN_TAG);
if (panNode && panNode->Value->size() >= 8)
{
panFound = true;
panData = *panNode->Value.get();
- panData = vector<byte>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits
+ panData = vector<uint8>(panData.rbegin(), panData.rbegin() + 2); // only interested in last digits
std::swap(panData[0], panData[1]);
lastPANDigits = ArrayToHexWideString(panData.data(), (int) panData.size());
}
}
}
diff --git a/src/Common/EMVCard.h b/src/Common/EMVCard.h
index 116de705..70ef035f 100644
--- a/src/Common/EMVCard.h
+++ b/src/Common/EMVCard.h
@@ -27,26 +27,26 @@ namespace VeraCrypt
// The following fields will only be empty if the card has not been read yet.
// After the card has been read, and if some or all fields cannot be read, the EMVCard
// object will be considered invalid and will not be included in the list of available cards
// of EMVToken.
- vector<byte> m_aid;
- vector<vector<byte>> m_supportedAids;
- vector<byte> m_iccCert;
- vector<byte> m_issuerCert;
- vector<byte> m_cplcData;
+ vector<uint8> m_aid;
+ vector<vector<uint8>> m_supportedAids;
+ vector<uint8> m_iccCert;
+ vector<uint8> m_issuerCert;
+ vector<uint8> m_cplcData;
wstring m_lastPANDigits;
public:
// Add other AIDS
// https://gist.github.com/pvieito/6224eed92c99b069f6401996c548d0e4
// https://ambimat.com/developer-resources/list-of-application-identifiers-aid/
- const static byte AMEX_AID[7];
- const static byte MASTERCARD_AID[7];
- const static byte VISA_AID[7];
- const static map<EMVCardType, vector<byte>> SUPPORTED_AIDS;
+ const static uint8 AMEX_AID[7];
+ const static uint8 MASTERCARD_AID[7];
+ const static uint8 VISA_AID[7];
+ const static map<EMVCardType, vector<uint8>> SUPPORTED_AIDS;
EMVCard();
EMVCard(size_t slotId);
EMVCard(const EMVCard& other);
EMVCard(EMVCard&& other);
@@ -57,13 +57,13 @@ namespace VeraCrypt
void Clear(void);
// Retrieves the card's AID.
// It first checks the card against a list of supported AIDs.
// If that fails, it tries getting the AID from the card using PSE
- vector<byte> GetCardAID(bool forceContactless = false);
+ vector<uint8> GetCardAID(bool forceContactless = false);
- void GetCardContent(vector<byte>& iccCert, vector<byte>& issuerCert, vector<byte>& cplcData);
+ void GetCardContent(vector<uint8>& iccCert, vector<uint8>& issuerCert, vector<uint8>& cplcData);
void GetCardPAN(wstring& lastPANDigits);
};
}
#endif // TC_HEADER_Common_EMVCard
diff --git a/src/Common/EMVToken.cpp b/src/Common/EMVToken.cpp
index 0fe3dc1f..8f89cb7e 100644
--- a/src/Common/EMVToken.cpp
+++ b/src/Common/EMVToken.cpp
@@ -20,11 +20,11 @@
using namespace std;
namespace VeraCrypt
{
- void AppendData(vector<byte>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false)
+ void AppendData(vector<uint8>& buffer, const unsigned char* pbData, size_t cbData, size_t from, size_t length, bool bEncodeLength = false)
{
if (cbData > 0 && from <= cbData - 2 && length > 0 && length <= cbData - from)
{
size_t offset = (bEncodeLength ? 4 : 0);
size_t orgSize = buffer.size();
@@ -72,17 +72,17 @@ namespace VeraCrypt
wstringstream path;
path << TC_EMV_TOKEN_KEYFILE_URL_PREFIX TC_EMV_TOKEN_KEYFILE_URL_SLOT L"/" << Token->SlotId;
return path.str();
}
- void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const
+ void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const
{
map <unsigned long int, shared_ptr<EMVCard>>::iterator emvCardsIt;
shared_ptr<EMVCard> card;
- vector<byte> iccCert;
- vector<byte> issuerCert;
- vector<byte> cplcData;
+ vector<uint8> iccCert;
+ vector<uint8> issuerCert;
+ vector<uint8> cplcData;
bool addNewCard = true;
keyfileData.clear();
emvCardsIt = EMVToken::EMVCards.find(Token->SlotId);
diff --git a/src/Common/EMVToken.h b/src/Common/EMVToken.h
index a1c0a2e1..d82ea542 100644
--- a/src/Common/EMVToken.h
+++ b/src/Common/EMVToken.h
@@ -21,21 +21,21 @@ namespace VeraCrypt
EMVTokenKeyfile();
EMVTokenKeyfile(const TokenKeyfilePath& path);
virtual ~EMVTokenKeyfile() {};
virtual operator TokenKeyfilePath () const;
- virtual void GetKeyfileData(vector <byte>& keyfileData) const;
+ virtual void GetKeyfileData(vector <uint8>& keyfileData) const;
};
class EMVToken
{
public:
static bool IsKeyfilePathValid(const wstring& emvTokenKeyfilePath);
static vector<EMVTokenKeyfile> GetAvailableKeyfiles(unsigned long int* slotIdFilter = nullptr, const wstring& keyfileIdFilter = wstring());
static EMVTokenInfo GetTokenInfo(unsigned long int slotId);
- friend void EMVTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const;
+ friend void EMVTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const;
static map <unsigned long int, shared_ptr<EMVCard>> EMVCards;
};
}
diff --git a/src/Common/EncryptionThreadPool.c b/src/Common/EncryptionThreadPool.c
index 62b2cae8..5a31bb5b 100644
--- a/src/Common/EncryptionThreadPool.c
+++ b/src/Common/EncryptionThreadPool.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -86,28 +86,28 @@ typedef struct EncryptionThreadPoolWorkItemStruct
union
{
struct
{
PCRYPTO_INFO CryptoInfo;
- byte *Data;
+ uint8 *Data;
UINT64_STRUCT StartUnitNo;
uint32 UnitCount;
} Encryption;
struct
{
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;
struct
{
@@ -141,11 +141,10 @@ static TC_MUTEX EnqueueMutex;
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())
{
CRYPTO_INFO tmpCI;
@@ -174,15 +173,10 @@ void DecryptDataUnitsCurrentThreadEx (unsigned __int8 *buf, const UINT64_STRUCT
}
else
DecryptDataUnitsCurrentThread (buf, structUnitNo, nbrUnits, ci);
}
-#else
-#define EncryptDataUnitsCurrentThreadEx EncryptDataUnitsCurrentThread
-#define DecryptDataUnitsCurrentThreadEx DecryptDataUnitsCurrentThread
-#endif
-
static WorkItemState GetWorkItemState (EncryptionThreadPoolWorkItem *workItem)
{
return InterlockedExchangeAdd ((LONG *) &workItem->State, 0);
}
@@ -531,11 +525,11 @@ void EncryptionThreadPoolStop ()
ThreadPoolRunning = FALSE;
}
-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;
if (!ThreadPoolRunning)
TC_THROW_FATAL_EXCEPTION;
@@ -604,17 +598,17 @@ void EncryptionThreadPoolBeginReadVolumeHeaderFinalization (TC_EVENT *keyDerivat
TC_SET_EVENT (WorkItemReadyEvent);
TC_RELEASE_MUTEX (&EnqueueMutex);
}
-void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo)
+void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo)
{
uint32 fragmentCount;
uint32 unitsPerFragment;
uint32 remainder;
- byte *fragmentData;
+ uint8 *fragmentData;
uint64 fragmentStartUnitNo;
EncryptionThreadPoolWorkItem *workItem;
EncryptionThreadPoolWorkItem *firstFragmentWorkItem;
diff --git a/src/Common/EncryptionThreadPool.h b/src/Common/EncryptionThreadPool.h
index 053d4107..95583165 100644
--- a/src/Common/EncryptionThreadPool.h
+++ b/src/Common/EncryptionThreadPool.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -30,13 +30,13 @@ typedef enum
#ifndef DEVICE_DRIVER
size_t GetCpuCount (WORD* pGroupCount);
#endif
-void EncryptionThreadPoolBeginKeyDerivation (TC_EVENT *completionEvent, TC_EVENT *noOutstandingWorkItemEvent, LONG *completionFlag, LONG *outstandingWorkItemCount, int pkcs5Prf, char *password, int passwordLength, char *salt, int iterationCount, char *derivedKey);
+void 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, byte *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
+void EncryptionThreadPoolDoWork (EncryptionThreadPoolWorkType type, uint8 *data, const UINT64_STRUCT *startUnitNo, uint32 unitCount, PCRYPTO_INFO cryptoInfo);
BOOL EncryptionThreadPoolStart (size_t encryptionFreeCpuCount);
void EncryptionThreadPoolStop ();
size_t GetEncryptionThreadCount ();
size_t GetMaxEncryptionThreadCount ();
BOOL IsEncryptionThreadPoolRunning ();
diff --git a/src/Common/Endian.c b/src/Common/Endian.c
index cea24d09..7cdda679 100644
--- a/src/Common/Endian.c
+++ b/src/Common/Endian.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
diff --git a/src/Common/Endian.h b/src/Common/Endian.h
index 000395f4..a0cf03b2 100644
--- a/src/Common/Endian.h
+++ b/src/Common/Endian.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_ENDIAN_H
diff --git a/src/Common/Exception.h b/src/Common/Exception.h
index cb4fefc5..f52484c7 100644
--- a/src/Common/Exception.h
+++ b/src/Common/Exception.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Fat.c b/src/Common/Fat.c
index 19720b17..c40084a0 100644
--- a/src/Common/Fat.c
+++ b/src/Common/Fat.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include <stdlib.h>
@@ -443,14 +443,12 @@ FormatFat (void* hwndDlgPtr, unsigned __int64 startSector, fatparams * ft, void
burn (&tmpCI, sizeof (tmpCI));
VirtualUnlock (&tmpCI, sizeof (tmpCI));
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--)
{
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo, startSector,
diff --git a/src/Common/Fat.h b/src/Common/Fat.h
index b2457be2..d6757aaa 100644
--- a/src/Common/Fat.h
+++ b/src/Common/Fat.h
@@ -4,19 +4,19 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
typedef struct fatparams_t
{
char volume_name[11];
- byte volume_id[4];
+ uint8 volume_id[4];
unsigned int num_sectors; /* total number of sectors */
int cluster_count; /* number of clusters */
int size_root_dir; /* size of the root directory in bytes */
int size_fat; /* size of FAT */
int fats;
diff --git a/src/Common/Format.c b/src/Common/Format.c
index 4d8dfed9..ee766d33 100644
--- a/src/Common/Format.c
+++ b/src/Common/Format.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include <stdlib.h>
@@ -82,11 +82,11 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
{
int nStatus;
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;
FILETIME ftLastWriteTime;
FILETIME ftLastAccessTime;
@@ -98,14 +98,12 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
WCHAR deviceName[MAX_PATH];
uint64 dataOffset, dataAreaSize;
LARGE_INTEGER offset;
BOOL bFailedRequiredDASD = FALSE;
HWND hwndDlg = volParams->hwndDlg;
-#ifdef _WIN64
CRYPTO_INFO tmpCI;
PCRYPTO_INFO cryptoInfoBackup = NULL;
-#endif
FormatSectorSize = volParams->sectorSize;
if (FormatSectorSize < TC_MIN_VOLUME_SECTOR_SIZE
|| FormatSectorSize > TC_MAX_VOLUME_SECTOR_SIZE
@@ -173,16 +171,14 @@ int TCFormatVolume (volatile FORMAT_VOL_PARAMETERS *volParams)
burn (header, sizeof (header));
VirtualUnlock (header, sizeof (header));
return nStatus? nStatus : ERR_OUTOFMEMORY;
}
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
{
VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo));
}
-#endif
begin_format:
if (volParams->bDevice)
{
@@ -196,11 +192,11 @@ begin_format:
if (IsDeviceMounted (devName))
{
if ((dev = DismountDrive (devName, volParams->volumePath)) == INVALID_HANDLE_VALUE)
{
- Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg);
+ Error ("FORMAT_CANT_UNMOUNT_FILESYS", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
}
/* Gain "raw" access to the partition (it contains a live filesystem and the filesystem driver
@@ -334,11 +330,11 @@ begin_format:
}
}
if (DeviceIoControl (dev, FSCTL_IS_VOLUME_MOUNTED, NULL, 0, NULL, 0, &dwResult, NULL))
{
- Error ("FORMAT_CANT_DISMOUNT_FILESYS", hwndDlg);
+ Error ("FORMAT_CANT_UNMOUNT_FILESYS", hwndDlg);
nStatus = ERR_DONT_REPORT;
goto error;
}
}
else
@@ -509,13 +505,13 @@ begin_format:
else if (bInstantRetryOtherFilesys)
{
// The previous file system format failed and the user wants to try again with a different file system.
// The volume header had been written successfully so we need to seek to the byte after the header.
- LARGE_INTEGER offset;
- offset.QuadPart = TC_VOLUME_DATA_OFFSET;
- if (!SetFilePointerEx ((HANDLE) dev, offset, NULL, FILE_BEGIN))
+ LARGE_INTEGER volDataOffset;
+ volDataOffset.QuadPart = TC_VOLUME_DATA_OFFSET;
+ if (!SetFilePointerEx ((HANDLE) dev, volDataOffset, NULL, FILE_BEGIN))
{
nStatus = ERR_OS_ERROR;
goto error;
}
}
@@ -530,11 +526,11 @@ begin_format:
}
// To prevent fragmentation, write zeroes to reserved header sectors which are going to be filled with random data
if (!volParams->bDevice && !volParams->hiddenVol)
{
- byte buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE];
+ uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE - TC_VOLUME_HEADER_EFFECTIVE_SIZE];
DWORD bytesWritten;
ZeroMemory (buf, sizeof (buf));
if (!WriteFile (dev, buf, sizeof (buf), &bytesWritten, NULL))
{
@@ -638,20 +634,18 @@ begin_format:
{
nStatus = ERR_OS_ERROR;
goto error;
}
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
{
VirtualLock (&tmpCI, sizeof (tmpCI));
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
VcUnprotectKeys (&tmpCI, VcGetEncryptionID (cryptoInfo));
cryptoInfoBackup = cryptoInfo;
cryptoInfo = &tmpCI;
}
-#endif
nStatus = CreateVolumeHeaderInMemory (hwndDlg, FALSE,
header,
volParams->ea,
FIRST_MODE_OF_OPERATION_ID,
@@ -667,18 +661,16 @@ begin_format:
0,
volParams->headerFlags,
FormatSectorSize,
FALSE);
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
{
cryptoInfo = cryptoInfoBackup;
burn (&tmpCI, sizeof (CRYPTO_INFO));
VirtualUnlock (&tmpCI, sizeof (tmpCI));
}
-#endif
if (!WriteEffectiveVolumeHeader (volParams->bDevice, dev, header))
{
nStatus = ERR_OS_ERROR;
goto error;
@@ -687,31 +679,27 @@ begin_format:
// Fill reserved header sectors (including the backup header area) with random data
if (!volParams->hiddenVol)
{
BOOL bUpdateBackup = FALSE;
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
{
VirtualLock (&tmpCI, sizeof (tmpCI));
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
VcUnprotectKeys (&tmpCI, VcGetEncryptionID (cryptoInfo));
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;
// write fake hidden volume header to protect against attacks that use statistical entropy
@@ -860,11 +848,11 @@ error:
}
if (retCode != 0)
{
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
- MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
+ MessageBoxW (volParams->hwndDlg, GetString ("CANT_UNMOUNT_VOLUME"), lpszTitle, ICON_HAND);
if (dataAreaSize <= TC_MAX_FAT_SECTOR_COUNT * FormatSectorSize)
{
if (AskErrYesNo ("FORMAT_NTFS_FAILED_ASK_FAT", hwndDlg) == IDYES)
{
@@ -882,11 +870,11 @@ error:
nStatus = ERR_DONT_REPORT;
goto fv_end;
}
if (!UnmountVolumeAfterFormatExCall (volParams->hwndDlg, driveNo) && !Silent)
- MessageBoxW (volParams->hwndDlg, GetString ("CANT_DISMOUNT_VOLUME"), lpszTitle, ICON_HAND);
+ MessageBoxW (volParams->hwndDlg, GetString ("CANT_UNMOUNT_VOLUME"), lpszTitle, ICON_HAND);
}
fv_end:
dwError = GetLastError();
@@ -913,13 +901,11 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num
CRYPTOPP_ALIGN_DATA(16) char originalK2[MASTER_KEYDATA_SIZE];
LARGE_INTEGER startOffset;
LARGE_INTEGER newOffset;
-#ifdef _WIN64
CRYPTO_INFO tmpCI;
-#endif
// Seek to start sector
startOffset.QuadPart = startSector * FormatSectorSize;
if (!SetFilePointerEx ((HANDLE) dev, startOffset, &newOffset, FILE_BEGIN)
|| newOffset.QuadPart != startOffset.QuadPart)
@@ -934,19 +920,17 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num
VirtualLock (temporaryKey, sizeof (temporaryKey));
VirtualLock (originalK2, sizeof (originalK2));
memset (sector, 0, sizeof (sector));
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
{
VirtualLock (&tmpCI, sizeof (tmpCI));
memcpy (&tmpCI, cryptoInfo, sizeof (CRYPTO_INFO));
VcUnprotectKeys (&tmpCI, VcGetEncryptionID (cryptoInfo));
cryptoInfo = &tmpCI;
}
-#endif
// Remember the original secondary key (XTS mode) before generating a temporary one
memcpy (originalK2, cryptoInfo->k2, sizeof (cryptoInfo->k2));
/* Fill the rest of the data area with random data */
@@ -973,14 +957,12 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num
{
retVal = ERR_MODE_INIT_FAILED;
goto fail;
}
-#ifdef _WIN64
if (IsRamEncryptionEnabled ())
VcProtectKeys (cryptoInfo, VcGetEncryptionID (cryptoInfo));
-#endif
while (num_sectors--)
{
if (WriteSector (dev, sector, write_buf, &write_buf_cnt, &nSecNo, startSector,
cryptoInfo) == FALSE)
@@ -1049,17 +1031,15 @@ int FormatNoFs (HWND hwndDlg, unsigned __int64 startSector, unsigned __int64 num
burn (temporaryKey, sizeof(temporaryKey));
burn (originalK2, sizeof(originalK2));
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;
fail:
err = GetLastError();
@@ -1067,17 +1047,15 @@ fail:
burn (temporaryKey, sizeof(temporaryKey));
burn (originalK2, sizeof(originalK2));
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);
}
@@ -1390,11 +1368,11 @@ BOOL WriteSector (void *dev, char *sector,
static volatile BOOL WriteThreadRunning;
static volatile BOOL WriteThreadExitRequested;
static HANDLE WriteThreadHandle;
-static byte *WriteThreadBuffer;
+static uint8 *WriteThreadBuffer;
static HANDLE WriteBufferEmptyEvent;
static HANDLE WriteBufferFullEvent;
static volatile HANDLE WriteRequestHandle;
static volatile int WriteRequestSize;
diff --git a/src/Common/Format.h b/src/Common/Format.h
index 0a42e5c8..8f1166ba 100644
--- a/src/Common/Format.h
+++ b/src/Common/Format.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_Format
diff --git a/src/Common/GfMul.c b/src/Common/GfMul.c
index 970e6318..db51f499 100644
--- a/src/Common/GfMul.c
+++ b/src/Common/GfMul.c
@@ -285,11 +285,11 @@ static mode(32t) gf_poly64[2] = { 0, 0xd8000000 };
/* are held in byte[n], with lower indexed bits placed in the */
/* more numerically significant bit positions in bytes. */
/* This function multiples a field element x, in the polynomial */
/* field representation. It uses 32-bit word operations to gain */
-/* speed but compensates for machine endianess and hence works */
+/* speed but compensates for machine endianness and hence works */
/* correctly on both styles of machine */
in_line void mul_x(mode(32t) x[4])
{ mode(32t) t;
@@ -331,11 +331,11 @@ in_line void mul_x64(mode(32t) x[2])
x[0] = (x[0] >> 1) ^ t; /* the field polynomial */
bsw_32(x, 2);
}
/* Multiply of a GF128 field element by x^8 using 32-bit words */
-/* for speed - machine endianess matters here */
+/* for speed - machine endianness matters here */
#if (PLATFORM_BYTE_ORDER == BRG_LITTLE_ENDIAN)
#define xp_fun(x,y) ((mode(32t))(x)) | (((mode(32t))(y)) << 8)
static const unsigned __int16 gft_le[256] = gf_dat(xp);
@@ -378,11 +378,11 @@ in_line void mul_bex8_64(mode(32t) x[2]) /* mutiply with long words */
x[0] = (x[0] >> 8) ^ (((mode(32t))gft_be64[t]) << 16);
}
#endif
-/* hence choose the correct version for the machine endianess */
+/* hence choose the correct version for the machine endianness */
#if PLATFORM_BYTE_ORDER == BRG_BIG_ENDIAN
#define mul_x8 mul_bex8
#define mul_x8_64 mul_bex8_64
#else
diff --git a/src/Common/Keyfiles.c b/src/Common/Keyfiles.c
index d10daa06..b31e335b 100644
--- a/src/Common/Keyfiles.c
+++ b/src/Common/Keyfiles.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -251,11 +251,11 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
try
{
if (Token::IsKeyfilePathValid (kf->FileName, EMVSupportEnabled? true : false))
{
// Apply security token keyfile
- vector <byte> keyfileData;
+ vector <uint8> keyfileData;
TokenKeyfilePath secPath (kf->FileName);
Token::getTokenKeyfile (secPath)->GetKeyfileData (keyfileData);
if (keyfileData.empty())
{
@@ -268,11 +268,11 @@ BOOL KeyFilesApply (HWND hwndDlg, Password *password, KeyFile *firstKeyFile, con
unsigned __int32 crc = 0xffffffff;
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);
keyPool[writePos++] += (unsigned __int8) (crc >> 24);
keyPool[writePos++] += (unsigned __int8) (crc >> 16);
@@ -494,11 +494,11 @@ BOOL CALLBACK KeyFilesDlgProc (HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lPa
{
// we're about to draw the static
// set the text colour in (HDC)wParam
SetBkMode((HDC)wParam,TRANSPARENT);
SetTextColor((HDC)wParam, RGB(255,0,0));
- return (BOOL)GetSysColorBrush(COLOR_MENU);
+ return (BOOL)(INT_PTR)GetSysColorBrush(COLOR_MENU);
}
}
return 0;
case WM_COMMAND:
diff --git a/src/Common/Keyfiles.h b/src/Common/Keyfiles.h
index a13666fb..e01f6bc9 100644
--- a/src/Common/Keyfiles.h
+++ b/src/Common/Keyfiles.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Language.c b/src/Common/Language.c
index 278b7dd1..3537d747 100644
--- a/src/Common/Language.c
+++ b/src/Common/Language.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -81,18 +81,44 @@ static char *MapFirstLanguageFile ()
}
return LanguageFileBuffer;
}
+static int IsValidLanguageFileName(const wchar_t* filename) {
+ size_t len = wcslen(filename);
+
+ // Check the base format and length directly
+ if (_wcsnicmp(filename, L"Language.", 9) != 0 || (len != 15 && len != 18))
+ return 0; // Does not start with "Language." or has incorrect length
+
+ // Check for the ".xml" suffix
+ if (_wcsicmp(filename + len - 4, L".xml") != 0)
+ return 0; // Does not end with ".xml"
+
+ // Detailed checks based on the specific length
+ if (len == 15) {
+ // Format should be Language.xx.xml
+ if (iswalpha(filename[9]) && iswalpha(filename[10]))
+ return 1; // Valid format for short code
+ } else if (len == 18) {
+ // Format should be Language.xx-yy.xml
+ if (iswalpha(filename[9]) && iswalpha(filename[10]) && filename[11] == L'-' &&
+ iswalpha(filename[12]) && iswalpha(filename[13]))
+ return 1; // Valid format for long code
+ }
+
+ return 0; // If none of the conditions are met, the filename is invalid
+}
static char *MapNextLanguageFile (int resourceid)
{
wchar_t f[TC_MAX_PATH*2], *t;
WIN32_FIND_DATAW find;
HANDLE file;
DWORD read;
BOOL bStatus;
+ BOOL validFileFound = FALSE;
/* free memory here to avoid leaks */
if (LanguageFileBuffer != NULL)
{
free (LanguageFileBuffer);
@@ -120,10 +146,28 @@ static char *MapNextLanguageFile (int resourceid)
}
if (LanguageFileFindHandle == INVALID_HANDLE_VALUE) return NULL;
if (find.nFileSizeHigh != 0) return NULL;
+ // Validate the file name format
+ while (!validFileFound)
+ {
+ if (!IsValidLanguageFileName(find.cFileName))
+ {
+ if (!FindNextFileW(LanguageFileFindHandle, &find))
+ {
+ FindClose(LanguageFileFindHandle);
+ LanguageFileFindHandle = INVALID_HANDLE_VALUE;
+ return NULL;
+ }
+ }
+ else
+ {
+ validFileFound = TRUE;
+ }
+ }
+
LanguageFileBuffer = malloc(find.nFileSizeLow + 1);
if (LanguageFileBuffer == NULL) return NULL;
GetModuleFileNameW (NULL, f, sizeof (f) / sizeof(f[0]));
t = wcsrchr (f, L'\\');
@@ -296,21 +340,21 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
for (i = 0; xmlElements[i] != 0; i++)
{
xml = (char *) res;
while (xml = XmlFindElement (xml, xmlElements[i]))
{
- void *key;
+ void *pkey;
void *text;
XmlGetAttributeText (xml, "lang", attr, sizeof (attr));
if (!defaultLangParsed
|| strcmp (attr, langId) == 0)
{
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));
// Parse \ escape sequences
{
@@ -325,11 +369,11 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
case '\\': *out++ = '\\'; break;
case 't': *out++ = '\t'; break;
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;
}
}
else
*out++ = *in++;
@@ -340,19 +384,19 @@ static BOOL LoadLanguageData (int resourceid, BOOL bForceSetPreferredLanguage, B
// UTF8 => wide char
len = MultiByteToWideChar (CP_UTF8, 0, attr, -1, wattr, sizeof (wattr) / sizeof(wattr[0]));
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;
}
// Add to dictionary
text = AddPoolData ((void *) wattr, len * 2);
if (text == NULL) return FALSE;
- AddDictionaryEntry ((char *) key, 0, text);
+ AddDictionaryEntry ((char *)pkey, 0, text);
}
}
xml++;
}
diff --git a/src/Common/Language.h b/src/Common/Language.h
index 4a87ceda..f4c57dae 100644
--- a/src/Common/Language.h
+++ b/src/Common/Language.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Language.xml b/src/Common/Language.xml
index 32930193..eac69303 100644
--- a/src/Common/Language.xml
+++ b/src/Common/Language.xml
@@ -133,12 +133,12 @@
<entry lang="en" key="IDC_FAVORITE_MOVE_UP">Move &amp;Up</entry>
<entry lang="en" key="IDC_FAVORITE_OPEN_EXPLORER_WIN_ON_MOUNT">Open &amp;Explorer window for selected volume when successfully mounted</entry>
<entry lang="en" key="IDC_FAVORITE_REMOVE">&amp;Remove</entry>
<entry lang="en" key="IDC_FAVORITE_USE_LABEL_IN_EXPLORER">Use favorite label as Explorer drive label</entry>
<entry lang="en" key="IDC_FAV_VOL_OPTIONS_GLOBAL_SETTINGS_BOX">Global Settings</entry>
- <entry lang="en" key="IDC_HK_DISMOUNT_BALLOON_TOOLTIP">Display balloon tooltip after successful hot-key dismount</entry>
- <entry lang="en" key="IDC_HK_DISMOUNT_PLAY_SOUND">Play system notification sound after successful hot-key dismount</entry>
+ <entry lang="en" key="IDC_HK_UNMOUNT_BALLOON_TOOLTIP">Display balloon tooltip after successful hot-key unmount</entry>
+ <entry lang="en" key="IDC_HK_UNMOUNT_PLAY_SOUND">Play system notification sound after successful hot-key unmount</entry>
<entry lang="en" key="IDC_HK_MOD_ALT">Alt</entry>
<entry lang="en" key="IDC_HK_MOD_CTRL">Ctrl</entry>
<entry lang="en" key="IDC_HK_MOD_SHIFT">Shift</entry>
<entry lang="en" key="IDC_HK_MOD_WIN">Win</entry>
<entry lang="en" key="IDC_HOTKEY_ASSIGN">Assign</entry>
@@ -154,24 +154,24 @@
<entry lang="en" key="IDC_NEW_KEYFILES">Keyfiles...</entry>
<entry lang="en" key="IDC_OLD_PIM_HELP">(Empty or 0 for default iterations)</entry>
<entry lang="en" key="IDC_PIM_HELP">(Empty or 0 for default iterations)</entry>
<entry lang="en" key="IDC_PREF_BKG_TASK_ENABLE">Enabled</entry>
<entry lang="en" key="IDC_PREF_CACHE_PASSWORDS">Cache passwords in driver memory</entry>
- <entry lang="en" key="IDC_PREF_DISMOUNT_INACTIVE">Auto-dismount volume after no data has been read/written to it for</entry>
- <entry lang="en" key="IDC_PREF_DISMOUNT_LOGOFF">User logs off</entry>
- <entry lang="en" key="IDC_PREF_DISMOUNT_SESSION_LOCKED">User session locked</entry>
- <entry lang="en" key="IDC_PREF_DISMOUNT_POWERSAVING">Entering power saving mode</entry>
- <entry lang="en" key="IDC_PREF_DISMOUNT_SCREENSAVER">Screen saver is launched</entry>
- <entry lang="en" key="IDC_PREF_FORCE_AUTO_DISMOUNT">Force auto-dismount even if volume contains open files or directories</entry>
+ <entry lang="en" key="IDC_PREF_UNMOUNT_INACTIVE">Auto-unmount volume after no data has been read/written to it for</entry>
+ <entry lang="en" key="IDC_PREF_UNMOUNT_LOGOFF">User logs off</entry>
+ <entry lang="en" key="IDC_PREF_UNMOUNT_SESSION_LOCKED">User session locked</entry>
+ <entry lang="en" key="IDC_PREF_UNMOUNT_POWERSAVING">Entering power saving mode</entry>
+ <entry lang="en" key="IDC_PREF_UNMOUNT_SCREENSAVER">Screen saver is launched</entry>
+ <entry lang="en" key="IDC_PREF_FORCE_AUTO_UNMOUNT">Force auto-unmount even if volume contains open files or directories</entry>
<entry lang="en" key="IDC_PREF_LOGON_MOUNT_DEVICES">Mount all device-hosted VeraCrypt volumes</entry>
<entry lang="en" key="IDC_PREF_LOGON_START">Start VeraCrypt Background Task</entry>
<entry lang="en" key="IDC_PREF_MOUNT_READONLY">Mount volumes as read-only</entry>
<entry lang="en" key="IDC_PREF_MOUNT_REMOVABLE">Mount volumes as removable media</entry>
<entry lang="en" key="IDC_PREF_OPEN_EXPLORER">Open Explorer window for successfully mounted volume</entry>
<entry lang="en" key="IDC_PREF_TEMP_CACHE_ON_MULTIPLE_MOUNT">Temporarily cache password during "Mount Favorite Volumes" operations</entry>
<entry lang="en" key="IDC_PREF_USE_DIFF_TRAY_ICON_IF_VOL_MOUNTED">Use a different taskbar icon when there are mounted volumes</entry>
- <entry lang="en" key="IDC_PREF_WIPE_CACHE_ON_AUTODISMOUNT">Wipe cached passwords on auto-dismount</entry>
+ <entry lang="en" key="IDC_PREF_WIPE_CACHE_ON_AUTOUNMOUNT">Wipe cached passwords on auto-unmount</entry>
<entry lang="en" key="IDC_PREF_WIPE_CACHE_ON_EXIT">Wipe cached passwords on exit</entry>
<entry lang="en" key="IDC_PRESERVE_TIMESTAMPS">Preserve modification timestamp of file containers</entry>
<entry lang="en" key="IDC_RESET_HOTKEYS">Reset</entry>
<entry lang="en" key="IDC_SELECT_DEVICE">Select D&amp;evice...</entry>
<entry lang="en" key="IDC_SELECT_FILE">Select &amp;File...</entry>
@@ -179,11 +179,11 @@
<entry lang="en" key="IDC_SHOW_PASSWORD_CHPWD_NEW">Display password</entry>
<entry lang="en" key="IDC_SHOW_PASSWORD_CHPWD_ORI">Display password</entry>
<entry lang="en" key="IDC_TRAVEL_OPEN_EXPLORER">Open &amp;Explorer window for mounted volume</entry>
<entry lang="en" key="IDC_TRAV_CACHE_PASSWORDS">&amp;Cache password in driver memory</entry>
<entry lang="en" key="IDC_TRUECRYPT_MODE">&amp;TrueCrypt Mode</entry>
- <entry lang="en" key="IDC_UNMOUNTALL">Di&amp;smount All</entry>
+ <entry lang="en" key="IDC_UNMOUNTALL">&amp;Unmount All</entry>
<entry lang="en" key="IDC_VOLUME_PROPERTIES">&amp;Volume Properties...</entry>
<entry lang="en" key="IDC_VOLUME_TOOLS">Volume &amp;Tools...</entry>
<entry lang="en" key="IDC_WIPE_CACHE">&amp;Wipe Cache</entry>
<entry lang="en" key="IDD_DEFAULT_MOUNT_PARAMETERS">VeraCrypt - Mount Parameters</entry>
<entry lang="en" key="IDD_FAVORITE_VOLUMES">VeraCrypt - Favorite Volumes</entry>
@@ -253,12 +253,12 @@
<entry lang="en" key="IDM_SYS_FAVORITES_SETTINGS">System Favorite Volumes...</entry>
<entry lang="en" key="IDM_TC_DOWNLOADS">Downloads</entry>
<entry lang="en" key="IDM_TEST_VECTORS">Test Vectors...</entry>
<entry lang="en" key="IDM_TOKEN_PREFERENCES">Security Tokens...</entry>
<entry lang="en" key="IDM_TRAVELER">Traveler Disk Setup...</entry>
- <entry lang="en" key="IDM_UNMOUNTALL">Dismount All Mounted Volumes</entry>
- <entry lang="en" key="IDM_UNMOUNT_VOLUME">Dismount Volume</entry>
+ <entry lang="en" key="IDM_UNMOUNTALL">Unmount All Mounted Volumes</entry>
+ <entry lang="en" key="IDM_UNMOUNT_VOLUME">Unmount Volume</entry>
<entry lang="en" key="IDM_VERIFY_RESCUE_DISK">Verify Rescue Disk</entry>
<entry lang="en" key="IDM_VERIFY_RESCUE_DISK_ISO">Verify Rescue Disk Image</entry>
<entry lang="en" key="IDM_VERSION_HISTORY">Version History</entry>
<entry lang="en" key="IDM_VOLUME_EXPANDER">Volume Expander</entry>
<entry lang="en" key="IDM_VOLUME_PROPERTIES">Volume Properties</entry>
@@ -267,18 +267,18 @@
<entry lang="en" key="IDM_WIPE_CACHE">Wipe Cached Passwords</entry>
<entry lang="en" key="IDOK">OK</entry>
<entry lang="en" key="IDT_ACCELERATION_OPTIONS">Hardware Acceleration</entry>
<entry lang="en" key="IDT_ASSIGN_HOTKEY">Shortcut</entry>
<entry lang="en" key="IDT_AUTORUN">AutoRun Configuration (autorun.inf)</entry>
- <entry lang="en" key="IDT_AUTO_DISMOUNT">Auto-Dismount</entry>
- <entry lang="en" key="IDT_AUTO_DISMOUNT_ON">Dismount all when:</entry>
+ <entry lang="en" key="IDT_AUTO_UNMOUNT">Auto-Unmount</entry>
+ <entry lang="en" key="IDT_AUTO_UNMOUNT_ON">Unmount all when:</entry>
<entry lang="en" key="IDT_BOOT_LOADER_SCREEN_OPTIONS">Boot Loader Screen Options</entry>
<entry lang="en" key="IDT_CONFIRM_PASSWORD">Confirm Password:</entry>
<entry lang="en" key="IDT_CURRENT">Current</entry>
<entry lang="en" key="IDT_CUSTOM_BOOT_LOADER_MESSAGE">Display this custom message in the pre-boot authentication screen (24 characters maximum):</entry>
<entry lang="en" key="IDT_DEFAULT_MOUNT_OPTIONS">Default Mount Options</entry>
- <entry lang="en" key="IDT_DISMOUNT_ACTION">Hot Key Options</entry>
+ <entry lang="en" key="IDT_UNMOUNT_ACTION">Hot Key Options</entry>
<entry lang="en" key="IDT_DRIVER_OPTIONS">Driver Configuration</entry>
<entry lang="en" key="IDC_ENABLE_EXTENDED_IOCTL_SUPPORT">Enable extended disk control codes support</entry>
<entry lang="en" key="IDT_FAVORITE_LABEL">Label of selected favorite volume:</entry>
<entry lang="en" key="IDT_FILE_SETTINGS">File Settings</entry>
<entry lang="en" key="IDT_HOTKEY_KEY">Key to assign:</entry>
@@ -421,12 +421,12 @@
<entry lang="en" key="DEVICE_FREE_GB">Size of %s is %.2f GiB</entry>
<entry lang="en" key="DEVICE_FREE_TB">Size of %s is %.2f TiB</entry>
<entry lang="en" key="DEVICE_FREE_PB">Size of %s is %.2f PiB</entry>
<entry lang="en" key="DEVICE_IN_USE_FORMAT">WARNING: The device/partition is in use by the operating system or applications. Formatting the device/partition might cause data corruption and system instability.\n\nContinue?</entry>
<entry lang="en" key="DEVICE_IN_USE_INPLACE_ENC">Warning: The partition is in use by the operating system or applications. You should close any applications that might be using the partition (including antivirus software).\n\nContinue?</entry>
- <entry lang="en" key="FORMAT_CANT_DISMOUNT_FILESYS">Error: The device/partition contains a file system that could not be dismounted. The file system may be in use by the operating system. Formatting the device/partition would very likely cause data corruption and system instability.\n\nTo solve this issue, we recommend that you first delete the partition and then recreate it without formatting. To do so, follow these steps:\n1) Right-click the 'Computer' (or 'My Computer') icon in the 'Start Menu' and select 'Manage'. The 'Computer Management' window should appear.\n2) In the 'Computer Management' window, select 'Storage' > 'Disk Management'.\n3) Right-click the partition you want to encrypt and select either 'Delete Partition', or 'Delete Volume', or 'Delete Logical Drive'.\n4) Click 'Yes'. If Windows asks you to restart the computer, do so. Then repeat the steps 1 and 2 and continue from the step 5.\n5) Right-click the unallocated/free space area and select either 'New Partition', or 'New Simple Volume', or 'New Logical Drive'.\n6) The 'New Partition Wizard' or 'New Simple Volume Wizard' window should appear now; follow its instructions. On the wizard page entitled 'Format Partition', select either 'Do not format this partition' or 'Do not format this volume'. In the same wizard, click 'Next' and then 'Finish'.\n7) Note that the device path you have selected in VeraCrypt may be wrong now. Therefore, exit the VeraCrypt Volume Creation Wizard (if it is still running) and then start it again.\n8) Try encrypting the device/partition again.\n\nIf VeraCrypt repeatedly fails to encrypt the device/partition, you may want to consider creating a file container instead.</entry>
- <entry lang="en" key="INPLACE_ENC_CANT_LOCK_OR_DISMOUNT_FILESYS">Error: The filesystem could not be locked and/or dismounted. It may be in use by the operating system or applications (for example, antivirus software). Encrypting the partition might cause data corruption and system instability.\n\nPlease close any applications that might be using the filesystem (including antivirus software) and try again. If it does not help, please follow the below steps.</entry>
+ <entry lang="en" key="FORMAT_CANT_UNMOUNT_FILESYS">Error: The device/partition contains a file system that could not be unmounted. The file system may be in use by the operating system. Formatting the device/partition would very likely cause data corruption and system instability.\n\nTo solve this issue, we recommend that you first delete the partition and then recreate it without formatting. To do so, follow these steps:\n1) Right-click the 'Computer' (or 'My Computer') icon in the 'Start Menu' and select 'Manage'. The 'Computer Management' window should appear.\n2) In the 'Computer Management' window, select 'Storage' > 'Disk Management'.\n3) Right-click the partition you want to encrypt and select either 'Delete Partition', or 'Delete Volume', or 'Delete Logical Drive'.\n4) Click 'Yes'. If Windows asks you to restart the computer, do so. Then repeat the steps 1 and 2 and continue from the step 5.\n5) Right-click the unallocated/free space area and select either 'New Partition', or 'New Simple Volume', or 'New Logical Drive'.\n6) The 'New Partition Wizard' or 'New Simple Volume Wizard' window should appear now; follow its instructions. On the wizard page entitled 'Format Partition', select either 'Do not format this partition' or 'Do not format this volume'. In the same wizard, click 'Next' and then 'Finish'.\n7) Note that the device path you have selected in VeraCrypt may be wrong now. Therefore, exit the VeraCrypt Volume Creation Wizard (if it is still running) and then start it again.\n8) Try encrypting the device/partition again.\n\nIf VeraCrypt repeatedly fails to encrypt the device/partition, you may want to consider creating a file container instead.</entry>
+ <entry lang="en" key="INPLACE_ENC_CANT_LOCK_OR_UNMOUNT_FILESYS">Error: The filesystem could not be locked and/or unmounted. It may be in use by the operating system or applications (for example, antivirus software). Encrypting the partition might cause data corruption and system instability.\n\nPlease close any applications that might be using the filesystem (including antivirus software) and try again. If it does not help, please follow the below steps.</entry>
<entry lang="en" key="DEVICE_IN_USE_INFO">WARNING: Some of the mounted devices/partitions were already in use!\n\nIgnoring this can cause undesired results including system instability.\n\nWe strongly recommend that you close any application that might be using the devices/partitions.</entry>
<entry lang="en" key="DEVICE_PARTITIONS_ERR">The selected device contains partitions.\n\nFormatting the device might cause system instability and/or data corruption. Please either select a partition on the device, or remove all partitions on the device to enable VeraCrypt to format it safely.</entry>
<entry lang="en" key="DEVICE_PARTITIONS_ERR_W_INPLACE_ENC_NOTE">The selected non-system device contains partitions.\n\nEncrypted device-hosted VeraCrypt volumes can be created within devices that do not contain any partitions (including hard disks and solid-state drives). A device that contains partitions can be entirely encrypted in place (using a single master key) only if it is the drive where Windows is installed and from which it boots.\n\nIf you want to encrypt the selected non-system device using a single master key, you will need to remove all partitions on the device first to enable VeraCrypt to format it safely (formatting a device that contains partitions might cause system instability and/or data corruption). Alternatively, you can encrypt each partition on the drive individually (each partition will be encrypted using a different master key).\n\nNote: If you want to remove all partitions from a GPT disk, you may need to convert it to a MBR disk (using e.g. the Computer Management tool) in order to remove hidden partitions.</entry>
<entry lang="en" key="WHOLE_NONSYS_DEVICE_ENC_CONFIRM">Warning: If you encrypt the entire device (as opposed to encrypting only a partition on it), operating systems will consider the device as new, empty, and unformatted (as it will contain no partition table) and may spontaneously initialize the device (or ask you if you want to do so), which may damage the volume. Furthermore, it will not be possible to consistently mount the volume as favorite (e.g. when the drive number changes) or to assign a favorite-volume label to it.\n\nTo avoid that you may want to consider creating a partition on the device and encrypting the partition instead.\n\nAre you sure want to encrypt the entire device?</entry>
<entry lang="en" key="AFTER_FORMAT_DRIVE_LETTER_WARN">IMPORTANT: Please keep in mind that this volume can NOT be mounted/accessed using the drive letter %c:, which is currently assigned to it!\n\nTo mount this volume, click 'Auto-Mount Devices' in the main VeraCrypt window (alternatively, in the main VeraCrypt window, click 'Select Device', then select this partition/device, and click 'Mount'). The volume will be mounted to a different drive letter, which you select from the list in the main VeraCrypt window.\n\nThe original drive letter %c: should be used only in case you need to remove encryption from the partition/device (e.g., if you no longer need encryption). In such a case, right-click the drive letter %c: in the 'Computer' (or 'My Computer') list and select 'Format'. Otherwise, the drive letter %c: should never be used (unless you remove it, as described e.g. in the VeraCrypt FAQ, and assign it to another partition/device).</entry>
@@ -523,23 +523,23 @@
<entry lang="en" key="HIDDEN_VOL_WIZARD_MODE_DIRECT_HELP">If you select this option, you will create a hidden volume within an existing VeraCrypt volume. It will be assumed that you have already created a VeraCrypt volume that is suitable to host the hidden volume.</entry>
<entry lang="en" key="HIDDEN_VOL_WIZARD_MODE_TITLE">Volume Creation Mode</entry>
<entry lang="en" key="HIDVOL_FORMAT_FINISHED_TITLE">Hidden Volume Created</entry>
<entry lang="en" key="HIDVOL_FORMAT_FINISHED_HELP">The hidden VeraCrypt volume has been successfully created and is ready for use. If all the instructions have been followed and if the precautions and requirements listed in the section "Security Requirements and Precautions Pertaining to Hidden Volumes" in the VeraCrypt User's Guide are followed, it should be impossible to prove that the hidden volume exists, even when the outer volume is mounted.\n\nWARNING: IF YOU DO NOT PROTECT THE HIDDEN VOLUME (FOR INFORMATION ON HOW TO DO SO, REFER TO THE SECTION "PROTECTION OF HIDDEN VOLUMES AGAINST DAMAGE" IN THE VERACRYPT USER'S GUIDE), DO NOT WRITE TO THE OUTER VOLUME. OTHERWISE, YOU MAY OVERWRITE AND DAMAGE THE HIDDEN VOLUME!</entry>
<entry lang="en" key="FIRST_HIDDEN_OS_BOOT_INFO">You have started the hidden operating system. As you may have noticed, the hidden operating system appears to be installed on the same partition as the original operating system. However, in reality, it is installed within the partition behind it (in the hidden volume). All read and write operations are being transparently redirected from the original system partition to the hidden volume.\n\nNeither the operating system nor applications will know that data written to and read from the system partition are actually written to and read from the partition behind it (from/to a hidden volume). Any such data is encrypted and decrypted on the fly as usual (with an encryption key different from the one that will be used for the decoy operating system).\n\n\nPlease click Next to continue.</entry>
- <entry lang="en" key="HIDVOL_HOST_FILLING_HELP_SYSENC">The outer volume has been created and mounted as drive %hc:. To this outer volume you should now copy some sensitive-looking files that you actually do NOT want to hide. They will be there for anyone forcing you to disclose the password for the first partition behind the system partition, where both the outer volume and the hidden volume (containing the hidden operating system) will reside. You will be able to reveal the password for this outer volume, and the existence of the hidden volume (and of the hidden operating system) will remain secret.\n\nIMPORTANT: The files you copy to the outer volume should not occupy more than %s. Otherwise, there may not be enough free space on the outer volume for the hidden volume (and you will not be able to continue). After you finish copying, click Next (do not dismount the volume).</entry>
- <entry lang="en" key="HIDVOL_HOST_FILLING_HELP">Outer volume has been successfully created and mounted as drive %hc:. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not dismount the volume.\n\nNote: After you click Next, cluster bitmap of the outer volume will be scanned to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. Cluster bitmap scanning ensures that no data on the outer volume are overwritten by the hidden volume.</entry>
+ <entry lang="en" key="HIDVOL_HOST_FILLING_HELP_SYSENC">The outer volume has been created and mounted as drive %hc:. To this outer volume you should now copy some sensitive-looking files that you actually do NOT want to hide. They will be there for anyone forcing you to disclose the password for the first partition behind the system partition, where both the outer volume and the hidden volume (containing the hidden operating system) will reside. You will be able to reveal the password for this outer volume, and the existence of the hidden volume (and of the hidden operating system) will remain secret.\n\nIMPORTANT: The files you copy to the outer volume should not occupy more than %s. Otherwise, there may not be enough free space on the outer volume for the hidden volume (and you will not be able to continue). After you finish copying, click Next (do not unmount the volume).</entry>
+ <entry lang="en" key="HIDVOL_HOST_FILLING_HELP">Outer volume has been successfully created and mounted as drive %hc:. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not unmount the volume.\n\nNote: After you click Next, cluster bitmap of the outer volume will be scanned to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. Cluster bitmap scanning ensures that no data on the outer volume are overwritten by the hidden volume.</entry>
<entry lang="en" key="HIDVOL_HOST_FILLING_TITLE">Outer Volume Contents</entry>
<entry lang="en" key="HIDVOL_HOST_PRE_CIPHER_HELP">\n\nIn the next steps, you will set the options for the outer volume (within which the hidden volume will be created later on).</entry>
<entry lang="en" key="HIDVOL_HOST_PRE_CIPHER_HELP_SYSENC">\n\nIn the next steps, you will create a so-called outer VeraCrypt volume within the first partition behind the system partition (as was explained in one of the previous steps).</entry>
<entry lang="en" key="HIDVOL_HOST_PRE_CIPHER_TITLE">Outer Volume</entry>
<entry lang="en" key="HIDDEN_OS_PRE_CIPHER_HELP">In the following steps, you will set the options and password for the hidden volume, which will contain the hidden operating system.\n\nRemark: The cluster bitmap of the outer volume has been scanned in order to determine the size of uninterrupted area of free space whose end is aligned with the end of the outer volume. This area will accommodate the hidden volume, so it limits its maximum possible size. The maximum possible size of the hidden volume has been determined and confirmed to be greater than the size of the system partition (which is required, because the entire content of the system partition will need to be copied to the hidden volume). This ensures that no data currently stored on the outer volume will be overwritten by data written to the area of the hidden volume.</entry>
<entry lang="en" key="HIDDEN_OS_PRE_CIPHER_WARNING">IMPORTANT: Please remember the algorithms that you select in this step. You will have to select the same algorithms for the decoy system. Otherwise, the hidden system will be inaccessible! (The decoy system must be encrypted with the same encryption algorithm as the hidden system.)\n\nNote: The reason is that the decoy system and the hidden system will share a single boot loader, which supports only a single algorithm, selected by the user (for each algorithm, there is a special version of the VeraCrypt Boot Loader).</entry>
<entry lang="en" key="HIDVOL_PRE_CIPHER_HELP">\n\nThe volume cluster bitmap has been scanned and the maximum possible size of the hidden volume has been determined. In the next steps you will set the options, the size, and the password for the hidden volume.</entry>
<entry lang="en" key="HIDVOL_PRE_CIPHER_TITLE">Hidden Volume</entry>
- <entry lang="en" key="HIDVOL_PROT_WARN_AFTER_MOUNT">The hidden volume is now protected against damage until the outer volume is dismounted.\n\nWARNING: If any data is attempted to be saved to the hidden volume area, VeraCrypt will start write-protecting the entire volume (both the outer and the hidden part) until it is dismounted. This may cause filesystem corruption on the outer volume, which (if repeated) might adversely affect plausible deniability of the hidden volume. Therefore, you should make every effort to avoid writing to the hidden volume area. Any data being saved to the hidden volume area will not be saved and will be lost. Windows may report this as a write error ("Delayed Write Failed" or "The parameter is incorrect").</entry>
- <entry lang="en" key="HIDVOL_PROT_WARN_AFTER_MOUNT_PLURAL">Each of the hidden volumes within the newly mounted volumes is now protected against damage until dismounted.\n\nWARNING: If any data is attempted to be saved to protected hidden volume area of any of these volumes, VeraCrypt will start write-protecting the entire volume (both the outer and the hidden part) until it is dismounted. This may cause filesystem corruption on the outer volume, which (if repeated) might adversely affect plausible deniability of the hidden volume. Therefore, you should make every effort to avoid writing to the hidden volume area. Any data being saved to protected hidden volume areas will not be saved and will be lost. Windows may report this as a write error ("Delayed Write Failed" or "The parameter is incorrect").</entry>
- <entry lang="en" key="DAMAGE_TO_HIDDEN_VOLUME_PREVENTED">WARNING: Data were attempted to be saved to the hidden volume area of the volume mounted as %c:! VeraCrypt prevented these data from being saved in order to protect the hidden volume. This may have caused filesystem corruption on the outer volume and Windows may have reported a write error ("Delayed Write Failed" or "The parameter is incorrect"). The entire volume (both the outer and the hidden part) will be write-protected until it is dismounted. If this is not the first time VeraCrypt has prevented data from being saved to the hidden volume area of this volume, plausible deniability of this hidden volume might be adversely affected (due to possible unusual correlated inconsistencies within the outer volume file system). Therefore, you should consider creating a new VeraCrypt volume (with Quick Format disabled) and moving files from this volume to the new volume; this volume should be securely erased (both the outer and the hidden part). We strongly recommend that you restart the operating system now.</entry>
+ <entry lang="en" key="HIDVOL_PROT_WARN_AFTER_MOUNT">The hidden volume is now protected against damage until the outer volume is unmounted.\n\nWARNING: If any data is attempted to be saved to the hidden volume area, VeraCrypt will start write-protecting the entire volume (both the outer and the hidden part) until it is unmounted. This may cause filesystem corruption on the outer volume, which (if repeated) might adversely affect plausible deniability of the hidden volume. Therefore, you should make every effort to avoid writing to the hidden volume area. Any data being saved to the hidden volume area will not be saved and will be lost. Windows may report this as a write error ("Delayed Write Failed" or "The parameter is incorrect").</entry>
+ <entry lang="en" key="HIDVOL_PROT_WARN_AFTER_MOUNT_PLURAL">Each of the hidden volumes within the newly mounted volumes is now protected against damage until unmounted.\n\nWARNING: If any data is attempted to be saved to protected hidden volume area of any of these volumes, VeraCrypt will start write-protecting the entire volume (both the outer and the hidden part) until it is unmounted. This may cause filesystem corruption on the outer volume, which (if repeated) might adversely affect plausible deniability of the hidden volume. Therefore, you should make every effort to avoid writing to the hidden volume area. Any data being saved to protected hidden volume areas will not be saved and will be lost. Windows may report this as a write error ("Delayed Write Failed" or "The parameter is incorrect").</entry>
+ <entry lang="en" key="DAMAGE_TO_HIDDEN_VOLUME_PREVENTED">WARNING: Data were attempted to be saved to the hidden volume area of the volume mounted as %c:! VeraCrypt prevented these data from being saved in order to protect the hidden volume. This may have caused filesystem corruption on the outer volume and Windows may have reported a write error ("Delayed Write Failed" or "The parameter is incorrect"). The entire volume (both the outer and the hidden part) will be write-protected until it is unmounted. If this is not the first time VeraCrypt has prevented data from being saved to the hidden volume area of this volume, plausible deniability of this hidden volume might be adversely affected (due to possible unusual correlated inconsistencies within the outer volume file system). Therefore, you should consider creating a new VeraCrypt volume (with Quick Format disabled) and moving files from this volume to the new volume; this volume should be securely erased (both the outer and the hidden part). We strongly recommend that you restart the operating system now.</entry>
<entry lang="en" key="CANNOT_SATISFY_OVER_4G_FILE_SIZE_REQ">You have indicated intent to store files larger than 4 GiB on the volume. This requires the volume to be formatted as NTFS/exFAT/ReFS, which, however, will not be possible.</entry>
<entry lang="en" key="CANNOT_CREATE_NON_HIDDEN_NTFS_VOLUMES_UNDER_HIDDEN_OS">Please note that when a hidden operating system is running, non-hidden VeraCrypt volumes cannot be formatted as NTFS/exFAT/ReFS. The reason is that the volume would need to be temporarily mounted without write protection in order to allow the operating system to format it as NTFS (whereas formatting as FAT is performed by VeraCrypt, not by the operating system, and without mounting the volume). For further technical details, see below. You can create a non-hidden NTFS/exFAT/ReFS volume from within the decoy operating system.</entry>
<entry lang="en" key="HIDDEN_VOL_CREATION_UNDER_HIDDEN_OS_HOWTO">For security reasons, when a hidden operating system is running, hidden volumes can be created only in the 'direct' mode (because outer volumes must always be mounted as read-only). To create a hidden volume securely, follow these steps:\n\n1) Boot the decoy system.\n\n2) Create a normal VeraCrypt volume and, to this volume, copy some sensitive-looking files that you actually do NOT want to hide (the volume will become the outer volume).\n\n3) Boot the hidden system and start the VeraCrypt Volume Creation Wizard. If the volume is file-hosted, move it to the system partition or to another hidden volume (otherwise, the newly created hidden volume would be mounted as read-only and could not be formatted). Follow the instructions in the wizard so as to select the 'direct' hidden volume creation mode.\n\n4) In the wizard, select the volume you created in step 2 and then follow the instructions to create a hidden volume within it.</entry>
<entry lang="en" key="HIDDEN_OS_WRITE_PROTECTION_BRIEF_INFO">For security reasons, when a hidden operating system is running, local unencrypted filesystems and non-hidden VeraCrypt volumes are mounted as read-only (no data can be written to such filesystems or VeraCrypt volumes).\n\nData is allowed to be written to any filesystem that resides within a hidden VeraCrypt volume (provided that the hidden volume is not located in a container stored on an unencrypted filesystem or on any other read-only filesystem).</entry>
<entry lang="en" key="HIDDEN_OS_WRITE_PROTECTION_EXPLANATION">There are three main reasons why such countermeasures have been implemented:\n\n- It enables the creation of a secure platform for mounting of hidden VeraCrypt volumes. Note that we officially recommend that hidden volumes are mounted only when a hidden operating system is running. (For more information, see the subsection 'Security Requirements and Precautions Pertaining to Hidden Volumes' in the documentation.)\n\n- In some cases, it is possible to determine that, at a certain time, a particular filesystem was not mounted under (or that a particular file on the filesystem was not saved or accessed from within) a particular instance of an operating system (e.g. by analyzing and comparing filesystem journals, file timestamps, application logs, error logs, etc). This might indicate that a hidden operating system is installed on the computer. The countermeasures prevent these issues.\n\n- It prevents data corruption and allows safe hibernation. When Windows resumes from hibernation, it assumes that all mounted filesystems are in the same state as when the system entered hibernation. VeraCrypt ensures this by write-protecting any filesystem accessible both from within the decoy and hidden systems. Without such protection, the filesystem could become corrupted when mounted by one system while the other system is hibernated.</entry>
@@ -564,12 +564,12 @@
<entry lang="en" key="MAX_HIDVOL_SIZE_BYTES">Maximum possible hidden volume size for this volume is %.2f bytes.</entry>
<entry lang="en" key="MAX_HIDVOL_SIZE_KB">Maximum possible hidden volume size for this volume is %.2f KiB.</entry>
<entry lang="en" key="MAX_HIDVOL_SIZE_MB">Maximum possible hidden volume size for this volume is %.2f MiB.</entry>
<entry lang="en" key="MAX_HIDVOL_SIZE_GB">Maximum possible hidden volume size for this volume is %.2f GiB.</entry>
<entry lang="en" key="MAX_HIDVOL_SIZE_TB">Maximum possible hidden volume size for this volume is %.2f TiB.</entry>
- <entry lang="en" key="MOUNTED_NOPWCHANGE">Volume password/keyfiles cannot be changed while the volume is mounted. Please dismount the volume first.</entry>
- <entry lang="en" key="MOUNTED_NO_PKCS5_PRF_CHANGE">The header key derivation algorithm cannot be changed while the volume is mounted. Please dismount the volume first.</entry>
+ <entry lang="en" key="MOUNTED_NOPWCHANGE">Volume password/keyfiles cannot be changed while the volume is mounted. Please unmount the volume first.</entry>
+ <entry lang="en" key="MOUNTED_NO_PKCS5_PRF_CHANGE">The header key derivation algorithm cannot be changed while the volume is mounted. Please unmount the volume first.</entry>
<entry lang="en" key="MOUNT_BUTTON">&amp;Mount</entry>
<entry lang="en" key="NEW_VERSION_REQUIRED">A newer version of VeraCrypt is required to mount this volume.</entry>
<entry lang="en" key="VOL_CREATION_WIZARD_NOT_FOUND">Error: Volume Creation Wizard not found.\n\nPlease make sure that the file 'VeraCrypt Format.exe' is in the folder from which 'VeraCrypt.exe' was launched. If it is not, please reinstall VeraCrypt, or locate 'VeraCrypt Format.exe' on your disk and run it.</entry>
<entry lang="en" key="VOL_EXPANDER_NOT_FOUND">Error: Volume Expander not found.\n\nPlease make sure that the file 'VeraCryptExpander.exe' is in the folder from which 'VeraCrypt.exe' was launched. If it is not, please reinstall VeraCrypt, or locate 'VeraCryptExpander.exe' on your disk and run it.</entry>
<entry lang="en" key="NEXT">&amp;Next &gt;</entry>
@@ -586,13 +586,13 @@
<entry lang="en" key="NO_FREE_DRIVE_FOR_OUTER_VOL">No free drive letter for the outer volume! Volume creation cannot continue.</entry>
<entry lang="en" key="NO_OS_VER">Could not determine your operating system version or you are using an unsupported operating system.</entry>
<entry lang="en" key="NO_PATH_SELECTED">No path selected!</entry>
<entry lang="en" key="NO_SPACE_FOR_HIDDEN_VOL">Not enough free space for the hidden volume! Volume creation cannot continue.</entry>
<entry lang="en" key="HIDDEN_VOLUME_TOO_SMALL_FOR_OS_CLONE">Error: The files you copied to the outer volume occupy too much space. Therefore, there is not enough free space on the outer volume for the hidden volume.\n\nNote that the hidden volume must be as large as the system partition (the partition where the currently running operating system is installed). The reason is that the hidden operating system needs to be created by copying the content of the system partition to the hidden volume.\n\n\nThe process of creation of the hidden operating system cannot continue.</entry>
- <entry lang="en" key="OPENFILES_DRIVER">The driver is unable to dismount the volume. Some files located on the volume are probably still open.</entry>
- <entry lang="en" key="OPENFILES_LOCK">Unable to lock the volume. There are still open files on the volume. Therefore, it cannot be dismounted.</entry>
- <entry lang="en" key="VOL_LOCK_FAILED_OFFER_FORCED_DISMOUNT">VeraCrypt cannot lock the volume because it is in use by the system or applications (there may be open files on the volume).\n\nDo you want to force dismount on the volume?</entry>
+ <entry lang="en" key="OPENFILES_DRIVER">The driver is unable to unmount the volume. Some files located on the volume are probably still open.</entry>
+ <entry lang="en" key="OPENFILES_LOCK">Unable to lock the volume. There are still open files on the volume. Therefore, it cannot be unmounted.</entry>
+ <entry lang="en" key="VOL_LOCK_FAILED_OFFER_FORCED_UNMOUNT">VeraCrypt cannot lock the volume because it is in use by the system or applications (there may be open files on the volume).\n\nDo you want to force unmount on the volume?</entry>
<entry lang="en" key="OPEN_VOL_TITLE">Select a VeraCrypt Volume</entry>
<entry lang="en" key="OPEN_TITLE">Specify Path and File Name</entry>
<entry lang="en" key="SELECT_PKCS11_MODULE">Select PKCS #11 Library</entry>
<entry lang="en" key="OUTOFMEMORY">Out of Memory</entry>
<entry lang="en" key="FORMAT_DEVICE_FOR_ADVANCED_ONLY">IMPORTANT: We strongly recommend that inexperienced users create a VeraCrypt file container on the selected device/partition, instead of attempting to encrypt the entire device/partition.\n\nWhen you create a VeraCrypt file container (as opposed to encrypting a device or partition) there is, for example, no risk of destroying a large number of files. Note that a VeraCrypt file container (even though it contains a virtual encrypted disk) is actually just like any normal file. For more information, see the chapter Beginner's Tutorial in the VeraCrypt User Guide.\n\nAre you sure you want to encrypt the entire device/partition?</entry>
@@ -630,16 +630,16 @@
<entry lang="en" key="PASSWORD_HIDVOL_HOST_TITLE">Outer Volume Password</entry>
<entry lang="en" key="PASSWORD_HIDVOL_TITLE">Hidden Volume Password</entry>
<entry lang="en" key="PASSWORD_HIDDEN_OS_TITLE">Password for Hidden Operating System</entry>
<entry lang="en" key="PASSWORD_LENGTH_WARNING">WARNING: Short passwords are easy to crack using brute force techniques!\n\nWe recommend choosing a password consisting of 20 or more characters. Are you sure you want to use a short password?</entry>
<entry lang="en" key="PASSWORD_TITLE">Volume Password</entry>
- <entry lang="en" key="PASSWORD_WRONG">Operation failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry>
- <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG">Operation failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry>
- <entry lang="en" key="PASSWORD_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry>
- <entry lang="en" key="PASSWORD_OR_KEYFILE_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.</entry>
- <entry lang="en" key="PASSWORD_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</entry>
- <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.</entry>
+ <entry lang="en" key="PASSWORD_WRONG">Operation failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
+ <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG">Operation failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
+ <entry lang="en" key="PASSWORD_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
+ <entry lang="en" key="PASSWORD_OR_KEYFILE_OR_MODE_WRONG">Operation failed due to one or more of the following:\n - Wrong mount mode.\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - Not a valid volume.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
+ <entry lang="en" key="PASSWORD_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
+ <entry lang="en" key="PASSWORD_OR_KEYFILE_WRONG_AUTOMOUNT">Auto-mount failed due to one or more of the following:\n - Incorrect keyfile(s).\n - Incorrect password.\n - Incorrect Volume PIM number.\n - Incorrect PRF (hash).\n - No valid volume found.\n - Volume uses an old algorithm that has been removed.\n - TrueCrypt format volumes are no longer supported.</entry>
<entry lang="en" key="PASSWORD_WRONG_CAPSLOCK_ON">\n\nWarning: Caps Lock is on. This may cause you to enter your password incorrectly.</entry>
<entry lang="en" key="PIM_CHANGE_WARNING">Remember Number to Mount Volume</entry>
<entry lang="en" key="PIM_HIDVOL_HOST_TITLE">Outer Volume PIM</entry>
<entry lang="en" key="PIM_HIDVOL_TITLE">Hidden Volume PIM</entry>
<entry lang="en" key="PIM_HIDDEN_OS_TITLE">PIM for Hidden Operating System</entry>
@@ -692,14 +692,14 @@
<entry lang="en" key="TC_TRAVELER_DISK">VeraCrypt Traveler Disk</entry>
<entry lang="en" key="TWOFISH_HELP">Designed by Bruce Schneier, John Kelsey, Doug Whiting, David Wagner, Chris Hall, and Niels Ferguson. Published in 1998. 256-bit key, 128-bit block. Mode of operation is XTS. Twofish was one of the AES finalists.</entry>
<entry lang="en" key="MORE_INFO_ABOUT">More information on %s</entry>
<entry lang="en" key="UNKNOWN">Unknown</entry>
<entry lang="en" key="ERR_UNKNOWN">An unspecified or unknown error occurred (%d).</entry>
- <entry lang="en" key="UNMOUNTALL_LOCK_FAILED">Some volumes contain files or folders being used by applications or system.\n\nForce dismount?</entry>
- <entry lang="en" key="UNMOUNT_BUTTON">&amp;Dismount</entry>
- <entry lang="en" key="UNMOUNT_FAILED">Dismount failed!</entry>
- <entry lang="en" key="UNMOUNT_LOCK_FAILED">Volume contains files or folders being used by applications or system.\n\nForce dismount?</entry>
+ <entry lang="en" key="UNMOUNTALL_LOCK_FAILED">Some volumes contain files or folders being used by applications or system.\n\nForce unmount?</entry>
+ <entry lang="en" key="UNMOUNT_BUTTON">&amp;Unmount</entry>
+ <entry lang="en" key="UNMOUNT_FAILED">Unmount failed!</entry>
+ <entry lang="en" key="UNMOUNT_LOCK_FAILED">Volume contains files or folders being used by applications or system.\n\nForce unmount?</entry>
<entry lang="en" key="NO_VOLUME_MOUNTED_TO_DRIVE">No volume is mounted to the specified drive letter.</entry>
<entry lang="en" key="VOL_ALREADY_MOUNTED">The volume you are trying to mount is already mounted. </entry>
<entry lang="en" key="VOL_MOUNT_FAILED">An error occurred when attempting to mount volume.</entry>
<entry lang="en" key="VOL_SEEKING">Error seeking location within volume.</entry>
<entry lang="en" key="VOL_SIZE_WRONG">Error: Incorrect volume size.</entry>
@@ -727,11 +727,11 @@
<entry lang="en" key="ALL_FILES">All Files</entry>
<entry lang="en" key="TC_VOLUMES">VeraCrypt Volumes</entry>
<entry lang="en" key="DLL_FILES">Library Modules</entry>
<entry lang="en" key="FORMAT_NTFS_STOP">NTFS/exFAT/ReFS formatting cannot continue.</entry>
<entry lang="en" key="CANT_MOUNT_VOLUME">Cannot mount volume.</entry>
- <entry lang="en" key="CANT_DISMOUNT_VOLUME">Cannot dismount volume.</entry>
+ <entry lang="en" key="CANT_UNMOUNT_VOLUME">Cannot unmount volume.</entry>
<entry lang="en" key="FORMAT_NTFS_FAILED">Windows failed to format the volume as NTFS/exFAT/ReFS.\n\nPlease select a different type of file system (if possible) and try again. Alternatively, you could leave the volume unformatted (select 'None' as the filesystem), exit this wizard, mount the volume, and then use either a system or a third-party tool to format the mounted volume (the volume will remain encrypted).</entry>
<entry lang="en" key="FORMAT_NTFS_FAILED_ASK_FAT">Windows failed to format the volume as NTFS/exFAT/ReFS.\n\nDo you want to format the volume as FAT instead?</entry>
<entry lang="en" key="DEFAULT">Default</entry>
<entry lang="en" key="PARTITION_LOWER_CASE">partition</entry>
<entry lang="en" key="PARTITION_UPPER_CASE">PARTITION</entry>
@@ -769,11 +769,11 @@
<entry lang="en" key="INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL">Error: Cannot access the volume and/or obtain information about the volume.\n\nMake sure that the selected volume exists, that it is not being used by the system or applications, that you have read/write permission for the volume, and that it is not write-protected.</entry>
<entry lang="en" key="INPLACE_ENC_CANT_ACCESS_OR_GET_INFO_ON_VOL_ALT">Error: Cannot access the volume and/or obtain information about the volume. Make sure that the selected volume exists, that it is not being used by the system or applications, that you have read/write permission for the volume, and that it is not write-protected.\n\nIf the problem persists, it might help to follow the below steps.</entry>
<entry lang="en" key="INPLACE_ENC_GENERIC_ERR_ALT_STEPS">An error prevented VeraCrypt from encrypting the partition. Please try fixing any previously reported problems and then try again. If the problems persist, it might help to follow the below steps.</entry>
<entry lang="en" key="INPLACE_ENC_GENERIC_ERR_RESUME">An error prevented VeraCrypt from resuming the process of encryption/decryption of the partition/volume.\n\nPlease try fixing any previously reported problems and then try resuming the process again if possible. Note that the volume cannot be mounted until it has been fully encrypted or fully decrypted.</entry>
<entry lang="en" key="INPLACE_DEC_GENERIC_ERR">An error prevented VeraCrypt from decrypting the volume. Please try fixing any previously reported problems and then try again if possible.</entry>
- <entry lang="en" key="CANT_DISMOUNT_OUTER_VOL">Error: Cannot dismount the outer volume!\n\nVolume cannot be dismounted if it contains files or folders being used by a program or the system.\n\nPlease close any program that might be using files or directories on the volume and click Retry.</entry>
+ <entry lang="en" key="CANT_UNMOUNT_OUTER_VOL">Error: Cannot unmount the outer volume!\n\nVolume cannot be unmounted if it contains files or folders being used by a program or the system.\n\nPlease close any program that might be using files or directories on the volume and click Retry.</entry>
<entry lang="en" key="CANT_GET_OUTER_VOL_INFO">Error: Cannot obtain information about the outer volume!\nVolume creation cannot continue.</entry>
<entry lang="en" key="CANT_ACCESS_OUTER_VOL">Error: Cannot access the outer volume! Volume creation cannot continue.</entry>
<entry lang="en" key="CANT_MOUNT_OUTER_VOL">Error: Cannot mount the outer volume! Volume creation cannot continue.</entry>
<entry lang="en" key="CANT_GET_CLUSTER_BITMAP">Error: Cannot get volume cluster bitmap! Volume creation cannot continue.</entry>
<entry lang="en" key="ALPHABETICAL_CATEGORIZED">Alphabetical/Categorized</entry>
@@ -880,11 +880,11 @@
<entry lang="en" key="INSTALL_OF_FAILED">Failed to install '%s'. %s\nDo you want to continue installing?</entry>
<entry lang="en" key="UNINSTALL_OF_FAILED">Failed to uninstall '%s'. %s\nDo you want to continue uninstalling?</entry>
<entry lang="en" key="INSTALL_COMPLETED">Installation completed.</entry>
<entry lang="en" key="CANT_CREATE_FOLDER">The folder '%s' could not be created</entry>
<entry lang="en" key="CLOSE_TC_FIRST">The VeraCrypt device driver cannot be unloaded.\n\nPlease close all open VeraCrypt windows first. If it does not help, please restart Windows and then try again.</entry>
- <entry lang="en" key="DISMOUNT_ALL_FIRST">All VeraCrypt volumes must be dismounted before installing or uninstalling VeraCrypt.</entry>
+ <entry lang="en" key="UNMOUNT_ALL_FIRST">All VeraCrypt volumes must be unmounted before installing or uninstalling VeraCrypt.</entry>
<entry lang="en" key="UNINSTALL_OLD_VERSION_FIRST">An obsolete version of VeraCrypt is currently installed on this system. It needs to be uninstalled before you can install this new version of VeraCrypt.\n\nAs soon as you close this message box, the uninstaller of the old version will be launched. Note that no volume will be decrypted when you uninstall VeraCrypt. After you uninstall the old version of VeraCrypt, run the installer of the new version of VeraCrypt again.</entry>
<entry lang="en" key="REG_INSTALL_FAILED">The installation of the registry entries has failed</entry>
<entry lang="en" key="DRIVER_INSTALL_FAILED">The installation of the device driver has failed. Please restart Windows and then try installing VeraCrypt again.</entry>
<entry lang="en" key="STARTING_DRIVER">Starting VeraCrypt device driver</entry>
<entry lang="en" key="DRIVER_UINSTALL_FAILED">Uninstallation of the device driver has failed. Please note that, due to a Windows issue, it may be necessary to log off or restart the system before the device driver can be uninstalled (or reinstalled).</entry>
@@ -901,11 +901,11 @@
<entry lang="en" key="DAYS">days</entry>
<entry lang="en" key="HOURS">hours</entry>
<entry lang="en" key="MINUTES">minutes</entry>
<entry lang="en" key="SECONDS">s</entry>
<entry lang="en" key="OPEN">Open</entry>
- <entry lang="en" key="DISMOUNT">Dismount</entry>
+ <entry lang="en" key="UNMOUNT">Unmount</entry>
<entry lang="en" key="SHOW_TC">Show VeraCrypt</entry>
<entry lang="en" key="HIDE_TC">Hide VeraCrypt</entry>
<entry lang="en" key="TOTAL_DATA_READ">Data Read since Mount</entry>
<entry lang="en" key="TOTAL_DATA_WRITTEN">Data Written since Mount</entry>
<entry lang="en" key="ENCRYPTED_PORTION">Encrypted Portion</entry>
@@ -973,11 +973,11 @@
<entry lang="en" key="RESCUE_DISK_CHECK_FAILED">Cannot verify that the Rescue Disk has been correctly burned.\n\nIf you have burned the Rescue Disk, please eject and reinsert the CD/DVD; then click Next to try again. If this does not help, please try another medium%s.\n\nIf you have not burned the Rescue Disk yet, please do so, and then click Next.\n\nIf you attempted to verify a VeraCrypt Rescue Disk created before you started this wizard, please note that such Rescue Disk cannot be used, because it was created for a different master key. You need to burn the newly generated Rescue Disk.</entry>
<entry lang="en" key="RESCUE_DISK_CHECK_FAILED_SENTENCE_APPENDIX"> and/or other CD/DVD recording software</entry>
<entry lang="en" key="SYSTEM_FAVORITES_DLG_TITLE">VeraCrypt - System Favorite Volumes</entry>
<entry lang="en" key="SYS_FAVORITES_HELP_LINK">What are system favorite volumes?</entry>
<entry lang="en" key="SYS_FAVORITES_REQUIRE_PBA">The system partition/drive does not appear to be encrypted.\n\nSystem favorite volumes can be mounted using only a pre-boot authentication password. Therefore, to enable use of system favorite volumes, you need to encrypt the system partition/drive first.</entry>
- <entry lang="en" key="DISMOUNT_FIRST">Please dismount the volume before proceeding.</entry>
+ <entry lang="en" key="UNMOUNT_FIRST">Please unmount the volume before proceeding.</entry>
<entry lang="en" key="CANNOT_SET_TIMER">Error: Cannot set timer.</entry>
<entry lang="en" key="IDPM_CHECK_FILESYS">Check Filesystem</entry>
<entry lang="en" key="IDPM_REPAIR_FILESYS">Repair Filesystem</entry>
<entry lang="en" key="IDPM_ADD_TO_FAVORITES">Add to Favorites...</entry>
<entry lang="en" key="IDPM_ADD_TO_SYSTEM_FAVORITES">Add to System Favorites...</entry>
@@ -995,27 +995,27 @@
<entry lang="en" key="PATH_ITEM">Path: </entry>
<entry lang="en" key="DRIVE_LETTER_ITEM">Drive Letter: </entry>
<entry lang="en" key="UNSUPPORTED_CHARS_IN_PWD">Error: Password must contain only ASCII characters.\n\nNon-ASCII characters in password might cause the volume to be impossible to mount when your system configuration changes.\n\nThe following characters are allowed:\n\n ! " # $ % &amp; ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; &lt; = &gt; ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~</entry>
<entry lang="en" key="UNSUPPORTED_CHARS_IN_PWD_RECOM">Warning: Password contains non-ASCII characters. This may cause the volume to be impossible to mount when your system configuration changes.\n\nYou should replace all non-ASCII characters in the password with ASCII characters. To do so, click 'Volumes' -&gt; 'Change Volume Password'.\n\nThe following are ASCII characters:\n\n ! " # $ % &amp; ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; &lt; = &gt; ? @ A B C D E F G H I J K L M N O P Q R S T U V W X Y Z [ \\ ] ^ _ ` a b c d e f g h i j k l m n o p q r s t u v w x y z { | } ~</entry>
<entry lang="en" key="EXE_FILE_EXTENSION_CONFIRM">WARNING: We strongly recommend that you avoid file extensions that are used for executable files (such as .exe, .sys, or .dll) and other similarly problematic file extensions. Using such file extensions causes Windows and antivirus software to interfere with the container, which adversely affects the performance of the volume and may also cause other serious problems.\n\nWe strongly recommend that you remove the file extension or change it (e.g., to '.hc').\n\nAre you sure you want to use the problematic file extension?</entry>
- <entry lang="en" key="EXE_FILE_EXTENSION_MOUNT_WARNING">WARNING: This container has a file extension that is used for executable files (such as .exe, .sys, or .dll) or some other file extension that is similarly problematic. It will very likely cause Windows and antivirus software to interfere with the container, which will adversely affect the performance of the volume and may also cause other serious problems.\n\nWe strongly recommend that you remove the file extension of the container or change it (e.g., to '.hc') after you dismount the volume.</entry>
+ <entry lang="en" key="EXE_FILE_EXTENSION_MOUNT_WARNING">WARNING: This container has a file extension that is used for executable files (such as .exe, .sys, or .dll) or some other file extension that is similarly problematic. It will very likely cause Windows and antivirus software to interfere with the container, which will adversely affect the performance of the volume and may also cause other serious problems.\n\nWe strongly recommend that you remove the file extension of the container or change it (e.g., to '.hc') after you unmount the volume.</entry>
<entry lang="en" key="HOMEPAGE">Homepage</entry>
<entry lang="en" key="LARGE_IDE_WARNING_XP">WARNING: It appears that you have not applied any Service Pack to your Windows installation. You should not write to IDE disks larger than 128 GiB under Windows XP to which you did not apply Service Pack 1 or later! If you do, data on the disk (no matter if it is a VeraCrypt volume or not) may get corrupted. Note that this is a limitation of Windows, not a bug in VeraCrypt.</entry>
<entry lang="en" key="LARGE_IDE_WARNING_2K">WARNING: It appears that you have not applied Service Pack 3 or later to your Windows installation. You should not write to IDE disks larger than 128 GiB under Windows 2000 to which you did not apply Service Pack 3 or later! If you do, data on the disk (no matter if it is a VeraCrypt volume or not) may get corrupted. Note that this is a limitation of Windows, not a bug in VeraCrypt.\n\nNote: You may also need to enable the 48-bit LBA support in the registry; for more information, see http://support.microsoft.com/kb/305098/EN-US</entry>
<entry lang="en" key="LARGE_IDE_WARNING_2K_REGISTRY">WARNING: 48-bit LBA ATAPI support is disabled on your system. Therefore, you should not write to IDE disks larger than 128 GiB! If you do, data on the disk (no matter if it is a VeraCrypt volume or not) may get corrupted. Note that this is a limitation of Windows, not a limitation of VeraCrypt.\n\nTo enable the 48-bit LBA support, add the 'EnableBigLba' registry value in the registry key HKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\atapi\\Parameters and set it to 1.\n\nFor more information, see http://support.microsoft.com/kb/305098</entry>
<entry lang="en" key="VOLUME_TOO_LARGE_FOR_FAT32">Error: Files larger than 4 GiB cannot be stored on a FAT32 file system. Therefore, file-hosted VeraCrypt volumes (containers) stored on a FAT32 file system cannot be larger than 4 GiB.\n\nIf you need a larger volume, create it on an NTFS file system (or, if you use Windows Vista SP1 or later, on an exFAT file system) or, instead of creating a file-hosted volume, encrypt an entire partition or device.</entry>
<entry lang="en" key="VOLUME_TOO_LARGE_FOR_WINXP">Warning: Windows XP does not support files larger than 2048 GiB (it will report that "Not enough storage is available"). Therefore, you cannot create a file-hosted VeraCrypt volume (container) larger than 2048 GiB under Windows XP.\n\nNote that it is still possible to encrypt the entire drive or create a partition-hosted VeraCrypt volume larger than 2048 GiB under Windows XP.</entry>
<entry lang="en" key="FREE_SPACE_FOR_WRITING_TO_OUTER_VOLUME">WARNING: If you want to be able to add more data/files to the outer volume in future, you should consider choosing a smaller size for the hidden volume.\n\nAre you sure you want to continue with the size you specified?</entry>
<entry lang="en" key="NO_VOLUME_SELECTED">No volume selected.\n\nClick 'Select Device' or 'Select File' to select a VeraCrypt volume.</entry>
- <entry lang="en" key="NO_SYSENC_PARTITION_SELECTED">No partition selected.\n\nClick 'Select Device' to select a dismounted partition that normally requires pre-boot authentication (for example, a partition located on the encrypted system drive of another operating system, which is not running, or the encrypted system partition of another operating system).\n\nNote: The selected partition will be mounted as a regular VeraCrypt volume without pre-boot authentication. This is useful e.g. for backup or repair operations.</entry>
+ <entry lang="en" key="NO_SYSENC_PARTITION_SELECTED">No partition selected.\n\nClick 'Select Device' to select a unmounted partition that normally requires pre-boot authentication (for example, a partition located on the encrypted system drive of another operating system, which is not running, or the encrypted system partition of another operating system).\n\nNote: The selected partition will be mounted as a regular VeraCrypt volume without pre-boot authentication. This is useful e.g. for backup or repair operations.</entry>
<entry lang="en" key="CONFIRM_SAVE_DEFAULT_KEYFILES">WARNING: If default keyfiles are set and enabled, volumes that are not using these keyfiles will be impossible to mount. Therefore, after you enable default keyfiles, keep in mind to uncheck the 'Use keyfiles' checkbox (below a password input field) whenever mounting such volumes.\n\nAre you sure you want to save the selected keyfiles/paths as default?</entry>
<entry lang="en" key="HK_AUTOMOUNT_DEVICES">Auto-Mount Devices</entry>
- <entry lang="en" key="HK_DISMOUNT_ALL">Dismount All</entry>
+ <entry lang="en" key="HK_UNMOUNT_ALL">Unmount All</entry>
<entry lang="en" key="HK_WIPE_CACHE">Wipe Cache</entry>
- <entry lang="en" key="HK_DISMOUNT_ALL_AND_WIPE">Dismount All &amp; Wipe Cache</entry>
- <entry lang="en" key="HK_FORCE_DISMOUNT_ALL_AND_WIPE">Force Dismount All &amp; Wipe Cache</entry>
- <entry lang="en" key="HK_FORCE_DISMOUNT_ALL_AND_WIPE_AND_EXIT">Force Dismount All, Wipe Cache &amp; Exit</entry>
+ <entry lang="en" key="HK_UNMOUNT_ALL_AND_WIPE">Unmount All &amp; Wipe Cache</entry>
+ <entry lang="en" key="HK_FORCE_UNMOUNT_ALL_AND_WIPE">Force Unmount All &amp; Wipe Cache</entry>
+ <entry lang="en" key="HK_FORCE_UNMOUNT_ALL_AND_WIPE_AND_EXIT">Force Unmount All, Wipe Cache &amp; Exit</entry>
<entry lang="en" key="HK_MOUNT_FAVORITE_VOLUMES">Mount Favorite Volumes</entry>
<entry lang="en" key="HK_SHOW_HIDE_MAIN_WINDOW">Show/Hide Main VeraCrypt Window</entry>
<entry lang="en" key="PRESS_A_KEY_TO_ASSIGN">(Click here and press a key)</entry>
<entry lang="en" key="ACTION">Action</entry>
<entry lang="en" key="SHORTCUT">Shortcut</entry>
@@ -1023,26 +1023,26 @@
<entry lang="en" key="SHORTCUT_ALREADY_IN_USE">Error: Shortcut already in use.</entry>
<entry lang="en" key="HOTKEY_REGISTRATION_ERROR">WARNING: One or more VeraCrypt system-wide hot keys will not work!\n\nPlease make sure that other applications and the operating system do not use the same shortcut(s) as VeraCrypt.</entry>
<entry lang="en" key="PAGING_FILE_CREATION_PREVENTED">Paging file creation has been prevented.\n\nPlease note that, due to Windows issues, paging files cannot be located on non-system VeraCrypt volumes (including system favorite volumes). VeraCrypt supports creation of paging files only on an encrypted system partition/drive.</entry>
<entry lang="en" key="SYS_ENC_HIBERNATION_PREVENTED">An error or incompatibility prevents VeraCrypt from encrypting the hibernation file. Therefore, hibernation has been prevented.\n\nNote: When a computer hibernates (or enters a power-saving mode), the content of its system memory is written to a hibernation storage file residing on the system drive. VeraCrypt would not be able to prevent encryption keys and the contents of sensitive files opened in RAM from being saved unencrypted to the hibernation storage file.</entry>
<entry lang="en" key="HIDDEN_OS_HIBERNATION_PREVENTED">Hibernation has been prevented.\n\nVeraCrypt does not support hibernation on hidden operating systems that use an extra boot partition. Please note that the boot partition is shared by both the decoy and the hidden system. Therefore, in order to prevent data leaks and problems while resuming from hibernation, VeraCrypt has to prevent the hidden system from writing to the shared boot partition and from hibernating.</entry>
- <entry lang="en" key="VOLUME_MOUNTED_AS_DRIVE_LETTER_X_DISMOUNTED">VeraCrypt volume mounted as %c: has been dismounted.</entry>
- <entry lang="en" key="MOUNTED_VOLUMES_DISMOUNTED">VeraCrypt volumes have been dismounted.</entry>
- <entry lang="en" key="VOLUMES_DISMOUNTED_CACHE_WIPED">VeraCrypt volumes have been dismounted and password cache has been wiped.</entry>
- <entry lang="en" key="SUCCESSFULLY_DISMOUNTED">Successfully dismounted</entry>
- <entry lang="en" key="CONFIRM_BACKGROUND_TASK_DISABLED">WARNING: If the VeraCrypt Background Task is disabled, the following functions will be disabled:\n\n1) Hot keys\n2) Auto-dismount (e.g., upon logoff, inadvertent host device removal, time-out, etc.)\n3) Auto-mount of favorite volumes\n4) Notifications (e.g., when damage to hidden volume is prevented)\n5) Tray icon\n\nNote: You can shut down the Background Task anytime by right-clicking the VeraCrypt tray icon and selecting 'Exit'.\n\nAre you sure you want to permanently disable the VeraCrypt Background Task?</entry>
- <entry lang="en" key="CONFIRM_NO_FORCED_AUTODISMOUNT">WARNING: If this option is disabled, volumes containing open files/directories will not be possible to auto-dismount.\n\nAre you sure you want to disable this option?</entry>
- <entry lang="en" key="WARN_PREF_AUTO_DISMOUNT">WARNING: Volumes containing open files/directories will NOT be auto-dismounted.\n\nTo prevent this, enable the following option in this dialog window: 'Force auto-dismount even if volume contains open files or directories'</entry>
- <entry lang="en" key="WARN_PREF_AUTO_DISMOUNT_ON_POWER">WARNING: When the notebook battery power is low, Windows may omit sending the appropriate messages to running applications when the computer is entering power saving mode. Therefore, VeraCrypt may fail to auto-dismount volumes in such cases.</entry>
+ <entry lang="en" key="VOLUME_MOUNTED_AS_DRIVE_LETTER_X_UNMOUNTED">VeraCrypt volume mounted as %c: has been unmounted.</entry>
+ <entry lang="en" key="MOUNTED_VOLUMES_UNMOUNTED">VeraCrypt volumes have been unmounted.</entry>
+ <entry lang="en" key="VOLUMES_UNMOUNTED_CACHE_WIPED">VeraCrypt volumes have been unmounted and password cache has been wiped.</entry>
+ <entry lang="en" key="SUCCESSFULLY_UNMOUNTED">Successfully unmounted</entry>
+ <entry lang="en" key="CONFIRM_BACKGROUND_TASK_DISABLED">WARNING: If the VeraCrypt Background Task is disabled, the following functions will be disabled:\n\n1) Hot keys\n2) Auto-unmount (e.g., upon logoff, inadvertent host device removal, time-out, etc.)\n3) Auto-mount of favorite volumes\n4) Notifications (e.g., when damage to hidden volume is prevented)\n5) Tray icon\n\nNote: You can shut down the Background Task anytime by right-clicking the VeraCrypt tray icon and selecting 'Exit'.\n\nAre you sure you want to permanently disable the VeraCrypt Background Task?</entry>
+ <entry lang="en" key="CONFIRM_NO_FORCED_AUTOUNMOUNT">WARNING: If this option is disabled, volumes containing open files/directories will not be possible to auto-unmount.\n\nAre you sure you want to disable this option?</entry>
+ <entry lang="en" key="WARN_PREF_AUTO_UNMOUNT">WARNING: Volumes containing open files/directories will NOT be auto-unmounted.\n\nTo prevent this, enable the following option in this dialog window: 'Force auto-unmount even if volume contains open files or directories'</entry>
+ <entry lang="en" key="WARN_PREF_AUTO_UNMOUNT_ON_POWER">WARNING: When the notebook battery power is low, Windows may omit sending the appropriate messages to running applications when the computer is entering power saving mode. Therefore, VeraCrypt may fail to auto-unmount volumes in such cases.</entry>
<entry lang="en" key="NONSYS_INPLACE_ENC_RESUME_PROMPT">You have scheduled the process of encryption/decryption of a partition/volume. The process has not been completed yet.\n\nDo you want to resume the process now?</entry>
<entry lang="en" key="SYSTEM_ENCRYPTION_RESUME_PROMPT">You have scheduled the process of encryption or decryption of the system partition/drive. The process has not been completed yet.\n\nDo you want to start (resume) the process now?</entry>
<entry lang="en" key="ASK_NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL">Do you want to be prompted about whether you want to resume the currently scheduled processes of encryption/decryption of non-system partitions/volumes?</entry>
<entry lang="en" key="KEEP_PROMPTING_ME">Yes, keep prompting me</entry>
<entry lang="en" key="DO_NOT_PROMPT_ME">No, do not prompt me</entry>
<entry lang="en" key="NONSYS_INPLACE_ENC_NOTIFICATION_REMOVAL_NOTE">IMPORTANT: Keep in mind that you can resume the process of encryption/decryption of any non-system partition/volume by selecting 'Volumes' &gt; 'Resume Interrupted Process' from the menu bar of the main VeraCrypt window.</entry>
<entry lang="en" key="SYSTEM_ENCRYPTION_SCHEDULED_BUT_PBA_FAILED">You have scheduled the process of encryption or decryption of the system partition/drive. However, pre-boot authentication failed (or was bypassed).\n\nNote: If you decrypted the system partition/drive in the pre-boot environment, you may need to finalize the process by selecting 'System' &gt; 'Permanently Decrypt System Partition/Drive' from the menu bar of the main VeraCrypt window.</entry>
- <entry lang="en" key="CONFIRM_EXIT">WARNING: If VeraCrypt exits now, the following functions will be disabled:\n\n1) Hot keys\n2) Auto-dismount (e.g., upon logoff, inadvertent host device removal, time-out, etc.)\n3) Auto-mount of favorite volumes\n4) Notifications (e.g., when damage to hidden volume is prevented)\n\nNote: If you do not wish VeraCrypt to run in the background, disable the VeraCrypt Background Task in the Preferences (and, if necessary, disable the automatic start of VeraCrypt in the Preferences).\n\nAre you sure you want VeraCrypt to exit?</entry>
+ <entry lang="en" key="CONFIRM_EXIT">WARNING: If VeraCrypt exits now, the following functions will be disabled:\n\n1) Hot keys\n2) Auto-unmount (e.g., upon logoff, inadvertent host device removal, time-out, etc.)\n3) Auto-mount of favorite volumes\n4) Notifications (e.g., when damage to hidden volume is prevented)\n\nNote: If you do not wish VeraCrypt to run in the background, disable the VeraCrypt Background Task in the Preferences (and, if necessary, disable the automatic start of VeraCrypt in the Preferences).\n\nAre you sure you want VeraCrypt to exit?</entry>
<entry lang="en" key="CONFIRM_EXIT_UNIVERSAL">Exit?</entry>
<entry lang="en" key="CHOOSE_ENCRYPT_OR_DECRYPT">VeraCrypt does not have sufficient information to determine whether to encrypt or decrypt.</entry>
<entry lang="en" key="CHOOSE_ENCRYPT_OR_DECRYPT_FINALIZE_DECRYPT_NOTE">VeraCrypt does not have sufficient information to determine whether to encrypt or decrypt.\n\nNote: If you decrypted the system partition/drive in the pre-boot environment, you may need to finalize the process by clicking Decrypt.</entry>
<entry lang="en" key="NONSYS_INPLACE_ENC_REVERSE_INFO">Note: When you are encrypting a non-system partition/volume in place and an error persistently prevents you from finishing the process, you will not be able to mount the volume (and access data stored on it) until you entirely DECRYPT the volume (i.e. reverse the process).\n\nIf you need to do so, follow these steps:\n1) Exit this wizard.\n2) In the main VeraCrypt window, select 'Volumes' &gt; 'Resume Interrupted Process'.\n3) Select 'Decrypt'.</entry>
<entry lang="en" key="NONSYS_INPLACE_ENC_DEFER_CONFIRM">Do you want to interrupt and postpone the process of encryption/decryption of the partition/volume?\n\nNote: Keep in mind that the volume cannot be mounted until it has been fully encrypted or decrypted. You will be able to resume the process of encryption/decryption and it will continue from the point where it was stopped. You can do so, for example, by selecting 'Volumes' &gt; 'Resume Interrupted Process' from the menu bar of the main VeraCrypt window.</entry>
@@ -1061,11 +1061,11 @@
<entry lang="en" key="REPAIRING_FS">Attempting to repair the file system on the VeraCrypt volume mounted as %s...</entry>
<entry lang="en" key="WARN_64_BIT_BLOCK_CIPHER">Warning: This volume is encrypted with a legacy encryption algorithm.\n\nAll 64-bit-block encryption algorithms (e.g., Blowfish, CAST-128, or Triple DES) are deprecated. It will be possible to mount this volume using future versions of VeraCrypt. However, there will be no further enhancements to the implementations of these legacy encryption algorithms. We recommend that you create a new VeraCrypt volume encrypted with a 128-bit-block encryption algorithm (e.g., AES, Serpent, Twofish, etc.) and that you move all files from this volume to the new volume.</entry>
<entry lang="en" key="SYS_AUTOMOUNT_DISABLED">Your system is not configured to auto-mount new volumes. It may be impossible to mount device-hosted VeraCrypt volumes. Auto-mounting can be enabled by executing the following command and restarting the system.\n\nmountvol.exe /E</entry>
<entry lang="en" key="SYS_ASSIGN_DRIVE_LETTER">Please assign a drive letter to the partition/device before proceeding ('Control Panel' > 'System and Maintenance' > 'Administrative Tools' - 'Create and format hard disk partitions').\n\nNote that this is a requirement of the operating system.</entry>
<entry lang="en" key="MOUNT_TC_VOLUME">Mount VeraCrypt volume</entry>
- <entry lang="en" key="DISMOUNT_ALL_TC_VOLUMES">Dismount all VeraCrypt volumes</entry>
+ <entry lang="en" key="UNMOUNT_ALL_TC_VOLUMES">Unmount all VeraCrypt volumes</entry>
<entry lang="en" key="UAC_INIT_ERROR">VeraCrypt failed to obtain Administrator privileges.</entry>
<entry lang="en" key="ERR_ACCESS_DENIED">Access was denied by the operating system.\n\nPossible cause: The operating system requires that you have read/write permission (or administrator privileges) for certain folders, files, and devices, in order for you to be allowed to read and write data to/from them. Normally, a user without administrator privileges is allowed to create, read and modify files in his or her Documents folder.</entry>
<entry lang="en" key="SECTOR_SIZE_UNSUPPORTED">Error: The drive uses an unsupported sector size.\n\nIt is currently not possible to create partition/device-hosted volumes on drives that use sectors larger than 4096 bytes. However, note that you can create file-hosted volumes (containers) on such drives.</entry>
<entry lang="en" key="SYSENC_UNSUPPORTED_SECTOR_SIZE_BIOS">It is currently not possible to encrypt a system installed on a disk that uses a sector size other than 512 bytes.</entry>
<entry lang="en" key="NO_SPACE_FOR_BOOT_LOADER">The VeraCrypt Boot Loader requires at least 32 KibiBytes of free space at the beginning of the system drive (the VeraCrypt Boot Loader needs to be stored in that area). Unfortunately, your drive does not meet this condition.\n\nPlease do NOT report this as a bug/problem in VeraCrypt. To solve this problem, you will need to repartition your disk and leave the first 32 KibiBytes of the disk free (in most cases, you will need to delete and recreate the first partition). We recommend that you use the Microsoft partition manager that is available e.g. when you are installing Windows.</entry>
@@ -1283,33 +1283,33 @@
<entry lang="en" key="TOKEN_SLOT_ID">Slot</entry>
<entry lang="en" key="TOKEN_NAME">Token name</entry>
<entry lang="en" key="TOKEN_DATA_OBJECT_LABEL">File name</entry>
<entry lang="en" key="BOOT_PASSWORD_CACHE_KEYBOARD_WARNING">IMPORTANT: Please note that pre-boot authentication passwords are always typed using the standard US keyboard layout. Therefore, a volume that uses a password typed using any other keyboard layout may be impossible to mount using a pre-boot authentication password (note that this is not a bug in VeraCrypt). To allow such a volume to be mounted using a pre-boot authentication password, follow these steps:\n\n1) Click 'Select File' or 'Select Device' and select the volume.\n2) Select 'Volumes' > 'Change Volume Password'.\n3) Enter the current password for the volume.\n4) Change the keyboard layout to English (US) by clicking the Language bar icon in the Windows taskbar and selecting 'EN English (United States)'.\n5) In VeraCrypt, in the field for the new password, type the pre-boot authentication password.\n6) Confirm the new password by retyping it in the confirmation field and click 'OK'.\nWARNING: Please keep in mind that if you follow these steps, the volume password will always have to be typed using the US keyboard layout (which is automatically ensured only in the pre-boot environment).</entry>
<entry lang="en" key="SYS_FAVORITES_KEYBOARD_WARNING">System favorite volumes will be mounted using the pre-boot authentication password. If any system favorite volume uses a different password, it will not be mounted.</entry>
- <entry lang="en" key="SYS_FAVORITES_ADMIN_ONLY_INFO">Please note that if you need to prevent normal VeraCrypt volume actions (such as 'Dismount All', auto-dismount, etc.) from affecting system favorite volumes, you should enable the option 'Allow only administrators to view and dismount system favorite volumes in VeraCrypt'. In addition, when VeraCrypt is run without administrator privileges (the default on Windows Vista and later), system favorite volumes will not be displayed in the drive letter list in the main VeraCrypt application window.</entry>
- <entry lang="en" key="SYS_FAVORITES_ADMIN_ONLY_WARNING">IMPORTANT: Please keep in mind that if this option is enabled and VeraCrypt does not have administrator privileges, mounted system favorite volumes are NOT displayed in the VeraCrypt application window and they cannot be dismounted. Therefore, if you need e.g. to dismount a system favorite volume, please right-click the VeraCrypt icon (in the Start menu) and select 'Run as administrator' first. The same limitation applies to the 'Dismount All' function, 'Auto-Dismount' functions, 'Dismount All' hot keys, etc.</entry>
+ <entry lang="en" key="SYS_FAVORITES_ADMIN_ONLY_INFO">Please note that if you need to prevent normal VeraCrypt volume actions (such as 'Unmount All', auto-unmount, etc.) from affecting system favorite volumes, you should enable the option 'Allow only administrators to view and unmount system favorite volumes in VeraCrypt'. In addition, when VeraCrypt is run without administrator privileges (the default on Windows Vista and later), system favorite volumes will not be displayed in the drive letter list in the main VeraCrypt application window.</entry>
+ <entry lang="en" key="SYS_FAVORITES_ADMIN_ONLY_WARNING">IMPORTANT: Please keep in mind that if this option is enabled and VeraCrypt does not have administrator privileges, mounted system favorite volumes are NOT displayed in the VeraCrypt application window and they cannot be unmounted. Therefore, if you need e.g. to unmount a system favorite volume, please right-click the VeraCrypt icon (in the Start menu) and select 'Run as administrator' first. The same limitation applies to the 'Unmount All' function, 'Auto-Unmount' functions, 'Unmount All' hot keys, etc.</entry>
<entry lang="en" key="SETTING_REQUIRES_REBOOT">Note that this setting takes effect only after the operating system is restarted.</entry>
<entry lang="en" key="COMMAND_LINE_ERROR">Error while parsing command line.</entry>
<entry lang="en" key="RESCUE_DISK">Rescue Disk</entry>
<entry lang="en" key="SELECT_FILE_AND_MOUNT">Select &amp;File and Mount...</entry>
<entry lang="en" key="SELECT_DEVICE_AND_MOUNT">Select &amp;Device and Mount...</entry>
- <entry lang="en" key="DISABLE_NONADMIN_SYS_FAVORITES_ACCESS">Allow only administrators to view and dismount system favorite volumes in VeraCrypt</entry>
+ <entry lang="en" key="DISABLE_NONADMIN_SYS_FAVORITES_ACCESS">Allow only administrators to view and unmount system favorite volumes in VeraCrypt</entry>
<entry lang="en" key="MOUNT_SYSTEM_FAVORITES_ON_BOOT">Mount system favorite volumes when Windows starts (in the initial phase of the startup procedure)</entry>
- <entry lang="en" key="MOUNTED_VOLUME_DIRTY">Warning: The filesystem on the volume mounted as '%s' was not cleanly dismounted and thus may contain errors. Using a corrupted filesystem can cause data loss or data corruption.\n\nNote: Before you physically remove or switch off a device (such as a USB flash drive or an external hard drive) where a mounted VeraCrypt volume resides, you should always dismount the VeraCrypt volume in VeraCrypt first.\n\n\nDo you want Windows to attempt to detect and fix errors (if any) on the filesystem?</entry>
- <entry lang="en" key="SYS_FAVORITE_VOLUME_DIRTY">Warning: One or more system favorite volumes were not cleanly dismounted and thus may contain filesystem errors. Please see the system event log for further details.\n\nUsing a corrupted filesystem can cause data loss or data corruption. You should check the affected system favorite volume(s) for errors (right-click each of them in VeraCrypt and select 'Repair Filesystem').</entry>
+ <entry lang="en" key="MOUNTED_VOLUME_DIRTY">Warning: The filesystem on the volume mounted as '%s' was not cleanly unmounted and thus may contain errors. Using a corrupted filesystem can cause data loss or data corruption.\n\nNote: Before you physically remove or switch off a device (such as a USB flash drive or an external hard drive) where a mounted VeraCrypt volume resides, you should always unmount the VeraCrypt volume in VeraCrypt first.\n\n\nDo you want Windows to attempt to detect and fix errors (if any) on the filesystem?</entry>
+ <entry lang="en" key="SYS_FAVORITE_VOLUME_DIRTY">Warning: One or more system favorite volumes were not cleanly unmounted and thus may contain filesystem errors. Please see the system event log for further details.\n\nUsing a corrupted filesystem can cause data loss or data corruption. You should check the affected system favorite volume(s) for errors (right-click each of them in VeraCrypt and select 'Repair Filesystem').</entry>
<entry lang="en" key="FILESYS_REPAIR_CONFIRM_BACKUP">Warning: Repairing a damaged filesystem using the Microsoft 'chkdsk' tool might cause loss of files in damaged areas. Therefore, it is recommended that you first back up the files stored on the VeraCrypt volume to another, healthy, VeraCrypt volume.\n\nDo you want to repair the filesystem now?</entry>
<entry lang="en" key="MOUNTED_CONTAINER_FORCED_READ_ONLY">Volume '%s' has been mounted as read-only because write access was denied.\n\nPlease make sure the security permissions of the file container allow you to write to it (right-click the container and select Properties > Security).\n\nNote that, due to a Windows issue, you may see this warning even after setting the appropriate security permissions. This is not caused by a bug in VeraCrypt. A possible solution is to move your container to, e.g., your 'Documents' folder.\n\nIf you intend to keep your volume read-only, set the read-only attribute of the container (right-click the container and select Properties > Read-only), which will suppress this warning.</entry>
<entry lang="en" key="MOUNTED_DEVICE_FORCED_READ_ONLY">Volume '%s' had to be mounted as read-only because write access was denied.\n\nPlease make sure no other application (e.g. antivirus software) is accessing the partition/device on which the volume is hosted.</entry>
<entry lang="en" key="MOUNTED_DEVICE_FORCED_READ_ONLY_WRITE_PROTECTION">Volume '%s' has been mounted as read-only because the operating system reported the host device to be write-protected.\n\nPlease note that some custom chipset drivers have been reported to cause writable media to falsely appear write-protected. This problem is not caused by VeraCrypt. It may be solved by updating or uninstalling any custom (non-Microsoft) chipset drivers that are currently installed on this system.</entry>
<entry lang="en" key="LIMIT_ENC_THREAD_POOL_NOTE">Note that the Hyper-Threading technology provides multiple logical cores per a single physical core. When Hyper Threading is enabled, the number selected above represents the number of logical processors/cores.</entry>
<entry lang="en" key="NUMBER_OF_THREADS">%d threads</entry>
<entry lang="en" key="DISABLED_HW_AES_AFFECTS_PERFORMANCE">Note that hardware-accelerated AES is disabled, which will affect benchmark results (worse performance).\n\nTo enable hardware acceleration, select 'Settings' > 'Performance' and enable the corresponding option.</entry>
<entry lang="en" key="LIMITED_THREAD_COUNT_AFFECTS_PERFORMANCE">Note that the number of threads is currently limited, which will affect benchmark results (worse performance).\n\nTo utilize the full potential of the processor(s), select 'Settings' > 'Performance' and disable the corresponding option.</entry>
<entry lang="en" key="ASK_REMOVE_DEVICE_WRITE_PROTECTION">Do you want VeraCrypt to attempt to disable write protection of the partition/drive?</entry>
<entry lang="en" key="CONFIRM_SETTING_DEGRADES_PERFORMANCE">WARNING: This setting may degrade performance.\n\nAre you sure you want to use this setting?</entry>
- <entry lang="en" key="HOST_DEVICE_REMOVAL_DISMOUNT_WARN_TITLE">Warning: VeraCrypt volume auto-dismounted</entry>
- <entry lang="en" key="HOST_DEVICE_REMOVAL_DISMOUNT_WARN">Before you physically remove or turn off a device containing a mounted volume, you should always dismount the volume in VeraCrypt first.\n\nUnexpected spontaneous dismount is usually caused by an intermittently failing cable, drive (enclosure), etc.</entry>
+ <entry lang="en" key="HOST_DEVICE_REMOVAL_UNMOUNT_WARN_TITLE">Warning: VeraCrypt volume auto-unmounted</entry>
+ <entry lang="en" key="HOST_DEVICE_REMOVAL_UNMOUNT_WARN">Before you physically remove or turn off a device containing a mounted volume, you should always unmount the volume in VeraCrypt first.\n\nUnexpected spontaneous unmount is usually caused by an intermittently failing cable, drive (enclosure), etc.</entry>
<entry lang="en" key="UNSUPPORTED_TRUECRYPT_FORMAT">This volume was created with TrueCrypt %x.%x but VeraCrypt supports only TrueCrypt volumes created with TrueCrypt 6.x/7.x series</entry>
<entry lang="en" key="TEST">Test</entry>
<entry lang="en" key="KEYFILE">Keyfile</entry>
<entry lang="en" key="VKEY_08">Backspace</entry>
<entry lang="en" key="VKEY_09">Tab</entry>
@@ -1451,11 +1451,11 @@
<entry lang="en" key="QUICK_FORMAT_HELP">In order to enable your operating system to mount your new volume, it has to be formatted with a filesystem. Please select a filesystem type.\n\nIf your volume is going to be hosted on a device or partition, you can use 'Quick format' to skip encryption of free space of the volume.</entry>
<entry lang="en" key="IDC_ENABLE_HARDWARE_ENCRYPTION_NEG">Do not accelerate AES encryption/decryption by using the AES instructions of the processor</entry>
<entry lang="en" key="IDM_ADD_ALL_VOLUME_TO_FAVORITES">Add All Mounted Volumes to Favorites...</entry>
<entry lang="en" key="TASKICON_PREF_MENU_ITEMS">Task Icon Menu Items</entry>
<entry lang="en" key="TASKICON_PREF_OPEN_VOL">Open Mounted Volumes</entry>
- <entry lang="en" key="TASKICON_PREF_DISMOUNT_VOL">Dismount Mounted Volumes</entry>
+ <entry lang="en" key="TASKICON_PREF_UNMOUNT_VOL">Unmount Mounted Volumes</entry>
<entry lang="en" key="DISK_FREE">Free space available: {0}</entry>
<entry lang="en" key="VOLUME_SIZE_HELP">Please specify the size of the container to create. Note that the minimum possible size of a volume is 292 KiB.</entry>
<entry lang="en" key="LINUX_CONFIRM_INNER_VOLUME_CALC">WARNING: You have selected a filesystem other than FAT for the outer volume.\nPlease Note that in this case VeraCrypt can't calculate the exact maximum allowed size for the hidden volume and it will use only an estimation that can be wrong.\nThus, it is your responsibility to use an adequate value for the size of the hidden volume so that it does not overlap the outer volume.\n\nDo you want to continue using the selected filesystem for the outer volume?</entry>
<entry lang="en" key="LINUX_PREF_TAB_SECURITY">Security</entry>
<entry lang="en" key="LINUX_PREF_TAB_MOUNT_OPTIONS">Mount Options</entry>
@@ -1481,18 +1481,18 @@
<entry lang="en" key="LINUX_SYSTEM_ENC_PW_LENGTH_NOTE">System Encryption password is longer than {0} characters.</entry>
<entry lang="en" key="LINUX_MOUNT_SYSTEM_ENC_PREBOOT">Mount partition &amp;using system encryption (preboot authentication)</entry>
<entry lang="en" key="LINUX_DO_NOT_MOUNT">Do &amp;not mount</entry>
<entry lang="en" key="LINUX_MOUNT_AT_DIR">Mount at directory:</entry>
<entry lang="en" key="LINUX_SELECT">Se&amp;lect...</entry>
- <entry lang="en" key="LINUX_DISMOUNT_ALL_WHEN">Dismount All Volumes When</entry>
+ <entry lang="en" key="LINUX_UNMOUNT_ALL_WHEN">Unmount All Volumes When</entry>
<entry lang="en" key="LINUX_ENTERING_POWERSAVING">System is entering power saving mode</entry>
<entry lang="en" key="LINUX_LOGIN_ACTION">Actions to Perform when User Logs On</entry>
- <entry lang="en" key="LINUX_CLOSE_EXPL_ON_DISMOUNT">Close all Explorer windows of volume being dismounted</entry>
+ <entry lang="en" key="LINUX_CLOSE_EXPL_ON_UNMOUNT">Close all Explorer windows of volume being unmounted</entry>
<entry lang="en" key="LINUX_HOTKEYS">Hotkeys</entry>
<entry lang="en" key="LINUX_SYSTEM_HOTKEYS">System-Wide Hotkeys</entry>
- <entry lang="en" key="LINUX_SOUND_NOTIFICATION">Play system notification sound after mount/dismount</entry>
- <entry lang="en" key="LINUX_CONFIRM_AFTER_DISMOUNT">Display confirmation message box after dismount</entry>
+ <entry lang="en" key="LINUX_SOUND_NOTIFICATION">Play system notification sound after mount/unmount</entry>
+ <entry lang="en" key="LINUX_CONFIRM_AFTER_UNMOUNT">Display confirmation message box after unmount</entry>
<entry lang="en" key="LINUX_VC_QUITS">VeraCrypt quits</entry>
<entry lang="en" key="LINUX_OPEN_FINDER">Open Finder window for successfully mounted volume</entry>
<entry lang="en" key="LINUX_DISABLE_KERNEL_ONLY_SETTING">Please note that this setting takes effect only if use of the kernel cryptographic services is disabled.</entry>
<entry lang="en" key="LINUX_DISABLE_KERNEL_CRYPT_CONFIRM">Disabling the use of kernel cryptographic services can degrade performance.\n\nAre you sure?</entry>
<entry lang="en" key="LINUX_KERNEL_CRYPT_OPTION_CHANGE_MOUNTED_HINT">Please note that disabling this option may have no effect on volumes mounted using kernel cryptographic services.</entry>
@@ -1508,23 +1508,23 @@
<entry lang="en" key="LINUX_ONLY_TEXTMODE">This feature is currently supported only in text mode.</entry>
<entry lang="en" key="LINUX_FREE_SPACE_ON_DRIVE">Free space on drive {0}: is {1}.</entry>
<entry lang="en" key="LINUX_DYNAMIC_NOTICE">Please note that if your operating system does not allocate files from the beginning of the free space, the maximum possible hidden volume size may be much smaller than the size of the free space on the outer volume. This is not a bug in VeraCrypt but a limitation of the operating system.</entry>
<entry lang="en" key="LINUX_MAX_HIDDEN_SIZE">Maximum possible hidden volume size for this volume is {0}.</entry>
<entry lang="en" key="LINUX_OPEN_OUTER_VOL">Open Outer Volume</entry>
- <entry lang="en" key="LINUX_OUTER_VOL_IS_MOUNTED">Outer volume has been successfully created and mounted as '{0}'. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not dismount the volume.\n\nNote: After you click Next, the outer volume will be analyzed to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. The procedure ensures no data on the outer volume are overwritten by the hidden volume.</entry>
+ <entry lang="en" key="LINUX_OUTER_VOL_IS_MOUNTED">Outer volume has been successfully created and mounted as '{0}'. To this volume you should now copy some sensitive-looking files that you actually do NOT want to hide. The files will be there for anyone forcing you to disclose your password. You will reveal only the password for this outer volume, not for the hidden one. The files that you really care about will be stored in the hidden volume, which will be created later on. When you finish copying, click Next. Do not unmount the volume.\n\nNote: After you click Next, the outer volume will be analyzed to determine the size of uninterrupted area of free space whose end is aligned with the end of the volume. This area will accommodate the hidden volume, so it will limit its maximum possible size. The procedure ensures no data on the outer volume are overwritten by the hidden volume.</entry>
<entry lang="en" key="LINUX_ERROR_TRY_ENCRYPT_SYSTEM_DRIVE">Error: You are trying to encrypt a system drive.\n\nVeraCrypt can encrypt a system drive only under Windows.</entry>
<entry lang="en" key="LINUX_ERROR_TRY_ENCRYPT_SYSTEM_PARTITION">Error: You are trying to encrypt a system partition.\n\nVeraCrypt can encrypt system partitions only under Windows.</entry>
<entry lang="en" key="LINUX_WARNING_FORMAT_DESTROY_FS">WARNING: Formatting of the device will destroy all data on filesystem '{0}'.\n\nDo you want to continue?</entry>
- <entry lang="en" key="LINUX_MOUNTET_HINT">The filesystem of the selected device is currently mounted. Please dismount '{0}' before proceeding.</entry>
+ <entry lang="en" key="LINUX_MOUNTET_HINT">The filesystem of the selected device is currently mounted. Please unmount '{0}' before proceeding.</entry>
<entry lang="en" key="LINUX_HIDDEN_PASS_NO_DIFF">The Hidden volume can't have the same password, PIM and keyfiles as the Outer volume</entry>
<entry lang="en" key="LINUX_NOT_FAT_HINT">Please note that the volume will not be formatted with a FAT filesystem and, therefore, you may be required to install additional filesystem drivers on platforms other than {0}, which will enable you to mount the volume.</entry>
<entry lang="en" key="LINUX_ERROR_SIZE_HIDDEN_VOL">Error: The hidden volume to be created is larger than {0} TB ({1} GB).\n\nPossible solutions:\n- Create a container/partition smaller than {0} TB.\n</entry>
<entry lang="en" key="LINUX_MAX_SIZE_HINT">- Use a drive with 4096-byte sectors to be able to create partition/device-hosted hidden volumes up to 16 TB in size</entry>
<entry lang="en" key="LINUX_DOT_LF">.\n</entry>
<entry lang="en" key="LINUX_NOT_SUPPORTED"> (not supported by components available on this platform).\n</entry>
<entry lang="en" key="LINUX_KERNEL_OLD">Your system uses an old version of the Linux kernel.\n\nDue to a bug in the Linux kernel, your system may stop responding when writing data to a VeraCrypt volume. This problem can be solved by upgrading the kernel to version 2.6.24 or later.</entry>
- <entry lang="en" key="LINUX_VOL_DISMOUNTED">Volume {0} has been dismounted.</entry>
+ <entry lang="en" key="LINUX_VOL_UNMOUNTED">Volume {0} has been unmounted.</entry>
<entry lang="en" key="LINUX_VOL_MOUNTED">Volume {0} has been mounted.</entry>
<entry lang="en" key="LINUX_OOM">Out of memory.</entry>
<entry lang="en" key="LINUX_CANT_GET_ADMIN_PRIV">Failed to obtain administrator privileges</entry>
<entry lang="en" key="LINUX_COMMAND_GET_ERROR">Command {0} returned error {1}.</entry>
<entry lang="en" key="LINUX_CMD_HELP">VeraCrypt Command Line Help</entry>
@@ -1615,14 +1615,14 @@
<entry lang="en" key="SCARD_MODULE_INIT_FAILED">Error when loading the WinSCard / PCSC library.</entry>
<entry lang="en" key="EMV_UNKNOWN_CARD_TYPE">The card in the reader is not a supported EMV card.</entry>
<entry lang="en" key="EMV_SELECT_AID_FAILED">The AID of the card in the reader could not be selected.</entry>
<entry lang="en" key="EMV_ICC_CERT_NOTFOUND">ICC Public Key Certificate was not found in the card.</entry>
<entry lang="en" key="EMV_ISSUER_CERT_NOTFOUND">Issuer Public Key Certificate was not found in the card.</entry>
- <entry lang="en" key="EMV_CPLC_NOTFOUND">CLPC was not found in the EMV card.</entry>
+ <entry lang="en" key="EMV_CPLC_NOTFOUND">CPLC was not found in the EMV card.</entry>
<entry lang="en" key="EMV_PAN_NOTFOUND">No Primary Account Number (PAN) found in the EMV card.</entry>
<entry lang="en" key="INVALID_EMV_PATH">EMV path is invalid.</entry>
- <entry lang="en" key="EMV_KEYFILE_DATA_NOTFOUND">Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPCL data.</entry>
+ <entry lang="en" key="EMV_KEYFILE_DATA_NOTFOUND">Unable to build a keyfile from the EMV card's data.\n\nOne of the following is missing:\n- ICC Public Key Certificate.\n- Issuer Public Key Certificate.\n- CPLC data.</entry>
<entry lang="en" key="SCARD_W_REMOVED_CARD">No card in the reader.\n\nPlease make sure the card is correctly slotted.</entry>
<entry lang="en" key="FORMAT_EXTERNAL_FAILED">Windows format.com command failed to format the volume as NTFS/exFAT/ReFS: Error 0x%.8X.\n\nFalling back to using Windows FormatEx API.</entry>
<entry lang="en" key="FORMATEX_API_FAILED">Windows FormatEx API failed to format the volume as NTFS/exFAT/ReFS.\n\nFailure status = %s.</entry>
<entry lang="en" key="EXPANDER_WRITING_RANDOM_DATA">Writing random data to new space ...\n</entry>
<entry lang="en" key="EXPANDER_WRITING_ENCRYPTED_BACKUP">Writing re-encrypted backup header ...\n</entry>
@@ -1633,10 +1633,19 @@
<entry lang="en" key="EXPANDER_EXTENDING_FILESYSTEM">Extending file system ...\n</entry>
<entry lang="en" key="PARTIAL_SYSENC_MOUNT_READONLY">Warning: The system partition you attempted to mount was not fully encrypted. As a safety measure to prevent potential corruption or unwanted modifications, volume '%s' was mounted as read-only.</entry>
<entry lang="en" key="IDC_LINK_KEYFILES_EXTENSIONS_WARNING">Important information on using third-party file extensions</entry>
<entry lang="en" key="IDC_DISABLE_MEMORY_PROTECTION">Disable memory protection for Accessibility tools compatibility</entry>
<entry lang="en" key="DISABLE_MEMORY_PROTECTION_WARNING">WARNING: Disabling memory protection significantly reduces security. Enable this option ONLY if you rely on Accessibility tools, like Screen Readers, to interact with VeraCrypt's UI.</entry>
+ <entry lang="en" key="LINUX_LANGUAGE">Language</entry>
+ <entry lang="en" key="LINUX_SELECT_SYS_DEFAULT_LANG">Select system's default language</entry>
+ <entry lang="en" key="LINUX_RESTART_FOR_LANGUAGE_CHANGE">For the language change to come into effect, VeraCrypt needs to be restarted.</entry>
+ <entry lang="en" key="ERR_XTS_MASTERKEY_VULNERABLE">WARNING: The volume's master key is vulnerable to an attack that compromises data security.\n\nPlease create a new volume and transfer the data to it.</entry>
+ <entry lang="en" key="ERR_SYSENC_XTS_MASTERKEY_VULNERABLE">WARNING: The encrypted system's master key is vulnerable to an attack that compromises data security.\nPlease decrypt the system partition/drive and then re-encrypt it.</entry>
+ <entry lang="en" key="ERR_XTS_MASTERKEY_VULNERABLE_SHORT">WARNING: The volume's master key has a security vulnerability.</entry>
+ <entry lang="en" key="MOUNTPOINT_BLOCKED">ERROR: The volume mount point is blocked because it overrides a protected system directory.\n\nPlease choose a different mount point.</entry>
+ <entry lang="en" key="MOUNTPOINT_NOTALLOWED">ERROR: The volume mount point is not allowed because it overrides a directory that is part of the PATH environment variable.\n\nPlease choose a different mount point.</entry>
+ <entry lang="en" key="INSECURE_MODE">[INSECURE MODE]</entry>
</localization>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="VeraCrypt">
<xs:complexType>
<xs:sequence>
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,16 +1,24 @@
<?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">
@@ -50,67 +58,101 @@
</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>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">
<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|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">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>$(Configuration)\</OutDir>
+ <OutDir>$(ProjectDir)$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)$(Configuration)\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>
<PrecompiledHeader>
</PrecompiledHeader>
@@ -136,20 +178,35 @@
<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>
@@ -164,10 +221,30 @@
<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>
diff --git a/src/Common/Lzma_vs2019.vcxproj b/src/Common/Lzma_vs2019.vcxproj
deleted file mode 100644
index 81a57daa..00000000
--- a/src/Common/Lzma_vs2019.vcxproj
+++ /dev/null
@@ -1,247 +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>
- </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>$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </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>
- </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>
- </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>
- </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 ae6b8035..ed662a88 100644
--- a/src/Common/Password.c
+++ b/src/Common/Password.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -171,11 +171,11 @@ BOOL CheckPasswordLength (HWND hwndDlg, unsigned __int32 passwordLength, int pim
int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5, int old_pim, Password *newPassword, int pkcs5, int pim, int wipePassCount, HWND hwndDlg)
{
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;
DWORD bytesRead;
BOOL bDevice;
@@ -369,10 +369,14 @@ int ChangePwd (const wchar_t *lpszVolume, Password *oldPassword, int old_pkcs5,
nStatus = ReadVolumeHeader (FALSE, buffer, oldPassword, old_pkcs5, old_pim, &cryptoInfo, NULL);
if (nStatus == ERR_CIPHER_INIT_WEAK_KEY)
nStatus = 0; // We can ignore this error here
+ // if the XTS master key is vulnerable, return error and do not allow the user to change the password since the master key will not be changed
+ if ((nStatus == 0) && cryptoInfo->bVulnerableMasterKey)
+ nStatus = ERR_XTS_MASTERKEY_VULNERABLE;
+
if (nStatus == ERR_PASSWORD_WRONG)
{
continue; // Try next volume type
}
else if (nStatus != 0)
diff --git a/src/Common/Password.h b/src/Common/Password.h
index dd3fbed6..9f2f0145 100644
--- a/src/Common/Password.h
+++ b/src/Common/Password.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef PASSWORD_H
diff --git a/src/Common/Pkcs5.c b/src/Common/Pkcs5.c
index d81078e8..fbe22275 100644
--- a/src/Common/Pkcs5.c
+++ b/src/Common/Pkcs5.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -41,75 +41,69 @@
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 */
)
{
sha256_ctx* ctx = &(hmac->ctx);
/**** Restore Precomputed Inner Digest Context ****/
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. */
if (lk > SHA256_BLOCKSIZE)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -120,47 +114,43 @@ void hmac_sha256
ctx = &(hmac.inner_digest_ctx);
sha256_begin (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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 */
burn(&hmac, sizeof(hmac));
burn(key, sizeof(key));
}
#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;
#ifdef TC_WINDOWS_BOOT
/* In bootloader mode, least significant bit of iterations is a boolean (TRUE for boot derivation mode, FALSE otherwise)
@@ -182,11 +172,11 @@ static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b,
/* big-endian block number */
#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);
#endif
@@ -204,39 +194,33 @@ static void derive_u_sha256 (char *salt, int salt_len, uint32 iterations, int b,
c--;
}
}
-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. */
if (pwd_len > SHA256_BLOCKSIZE)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -259,25 +243,25 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
ctx = &(hmac.inner_digest_ctx);
sha256_begin (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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++)
{
derive_u_sha256 (salt, salt_len, iterations, b, &hmac);
@@ -287,17 +271,13 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
/* last block */
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. */
burn (&hmac, sizeof(hmac));
#ifndef TC_WINDOWS_BOOT
@@ -312,75 +292,69 @@ void derive_key_sha256 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
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
)
{
sha512_ctx* ctx = &(hmac->ctx);
/**** Restore Precomputed Inner Digest Context ****/
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,
let key = sha512(key), as per HMAC specifications. */
if (lk > SHA512_BLOCKSIZE)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -391,46 +365,42 @@ void hmac_sha512
ctx = &(hmac.inner_digest_ctx);
sha512_begin (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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 */
burn (&hmac, sizeof(hmac));
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 */
memcpy (k, salt, salt_len); /* salt */
/* big-endian block number */
@@ -450,39 +420,33 @@ 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,
let pwd = sha512(pwd), as per HMAC specifications. */
if (pwd_len > SHA512_BLOCKSIZE)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -504,25 +468,25 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
ctx = &(hmac.inner_digest_ctx);
sha512_begin (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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++)
{
derive_u_sha512 (salt, salt_len, iterations, b, &hmac);
@@ -532,17 +496,13 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
/* last block */
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. */
burn (&hmac, sizeof(hmac));
burn (key, sizeof(key));
@@ -555,17 +515,17 @@ void derive_key_sha512 (char *pwd, int pwd_len, char *salt, int salt_len, uint32
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 */
)
{
blake2s_state* ctx = &(hmac->ctx);
@@ -574,56 +534,50 @@ void hmac_blake2s_internal
memcpy (ctx, &(hmac->inner_digest_ctx), sizeof (blake2s_state));
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 ****/
memcpy (ctx, &(hmac->outer_digest_ctx), sizeof (blake2s_state));
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. */
if (lk > BLAKE2S_BLOCKSIZE)
{
blake2s_state tctx;
blake2s_init (&tctx);
blake2s_update (&tctx, k, lk);
- blake2s_final (&tctx, (unsigned char *) key);
+ blake2s_final (&tctx, key);
k = key;
lk = BLAKE2S_DIGESTSIZE;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -634,47 +588,43 @@ void hmac_blake2s
ctx = &(hmac.inner_digest_ctx);
blake2s_init (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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 */
burn(&hmac, sizeof(hmac));
burn(key, sizeof(key));
}
#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;
#ifdef TC_WINDOWS_BOOT
/* In bootloader mode, least significant bit of iterations is a boolean (TRUE for boot derivation mode, FALSE otherwise)
@@ -696,11 +646,11 @@ static void derive_u_blake2s (char *salt, int salt_len, uint32 iterations, int b
/* big-endian block number */
#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);
#endif
@@ -718,39 +668,33 @@ static void derive_u_blake2s (char *salt, int salt_len, uint32 iterations, int b
c--;
}
}
-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. */
if (pwd_len > BLAKE2S_BLOCKSIZE)
{
blake2s_state tctx;
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -773,22 +717,22 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3
ctx = &(hmac.inner_digest_ctx);
blake2s_init (ctx);
/* 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);
/**** Precompute HMAC Outer Digest ****/
ctx = &(hmac.outer_digest_ctx);
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);
/* first l - 1 blocks */
@@ -801,17 +745,13 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3
/* last block */
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. */
burn (&hmac, sizeof(hmac));
#ifndef TC_WINDOWS_BOOT
@@ -826,68 +766,62 @@ void derive_key_blake2s (char *pwd, int pwd_len, char *salt, int salt_len, uint3
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 */
)
{
WHIRLPOOL_CTX* ctx = &(hmac->ctx);
/**** Restore Precomputed Inner Digest Context ****/
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)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -898,40 +832,36 @@ void hmac_whirlpool
ctx = &(hmac.inner_digest_ctx);
WHIRLPOOL_init (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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 */
memcpy (k, salt, salt_len); /* salt */
/* big-endian block number */
@@ -950,32 +880,26 @@ static void derive_u_whirlpool (char *salt, int salt_len, uint32 iterations, int
u[i] ^= k[i];
}
}
}
-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)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -997,25 +921,25 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin
ctx = &(hmac.inner_digest_ctx);
WHIRLPOOL_init (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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++)
{
derive_u_whirlpool (salt, salt_len, iterations, b, &hmac);
@@ -1025,15 +949,10 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin
/* last block */
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));
}
@@ -1041,68 +960,62 @@ void derive_key_whirlpool (char *pwd, int pwd_len, char *salt, int salt_len, uin
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 */
)
{
STREEBOG_CTX* ctx = &(hmac->ctx);
/**** Restore Precomputed Inner Digest Context ****/
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)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -1113,40 +1026,36 @@ void hmac_streebog
ctx = &(hmac.inner_digest_ctx);
STREEBOG_init (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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 */
memcpy (k, salt, salt_len); /* salt */
/* big-endian block number */
@@ -1165,32 +1074,26 @@ static void derive_u_streebog (char *salt, int salt_len, uint32 iterations, int
u[i] ^= k[i];
}
}
}
-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)
{
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;
burn (&tctx, sizeof(tctx)); // Prevent leaks
@@ -1212,25 +1115,25 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint
ctx = &(hmac.inner_digest_ctx);
STREEBOG_init (ctx);
/* 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 ****/
ctx = &(hmac.outer_digest_ctx);
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++)
{
derive_u_streebog (salt, salt_len, iterations, b, &hmac);
@@ -1240,15 +1143,10 @@ void derive_key_streebog (char *pwd, int pwd_len, char *salt, int salt_len, uint
/* last block */
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));
}
@@ -1276,57 +1174,53 @@ 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)
{
if (pkcs5_prf_id == 0) // auto-detection always supported
diff --git a/src/Common/Pkcs5.h b/src/Common/Pkcs5.h
index a9abeec5..41679fe7 100644
--- a/src/Common/Pkcs5.h
+++ b/src/Common/Pkcs5.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_PKCS5
@@ -19,28 +19,28 @@
#if defined(__cplusplus)
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);
/* check if given PRF supported.*/
diff --git a/src/Common/Progress.c b/src/Common/Progress.c
index 2619b173..2abf782c 100644
--- a/src/Common/Progress.c
+++ b/src/Common/Progress.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -34,13 +34,13 @@ static wchar_t *seconds, *minutes, *hours, *days;
// If bIOThroughput is TRUE, the speed reflects the amount of data read AND written per second (rather than
// 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;
bShowStatus = bDisplayStatus;
bPercentMode = bShowPercent;
@@ -64,11 +64,11 @@ BOOL UpdateProgressBar (__int64 byteOffset)
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;
uint64 bytesDone = (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset);
uint64 bytesPerSec = (bProgressBarReverse ? (resumedPointBytesDone - byteOffset) : (bytesDone - resumedPointBytesDone)) / (elapsed + 1);
@@ -124,11 +124,11 @@ BOOL UpdateProgressBarProc (__int64 byteOffset)
SetWindowTextW (GetDlgItem (hCurPage, IDC_TIMEREMAIN), text);
}
prevTime = time;
- SendMessage (hProgressBar, PBM_SETPOS,
+ SendMessage (hCurProgressBar, PBM_SETPOS,
(int) (10000.0 * (bProgressBarReverse ? (TotalSize - byteOffset) : byteOffset) / (TotalSize == 0 ? 1 : TotalSize)),
0);
return bVolTransformThreadCancel;
}
diff --git a/src/Common/Progress.h b/src/Common/Progress.h
index d86e51ac..6642bb35 100644
--- a/src/Common/Progress.h
+++ b/src/Common/Progress.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifdef __cplusplus
diff --git a/src/Common/Random.c b/src/Common/Random.c
index fd836c7f..4c6382b4 100644
--- a/src/Common/Random.c
+++ b/src/Common/Random.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -17,10 +17,11 @@
#include "Dlgcode.h"
#include "Crypto\cpu.h"
#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;
static BOOL bRandDidInit = FALSE;
static int nRandIndex = 0, randPoolReadIndex = 0;
@@ -40,15 +41,11 @@ 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)
{
RandaddByte(x);
RandaddByte((x >> 8));
@@ -87,20 +84,21 @@ BOOL volatile bThreadTerminate = FALSE; /* This variable is shared among thread'
/* Network library handle for the SlowPoll function */
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;
if(bRandDidInit)
{
@@ -141,18 +139,18 @@ int RandinitWithCheck ( int* pAlreadyInitialized)
{
handleWin32Error (0, SRC_POS);
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;
return 0;
@@ -197,16 +195,10 @@ void RandStop (BOOL freePool)
{
FreeLibrary (hNetAPI32);
hNetAPI32 = NULL;
}
- if (CryptoAPIAvailable)
- {
- CryptReleaseContext (hCryptProv, 0);
- CryptoAPIAvailable = FALSE;
- CryptoAPILastError = ERROR_SUCCESS;
- }
hMouse = NULL;
hKeyboard = NULL;
bThreadTerminate = FALSE;
DeleteCriticalSection (&critRandProt);
@@ -260,39 +252,42 @@ BOOL IsRandomPoolEnrichedByUser ()
BOOL Randmix ()
{
if (bRandmixEnabled)
{
unsigned char hashOutputBuffer [MAX_DIGESTSIZE];
- WHIRLPOOL_CTX wctx;
- blake2s_state bctx;
+ #ifndef WOLFCRYPT_BACKEND
+ WHIRLPOOL_CTX wctx;
+ blake2s_state bctx;
+ STREEBOG_CTX stctx;
+ #endif
sha512_ctx sctx;
sha256_ctx s256ctx;
- STREEBOG_CTX stctx;
int poolIndex, digestIndex, digestSize;
switch (HashFunction)
{
- case BLAKE2S:
- digestSize = BLAKE2S_DIGESTSIZE;
- break;
-
case SHA512:
digestSize = SHA512_DIGESTSIZE;
break;
case SHA256:
digestSize = SHA256_DIGESTSIZE;
break;
+ #ifndef WOLFCRYPT_BACKEND
+ case BLAKE2S:
+ digestSize = BLAKE2S_DIGESTSIZE;
+ break;
+
case WHIRLPOOL:
digestSize = WHIRLPOOL_DIGESTSIZE;
break;
case STREEBOG:
digestSize = STREEBOG_DIGESTSIZE;
break;
-
+ #endif
default:
TC_THROW_FATAL_EXCEPTION;
}
if (RNG_POOL_SIZE % digestSize)
@@ -301,16 +296,10 @@ BOOL Randmix ()
for (poolIndex = 0; poolIndex < RNG_POOL_SIZE; poolIndex += digestSize)
{
/* Compute the message digest of the entire pool using the selected hash function. */
switch (HashFunction)
{
- case BLAKE2S:
- blake2s_init(&bctx);
- blake2s_update(&bctx, pRandPool, RNG_POOL_SIZE);
- blake2s_final(&bctx, hashOutputBuffer);
- break;
-
case SHA512:
sha512_begin (&sctx);
sha512_hash (pRandPool, RNG_POOL_SIZE, &sctx);
sha512_end (hashOutputBuffer, &sctx);
break;
@@ -319,10 +308,17 @@ BOOL Randmix ()
sha256_begin (&s256ctx);
sha256_hash (pRandPool, RNG_POOL_SIZE, &s256ctx);
sha256_end (hashOutputBuffer, &s256ctx);
break;
+ #ifndef WOLFCRYPT_BACKEND
+ case BLAKE2S:
+ blake2s_init(&bctx);
+ blake2s_update(&bctx, pRandPool, RNG_POOL_SIZE);
+ blake2s_final(&bctx, hashOutputBuffer);
+ break;
+
case WHIRLPOOL:
WHIRLPOOL_init (&wctx);
WHIRLPOOL_add (pRandPool, RNG_POOL_SIZE, &wctx);
WHIRLPOOL_finalize (&wctx, hashOutputBuffer);
break;
@@ -330,11 +326,11 @@ BOOL Randmix ()
case STREEBOG:
STREEBOG_init (&stctx);
STREEBOG_add (&stctx, pRandPool, RNG_POOL_SIZE);
STREEBOG_finalize (&stctx, hashOutputBuffer);
break;
-
+ #endif
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
}
@@ -347,30 +343,31 @@ BOOL Randmix ()
/* Prevent leaks */
burn (hashOutputBuffer, MAX_DIGESTSIZE);
switch (HashFunction)
{
- case BLAKE2S:
- burn (&bctx, sizeof(bctx));
- break;
-
case SHA512:
burn (&sctx, sizeof(sctx));
break;
case SHA256:
burn (&s256ctx, sizeof(s256ctx));
break;
+ #ifndef WOLFCRYPT_BACKEND
+ case BLAKE2S:
+ burn (&bctx, sizeof(bctx));
+ break;
+
case WHIRLPOOL:
burn (&wctx, sizeof(wctx));
break;
case STREEBOG:
burn (&stctx, sizeof(sctx));
break;
-
+ #endif
default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
}
}
@@ -668,10 +665,11 @@ BOOL SlowPoll (void)
HANDLE hDevice;
LPBYTE lpBuffer;
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)
{
HKEY hKey;
@@ -776,22 +774,20 @@ BOOL SlowPoll (void)
RandaddBuf ((unsigned char *) &diskPerformance, dwSize);
}
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;
}
/* use JitterEntropy library to get good quality random bytes based on CPU timing jitter */
if (0 == jent_entropy_init ())
@@ -804,18 +800,20 @@ BOOL SlowPoll (void)
RandaddBuf (buffer, (int) rndLen);
jent_entropy_collector_free (ec);
}
}
+#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if present
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (buffer, sizeof (buffer)))
|| (HasRDRAND() && RDRAND_getBytes (buffer, sizeof (buffer)))
))
{
RandaddBuf (buffer, sizeof (buffer));
}
+#endif
burn(buffer, sizeof (buffer));
Randmix();
return TRUE;
@@ -831,10 +829,11 @@ BOOL FastPoll (void)
SIZE_T minimumWorkingSetSize, maximumWorkingSetSize;
LARGE_INTEGER performanceCount;
MEMORYSTATUSEX memoryStatus;
HANDLE handle;
POINT point;
+ NTSTATUS bStatus = 0;
/* Get various basic pieces of system information */
RandaddIntPtr (GetActiveWindow ()); /* Handle of active window */
RandaddIntPtr (GetCapture ()); /* Handle of window with mouse
capture */
@@ -921,33 +920,33 @@ BOOL FastPoll (void)
/* Millisecond accuracy at best... */
DWORD dwTicks = GetTickCount ();
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;
}
+#ifndef _M_ARM64
// use RDSEED or RDRAND from CPU as source of entropy if enabled
if ( IsCpuRngEnabled() &&
( (HasRDSEED() && RDSEED_getBytes (buffer, sizeof (buffer)))
|| (HasRDRAND() && RDRAND_getBytes (buffer, sizeof (buffer)))
))
{
RandaddBuf (buffer, sizeof (buffer));
}
+#endif
burn (buffer, sizeof(buffer));
/* Apply the pool mixing function */
Randmix();
diff --git a/src/Common/Random.h b/src/Common/Random.h
index 68758782..9d7e345a 100644
--- a/src/Common/Random.h
+++ b/src/Common/Random.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
diff --git a/src/Common/Registry.c b/src/Common/Registry.c
index b04bbf60..f5aa4053 100644
--- a/src/Common/Registry.c
+++ b/src/Common/Registry.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Registry.h b/src/Common/Registry.h
index ea449d3e..0e869281 100644
--- a/src/Common/Registry.h
+++ b/src/Common/Registry.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
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
@@ -71,18 +71,11 @@
#define IDR_EFI_DCSINT 567
#define IDR_EFI_DCSCFG 568
#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
#define IDC_PARALLELIZATION 5003
#define IDT_TOKEN_PASSWORD 5004
diff --git a/src/Common/ResponseAPDU.cpp b/src/Common/ResponseAPDU.cpp
index 8a7f069c..3fe3b6de 100644
--- a/src/Common/ResponseAPDU.cpp
+++ b/src/Common/ResponseAPDU.cpp
@@ -3,11 +3,11 @@
using namespace std;
namespace VeraCrypt
{
- uint16 BytesToUInt16(const vector<byte>& buff)
+ uint16 BytesToUInt16(const vector<uint8>& buff)
{
uint16 value = 0;
for (uint16 i = 0; i < buff.size(); i++)
{
value <<= 8;
@@ -15,11 +15,11 @@ namespace VeraCrypt
}
return value;
}
- void AppendData (vector<byte>& buffer, const byte* pbData, size_t cbData)
+ void AppendData (vector<uint8>& buffer, const uint8* pbData, size_t cbData)
{
size_t orgSize = buffer.size ();
buffer.resize (orgSize + cbData);
memcpy (buffer.data () + orgSize, pbData, cbData);
}
@@ -34,73 +34,73 @@ namespace VeraCrypt
ResponseAPDU::ResponseAPDU() : m_SW(0)
{
}
- ResponseAPDU::ResponseAPDU(const vector<byte>& data, uint16 SW)
+ ResponseAPDU::ResponseAPDU(const vector<uint8>& data, uint16 SW)
{
m_data = data;
m_SW = SW;
}
uint32 ResponseAPDU::getNr()
{
return (uint32)m_data.size();
}
- const vector<byte> ResponseAPDU::getData()
+ const vector<uint8> ResponseAPDU::getData()
{
return m_data;
}
- byte ResponseAPDU::getSW1()
+ uint8 ResponseAPDU::getSW1()
{
- return (byte)((0xFF00 & m_SW) >> 8);
+ return (uint8)((0xFF00 & m_SW) >> 8);
}
- byte ResponseAPDU::getSW2()
+ uint8 ResponseAPDU::getSW2()
{
- return (byte)(0x00FF & m_SW);
+ return (uint8)(0x00FF & m_SW);
}
uint16 ResponseAPDU::getSW()
{
return m_SW;
}
- const vector<byte> ResponseAPDU::getBytes()
+ const vector<uint8> ResponseAPDU::getBytes()
{
- vector<byte> apdu;
+ vector<uint8> apdu;
AppendData(apdu, m_data.data(), m_data.size());
- apdu.push_back((byte)getSW1());
- apdu.push_back((byte)getSW2());
+ apdu.push_back((uint8)getSW1());
+ apdu.push_back((uint8)getSW2());
return apdu;
}
- void ResponseAPDU::appendData(const vector<byte>& data)
+ void ResponseAPDU::appendData(const vector<uint8>& data)
{
appendData(data.data(), data.size());
}
- void ResponseAPDU::appendData(const byte* data, size_t dataLen)
+ void ResponseAPDU::appendData(const uint8* data, size_t dataLen)
{
AppendData(m_data, data, dataLen);
}
void ResponseAPDU::setSW(uint16 SW)
{
m_SW = SW;
}
- void ResponseAPDU::setBytes(const vector<byte>& bytes)
+ void ResponseAPDU::setBytes(const vector<uint8>& bytes)
{
clear();
if (bytes.size() >= 2)
{
- vector<byte> SWBytes;
+ vector<uint8> SWBytes;
m_data.resize(bytes.size() - 2);
SWBytes.resize(2);
memcpy(m_data.data(), bytes.data(), bytes.size() - 2);
memcpy(SWBytes.data(), bytes.data() + bytes.size() - 2, 2);
diff --git a/src/Common/ResponseAPDU.h b/src/Common/ResponseAPDU.h
index b9aa4adc..f279afca 100644
--- a/src/Common/ResponseAPDU.h
+++ b/src/Common/ResponseAPDU.h
@@ -7,38 +7,38 @@ namespace VeraCrypt
{
class ResponseAPDU
{
protected:
- vector<byte> m_data;
+ vector<uint8> m_data;
uint16 m_SW;
public:
void clear();
ResponseAPDU();
- ResponseAPDU(const vector<byte>& data, uint16 SW);
+ ResponseAPDU(const vector<uint8>& data, uint16 SW);
uint32 getNr();
- const vector<byte> getData();
+ const vector<uint8> getData();
- byte getSW1();
+ uint8 getSW1();
- byte getSW2();
+ uint8 getSW2();
uint16 getSW();
- const vector<byte> getBytes();
+ const vector<uint8> getBytes();
void setSW(uint16 SW);
- void setBytes(const vector<byte>& bytes);
+ void setBytes(const vector<uint8>& bytes);
- void appendData(const vector<byte>& data);
- void appendData(const byte* data, size_t dataLen);
+ void appendData(const vector<uint8>& data);
+ void appendData(const uint8* data, size_t dataLen);
};
};
#endif // TC_HEADER_Common_ResponseAPDU \ No newline at end of file
diff --git a/src/Common/SCard.cpp b/src/Common/SCard.cpp
index 9f8d1145..edd315f6 100644
--- a/src/Common/SCard.cpp
+++ b/src/Common/SCard.cpp
@@ -4,11 +4,11 @@ using namespace std;
namespace VeraCrypt
{
SCardManager SCard::manager;
- SCard::SCard() : m_reader(NULL)
+ SCard::SCard()
{
}
SCard::SCard(size_t slotId)
{
diff --git a/src/Common/SCardLoader.cpp b/src/Common/SCardLoader.cpp
index 16026e62..24486002 100644
--- a/src/Common/SCardLoader.cpp
+++ b/src/Common/SCardLoader.cpp
@@ -318,11 +318,11 @@ namespace VeraCrypt
throw ScardLibraryInitializationFailed();
return scardStatus(hCard, mszReaderNames, pcchReaderLen, pdwState, pdwProtocol, pbAtr, pcbAtrLen);
}
- LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders)
+ LONG SCardLoader::SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders)
{
Initialize();
if (!bInitialized)
throw ScardLibraryInitializationFailed();
@@ -397,6 +397,6 @@ namespace VeraCrypt
if (!bInitialized)
throw ScardLibraryInitializationFailed();
return scardSetAttrib(hCard, dwAttrId, pbAttr, cbAttrLen);
}
-} \ No newline at end of file
+}
diff --git a/src/Common/SCardLoader.h b/src/Common/SCardLoader.h
index b1ab114b..af0758ed 100644
--- a/src/Common/SCardLoader.h
+++ b/src/Common/SCardLoader.h
@@ -11,20 +11,17 @@
#undef BOOL
#include <PCSC/pcsclite.h>
#include <PCSC/winscard.h>
#include <PCSC/wintypes.h>
#include "reader.h"
-typedef LPSCARD_READERSTATE_A LPSCARD_READERSTATE;
-using VeraCrypt::byte;
#define BOOL int
#else
#undef BOOL
#include "pcsclite.h"
#include <winscard.h>
#include <wintypes.h>
#include <reader.h>
-using VeraCrypt::byte;
#define BOOL int
#endif
#endif
#ifndef TC_WINDOWS
@@ -46,11 +43,11 @@ namespace VeraCrypt
typedef LONG (SCARD_CALL_SPEC *SCardReconnectPtr)(SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol);
typedef LONG (SCARD_CALL_SPEC *SCardDisconnectPtr)(SCARDHANDLE hCard, DWORD dwDisposition);
typedef LONG (SCARD_CALL_SPEC *SCardBeginTransactionPtr)(SCARDHANDLE hCard);
typedef LONG (SCARD_CALL_SPEC *SCardEndTransactionPtr)(SCARDHANDLE hCard, DWORD dwDisposition);
typedef LONG (SCARD_CALL_SPEC *SCardStatusPtr)(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen);
- typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders);
+ typedef LONG (SCARD_CALL_SPEC *SCardGetStatusChangePtr)(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders);
typedef LONG (SCARD_CALL_SPEC *SCardControlPtr)(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned);
typedef LONG (SCARD_CALL_SPEC *SCardTransmitPtr)(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength);
typedef LONG (SCARD_CALL_SPEC *SCardListReaderGroupsPtr)(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups);
typedef LONG (SCARD_CALL_SPEC *SCardListReadersPtr)(SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders);
typedef LONG (SCARD_CALL_SPEC *SCardCancelPtr)(SCARDCONTEXT hContext);
@@ -109,17 +106,17 @@ namespace VeraCrypt
static LONG SCardReconnect(SCARDHANDLE hCard, DWORD dwShareMode, DWORD dwPreferredProtocols, DWORD dwInitialization, LPDWORD pdwActiveProtocol);
static LONG SCardDisconnect(SCARDHANDLE hCard, DWORD dwDisposition);
static LONG SCardBeginTransaction(SCARDHANDLE hCard);
static LONG SCardEndTransaction(SCARDHANDLE hCard, DWORD dwDisposition);
static LONG SCardStatus(SCARDHANDLE hCard, LPTSTR mszReaderNames, LPDWORD pcchReaderLen, LPDWORD pdwState, LPDWORD pdwProtocol, BYTE* pbAtr, LPDWORD pcbAtrLen);
- static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, LPSCARD_READERSTATE rgReaderStates, DWORD cReaders);
+ static LONG SCardGetStatusChange(SCARDCONTEXT hContext, DWORD dwTimeout, SCARD_READERSTATE* rgReaderStates, DWORD cReaders);
static LONG SCardControl(SCARDHANDLE hCard, DWORD dwControlCode, LPCVOID pbSendBuffer, DWORD cbSendLength, LPVOID pbRecvBuffer, DWORD cbRecvLength, LPDWORD lpBytesReturned);
static LONG SCardTransmit(SCARDHANDLE hCard, LPCSCARD_IO_REQUEST pioSendPci, const BYTE* pbSendBuffer, DWORD cbSendLength, LPSCARD_IO_REQUEST pioRecvPci, BYTE* pbRecvBuffer, LPDWORD pcbRecvLength);
static LONG SCardListReaderGroups(SCARDCONTEXT hContext, LPTSTR mszGroups, LPDWORD pcchGroups);
static LONG SCardListReaders(SCARDCONTEXT hContext, LPCTSTR mszGroups, LPTSTR mszReaders, LPDWORD pcchReaders);
static LONG SCardCancel(SCARDCONTEXT hContext);
static LONG SCardGetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, BYTE* pbAttr, LPDWORD pcbAttrLen);
static LONG SCardSetAttrib(SCARDHANDLE hCard, DWORD dwAttrId, const BYTE* pbAttr, DWORD cbAttrLen);
};
};
-#endif // TC_HEADER_Common_SCardLoader \ No newline at end of file
+#endif // TC_HEADER_Common_SCardLoader
diff --git a/src/Common/SCardReader.cpp b/src/Common/SCardReader.cpp
index 3a762415..6c5f654a 100644
--- a/src/Common/SCardReader.cpp
+++ b/src/Common/SCardReader.cpp
@@ -15,11 +15,11 @@ namespace VeraCrypt
m_scardLoader = scardLoader;
m_hSCReaderContext = m_scardLoader->GetSCardContext();
}
else
{
- m_scardLoader = NULL;
+ m_scardLoader.reset();
m_hSCReaderContext = 0;
}
m_hCard = hCard;
m_dwProtocol = dwProtocol;
m_pIO_Protocol = pIO_Protocol;
@@ -82,11 +82,11 @@ namespace VeraCrypt
}
void SCardReader::Clear(void)
{
m_szSCReaderName = L"";
- m_scardLoader = NULL;
+ m_scardLoader.reset();
m_hSCReaderContext = 0;
m_hCard = 0;
m_dwProtocol = 0;
m_pIO_Protocol = NULL;
}
@@ -115,11 +115,11 @@ namespace VeraCrypt
}
}
return name;
}
- bool SCardReader::IsCardPresent(vector<byte>& cardAtr)
+ bool SCardReader::IsCardPresent(vector<uint8>& cardAtr)
{
LONG lRet = SCARD_S_SUCCESS;
SCARD_READERSTATE state;
bool bIsCardPresent = false;
#ifdef TC_WINDOWS
@@ -163,11 +163,11 @@ namespace VeraCrypt
return bIsCardPresent;
}
bool SCardReader::IsCardPresent()
{
- vector<byte> dummy;
+ vector<uint8> dummy;
return IsCardPresent(dummy);
}
LONG SCardReader::CardHandleStatus()
{
@@ -396,12 +396,12 @@ namespace VeraCrypt
bool useExtendedAPDU = false;
size_t indexOfLe = 0;
size_t indexOfLcData = 0;
- vector<byte> pbSendBuffer;
- vector<byte> pbRecvBuffer;
+ vector<uint8> pbSendBuffer;
+ vector<uint8> pbRecvBuffer;
DWORD cbSendLength = 0;
DWORD cbRecvLength = 0;
responseAPDU.clear();
@@ -458,11 +458,11 @@ namespace VeraCrypt
{
// case 2s
// 256 is encoded as 0x00
pbSendBuffer[4] = (BYTE)ne;
indexOfLe = 4;
- cbSendLength = 4 + 1; // header || Le (1 byte)
+ cbSendLength = 4 + 1; // header || Le (1 uint8)
}
else
{
// case 2e
// 65536 is encoded as 0x00 0x00 0x00
@@ -492,11 +492,11 @@ namespace VeraCrypt
if (nc <= 255)
{
// case 3s
pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5;
- cbSendLength = 4 + 1 + nc; // header || Lc (1 byte) || Data
+ cbSendLength = 4 + 1 + nc; // header || Lc (1 uint8) || Data
memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
}
else
{
// case 3e
@@ -516,11 +516,11 @@ namespace VeraCrypt
if ((nc <= 255) && (ne <= 256))
{
// case 4s
pbSendBuffer[4] = (BYTE)nc;
indexOfLcData = 5;
- cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 byte) || Data || Le (1 byte)
+ cbSendLength = 4 + 1 + nc + 1; // header || Lc (1 uint8) || Data || Le (1 uint8)
memcpy(&pbSendBuffer[indexOfLcData], commandAPDU.getData().data(), nc);
pbSendBuffer[indexOfLcData + nc] = (ne != 256) ? (BYTE)ne : 0;
indexOfLe = indexOfLcData + nc;
}
else
@@ -644,13 +644,13 @@ namespace VeraCrypt
if (lRet != SCARD_S_SUCCESS)
throw PCSCException(lRet);
}
- void SCardReader::GetATRFromHandle(vector<byte>& atrValue)
+ void SCardReader::GetATRFromHandle(vector<uint8>& atrValue)
{
- vector<byte> pbATR;
+ vector<uint8> pbATR;
DWORD cByte = 0;
LONG lRet = 0;
atrValue.clear();
diff --git a/src/Common/SCardReader.h b/src/Common/SCardReader.h
index 95586963..8814bce0 100644
--- a/src/Common/SCardReader.h
+++ b/src/Common/SCardReader.h
@@ -49,76 +49,76 @@ namespace VeraCrypt
const uint16 SW_NO_ERROR = (uint16)0x9000;
/* ================================================================================================ */
/* CLA values */
/* ================================================================================================ */
- const byte CLA_ISO7816 = (byte)0x00;
- const byte CLA_COMMAND_CHAINING = (byte)0x10;
+ const uint8 CLA_ISO7816 = (uint8)0x00;
+ const uint8 CLA_COMMAND_CHAINING = (uint8)0x10;
/* ================================================================================================ */
/* INS values */
/* ================================================================================================ */
- const byte INS_ERASE_BINARY = 0x0E;
- const byte INS_VERIFY = 0x20;
- const byte INS_CHANGE_CHV = 0x24;
- const byte INS_UNBLOCK_CHV = 0x2C;
- const byte INS_DECREASE = 0x30;
- const byte INS_INCREASE = 0x32;
- const byte INS_DECREASE_STAMPED = 0x34;
- const byte INS_REHABILITATE_CHV = 0x44;
- const byte INS_MANAGE_CHANNEL = 0x70;
- const byte INS_EXTERNAL_AUTHENTICATE = (byte)0x82;
- const byte INS_MUTUAL_AUTHENTICATE = (byte)0x82;
- const byte INS_GET_CHALLENGE = (byte)0x84;
- const byte INS_ASK_RANDOM = (byte)0x84;
- const byte INS_GIVE_RANDOM = (byte)0x86;
- const byte INS_INTERNAL_AUTHENTICATE = (byte)0x88;
- const byte INS_SEEK = (byte)0xA2;
- const byte INS_SELECT = (byte)0xA4;
- const byte INS_SELECT_FILE = (byte)0xA4;
- const byte INS_CLOSE_APPLICATION = (byte)0xAC;
- const byte INS_READ_BINARY = (byte)0xB0;
- const byte INS_READ_BINARY2 = (byte)0xB1;
- const byte INS_READ_RECORD = (byte)0xB2;
- const byte INS_READ_RECORD2 = (byte)0xB3;
- const byte INS_READ_RECORDS = (byte)0xB2;
- const byte INS_READ_BINARY_STAMPED = (byte)0xB4;
- const byte INS_READ_RECORD_STAMPED = (byte)0xB6;
- const byte INS_GET_RESPONSE = (byte)0xC0;
- const byte INS_ENVELOPE = (byte)0xC2;
- const byte INS_GET_DATA = (byte)0xCA;
- const byte INS_WRITE_BINARY = (byte)0xD0;
- const byte INS_WRITE_RECORD = (byte)0xD2;
- const byte INS_UPDATE_BINARY = (byte)0xD6;
- const byte INS_LOAD_KEY_FILE = (byte)0xD8;
- const byte INS_PUT_DATA = (byte)0xDA;
- const byte INS_UPDATE_RECORD = (byte)0xDC;
- const byte INS_CREATE_FILE = (byte)0xE0;
- const byte INS_APPEND_RECORD = (byte)0xE2;
- const byte INS_DELETE_FILE = (byte)0xE4;
- const byte INS_PSO = (byte)0x2A;
- const byte INS_MSE = (byte)0x22;
+ const uint8 INS_ERASE_BINARY = 0x0E;
+ const uint8 INS_VERIFY = 0x20;
+ const uint8 INS_CHANGE_CHV = 0x24;
+ const uint8 INS_UNBLOCK_CHV = 0x2C;
+ const uint8 INS_DECREASE = 0x30;
+ const uint8 INS_INCREASE = 0x32;
+ const uint8 INS_DECREASE_STAMPED = 0x34;
+ const uint8 INS_REHABILITATE_CHV = 0x44;
+ const uint8 INS_MANAGE_CHANNEL = 0x70;
+ const uint8 INS_EXTERNAL_AUTHENTICATE = (uint8)0x82;
+ const uint8 INS_MUTUAL_AUTHENTICATE = (uint8)0x82;
+ const uint8 INS_GET_CHALLENGE = (uint8)0x84;
+ const uint8 INS_ASK_RANDOM = (uint8)0x84;
+ const uint8 INS_GIVE_RANDOM = (uint8)0x86;
+ const uint8 INS_INTERNAL_AUTHENTICATE = (uint8)0x88;
+ const uint8 INS_SEEK = (uint8)0xA2;
+ const uint8 INS_SELECT = (uint8)0xA4;
+ const uint8 INS_SELECT_FILE = (uint8)0xA4;
+ const uint8 INS_CLOSE_APPLICATION = (uint8)0xAC;
+ const uint8 INS_READ_BINARY = (uint8)0xB0;
+ const uint8 INS_READ_BINARY2 = (uint8)0xB1;
+ const uint8 INS_READ_RECORD = (uint8)0xB2;
+ const uint8 INS_READ_RECORD2 = (uint8)0xB3;
+ const uint8 INS_READ_RECORDS = (uint8)0xB2;
+ const uint8 INS_READ_BINARY_STAMPED = (uint8)0xB4;
+ const uint8 INS_READ_RECORD_STAMPED = (uint8)0xB6;
+ const uint8 INS_GET_RESPONSE = (uint8)0xC0;
+ const uint8 INS_ENVELOPE = (uint8)0xC2;
+ const uint8 INS_GET_DATA = (uint8)0xCA;
+ const uint8 INS_WRITE_BINARY = (uint8)0xD0;
+ const uint8 INS_WRITE_RECORD = (uint8)0xD2;
+ const uint8 INS_UPDATE_BINARY = (uint8)0xD6;
+ const uint8 INS_LOAD_KEY_FILE = (uint8)0xD8;
+ const uint8 INS_PUT_DATA = (uint8)0xDA;
+ const uint8 INS_UPDATE_RECORD = (uint8)0xDC;
+ const uint8 INS_CREATE_FILE = (uint8)0xE0;
+ const uint8 INS_APPEND_RECORD = (uint8)0xE2;
+ const uint8 INS_DELETE_FILE = (uint8)0xE4;
+ const uint8 INS_PSO = (uint8)0x2A;
+ const uint8 INS_MSE = (uint8)0x22;
/* ================================================================================================ */
/* EMV values */
/* ================================================================================================ */
const uint16 EMV_CPLC_TAG = (uint16)0x9F7F;
const uint16 EMV_ICC_PK_CERT_TAG = (uint16)0x9F46;
const uint16 EMV_FCI_ISSUER_DISCRETIONARY_DATA_TAG = (uint16)0xBF0C;
- const byte EMV_ISS_PK_CERT_TAG = (byte)0x90;
- const byte EMV_PAN_TAG = (byte)0x5A;
- const byte EMV_FCI_TAG = (byte)0x6F;
- const byte EMV_DFNAME_TAG = (byte)0x84;
- const byte EMV_FCI_ISSUER_TAG = (byte)0xA5;
- const byte EMV_DIRECTORY_ENTRY_TAG = (byte)0x61;
- const byte EMV_SFI_TAG = (byte)0x88;
- const byte EMV_TEMPLATE_TAG = (byte)0x70;
- const byte EMV_AID_TAG = (byte)0x4F;
- const byte EMV_LABEL_TAG = (byte)0x50;
- const byte EMV_PRIORITY_TAG = (byte)0x87;
- const byte EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact)
- const byte EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless)
+ const uint8 EMV_ISS_PK_CERT_TAG = (uint8)0x90;
+ const uint8 EMV_PAN_TAG = (uint8)0x5A;
+ const uint8 EMV_FCI_TAG = (uint8)0x6F;
+ const uint8 EMV_DFNAME_TAG = (uint8)0x84;
+ const uint8 EMV_FCI_ISSUER_TAG = (uint8)0xA5;
+ const uint8 EMV_DIRECTORY_ENTRY_TAG = (uint8)0x61;
+ const uint8 EMV_SFI_TAG = (uint8)0x88;
+ const uint8 EMV_TEMPLATE_TAG = (uint8)0x70;
+ const uint8 EMV_AID_TAG = (uint8)0x4F;
+ const uint8 EMV_LABEL_TAG = (uint8)0x50;
+ const uint8 EMV_PRIORITY_TAG = (uint8)0x87;
+ const uint8 EMV_PSE1[] = { 0x31, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "1PAY.SYS.DDF01" (contact)
+ const uint8 EMV_PSE2[] = { 0x32, 0x50, 0x41, 0x59, 0x2E, 0x53, 0x59, 0x53, 0x2E, 0x44, 0x44, 0x46, 0x30, 0x31 }; // "2PAY.SYS.DDF01" (contactless)
/* ================================================================================================ */
class SCardReader
{
@@ -171,11 +171,11 @@ namespace VeraCrypt
// ------------------------------------------------------------------------------------------------------------------------------------- //
// Card Connection management methods
// ------------------------------------------------------------------------------------------------------------------------------------- //
- bool IsCardPresent(vector<byte>& cardAtr);
+ bool IsCardPresent(vector<uint8>& cardAtr);
bool IsCardPresent();
LONG CardHandleStatus();
void Connect(DWORD dwProtocolToUse, bool& bHasBeenReset, bool resetAfterConnect = false);
@@ -191,10 +191,10 @@ namespace VeraCrypt
void BeginTransaction();
void EndTransaction();
void ApduProcessData(CommandAPDU commandAPDU, ResponseAPDU& responseAPDU) const;
- void GetATRFromHandle(vector<byte>& atrValue);
+ void GetATRFromHandle(vector<uint8>& atrValue);
};
};
#endif // TC_HEADER_Common_SCardReader \ No newline at end of file
diff --git a/src/Common/SecurityToken.cpp b/src/Common/SecurityToken.cpp
index ad8ed33e..85219395 100644
--- a/src/Common/SecurityToken.cpp
+++ b/src/Common/SecurityToken.cpp
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -121,11 +121,11 @@ namespace VeraCrypt
Pkcs11Functions->C_CloseSession(Sessions[slotId].Handle);
Sessions.erase(Sessions.find(slotId));
}
- void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name)
+ void SecurityToken::CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name)
{
if (name.empty())
throw ParameterIncorrect(SRC_POS);
LoginUserIfRequired(slotId);
@@ -165,14 +165,14 @@ namespace VeraCrypt
if (status != CKR_OK)
throw Pkcs11Exception(status);
// Some tokens report success even if the new object was truncated to fit in the available memory
- vector <byte> objectData;
+ vector <uint8> objectData;
GetObjectAttribute(slotId, keyfileHandle, CKA_VALUE, objectData);
- finally_do_arg(vector <byte> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); });
+ finally_do_arg(vector <uint8> *, &objectData, { if (!finally_arg->empty()) burn(&finally_arg->front(), finally_arg->size()); });
if (objectData.size() != keyfileData.size())
{
Pkcs11Functions->C_DestroyObject(Sessions[slotId].Handle, keyfileHandle);
throw Pkcs11Exception(CKR_DEVICE_MEMORY);
@@ -218,24 +218,24 @@ 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;
keyfile.Token->SlotId = slotId;
keyfile.Token = shared_ptr<SecurityTokenInfo>(new SecurityTokenInfo(token));
- vector <byte> privateAttrib;
+ vector <uint8> privateAttrib;
GetObjectAttribute(slotId, dataHandle, CKA_PRIVATE, privateAttrib);
if (privateAttrib.size() == sizeof(CK_BBOOL) && *(CK_BBOOL*)&privateAttrib.front() != CK_TRUE)
continue;
- vector <byte> label;
+ vector <uint8> label;
GetObjectAttribute(slotId, dataHandle, CKA_LABEL, label);
label.push_back(0);
keyfile.IdUtf8 = (char*)&label.front();
@@ -318,11 +318,11 @@ namespace VeraCrypt
token.Label = StringConverter::ToWide(token.LabelUtf8);
#endif
return token;
}
- void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const
+ void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const
{
SecurityToken::LoginUserIfRequired(Token->SlotId);
SecurityToken::GetObjectAttribute(Token->SlotId, Handle, CKA_VALUE, keyfileData);
}
@@ -346,11 +346,11 @@ namespace VeraCrypt
vector <CK_OBJECT_HANDLE> objects;
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);
if (objectCount != 1)
break;
@@ -359,11 +359,11 @@ namespace VeraCrypt
}
return objects;
}
- void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue)
+ void SecurityToken::GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue)
{
attributeValue.clear();
if (Sessions.find(slotId) == Sessions.end())
throw ParameterIncorrect(SRC_POS);
@@ -377,11 +377,11 @@ namespace VeraCrypt
throw Pkcs11Exception(status);
if (attribute.ulValueLen == 0)
return;
- attributeValue = vector <byte>(attribute.ulValueLen);
+ attributeValue = vector <uint8>(attribute.ulValueLen);
attribute.pValue = &attributeValue.front();
status = Pkcs11Functions->C_GetAttributeValue(Sessions[slotId].Handle, tokenObject, &attribute, 1);
if (status != CKR_OK)
throw Pkcs11Exception(status);
diff --git a/src/Common/SecurityToken.h b/src/Common/SecurityToken.h
index 4dff42fa..9f024b36 100644
--- a/src/Common/SecurityToken.h
+++ b/src/Common/SecurityToken.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -74,11 +74,11 @@ namespace VeraCrypt
virtual ~SecurityTokenKeyfile() {}
operator TokenKeyfilePath () const;
- void GetKeyfileData(vector<byte>& keyfileData) const;
+ void GetKeyfileData(vector<uint8>& keyfileData) const;
string IdUtf8;
CK_OBJECT_HANDLE Handle;
};
@@ -179,11 +179,11 @@ namespace VeraCrypt
class SecurityToken
{
public:
static void CloseAllSessions() throw ();
static void CloseLibrary();
- static void CreateKeyfile(CK_SLOT_ID slotId, vector <byte>& keyfileData, const string& name);
+ static void CreateKeyfile(CK_SLOT_ID slotId, vector <uint8>& keyfileData, const string& name);
static void DeleteKeyfile(const SecurityTokenKeyfile& keyfile);
static vector <SecurityTokenKeyfile> GetAvailableKeyfiles(CK_SLOT_ID* slotIdFilter = nullptr, const wstring keyfileIdFilter = wstring());
static list <SecurityTokenInfo> GetAvailableTokens();
static SecurityTokenInfo GetTokenInfo(CK_SLOT_ID slotId);
#ifdef TC_WINDOWS
@@ -197,11 +197,11 @@ namespace VeraCrypt
static const size_t MaxPasswordLength = 128;
protected:
static void CloseSession(CK_SLOT_ID slotId);
static vector <CK_OBJECT_HANDLE> GetObjects(CK_SLOT_ID slotId, CK_ATTRIBUTE_TYPE objectClass);
- static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <byte>& attributeValue);
+ static void GetObjectAttribute(CK_SLOT_ID slotId, CK_OBJECT_HANDLE tokenObject, CK_ATTRIBUTE_TYPE attributeType, vector <uint8>& attributeValue);
static list <CK_SLOT_ID> GetTokenSlots();
static void Login(CK_SLOT_ID slotId, const char* pin);
static void LoginUserIfRequired(CK_SLOT_ID slotId);
static void OpenSession(CK_SLOT_ID slotId);
static void CheckLibraryStatus();
@@ -215,10 +215,10 @@ namespace VeraCrypt
static void* Pkcs11LibraryHandle;
#endif
static map <CK_SLOT_ID, Pkcs11Session> Sessions;
static unique_ptr <SendExceptionFunctor> WarningCallback;
- friend void SecurityTokenKeyfile::GetKeyfileData(vector <byte>& keyfileData) const;
+ friend void SecurityTokenKeyfile::GetKeyfileData(vector <uint8>& keyfileData) const;
};
}
#endif // TC_HEADER_Common_SecurityToken
diff --git a/src/Common/TLVParser.cpp b/src/Common/TLVParser.cpp
index 9a177007..5ddf37e5 100644
--- a/src/Common/TLVParser.cpp
+++ b/src/Common/TLVParser.cpp
@@ -11,11 +11,11 @@ namespace VeraCrypt
shared_ptr<TLVNode> node = shared_ptr<TLVNode>(new TLVNode());
return node;
}
/* Check if the bit is correct */
- uint16 TLVParser::CheckBit(byte value, int bit)
+ uint16 TLVParser::CheckBit(uint8 value, int bit)
{
unsigned char bitvalue[8] = {0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80};
if ((bit >= 1) && (bit <= 8))
{
@@ -34,17 +34,17 @@ namespace VeraCrypt
//return(2);
}
}
/* Parsing one TLV node */
- shared_ptr<TLVNode> TLVParser::TLV_Parse_One(byte* buf, size_t size)
+ shared_ptr<TLVNode> TLVParser::TLV_Parse_One(uint8* buf, size_t size)
{
size_t index = 0;
size_t i = 0;
- byte tag1, tag2, tagsize;
- byte len, lensize;
- shared_ptr<vector<byte>> value = make_shared<vector<byte>>();
+ uint8 tag1, tag2, tagsize;
+ uint8 len, lensize;
+ shared_ptr<vector<uint8>> value = make_shared<vector<uint8>>();
shared_ptr<TLVNode> node = TLV_CreateNode();
tag1 = tag2 = 0;
tagsize = 1;
tag1 = buf[index++];
@@ -155,11 +155,11 @@ namespace VeraCrypt
}
}
}
/* Parsing TLV from a buffer and constructing TLV structure */
- shared_ptr<TLVNode> TLVParser::TLV_Parse(byte* buf, size_t size)
+ shared_ptr<TLVNode> TLVParser::TLV_Parse(uint8* buf, size_t size)
{
shared_ptr<TLVNode> node = TLV_Parse_One(buf, size);
TLV_Parse_Sub(node);
return node;
@@ -167,21 +167,21 @@ namespace VeraCrypt
/* Finding a TLV node with a particular tag */
shared_ptr<TLVNode> TLVParser::TLV_Find(shared_ptr<TLVNode> node, uint16 tag)
{
size_t i = 0;
- shared_ptr<TLVNode> tmpnode = NULL;
+ shared_ptr<TLVNode> tmpnode;
if (node->Tag == tag)
{
return node;
}
for (i = 0; i < node->Subs->size(); i++)
{
tmpnode = TLV_Find(node->Subs->at(i),tag);
- if (tmpnode != NULL)
+ if (tmpnode)
{
return tmpnode;
}
}
- return NULL;
+ return shared_ptr<TLVNode>();
}
-} \ No newline at end of file
+}
diff --git a/src/Common/TLVParser.h b/src/Common/TLVParser.h
index b989ca41..2fc4a27c 100644
--- a/src/Common/TLVParser.h
+++ b/src/Common/TLVParser.h
@@ -8,20 +8,20 @@ namespace VeraCrypt
{
struct TLVNode
{
uint16 Tag; /* T */
uint16 Length; /* L */
- shared_ptr<vector<byte>> Value; /* V */
- byte TagSize;
- byte LengthSize;
+ shared_ptr<vector<uint8>> Value; /* V */
+ uint8 TagSize;
+ uint8 LengthSize;
uint16 MoreFlag; /* Used In Sub */
uint16 SubFlag; /* Does it have sub-nodes? */
shared_ptr<vector<shared_ptr<TLVNode>>> Subs;
TLVNode() : Tag(0), Length(0), TagSize(0), LengthSize(0), MoreFlag(0), SubFlag(0)
{
- Value = make_shared<vector<byte>>();
+ Value = make_shared<vector<uint8>>();
Subs = make_shared<vector<shared_ptr<TLVNode>>>();
}
~TLVNode()
{
@@ -35,14 +35,14 @@ namespace VeraCrypt
/* TLV node structure creation */
static shared_ptr<TLVNode> TLV_CreateNode();
/* Check if the bit is correct */
- static uint16 CheckBit(byte value, int bit);
+ static uint16 CheckBit(uint8 value, int bit);
/* Parsing one TLV node */
- static shared_ptr<TLVNode> TLV_Parse_One(byte* buf, size_t size);
+ static shared_ptr<TLVNode> TLV_Parse_One(uint8* buf, size_t size);
/* Parsing all TLV nodes */
static int TLV_Parse_SubNodes(shared_ptr<TLVNode> parent);
/* Parsing all sub-nodes (in width not in depth) of a given parent node */
@@ -52,11 +52,11 @@ namespace VeraCrypt
static void TLV_Parse_Sub(shared_ptr<TLVNode> parent);
public:
/* Parsing TLV from a buffer and constructing TLV structure */
- static shared_ptr<TLVNode> TLV_Parse(byte* buf, size_t size);
+ static shared_ptr<TLVNode> TLV_Parse(uint8* buf, size_t size);
/* Finding a TLV node with a particular tag */
static shared_ptr<TLVNode> TLV_Find(shared_ptr<TLVNode> node, uint16 tag);
};
diff --git a/src/Common/Tcdefs.h b/src/Common/Tcdefs.h
index 1223340e..ee5751b7 100644
--- a/src/Common/Tcdefs.h
+++ b/src/Common/Tcdefs.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TCDEFS_H
@@ -57,11 +57,11 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
#endif
#define TC_APP_NAME "VeraCrypt"
// Version displayed to user
-#define VERSION_STRING "1.26.8"
+#define VERSION_STRING "1.26.20"
#ifdef VC_EFI_CUSTOM_MODE
#define VERSION_STRING_SUFFIX "-CustomEFI"
#elif defined(VC_SKIP_OS_DRIVER_REQ_CHECK)
#define VERSION_STRING_SUFFIX "-TESTSIGNING"
@@ -71,13 +71,13 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
// Version number to compare against driver
#define VERSION_NUM 0x0126
// Release date
-#define TC_STR_RELEASE_DATE L"October 7, 2023"
-#define TC_RELEASE_DATE_YEAR 2023
-#define TC_RELEASE_DATE_MONTH 10
+#define TC_STR_RELEASE_DATE L"February 3, 2025"
+#define TC_RELEASE_DATE_YEAR 2025
+#define TC_RELEASE_DATE_MONTH 2
#define BYTES_PER_KB 1024LL
#define BYTES_PER_MB 1048576LL
#define BYTES_PER_GB 1073741824LL
#define BYTES_PER_TB 1099511627776LL
@@ -93,11 +93,10 @@ extern unsigned short _rotl16(unsigned short value, unsigned char shift);
#ifdef _MSC_VER
typedef __int8 int8;
typedef __int16 int16;
typedef __int32 int32;
-typedef unsigned __int8 byte;
typedef unsigned __int8 uint8;
typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32;
#ifdef TC_NO_COMPILER_INT64
@@ -107,10 +106,16 @@ typedef unsigned __int64 TC_LARGEST_COMPILER_UINT;
typedef __int64 int64;
typedef unsigned __int64 uint64;
#define LL(x) x##ui64
#endif
+#if _MSC_VER > 1900
+#define VC_CDECL __cdecl // this is needed because Windows driver on VS2019 uses stdcall for build
+#else
+#define VC_CDECL
+#endif
+
#pragma warning( disable : 4201 ) // disable: 4201 nonstandard extension used : nameless struct/union
#pragma warning( disable : 4324 ) // disable: 4324 structure was padded due to __declspec(align())
#else // !_MSC_VER
@@ -120,11 +125,10 @@ typedef unsigned __int64 uint64;
typedef int8_t int8;
typedef int16_t int16;
typedef int32_t int32;
typedef int64_t int64;
-typedef uint8_t byte;
typedef uint8_t uint8;
typedef uint16_t uint16;
typedef uint32_t uint32;
typedef uint64_t uint64;
@@ -151,10 +155,12 @@ typedef uint64 TC_LARGEST_COMPILER_UINT;
#ifndef FALSE
#define FALSE 0
#define TRUE 1
#endif
+#define VC_CDECL
+
#endif // !_MSC_VER
#define TC_INT_TYPES_DEFINED
// Integer types required by Cryptolib
@@ -232,10 +238,13 @@ void ThrowFatalException(int line);
# define TC_THROW_FATAL_EXCEPTION ThrowFatalException (__LINE__)
#elif (defined(__clang__) && __has_builtin(__builtin_trap)) \
|| (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
#ifdef __COVERITY__
@@ -247,24 +256,14 @@ void ThrowFatalException(int line);
#include <ntifs.h>
#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 *) ExAllocatePoolUninitialized( NonPagedPoolNx , size, AllocTag ))
#define TCfree(memblock) ExFreePoolWithTag( memblock, AllocTag )
#define DEVICE_DRIVER
#ifndef BOOL
@@ -285,57 +284,10 @@ typedef unsigned char BOOLEAN;
#ifndef FALSE
#define FALSE !TRUE
#endif
-typedef NTSTATUS (NTAPI *KeSaveExtendedProcessorStateFn) (
- __in ULONG64 Mask,
- PXSTATE_SAVE XStateSave
- );
-
-
-typedef VOID (NTAPI *KeRestoreExtendedProcessorStateFn) (
- PXSTATE_SAVE XStateSave
- );
-
-typedef NTSTATUS (NTAPI *ExGetFirmwareEnvironmentVariableFn) (
- PUNICODE_STRING VariableName,
- LPGUID VendorGuid,
- PVOID Value,
- PULONG ValueLength,
- PULONG Attributes
-);
-
-typedef ULONG64 (NTAPI *KeQueryInterruptTimePreciseFn)(
- PULONG64 QpcTimeStamp
-);
-
-typedef BOOLEAN (NTAPI *KeAreAllApcsDisabledFn) ();
-
-typedef void (NTAPI *KeSetSystemGroupAffinityThreadFn)(
- PGROUP_AFFINITY Affinity,
- PGROUP_AFFINITY PreviousAffinity
-);
-
-typedef USHORT (NTAPI *KeQueryActiveGroupCountFn)();
-
-typedef ULONG (NTAPI *KeQueryActiveProcessorCountExFn)(
- USHORT GroupNumber
-);
-
-extern NTSTATUS NTAPI KeSaveExtendedProcessorStateVC (
- __in ULONG64 Mask,
- PXSTATE_SAVE XStateSave
- );
-
-
-extern VOID NTAPI KeRestoreExtendedProcessorStateVC (
- PXSTATE_SAVE XStateSave
- );
-
-extern BOOLEAN VC_KeAreAllApcsDisabled (VOID);
-
#else /* !TC_WINDOWS_DRIVER */
#if !defined(_UEFI)
#define TCalloc malloc
#define TCfree free
@@ -349,11 +301,17 @@ extern BOOLEAN VC_KeAreAllApcsDisabled (VOID);
#ifndef TC_LOCAL_WIN32_WINNT_OVERRIDE
# undef _WIN32_WINNT
#ifdef _M_ARM64
# define _WIN32_WINNT 0x0A00
#else
-# define _WIN32_WINNT 0x0601 /* Does not apply to the driver */
+// for Visual Studio 2015 and later, set minimum Windows version to Windows 8
+// for old versions of Visual Studio, set minimum Windows version to Windows 7
+#if _MSC_VER >= 1900
+# define _WIN32_WINNT 0x0602
+#else
+# define _WIN32_WINNT 0x0601
+#endif
#endif
#endif
#include <windows.h> /* Windows header */
#include <commctrl.h> /* The common controls */
@@ -494,9 +452,11 @@ enum
ERR_PARAMETER_INCORRECT = 30,
ERR_SYS_HIDVOL_HEAD_REENC_MODE_WRONG = 31,
ERR_NONSYS_INPLACE_ENC_INCOMPLETE = 32,
ERR_USER_ABORT = 33,
ERR_RAND_INIT_FAILED = 34,
- ERR_CAPI_INIT_FAILED = 35
+ ERR_CAPI_INIT_FAILED = 35,
+ ERR_XTS_MASTERKEY_VULNERABLE = 36,
+ ERR_SYSENC_XTS_MASTERKEY_VULNERABLE = 37
};
#endif // #ifndef TCDEFS_H
diff --git a/src/Common/Tests.c b/src/Common/Tests.c
index 4f53d4ed..89af24f1 100644
--- a/src/Common/Tests.c
+++ b/src/Common/Tests.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -309,10 +309,13 @@ AES_TEST aes_ecb_vectors[AES_TEST_COUNT] = {
0x00,0x11,0x22,0x33,0x44,0x55,0x66,0x77,0x88,0x99,0xaa,0xbb,0xcc,0xdd,0xee,0xff,
0x8e,0xa2,0xb7,0xca,0x51,0x67,0x45,0xbf,0xea,0xfc,0x49,0x90,0x4b,0x49,0x60,0x89
};
+
+#ifndef WOLFCRYPT_BACKEND
+
// Serpent ECB test vectors
#define SERPENT_TEST_COUNT 1
typedef struct {
@@ -417,10 +420,11 @@ KUZNYECHIK_TEST kuznyechik_vectors[KUZNYECHIK_TEST_COUNT] = {
0xD0, 0xB0, 0x9C, 0xCD, 0xE8, 0x30, 0xB9, 0xEB, 0x3A, 0x02, 0xC4, 0xC5,
0xAA, 0x8A, 0xDA, 0x98
}
};
+#endif
/* Test vectors from FIPS 198a, RFC 4231, RFC 2104, RFC 2202, and other sources. */
char *hmac_sha256_test_keys[] =
{
@@ -561,23 +565,17 @@ unsigned long HexStringToByteArray(const char* hexStr, unsigned char* pbData)
count++;
}
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);
outputLen = HexStringToByteArray (vector[i].hexOutput, output);
digestLen = fn (input, inputLen, digest);
@@ -587,15 +585,10 @@ BOOL RunHashTest (HashFunction fn, HashTestVector* vector, BOOL bUseSSE)
break;
}
i++;
}
-#if defined (DEVICE_DRIVER) && !defined (_WIN64)
- if (NT_SUCCESS (saveStatus))
- KeRestoreFloatingPointState (&floatingPointState);
-#endif
-
return bRet;
}
/* https://www.streebog.net/src/trunk/examples/ */
@@ -645,11 +638,11 @@ HashTestVector Blake2sTestVectors[] = {
{NULL, NULL}
};
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)
{
case AES:
@@ -730,14 +723,12 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
memcpy (key2, XTS_vectors[XTS_TEST_COUNT-1].key2, sizeof (XTS_vectors[XTS_TEST_COUNT-1].key2));
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++)
{
memcpy ((unsigned char *) buf + i * ENCRYPTION_DATA_UNIT_SIZE,
@@ -782,10 +773,11 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
return FALSE;
nTestsPerformed++;
break;
}
}
+ #ifndef WOLFCRYPT_BACKEND
else if (wcscmp (name, L"Serpent") == 0)
{
switch (testCase)
{
case 0:
@@ -1146,11 +1138,11 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
return FALSE;
nTestsPerformed++;
break;
}
}
-
+ #endif
if (crc == 0x9f5edd58)
return FALSE;
DecryptDataUnits (buf, &unitNo, nbrUnits, ci);
@@ -1198,10 +1190,11 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
{
if (crc != 0x33b91fab)
return FALSE;
nTestsPerformed++;
}
+ #ifndef WOLFCRYPT_BACKEND
else if (wcscmp (name, L"Serpent") == 0)
{
if (crc != 0x3494d480)
return FALSE;
nTestsPerformed++;
@@ -1282,11 +1275,11 @@ BOOL TestSectorBufEncryption (PCRYPTO_INFO ci)
{
if (crc != 0x755dad72)
return FALSE;
nTestsPerformed++;
}
-
+ #endif
if (crc == 0x9f5edd58)
return FALSE;
DecryptBuffer (buf, sizeof (buf), ci);
@@ -1299,11 +1292,11 @@ 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;
ci = crypto_open ();
@@ -1332,17 +1325,16 @@ static BOOL DoAutoTestAlgorithms (void)
if (i != AES_TEST_COUNT)
bFailed = TRUE;
// AES EncipherBlocks()/DecipherBlocks()
{
- byte testData[1024];
+ uint8 testData[1024];
uint32 origCrc;
- size_t i;
for (i = 0; i < sizeof (testData); ++i)
{
- testData[i] = (byte) i;
+ testData[i] = (uint8) i;
}
origCrc = GetCrc32 (testData, sizeof (testData));
CipherInit (AES, testData, ks_tmp);
@@ -1355,10 +1347,11 @@ static BOOL DoAutoTestAlgorithms (void)
if (origCrc != GetCrc32 (testData, sizeof (testData)))
bFailed = TRUE;
}
+ #ifndef WOLFCRYPT_BACKEND
/* Serpent */
for (i = 0; i < SERPENT_TEST_COUNT; i++)
{
int cipher = SERPENT;
@@ -1435,10 +1428,11 @@ static BOOL DoAutoTestAlgorithms (void)
if (memcmp(kuznyechik_vectors[i].plaintext, tmp, 16) != 0)
break;
}
if (i != KUZNYECHIK_TEST_COUNT)
bFailed = TRUE;
+ #endif
/* PKCS #5 and HMACs */
if (!test_pkcs5 ())
bFailed = TRUE;
@@ -1494,11 +1488,13 @@ BOOL AutoTestAlgorithms (void)
if (exceptionCatched)
{
/* unexepected exception raised. Disable all CPU extended feature and try again */
EnableHwEncryption (hwEncryptionEnabled);
+#ifndef _M_ARM64
DisableCPUExtendedFeatures ();
+#endif
__try
{
result = DoAutoTestAlgorithms();
}
__except (EXCEPTION_EXECUTE_HANDLER)
@@ -1516,16 +1512,16 @@ BOOL test_hmac_sha256 ()
unsigned int i;
int nTestsPerformed = 0;
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
nTestsPerformed++;
}
@@ -1543,16 +1539,16 @@ BOOL test_hmac_sha512 ()
unsigned int i;
int nTestsPerformed = 0;
for (i = 0; i < sizeof (hmac_sha512_test_data) / sizeof(char *); i++)
{
- char digest[1024]; /* large enough to hold digets and test vector inputs */
+ 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
nTestsPerformed++;
}
@@ -1563,23 +1559,24 @@ BOOL test_hmac_sha512 ()
}
return (nTestsPerformed == 6);
}
+#ifndef WOLFCRYPT_BACKEND
BOOL test_hmac_blake2s ()
{
unsigned int i;
int nTestsPerformed = 0;
for (i = 0; i < sizeof (hmac_blake2s_test_data) / sizeof(char *); i++)
{
- char digest[1024]; /* large enough to hold digets and test vector inputs */
+ 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
nTestsPerformed++;
}
@@ -1601,16 +1598,17 @@ int __cdecl Blake2sHash (unsigned char* input, unsigned long inputLen, unsigned
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;
return TRUE;
}
+#endif
/* http://www.tc26.ru/methods/recommendation/%D0%A2%D0%9A26%D0%90%D0%9B%D0%93.pdf */
/* https://tools.ietf.org/html/draft-smyshlyaev-gost-usage-00 */
/* https://datatracker.ietf.org/doc/rfc7836/?include_text=1 */
static const unsigned char gost3411_2012_hmac_k1[] = {
@@ -1631,16 +1629,17 @@ static const unsigned char gost3411_2012_hmac_r1[] = {
0x3A, 0xFE, 0x93, 0xB2, 0x81, 0x4F, 0x79, 0xF5, 0x00, 0x0F, 0xFC, 0x03,
0x66, 0xC2, 0x51, 0xE6
};
+#ifndef WOLFCRYPT_BACKEND
BOOL test_hmac_streebog ()
{
- CRYPTOPP_ALIGN_DATA(16) char digest[64]; /* large enough to hold digets and test vector inputs */
+ 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;
return TRUE;
}
@@ -1651,29 +1650,31 @@ int __cdecl StreebogHash (unsigned char* input, unsigned long inputLen, unsigned
STREEBOG_init (&ctx);
STREEBOG_add (&ctx, input, inputLen);
STREEBOG_finalize (&ctx, output);
return STREEBOG_DIGESTSIZE;
}
+#endif
BOOL test_pkcs5 ()
{
- char dk[144];
+ unsigned char dk[144];
/* HMAC-SHA-256 tests */
if (!test_hmac_sha256())
return FALSE;
/* HMAC-SHA-512 tests */
if (!test_hmac_sha512())
return FALSE;
+#ifndef WOLFCRYPT_BACKEND
/* HMAC-BLAKE2s tests */
if (test_hmac_blake2s() == FALSE)
return FALSE;
/* Blake2s hash tests */
- if (RunHashTest (Blake2sHash, Blake2sTestVectors, (HasSSE2())? TRUE : FALSE) == FALSE)
+ if (RunHashTest (Blake2sHash, Blake2sTestVectors) == FALSE)
return FALSE;
/* HMAC-Whirlpool tests */
if (test_hmac_whirlpool() == FALSE)
return FALSE;
@@ -1681,71 +1682,72 @@ BOOL test_pkcs5 ()
/* HMAC-STREEBOG tests */
if (test_hmac_streebog() == FALSE)
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
return TRUE;
}
diff --git a/src/Common/Tests.h b/src/Common/Tests.h
index 356d54f4..9b9d09e4 100644
--- a/src/Common/Tests.h
+++ b/src/Common/Tests.h
@@ -4,22 +4,22 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifdef __cplusplus
extern "C" {
#endif
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);
BOOL test_pkcs5 (void);
BOOL TestSectorBufEncryption ();
diff --git a/src/Common/Token.h b/src/Common/Token.h
index 754e2830..959c7e24 100644
--- a/src/Common/Token.h
+++ b/src/Common/Token.h
@@ -39,11 +39,11 @@ namespace VeraCrypt
struct TokenKeyfile
{
virtual ~TokenKeyfile() {}
virtual operator TokenKeyfilePath () const = 0;
- virtual void GetKeyfileData(vector <byte>& keyfileData) const = 0;
+ virtual void GetKeyfileData(vector <uint8>& keyfileData) const = 0;
shared_ptr<TokenInfo> Token;
wstring Id;
};
diff --git a/src/Common/Volumes.c b/src/Common/Volumes.c
index 5b1d4065..10f03636 100644
--- a/src/Common/Volumes.c
+++ b/src/Common/Volumes.c
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#include "Tcdefs.h"
@@ -128,23 +128,23 @@
// For CBC (deprecated/legacy), data used to generate IV and whitening values
// 288 224 Master key(s)
-uint16 GetHeaderField16 (byte *header, int offset)
+uint16 GetHeaderField16 (uint8 *header, int offset)
{
return BE16 (*(uint16 *) (header + offset));
}
-uint32 GetHeaderField32 (byte *header, int offset)
+uint32 GetHeaderField32 (uint8 *header, int offset)
{
return BE32 (*(uint32 *) (header + offset));
}
-UINT64_STRUCT GetHeaderField64 (byte *header, int offset)
+UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset)
{
UINT64_STRUCT uint64Struct;
#ifndef TC_NO_COMPILER_INT64
uint64Struct.Value = BE64 (*(uint64 *) (header + offset));
@@ -158,28 +158,28 @@ UINT64_STRUCT GetHeaderField64 (byte *header, int offset)
#ifndef TC_WINDOWS_BOOT
typedef struct
{
- char DerivedKey[MASTER_KEYDATA_SIZE];
+ unsigned char DerivedKey[MASTER_KEYDATA_SIZE];
BOOL Free;
LONG KeyReady;
int Pkcs5Prf;
} KeyDerivationWorkItem;
BOOL ReadVolumeHeaderRecoveryMode = FALSE;
-int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int selected_pkcs5_prf, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo)
+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;
int primaryKeyOffset;
int pkcs5PrfCount = LAST_PRF_ID - FIRST_PRF_ID + 1;
@@ -367,35 +367,38 @@ KeyReady: ;
pkcs5_prf = enqPkcs5Prf;
keyInfo->noIterations = get_pkcs5_iteration_count (enqPkcs5Prf, pim, bBoot);
switch (pkcs5_prf)
{
- case BLAKE2S:
- derive_key_blake2s (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
+ case SHA512:
+ derive_key_sha512 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize());
break;
- case SHA512:
- derive_key_sha512 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
+ case SHA256:
+ derive_key_sha256 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize());
break;
- case WHIRLPOOL:
- derive_key_whirlpool (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
+ #ifndef WOLFCRYPT_BACKEND
+ case BLAKE2S:
+ derive_key_blake2s (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize());
break;
- case SHA256:
- derive_key_sha256 (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
+ case WHIRLPOOL:
+ derive_key_whirlpool (keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize());
break;
- case STREEBOG:
+
+ case STREEBOG:
derive_key_streebog(keyInfo->userKey, keyInfo->keyLength, keyInfo->salt,
PKCS5_SALT_SIZE, keyInfo->noIterations, dk, GetMaxPkcs5OutSize());
break;
- default:
+ #endif
+ default:
// Unknown/wrong ID
TC_THROW_FATAL_EXCEPTION;
}
}
@@ -554,25 +557,15 @@ KeyReady: ;
// Master key data
memcpy (keyInfo->master_keydata, header + HEADER_MASTER_KEYDATA_OFFSET, MASTER_KEYDATA_SIZE);
#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);
#endif
// PKCS #5
@@ -592,10 +585,18 @@ KeyReady: ;
{
status = ERR_MODE_INIT_FAILED;
goto err;
}
+ // check that first half of keyInfo.master_keydata is different from the second half. If they are the same return error
+ if (memcmp (keyInfo->master_keydata, keyInfo->master_keydata + EAGetKeySize (cryptoInfo->ea), EAGetKeySize (cryptoInfo->ea)) == 0)
+ {
+ cryptoInfo->bVulnerableMasterKey = TRUE;
+ if (retHeaderCryptoInfo)
+ retHeaderCryptoInfo->bVulnerableMasterKey = TRUE;
+ }
+
status = ERR_SUCCESS;
goto ret;
}
}
}
@@ -635,11 +636,11 @@ ret:
}
return status;
}
#if defined(_WIN32) && !defined(_UEFI)
-void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint)
+void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint)
{
// compute Whirlpool+SHA512 fingerprint of bootloader including MBR
// we skip user configuration fields:
// TC_BOOT_SECTOR_PIM_VALUE_OFFSET = 400
// TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET = 402
@@ -648,11 +649,12 @@ void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderS
// => TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH = 24
// TC_BOOT_SECTOR_USER_CONFIG_OFFSET = 438
//
// we have: TC_BOOT_SECTOR_USER_MESSAGE_OFFSET = TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_OFFSET + TC_BOOT_SECTOR_OUTER_VOLUME_BAK_HEADER_CRC_SIZE
- WHIRLPOOL_CTX whirlpool;
+#ifndef WOLFCRYPT_BACKEND
+ WHIRLPOOL_CTX whirlpool;
sha512_ctx sha2;
WHIRLPOOL_init (&whirlpool);
sha512_begin (&sha2);
@@ -665,21 +667,41 @@ void ComputeBootloaderFingerprint (byte *bootLoaderBuf, unsigned int bootLoaderS
WHIRLPOOL_add (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &whirlpool);
sha512_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2);
WHIRLPOOL_finalize (&whirlpool, fingerprint);
sha512_end (&fingerprint [WHIRLPOOL_DIGESTSIZE], &sha2);
+#else
+ sha512_ctx sha2_512;
+ sha256_ctx sha2_256;
+
+ sha512_begin (&sha2_512);
+ sha256_begin (&sha2_256);
+
+ sha512_hash (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &sha2_512);
+ sha256_hash (bootLoaderBuf, TC_BOOT_SECTOR_PIM_VALUE_OFFSET, &sha2_256);
+
+ sha512_hash (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &sha2_512);
+ sha256_hash (bootLoaderBuf + TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH, (TC_BOOT_SECTOR_USER_CONFIG_OFFSET - (TC_BOOT_SECTOR_USER_MESSAGE_OFFSET + TC_BOOT_SECTOR_USER_MESSAGE_MAX_LENGTH)), &sha2_256);
+
+ sha512_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2_512);
+ sha256_hash (bootLoaderBuf + TC_SECTOR_SIZE_BIOS, (bootLoaderSize - TC_SECTOR_SIZE_BIOS), &sha2_256);
+
+ sha512_end (&fingerprint, &sha2_512);
+ sha256_end (&fingerprint [SHA512_DIGESTSIZE], &sha2_256);
+ sha256_end (&fingerprint [SHA512_DIGESTSIZE + SHA256_DIGESTSIZE], &sha2_256);
+#endif
}
#endif
#else // TC_WINDOWS_BOOT
-int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo)
+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;
int status = ERR_SUCCESS;
uint32 iterations = pim;
@@ -709,15 +731,15 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCR
// Test all available encryption algorithms
for (cryptoInfo->ea = EAGetFirst (); cryptoInfo->ea != 0; cryptoInfo->ea = EAGetNext (cryptoInfo->ea))
#endif
{
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
- #if defined (TC_WINDOWS_BOOT_SERPENT)
+ #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_set_key (dk, cryptoInfo->ks);
- #elif defined (TC_WINDOWS_BOOT_TWOFISH)
+ #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_set_key ((TwofishInstance *) cryptoInfo->ks, (const u4byte *) dk);
- #elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+ #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_set_key (dk, cryptoInfo->ks);
#else
status = EAInit (dk, cryptoInfo->ks);
if (status == ERR_CIPHER_INIT_FAILURE)
goto err;
@@ -727,15 +749,15 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCR
if (status == ERR_CIPHER_INIT_FAILURE)
goto err;
#endif
// Secondary key schedule
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
- #if defined (TC_WINDOWS_BOOT_SERPENT)
+ #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_set_key (dk + 32, cryptoInfo->ks2);
- #elif defined (TC_WINDOWS_BOOT_TWOFISH)
+ #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_set_key ((TwofishInstance *)cryptoInfo->ks2, (const u4byte *) (dk + 32));
- #elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+ #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_set_key (dk + 32, cryptoInfo->ks2);
#else
EAInit (dk + 32, cryptoInfo->ks2);
#endif
#else
@@ -788,15 +810,15 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCR
if (retHeaderCryptoInfo)
goto ret;
// Init the encryption algorithm with the decrypted master key
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
- #if defined (TC_WINDOWS_BOOT_SERPENT)
+ #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_set_key (dk, cryptoInfo->ks);
- #elif defined (TC_WINDOWS_BOOT_TWOFISH)
+ #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_set_key ((TwofishInstance *) cryptoInfo->ks, (const u4byte *) dk);
- #elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+ #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_set_key (dk, cryptoInfo->ks);
#else
status = EAInit (dk, cryptoInfo->ks);
if (status == ERR_CIPHER_INIT_FAILURE)
goto err;
@@ -807,15 +829,15 @@ int ReadVolumeHeader (BOOL bBoot, char *header, Password *password, int pim, PCR
goto err;
#endif
// The secondary master key (if cascade, multiple concatenated)
#ifdef TC_WINDOWS_BOOT_SINGLE_CIPHER_MODE
- #if defined (TC_WINDOWS_BOOT_SERPENT)
+ #if defined (TC_WINDOWS_BOOT_SERPENT) && !defined (WOLFCRYPT_BACKEND)
serpent_set_key (dk + 32, cryptoInfo->ks2);
- #elif defined (TC_WINDOWS_BOOT_TWOFISH)
+ #elif defined (TC_WINDOWS_BOOT_TWOFISH) && !defined (WOLFCRYPT_BACKEND)
twofish_set_key ((TwofishInstance *)cryptoInfo->ks2, (const u4byte *) (dk + 32));
- #elif defined (TC_WINDOWS_BOOT_CAMELLIA)
+ #elif defined (TC_WINDOWS_BOOT_CAMELLIA) && !defined (WOLFCRYPT_BACKEND)
camellia_set_key (dk + 32, cryptoInfo->ks2);
#else
EAInit (dk + 32, cryptoInfo->ks2);
#endif
#else
@@ -848,22 +870,22 @@ ret:
# include "Dlgcode.h"
#endif
// 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;
PCRYPTO_INFO cryptoInfo = crypto_open ();
static char dk[MASTER_KEYDATA_SIZE];
@@ -974,10 +996,11 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea,
case SHA256:
derive_key_sha256 (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt,
PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize());
break;
+ #ifndef WOLFCRYPT_BACKEND
case BLAKE2S:
derive_key_blake2s (keyInfo.userKey, keyInfo.keyLength, keyInfo.salt,
PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize());
break;
@@ -988,11 +1011,11 @@ int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *header, int ea,
case STREEBOG:
derive_key_streebog(keyInfo.userKey, keyInfo.keyLength, keyInfo.salt,
PKCS5_SALT_SIZE, keyInfo.noIterations, dk, GetMaxPkcs5OutSize());
break;
-
+ #endif
default:
// Unknown/wrong ID
crypto_close (cryptoInfo);
TC_THROW_FATAL_EXCEPTION;
}
@@ -1187,17 +1210,17 @@ err:
return 0;
}
#if !defined(_UEFI)
-BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead)
+BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header, DWORD *bytesRead)
{
#if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif
- byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
+ uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DISK_GEOMETRY geometry;
if (!device)
return ReadFile (fileHandle, header, TC_VOLUME_HEADER_EFFECTIVE_SIZE, bytesRead, NULL);
@@ -1220,17 +1243,17 @@ BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DW
return TRUE;
}
-BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
+BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, uint8 *header)
{
#if TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#error TC_VOLUME_HEADER_EFFECTIVE_SIZE > TC_MAX_VOLUME_SECTOR_SIZE
#endif
- byte sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
+ uint8 sectorBuffer[TC_MAX_VOLUME_SECTOR_SIZE];
DWORD bytesDone;
DISK_GEOMETRY geometry;
if (!device)
{
@@ -1295,11 +1318,11 @@ BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header)
int WriteRandomDataToReservedHeaderAreas (HWND hwndDlg, HANDLE dev, CRYPTO_INFO *cryptoInfo, uint64 dataAreaSize, BOOL bPrimaryOnly, BOOL bBackupOnly)
{
char temporaryKey[MASTER_KEYDATA_SIZE];
char originalK2[MASTER_KEYDATA_SIZE];
- byte buf[TC_VOLUME_HEADER_GROUP_SIZE];
+ uint8 buf[TC_VOLUME_HEADER_GROUP_SIZE];
LARGE_INTEGER offset;
int nStatus = ERR_SUCCESS;
DWORD dwError;
DWORD bytesDone;
diff --git a/src/Common/Volumes.h b/src/Common/Volumes.h
index 1c9981c2..98b2f8d6 100644
--- a/src/Common/Volumes.h
+++ b/src/Common/Volumes.h
@@ -4,11 +4,11 @@
Copyright (c) 2003-2012 TrueCrypt Developers Association and which is
governed by the TrueCrypt License 3.0, also from the source code of
Encryption for the Masses 2.02a, which is Copyright (c) 1998-2000 Paul Le Roux
and which is governed by the 'License Agreement for Encryption for the Masses'
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages. */
#ifndef TC_HEADER_Common_Volumes
@@ -127,30 +127,30 @@ extern "C" {
#include "Password.h"
extern BOOL ReadVolumeHeaderRecoveryMode;
-uint16 GetHeaderField16 (byte *header, int offset);
-uint32 GetHeaderField32 (byte *header, int offset);
-UINT64_STRUCT GetHeaderField64 (byte *header, int offset);
+uint16 GetHeaderField16 (uint8 *header, int offset);
+uint32 GetHeaderField32 (uint8 *header, int offset);
+UINT64_STRUCT GetHeaderField64 (uint8 *header, int offset);
#if defined(TC_WINDOWS_BOOT)
-int ReadVolumeHeader (BOOL bBoot, char *encryptedHeader, Password *password, int pim, PCRYPTO_INFO *retInfo, CRYPTO_INFO *retHeaderCryptoInfo);
+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 (byte *bootLoaderBuf, unsigned int bootLoaderSize, byte* fingerprint);
+void ComputeBootloaderFingerprint (uint8 *bootLoaderBuf, unsigned int bootLoaderSize, uint8* fingerprint);
#endif
#endif
#if !defined (DEVICE_DRIVER) && !defined (TC_WINDOWS_BOOT) && !defined(_UEFI)
-int CreateVolumeHeaderInMemory (HWND hwndDlg, BOOL bBoot, char *encryptedHeader, int ea, int mode, Password *password, int pkcs5_prf, int pim, char *masterKeydata, PCRYPTO_INFO *retInfo, unsigned __int64 volumeSize, unsigned __int64 hiddenVolumeSize, unsigned __int64 encryptedAreaStart, unsigned __int64 encryptedAreaLength, uint16 requiredProgramVersion, uint32 headerFlags, uint32 sectorSize, BOOL bWipeMode);
-BOOL ReadEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header, DWORD *bytesRead);
-BOOL WriteEffectiveVolumeHeader (BOOL device, HANDLE fileHandle, byte *header);
+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);
#endif
#endif // !TC_HEADER_Volume_VolumeHeader
diff --git a/src/Common/Wipe.c b/src/Common/Wipe.c
index 2fe6aa03..66d633b8 100644
--- a/src/Common/Wipe.c
+++ b/src/Common/Wipe.c
@@ -2,32 +2,27 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
#include "Tcdefs.h"
#include "Wipe.h"
-static BOOL Wipe1PseudoRandom (int pass, byte *buffer, size_t size)
-{
- return FALSE;
-}
-
// Fill buffer with wipe patterns defined in "National Industrial Security Program Operating Manual", US DoD 5220.22-M.
// Return: FALSE = buffer must be filled with random data
-static BOOL Wipe3Dod5220 (int pass, byte *buffer, size_t size)
+static BOOL Wipe3Dod5220 (int pass, uint8 *buffer, size_t size)
{
- byte wipeChar;
+ uint8 wipeChar;
switch (pass)
{
case 1:
wipeChar = 0;
@@ -44,13 +39,13 @@ static BOOL Wipe3Dod5220 (int pass, byte *buffer, size_t size)
memset (buffer, wipeChar, size);
return TRUE;
}
-static BOOL Wipe7Dod5220 (int pass, byte randChars[TC_WIPE_RAND_CHAR_COUNT], byte *buffer, size_t size)
+static BOOL Wipe7Dod5220 (int pass, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], uint8 *buffer, size_t size)
{
- byte wipeChar;
+ uint8 wipeChar;
switch (pass)
{
case 1:
wipeChar = randChars[0];
@@ -82,13 +77,13 @@ static BOOL Wipe7Dod5220 (int pass, byte randChars[TC_WIPE_RAND_CHAR_COUNT], byt
// Fill the buffer with wipe patterns defined in the paper "Secure Deletion of Data from Magnetic and Solid-State Memory" by Peter Gutmann.
// Return: FALSE = buffer must be filled with random data
-static BOOL Wipe35Gutmann (int pass, byte *buffer, size_t size)
+static BOOL Wipe35Gutmann (int pass, uint8 *buffer, size_t size)
{
- byte wipePat3[] = { 0x92, 0x49, 0x24 };
+ uint8 wipePat3[] = { 0x92, 0x49, 0x24 };
int wipePat3Pos;
size_t i;
switch (pass)
{
@@ -165,17 +160,17 @@ int GetWipePassCount (WipeAlgorithmId algorithm)
return -1; // Prevent compiler warnings
}
-BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size)
+BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size)
{
switch (algorithm)
{
case TC_WIPE_1_RAND:
case TC_WIPE_256:
- return Wipe1PseudoRandom (pass, buffer, size);
+ return FALSE; // Delegate buffer filling to the caller
case TC_WIPE_3_DOD_5220:
return Wipe3Dod5220 (pass, buffer, size);
case TC_WIPE_7_DOD_5220:
diff --git a/src/Common/Wipe.h b/src/Common/Wipe.h
index ef27eb06..b8bd0fac 100644
--- a/src/Common/Wipe.h
+++ b/src/Common/Wipe.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -34,11 +34,11 @@ typedef enum
} WipeAlgorithmId;
#define TC_WIPE_RAND_CHAR_COUNT 3
int GetWipePassCount (WipeAlgorithmId algorithm);
-BOOL WipeBuffer (WipeAlgorithmId algorithm, byte randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, byte *buffer, size_t size);
+BOOL WipeBuffer (WipeAlgorithmId algorithm, uint8 randChars[TC_WIPE_RAND_CHAR_COUNT], int pass, uint8 *buffer, size_t size);
#ifdef __cplusplus
}
#endif
diff --git a/src/Common/Xml.c b/src/Common/Xml.c
index 9f77b3ba..d48940ed 100644
--- a/src/Common/Xml.c
+++ b/src/Common/Xml.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
#if !defined(_UEFI)
diff --git a/src/Common/Xml.h b/src/Common/Xml.h
index 09b8543a..d442f187 100644
--- a/src/Common/Xml.h
+++ b/src/Common/Xml.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Xts.c b/src/Common/Xts.c
index 390eb31e..99999f11 100644
--- a/src/Common/Xts.c
+++ b/src/Common/Xts.c
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
@@ -52,14 +52,18 @@ void EncryptBufferXTS (unsigned __int8 *buffer,
unsigned int startCipherBlockNo,
unsigned __int8 *ks,
unsigned __int8 *ks2,
int cipher)
{
- if (CipherSupportsIntraDataUnitParallelization (cipher))
+ #ifndef WOLFCRYPT_BACKEND
+ if (CipherSupportsIntraDataUnitParallelization (cipher))
EncryptBufferXTSParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher);
else
EncryptBufferXTSNonParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher);
+ #else
+ xts_encrypt(buffer, buffer, length, startDataUnitNo, ks);
+ #endif
}
#if (CRYPTOPP_BOOL_SSE2_INTRINSICS_AVAILABLE && CRYPTOPP_BOOL_X64)
#define XorBlocks(result,ptr,len,start,end) \
@@ -378,14 +382,18 @@ void DecryptBufferXTS (unsigned __int8 *buffer,
unsigned int startCipherBlockNo,
unsigned __int8 *ks,
unsigned __int8 *ks2,
int cipher)
{
+ #ifndef WOLFCRYPT_BACKEND
if (CipherSupportsIntraDataUnitParallelization (cipher))
DecryptBufferXTSParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher);
else
DecryptBufferXTSNonParallel (buffer, length, startDataUnitNo, startCipherBlockNo, ks, ks2, cipher);
+ #else
+ xts_decrypt(buffer, buffer, length, startDataUnitNo, ks);
+ #endif
}
// Optimized for encryption algorithms supporting intra-data-unit parallelization
static void DecryptBufferXTSParallel (unsigned __int8 *buffer,
diff --git a/src/Common/Xts.h b/src/Common/Xts.h
index b4b4058e..0cc3a99f 100644
--- a/src/Common/Xts.h
+++ b/src/Common/Xts.h
@@ -2,11 +2,11 @@
Derived from source code of TrueCrypt 7.1a, which is
Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
by the TrueCrypt License 3.0.
Modifications and additions to the original source code (contained in this file)
- and all other portions of this file are Copyright (c) 2013-2017 IDRIX
+ and all other portions of this file are Copyright (c) 2013-2025 IDRIX
and are governed by the Apache License 2.0 the full text of which is
contained in the file License.txt included in VeraCrypt binary and source
code distribution packages.
*/
diff --git a/src/Common/Zip.vcxproj b/src/Common/Zip.vcxproj
index 11a971b2..a8fbf1eb 100644
--- a/src/Common/Zip.vcxproj
+++ b/src/Common/Zip.vcxproj
@@ -1,16 +1,24 @@
<?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">
@@ -104,10 +112,11 @@
<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_dostime.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" />
@@ -173,67 +182,101 @@
</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>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">
<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>
<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">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ <OutDir>$(ProjectDir)$(Platform)\$(Configuration)\</OutDir>
+ <IntDir>$(ProjectDir)$(Platform)\$(Configuration)\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>
<PrecompiledHeader>
</PrecompiledHeader>
@@ -245,10 +288,33 @@
</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>
@@ -260,10 +326,14 @@
</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>
@@ -272,17 +342,46 @@
<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>
@@ -291,17 +390,22 @@
<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.vcxproj.filters b/src/Common/Zip.vcxproj.filters
index 92bcf493..eb88a358 100644
--- a/src/Common/Zip.vcxproj.filters
+++ b/src/Common/Zip.vcxproj.filters
@@ -397,10 +397,13 @@
<Filter>libzip</Filter>
</ClCompile>
<ClCompile Include="libzip\zip_source_pass_to_lower_layer.c">
<Filter>zlib</Filter>
</ClCompile>
+ <ClCompile Include="libzip\zip_source_get_dostime.c">
+ <Filter>libzip</Filter>
+ </ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="libzip\compat.h">
<Filter>libzip</Filter>
</ClInclude>
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 26ab3310..00000000
--- a/src/Common/Zip_vs2019.vcxproj
+++ /dev/null
@@ -1,401 +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>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
- <OutDir>$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
- <OutDir>$(Configuration)\</OutDir>
- </PropertyGroup>
- <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|ARM64'">
- <OutDir>$(Platform)\$(Configuration)\</OutDir>
- </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>
- </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>
- </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>
- </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
diff --git a/src/Common/libzip/NEWS.md b/src/Common/libzip/NEWS.md
index e117422d..d2b1e73d 100644
--- a/src/Common/libzip/NEWS.md
+++ b/src/Common/libzip/NEWS.md
@@ -1,5 +1,22 @@
+# 1.11.2 [2024-10-31]
+
+* Fix performance regression in `zip_stat` introduced in 1.11.
+
+# 1.11.1 [2024-09-19]
+
+* Fix zipconf.h for version number with missing third component.
+
+# 1.11 [2024-09-19]
+
+* Stop searching after finding acceptable central directory, even if it contains inconsistencies.
+* Only write Zip64 EOCD if fields don't fit in normal EOCD. Previously libzip also wrote it when any directory entry required Zip64.
+* Allow bytes from 0x00-0x1F as UTF-8.
+* Add new error code `ZIP_ER_TRUNCATED_ZIP` for files that start with a valid local header signature.
+* `zipcmp`: add `-T` option for comparing timestamps.
+* `zip_file_replace` now removes the target's extra field information.
+
# 1.10.1 [2023-08-23]
* Add `ZIP_LENGTH_TO_END` and `ZIP_LENGTH_UNCHECKED`. Unless `ZIP_LENGTH_UNCHECKED` is used as `length`, it is an error for a file to shrink between the time when the source is created and when its data is read.
* Fix test on Windows.
diff --git a/src/Common/libzip/compat.h b/src/Common/libzip/compat.h
index 296ee59e..2cbc19f8 100644
--- a/src/Common/libzip/compat.h
+++ b/src/Common/libzip/compat.h
@@ -1,11 +1,11 @@
#ifndef _HAD_LIBZIP_COMPAT_H
#define _HAD_LIBZIP_COMPAT_H
/*
compat.h -- compatibility defines.
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -124,18 +124,69 @@ typedef char bool;
#if defined(HAVE__UNLINK)
#define unlink _unlink
#endif
#endif
-#ifndef HAVE_FSEEKO
-#define fseeko(s, o, w) (fseek((s), (long int)(o), (w)))
+
+#if defined(HAVE__FSEEKI64) && defined(HAVE__FSTAT64) && defined(HAVE__FTELLI64)
+/* Windows API using int64 */
+typedef zip_int64_t zip_off_t;
+typedef struct _stat64 zip_os_stat_t;
+#define zip_os_stat _stat64
+#define zip_os_fstat _fstat64
+#define zip_os_fseek _fseeki64
+#define zip_os_ftell _ftelli64
+#define ZIP_FSEEK_MAX ZIP_INT64_MAX
+#define ZIP_FSEEK_MIN ZIP_INT64_MIN
+#else
+
+/* Normal API */
+#include <sys/stat.h>
+typedef struct stat zip_os_stat_t;
+#define zip_os_fstat fstat
+#define zip_os_stat stat
+
+#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
+/* Using off_t */
+typedef off_t zip_off_t;
+#if SIZEOF_OFF_T == 8
+#define ZIP_OFF_MAX ZIP_INT64_MAX
+#define ZIP_OFF_MIN ZIP_INT64_MIN
+#elif SIZEOF_OFF_T == 4
+#define ZIP_OFF_MAX ZIP_INT32_MAX
+#define ZIP_OFF_MIN ZIP_INT32_MIN
+#elif SIZEOF_OFF_T == 2
+#define ZIP_OFF_MAX ZIP_INT16_MAX
+#define ZIP_OFF_MIN ZIP_INT16_MIN
+#else
+#error unsupported size of off_t
+#endif
+
+#define ZIP_FSEEK_MAX ZIP_OFF_MAX
+#define ZIP_FSEEK_MIN ZIP_OFF_MIN
+
+#define zip_os_fseek fseeko
+#define zip_os_ftell ftello
+#else
+
+/* Using long */
+typedef long zip_off_t;
+#include <limits.h>
+#define ZIP_FSEEK_MAX LONG_MAX
+#define ZIP_FSEEK_MIN LONG_MIN
+
+#define zip_os_fseek fseek
+#define zip_os_ftell ftell
+#endif
+
#endif
#ifndef HAVE_FTELLO
#define ftello(s) ((long)ftell((s)))
#endif
+
#ifdef HAVE_LOCALTIME_S
#ifdef _WIN32
/* Windows is incompatible to the C11 standard, hurray! */
#define zip_localtime(t, tm) (localtime_s((tm), (t)) == 0 ? tm : NULL)
#else
@@ -180,31 +231,10 @@ typedef char bool;
#ifndef HAVE_STRERRORLEN_S
#define strerrorlen_s(errnum) 8192
#endif
#endif
-#if SIZEOF_OFF_T == 8
-#define ZIP_OFF_MAX ZIP_INT64_MAX
-#define ZIP_OFF_MIN ZIP_INT64_MIN
-#elif SIZEOF_OFF_T == 4
-#define ZIP_OFF_MAX ZIP_INT32_MAX
-#define ZIP_OFF_MIN ZIP_INT32_MIN
-#elif SIZEOF_OFF_T == 2
-#define ZIP_OFF_MAX ZIP_INT16_MAX
-#define ZIP_OFF_MIN ZIP_INT16_MIN
-#else
-#error unsupported size of off_t
-#endif
-
-#if defined(HAVE_FTELLO) && defined(HAVE_FSEEKO)
-#define ZIP_FSEEK_MAX ZIP_OFF_MAX
-#define ZIP_FSEEK_MIN ZIP_OFF_MIN
-#else
-#include <limits.h>
-#define ZIP_FSEEK_MAX LONG_MAX
-#define ZIP_FSEEK_MIN LONG_MIN
-#endif
#ifndef SIZE_MAX
#if SIZEOF_SIZE_T == 8
#define SIZE_MAX ZIP_INT64_MAX
#elif SIZEOF_SIZE_T == 4
diff --git a/src/Common/libzip/config.h b/src/Common/libzip/config.h
index 2976249c..5edc625f 100644
--- a/src/Common/libzip/config.h
+++ b/src/Common/libzip/config.h
@@ -8,18 +8,22 @@
/* #undef HAVE___PROGNAME */
#define HAVE__CLOSE
#define HAVE__DUP
#define HAVE__FDOPEN
#define HAVE__FILENO
+#define HAVE__FSEEKI64
+#define HAVE__FSTAT64
+#define HAVE__FTELLI64
#define HAVE__SETMODE
#if defined(_MSC_VER) && _MSC_VER < 1900
#define HAVE__SNPRINTF
#else
/* #undef HAVE__SNPRINTF */
#endif
#define HAVE__SNPRINTF_S
#define HAVE__SNWPRINTF_S
+#define HAVE__STAT64
#define HAVE__STRDUP
#define HAVE__STRICMP
#define HAVE__STRTOI64
#define HAVE__STRTOUI64
#define HAVE__UNLINK
@@ -86,8 +90,8 @@
/* #undef HAVE_SYS_NDIR_H */
/* #undef WORDS_BIGENDIAN */
#define HAVE_SHARED
/* END DEFINES */
#define PACKAGE "libzip"
-#define VERSION "1.10.1"
+#define VERSION "1.11.2"
#endif /* HAD_CONFIG_H */
diff --git a/src/Common/libzip/zip.h b/src/Common/libzip/zip.h
index dc3751c8..da57ea56 100644
--- a/src/Common/libzip/zip.h
+++ b/src/Common/libzip/zip.h
@@ -1,11 +1,11 @@
#ifndef _HAD_ZIP_H
#define _HAD_ZIP_H
/*
zip.h -- exported declarations.
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -156,10 +156,11 @@ extern "C" {
#define ZIP_ER_TELL 30 /* S Tell error */
#define ZIP_ER_COMPRESSED_DATA 31 /* N Compressed data invalid */
#define ZIP_ER_CANCELLED 32 /* N Operation cancelled */
#define ZIP_ER_DATA_LENGTH 33 /* N Unexpected length of data */
#define ZIP_ER_NOT_ALLOWED 34 /* N Not allowed in torrentzip */
+#define ZIP_ER_TRUNCATED_ZIP 35 /* N Possibly truncated or corrupted zip archive */
/* type of system error value */
#define ZIP_ET_NONE 0 /* sys_err unused */
#define ZIP_ET_SYS 1 /* sys_err is errno */
@@ -258,11 +259,12 @@ enum zip_source_cmd {
ZIP_SOURCE_REMOVE, /* remove file */
ZIP_SOURCE_RESERVED_1, /* previously used internally */
ZIP_SOURCE_BEGIN_WRITE_CLONING, /* like ZIP_SOURCE_BEGIN_WRITE, but keep part of original file */
ZIP_SOURCE_ACCEPT_EMPTY, /* whether empty files are valid archives */
ZIP_SOURCE_GET_FILE_ATTRIBUTES, /* get additional file attributes */
- ZIP_SOURCE_SUPPORTS_REOPEN /* allow reading from changed entry */
+ ZIP_SOURCE_SUPPORTS_REOPEN, /* allow reading from changed entry */
+ ZIP_SOURCE_GET_DOS_TIME /* get last modification time in DOS format */
};
typedef enum zip_source_cmd zip_source_cmd_t;
#define ZIP_SOURCE_MAKE_COMMAND_BITMASK(cmd) (((zip_int64_t)1) << (cmd))
diff --git a/src/Common/libzip/zip_add.c b/src/Common/libzip/zip_add.c
index 9770139d..a426a579 100644
--- a/src/Common/libzip/zip_add.c
+++ b/src/Common/libzip/zip_add.c
@@ -1,8 +1,8 @@
/*
zip_add.c -- add file via callback function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_add_dir.c b/src/Common/libzip/zip_add_dir.c
index c31fea36..2faaa1a6 100644
--- a/src/Common/libzip/zip_add_dir.c
+++ b/src/Common/libzip/zip_add_dir.c
@@ -1,8 +1,8 @@
/*
zip_add_dir.c -- add directory
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_add_entry.c b/src/Common/libzip/zip_add_entry.c
index bf12dd54..e8beaa81 100644
--- a/src/Common/libzip/zip_add_entry.c
+++ b/src/Common/libzip/zip_add_entry.c
@@ -1,8 +1,8 @@
/*
zip_add_entry.c -- create and init struct zip_entry
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -62,11 +62,11 @@ _zip_add_entry(zip_t *za) {
if (sizeof(struct zip_entry) * (size_t)za->nentry_alloc > realloc_size) {
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
rentries = (zip_entry_t *)realloc(za->entry, sizeof(struct zip_entry) * (size_t)nalloc);
- if (!rentries) {
+ if (rentries == NULL) {
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
za->entry = rentries;
za->nentry_alloc = nalloc;
diff --git a/src/Common/libzip/zip_algorithm_bzip2.c b/src/Common/libzip/zip_algorithm_bzip2.c
index f25be143..1818039e 100644
--- a/src/Common/libzip/zip_algorithm_bzip2.c
+++ b/src/Common/libzip/zip_algorithm_bzip2.c
@@ -1,8 +1,8 @@
/*
zip_algorithm_bzip2.c -- bzip2 (de)compression routines
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_algorithm_deflate.c b/src/Common/libzip/zip_algorithm_deflate.c
index 3c85e204..5ab879df 100644
--- a/src/Common/libzip/zip_algorithm_deflate.c
+++ b/src/Common/libzip/zip_algorithm_deflate.c
@@ -1,8 +1,8 @@
/*
zip_algorithm_deflate.c -- deflate (de)compression routines
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_algorithm_xz.c b/src/Common/libzip/zip_algorithm_xz.c
index d7a7142d..b0413e01 100644
--- a/src/Common/libzip/zip_algorithm_xz.c
+++ b/src/Common/libzip/zip_algorithm_xz.c
@@ -1,9 +1,9 @@
/*
zip_algorithm_xz.c -- LZMA/XZ (de)compression routines
Bazed on zip_algorithm_deflate.c -- deflate (de)compression routines
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_algorithm_zstd.c b/src/Common/libzip/zip_algorithm_zstd.c
index d005da9d..b2aa2132 100644
--- a/src/Common/libzip/zip_algorithm_zstd.c
+++ b/src/Common/libzip/zip_algorithm_zstd.c
@@ -1,8 +1,8 @@
/*
zip_algorithm_zstd.c -- zstd (de)compression routines
- Copyright (C) 2020-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_buffer.c b/src/Common/libzip/zip_buffer.c
index e2103f04..de22bab1 100644
--- a/src/Common/libzip/zip_buffer.c
+++ b/src/Common/libzip/zip_buffer.c
@@ -1,8 +1,8 @@
/*
zip_buffer.c -- bounds checked access to memory buffer
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -304,12 +304,11 @@ _zip_buffer_put_8(zip_buffer_t *buffer, zip_uint8_t i) {
return 0;
}
-int
-_zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset) {
+int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset) {
if (offset > buffer->size) {
buffer->ok = false;
return -1;
}
diff --git a/src/Common/libzip/zip_close.c b/src/Common/libzip/zip_close.c
index ddc2c245..4313592c 100644
--- a/src/Common/libzip/zip_close.c
+++ b/src/Common/libzip/zip_close.c
@@ -1,8 +1,8 @@
/*
zip_close.c -- close zip archive and update changes
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -42,11 +42,11 @@
#endif
static int add_data(zip_t *, zip_source_t *, zip_dirent_t *, zip_uint32_t);
static int copy_data(zip_t *, zip_uint64_t);
-static int copy_source(zip_t *, zip_source_t *, zip_int64_t);
+static int copy_source(zip_t *, zip_source_t *, zip_source_t *, zip_int64_t);
static int torrentzip_compare_names(const void *a, const void *b);
static int write_cdir(zip_t *, const zip_filelist_t *, zip_uint64_t);
static int write_data_descriptor(zip_t *za, const zip_dirent_t *dirent, int is_zip64);
ZIP_EXTERN int
@@ -466,15 +466,11 @@ add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) {
if (de->encryption_method == ZIP_EM_TRAD_PKWARE) {
de->bitflags |= ZIP_GPBF_DATA_DESCRIPTOR;
/* PKWare encryption uses last_mod, make sure it gets the right value. */
if (de->changed & ZIP_DIRENT_LAST_MOD) {
- zip_stat_t st_mtime;
- zip_stat_init(&st_mtime);
- st_mtime.valid = ZIP_STAT_MTIME;
- st_mtime.mtime = de->last_mod;
- if ((src_tmp = _zip_source_window_new(src_final, 0, -1, &st_mtime, 0, NULL, NULL, 0, true, &za->error)) == NULL) {
+ if ((src_tmp = _zip_source_window_new(src_final, 0, -1, NULL, 0, NULL, &de->last_mod, NULL, 0, true, &za->error)) == NULL) {
zip_source_free(src_final);
return -1;
}
src_final = src_tmp;
}
@@ -493,11 +489,11 @@ add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) {
if ((offdata = zip_source_tell_write(za->src)) < 0) {
zip_error_set_from_source(&za->error, za->src);
return -1;
}
- ret = copy_source(za, src_final, data_length);
+ ret = copy_source(za, src_final, src, data_length);
if (zip_source_stat(src_final, &st) < 0) {
zip_error_set_from_source(&za->error, src_final);
ret = -1;
}
@@ -527,14 +523,27 @@ add_data(zip_t *za, zip_source_t *src, zip_dirent_t *de, zip_uint32_t changed) {
zip_error_set(&za->error, ZIP_ER_INTERNAL, 0);
return -1;
}
if ((de->changed & ZIP_DIRENT_LAST_MOD) == 0) {
- if (st.valid & ZIP_STAT_MTIME)
- de->last_mod = st.mtime;
- else
- time(&de->last_mod);
+ int ret2 = zip_source_get_dos_time(src, &de->last_mod);
+ if (ret2 < 0) {
+ zip_error_set_from_source(&za->error, src);
+ return -1;
+ }
+ if (ret2 == 0) {
+ time_t mtime;
+ if (st.valid & ZIP_STAT_MTIME) {
+ mtime = st.mtime;
+ }
+ else {
+ time(&mtime);
+ }
+ if (_zip_u2d_time(mtime, &de->last_mod, &za->error) < 0) {
+ return -1;
+ }
+ }
}
de->comp_method = st.comp_method;
de->crc = st.crc;
de->uncomp_size = st.size;
de->comp_size = (zip_uint64_t)(offend - offdata);
@@ -603,11 +612,11 @@ copy_data(zip_t *za, zip_uint64_t len) {
return 0;
}
static int
-copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
+copy_source(zip_t *za, zip_source_t *src, zip_source_t *src_for_length, zip_int64_t data_length) {
DEFINE_BYTE_ARRAY(buf, BUFSIZE);
zip_int64_t n, current;
int ret;
if (zip_source_open(src) < 0) {
@@ -626,11 +635,17 @@ copy_source(zip_t *za, zip_source_t *src, zip_int64_t data_length) {
if (_zip_write(za, buf, (zip_uint64_t)n) < 0) {
ret = -1;
break;
}
if (n == BUFSIZE && za->progress && data_length > 0) {
- current += n;
+ zip_int64_t t;
+ t = zip_source_tell(src_for_length);
+ if (t >= 0) {
+ current = t;
+ } else {
+ current += n;
+ }
if (_zip_progress_update(za->progress, (double)current / (double)data_length) != 0) {
zip_error_set(&za->error, ZIP_ER_CANCELLED, 0);
ret = -1;
break;
}
@@ -740,6 +755,6 @@ static int torrentzip_compare_names(const void *a, const void *b) {
else if (bname == NULL) {
return 1;
}
return strcasecmp(aname, bname);
-} \ No newline at end of file
+}
diff --git a/src/Common/libzip/zip_crypto.h b/src/Common/libzip/zip_crypto.h
index 0d74d1a4..805af52f 100644
--- a/src/Common/libzip/zip_crypto.h
+++ b/src/Common/libzip/zip_crypto.h
@@ -1,8 +1,8 @@
/*
zip_crypto.h -- crypto definitions
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_commoncrypto.c b/src/Common/libzip/zip_crypto_commoncrypto.c
index b198be56..e6cb72d3 100644
--- a/src/Common/libzip/zip_crypto_commoncrypto.c
+++ b/src/Common/libzip/zip_crypto_commoncrypto.c
@@ -1,8 +1,8 @@
/*
zip_crypto_commoncrypto.c -- CommonCrypto wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_commoncrypto.h b/src/Common/libzip/zip_crypto_commoncrypto.h
index 01828cc6..82dafdb4 100644
--- a/src/Common/libzip/zip_crypto_commoncrypto.h
+++ b/src/Common/libzip/zip_crypto_commoncrypto.h
@@ -1,8 +1,8 @@
/*
zip_crypto_commoncrypto.h -- definitions for CommonCrypto wrapper.
- Copyright (C) 2018 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_gnutls.c b/src/Common/libzip/zip_crypto_gnutls.c
index 1a25aa12..fcc7fdfd 100644
--- a/src/Common/libzip/zip_crypto_gnutls.c
+++ b/src/Common/libzip/zip_crypto_gnutls.c
@@ -1,8 +1,8 @@
/*
zip_crypto_gnutls.c -- GnuTLS wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_gnutls.h b/src/Common/libzip/zip_crypto_gnutls.h
index dc8b97a4..a6fa508a 100644
--- a/src/Common/libzip/zip_crypto_gnutls.h
+++ b/src/Common/libzip/zip_crypto_gnutls.h
@@ -1,8 +1,8 @@
/*
zip_crypto_gnutls.h -- definitions for GnuTLS wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_mbedtls.c b/src/Common/libzip/zip_crypto_mbedtls.c
index 84544a82..0ed66c0d 100644
--- a/src/Common/libzip/zip_crypto_mbedtls.c
+++ b/src/Common/libzip/zip_crypto_mbedtls.c
@@ -1,8 +1,8 @@
/*
zip_crypto_mbedtls.c -- mbed TLS wrapper
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_mbedtls.h b/src/Common/libzip/zip_crypto_mbedtls.h
index 1151fff7..30ce21c9 100644
--- a/src/Common/libzip/zip_crypto_mbedtls.h
+++ b/src/Common/libzip/zip_crypto_mbedtls.h
@@ -1,8 +1,8 @@
/*
zip_crypto_mbedtls.h -- definitions for mbedtls wrapper
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_openssl.c b/src/Common/libzip/zip_crypto_openssl.c
index 7f1da10e..9e9e8e7c 100644
--- a/src/Common/libzip/zip_crypto_openssl.c
+++ b/src/Common/libzip/zip_crypto_openssl.c
@@ -1,8 +1,8 @@
/*
zip_crypto_openssl.c -- OpenSSL wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -124,12 +124,13 @@ _zip_crypto_aes_free(_zip_crypto_aes_t *aes) {
}
bool
_zip_crypto_aes_encrypt_block(_zip_crypto_aes_t *aes, const zip_uint8_t *in, zip_uint8_t *out) {
- int len;
- if (EVP_EncryptUpdate(aes, out, &len, in, ZIP_CRYPTO_AES_BLOCK_LENGTH) != 1) {
+ int len = 0;
+ if (EVP_EncryptUpdate(aes, out, &len, in, ZIP_CRYPTO_AES_BLOCK_LENGTH) != 1
+ || len != ZIP_CRYPTO_AES_BLOCK_LENGTH) {
return false;
}
return true;
}
@@ -212,15 +213,15 @@ _zip_crypto_hmac_free(_zip_crypto_hmac_t *hmac) {
bool
_zip_crypto_hmac_output(_zip_crypto_hmac_t *hmac, zip_uint8_t *data) {
#ifdef USE_OPENSSL_3_API
- size_t length;
+ size_t length = 0;
return EVP_MAC_final(hmac->ctx, data, &length, ZIP_CRYPTO_SHA1_LENGTH) == 1 && length == ZIP_CRYPTO_SHA1_LENGTH;
#else
- unsigned int length;
- return HMAC_Final(hmac, data, &length) == 1;
+ unsigned int length = 0;
+ return HMAC_Final(hmac, data, &length) == 1 && length == ZIP_CRYPTO_SHA1_LENGTH;
#endif
}
ZIP_EXTERN bool
diff --git a/src/Common/libzip/zip_crypto_openssl.h b/src/Common/libzip/zip_crypto_openssl.h
index 198a9071..e593ec55 100644
--- a/src/Common/libzip/zip_crypto_openssl.h
+++ b/src/Common/libzip/zip_crypto_openssl.h
@@ -1,8 +1,8 @@
/*
zip_crypto_openssl.h -- definitions for OpenSSL wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_crypto_win.c b/src/Common/libzip/zip_crypto_win.c
index ee3ccc30..6d923038 100644
--- a/src/Common/libzip/zip_crypto_win.c
+++ b/src/Common/libzip/zip_crypto_win.c
@@ -1,8 +1,8 @@
/*
zip_crypto_win.c -- Windows Crypto API wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -35,13 +35,10 @@
#include "zipint.h"
#include "zip_crypto.h"
-#define WIN32_LEAN_AND_MEAN
-#define NOCRYPT
-
#include <windows.h>
#include <bcrypt.h>
#pragma comment(lib, "bcrypt.lib")
diff --git a/src/Common/libzip/zip_crypto_win.h b/src/Common/libzip/zip_crypto_win.h
index a533fe2d..3f05b621 100644
--- a/src/Common/libzip/zip_crypto_win.h
+++ b/src/Common/libzip/zip_crypto_win.h
@@ -1,8 +1,8 @@
/*
zip_crypto_win.h -- Windows Crypto API wrapper.
- Copyright (C) 2018-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2018-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_delete.c b/src/Common/libzip/zip_delete.c
index 676c16bf..4eefdd97 100644
--- a/src/Common/libzip/zip_delete.c
+++ b/src/Common/libzip/zip_delete.c
@@ -1,8 +1,8 @@
/*
zip_delete.c -- delete file from zip archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_dir_add.c b/src/Common/libzip/zip_dir_add.c
index c0108191..01d8ec9d 100644
--- a/src/Common/libzip/zip_dir_add.c
+++ b/src/Common/libzip/zip_dir_add.c
@@ -1,8 +1,8 @@
/*
zip_dir_add.c -- add directory
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_dirent.c b/src/Common/libzip/zip_dirent.c
index 45a2a6a2..24bc6abf 100644
--- a/src/Common/libzip/zip_dirent.c
+++ b/src/Common/libzip/zip_dirent.c
@@ -1,8 +1,8 @@
/*
zip_dirent.c -- read directory entry (local or central), clean dirent
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -39,32 +39,33 @@
#include <time.h>
#include <zlib.h>
#include "zipint.h"
-static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str);
+static zip_string_t *_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency);
static zip_extra_field_t *_zip_ef_utf8(zip_uint16_t, zip_string_t *, zip_error_t *);
static bool _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error);
void
_zip_cdir_free(zip_cdir_t *cd) {
zip_uint64_t i;
- if (!cd)
+ if (cd == NULL) {
return;
+ }
for (i = 0; i < cd->nentry; i++)
_zip_entry_finalize(cd->entry + i);
free(cd->entry);
_zip_string_free(cd->comment);
free(cd);
}
zip_cdir_t *
-_zip_cdir_new(zip_uint64_t nentry, zip_error_t *error) {
+_zip_cdir_new(zip_error_t *error) {
zip_cdir_t *cd;
if ((cd = (zip_cdir_t *)malloc(sizeof(*cd))) == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return NULL;
@@ -74,15 +75,10 @@ _zip_cdir_new(zip_uint64_t nentry, zip_error_t *error) {
cd->nentry = cd->nentry_alloc = 0;
cd->size = cd->offset = 0;
cd->comment = NULL;
cd->is_zip64 = false;
- if (!_zip_cdir_grow(cd, nentry, error)) {
- _zip_cdir_free(cd);
- return NULL;
- }
-
return cd;
}
bool
@@ -124,54 +120,46 @@ _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivor
zip_string_t *comment;
zip_uint8_t buf[EOCDLEN + EOCD64LEN + EOCD64LOCLEN];
zip_buffer_t *buffer;
zip_int64_t off;
zip_uint64_t i;
- bool is_zip64;
- int ret;
zip_uint32_t cdir_crc;
if ((off = zip_source_tell_write(za->src)) < 0) {
zip_error_set_from_source(&za->error, za->src);
return -1;
}
offset = (zip_uint64_t)off;
- is_zip64 = false;
-
if (ZIP_WANT_TORRENTZIP(za)) {
cdir_crc = (zip_uint32_t)crc32(0, NULL, 0);
za->write_crc = &cdir_crc;
}
for (i = 0; i < survivors; i++) {
zip_entry_t *entry = za->entry + filelist[i].idx;
- if ((ret = _zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL)) < 0)
+ if (_zip_dirent_write(za, entry->changes ? entry->changes : entry->orig, ZIP_FL_CENTRAL) < 0) {
+ za->write_crc = NULL;
return -1;
- if (ret)
- is_zip64 = true;
+ }
}
za->write_crc = NULL;
if ((off = zip_source_tell_write(za->src)) < 0) {
zip_error_set_from_source(&za->error, za->src);
return -1;
}
size = (zip_uint64_t)off - offset;
- if (offset > ZIP_UINT32_MAX || survivors > ZIP_UINT16_MAX) {
- is_zip64 = true;
- }
-
if ((buffer = _zip_buffer_new(buf, sizeof(buf))) == NULL) {
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
- if (is_zip64) {
+ if (survivors > ZIP_UINT16_MAX || offset > ZIP_UINT32_MAX || size > ZIP_UINT32_MAX) {
_zip_buffer_put(buffer, EOCD64_MAGIC, 4);
_zip_buffer_put_64(buffer, EOCD64LEN - 12);
_zip_buffer_put_16(buffer, 45);
_zip_buffer_put_16(buffer, 45);
_zip_buffer_put_32(buffer, 0);
@@ -292,15 +280,17 @@ _zip_dirent_init(zip_dirent_t *de) {
de->changed = 0;
de->local_extra_fields_read = 0;
de->cloned = 0;
de->crc_valid = true;
+ de->last_mod_mtime_valid = false;
de->version_madeby = 63 | (ZIP_OPSYS_DEFAULT << 8);
de->version_needed = 10; /* 1.0 */
de->bitflags = 0;
de->comp_method = ZIP_CM_DEFAULT;
- de->last_mod = 0;
+ de->last_mod.date = 0;
+ de->last_mod.time = 0;
de->crc = 0;
de->comp_size = 0;
de->uncomp_size = 0;
de->filename = NULL;
de->extra_fields = NULL;
@@ -334,26 +324,27 @@ _zip_dirent_new(void) {
_zip_dirent_init(de);
return de;
}
-/* _zip_dirent_read(zde, fp, bufp, left, localp, error):
+/*
Fills the zip directory entry zde.
If buffer is non-NULL, data is taken from there; otherwise data is read from fp as needed.
If local is true, it reads a local header instead of a central directory entry.
Returns size of dirent read if successful. On error, error is filled in and -1 is returned.
*/
zip_int64_t
-_zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error) {
+_zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_uint64_t central_compressed_size, bool check_consistency, zip_error_t *error) {
zip_uint8_t buf[CDENTRYSIZE];
- zip_uint16_t dostime, dosdate;
zip_uint32_t size, variable_size;
zip_uint16_t filename_len, comment_len, ef_len;
+ zip_string_t *utf8_string;
+ bool is_zip64 = false;
bool from_buffer = (buffer != NULL);
size = local ? LENTRYSIZE : CDENTRYSIZE;
@@ -387,13 +378,12 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
zde->version_needed = _zip_buffer_get_16(buffer);
zde->bitflags = _zip_buffer_get_16(buffer);
zde->comp_method = _zip_buffer_get_16(buffer);
/* convert to time_t */
- dostime = _zip_buffer_get_16(buffer);
- dosdate = _zip_buffer_get_16(buffer);
- zde->last_mod = _zip_d2u_time(dostime, dosdate);
+ zde->last_mod.time = _zip_buffer_get_16(buffer);
+ zde->last_mod.date = _zip_buffer_get_16(buffer);
zde->crc = _zip_buffer_get_32(buffer);
zde->comp_size = _zip_buffer_get_32(buffer);
zde->uncomp_size = _zip_buffer_get_32(buffer);
@@ -456,11 +446,11 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
}
}
if (filename_len) {
zde->filename = _zip_read_string(buffer, src, filename_len, 1, error);
- if (!zde->filename) {
+ if (zde->filename == NULL) {
if (zip_error_code_zip(error) == ZIP_ER_EOF) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW);
}
if (!from_buffer) {
_zip_buffer_free(buffer);
@@ -500,11 +490,11 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
zde->local_extra_fields_read = 1;
}
if (comment_len) {
zde->comment = _zip_read_string(buffer, src, comment_len, 0, error);
- if (!zde->comment) {
+ if (zde->comment == NULL) {
if (!from_buffer) {
_zip_buffer_free(buffer);
}
return -1;
}
@@ -517,12 +507,28 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
return -1;
}
}
}
- zde->filename = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_NAME, zde->filename);
- zde->comment = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_COMMENT, zde->comment);
+ if ((utf8_string = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_NAME, zde->filename, check_consistency)) == NULL && zde->filename != NULL) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_UTF8_FILENAME_MISMATCH);
+ if (!from_buffer) {
+ _zip_buffer_free(buffer);
+ }
+ return -1;
+ }
+ zde->filename = utf8_string;
+ if (!local) {
+ if ((utf8_string = _zip_dirent_process_ef_utf_8(zde, ZIP_EF_UTF_8_COMMENT, zde->comment, check_consistency)) == NULL && zde->comment != NULL) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_UTF8_COMMENT_MISMATCH);
+ if (!from_buffer) {
+ _zip_buffer_free(buffer);
+ }
+ return -1;
+ }
+ zde->comment = utf8_string;
+ }
/* Zip64 */
if (zde->uncomp_size == ZIP_UINT32_MAX || zde->comp_size == ZIP_UINT32_MAX || zde->offset == ZIP_UINT32_MAX) {
zip_uint16_t got_len;
@@ -533,24 +539,55 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
_zip_buffer_free(buffer);
}
return -1;
}
}
+ is_zip64 = true;
}
if (!_zip_buffer_ok(buffer)) {
zip_error_set(error, ZIP_ER_INTERNAL, 0);
if (!from_buffer) {
_zip_buffer_free(buffer);
}
return -1;
}
+
if (!from_buffer) {
_zip_buffer_free(buffer);
}
+ if (local && zde->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) {
+ zip_uint32_t df_crc;
+ zip_uint64_t df_comp_size, df_uncomp_size;
+ if (zip_source_seek(src, central_compressed_size, SEEK_CUR) != 0 || (buffer = _zip_buffer_new_from_source(src, MAX_DATA_DESCRIPTOR_LENGTH, buf, error)) == NULL) {
+ return -1;
+ }
+ if (memcmp(_zip_buffer_peek(buffer, MAGIC_LEN), DATADES_MAGIC, MAGIC_LEN) == 0) {
+ _zip_buffer_skip(buffer, MAGIC_LEN);
+ }
+ df_crc = _zip_buffer_get_32(buffer);
+ df_comp_size = is_zip64 ? _zip_buffer_get_64(buffer) : _zip_buffer_get_32(buffer);
+ df_uncomp_size = is_zip64 ? _zip_buffer_get_64(buffer) : _zip_buffer_get_32(buffer);
+
+ if (!_zip_buffer_ok(buffer)) {
+ zip_error_set(error, ZIP_ER_INTERNAL, 0);
+ _zip_buffer_free(buffer);
+ return -1;
+ }
+ _zip_buffer_free(buffer);
+
+ if ((zde->crc != 0 && zde->crc != df_crc) || (zde->comp_size != 0 && zde->comp_size != df_comp_size) || (zde->uncomp_size != 0 && zde->uncomp_size != df_uncomp_size)) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_DATA_DESCRIPTOR_MISMATCH);
+ return -1;
+ }
+ zde->crc = df_crc;
+ zde->comp_size = df_comp_size;
+ zde->uncomp_size = df_uncomp_size;
+ }
+
/* zip_source_seek / zip_source_tell don't support values > ZIP_INT64_MAX */
if (zde->offset > ZIP_INT64_MAX) {
zip_error_set(error, ZIP_ER_SEEK, EFBIG);
return -1;
}
@@ -562,11 +599,12 @@ _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, boo
zde->extra_fields = _zip_ef_remove_internal(zde->extra_fields);
return (zip_int64_t)size + (zip_int64_t)variable_size;
}
-bool zip_dirent_process_ef_zip64(zip_dirent_t* zde, const zip_uint8_t* ef, zip_uint64_t got_len, bool local, zip_error_t* error) {
+bool
+zip_dirent_process_ef_zip64(zip_dirent_t *zde, const zip_uint8_t *ef, zip_uint64_t got_len, bool local, zip_error_t *error) {
zip_buffer_t *ef_buffer;
if ((ef_buffer = _zip_buffer_new((zip_uint8_t *)ef, got_len)) == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return false;
@@ -623,11 +661,11 @@ bool zip_dirent_process_ef_zip64(zip_dirent_t* zde, const zip_uint8_t* ef, zip_u
return true;
}
static zip_string_t *
-_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str) {
+_zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string_t *str, bool check_consistency) {
zip_uint16_t ef_len;
zip_uint32_t ef_crc;
zip_buffer_t *buffer;
const zip_uint8_t *ef = _zip_ef_get_by_id(de->extra_fields, &ef_len, id, 0, ZIP_EF_BOTH, NULL);
@@ -646,10 +684,18 @@ _zip_dirent_process_ef_utf_8(const zip_dirent_t *de, zip_uint16_t id, zip_string
if (_zip_string_crc32(str) == ef_crc) {
zip_uint16_t len = (zip_uint16_t)_zip_buffer_left(buffer);
zip_string_t *ef_str = _zip_string_new(_zip_buffer_get(buffer, len), len, ZIP_FL_ENC_UTF_8, NULL);
if (ef_str != NULL) {
+ if (check_consistency) {
+ if (!_zip_string_equal(str, ef_str) && _zip_string_is_ascii(ef_str)) {
+ _zip_string_free(ef_str);
+ _zip_buffer_free(buffer);
+ return NULL;
+ }
+ }
+
_zip_string_free(str);
str = ef_str;
}
}
@@ -686,22 +732,22 @@ _zip_dirent_process_winzip_aes(zip_dirent_t *de, zip_error_t *error) {
/* version */
crc_valid = true;
switch (_zip_buffer_get_16(buffer)) {
- case 1:
- break;
+ case 1:
+ break;
- case 2:
- crc_valid = false;
- /* TODO: When checking consistency, check that crc is 0. */
- break;
-
- default:
- zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0);
- _zip_buffer_free(buffer);
- return false;
+ case 2:
+ crc_valid = false;
+ /* TODO: When checking consistency, check that crc is 0. */
+ break;
+
+ default:
+ zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0);
+ _zip_buffer_free(buffer);
+ return false;
}
/* vendor */
if (memcmp(_zip_buffer_get(buffer, 2), "AE", 2) != 0) {
zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0);
@@ -785,11 +831,11 @@ _zip_dirent_size(zip_source_t *src, zip_uint16_t flags, zip_error_t *error) {
returned.
*/
int
_zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) {
- zip_uint16_t dostime, dosdate;
+ zip_dostime_t dostime;
zip_encoding_type_t com_enc, name_enc;
zip_extra_field_t *ef;
zip_extra_field_t *ef64;
zip_uint32_t ef_total_size;
bool is_zip64;
@@ -924,18 +970,18 @@ _zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) {
else {
_zip_buffer_put_16(buffer, (zip_uint16_t)de->comp_method);
}
if (ZIP_WANT_TORRENTZIP(za)) {
- dostime = 0xbc00;
- dosdate = 0x2198;
+ dostime.time = 0xbc00;
+ dostime.date = 0x2198;
}
else {
- _zip_u2d_time(de->last_mod, &dostime, &dosdate);
+ dostime = de->last_mod;
}
- _zip_buffer_put_16(buffer, dostime);
- _zip_buffer_put_16(buffer, dosdate);
+ _zip_buffer_put_16(buffer, dostime.time);
+ _zip_buffer_put_16(buffer, dostime.date);
if (is_winzip_aes && de->uncomp_size < 20) {
_zip_buffer_put_32(buffer, 0);
}
else {
@@ -1032,25 +1078,25 @@ _zip_dirent_write(zip_t *za, zip_dirent_t *de, zip_flags_t flags) {
return is_zip64;
}
time_t
-_zip_d2u_time(zip_uint16_t dtime, zip_uint16_t ddate) {
+_zip_d2u_time(const zip_dostime_t *dtime) {
struct tm tm;
memset(&tm, 0, sizeof(tm));
/* let mktime decide if DST is in effect */
tm.tm_isdst = -1;
- tm.tm_year = ((ddate >> 9) & 127) + 1980 - 1900;
- tm.tm_mon = ((ddate >> 5) & 15) - 1;
- tm.tm_mday = ddate & 31;
+ tm.tm_year = ((dtime->date >> 9) & 127) + 1980 - 1900;
+ tm.tm_mon = ((dtime->date >> 5) & 15) - 1;
+ tm.tm_mday = dtime->date & 31;
- tm.tm_hour = (dtime >> 11) & 31;
- tm.tm_min = (dtime >> 5) & 63;
- tm.tm_sec = (dtime << 1) & 62;
+ tm.tm_hour = (dtime->time >> 11) & 31;
+ tm.tm_min = (dtime->time >> 5) & 63;
+ tm.tm_sec = (dtime->time << 1) & 62;
return mktime(&tm);
}
@@ -1117,27 +1163,32 @@ _zip_get_dirent(zip_t *za, zip_uint64_t idx, zip_flags_t flags, zip_error_t *err
else
return za->entry[idx].changes;
}
-void
-_zip_u2d_time(time_t intime, zip_uint16_t *dtime, zip_uint16_t *ddate) {
+int
+_zip_u2d_time(time_t intime, zip_dostime_t *dtime, zip_error_t *ze) {
struct tm *tpm;
struct tm tm;
tpm = zip_localtime(&intime, &tm);
if (tpm == NULL) {
/* if localtime fails, return an arbitrary date (1980-01-01 00:00:00) */
- *ddate = (1 << 5) + 1;
- *dtime = 0;
- return;
+ dtime->date = (1 << 5) + 1;
+ dtime->time = 0;
+ if (ze) {
+ zip_error_set(ze, ZIP_ER_INVAL, errno);
+ }
+ return -1;
}
if (tpm->tm_year < 80) {
tpm->tm_year = 80;
}
- *ddate = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday);
- *dtime = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1));
+ dtime->date = (zip_uint16_t)(((tpm->tm_year + 1900 - 1980) << 9) + ((tpm->tm_mon + 1) << 5) + tpm->tm_mday);
+ dtime->time = (zip_uint16_t)(((tpm->tm_hour) << 11) + ((tpm->tm_min) << 5) + ((tpm->tm_sec) >> 1));
+
+ return 0;
}
void
_zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes, bool force_zip64, zip_uint32_t changed) {
@@ -1190,18 +1241,35 @@ _zip_dirent_apply_attributes(zip_dirent_t *de, zip_file_attributes_t *attributes
/* _zip_dirent_torrent_normalize(de);
Set values suitable for torrentzip.
*/
-void zip_dirent_torrentzip_normalize(zip_dirent_t *de) {
+void
+zip_dirent_torrentzip_normalize(zip_dirent_t *de) {
de->version_madeby = 0;
de->version_needed = 20; /* 2.0 */
- de->bitflags = 2; /* maximum compression */
+ de->bitflags = 2; /* maximum compression */
de->comp_method = ZIP_CM_DEFLATE;
de->compression_level = TORRENTZIP_COMPRESSION_FLAGS;
de->disk_number = 0;
de->int_attrib = 0;
de->ext_attrib = 0;
/* last_mod, extra_fields, and comment are normalized in zip_dirent_write() directly */
+}
+int
+zip_dirent_check_consistency(zip_dirent_t *dirent) {
+ if (dirent->comp_method == ZIP_CM_STORE && dirent->comp_size != dirent->uncomp_size) {
+ return ZIP_ER_DETAIL_STORED_SIZE_MISMATCH;
+ }
+ return 0;
}
+
+time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de) {
+ if (!de->last_mod_mtime_valid) {
+ de->last_mod_mtime = _zip_d2u_time(&de->last_mod);
+ de->last_mod_mtime_valid = true;
+ }
+
+ return de->last_mod_mtime;
+} \ No newline at end of file
diff --git a/src/Common/libzip/zip_discard.c b/src/Common/libzip/zip_discard.c
index d1dc4f8b..841a80e2 100644
--- a/src/Common/libzip/zip_discard.c
+++ b/src/Common/libzip/zip_discard.c
@@ -1,8 +1,8 @@
/*
zip_discard.c -- discard and free struct zip
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_entry.c b/src/Common/libzip/zip_entry.c
index 35a36e4a..dd25e61f 100644
--- a/src/Common/libzip/zip_entry.c
+++ b/src/Common/libzip/zip_entry.c
@@ -1,8 +1,8 @@
/*
zip_entry.c -- struct zip_entry helper functions
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_err_str.c b/src/Common/libzip/zip_err_str.c
index 28af773b..fb4b69fa 100644
--- a/src/Common/libzip/zip_err_str.c
+++ b/src/Common/libzip/zip_err_str.c
@@ -47,10 +47,11 @@ const struct _zip_err_info _zip_err_str[] = {
{ S, "Tell error" },
{ N, "Compressed data invalid" },
{ N, "Operation cancelled" },
{ N, "Unexpected length of data" },
{ N, "Not allowed in torrentzip" },
+ { N, "Possibly truncated or corrupted zip archive" },
};
const int _zip_err_str_count = sizeof(_zip_err_str)/sizeof(_zip_err_str[0]);
const struct _zip_err_info _zip_err_details[] = {
@@ -72,8 +73,13 @@ const struct _zip_err_info _zip_err_details[] = {
{ E, "invalid Zip64 extra field" },
{ E, "invalid WinZip AES extra field" },
{ E, "garbage at end of extra fields" },
{ E, "extra field length is invalid" },
{ E, "file length in header doesn't match actual file length" },
+ { E, "compressed and uncompressed sizes don't match for stored file" },
+ { E, "local header and data descriptor do not match" },
+ { G, "EOCD64 and EOCD64 locator do not match" },
+ { E, "UTF-8 filename is ASCII and doesn't match filename" },
+ { E, "UTF-8 comment is ASCII and doesn't match comment" },
};
const int _zip_err_details_count = sizeof(_zip_err_details)/sizeof(_zip_err_details[0]);
diff --git a/src/Common/libzip/zip_error.c b/src/Common/libzip/zip_error.c
index c498e086..da910d44 100644
--- a/src/Common/libzip/zip_error.c
+++ b/src/Common/libzip/zip_error.c
@@ -1,8 +1,8 @@
/*
zip_error.c -- zip_error_t helper functions
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_error_clear.c b/src/Common/libzip/zip_error_clear.c
index 94ff5062..04062719 100644
--- a/src/Common/libzip/zip_error_clear.c
+++ b/src/Common/libzip/zip_error_clear.c
@@ -1,8 +1,8 @@
/*
zip_error_clear.c -- clear zip error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_error_get.c b/src/Common/libzip/zip_error_get.c
index c0418f0d..2a5b3eaf 100644
--- a/src/Common/libzip/zip_error_get.c
+++ b/src/Common/libzip/zip_error_get.c
@@ -1,8 +1,8 @@
/*
zip_error_get.c -- get zip error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_error_get_sys_type.c b/src/Common/libzip/zip_error_get_sys_type.c
index a22ffb03..973d26c0 100644
--- a/src/Common/libzip/zip_error_get_sys_type.c
+++ b/src/Common/libzip/zip_error_get_sys_type.c
@@ -1,8 +1,8 @@
/*
zip_error_get_sys_type.c -- return type of system error code
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_error_strerror.c b/src/Common/libzip/zip_error_strerror.c
index fe04cbb4..5be54b38 100644
--- a/src/Common/libzip/zip_error_strerror.c
+++ b/src/Common/libzip/zip_error_strerror.c
@@ -1,8 +1,8 @@
/*
zip_error_sterror.c -- get string representation of struct zip_error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -47,10 +47,13 @@ zip_error_strerror(zip_error_t *err) {
zip_error_fini(err);
if (err->zip_err < 0 || err->zip_err >= _zip_err_str_count) {
system_error_buffer = (char *)malloc(128);
+ if (system_error_buffer == NULL) {
+ return _zip_err_str[ZIP_ER_MEMORY].description;
+ }
snprintf_s(system_error_buffer, 128, "Unknown error %d", err->zip_err);
system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */
zip_error_string = NULL;
system_error_string = system_error_buffer;
}
@@ -59,10 +62,13 @@ zip_error_strerror(zip_error_t *err) {
switch (_zip_err_str[err->zip_err].type) {
case ZIP_ET_SYS: {
size_t len = strerrorlen_s(err->sys_err) + 1;
system_error_buffer = malloc(len);
+ if (system_error_buffer == NULL) {
+ return _zip_err_str[ZIP_ER_MEMORY].description;
+ }
strerror_s(system_error_buffer, len, err->sys_err);
system_error_string = system_error_buffer;
break;
}
@@ -77,16 +83,22 @@ zip_error_strerror(zip_error_t *err) {
if (error == 0) {
system_error_string = NULL;
}
else if (error >= _zip_err_details_count) {
system_error_buffer = (char *)malloc(128);
+ if (system_error_buffer == NULL) {
+ return _zip_err_str[ZIP_ER_MEMORY].description;
+ }
snprintf_s(system_error_buffer, 128, "invalid detail error %u", error);
system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */
system_error_string = system_error_buffer;
}
else if (_zip_err_details[error].type == ZIP_DETAIL_ET_ENTRY && index < MAX_DETAIL_INDEX) {
system_error_buffer = (char *)malloc(128);
+ if (system_error_buffer == NULL) {
+ return _zip_err_str[ZIP_ER_MEMORY].description;
+ }
snprintf_s(system_error_buffer, 128, "entry %d: %s", index, _zip_err_details[error].description);
system_error_buffer[128 - 1] = '\0'; /* make sure string is NUL-terminated */
system_error_string = system_error_buffer;
}
else {
diff --git a/src/Common/libzip/zip_error_to_str.c b/src/Common/libzip/zip_error_to_str.c
index b60b7881..4186e3a4 100644
--- a/src/Common/libzip/zip_error_to_str.c
+++ b/src/Common/libzip/zip_error_to_str.c
@@ -1,8 +1,8 @@
/*
zip_error_to_str.c -- get string representation of zip error code
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_extra_field.c b/src/Common/libzip/zip_extra_field.c
index 7aed12ad..52837046 100644
--- a/src/Common/libzip/zip_extra_field.c
+++ b/src/Common/libzip/zip_extra_field.c
@@ -1,8 +1,8 @@
/*
zip_extra_field.c -- manipulate extra fields
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_extra_field_api.c b/src/Common/libzip/zip_extra_field_api.c
index 560c71bb..6f2b4596 100644
--- a/src/Common/libzip/zip_extra_field_api.c
+++ b/src/Common/libzip/zip_extra_field_api.c
@@ -1,8 +1,8 @@
/*
zip_extra_field_api.c -- public extra fields API functions
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -54,14 +54,10 @@ zip_file_extra_field_delete(zip_t *za, zip_uint64_t idx, zip_uint16_t ef_idx, zi
if (ZIP_IS_RDONLY(za)) {
zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
return -1;
}
- if (ZIP_WANT_TORRENTZIP(za)) {
- zip_error_set(&za->error, ZIP_ER_NOT_ALLOWED, 0);
- return -1;
- }
if (_zip_file_extra_field_prepare_for_change(za, idx) < 0)
return -1;
de = za->entry[idx].changes;
diff --git a/src/Common/libzip/zip_fclose.c b/src/Common/libzip/zip_fclose.c
index b820d98b..2ef579a0 100644
--- a/src/Common/libzip/zip_fclose.c
+++ b/src/Common/libzip/zip_fclose.c
@@ -1,8 +1,8 @@
/*
zip_fclose.c -- close file in zip archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fdopen.c b/src/Common/libzip/zip_fdopen.c
index e72c55dc..94fe6c7c 100644
--- a/src/Common/libzip/zip_fdopen.c
+++ b/src/Common/libzip/zip_fdopen.c
@@ -1,8 +1,8 @@
/*
zip_fdopen.c -- open read-only archive from file descriptor
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_add.c b/src/Common/libzip/zip_file_add.c
index c2c41e15..5959d504 100644
--- a/src/Common/libzip/zip_file_add.c
+++ b/src/Common/libzip/zip_file_add.c
@@ -1,8 +1,8 @@
/*
zip_file_add.c -- add file via callback function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_error_clear.c b/src/Common/libzip/zip_file_error_clear.c
index a10bff80..eb9a614e 100644
--- a/src/Common/libzip/zip_file_error_clear.c
+++ b/src/Common/libzip/zip_file_error_clear.c
@@ -1,8 +1,8 @@
/*
zip_file_error_clear.c -- clear zip file error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_error_get.c b/src/Common/libzip/zip_file_error_get.c
index b93117bb..679aeefb 100644
--- a/src/Common/libzip/zip_file_error_get.c
+++ b/src/Common/libzip/zip_file_error_get.c
@@ -1,8 +1,8 @@
/*
zip_file_error_get.c -- get zip file error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_get_comment.c b/src/Common/libzip/zip_file_get_comment.c
index fa998f02..ca04042a 100644
--- a/src/Common/libzip/zip_file_get_comment.c
+++ b/src/Common/libzip/zip_file_get_comment.c
@@ -1,8 +1,8 @@
/*
zip_file_get_comment.c -- get file comment
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_get_external_attributes.c b/src/Common/libzip/zip_file_get_external_attributes.c
index a79bb3ed..483557f0 100644
--- a/src/Common/libzip/zip_file_get_external_attributes.c
+++ b/src/Common/libzip/zip_file_get_external_attributes.c
@@ -1,8 +1,8 @@
/*
zip_file_get_external_attributes.c -- get opsys/external attributes
- Copyright (C) 2013-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2013-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_get_offset.c b/src/Common/libzip/zip_file_get_offset.c
index 72f4880e..c50def54 100644
--- a/src/Common/libzip/zip_file_get_offset.c
+++ b/src/Common/libzip/zip_file_get_offset.c
@@ -1,8 +1,8 @@
/*
zip_file_get_offset.c -- get offset of file data in archive.
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_rename.c b/src/Common/libzip/zip_file_rename.c
index 9ac25814..03101e43 100644
--- a/src/Common/libzip/zip_file_rename.c
+++ b/src/Common/libzip/zip_file_rename.c
@@ -1,8 +1,8 @@
/*
zip_file_rename.c -- rename file in zip archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_replace.c b/src/Common/libzip/zip_file_replace.c
index 4262d453..ce457ed1 100644
--- a/src/Common/libzip/zip_file_replace.c
+++ b/src/Common/libzip/zip_file_replace.c
@@ -1,8 +1,8 @@
/*
zip_file_replace.c -- replace file via callback function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -81,10 +81,16 @@ _zip_file_replace(zip_t *za, zip_uint64_t idx, const char *name, zip_source_t *s
za->nentry = za_nentry_prev;
}
return -1;
}
+ /* delete all extra fields - these are usually data that are
+ * strongly coupled with the original data */
+ if (zip_file_extra_field_delete(za, idx, ZIP_EXTRA_FIELD_ALL, ZIP_FL_CENTRAL | ZIP_FL_LOCAL) < 0) {
+ return -1;
+ }
+
/* does not change any name related data, so we can do it here;
* needed for a double add of the same file name */
_zip_unchange_data(za->entry + idx);
if (za->entry[idx].orig != NULL && (za->entry[idx].changes == NULL || (za->entry[idx].changes->changed & ZIP_DIRENT_COMP_METHOD) == 0)) {
diff --git a/src/Common/libzip/zip_file_set_comment.c b/src/Common/libzip/zip_file_set_comment.c
index 570f8e82..fb7b9edd 100644
--- a/src/Common/libzip/zip_file_set_comment.c
+++ b/src/Common/libzip/zip_file_set_comment.c
@@ -1,8 +1,8 @@
/*
zip_file_set_comment.c -- set comment for file in archive
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_set_encryption.c b/src/Common/libzip/zip_file_set_encryption.c
index 1cdcd4ab..7bb6cdc7 100644
--- a/src/Common/libzip/zip_file_set_encryption.c
+++ b/src/Common/libzip/zip_file_set_encryption.c
@@ -1,8 +1,8 @@
/*
zip_file_set_encryption.c -- set encryption for file in archive
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_set_external_attributes.c b/src/Common/libzip/zip_file_set_external_attributes.c
index 2e0429b8..2f9d30f9 100644
--- a/src/Common/libzip/zip_file_set_external_attributes.c
+++ b/src/Common/libzip/zip_file_set_external_attributes.c
@@ -1,8 +1,8 @@
/*
zip_file_set_external_attributes.c -- set external attributes for entry
- Copyright (C) 2013-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2013-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_file_set_mtime.c b/src/Common/libzip/zip_file_set_mtime.c
index 4126f5a1..e60f7a9a 100644
--- a/src/Common/libzip/zip_file_set_mtime.c
+++ b/src/Common/libzip/zip_file_set_mtime.c
@@ -1,8 +1,8 @@
/*
zip_file_set_mtime.c -- set modification time of entry.
- Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -31,23 +31,16 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "zipint.h"
-ZIP_EXTERN int
-zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
- time_t mtime;
- mtime = _zip_d2u_time(dtime, ddate);
- return zip_file_set_mtime(za, idx, mtime, flags);
-}
-
-ZIP_EXTERN int
-zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
+static int zip_file_set_time(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags, time_t *mtime) {
zip_entry_t *e;
- if (_zip_get_dirent(za, idx, 0, NULL) == NULL)
+ if (_zip_get_dirent(za, idx, 0, NULL) == NULL) {
return -1;
+ }
if (ZIP_IS_RDONLY(za)) {
zip_error_set(&za->error, ZIP_ER_RDONLY, 0);
return -1;
}
@@ -68,10 +61,33 @@ zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags)
zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return -1;
}
}
- e->changes->last_mod = mtime;
+ e->changes->last_mod.time = dtime;
+ e->changes->last_mod.date = ddate;
+ if (mtime != NULL) {
+ e->changes->last_mod_mtime = *mtime;
+ e->changes->last_mod_mtime_valid = true;
+ }
+ else {
+ e->changes->last_mod_mtime_valid = false;
+ }
e->changes->changed |= ZIP_DIRENT_LAST_MOD;
return 0;
}
+
+ZIP_EXTERN int zip_file_set_dostime(zip_t *za, zip_uint64_t idx, zip_uint16_t dtime, zip_uint16_t ddate, zip_flags_t flags) {
+ return zip_file_set_time(za, idx, dtime, ddate, flags, NULL);
+}
+
+
+ZIP_EXTERN int zip_file_set_mtime(zip_t *za, zip_uint64_t idx, time_t mtime, zip_flags_t flags) {
+ zip_dostime_t dostime;
+
+ if (_zip_u2d_time(mtime, &dostime, &za->error) < 0) {
+ return -1;
+ }
+
+ return zip_file_set_time(za, idx, dostime.time, dostime.date, flags, &mtime);
+}
diff --git a/src/Common/libzip/zip_file_strerror.c b/src/Common/libzip/zip_file_strerror.c
index 5b5a0092..5e896b4c 100644
--- a/src/Common/libzip/zip_file_strerror.c
+++ b/src/Common/libzip/zip_file_strerror.c
@@ -1,8 +1,8 @@
/*
zip_file_sterror.c -- get string representation of zip file error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fopen.c b/src/Common/libzip/zip_fopen.c
index e3cde9be..93217f3d 100644
--- a/src/Common/libzip/zip_fopen.c
+++ b/src/Common/libzip/zip_fopen.c
@@ -1,8 +1,8 @@
/*
zip_fopen.c -- open file in zip archive for reading
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fopen_encrypted.c b/src/Common/libzip/zip_fopen_encrypted.c
index d5880dcb..78143afe 100644
--- a/src/Common/libzip/zip_fopen_encrypted.c
+++ b/src/Common/libzip/zip_fopen_encrypted.c
@@ -1,8 +1,8 @@
/*
zip_fopen_encrypted.c -- open file for reading with password
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fopen_index.c b/src/Common/libzip/zip_fopen_index.c
index a449b83a..b6676b7d 100644
--- a/src/Common/libzip/zip_fopen_index.c
+++ b/src/Common/libzip/zip_fopen_index.c
@@ -1,8 +1,8 @@
/*
zip_fopen_index.c -- open file in zip archive for reading by index
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fopen_index_encrypted.c b/src/Common/libzip/zip_fopen_index_encrypted.c
index 40483709..86d69774 100644
--- a/src/Common/libzip/zip_fopen_index_encrypted.c
+++ b/src/Common/libzip/zip_fopen_index_encrypted.c
@@ -1,8 +1,8 @@
/*
zip_fopen_index_encrypted.c -- open file for reading by index w/ password
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_fread.c b/src/Common/libzip/zip_fread.c
index 5b7da46a..17cec4fb 100644
--- a/src/Common/libzip/zip_fread.c
+++ b/src/Common/libzip/zip_fread.c
@@ -1,8 +1,8 @@
/*
zip_fread.c -- read from file
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -37,15 +37,17 @@
ZIP_EXTERN zip_int64_t
zip_fread(zip_file_t *zf, void *outbuf, zip_uint64_t toread) {
zip_int64_t n;
- if (!zf)
+ if (zf == NULL) {
return -1;
+ }
- if (zf->error.zip_err != 0)
+ if (zf->error.zip_err != 0) {
return -1;
+ }
if (toread > ZIP_INT64_MAX) {
zip_error_set(&zf->error, ZIP_ER_INVAL, 0);
return -1;
}
diff --git a/src/Common/libzip/zip_fseek.c b/src/Common/libzip/zip_fseek.c
index e68ffd36..107a6f73 100644
--- a/src/Common/libzip/zip_fseek.c
+++ b/src/Common/libzip/zip_fseek.c
@@ -1,8 +1,8 @@
/*
zip_fseek.c -- seek in file
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2016-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -34,15 +34,17 @@
#include "zipint.h"
ZIP_EXTERN zip_int8_t
zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) {
- if (!zf)
+ if (zf == NULL) {
return -1;
+ }
- if (zf->error.zip_err != 0)
+ if (zf->error.zip_err != 0) {
return -1;
+ }
if (zip_source_seek(zf->src, offset, whence) < 0) {
zip_error_set_from_source(&zf->error, zf->src);
return -1;
}
@@ -51,11 +53,11 @@ zip_fseek(zip_file_t *zf, zip_int64_t offset, int whence) {
}
ZIP_EXTERN int
zip_file_is_seekable(zip_file_t *zfile) {
- if (!zfile) {
+ if (zfile == NULL) {
return -1;
}
return zip_source_is_seekable(zfile->src);
}
diff --git a/src/Common/libzip/zip_ftell.c b/src/Common/libzip/zip_ftell.c
index bf3b03d3..6299b2da 100644
--- a/src/Common/libzip/zip_ftell.c
+++ b/src/Common/libzip/zip_ftell.c
@@ -1,8 +1,8 @@
/*
zip_ftell.c -- tell position in file
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2016-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -36,15 +36,17 @@
ZIP_EXTERN zip_int64_t
zip_ftell(zip_file_t *zf) {
zip_int64_t res;
- if (!zf)
+ if (zf == NULL) {
return -1;
+ }
- if (zf->error.zip_err != 0)
+ if (zf->error.zip_err != 0) {
return -1;
+ }
res = zip_source_tell(zf->src);
if (res < 0) {
zip_error_set_from_source(&zf->error, zf->src);
return -1;
diff --git a/src/Common/libzip/zip_get_archive_comment.c b/src/Common/libzip/zip_get_archive_comment.c
index ea9a00ab..b83e6bcf 100644
--- a/src/Common/libzip/zip_get_archive_comment.c
+++ b/src/Common/libzip/zip_get_archive_comment.c
@@ -1,8 +1,8 @@
/*
zip_get_archive_comment.c -- get archive comment
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_archive_flag.c b/src/Common/libzip/zip_get_archive_flag.c
index fc200bdc..80d59914 100644
--- a/src/Common/libzip/zip_get_archive_flag.c
+++ b/src/Common/libzip/zip_get_archive_flag.c
@@ -1,8 +1,8 @@
/*
zip_get_archive_flag.c -- get archive global flag
- Copyright (C) 2008-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2008-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_encryption_implementation.c b/src/Common/libzip/zip_get_encryption_implementation.c
index 72e48fe8..28ad3297 100644
--- a/src/Common/libzip/zip_get_encryption_implementation.c
+++ b/src/Common/libzip/zip_get_encryption_implementation.c
@@ -1,8 +1,8 @@
/*
zip_get_encryption_implementation.c -- get encryption implementation
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_file_comment.c b/src/Common/libzip/zip_get_file_comment.c
index d58e22ba..0284aecd 100644
--- a/src/Common/libzip/zip_get_file_comment.c
+++ b/src/Common/libzip/zip_get_file_comment.c
@@ -1,8 +1,8 @@
/*
zip_get_file_comment.c -- get file comment
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_name.c b/src/Common/libzip/zip_get_name.c
index 4828d781..d1c94532 100644
--- a/src/Common/libzip/zip_get_name.c
+++ b/src/Common/libzip/zip_get_name.c
@@ -1,8 +1,8 @@
/*
zip_get_name.c -- get filename for a file in zip file
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_num_entries.c b/src/Common/libzip/zip_get_num_entries.c
index 667dc511..b2595dec 100644
--- a/src/Common/libzip/zip_get_num_entries.c
+++ b/src/Common/libzip/zip_get_num_entries.c
@@ -1,8 +1,8 @@
/*
zip_get_num_entries.c -- get number of entries in archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_get_num_files.c b/src/Common/libzip/zip_get_num_files.c
index 140e34f9..16d7754b 100644
--- a/src/Common/libzip/zip_get_num_files.c
+++ b/src/Common/libzip/zip_get_num_files.c
@@ -1,8 +1,8 @@
/*
zip_get_num_files.c -- get number of files in archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_hash.c b/src/Common/libzip/zip_hash.c
index d3a954ec..8479bec1 100644
--- a/src/Common/libzip/zip_hash.c
+++ b/src/Common/libzip/zip_hash.c
@@ -1,8 +1,8 @@
/*
zip_hash.c -- hash table string -> uint64
- Copyright (C) 2015-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2015-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_io_util.c b/src/Common/libzip/zip_io_util.c
index 9fcd10b4..6ae8aac6 100644
--- a/src/Common/libzip/zip_io_util.c
+++ b/src/Common/libzip/zip_io_util.c
@@ -1,8 +1,8 @@
/*
zip_io_util.c -- I/O helper functions
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -67,12 +67,18 @@ _zip_read_data(zip_buffer_t *buffer, zip_source_t *src, size_t length, bool nulp
if (length == 0 && !nulp) {
return NULL;
}
+// VS2022: Workaround an Internal compiler error for Release ARM (32-bit) build.
+#if _MSC_VER >= 1940 && _MSC_VER < 1950 && defined(_M_ARM) && defined(NDEBUG)
+ size_t l = length + (nulp ? 1 : 0);
+ r = (zip_uint8_t *)malloc(l);
+#else
r = (zip_uint8_t *)malloc(length + (nulp ? 1 : 0));
- if (!r) {
+#endif
+ if (r == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return NULL;
}
if (buffer) {
diff --git a/src/Common/libzip/zip_libzip_version.c b/src/Common/libzip/zip_libzip_version.c
index 4200727f..139b250f 100644
--- a/src/Common/libzip/zip_libzip_version.c
+++ b/src/Common/libzip/zip_libzip_version.c
@@ -1,8 +1,8 @@
/*
zip_libzip_version.c -- return run-time version of library
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_memdup.c b/src/Common/libzip/zip_memdup.c
index 75d72c61..6ac9a5a2 100644
--- a/src/Common/libzip/zip_memdup.c
+++ b/src/Common/libzip/zip_memdup.c
@@ -1,8 +1,8 @@
/*
zip_memdup.c -- internal zip function, "strdup" with len
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -43,11 +43,11 @@ _zip_memdup(const void *mem, size_t len, zip_error_t *error) {
if (len == 0)
return NULL;
ret = malloc(len);
- if (!ret) {
+ if (ret == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return NULL;
}
(void)memcpy_s(ret, len, mem, len);
diff --git a/src/Common/libzip/zip_new.c b/src/Common/libzip/zip_new.c
index 4f69c8a2..68e1588f 100644
--- a/src/Common/libzip/zip_new.c
+++ b/src/Common/libzip/zip_new.c
@@ -1,8 +1,8 @@
/*
zip_new.c -- create and init struct zip
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -44,11 +44,11 @@
zip_t *
_zip_new(zip_error_t *error) {
zip_t *za;
za = (zip_t *)malloc(sizeof(struct zip));
- if (!za) {
+ if (za == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return NULL;
}
if ((za->names = _zip_hash_new(error)) == NULL) {
@@ -66,8 +66,9 @@ _zip_new(zip_error_t *error) {
za->nentry = za->nentry_alloc = 0;
za->entry = NULL;
za->nopen_source = za->nopen_source_alloc = 0;
za->open_source = NULL;
za->progress = NULL;
+ za->torrent_mtime = 0;
return za;
}
diff --git a/src/Common/libzip/zip_open.c b/src/Common/libzip/zip_open.c
index ee7e9dec..9dccad61 100644
--- a/src/Common/libzip/zip_open.c
+++ b/src/Common/libzip/zip_open.c
@@ -1,8 +1,8 @@
/*
zip_open.c -- open zip archive by name
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -29,29 +29,41 @@
IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "zipint.h"
-typedef enum { EXISTS_ERROR = -1, EXISTS_NOT = 0, EXISTS_OK } exists_t;
+typedef enum {
+ EXISTS_ERROR = -1,
+ EXISTS_NOT = 0,
+ EXISTS_OK
+} exists_t;
+typedef enum {
+ CDIR_OK,
+ CDIR_INVALID,
+ CDIR_NOT_FOUND
+
+} cdir_status_t;
+
+static bool check_eocd(zip_cdir_t *cd, unsigned int flags, zip_error_t *error);
+static bool check_magic(zip_uint64_t offset, zip_buffer_t *buffer, zip_uint64_t buffer_offset, zip_source_t *src, const char* magic);
static zip_t *_zip_allocate_new(zip_source_t *src, unsigned int flags, zip_error_t *error);
static zip_int64_t _zip_checkcons(zip_t *za, zip_cdir_t *cdir, zip_error_t *error);
static void zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir);
static zip_cdir_t *_zip_find_central_dir(zip_t *za, zip_uint64_t len);
static exists_t _zip_file_exists(zip_source_t *src, zip_error_t *error);
static int _zip_headercomp(const zip_dirent_t *, const zip_dirent_t *);
-static const unsigned char *_zip_memmem(const unsigned char *, size_t, const unsigned char *, size_t);
-static zip_cdir_t *_zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error);
-static zip_cdir_t *_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error);
-static zip_cdir_t *_zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error);
+static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_cdir_t **cdirp, zip_error_t *error);
+static zip_cdir_t *_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error);
+static cdir_status_t _zip_read_eocd64(zip_cdir_t *cdir, zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error);
+static const unsigned char *find_eocd(zip_buffer_t *buffer, const unsigned char *last);
ZIP_EXTERN zip_t *
zip_open(const char *fn, int _flags, int *zep) {
zip_t *za;
@@ -142,10 +154,31 @@ zip_open_from_source(zip_source_t *src, int _flags, zip_error_t *error) {
}
}
}
+static bool
+_is_truncated_zip(zip_source_t *src) {
+ unsigned char data[4];
+ /* check if the source is a truncated zip archive: true if yes, no
+ if not or can't be determined */
+ if (zip_source_seek(src, 0, SEEK_SET) < 0) {
+ return false;
+ }
+
+ if (zip_source_read(src, data, 4) != 4) {
+ return false;
+ }
+
+ if (memcmp(data, LOCAL_MAGIC, 4) == 0) {
+ /* file starts with a ZIP local header signature */
+ return true;
+ }
+ return false;
+}
+
+
zip_t *
_zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) {
zip_t *za;
zip_cdir_t *cdir;
struct zip_stat st;
@@ -172,10 +205,16 @@ _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) {
return za;
}
if ((cdir = _zip_find_central_dir(za, len)) == NULL) {
_zip_error_copy(error, &za->error);
+ if (zip_error_code_zip(error) == ZIP_ER_NOZIP) {
+ /* not a zip - find out if it's truncated */
+ if (_is_truncated_zip(src)) {
+ zip_error_set(error, ZIP_ER_TRUNCATED_ZIP, 0);
+ }
+ }
/* keep src so discard does not get rid of it */
zip_source_keep(src);
zip_discard(za);
return NULL;
}
@@ -226,18 +265,18 @@ _zip_open(zip_source_t *src, unsigned int flags, zip_error_t *error) {
void
_zip_set_open_error(int *zep, const zip_error_t *err, int ze) {
if (err) {
ze = zip_error_code_zip(err);
- switch (zip_error_system_type(err)) {
- case ZIP_ET_SYS:
- case ZIP_ET_LIBZIP:
- errno = zip_error_code_system(err);
- break;
-
- default:
- break;
+ switch (zip_error_system_type(err)) {
+ case ZIP_ET_SYS:
+ case ZIP_ET_LIBZIP:
+ errno = zip_error_code_system(err);
+ break;
+
+ default:
+ break;
}
}
if (zep)
*zep = ze;
@@ -248,68 +287,103 @@ _zip_set_open_error(int *zep, const zip_error_t *err, int ze) {
tries to find a valid end-of-central-directory at the beginning of
buf, and then the corresponding central directory entries.
Returns a struct zip_cdir which contains the central directory
entries, or NULL if unsuccessful. */
-static zip_cdir_t *
-_zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error) {
+static bool _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_cdir_t **cdirp, zip_error_t *error) {
zip_cdir_t *cd;
zip_uint16_t comment_len;
zip_uint64_t i, left;
zip_uint64_t eocd_offset = _zip_buffer_offset(buffer);
zip_buffer_t *cd_buffer;
+ bool eocd64_found = false;
- if (_zip_buffer_left(buffer) < EOCDLEN) {
- /* not enough bytes left for comment */
- zip_error_set(error, ZIP_ER_NOZIP, 0);
- return NULL;
- }
+ *cdirp = NULL;
- /* check for end-of-central-dir magic */
- if (memcmp(_zip_buffer_get(buffer, 4), EOCD_MAGIC, 4) != 0) {
- zip_error_set(error, ZIP_ER_NOZIP, 0);
- return NULL;
+ if ((cd = _zip_read_eocd(buffer, buf_offset, error)) == NULL) {
+ return false;
}
if (eocd_offset >= EOCD64LOCLEN && memcmp(_zip_buffer_data(buffer) + eocd_offset - EOCD64LOCLEN, EOCD64LOC_MAGIC, 4) == 0) {
+ eocd64_found = true;
_zip_buffer_set_offset(buffer, eocd_offset - EOCD64LOCLEN);
- cd = _zip_read_eocd64(za->src, buffer, buf_offset, za->flags, error);
+ switch (_zip_read_eocd64(cd, za->src, buffer, buf_offset, za->flags, error)) {
+ case CDIR_OK:
+ break;
+
+ case CDIR_INVALID:
+ _zip_cdir_free(cd);
+ return true;
+
+ case CDIR_NOT_FOUND:
+ _zip_cdir_free(cd);
+ return false;
+ }
}
- else {
- _zip_buffer_set_offset(buffer, eocd_offset);
- cd = _zip_read_eocd(buffer, buf_offset, za->flags, error);
+
+ if ((cd->eocd_disk != 0 || cd->this_disk != 0) && !eocd64_found && cd->eocd_disk != cd->this_disk) {
+ /* If the central directory doesn't start on this disk, we can't check that offset is valid. Check as much as we can instead. */
+ if (cd->this_disk < cd->eocd_disk) {
+ /* Disks before the start of the central directory don't contain an EOCD. */
+ _zip_cdir_free(cd);
+ return false;
+ }
+ if (cd->size <= cd->eocd_offset) {
+ /* The complete central directory would fit on this disk. */
+ _zip_cdir_free(cd);
+ return false;
+ }
}
- if (cd == NULL)
- return NULL;
+ if (!eocd64_found) {
+ if (cd->this_disk == 0 && cd->eocd_disk == 0 && cd->eocd_offset == 0 && cd->offset == 0 && cd->num_entries == 0) {
+ /* An empty archive doesn't contain central directory entries. */
+ }
+ else if (!check_magic(cd->offset, buffer, buf_offset, za->src, CENTRAL_MAGIC)) {
+ _zip_cdir_free(cd);
+ return false;
+ }
+ }
+
+ /* We accept this EOCD as valid and won't search for an earlier one if it is unusable. */
+
+ if (!check_eocd(cd, za->flags, error)) {
+ _zip_cdir_free(cd);
+ return true;
+ }
_zip_buffer_set_offset(buffer, eocd_offset + 20);
comment_len = _zip_buffer_get_16(buffer);
if (cd->offset + cd->size > buf_offset + eocd_offset) {
/* cdir spans past EOCD record */
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
if (comment_len || (za->open_flags & ZIP_CHECKCONS)) {
zip_uint64_t tail_len;
_zip_buffer_set_offset(buffer, eocd_offset + EOCDLEN);
tail_len = _zip_buffer_left(buffer);
- if (tail_len < comment_len || ((za->open_flags & ZIP_CHECKCONS) && tail_len != comment_len)) {
- zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_COMMENT_LENGTH_INVALID);
- _zip_cdir_free(cd);
- return NULL;
+ if (tail_len != comment_len) {
+ if (za->open_flags & ZIP_CHECKCONS) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_COMMENT_LENGTH_INVALID);
+ _zip_cdir_free(cd);
+ return true;
+ }
+ if (tail_len < comment_len) {
+ comment_len = tail_len;
+ }
}
if (comment_len) {
if ((cd->comment = _zip_string_new(_zip_buffer_get(buffer, comment_len), comment_len, ZIP_FL_ENC_GUESS, error)) == NULL) {
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
}
}
if (cd->offset >= buf_offset) {
@@ -318,35 +392,40 @@ _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_err
_zip_buffer_set_offset(buffer, cd->offset - buf_offset);
if ((data = _zip_buffer_get(buffer, cd->size)) == NULL) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
if ((cd_buffer = _zip_buffer_new(data, cd->size)) == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
}
else {
cd_buffer = NULL;
if (zip_source_seek(za->src, (zip_int64_t)cd->offset, SEEK_SET) < 0) {
zip_error_set_from_source(error, za->src);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
/* possible consistency check: cd->offset = len-(cd->size+cd->comment_len+EOCDLEN) ? */
if (zip_source_tell(za->src) != (zip_int64_t)cd->offset) {
zip_error_set(error, ZIP_ER_NOZIP, 0);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
}
+ if (!_zip_cdir_grow(cd, cd->num_entries, error)) {
+ _zip_cdir_free(cd);
+ _zip_buffer_free(cd_buffer);
+ return true;
+ }
left = (zip_uint64_t)cd->size;
i = 0;
while (left > 0) {
bool grown = false;
zip_int64_t entry_size;
@@ -360,35 +439,36 @@ _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_err
}
if (!_zip_cdir_grow(cd, 0x10000, error)) {
_zip_cdir_free(cd);
_zip_buffer_free(cd_buffer);
- return NULL;
+ return true;
}
grown = true;
}
- if ((cd->entry[i].orig = _zip_dirent_new()) == NULL || (entry_size = _zip_dirent_read(cd->entry[i].orig, za->src, cd_buffer, false, error)) < 0) {
- if (zip_error_code_zip(error) == ZIP_ER_INCONS) {
- zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i));
- }
- else if (grown && zip_error_code_zip(error) == ZIP_ER_NOZIP) {
+ if ((cd->entry[i].orig = _zip_dirent_new()) == NULL || (entry_size = _zip_dirent_read(cd->entry[i].orig, za->src, cd_buffer, false, 0, za->open_flags & ZIP_CHECKCONS, error)) < 0) {
+ if (zip_error_code_zip(error) == ZIP_ER_INCONS) {
+ zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i));
+ }
+ else if (grown && zip_error_code_zip(error) == ZIP_ER_NOZIP) {
zip_error_set(error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(ZIP_ER_DETAIL_CDIR_ENTRY_INVALID, i));
}
_zip_cdir_free(cd);
_zip_buffer_free(cd_buffer);
- return NULL;
+ return true;
}
i++;
left -= (zip_uint64_t)entry_size;
}
+ /* If we didn't fill all we grew, cd->num_entries was wrong. */
if (i != cd->nentry || left > 0) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_WRONG_ENTRIES_COUNT);
_zip_buffer_free(cd_buffer);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
if (za->open_flags & ZIP_CHECKCONS) {
bool ok;
@@ -399,25 +479,45 @@ _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_err
zip_int64_t offset = zip_source_tell(za->src);
if (offset < 0) {
zip_error_set_from_source(error, za->src);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
ok = ((zip_uint64_t)offset == cd->offset + cd->size);
}
if (!ok) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID);
_zip_buffer_free(cd_buffer);
_zip_cdir_free(cd);
- return NULL;
+ return true;
}
}
_zip_buffer_free(cd_buffer);
- return cd;
+ *cdirp = cd;
+ return true;
+}
+
+
+static bool check_magic(zip_uint64_t offset, zip_buffer_t *buffer, zip_uint64_t buffer_offset, zip_source_t *src, const char* magic) {
+ if (buffer_offset <= offset) {
+ zip_uint8_t* data;
+ if (_zip_buffer_set_offset(buffer, offset - buffer_offset) < 0 || (data = _zip_buffer_get(buffer, MAGIC_LEN)) == NULL) {
+ return false;
+ }
+ return memcmp(data, magic, MAGIC_LEN) == 0;
+ }
+ else {
+ zip_uint8_t data[MAGIC_LEN];
+
+ if (zip_source_seek(src, offset, SEEK_SET) < 0 || zip_source_read(src, data, MAGIC_LEN) != MAGIC_LEN) {
+ return false;
+ }
+ return memcmp(data, magic, MAGIC_LEN) == 0;
+ }
}
/* _zip_checkcons:
Checks the consistency of the central directory by comparing central
@@ -428,10 +528,11 @@ _zip_read_cdir(zip_t *za, zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_err
static zip_int64_t
_zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error) {
zip_uint64_t i;
zip_uint64_t min, max, j;
struct zip_dirent temp;
+ int detail;
_zip_dirent_init(&temp);
if (cd->nentry) {
max = cd->entry[0].orig->offset;
min = cd->entry[0].orig->offset;
@@ -458,14 +559,14 @@ _zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error) {
if (zip_source_seek(za->src, (zip_int64_t)cd->entry[i].orig->offset, SEEK_SET) < 0) {
zip_error_set_from_source(error, za->src);
return -1;
}
- if (_zip_dirent_read(&temp, za->src, NULL, true, error) == -1) {
- if (zip_error_code_zip(error) == ZIP_ER_INCONS) {
- zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i));
- }
+ if (_zip_dirent_read(&temp, za->src, NULL, true, cd->entry[i].orig->comp_size, true, error) == -1) {
+ if (zip_error_code_zip(error) == ZIP_ER_INCONS) {
+ zip_error_set(error, ZIP_ER_INCONS, ADD_INDEX_TO_DETAIL(zip_error_code_system(error), i));
+ }
_zip_dirent_finalize(&temp);
return -1;
}
if (_zip_headercomp(cd->entry[i].orig, &temp) != 0) {
@@ -477,10 +578,15 @@ _zip_checkcons(zip_t *za, zip_cdir_t *cd, zip_error_t *error) {
cd->entry[i].orig->extra_fields = _zip_ef_merge(cd->entry[i].orig->extra_fields, temp.extra_fields);
cd->entry[i].orig->local_extra_fields_read = 1;
temp.extra_fields = NULL;
_zip_dirent_finalize(&temp);
+
+ if ((detail = zip_dirent_check_consistency(cd->entry[i].orig)) != 0) {
+ zip_error_set(error, ZIP_ER_INCONS, MAKE_DETAIL_WITH_INDEX(detail, i));
+ return -1;
+ }
}
return (max - min) < ZIP_INT64_MAX ? (zip_int64_t)(max - min) : ZIP_INT64_MAX;
}
@@ -495,29 +601,27 @@ _zip_headercomp(const zip_dirent_t *central, const zip_dirent_t *local) {
#if 0
/* some zip-files have different values in local
and global headers for the bitflags */
|| (central->bitflags != local->bitflags)
#endif
- || (central->comp_method != local->comp_method) || (central->last_mod != local->last_mod) || !_zip_string_equal(central->filename, local->filename))
+ || (central->comp_method != local->comp_method) || (central->last_mod.time != local->last_mod.time) || (central->last_mod.date != local->last_mod.date) || !_zip_string_equal(central->filename, local->filename))
return -1;
if ((central->crc != local->crc) || (central->comp_size != local->comp_size) || (central->uncomp_size != local->uncomp_size)) {
/* InfoZip stores valid values in local header even when data descriptor is used.
This is in violation of the appnote.
- macOS Archive sets the compressed size even when data descriptor is used ( but not the others),
- also in violation of the appnote.
- */
- /* if data descriptor is not used, the values must match */
+ macOS Archive sets the compressed size even when data descriptor is used ( but not the others),
+ also in violation of the appnote.
+ */
+ /* if data descriptor is not used, the values must match */
if ((local->bitflags & ZIP_GPBF_DATA_DESCRIPTOR) == 0) {
return -1;
- }
- /* when using a data descriptor, the local header value must be zero or match */
- if ((local->crc != 0 && central->crc != local->crc) ||
- (local->comp_size != 0 && central->comp_size != local->comp_size) ||
- (local->uncomp_size != 0 && central->uncomp_size != local->uncomp_size)) {
- return -1;
- }
+ }
+ /* when using a data descriptor, the local header value must be zero or match */
+ if ((local->crc != 0 && central->crc != local->crc) || (local->comp_size != 0 && central->comp_size != local->comp_size) || (local->uncomp_size != 0 && central->uncomp_size != local->uncomp_size)) {
+ return -1;
+ }
}
return 0;
}
@@ -566,16 +670,14 @@ _zip_file_exists(zip_source_t *src, zip_error_t *error) {
}
static zip_cdir_t *
_zip_find_central_dir(zip_t *za, zip_uint64_t len) {
- zip_cdir_t *cdir, *cdirnew;
+ zip_cdir_t *cdir;
const zip_uint8_t *match;
zip_int64_t buf_offset;
zip_uint64_t buflen;
- zip_int64_t a;
- zip_int64_t best;
zip_error_t error;
zip_buffer_t *buffer;
if (len < EOCDLEN) {
zip_error_set(&za->error, ZIP_ER_NOZIP, 0);
@@ -598,201 +700,174 @@ _zip_find_central_dir(zip_t *za, zip_uint64_t len) {
if ((buffer = _zip_buffer_new_from_source(za->src, buflen, NULL, &za->error)) == NULL) {
return NULL;
}
- best = -1;
cdir = NULL;
if (buflen >= CDBUFSIZE) {
/* EOCD64 locator is before EOCD, so leave place for it */
_zip_buffer_set_offset(buffer, EOCD64LOCLEN);
}
zip_error_set(&error, ZIP_ER_NOZIP, 0);
- match = _zip_buffer_get(buffer, 0);
- /* The size of buffer never greater than CDBUFSIZE. */
- while (_zip_buffer_left(buffer) >= EOCDLEN && (match = _zip_memmem(match, (size_t)_zip_buffer_left(buffer) - (EOCDLEN - 4), (const unsigned char *)EOCD_MAGIC, 4)) != NULL) {
+ match = NULL;
+ while ((match = find_eocd(buffer, match)) != NULL) {
_zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer)));
- if ((cdirnew = _zip_read_cdir(za, buffer, (zip_uint64_t)buf_offset, &error)) != NULL) {
- if (cdir) {
- if (best <= 0) {
- best = _zip_checkcons(za, cdir, &error);
- }
-
- a = _zip_checkcons(za, cdirnew, &error);
- if (best < a) {
- _zip_cdir_free(cdir);
- cdir = cdirnew;
- best = a;
- }
- else {
- _zip_cdir_free(cdirnew);
- }
+ if (_zip_read_cdir(za, buffer, (zip_uint64_t)buf_offset, &cdir, &error)) {
+ if (cdir != NULL && (za->open_flags & ZIP_CHECKCONS) && _zip_checkcons(za, cdir, &error) < 0) {
+ _zip_cdir_free(cdir);
+ cdir = NULL;
}
- else {
- cdir = cdirnew;
- if (za->open_flags & ZIP_CHECKCONS)
- best = _zip_checkcons(za, cdir, &error);
- else {
- best = 0;
- }
- }
- cdirnew = NULL;
+ break;
}
-
- match++;
- _zip_buffer_set_offset(buffer, (zip_uint64_t)(match - _zip_buffer_data(buffer)));
}
_zip_buffer_free(buffer);
- if (best < 0) {
+ if (cdir == NULL) {
_zip_error_copy(&za->error, &error);
- _zip_cdir_free(cdir);
- return NULL;
}
-
return cdir;
}
-static const unsigned char *_zip_memmem(const unsigned char *big, size_t biglen, const unsigned char *little, size_t littlelen) {
+static const unsigned char *
+find_eocd(zip_buffer_t *buffer, const unsigned char *last) {
+ const unsigned char *data = _zip_buffer_data(buffer);
const unsigned char *p;
- if (littlelen == 0) {
- return big;
+ if (last == NULL) {
+ last = data + _zip_buffer_size(buffer) - MAGIC_LEN;
}
-
- if (biglen < littlelen) {
+ else if (last == _zip_buffer_data(buffer)) {
return NULL;
}
+ else {
+ last -= 1;
+ }
- p = big;
- while (true) {
- p = (const unsigned char *)memchr(p, little[0], biglen - (littlelen - 1) - (size_t)(p - big));
- if (p == NULL) {
- return NULL;
- }
- if (memcmp(p + 1, little + 1, littlelen - 1) == 0) {
- return p;
+ for (p = last; p >= data; p -= 1) {
+ if (*p == EOCD_MAGIC[0]) {
+ if (memcmp(p, EOCD_MAGIC, MAGIC_LEN) == 0) {
+ return p;
+ }
}
- p += 1;
}
+
+ return NULL;
}
static zip_cdir_t *
-_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) {
+_zip_read_eocd(zip_buffer_t *buffer, zip_uint64_t buf_offset, zip_error_t *error) {
zip_cdir_t *cd;
- zip_uint64_t i, nentry, size, offset, eocd_offset;
if (_zip_buffer_left(buffer) < EOCDLEN) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD_LENGTH_INVALID);
return NULL;
}
- eocd_offset = _zip_buffer_offset(buffer);
-
- _zip_buffer_get(buffer, 4); /* magic already verified */
-
- if (_zip_buffer_get_32(buffer) != 0) {
- zip_error_set(error, ZIP_ER_MULTIDISK, 0);
+ if ((cd = _zip_cdir_new(error)) == NULL) {
return NULL;
}
+ cd->eocd_offset = buf_offset + _zip_buffer_offset(buffer);
+ /* This function is only called where EOCD magic was found, so no need to check that here. */
+ _zip_buffer_skip(buffer, MAGIC_LEN);
+ cd->is_zip64 = false;
+ cd->this_disk = _zip_buffer_get_16(buffer);
+ cd->eocd_disk = _zip_buffer_get_16(buffer);
+
/* number of cdir-entries on this disk */
- i = _zip_buffer_get_16(buffer);
+ cd->disk_entries = _zip_buffer_get_16(buffer);
/* number of cdir-entries */
- nentry = _zip_buffer_get_16(buffer);
-
- if (nentry != i) {
- zip_error_set(error, ZIP_ER_NOZIP, 0);
- return NULL;
- }
+ cd->num_entries = _zip_buffer_get_16(buffer);
+ cd->size = _zip_buffer_get_32(buffer);
+ cd->offset = _zip_buffer_get_32(buffer);
- size = _zip_buffer_get_32(buffer);
- offset = _zip_buffer_get_32(buffer);
+ return cd;
+}
- if (offset + size < offset) {
- zip_error_set(error, ZIP_ER_SEEK, EFBIG);
- return NULL;
+static bool
+check_eocd(zip_cdir_t *cd, unsigned int flags, zip_error_t *error) {
+ if (cd->disk_entries != cd->num_entries || cd->this_disk != 0 || cd->eocd_disk != 0) {
+ zip_error_set(error, ZIP_ER_MULTIDISK, 0);
+ return false;
}
- if (offset + size > buf_offset + eocd_offset) {
- /* cdir spans past EOCD record */
- zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD);
- return NULL;
+ if (cd->offset + cd->size < cd->offset) {
+ zip_error_set(error, ZIP_ER_SEEK, EFBIG);
+ return false;
}
-
- if ((flags & ZIP_CHECKCONS) && offset + size != buf_offset + eocd_offset) {
+ if ((flags & ZIP_CHECKCONS) && cd->offset + cd->size != cd->eocd_offset) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_LENGTH_INVALID);
- return NULL;
+ return false;
}
- if ((cd = _zip_cdir_new(nentry, error)) == NULL)
- return NULL;
-
- cd->is_zip64 = false;
- cd->size = size;
- cd->offset = offset;
-
- return cd;
+ return true;
}
-static zip_cdir_t *
-_zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) {
- zip_cdir_t *cd;
+cdir_status_t _zip_read_eocd64(zip_cdir_t *cdir, zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offset, unsigned int flags, zip_error_t *error) {
zip_uint64_t offset;
zip_uint8_t eocd[EOCD64LEN];
zip_uint64_t eocd_offset;
zip_uint64_t size, nentry, i, eocdloc_offset;
bool free_buffer;
- zip_uint32_t num_disks, num_disks64, eocd_disk, eocd_disk64;
+ zip_uint32_t num_disks, eocd_disk, this_disk;
eocdloc_offset = _zip_buffer_offset(buffer);
_zip_buffer_get(buffer, 4); /* magic already verified */
- num_disks = _zip_buffer_get_16(buffer);
- eocd_disk = _zip_buffer_get_16(buffer);
+ eocd_disk = _zip_buffer_get_32(buffer);
eocd_offset = _zip_buffer_get_64(buffer);
+ num_disks = _zip_buffer_get_32(buffer);
+
+ if (!check_magic(eocd_offset, buffer, buf_offset, src, EOCD64_MAGIC)) {
+ return CDIR_NOT_FOUND;
+ }
+
+ if (num_disks != 1) {
+ zip_error_set(error, ZIP_ER_MULTIDISK, 0);
+ return CDIR_INVALID;
+ }
/* valid seek value for start of EOCD */
if (eocd_offset > ZIP_INT64_MAX) {
zip_error_set(error, ZIP_ER_SEEK, EFBIG);
- return NULL;
+ return CDIR_INVALID;
}
/* does EOCD fit before EOCD locator? */
if (eocd_offset + EOCD64LEN > eocdloc_offset + buf_offset) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_OVERLAPS_EOCD);
- return NULL;
+ return CDIR_INVALID;
}
/* make sure current position of buffer is beginning of EOCD */
if (eocd_offset >= buf_offset && eocd_offset + EOCD64LEN <= buf_offset + _zip_buffer_size(buffer)) {
_zip_buffer_set_offset(buffer, eocd_offset - buf_offset);
free_buffer = false;
}
else {
if (zip_source_seek(src, (zip_int64_t)eocd_offset, SEEK_SET) < 0) {
zip_error_set_from_source(error, src);
- return NULL;
+ return CDIR_INVALID;
}
if ((buffer = _zip_buffer_new_from_source(src, EOCD64LEN, eocd, error)) == NULL) {
- return NULL;
+ return CDIR_INVALID;
}
free_buffer = true;
}
if (memcmp(_zip_buffer_get(buffer, 4), EOCD64_MAGIC, 4) != 0) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_WRONG_MAGIC);
if (free_buffer) {
_zip_buffer_free(buffer);
}
- return NULL;
+ return CDIR_INVALID;
}
/* size of EOCD */
size = _zip_buffer_get_64(buffer);
@@ -800,51 +875,33 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
if ((flags & ZIP_CHECKCONS) && size + eocd_offset + 12 != buf_offset + eocdloc_offset) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_OVERLAPS_EOCD);
if (free_buffer) {
_zip_buffer_free(buffer);
}
- return NULL;
+ return CDIR_INVALID;
}
_zip_buffer_get(buffer, 4); /* skip version made by/needed */
- num_disks64 = _zip_buffer_get_32(buffer);
- eocd_disk64 = _zip_buffer_get_32(buffer);
-
- /* if eocd values are 0xffff, we have to use eocd64 values.
- otherwise, if the values are not the same, it's inconsistent;
- in any case, if the value is not 0, we don't support it */
- if (num_disks == 0xffff) {
- num_disks = num_disks64;
- }
- if (eocd_disk == 0xffff) {
- eocd_disk = eocd_disk64;
- }
- if ((flags & ZIP_CHECKCONS) && (eocd_disk != eocd_disk64 || num_disks != num_disks64)) {
- zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_MISMATCH);
+ this_disk = _zip_buffer_get_32(buffer);
+ if (_zip_buffer_get_32(buffer) != eocd_disk) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_LOCATOR_MISMATCH);
if (free_buffer) {
_zip_buffer_free(buffer);
}
- return NULL;
- }
- if (num_disks != 0 || eocd_disk != 0) {
- zip_error_set(error, ZIP_ER_MULTIDISK, 0);
- if (free_buffer) {
- _zip_buffer_free(buffer);
- }
- return NULL;
+ return CDIR_INVALID;
}
- nentry = _zip_buffer_get_64(buffer);
i = _zip_buffer_get_64(buffer);
+ nentry = _zip_buffer_get_64(buffer);
if (nentry != i) {
zip_error_set(error, ZIP_ER_MULTIDISK, 0);
if (free_buffer) {
_zip_buffer_free(buffer);
}
- return NULL;
+ return CDIR_INVALID;
}
size = _zip_buffer_get_64(buffer);
offset = _zip_buffer_get_64(buffer);
@@ -852,48 +909,46 @@ _zip_read_eocd64(zip_source_t *src, zip_buffer_t *buffer, zip_uint64_t buf_offse
if (!_zip_buffer_ok(buffer)) {
zip_error_set(error, ZIP_ER_INTERNAL, 0);
if (free_buffer) {
_zip_buffer_free(buffer);
}
- return NULL;
+ return CDIR_INVALID;
}
if (free_buffer) {
_zip_buffer_free(buffer);
}
if (offset > ZIP_INT64_MAX || offset + size < offset) {
zip_error_set(error, ZIP_ER_SEEK, EFBIG);
- return NULL;
- }
- if (offset + size > buf_offset + eocd_offset) {
- /* cdir spans past EOCD record */
- zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD);
- return NULL;
- }
- if ((flags & ZIP_CHECKCONS) && offset + size != buf_offset + eocd_offset) {
- zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_OVERLAPS_EOCD);
- return NULL;
+ return CDIR_INVALID;
}
if (nentry > size / CDENTRYSIZE) {
zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_CDIR_INVALID);
- return NULL;
+ return CDIR_INVALID;
}
- if ((cd = _zip_cdir_new(nentry, error)) == NULL)
- return NULL;
+ if ((cdir->size != 0xffffffff && cdir->size != size) || (cdir->offset != 0xffffffff && cdir->offset != offset) || (cdir->num_entries != 0xffff && cdir->num_entries != nentry) || (cdir->disk_entries != 0xffff && cdir->disk_entries != i) || (cdir->this_disk != 0xffff && cdir->this_disk != this_disk) || (cdir->eocd_disk != 0xffff && cdir->eocd_disk != eocd_disk)) {
+ zip_error_set(error, ZIP_ER_INCONS, ZIP_ER_DETAIL_EOCD64_MISMATCH);
+ return CDIR_INVALID;
+ }
- cd->is_zip64 = true;
- cd->size = size;
- cd->offset = offset;
+ cdir->is_zip64 = true;
+ cdir->size = size;
+ cdir->offset = offset;
+ cdir->disk_entries = i;
+ cdir->num_entries = nentry;
+ cdir->this_disk = this_disk;
+ cdir->eocd_disk = eocd_disk;
- return cd;
+ return CDIR_OK;
}
-static int decode_hex(char c) {
+static int
+decode_hex(char c) {
if (c >= '0' && c <= '9') {
return c - '0';
}
else if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
@@ -904,21 +959,21 @@ static int decode_hex(char c) {
}
/* _zip_check_torrentzip:
check whether ZA has a valid TORRENTZIP comment, i.e. is torrentzipped */
-static void zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir) {
+static void
+zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir) {
zip_uint32_t crc_should;
- char buf[8+1];
+ char buf[8 + 1];
size_t i;
if (cdir == NULL) {
return;
}
- if (_zip_string_length(cdir->comment) != TORRENTZIP_SIGNATURE_LENGTH + TORRENTZIP_CRC_LENGTH
- || strncmp((const char *)cdir->comment->raw, TORRENTZIP_SIGNATURE, TORRENTZIP_SIGNATURE_LENGTH) != 0)
+ if (_zip_string_length(cdir->comment) != TORRENTZIP_SIGNATURE_LENGTH + TORRENTZIP_CRC_LENGTH || strncmp((const char *)cdir->comment->raw, TORRENTZIP_SIGNATURE, TORRENTZIP_SIGNATURE_LENGTH) != 0)
return;
memcpy(buf, cdir->comment->raw + TORRENTZIP_SIGNATURE_LENGTH, TORRENTZIP_CRC_LENGTH);
buf[TORRENTZIP_CRC_LENGTH] = '\0';
crc_should = 0;
@@ -932,20 +987,20 @@ static void zip_check_torrentzip(zip_t *za, const zip_cdir_t *cdir) {
crc_should = (crc_should << 8) + (high << 4) + low;
}
{
zip_stat_t st;
- zip_source_t* src_window;
- zip_source_t* src_crc;
+ zip_source_t *src_window;
+ zip_source_t *src_crc;
zip_uint8_t buffer[512];
zip_int64_t ret;
zip_stat_init(&st);
st.valid |= ZIP_STAT_SIZE | ZIP_STAT_CRC;
st.size = cdir->size;
st.crc = crc_should;
- if ((src_window = _zip_source_window_new(za->src, cdir->offset, cdir->size, &st, 0, NULL, NULL, 0, false, NULL)) == NULL) {
+ if ((src_window = _zip_source_window_new(za->src, cdir->offset, cdir->size, &st, 0, NULL, NULL, NULL, 0, false, NULL)) == NULL) {
return;
}
if ((src_crc = zip_source_crc_create(src_window, 1, NULL)) == NULL) {
zip_source_free(src_window);
return;
diff --git a/src/Common/libzip/zip_pkware.c b/src/Common/libzip/zip_pkware.c
index 6a8c9fcd..ef3a30bb 100644
--- a/src/Common/libzip/zip_pkware.c
+++ b/src/Common/libzip/zip_pkware.c
@@ -1,8 +1,8 @@
/*
zip_pkware.c -- Traditional PKWARE de/encryption backend routines
- Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_progress.c b/src/Common/libzip/zip_progress.c
index e080514b..5693d7a5 100644
--- a/src/Common/libzip/zip_progress.c
+++ b/src/Common/libzip/zip_progress.c
@@ -1,8 +1,8 @@
/*
zip_progress.c -- progress reporting
- Copyright (C) 2017-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -189,11 +189,11 @@ _zip_progress_update(zip_progress_t *progress, double sub_current) {
}
if (progress->callback_progress != NULL) {
current = ZIP_MIN(ZIP_MAX(sub_current, 0.0), 1.0) * (progress->end - progress->start) + progress->start;
- if (current - progress->last_update > progress->precision) {
+ if (current - progress->last_update > progress->precision || (progress->last_update < 1 && current == 1)) {
progress->callback_progress(progress->za, current, progress->ud_progress);
progress->last_update = current;
}
}
diff --git a/src/Common/libzip/zip_random_unix.c b/src/Common/libzip/zip_random_unix.c
index 867df790..9446ca92 100644
--- a/src/Common/libzip/zip_random_unix.c
+++ b/src/Common/libzip/zip_random_unix.c
@@ -1,8 +1,8 @@
/*
zip_random_unix.c -- fill the user's buffer with random stuff (Unix version)
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_random_uwp.c b/src/Common/libzip/zip_random_uwp.c
index 0883ce45..7accdeb2 100644
--- a/src/Common/libzip/zip_random_uwp.c
+++ b/src/Common/libzip/zip_random_uwp.c
@@ -1,8 +1,8 @@
/*
zip_random_uwp.c -- fill the user's buffer with random stuff (UWP version)
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_random_win32.c b/src/Common/libzip/zip_random_win32.c
index 789b9c20..209ca4b8 100644
--- a/src/Common/libzip/zip_random_win32.c
+++ b/src/Common/libzip/zip_random_win32.c
@@ -1,8 +1,8 @@
/*
zip_random_win32.c -- fill the user's buffer with random stuff (Windows version)
- Copyright (C) 2016-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2016-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_rename.c b/src/Common/libzip/zip_rename.c
index c89b06c9..b356de45 100644
--- a/src/Common/libzip/zip_rename.c
+++ b/src/Common/libzip/zip_rename.c
@@ -1,8 +1,8 @@
/*
zip_rename.c -- rename file in zip archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_replace.c b/src/Common/libzip/zip_replace.c
index 96c083c3..549306a0 100644
--- a/src/Common/libzip/zip_replace.c
+++ b/src/Common/libzip/zip_replace.c
@@ -1,8 +1,8 @@
/*
zip_replace.c -- replace file via callback function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_archive_comment.c b/src/Common/libzip/zip_set_archive_comment.c
index 7d06688e..2c75bda6 100644
--- a/src/Common/libzip/zip_set_archive_comment.c
+++ b/src/Common/libzip/zip_set_archive_comment.c
@@ -1,8 +1,8 @@
/*
zip_set_archive_comment.c -- set archive comment
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_archive_flag.c b/src/Common/libzip/zip_set_archive_flag.c
index 834ef5ba..7533ac50 100644
--- a/src/Common/libzip/zip_set_archive_flag.c
+++ b/src/Common/libzip/zip_set_archive_flag.c
@@ -1,8 +1,8 @@
/*
zip_get_archive_flag.c -- set archive global flag
- Copyright (C) 2008-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2008-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_default_password.c b/src/Common/libzip/zip_set_default_password.c
index 4bab513f..07b3a06e 100644
--- a/src/Common/libzip/zip_set_default_password.c
+++ b/src/Common/libzip/zip_set_default_password.c
@@ -1,8 +1,8 @@
/*
zip_set_default_password.c -- set default password for decryption
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_file_comment.c b/src/Common/libzip/zip_set_file_comment.c
index 5d2b0b8a..b587ae95 100644
--- a/src/Common/libzip/zip_set_file_comment.c
+++ b/src/Common/libzip/zip_set_file_comment.c
@@ -1,8 +1,8 @@
/*
zip_set_file_comment.c -- set comment for file in archive
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_file_compression.c b/src/Common/libzip/zip_set_file_compression.c
index a193bb77..cee099d5 100644
--- a/src/Common/libzip/zip_set_file_compression.c
+++ b/src/Common/libzip/zip_set_file_compression.c
@@ -1,8 +1,8 @@
/*
zip_set_file_compression.c -- set compression for file in archive
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_set_name.c b/src/Common/libzip/zip_set_name.c
index f1bf703e..0087af1a 100644
--- a/src/Common/libzip/zip_set_name.c
+++ b/src/Common/libzip/zip_set_name.c
@@ -1,8 +1,8 @@
/*
zip_set_name.c -- rename helper function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_accept_empty.c b/src/Common/libzip/zip_source_accept_empty.c
index e772aeea..be319434 100644
--- a/src/Common/libzip/zip_source_accept_empty.c
+++ b/src/Common/libzip/zip_source_accept_empty.c
@@ -1,8 +1,8 @@
/*
zip_source_accept_empty.c -- if empty source is a valid archive
- Copyright (C) 2019-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2019-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_begin_write.c b/src/Common/libzip/zip_source_begin_write.c
index 4a9d5d5d..2724335d 100644
--- a/src/Common/libzip/zip_source_begin_write.c
+++ b/src/Common/libzip/zip_source_begin_write.c
@@ -1,8 +1,8 @@
/*
zip_source_begin_write.c -- start a new file for writing
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_begin_write_cloning.c b/src/Common/libzip/zip_source_begin_write_cloning.c
index df195fcd..67d3475b 100644
--- a/src/Common/libzip/zip_source_begin_write_cloning.c
+++ b/src/Common/libzip/zip_source_begin_write_cloning.c
@@ -1,8 +1,8 @@
/*
zip_source_begin_write_cloning.c -- clone part of file for writing
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_buffer.c b/src/Common/libzip/zip_source_buffer.c
index 44159536..bdd522d6 100644
--- a/src/Common/libzip/zip_source_buffer.c
+++ b/src/Common/libzip/zip_source_buffer.c
@@ -1,8 +1,8 @@
/*
zip_source_buffer.c -- create zip data source from buffer
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_call.c b/src/Common/libzip/zip_source_call.c
index 8c98fc2e..bc13c3b0 100644
--- a/src/Common/libzip/zip_source_call.c
+++ b/src/Common/libzip/zip_source_call.c
@@ -1,8 +1,8 @@
/*
zip_source_call.c -- invoke callback command on zip_source
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_close.c b/src/Common/libzip/zip_source_close.c
index f4f3ff2b..f1ae6f3e 100644
--- a/src/Common/libzip/zip_source_close.c
+++ b/src/Common/libzip/zip_source_close.c
@@ -1,8 +1,8 @@
/*
zip_source_close.c -- close zip_source (stop reading)
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_commit_write.c b/src/Common/libzip/zip_source_commit_write.c
index d7f567b8..ca7563ce 100644
--- a/src/Common/libzip/zip_source_commit_write.c
+++ b/src/Common/libzip/zip_source_commit_write.c
@@ -1,8 +1,8 @@
/*
zip_source_commit_write.c -- commit changes to file
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_compress.c b/src/Common/libzip/zip_source_compress.c
index 3cf709ff..54387eca 100644
--- a/src/Common/libzip/zip_source_compress.c
+++ b/src/Common/libzip/zip_source_compress.c
@@ -1,8 +1,8 @@
/*
zip_source_compress.c -- (de)compression routines
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_crc.c b/src/Common/libzip/zip_source_crc.c
index 435a084b..931a729c 100644
--- a/src/Common/libzip/zip_source_crc.c
+++ b/src/Common/libzip/zip_source_crc.c
@@ -1,8 +1,8 @@
/*
zip_source_crc.c -- pass-through source that calculates CRC32 and size
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_error.c b/src/Common/libzip/zip_source_error.c
index dc7fa20c..774eec0a 100644
--- a/src/Common/libzip/zip_source_error.c
+++ b/src/Common/libzip/zip_source_error.c
@@ -1,8 +1,8 @@
/*
zip_source_error.c -- get last error from zip_source
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_file.h b/src/Common/libzip/zip_source_file.h
index cca9fd2b..de07aecc 100644
--- a/src/Common/libzip/zip_source_file.h
+++ b/src/Common/libzip/zip_source_file.h
@@ -1,8 +1,11 @@
+#ifndef _HAD_ZIP_SOURCE_FILE_H
+#define _HAD_ZIP_SOURCE_FILE_H
+
/*
zip_source_file.h -- header for common file operations
- Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -86,5 +89,7 @@ struct zip_source_file_operations {
zip_int64_t (*tell)(zip_source_file_context_t *ctx, void *f);
zip_int64_t (*write)(zip_source_file_context_t *ctx, const void *data, zip_uint64_t len);
};
zip_source_t *zip_source_file_common_new(const char *fname, void *file, zip_uint64_t start, zip_int64_t len, const zip_stat_t *st, zip_source_file_operations_t *ops, void *ops_userdata, zip_error_t *error);
+
+#endif /* _HAD_ZIP_SOURCE_FILE_H */
diff --git a/src/Common/libzip/zip_source_file_common.c b/src/Common/libzip/zip_source_file_common.c
index 6c58320f..99f893eb 100644
--- a/src/Common/libzip/zip_source_file_common.c
+++ b/src/Common/libzip/zip_source_file_common.c
@@ -1,8 +1,8 @@
/*
zip_source_file_common.c -- create data source from file
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_file_stdio.c b/src/Common/libzip/zip_source_file_stdio.c
index 6dcc5639..fd16f392 100644
--- a/src/Common/libzip/zip_source_file_stdio.c
+++ b/src/Common/libzip/zip_source_file_stdio.c
@@ -1,8 +1,8 @@
/*
zip_source_file_stdio.c -- read-only stdio file source implementation
- Copyright (C) 2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -118,29 +118,29 @@ _zip_stdio_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t offset,
zip_error_set(&ctx->error, ZIP_ER_SEEK, EOVERFLOW);
return false;
}
#endif
- if (fseeko((FILE *)f, (off_t)offset, whence) < 0) {
+ if (zip_os_fseek((FILE *)f, (zip_off_t)offset, whence) < 0) {
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
return false;
}
return true;
}
bool
_zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
- struct stat sb;
+ zip_os_stat_t sb;
int ret;
if (ctx->fname) {
- ret = stat(ctx->fname, &sb);
+ ret = zip_os_stat(ctx->fname, &sb);
}
else {
- ret = fstat(fileno((FILE *)ctx->f), &sb);
+ ret = zip_os_fstat(fileno((FILE *)ctx->f), &sb);
}
if (ret < 0) {
if (errno == ENOENT) {
st->exists = false;
@@ -166,11 +166,11 @@ _zip_stdio_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t *st) {
}
zip_int64_t
_zip_stdio_op_tell(zip_source_file_context_t *ctx, void *f) {
- off_t offset = ftello((FILE *)f);
+ zip_off_t offset = zip_os_ftell((FILE *)f);
if (offset < 0) {
zip_error_set(&ctx->error, ZIP_ER_SEEK, errno);
}
diff --git a/src/Common/libzip/zip_source_file_stdio.h b/src/Common/libzip/zip_source_file_stdio.h
index 802e6071..417a28c0 100644
--- a/src/Common/libzip/zip_source_file_stdio.h
+++ b/src/Common/libzip/zip_source_file_stdio.h
@@ -1,11 +1,11 @@
#ifndef _HAD_ZIP_SOURCE_FILE_STDIO_H
#define _HAD_ZIP_SOURCE_FILE_STDIO_H
/*
zip_source_file_stdio.h -- common header for stdio file implementation
- Copyright (C) 2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_file_stdio_named.c b/src/Common/libzip/zip_source_file_stdio_named.c
index 1495d7dd..1a5ca226 100644
--- a/src/Common/libzip/zip_source_file_stdio_named.c
+++ b/src/Common/libzip/zip_source_file_stdio_named.c
@@ -1,8 +1,8 @@
/*
zip_source_file_stdio_named.c -- source for stdio file opened by name
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -176,13 +176,13 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
}
#else
{
int fd;
struct file_clone_range range;
- struct stat st;
+ zip_os_stat_t st;
- if (fstat(fileno(ctx->f), &st) < 0) {
+ if (zip_os_fstat(fileno(ctx->f), &st) < 0) {
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
return -1;
}
if ((fd = create_temp_file(ctx, true)) < 0) {
@@ -221,11 +221,11 @@ _zip_stdio_op_create_temp_output_cloning(zip_source_file_context_t *ctx, zip_uin
(void)remove(ctx->tmpname);
free(ctx->tmpname);
ctx->tmpname = NULL;
return -1;
}
- if (fseeko(tfp, (off_t)offset, SEEK_SET) < 0) {
+ if (zip_os_fseek(tfp, (zip_off_t)offset, SEEK_SET) < 0) {
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
(void)fclose(tfp);
(void)remove(ctx->tmpname);
free(ctx->tmpname);
ctx->tmpname = NULL;
@@ -288,15 +288,15 @@ _zip_stdio_op_write(zip_source_file_context_t *ctx, const void *data, zip_uint64
static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
char *temp;
int mode;
- struct stat st;
+ zip_os_stat_t st;
int fd = 0;
char *start, *end;
- if (stat(ctx->fname, &st) == 0) {
+ if (zip_os_stat(ctx->fname, &st) == 0) {
mode = st.st_mode;
}
else {
mode = -1;
}
@@ -342,11 +342,11 @@ static int create_temp_file(zip_source_file_context_t *ctx, bool create_file) {
free(temp);
return -1;
}
}
else {
- if (stat(temp, &st) < 0) {
+ if (zip_os_stat(temp, &st) < 0) {
if (errno == ENOENT) {
break;
}
else {
zip_error_set(&ctx->error, ZIP_ER_TMPOPEN, errno);
diff --git a/src/Common/libzip/zip_source_file_win32.c b/src/Common/libzip/zip_source_file_win32.c
index 624860b1..aa669766 100644
--- a/src/Common/libzip/zip_source_file_win32.c
+++ b/src/Common/libzip/zip_source_file_win32.c
@@ -1,8 +1,8 @@
/*
zip_source_file_win32.c -- read-only Windows file source implementation
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_file_win32.h b/src/Common/libzip/zip_source_file_win32.h
index d86069ec..da691f0a 100644
--- a/src/Common/libzip/zip_source_file_win32.h
+++ b/src/Common/libzip/zip_source_file_win32.h
@@ -1,11 +1,11 @@
#ifndef _HAD_ZIP_SOURCE_FILE_WIN32_H
#define _HAD_ZIP_SOURCE_FILE_WIN32_H
/*
zip_source_file_win32.h -- common header for Windows file implementation
- Copyright (C) 2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -57,10 +57,11 @@ struct zip_win32_file_operations {
BOOL(__stdcall *get_file_attributes_ex)(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information);
void (*make_tempname)(char *buf, size_t len, const char *name, zip_uint32_t i);
BOOL(__stdcall *move_file)(const void *from, const void *to, DWORD flags);
BOOL(__stdcall *set_file_attributes)(const void *name, DWORD attributes);
char *(*string_duplicate)(const char *string);
+ HANDLE(__stdcall *find_first_file)(const void *name, void *data);
};
typedef struct zip_win32_file_operations zip_win32_file_operations_t;
extern zip_source_file_operations_t _zip_source_file_win32_named_ops;
@@ -71,14 +72,6 @@ bool _zip_win32_op_seek(zip_source_file_context_t *ctx, void *f, zip_int64_t off
zip_int64_t _zip_win32_op_tell(zip_source_file_context_t *ctx, void *f);
bool _zip_filetime_to_time_t(FILETIME ft, time_t *t);
int _zip_win32_error_to_errno(DWORD win32err);
-#ifdef __clang__
-#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN _Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wincompatible-function-pointer-types\"")
-#define DONT_WARN_INCOMPATIBLE_FN_PTR_END _Pragma("GCC diagnostic pop")
-#else
-#define DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN
-#define DONT_WARN_INCOMPATIBLE_FN_PTR_END
-#endif
-
#endif /* _HAD_ZIP_SOURCE_FILE_WIN32_H */
diff --git a/src/Common/libzip/zip_source_file_win32_ansi.c b/src/Common/libzip/zip_source_file_win32_ansi.c
index 58034cc2..f10f8ae3 100644
--- a/src/Common/libzip/zip_source_file_win32_ansi.c
+++ b/src/Common/libzip/zip_source_file_win32_ansi.c
@@ -1,8 +1,8 @@
/*
zip_source_file_win32_ansi.c -- source for Windows file opened by ANSI name
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -32,28 +32,32 @@
*/
#include "zip_source_file_win32.h"
static char *ansi_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp);
+static HANDLE __stdcall ansi_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file);
+static BOOL __stdcall ansi_delete_file(const void *name);
+static DWORD __stdcall ansi_get_file_attributes(const void *name);
+static BOOL __stdcall ansi_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information);
static void ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i);
+static BOOL __stdcall ansi_move_file(const void *from, const void *to, DWORD flags);
+static BOOL __stdcall ansi_set_file_attributes(const void *name, DWORD attributes);
+static HANDLE __stdcall ansi_find_first_file(const void *name, void* data);
/* clang-format off */
-DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN
-
zip_win32_file_operations_t ops_ansi = {
ansi_allocate_tempname,
- CreateFileA,
- DeleteFileA,
- GetFileAttributesA,
- GetFileAttributesExA,
+ ansi_create_file,
+ ansi_delete_file,
+ ansi_get_file_attributes,
+ ansi_get_file_attributes_ex,
ansi_make_tempname,
- MoveFileExA,
- SetFileAttributesA,
- strdup
+ ansi_move_file,
+ ansi_set_file_attributes,
+ strdup,
+ ansi_find_first_file,
};
-
-DONT_WARN_INCOMPATIBLE_FN_PTR_END
/* clang-format on */
ZIP_EXTERN zip_source_t *
zip_source_win32a(zip_t *za, const char *fname, zip_uint64_t start, zip_int64_t len) {
if (za == NULL)
@@ -78,10 +82,51 @@ static char *
ansi_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) {
*lengthp = strlen(name) + extra_chars;
return (char *)malloc(*lengthp);
}
+static HANDLE __stdcall
+ansi_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file)
+{
+ return CreateFileA((const char *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file);
+}
+
+static BOOL __stdcall
+ansi_delete_file(const void *name)
+{
+ return DeleteFileA((const char *)name);
+}
+
+static DWORD __stdcall
+ansi_get_file_attributes(const void *name)
+{
+ return GetFileAttributesA((const char *)name);
+}
+
+static BOOL __stdcall
+ansi_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information)
+{
+ return GetFileAttributesExA((const char *)name, info_level, information);
+}
static void
ansi_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) {
snprintf_s(buf, len, "%s.%08x", name, i);
}
+
+static BOOL __stdcall
+ansi_move_file(const void *from, const void *to, DWORD flags)
+{
+ return MoveFileExA((const char *)from, (const char *)to, flags);
+}
+
+static BOOL __stdcall
+ansi_set_file_attributes(const void *name, DWORD attributes)
+{
+ return SetFileAttributesA((const char *)name, attributes);
+}
+
+static HANDLE __stdcall
+ansi_find_first_file(const void *name, void *data)
+{
+ return FindFirstFileA((const char *)name, data);
+}
diff --git a/src/Common/libzip/zip_source_file_win32_named.c b/src/Common/libzip/zip_source_file_win32_named.c
index 855e605a..ae72db19 100644
--- a/src/Common/libzip/zip_source_file_win32_named.c
+++ b/src/Common/libzip/zip_source_file_win32_named.c
@@ -1,8 +1,8 @@
/*
zip_source_file_win32_named.c -- source for Windows file opened by name
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -31,10 +31,17 @@
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "zip_source_file_win32.h"
+/* ACL is not available when targeting the games API partition */
+#if defined(WINAPI_FAMILY_PARTITION) && defined(WINAPI_PARTITION_GAMES)
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_GAMES)
+#define ACL_UNSUPPORTED
+#endif
+#endif
+
static zip_int64_t _zip_win32_named_op_commit_write(zip_source_file_context_t *ctx);
static zip_int64_t _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx);
static bool _zip_win32_named_op_open(zip_source_file_context_t *ctx);
static zip_int64_t _zip_win32_named_op_remove(zip_source_file_context_t *ctx);
static void _zip_win32_named_op_rollback_write(zip_source_file_context_t *ctx);
@@ -108,11 +115,15 @@ _zip_win32_named_op_create_temp_output(zip_source_file_context_t *ctx) {
char *tempname = NULL;
size_t tempname_size = 0;
if ((HANDLE)ctx->f != INVALID_HANDLE_VALUE && GetFileType((HANDLE)ctx->f) == FILE_TYPE_DISK) {
si = DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION;
+ #ifdef ACL_UNSUPPORTED
+ success = ERROR_NOT_SUPPORTED;
+ #else
success = GetSecurityInfo((HANDLE)ctx->f, SE_FILE_OBJECT, si, NULL, NULL, &dacl, NULL, &psd);
+ #endif
if (success == ERROR_SUCCESS) {
sa.nLength = sizeof(SECURITY_ATTRIBUTES);
sa.bInheritHandle = FALSE;
sa.lpSecurityDescriptor = psd;
psa = &sa;
@@ -208,12 +219,24 @@ _zip_win32_named_op_stat(zip_source_file_context_t *ctx, zip_source_file_stat_t
st->exists = true;
st->regular_file = false;
if (file_attributes.dwFileAttributes != INVALID_FILE_ATTRIBUTES) {
- if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE | FILE_ATTRIBUTE_REPARSE_POINT)) == 0) {
- st->regular_file = true;
+ if ((file_attributes.dwFileAttributes & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)) == 0) {
+ if (file_attributes.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
+#ifdef IO_REPARSE_TAG_DEDUP // Not defined in WinSDK 7.1 or before (VS2010).
+ WIN32_FIND_DATA find_data;
+ /* Deduplication on Windows replaces files with reparse points;
+ * accept them as regular files. */
+ if (file_ops->find_first_file(ctx->fname, &find_data) != INVALID_HANDLE_VALUE) {
+ st->regular_file = (find_data.dwReserved0 == IO_REPARSE_TAG_DEDUP);
+ }
+#endif
+ }
+ else {
+ st->regular_file = true;
+ }
}
}
if (!_zip_filetime_to_time_t(file_attributes.ftLastWriteTime, &st->mtime)) {
zip_error_set(&ctx->error, ZIP_ER_READ, ERANGE);
diff --git a/src/Common/libzip/zip_source_file_win32_utf16.c b/src/Common/libzip/zip_source_file_win32_utf16.c
index 8f07d021..73e25666 100644
--- a/src/Common/libzip/zip_source_file_win32_utf16.c
+++ b/src/Common/libzip/zip_source_file_win32_utf16.c
@@ -1,8 +1,8 @@
/*
zip_source_file_win32_utf16.c -- source for Windows file opened by UTF-16 name
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -32,30 +32,34 @@
*/
#include "zip_source_file_win32.h"
static char *utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp);
-static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file);
+static HANDLE __stdcall utf16_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file);
+static BOOL __stdcall utf16_delete_file(const void *name);
+static DWORD __stdcall utf16_get_file_attributes(const void *name);
+static BOOL __stdcall utf16_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information);
static void utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i);
+static BOOL __stdcall utf16_move_file(const void *from, const void *to, DWORD flags);
+static BOOL __stdcall utf16_set_file_attributes(const void *name, DWORD attributes);
static char *utf16_strdup(const char *string);
+static HANDLE __stdcall utf16_find_first_file(const void *name, void* data);
-/* clang-format off */
-DONT_WARN_INCOMPATIBLE_FN_PTR_BEGIN
+/* clang-format off */
zip_win32_file_operations_t ops_utf16 = {
utf16_allocate_tempname,
utf16_create_file,
- DeleteFileW,
- GetFileAttributesW,
- GetFileAttributesExW,
+ utf16_delete_file,
+ utf16_get_file_attributes,
+ utf16_get_file_attributes_ex,
utf16_make_tempname,
- MoveFileExW,
- SetFileAttributesW,
- utf16_strdup
+ utf16_move_file,
+ utf16_set_file_attributes,
+ utf16_strdup,
+ utf16_find_first_file
};
-
-DONT_WARN_INCOMPATIBLE_FN_PTR_END
/* clang-format on */
ZIP_EXTERN zip_source_t *
zip_source_win32w(zip_t *za, const wchar_t *fname, zip_uint64_t start, zip_int64_t len) {
if (za == NULL)
@@ -82,11 +86,11 @@ utf16_allocate_tempname(const char *name, size_t extra_chars, size_t *lengthp) {
*lengthp = wcslen((const wchar_t *)name) + extra_chars;
return (char *)malloc(*lengthp * sizeof(wchar_t));
}
-static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) {
+static HANDLE __stdcall utf16_create_file(const void *name, DWORD access, DWORD share_mode, PSECURITY_ATTRIBUTES security_attributes, DWORD creation_disposition, DWORD file_attributes, HANDLE template_file) {
#ifdef MS_UWP
CREATEFILE2_EXTENDED_PARAMETERS extParams = {0};
extParams.dwFileAttributes = file_attributes;
extParams.dwFileFlags = FILE_FLAG_RANDOM_ACCESS;
extParams.dwSecurityQosFlags = SECURITY_ANONYMOUS;
@@ -98,16 +102,51 @@ static HANDLE __stdcall utf16_create_file(const char *name, DWORD access, DWORD
#else
return CreateFileW((const wchar_t *)name, access, share_mode, security_attributes, creation_disposition, file_attributes, template_file);
#endif
}
+static BOOL __stdcall
+utf16_delete_file(const void *name)
+{
+ return DeleteFileW((const wchar_t *)name);
+}
+
+static DWORD __stdcall
+utf16_get_file_attributes(const void *name)
+{
+ return GetFileAttributesW((const wchar_t *)name);
+}
+
+static BOOL __stdcall
+utf16_get_file_attributes_ex(const void *name, GET_FILEEX_INFO_LEVELS info_level, void *information)
+{
+ return GetFileAttributesExW((const wchar_t *)name, info_level, information);
+}
static void
utf16_make_tempname(char *buf, size_t len, const char *name, zip_uint32_t i) {
_snwprintf_s((wchar_t *)buf, len, len, L"%s.%08x", (const wchar_t *)name, i);
}
+static BOOL __stdcall
+utf16_move_file(const void *from, const void *to, DWORD flags)
+{
+ return MoveFileExW((const wchar_t *)from, (const wchar_t *)to, flags);
+}
+
+static BOOL __stdcall
+utf16_set_file_attributes(const void *name, DWORD attributes)
+{
+ return SetFileAttributesW((const wchar_t *)name, attributes);
+}
static char *
utf16_strdup(const char *string) {
return (char *)_wcsdup((const wchar_t *)string);
}
+
+
+static HANDLE __stdcall
+utf16_find_first_file(const void *name, void* data)
+{
+ return FindFirstFileW((const wchar_t *)name, data);
+}
diff --git a/src/Common/libzip/zip_source_file_win32_utf8.c b/src/Common/libzip/zip_source_file_win32_utf8.c
index d154f97a..5c27df92 100644
--- a/src/Common/libzip/zip_source_file_win32_utf8.c
+++ b/src/Common/libzip/zip_source_file_win32_utf8.c
@@ -1,8 +1,8 @@
/*
zip_source_file_win32_ansi.c -- source for Windows file opened by UTF-8 name
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_free.c b/src/Common/libzip/zip_source_free.c
index 1a800405..df4b08d8 100644
--- a/src/Common/libzip/zip_source_free.c
+++ b/src/Common/libzip/zip_source_free.c
@@ -1,8 +1,8 @@
/*
zip_source_free.c -- free zip data source
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_get_dostime.c b/src/Common/libzip/zip_source_get_dostime.c
new file mode 100644
index 00000000..17f652bb
--- /dev/null
+++ b/src/Common/libzip/zip_source_get_dostime.c
@@ -0,0 +1,72 @@
+/*
+ zip_source_get_dostime.c -- get modification time in DOS format from source
+ Copyright (C) 2024 Dieter Baron and Thomas Klausner
+
+ This file is part of libzip, a library to manipulate ZIP archives.
+ The authors can be contacted at <info@libzip.org>
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in
+ the documentation and/or other materials provided with the
+ distribution.
+ 3. The names of the authors may not be used to endorse or promote
+ products derived from this software without specific prior
+ written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS
+ OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
+ IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+
+#include "zipint.h"
+
+/* Returns -1 on error, 0 on no dostime available, 1 for dostime returned */
+int
+zip_source_get_dos_time(zip_source_t *src, zip_dostime_t *dos_time) {
+ if (src->source_closed) {
+ return -1;
+ }
+ if (dos_time == NULL) {
+ zip_error_set(&src->error, ZIP_ER_INVAL, 0);
+ return -1;
+ }
+
+ if (src->write_state == ZIP_SOURCE_WRITE_REMOVED) {
+ zip_error_set(&src->error, ZIP_ER_READ, ENOENT);
+ }
+
+ if (zip_source_supports(src) & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_GET_DOS_TIME)) {
+ zip_int64_t n = _zip_source_call(src, dos_time, sizeof(*dos_time), ZIP_SOURCE_GET_DOS_TIME);
+
+ if (n < 0) {
+ return -1;
+ }
+ else if (n == 0) {
+ return 0;
+ }
+ else if (n == sizeof(*dos_time)) {
+ return 1;
+ }
+ else {
+ zip_error_set(&src->error, ZIP_ER_INTERNAL, 0);
+ return -1;
+ }
+ }
+ else {
+ return 0;
+ }
+}
diff --git a/src/Common/libzip/zip_source_get_file_attributes.c b/src/Common/libzip/zip_source_get_file_attributes.c
index 4771dc16..209e39f5 100644
--- a/src/Common/libzip/zip_source_get_file_attributes.c
+++ b/src/Common/libzip/zip_source_get_file_attributes.c
@@ -1,8 +1,8 @@
/*
zip_source_get_file_attributes.c -- get attributes for file from source
- Copyright (C) 2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2020-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_is_deleted.c b/src/Common/libzip/zip_source_is_deleted.c
index 838aa909..d6016a02 100644
--- a/src/Common/libzip/zip_source_is_deleted.c
+++ b/src/Common/libzip/zip_source_is_deleted.c
@@ -1,8 +1,8 @@
/*
zip_source_is_deleted.c -- was archive was removed?
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_layered.c b/src/Common/libzip/zip_source_layered.c
index 62b78e68..be428190 100644
--- a/src/Common/libzip/zip_source_layered.c
+++ b/src/Common/libzip/zip_source_layered.c
@@ -1,8 +1,8 @@
/*
zip_source_layered.c -- create layered source
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_open.c b/src/Common/libzip/zip_source_open.c
index b34fa2c6..9e42d0a9 100644
--- a/src/Common/libzip/zip_source_open.c
+++ b/src/Common/libzip/zip_source_open.c
@@ -1,8 +1,8 @@
/*
zip_source_open.c -- open zip_source (prepare for reading)
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_pass_to_lower_layer.c b/src/Common/libzip/zip_source_pass_to_lower_layer.c
index 4a98222e..391729e4 100644
--- a/src/Common/libzip/zip_source_pass_to_lower_layer.c
+++ b/src/Common/libzip/zip_source_pass_to_lower_layer.c
@@ -1,8 +1,8 @@
/*
zip_source_pass_to_lower_layer.c -- pass command to lower layer
- Copyright (C) 2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 2022-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -45,16 +45,16 @@ zip_int64_t zip_source_pass_to_lower_layer(zip_source_t *src, void *data, zip_ui
case ZIP_SOURCE_STAT:
return sizeof(zip_stat_t);
case ZIP_SOURCE_ACCEPT_EMPTY:
case ZIP_SOURCE_ERROR:
+ case ZIP_SOURCE_GET_DOS_TIME:
case ZIP_SOURCE_READ:
case ZIP_SOURCE_SEEK:
case ZIP_SOURCE_TELL:
return _zip_source_call(src, data, length, command);
-
case ZIP_SOURCE_BEGIN_WRITE:
case ZIP_SOURCE_BEGIN_WRITE_CLONING:
case ZIP_SOURCE_COMMIT_WRITE:
case ZIP_SOURCE_REMOVE:
case ZIP_SOURCE_ROLLBACK_WRITE:
diff --git a/src/Common/libzip/zip_source_pkware_decode.c b/src/Common/libzip/zip_source_pkware_decode.c
index b4c482b3..9c22a069 100644
--- a/src/Common/libzip/zip_source_pkware_decode.c
+++ b/src/Common/libzip/zip_source_pkware_decode.c
@@ -1,8 +1,8 @@
/*
zip_source_pkware_decode.c -- Traditional PKWARE decryption routines
- Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -78,13 +78,13 @@ zip_source_pkware_decode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flag
static int
decrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
zip_uint8_t header[ZIP_CRYPTO_PKWARE_HEADERLEN];
- struct zip_stat st;
+ zip_stat_t st;
+ zip_dostime_t dostime;
zip_int64_t n;
- bool ok = false;
if ((n = zip_source_read(src, header, ZIP_CRYPTO_PKWARE_HEADERLEN)) < 0) {
zip_error_set_from_source(&ctx->error, src);
return -1;
}
@@ -94,40 +94,39 @@ decrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
return -1;
}
_zip_pkware_decrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN);
- if (zip_source_stat(src, &st)) {
- /* stat failed, skip password validation */
+ if (zip_source_stat(src, &st) < 0 || (st.valid & ZIP_STAT_CRC) == 0) {
+ /* skip password validation */
return 0;
}
- /* password verification - two ways:
- * mtime - InfoZIP way, to avoid computing complete CRC before encrypting data
- * CRC - old PKWare way
- */
-
- if (st.valid & ZIP_STAT_MTIME) {
- unsigned short dostime, dosdate;
- _zip_u2d_time(st.mtime, &dostime, &dosdate);
- if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == dostime >> 8) {
- ok = true;
+ if (zip_source_get_dos_time(src, &dostime) <= 0) {
+ if ((st.valid & ZIP_STAT_MTIME) == 0) {
+ /* no date available, skip password validation */
+ return 0;
}
- }
- if (st.valid & ZIP_STAT_CRC) {
- if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == st.crc >> 24) {
- ok = true;
+ if (_zip_u2d_time(st.mtime, &dostime, &ctx->error) < 0) {
+ return -1;
}
}
- if (!ok && ((st.valid & (ZIP_STAT_MTIME | ZIP_STAT_CRC)) != 0)) {
+ /*
+ password verification - two ways:
+ - mtime - InfoZIP way, to avoid computing complete CRC before encrypting data
+ - CRC - old PKWare way
+ */
+ if (header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == dostime.time >> 8
+ || header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] == st.crc >> 24) {
+ return 0;
+ }
+ else {
zip_error_set(&ctx->error, ZIP_ER_WRONGPASSWD, 0);
return -1;
}
-
- return 0;
}
static zip_int64_t
pkware_decrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t len, zip_source_cmd_t cmd) {
diff --git a/src/Common/libzip/zip_source_pkware_encode.c b/src/Common/libzip/zip_source_pkware_encode.c
index d89b9f4e..fed76115 100644
--- a/src/Common/libzip/zip_source_pkware_encode.c
+++ b/src/Common/libzip/zip_source_pkware_encode.c
@@ -1,8 +1,8 @@
/*
zip_source_pkware_encode.c -- Traditional PKWARE encryption routines
- Copyright (C) 2009-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -40,21 +40,19 @@
struct trad_pkware {
char *password;
zip_pkware_keys_t keys;
zip_buffer_t *buffer;
bool eof;
- bool mtime_set;
- time_t mtime;
+ zip_dostime_t dostime;
zip_error_t error;
};
static int encrypt_header(zip_source_t *, struct trad_pkware *);
static zip_int64_t pkware_encrypt(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t);
static void trad_pkware_free(struct trad_pkware *);
static struct trad_pkware *trad_pkware_new(const char *password, zip_error_t *error);
-static void set_mtime(struct trad_pkware* ctx, zip_stat_t* st);
zip_source_t *
zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flags, const char *password) {
struct trad_pkware *ctx;
zip_source_t *s2;
@@ -67,13 +65,28 @@ zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flag
zip_error_set(&za->error, ZIP_ER_ENCRNOTSUPP, 0);
return NULL;
}
if ((ctx = trad_pkware_new(password, &za->error)) == NULL) {
+ zip_error_set(&za->error, ZIP_ER_MEMORY, 0);
return NULL;
}
+ if (zip_source_get_dos_time(src, &ctx->dostime) <= 0) {
+ zip_stat_t st;
+
+ if (zip_source_stat(src, &st) < 0) {
+ zip_error_set_from_source(&za->error, src);
+ trad_pkware_free(ctx);
+ return NULL;
+ }
+ if (_zip_u2d_time((st.valid & ZIP_STAT_MTIME) ? st.mtime : time(NULL), &ctx->dostime, &za->error) < 0) {
+ trad_pkware_free(ctx);
+ return NULL;
+ }
+ }
+
if ((s2 = zip_source_layered(za, src, pkware_encrypt, ctx)) == NULL) {
trad_pkware_free(ctx);
return NULL;
}
@@ -81,24 +94,12 @@ zip_source_pkware_encode(zip_t *za, zip_source_t *src, zip_uint16_t em, int flag
}
static int
encrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
- unsigned short dostime, dosdate;
zip_uint8_t *header;
- if (!ctx->mtime_set) {
- struct zip_stat st;
- if (zip_source_stat(src, &st) != 0) {
- zip_error_set_from_source(&ctx->error, src);
- return -1;
- }
- set_mtime(ctx, &st);
- }
-
- _zip_u2d_time(ctx->mtime, &dostime, &dosdate);
-
if ((ctx->buffer = _zip_buffer_new(NULL, ZIP_CRYPTO_PKWARE_HEADERLEN)) == NULL) {
zip_error_set(&ctx->error, ZIP_ER_MEMORY, 0);
return -1;
}
@@ -110,11 +111,11 @@ encrypt_header(zip_source_t *src, struct trad_pkware *ctx) {
zip_error_set(&ctx->error, ZIP_ER_INTERNAL, 0);
_zip_buffer_free(ctx->buffer);
ctx->buffer = NULL;
return -1;
}
- header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] = (zip_uint8_t)((dostime >> 8) & 0xff);
+ header[ZIP_CRYPTO_PKWARE_HEADERLEN - 1] = (zip_uint8_t)((ctx->dostime.time >> 8) & 0xff);
_zip_pkware_encrypt(&ctx->keys, header, header, ZIP_CRYPTO_PKWARE_HEADERLEN);
return 0;
}
@@ -185,13 +186,10 @@ pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip
st->encryption_method = ZIP_EM_TRAD_PKWARE;
st->valid |= ZIP_STAT_ENCRYPTION_METHOD;
if (st->valid & ZIP_STAT_COMP_SIZE) {
st->comp_size += ZIP_CRYPTO_PKWARE_HEADERLEN;
}
- set_mtime(ctx, st);
- st->mtime = ctx->mtime;
- st->valid |= ZIP_STAT_MTIME;
return 0;
}
case ZIP_SOURCE_GET_FILE_ATTRIBUTES: {
@@ -204,12 +202,20 @@ pkware_encrypt(zip_source_t *src, void *ud, void *data, zip_uint64_t length, zip
attributes->version_needed = 20;
return 0;
}
+ case ZIP_SOURCE_GET_DOS_TIME:
+ if (length < sizeof(ctx->dostime)) {
+ zip_error_set(&ctx->error, ZIP_ER_INVAL, 0);
+ return -1;
+ }
+ (void)memcpy_s(data, sizeof(ctx->dostime), &ctx->dostime, sizeof(ctx->dostime));
+ return sizeof(ctx->dostime);
+
case ZIP_SOURCE_SUPPORTS:
- return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, -1);
+ return zip_source_make_command_bitmap(ZIP_SOURCE_OPEN, ZIP_SOURCE_READ, ZIP_SOURCE_CLOSE, ZIP_SOURCE_STAT, ZIP_SOURCE_ERROR, ZIP_SOURCE_FREE, ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_GET_DOS_TIME, -1);
case ZIP_SOURCE_ERROR:
return zip_error_to_data(&ctx->error, data, length);
case ZIP_SOURCE_FREE:
@@ -235,12 +241,10 @@ trad_pkware_new(const char *password, zip_error_t *error) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
free(ctx);
return NULL;
}
ctx->buffer = NULL;
- ctx->mtime_set = false;
- ctx->mtime = 0;
zip_error_init(&ctx->error);
return ctx;
}
@@ -254,18 +258,5 @@ trad_pkware_free(struct trad_pkware *ctx) {
free(ctx->password);
_zip_buffer_free(ctx->buffer);
zip_error_fini(&ctx->error);
free(ctx);
}
-
-
-static void set_mtime(struct trad_pkware* ctx, zip_stat_t* st) {
- if (!ctx->mtime_set) {
- if (st->valid & ZIP_STAT_MTIME) {
- ctx->mtime = st->mtime;
- }
- else {
- time(&ctx->mtime);
- }
- ctx->mtime_set = true;
- }
-}
diff --git a/src/Common/libzip/zip_source_read.c b/src/Common/libzip/zip_source_read.c
index 0938fcb0..910d4c3e 100644
--- a/src/Common/libzip/zip_source_read.c
+++ b/src/Common/libzip/zip_source_read.c
@@ -1,8 +1,8 @@
/*
zip_source_read.c -- read data from zip_source
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_remove.c b/src/Common/libzip/zip_source_remove.c
index c1d73ab9..06325b72 100644
--- a/src/Common/libzip/zip_source_remove.c
+++ b/src/Common/libzip/zip_source_remove.c
@@ -1,8 +1,8 @@
/*
zip_source_remove.c -- remove empty archive
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_rollback_write.c b/src/Common/libzip/zip_source_rollback_write.c
index ea1a1510..51613252 100644
--- a/src/Common/libzip/zip_source_rollback_write.c
+++ b/src/Common/libzip/zip_source_rollback_write.c
@@ -1,8 +1,8 @@
/*
zip_source_rollback_write.c -- discard changes
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_seek.c b/src/Common/libzip/zip_source_seek.c
index e3baad5a..42d6b0d2 100644
--- a/src/Common/libzip/zip_source_seek.c
+++ b/src/Common/libzip/zip_source_seek.c
@@ -1,8 +1,8 @@
/*
zip_source_seek.c -- seek to offset
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_seek_write.c b/src/Common/libzip/zip_source_seek_write.c
index 34ae2f5a..9e87fa4d 100644
--- a/src/Common/libzip/zip_source_seek_write.c
+++ b/src/Common/libzip/zip_source_seek_write.c
@@ -1,8 +1,8 @@
/*
zip_source_seek_write.c -- seek to offset for writing
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_stat.c b/src/Common/libzip/zip_source_stat.c
index 05dcb84d..7c8bacac 100644
--- a/src/Common/libzip/zip_source_stat.c
+++ b/src/Common/libzip/zip_source_stat.c
@@ -1,8 +1,8 @@
/*
zip_source_stat.c -- get meta information from zip_source
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_supports.c b/src/Common/libzip/zip_source_supports.c
index 8fea2ae9..e30ee757 100644
--- a/src/Common/libzip/zip_source_supports.c
+++ b/src/Common/libzip/zip_source_supports.c
@@ -1,8 +1,8 @@
/*
zip_source_supports.c -- check for supported functions
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_tell.c b/src/Common/libzip/zip_source_tell.c
index 49057ce5..33ec475e 100644
--- a/src/Common/libzip/zip_source_tell.c
+++ b/src/Common/libzip/zip_source_tell.c
@@ -1,8 +1,8 @@
/*
zip_source_tell.c -- report current offset
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_tell_write.c b/src/Common/libzip/zip_source_tell_write.c
index a5b0e531..6912af9e 100644
--- a/src/Common/libzip/zip_source_tell_write.c
+++ b/src/Common/libzip/zip_source_tell_write.c
@@ -1,8 +1,8 @@
/*
zip_source_tell_write.c -- report current offset for writing
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_window.c b/src/Common/libzip/zip_source_window.c
index 524e27c8..eac27c39 100644
--- a/src/Common/libzip/zip_source_window.c
+++ b/src/Common/libzip/zip_source_window.c
@@ -1,8 +1,8 @@
/*
zip_source_window.c -- return part of lower source
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -49,26 +49,28 @@ struct window {
zip_uint64_t offset; /* offset in src for next read */
zip_stat_t stat;
zip_uint64_t stat_invalid;
zip_file_attributes_t attributes;
+ zip_dostime_t dostime;
+ bool dostime_valid;
zip_error_t error;
zip_int64_t supports;
bool needs_seek;
};
static zip_int64_t window_read(zip_source_t *, void *, void *, zip_uint64_t, zip_source_cmd_t);
ZIP_EXTERN zip_source_t *
zip_source_window_create(zip_source_t *src, zip_uint64_t start, zip_int64_t len, zip_error_t *error) {
- return _zip_source_window_new(src, start, len, NULL, 0, NULL, NULL, 0, false, error);
+ return _zip_source_window_new(src, start, len, NULL, 0, NULL, NULL, NULL, 0, false, error);
}
zip_source_t *
-_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error) {
+_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_dostime_t *dostime, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error) {
zip_source_t* window_source;
struct window *ctx;
if (src == NULL || length < -1 || (source_archive == NULL && source_index != 0)) {
zip_error_set(error, ZIP_ER_INVAL, 0);
@@ -101,14 +103,21 @@ _zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length
(void)memcpy_s(&ctx->attributes, sizeof(ctx->attributes), attributes, sizeof(ctx->attributes));
}
else {
zip_file_attributes_init(&ctx->attributes);
}
+ if (dostime != NULL) {
+ ctx->dostime = *dostime;
+ ctx->dostime_valid = true;
+ }
+ else {
+ ctx->dostime_valid = false;
+ }
ctx->source_archive = source_archive;
ctx->source_index = source_index;
zip_error_init(&ctx->error);
- ctx->supports = (zip_source_supports(src) & (ZIP_SOURCE_SUPPORTS_SEEKABLE | ZIP_SOURCE_SUPPORTS_REOPEN)) | (zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, ZIP_SOURCE_FREE, -1));
+ ctx->supports = (zip_source_supports(src) & (ZIP_SOURCE_SUPPORTS_SEEKABLE | ZIP_SOURCE_SUPPORTS_REOPEN)) | (zip_source_make_command_bitmap(ZIP_SOURCE_GET_FILE_ATTRIBUTES, ZIP_SOURCE_GET_DOS_TIME, ZIP_SOURCE_SUPPORTS, ZIP_SOURCE_TELL, ZIP_SOURCE_FREE, -1));
ctx->needs_seek = (ctx->supports & ZIP_SOURCE_MAKE_COMMAND_BITMASK(ZIP_SOURCE_SEEK)) ? true : false;
if (st) {
if (_zip_stat_merge(&ctx->stat, st, error) < 0) {
free(ctx);
@@ -307,10 +316,23 @@ window_read(zip_source_t *src, void *_ctx, void *data, zip_uint64_t len, zip_sou
}
(void)memcpy_s(data, sizeof(ctx->attributes), &ctx->attributes, sizeof(ctx->attributes));
return sizeof(ctx->attributes);
+ case ZIP_SOURCE_GET_DOS_TIME:
+ if (len < sizeof(ctx->dostime)) {
+ zip_error_set(&ctx->error, ZIP_ER_INVAL, 0);
+ return -1;
+ }
+ if (ctx->dostime_valid) {
+ (void)memcpy_s(data, sizeof(ctx->dostime), &ctx->dostime, sizeof(ctx->dostime));
+ return sizeof(ctx->dostime);
+ }
+ else {
+ return 0;
+ }
+
case ZIP_SOURCE_SUPPORTS:
return ctx->supports;
case ZIP_SOURCE_TELL:
return (zip_int64_t)(ctx->offset - ctx->start);
diff --git a/src/Common/libzip/zip_source_winzip_aes_decode.c b/src/Common/libzip/zip_source_winzip_aes_decode.c
index ee53fb41..8830a005 100644
--- a/src/Common/libzip/zip_source_winzip_aes_decode.c
+++ b/src/Common/libzip/zip_source_winzip_aes_decode.c
@@ -1,8 +1,8 @@
/*
zip_source_winzip_aes_decode.c -- Winzip AES decryption routines
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_winzip_aes_encode.c b/src/Common/libzip/zip_source_winzip_aes_encode.c
index 87e2865a..c704b123 100644
--- a/src/Common/libzip/zip_source_winzip_aes_encode.c
+++ b/src/Common/libzip/zip_source_winzip_aes_encode.c
@@ -1,8 +1,8 @@
/*
zip_source_winzip_aes_encode.c -- Winzip AES encryption routines
- Copyright (C) 2009-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2009-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_write.c b/src/Common/libzip/zip_source_write.c
index 24dde9b2..20ca361c 100644
--- a/src/Common/libzip/zip_source_write.c
+++ b/src/Common/libzip/zip_source_write.c
@@ -1,8 +1,8 @@
/*
zip_source_write.c -- start a new file for writing
- Copyright (C) 2014-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2014-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_zip.c b/src/Common/libzip/zip_source_zip.c
index faabf0d2..07819865 100644
--- a/src/Common/libzip/zip_source_zip.c
+++ b/src/Common/libzip/zip_source_zip.c
@@ -1,8 +1,8 @@
/*
zip_source_zip.c -- create data source from zip file
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2023 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_source_zip_new.c b/src/Common/libzip/zip_source_zip_new.c
index ecccdd68..3eb8a4c2 100644
--- a/src/Common/libzip/zip_source_zip_new.c
+++ b/src/Common/libzip/zip_source_zip_new.c
@@ -1,8 +1,8 @@
/*
zip_source_zip_new.c -- prepare data structures for zip_fopen/zip_source_zip
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -198,11 +198,11 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s
if (st.valid & ZIP_STAT_MTIME) {
st2.mtime = st.mtime;
st2.valid |= ZIP_STAT_MTIME;
}
- if ((src = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, &attributes, source_archive, source_index, take_ownership, error)) == NULL) {
+ if ((src = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, &attributes, &de->last_mod, source_archive, source_index, take_ownership, error)) == NULL) {
return NULL;
}
}
/* here we restrict src to file data, so no point in doing it for
source that already represents only the file data */
@@ -217,11 +217,11 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s
/* despite the fact that we want the whole data file, we still
wrap the source into a window source to add st and
attributes and to have a source that positions the read
offset properly before each read for multiple zip_file_t
referring to the same underlying source */
- if ((src = _zip_source_window_new(srcza->src, 0, (zip_int64_t)st.comp_size, &st, ZIP_STAT_NAME, &attributes, srcza, srcidx, take_ownership, error)) == NULL) {
+ if ((src = _zip_source_window_new(srcza->src, 0, (zip_int64_t)st.comp_size, &st, ZIP_STAT_NAME, &attributes, &de->last_mod, srcza, srcidx, take_ownership, error)) == NULL) {
return NULL;
}
}
else {
/* this branch gets executed when reading the whole changed
@@ -233,11 +233,11 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s
/* despite the fact that we want the whole data file, we still
wrap the source into a window source to add st and
attributes and to have a source that positions the read
offset properly before each read for multiple zip_file_t
referring to the same underlying source */
- if ((src = _zip_source_window_new(src, 0, data_len, &st, ZIP_STAT_NAME, &attributes, NULL, 0, take_ownership, error)) == NULL) {
+ if ((src = _zip_source_window_new(src, 0, data_len, &st, ZIP_STAT_NAME, &attributes, &de->last_mod, NULL, 0, take_ownership, error)) == NULL) {
return NULL;
}
}
/* In all cases, src is a window source and therefore is owned by this function. */
@@ -251,10 +251,11 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s
if (needs_decrypt) {
zip_encryption_implementation enc_impl;
if ((enc_impl = _zip_get_encryption_implementation(st.encryption_method, ZIP_CODEC_DECODE)) == NULL) {
+ zip_source_free(src);
zip_error_set(error, ZIP_ER_ENCRNOTSUPP, 0);
return NULL;
}
s2 = enc_impl(srcza, src, st.encryption_method, 0, password);
@@ -287,11 +288,11 @@ ZIP_EXTERN zip_source_t *zip_source_zip_file_create(zip_t *srcza, zip_uint64_t s
zip_stat_init(&st2);
if (data_len >= 0) {
st2.valid = ZIP_STAT_SIZE;
st2.size = (zip_uint64_t)data_len;
}
- s2 = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, NULL, NULL, 0, true, error);
+ s2 = _zip_source_window_new(src, start, data_len, &st2, ZIP_STAT_NAME, NULL, NULL, NULL, 0, true, error);
if (s2 == NULL) {
zip_source_free(src);
return NULL;
}
src = s2;
diff --git a/src/Common/libzip/zip_stat.c b/src/Common/libzip/zip_stat.c
index 51d8026d..74fc5c37 100644
--- a/src/Common/libzip/zip_stat.c
+++ b/src/Common/libzip/zip_stat.c
@@ -1,8 +1,8 @@
/*
zip_stat.c -- get information about file by name
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_stat_index.c b/src/Common/libzip/zip_stat_index.c
index da33c09e..af9f0e5f 100644
--- a/src/Common/libzip/zip_stat_index.c
+++ b/src/Common/libzip/zip_stat_index.c
@@ -1,8 +1,8 @@
/*
zip_stat_index.c -- get information about file by index
- Copyright (C) 1999-2020 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -75,32 +75,36 @@ zip_stat_index(zip_t *za, zip_uint64_t index, zip_flags_t flags, zip_stat_t *st)
st->valid |= ZIP_STAT_COMP_SIZE;
st->comp_size = st->size;
}
if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_LAST_MOD) {
- st->mtime = de->last_mod;
+ st->mtime = zip_dirent_get_last_mod_mtime(de);
st->valid |= ZIP_STAT_MTIME;
}
}
else {
zip_stat_init(st);
st->crc = de->crc;
st->size = de->uncomp_size;
- st->mtime = de->last_mod;
+ st->mtime = zip_dirent_get_last_mod_mtime(de);
st->comp_size = de->comp_size;
st->comp_method = (zip_uint16_t)de->comp_method;
st->encryption_method = de->encryption_method;
st->valid = (de->crc_valid ? ZIP_STAT_CRC : 0) | ZIP_STAT_SIZE | ZIP_STAT_MTIME | ZIP_STAT_COMP_SIZE | ZIP_STAT_COMP_METHOD | ZIP_STAT_ENCRYPTION_METHOD;
if (entry->changes != NULL && entry->changes->changed & ZIP_DIRENT_COMP_METHOD) {
st->valid &= ~ZIP_STAT_COMP_SIZE;
}
}
if ((za->ch_flags & ZIP_AFL_WANT_TORRENTZIP) && (flags & ZIP_FL_UNCHANGED) == 0) {
+ if (za->torrent_mtime == 0) {
+ zip_dostime_t dostime = {0xbc00, 0x2198};
+ za->torrent_mtime = _zip_d2u_time(&dostime);
+ }
st->comp_method = ZIP_CM_DEFLATE;
- st->mtime = _zip_d2u_time(0xbc00, 0x2198);
+ st->mtime = za->torrent_mtime;
st->valid |= ZIP_STAT_MTIME | ZIP_STAT_COMP_METHOD;
st->valid &= ~ZIP_STAT_COMP_SIZE;
}
st->index = index;
diff --git a/src/Common/libzip/zip_stat_init.c b/src/Common/libzip/zip_stat_init.c
index 9c6088a7..bd83565b 100644
--- a/src/Common/libzip/zip_stat_init.c
+++ b/src/Common/libzip/zip_stat_init.c
@@ -1,8 +1,8 @@
/*
zip_stat_init.c -- initialize struct zip_stat.
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_strerror.c b/src/Common/libzip/zip_strerror.c
index 7d827931..681024a3 100644
--- a/src/Common/libzip/zip_strerror.c
+++ b/src/Common/libzip/zip_strerror.c
@@ -1,8 +1,8 @@
/*
zip_sterror.c -- get string representation of zip error
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_string.c b/src/Common/libzip/zip_string.c
index 1c964491..bb06c1d6 100644
--- a/src/Common/libzip/zip_string.c
+++ b/src/Common/libzip/zip_string.c
@@ -1,8 +1,8 @@
/*
zip_string.c -- string handling (with encoding)
- Copyright (C) 2012-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2012-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -86,12 +86,14 @@ _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip
return empty;
}
if ((flags & ZIP_FL_ENC_RAW) == 0) {
/* start guessing */
- if (string->encoding == ZIP_ENCODING_UNKNOWN)
- _zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN);
+ if (string->encoding == ZIP_ENCODING_UNKNOWN) {
+ /* guess encoding, sets string->encoding */
+ (void)_zip_guess_encoding(string, ZIP_ENCODING_UNKNOWN);
+ }
if (((flags & ZIP_FL_ENC_STRICT) && string->encoding != ZIP_ENCODING_ASCII && string->encoding != ZIP_ENCODING_UTF8_KNOWN) || (string->encoding == ZIP_ENCODING_CP437)) {
if (string->converted == NULL) {
if ((string->converted = _zip_cp437_to_utf8(string->raw, string->length, &string->converted_length, error)) == NULL)
return NULL;
@@ -105,10 +107,24 @@ _zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip
if (lenp)
*lenp = string->length;
return string->raw;
}
+bool _zip_string_is_ascii(const zip_string_t *string) {
+ if (string->encoding != ZIP_ENCODING_ASCII) {
+ zip_uint16_t i;
+
+ for (i = 0; i < string->length; i++) {
+ if (string->raw[i] & 0x80) {
+ return false;
+ }
+ }
+ }
+
+ return true;
+}
+
zip_uint16_t
_zip_string_length(const zip_string_t *s) {
if (s == NULL)
return 0;
diff --git a/src/Common/libzip/zip_unchange_all.c b/src/Common/libzip/zip_unchange_all.c
index 34f3702e..0b22c803 100644
--- a/src/Common/libzip/zip_unchange_all.c
+++ b/src/Common/libzip/zip_unchange_all.c
@@ -1,8 +1,8 @@
/*
zip_unchange.c -- undo changes to all files in zip archive
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_unchange_archive.c b/src/Common/libzip/zip_unchange_archive.c
index 56a8e31f..ddd617bc 100644
--- a/src/Common/libzip/zip_unchange_archive.c
+++ b/src/Common/libzip/zip_unchange_archive.c
@@ -1,8 +1,8 @@
/*
zip_unchange_archive.c -- undo global changes to ZIP archive
- Copyright (C) 2006-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2006-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_unchange_data.c b/src/Common/libzip/zip_unchange_data.c
index 6bdecd18..30a7be7b 100644
--- a/src/Common/libzip/zip_unchange_data.c
+++ b/src/Common/libzip/zip_unchange_data.c
@@ -1,8 +1,8 @@
/*
zip_unchange_data.c -- undo helper function
- Copyright (C) 1999-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zip_utf-8.c b/src/Common/libzip/zip_utf-8.c
index 678912f6..7d671f60 100644
--- a/src/Common/libzip/zip_utf-8.c
+++ b/src/Common/libzip/zip_utf-8.c
@@ -1,8 +1,8 @@
/*
zip_utf-8.c -- UTF-8 support functions for libzip
- Copyright (C) 2011-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2011-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -99,74 +99,128 @@ static const zip_uint16_t _cp437_to_unicode[256] = {
zip_encoding_type_t
_zip_guess_encoding(zip_string_t *str, zip_encoding_type_t expected_encoding) {
zip_encoding_type_t enc;
const zip_uint8_t *name;
zip_uint32_t i, j, ulen;
+ bool can_be_ascii = true;
+ bool can_be_utf8 = true;
+ bool has_control_characters = false;
- if (str == NULL)
+ if (str == NULL) {
return ZIP_ENCODING_ASCII;
+ }
name = str->raw;
- if (str->encoding != ZIP_ENCODING_UNKNOWN)
- enc = str->encoding;
- else {
- enc = ZIP_ENCODING_ASCII;
- for (i = 0; i < str->length; i++) {
- if ((name[i] > 31 && name[i] < 128) || name[i] == '\r' || name[i] == '\n' || name[i] == '\t')
- continue;
-
- enc = ZIP_ENCODING_UTF8_GUESSED;
- if ((name[i] & UTF_8_LEN_2_MASK) == UTF_8_LEN_2_MATCH)
- ulen = 1;
- else if ((name[i] & UTF_8_LEN_3_MASK) == UTF_8_LEN_3_MATCH)
- ulen = 2;
- else if ((name[i] & UTF_8_LEN_4_MASK) == UTF_8_LEN_4_MATCH)
- ulen = 3;
- else {
- enc = ZIP_ENCODING_CP437;
- break;
- }
+ if (str->encoding != ZIP_ENCODING_UNKNOWN) {
+ return str->encoding;
+ }
- if (i + ulen >= str->length) {
- enc = ZIP_ENCODING_CP437;
- break;
+ for (i = 0; i < str->length; i++) {
+ if (name[i] < 128) {
+ if (name[i] < 32 && name[i] != '\r' && name[i] != '\n' && name[i] != '\t') {
+ has_control_characters = true;
}
+ continue;
+ }
+
+ can_be_ascii = false;
+ if ((name[i] & UTF_8_LEN_2_MASK) == UTF_8_LEN_2_MATCH) {
+ ulen = 1;
+ }
+ else if ((name[i] & UTF_8_LEN_3_MASK) == UTF_8_LEN_3_MATCH) {
+ ulen = 2;
+ }
+ else if ((name[i] & UTF_8_LEN_4_MASK) == UTF_8_LEN_4_MATCH) {
+ ulen = 3;
+ }
+ else {
+ can_be_utf8 = false;
+ break;
+ }
- for (j = 1; j <= ulen; j++) {
- if ((name[i + j] & UTF_8_CONTINUE_MASK) != UTF_8_CONTINUE_MATCH) {
- enc = ZIP_ENCODING_CP437;
- goto done;
- }
+ if (i + ulen >= str->length) {
+ can_be_utf8 = false;
+ break;
+ }
+
+ for (j = 1; j <= ulen; j++) {
+ if ((name[i + j] & UTF_8_CONTINUE_MASK) != UTF_8_CONTINUE_MATCH) {
+ can_be_utf8 = false;
+ goto done;
}
- i += ulen;
}
+ i += ulen;
}
-done:
- str->encoding = enc;
+ done:
+ enc = ZIP_ENCODING_CP437;
+
+ switch (expected_encoding) {
+ case ZIP_ENCODING_UTF8_KNOWN:
+ case ZIP_ENCODING_UTF8_GUESSED:
+ if (can_be_utf8) {
+ enc = ZIP_ENCODING_UTF8_KNOWN;
+ }
+ else {
+ enc = ZIP_ENCODING_ERROR;
+ }
+ break;
- if (expected_encoding != ZIP_ENCODING_UNKNOWN) {
- if (expected_encoding == ZIP_ENCODING_UTF8_KNOWN && enc == ZIP_ENCODING_UTF8_GUESSED)
- str->encoding = enc = ZIP_ENCODING_UTF8_KNOWN;
+ case ZIP_ENCODING_ASCII:
+ if (can_be_ascii && !has_control_characters) {
+ enc = ZIP_ENCODING_ASCII;
+ }
+ else {
+ enc = ZIP_ENCODING_ERROR;
+ }
+ break;
- if (expected_encoding != enc && enc != ZIP_ENCODING_ASCII)
- return ZIP_ENCODING_ERROR;
+ case ZIP_ENCODING_CP437:
+ enc = ZIP_ENCODING_CP437;
+ break;
+
+ case ZIP_ENCODING_UNKNOWN:
+ if (can_be_ascii && !has_control_characters) {
+ /* only bytes from 0x20-0x7F */
+ enc = ZIP_ENCODING_ASCII;
+ }
+ else if (can_be_ascii && has_control_characters) {
+ /* only bytes from 0x00-0x7F */
+ enc = ZIP_ENCODING_CP437;
+ }
+ else if (can_be_utf8) {
+ /* contains bytes from 0x80-0xFF and is valid UTF-8 */
+ enc = ZIP_ENCODING_UTF8_GUESSED;
+ }
+ else {
+ /* fallback */
+ enc = ZIP_ENCODING_CP437;
+ }
+ break;
+ case ZIP_ENCODING_ERROR:
+ /* invalid, shouldn't happen */
+ enc = ZIP_ENCODING_ERROR;
+ break;
}
+ str->encoding = enc;
return enc;
}
static zip_uint32_t
_zip_unicode_to_utf8_len(zip_uint32_t codepoint) {
- if (codepoint < 0x0080)
+ if (codepoint < 0x0080) {
return 1;
- if (codepoint < 0x0800)
+ }
+ if (codepoint < 0x0800) {
return 2;
- if (codepoint < 0x10000)
+ }
+ if (codepoint < 0x10000) {
return 3;
+ }
return 4;
}
static zip_uint32_t
@@ -199,28 +253,32 @@ _zip_cp437_to_utf8(const zip_uint8_t *const _cp437buf, zip_uint32_t len, zip_uin
zip_uint8_t *cp437buf = (zip_uint8_t *)_cp437buf;
zip_uint8_t *utf8buf;
zip_uint32_t buflen, i, offset;
if (len == 0) {
- if (utf8_lenp)
+ if (utf8_lenp) {
*utf8_lenp = 0;
+ }
return NULL;
}
buflen = 1;
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
buflen += _zip_unicode_to_utf8_len(_cp437_to_unicode[cp437buf[i]]);
+ }
if ((utf8buf = (zip_uint8_t *)malloc(buflen)) == NULL) {
zip_error_set(error, ZIP_ER_MEMORY, 0);
return NULL;
}
offset = 0;
- for (i = 0; i < len; i++)
+ for (i = 0; i < len; i++) {
offset += _zip_unicode_to_utf8(_cp437_to_unicode[cp437buf[i]], utf8buf + offset);
+ }
utf8buf[buflen - 1] = 0;
- if (utf8_lenp)
+ if (utf8_lenp) {
*utf8_lenp = buflen - 1;
+ }
return utf8buf;
}
diff --git a/src/Common/libzip/zip_winzip_aes.c b/src/Common/libzip/zip_winzip_aes.c
index ce269036..2c9874b0 100644
--- a/src/Common/libzip/zip_winzip_aes.c
+++ b/src/Common/libzip/zip_winzip_aes.c
@@ -1,8 +1,8 @@
/*
zip_winzip_aes.c -- Winzip AES de/encryption backend routines
- Copyright (C) 2017-2021 Dieter Baron and Thomas Klausner
+ Copyright (C) 2017-2022 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
diff --git a/src/Common/libzip/zipconf.h b/src/Common/libzip/zipconf.h
index 472e06c1..28954780 100644
--- a/src/Common/libzip/zipconf.h
+++ b/src/Common/libzip/zipconf.h
@@ -6,14 +6,14 @@
This file was generated automatically by CMake
based on ../cmake-zipconf.h.in.
*/
-#define LIBZIP_VERSION "1.10.1"
+#define LIBZIP_VERSION "1.11.2"
#define LIBZIP_VERSION_MAJOR 1
-#define LIBZIP_VERSION_MINOR 10
-#define LIBZIP_VERSION_MICRO 1
+#define LIBZIP_VERSION_MINOR 11
+#define LIBZIP_VERSION_MICRO 2
/* #undef ZIP_STATIC */
#define _Nullable
#define _Nonnull
diff --git a/src/Common/libzip/zipint.h b/src/Common/libzip/zipint.h
index 4887b6c5..e22d74c2 100644
--- a/src/Common/libzip/zipint.h
+++ b/src/Common/libzip/zipint.h
@@ -1,11 +1,11 @@
#ifndef _HAD_ZIPINT_H
#define _HAD_ZIPINT_H
/*
zipint.h -- internal declarations.
- Copyright (C) 1999-2022 Dieter Baron and Thomas Klausner
+ Copyright (C) 1999-2024 Dieter Baron and Thomas Klausner
This file is part of libzip, a library to manipulate ZIP archives.
The authors can be contacted at <info@libzip.org>
Redistribution and use in source and binary forms, with or without
@@ -54,10 +54,11 @@
#define LOCAL_MAGIC "PK\3\4"
#define EOCD_MAGIC "PK\5\6"
#define DATADES_MAGIC "PK\7\10"
#define EOCD64LOC_MAGIC "PK\6\7"
#define EOCD64_MAGIC "PK\6\6"
+#define MAGIC_LEN 4
#define CDENTRYSIZE 46u
#define LENTRYSIZE 30
#define MAXCOMLEN 65536
#define MAXEXTLEN 65536
#define EOCDLEN 22
@@ -227,16 +228,21 @@ extern const int _zip_err_details_count;
#define ZIP_ER_DETAIL_EOCD64_WRONG_MAGIC 9 /* G EOCD64 magic incorrect */
#define ZIP_ER_DETAIL_EOCD64_MISMATCH 10 /* G EOCD64 and EOCD do not match */
#define ZIP_ER_DETAIL_CDIR_INVALID 11 /* G invalid value in central directory */
#define ZIP_ER_DETAIL_VARIABLE_SIZE_OVERFLOW 12 /* E variable size fields overflow header */
#define ZIP_ER_DETAIL_INVALID_UTF8_IN_FILENAME 13 /* E invalid UTF-8 in filename */
-#define ZIP_ER_DETAIL_INVALID_UTF8_IN_COMMENT 13 /* E invalid UTF-8 in comment */
-#define ZIP_ER_DETAIL_INVALID_ZIP64_EF 14 /* E invalid Zip64 extra field */
-#define ZIP_ER_DETAIL_INVALID_WINZIPAES_EF 14 /* E invalid WinZip AES extra field */
-#define ZIP_ER_DETAIL_EF_TRAILING_GARBAGE 15 /* E garbage at end of extra fields */
-#define ZIP_ER_DETAIL_INVALID_EF_LENGTH 16 /* E extra field length is invalid */
-#define ZIP_ER_DETAIL_INVALID_FILE_LENGTH 17 /* E file length in header doesn't match actual file length */
+#define ZIP_ER_DETAIL_INVALID_UTF8_IN_COMMENT 14 /* E invalid UTF-8 in comment */
+#define ZIP_ER_DETAIL_INVALID_ZIP64_EF 15 /* E invalid Zip64 extra field */
+#define ZIP_ER_DETAIL_INVALID_WINZIPAES_EF 16 /* E invalid WinZip AES extra field */
+#define ZIP_ER_DETAIL_EF_TRAILING_GARBAGE 17 /* E garbage at end of extra fields */
+#define ZIP_ER_DETAIL_INVALID_EF_LENGTH 18 /* E extra field length is invalid */
+#define ZIP_ER_DETAIL_INVALID_FILE_LENGTH 19 /* E file length in header doesn't match actual file length */
+#define ZIP_ER_DETAIL_STORED_SIZE_MISMATCH 20 /* E compressed and uncompressed sizes don't match for stored file */
+#define ZIP_ER_DETAIL_DATA_DESCRIPTOR_MISMATCH 21 /* E local header and data descriptor do not match */
+#define ZIP_ER_DETAIL_EOCD64_LOCATOR_MISMATCH 22 /* G EOCD64 and EOCD64 locator do not match */
+#define ZIP_ER_DETAIL_UTF8_FILENAME_MISMATCH 23 /* E UTF-8 filename is ASCII and doesn't match filename */
+#define ZIP_ER_DETAIL_UTF8_COMMENT_MISMATCH 24 /* E UTF-8 comment is ASCII and doesn't match comment */
/* directory entry: general purpose bit flags */
#define ZIP_GPBF_ENCRYPTED 0x0001u /* is encrypted */
#define ZIP_GPBF_DATA_DESCRIPTOR 0x0008u /* crc/size after file data */
@@ -268,10 +274,11 @@ typedef enum zip_encoding_type zip_encoding_type_t;
struct zip_hash;
struct zip_progress;
typedef struct zip_cdir zip_cdir_t;
+typedef struct zip_dostime zip_dostime_t;
typedef struct zip_dirent zip_dirent_t;
typedef struct zip_entry zip_entry_t;
typedef struct zip_extra_field zip_extra_field_t;
typedef struct zip_string zip_string_t;
typedef struct zip_buffer zip_buffer_t;
@@ -305,10 +312,11 @@ struct zip {
zip_hash_t *names; /* hash table for name lookup */
zip_progress_t *progress; /* progress callback for zip_close() */
zip_uint32_t* write_crc; /* have _zip_write() compute CRC */
+ time_t torrent_mtime;
};
/* file in zip archive, part of API */
struct zip_file {
@@ -326,22 +334,28 @@ struct zip_file {
#define ZIP_DIRENT_LAST_MOD 0x0020u
#define ZIP_DIRENT_ENCRYPTION_METHOD 0x0040u
#define ZIP_DIRENT_PASSWORD 0x0080u
#define ZIP_DIRENT_ALL ZIP_UINT32_MAX
+struct zip_dostime {
+ zip_uint16_t time;
+ zip_uint16_t date;
+};
+
struct zip_dirent {
zip_uint32_t changed;
bool local_extra_fields_read; /* whether we already read in local header extra fields */
bool cloned; /* whether this instance is cloned, and thus shares non-changed strings */
bool crc_valid; /* if CRC is valid (sometimes not for encrypted archives) */
+ bool last_mod_mtime_valid;
zip_uint16_t version_madeby; /* (c) version of creator */
zip_uint16_t version_needed; /* (cl) version needed to extract */
zip_uint16_t bitflags; /* (cl) general purpose bit flag */
zip_int32_t comp_method; /* (cl) compression method used (uint16 and ZIP_CM_DEFAULT (-1)) */
- time_t last_mod; /* (cl) time of last modification */
+ zip_dostime_t last_mod; /* (cl) time of last modification */
zip_uint32_t crc; /* (cl) CRC-32 of uncompressed data */
zip_uint64_t comp_size; /* (cl) size of compressed data */
zip_uint64_t uncomp_size; /* (cl) size of uncompressed data */
zip_string_t *filename; /* (cl) file name (NUL-terminated) */
zip_extra_field_t *extra_fields; /* (cl) extra fields, parsed */
@@ -352,21 +366,28 @@ struct zip_dirent {
zip_uint64_t offset; /* (c) offset of local header */
zip_uint32_t compression_level; /* level of compression to use (never valid in orig) */
zip_uint16_t encryption_method; /* encryption method, computed from other fields */
char *password; /* file specific encryption password */
+
+ time_t last_mod_mtime; /* cached last_mod in Unix time format */
};
/* zip archive central directory */
struct zip_cdir {
zip_entry_t *entry; /* directory entries */
zip_uint64_t nentry; /* number of entries */
zip_uint64_t nentry_alloc; /* number of entries allocated */
+ zip_uint32_t this_disk;
+ zip_uint32_t eocd_disk;
+ zip_uint64_t disk_entries; /* number of entries on this disk */
+ zip_uint64_t num_entries; /* number of entries on all disks */
zip_uint64_t size; /* size of central directory */
zip_uint64_t offset; /* offset of central directory in file */
+ zip_uint64_t eocd_offset; /* offset of EOCD in file */
zip_string_t *comment; /* zip archive comment */
bool is_zip64; /* central directory in zip64 format */
};
struct zip_extra_field {
@@ -524,24 +545,26 @@ int _zip_buffer_skip(zip_buffer_t *buffer, zip_uint64_t length);
int _zip_buffer_set_offset(zip_buffer_t *buffer, zip_uint64_t offset);
zip_uint64_t _zip_buffer_size(zip_buffer_t *buffer);
void _zip_cdir_free(zip_cdir_t *);
bool _zip_cdir_grow(zip_cdir_t *cd, zip_uint64_t additional_entries, zip_error_t *error);
-zip_cdir_t *_zip_cdir_new(zip_uint64_t, zip_error_t *);
+zip_cdir_t *_zip_cdir_new(zip_error_t *);
zip_int64_t _zip_cdir_write(zip_t *za, const zip_filelist_t *filelist, zip_uint64_t survivors);
-time_t _zip_d2u_time(zip_uint16_t, zip_uint16_t);
+time_t _zip_d2u_time(const zip_dostime_t*);
void _zip_deregister_source(zip_t *za, zip_source_t *src);
void _zip_dirent_apply_attributes(zip_dirent_t *, zip_file_attributes_t *, bool, zip_uint32_t);
+int zip_dirent_check_consistency(zip_dirent_t *dirent);
zip_dirent_t *_zip_dirent_clone(const zip_dirent_t *);
void _zip_dirent_free(zip_dirent_t *);
void _zip_dirent_finalize(zip_dirent_t *);
+time_t zip_dirent_get_last_mod_mtime(zip_dirent_t *de);
void _zip_dirent_init(zip_dirent_t *);
bool _zip_dirent_needs_zip64(const zip_dirent_t *, zip_flags_t);
zip_dirent_t *_zip_dirent_new(void);
bool zip_dirent_process_ef_zip64(zip_dirent_t * zde, const zip_uint8_t * ef, zip_uint64_t got_len, bool local, zip_error_t * error);
-zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_error_t *error);
+zip_int64_t _zip_dirent_read(zip_dirent_t *zde, zip_source_t *src, zip_buffer_t *buffer, bool local, zip_uint64_t central_compressed_size, bool check_consistency, zip_error_t *error);
void _zip_dirent_set_version_needed(zip_dirent_t *de, bool force_zip64);
void zip_dirent_torrentzip_normalize(zip_dirent_t *de);
zip_int32_t _zip_dirent_size(zip_source_t *src, zip_uint16_t, zip_error_t *);
int _zip_dirent_write(zip_t *za, zip_dirent_t *dirent, zip_flags_t flags);
@@ -609,22 +632,25 @@ int _zip_register_source(zip_t *za, zip_source_t *src);
void _zip_set_open_error(int *zep, const zip_error_t *err, int ze);
bool zip_source_accept_empty(zip_source_t *src);
zip_int64_t _zip_source_call(zip_source_t *src, void *data, zip_uint64_t length, zip_source_cmd_t command);
bool _zip_source_eof(zip_source_t *);
+int zip_source_get_dos_time(zip_source_t *src, zip_dostime_t *dos_time);
+
zip_source_t *_zip_source_file_or_p(const char *, FILE *, zip_uint64_t, zip_int64_t, const zip_stat_t *, zip_error_t *error);
bool _zip_source_had_error(zip_source_t *);
void _zip_source_invalidate(zip_source_t *src);
zip_source_t *_zip_source_new(zip_error_t *error);
int _zip_source_set_source_archive(zip_source_t *, zip_t *);
-zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error);
+zip_source_t *_zip_source_window_new(zip_source_t *src, zip_uint64_t start, zip_int64_t length, zip_stat_t *st, zip_uint64_t st_invalid, zip_file_attributes_t *attributes, zip_dostime_t *dostime, zip_t *source_archive, zip_uint64_t source_index, bool take_ownership, zip_error_t *error);
int _zip_stat_merge(zip_stat_t *dst, const zip_stat_t *src, zip_error_t *error);
int _zip_string_equal(const zip_string_t *a, const zip_string_t *b);
void _zip_string_free(zip_string_t *string);
zip_uint32_t _zip_string_crc32(const zip_string_t *string);
const zip_uint8_t *_zip_string_get(zip_string_t *string, zip_uint32_t *lenp, zip_flags_t flags, zip_error_t *error);
+bool _zip_string_is_ascii(const zip_string_t *string);
zip_uint16_t _zip_string_length(const zip_string_t *string);
zip_string_t *_zip_string_new(const zip_uint8_t *raw, zip_uint16_t length, zip_flags_t flags, zip_error_t *error);
int _zip_string_write(zip_t *za, const zip_string_t *string);
bool _zip_winzip_aes_decrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length);
bool _zip_winzip_aes_encrypt(zip_winzip_aes_t *ctx, zip_uint8_t *data, zip_uint64_t length);
@@ -645,11 +671,11 @@ void *_zip_memdup(const void *, size_t, zip_error_t *);
zip_int64_t _zip_name_locate(zip_t *, const char *, zip_flags_t, zip_error_t *);
zip_t *_zip_new(zip_error_t *);
zip_int64_t _zip_file_replace(zip_t *, zip_uint64_t, const char *, zip_source_t *, zip_flags_t);
int _zip_set_name(zip_t *, zip_uint64_t, const char *, zip_flags_t);
-void _zip_u2d_time(time_t, zip_uint16_t *, zip_uint16_t *);
+int _zip_u2d_time(time_t, zip_dostime_t *, zip_error_t *);
int _zip_unchange(zip_t *, zip_uint64_t, int);
void _zip_unchange_data(zip_entry_t *);
int _zip_write(zip_t *za, const void *data, zip_uint64_t length);
-#endif /* zipint.h */
+#endif /* _HAD_ZIPINT_H */
diff --git a/src/Common/lzma/7zTypes.h b/src/Common/lzma/7zTypes.h
index 1fcb2473..5b77420a 100644
--- a/src/Common/lzma/7zTypes.h
+++ b/src/Common/lzma/7zTypes.h
@@ -1,7 +1,7 @@
/* 7zTypes.h -- Basic types
-2023-04-02 : Igor Pavlov : Public domain */
+2024-01-24 : Igor Pavlov : Public domain */
#ifndef ZIP7_7Z_TYPES_H
#define ZIP7_7Z_TYPES_H
#ifdef _WIN32
@@ -528,24 +528,24 @@ struct ISzAlloc
#define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL_SIMPLE(ptr, type, m)
/*
#define Z7_CONTAINER_FROM_VTBL_CLS(ptr, type, m) Z7_CONTAINER_FROM_VTBL(ptr, type, m)
*/
#if defined (__clang__) || defined(__GNUC__)
-#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \
+#define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wcast-qual\"")
-#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL \
+#define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL \
_Pragma("GCC diagnostic pop")
#else
-#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL
-#define Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL
+#define Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL
+#define Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL
#endif
#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(ptr, type, m, p) \
- Z7_DIAGNOSCTIC_IGNORE_BEGIN_CAST_QUAL \
+ Z7_DIAGNOSTIC_IGNORE_BEGIN_CAST_QUAL \
type *p = Z7_CONTAINER_FROM_VTBL(ptr, type, m); \
- Z7_DIAGNOSCTIC_IGNORE_END_CAST_QUAL
+ Z7_DIAGNOSTIC_IGNORE_END_CAST_QUAL
#define Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR_pp_vt_p(type) \
Z7_CONTAINER_FROM_VTBL_TO_DECL_VAR(pp, type, vt, p)
diff --git a/src/Common/lzma/Alloc.c b/src/Common/lzma/Alloc.c
index d841bf20..63e1a121 100644
--- a/src/Common/lzma/Alloc.c
+++ b/src/Common/lzma/Alloc.c
@@ -1,30 +1,29 @@
/* Alloc.c -- Memory allocation functions
-2023-04-02 : Igor Pavlov : Public domain */
+2024-02-18 : Igor Pavlov : Public domain */
#include "Precomp.h"
#ifdef _WIN32
#include "7zWindows.h"
#endif
#include <stdlib.h>
#include "Alloc.h"
-#ifdef _WIN32
-#ifdef Z7_LARGE_PAGES
-#if defined(__clang__) || defined(__GNUC__)
-typedef void (*Z7_voidFunction)(void);
-#define MY_CAST_FUNC (Z7_voidFunction)
-#elif defined(_MSC_VER) && _MSC_VER > 1920
-#define MY_CAST_FUNC (void *)
-// #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()'
-#else
-#define MY_CAST_FUNC
+#if defined(Z7_LARGE_PAGES) && defined(_WIN32) && \
+ (!defined(Z7_WIN32_WINNT_MIN) || Z7_WIN32_WINNT_MIN < 0x0502) // < Win2003 (xp-64)
+ #define Z7_USE_DYN_GetLargePageMinimum
+#endif
+
+// for debug:
+#if 0
+#if defined(__CHERI__) && defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 16)
+// #pragma message("=== Z7_ALLOC_NO_OFFSET_ALLOCATOR === ")
+#define Z7_ALLOC_NO_OFFSET_ALLOCATOR
+#endif
#endif
-#endif // Z7_LARGE_PAGES
-#endif // _WIN32
// #define SZ_ALLOC_DEBUG
/* #define SZ_ALLOC_DEBUG */
/* use SZ_ALLOC_DEBUG to debug alloc/free operations */
@@ -144,11 +143,13 @@ static void PrintAddr(void *p)
#define PRINT_ALLOC(name, cnt, size, ptr)
#endif
#define PRINT_FREE(name, cnt, ptr)
#define Print(s)
#define PrintLn()
+#ifndef Z7_ALLOC_NO_OFFSET_ALLOCATOR
#define PrintHex(v, align)
+#endif
#define PrintAddr(p)
#endif
@@ -244,35 +245,39 @@ void MidFree(void *address)
}
#ifdef Z7_LARGE_PAGES
#ifdef MEM_LARGE_PAGES
- #define MY__MEM_LARGE_PAGES MEM_LARGE_PAGES
+ #define MY_MEM_LARGE_PAGES MEM_LARGE_PAGES
#else
- #define MY__MEM_LARGE_PAGES 0x20000000
+ #define MY_MEM_LARGE_PAGES 0x20000000
#endif
extern
SIZE_T g_LargePageSize;
SIZE_T g_LargePageSize = 0;
typedef SIZE_T (WINAPI *Func_GetLargePageMinimum)(VOID);
void SetLargePageSize(void)
{
- #ifdef Z7_LARGE_PAGES
SIZE_T size;
+#ifdef Z7_USE_DYN_GetLargePageMinimum
+Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION
+
const
Func_GetLargePageMinimum fn =
- (Func_GetLargePageMinimum) MY_CAST_FUNC GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
+ (Func_GetLargePageMinimum) Z7_CAST_FUNC_C GetProcAddress(GetModuleHandle(TEXT("kernel32.dll")),
"GetLargePageMinimum");
if (!fn)
return;
size = fn();
+#else
+ size = GetLargePageMinimum();
+#endif
if (size == 0 || (size & (size - 1)) != 0)
return;
g_LargePageSize = size;
- #endif
}
#endif // Z7_LARGE_PAGES
void *BigAlloc(size_t size)
@@ -290,11 +295,11 @@ void *BigAlloc(size_t size)
size_t size2;
ps--;
size2 = (size + ps) & ~ps;
if (size2 >= size)
{
- void *p = VirtualAlloc(NULL, size2, MEM_COMMIT | MY__MEM_LARGE_PAGES, PAGE_READWRITE);
+ void *p = VirtualAlloc(NULL, size2, MEM_COMMIT | MY_MEM_LARGE_PAGES, PAGE_READWRITE);
if (p)
{
PRINT_ALLOC("Alloc-BM ", g_allocCountMid, size2, p)
return p;
}
@@ -326,42 +331,51 @@ static void *SzBigAlloc(ISzAllocPtr p, size_t size) { UNUSED_VAR(p) return BigA
static void SzBigFree(ISzAllocPtr p, void *address) { UNUSED_VAR(p) BigFree(address); }
const ISzAlloc g_MidAlloc = { SzMidAlloc, SzMidFree };
const ISzAlloc g_BigAlloc = { SzBigAlloc, SzBigFree };
#endif
-/*
- uintptr_t : <stdint.h> C99 (optional)
- : unsupported in VS6
-*/
-
-#ifdef _WIN32
- typedef UINT_PTR UIntPtr;
-#else
- /*
- typedef uintptr_t UIntPtr;
- */
- typedef ptrdiff_t UIntPtr;
-#endif
-
+#ifndef Z7_ALLOC_NO_OFFSET_ALLOCATOR
#define ADJUST_ALLOC_SIZE 0
/*
#define ADJUST_ALLOC_SIZE (sizeof(void *) - 1)
*/
/*
Use (ADJUST_ALLOC_SIZE = (sizeof(void *) - 1)), if
MyAlloc() can return address that is NOT multiple of sizeof(void *).
*/
-
/*
-#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((char *)(p) - ((size_t)(UIntPtr)(p) & ((align) - 1))))
+ uintptr_t : <stdint.h> C99 (optional)
+ : unsupported in VS6
*/
-#define MY_ALIGN_PTR_DOWN(p, align) ((void *)((((UIntPtr)(p)) & ~((UIntPtr)(align) - 1))))
+typedef
+ #ifdef _WIN32
+ UINT_PTR
+ #elif 1
+ uintptr_t
+ #else
+ ptrdiff_t
+ #endif
+ MY_uintptr_t;
+
+#if 0 \
+ || (defined(__CHERI__) \
+ || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ > 8))
+// for 128-bit pointers (cheri):
+#define MY_ALIGN_PTR_DOWN(p, align) \
+ ((void *)((char *)(p) - ((size_t)(MY_uintptr_t)(p) & ((align) - 1))))
+#else
+#define MY_ALIGN_PTR_DOWN(p, align) \
+ ((void *)((((MY_uintptr_t)(p)) & ~((MY_uintptr_t)(align) - 1))))
+#endif
+#endif
-#if !defined(_WIN32) && defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L)
+#if !defined(_WIN32) \
+ && (defined(Z7_ALLOC_NO_OFFSET_ALLOCATOR) \
+ || defined(_POSIX_C_SOURCE) && (_POSIX_C_SOURCE >= 200112L))
#define USE_posix_memalign
#endif
#ifndef USE_posix_memalign
#define MY_ALIGN_PTR_UP_PLUS(p, align) MY_ALIGN_PTR_DOWN(((char *)(p) + (align) + ADJUST_ALLOC_SIZE), align)
@@ -397,18 +411,17 @@ static int posix_memalign(void **ptr, size_t align, size_t size)
ALLOC_ALIGN_SIZE >= cache_line_size
*/
#define ALLOC_ALIGN_SIZE ((size_t)1 << 7)
-static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size)
+void *z7_AlignedAlloc(size_t size)
{
- #ifndef USE_posix_memalign
+#ifndef USE_posix_memalign
void *p;
void *pAligned;
size_t newSize;
- UNUSED_VAR(pp)
/* also we can allocate additional dummy ALLOC_ALIGN_SIZE bytes after aligned
block to prevent cache line sharing with another allocated blocks */
newSize = size + ALLOC_ALIGN_SIZE * 1 + ADJUST_ALLOC_SIZE;
@@ -429,52 +442,97 @@ static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size)
((void **)pAligned)[-1] = p;
return pAligned;
- #else
+#else
void *p;
- UNUSED_VAR(pp)
if (posix_memalign(&p, ALLOC_ALIGN_SIZE, size))
return NULL;
Print(" posix_memalign="); PrintAddr(p);
PrintLn();
return p;
- #endif
+#endif
+}
+
+
+void z7_AlignedFree(void *address)
+{
+#ifndef USE_posix_memalign
+ if (address)
+ MyFree(((void **)address)[-1]);
+#else
+ free(address);
+#endif
+}
+
+
+static void *SzAlignedAlloc(ISzAllocPtr pp, size_t size)
+{
+ UNUSED_VAR(pp)
+ return z7_AlignedAlloc(size);
}
static void SzAlignedFree(ISzAllocPtr pp, void *address)
{
UNUSED_VAR(pp)
- #ifndef USE_posix_memalign
+#ifndef USE_posix_memalign
if (address)
MyFree(((void **)address)[-1]);
- #else
+#else
free(address);
- #endif
+#endif
}
const ISzAlloc g_AlignedAlloc = { SzAlignedAlloc, SzAlignedFree };
-#define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *))
-
/* we align ptr to support cases where CAlignOffsetAlloc::offset is not multiply of sizeof(void *) */
-#define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1]
-/*
-#define REAL_BLOCK_PTR_VAR(p) ((void **)(p))[-1]
-*/
+#ifndef Z7_ALLOC_NO_OFFSET_ALLOCATOR
+#if 1
+ #define MY_ALIGN_PTR_DOWN_1(p) MY_ALIGN_PTR_DOWN(p, sizeof(void *))
+ #define REAL_BLOCK_PTR_VAR(p) ((void **)MY_ALIGN_PTR_DOWN_1(p))[-1]
+#else
+ // we can use this simplified code,
+ // if (CAlignOffsetAlloc::offset == (k * sizeof(void *))
+ #define REAL_BLOCK_PTR_VAR(p) (((void **)(p))[-1])
+#endif
+#endif
+
+
+#if 0
+#ifndef Z7_ALLOC_NO_OFFSET_ALLOCATOR
+#include <stdio.h>
+static void PrintPtr(const char *s, const void *p)
+{
+ const Byte *p2 = (const Byte *)&p;
+ unsigned i;
+ printf("%s %p ", s, p);
+ for (i = sizeof(p); i != 0;)
+ {
+ i--;
+ printf("%02x", p2[i]);
+ }
+ printf("\n");
+}
+#endif
+#endif
+
static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size)
{
+#if defined(Z7_ALLOC_NO_OFFSET_ALLOCATOR)
+ UNUSED_VAR(pp)
+ return z7_AlignedAlloc(size);
+#else
const CAlignOffsetAlloc *p = Z7_CONTAINER_FROM_VTBL_CONST(pp, CAlignOffsetAlloc, vt);
void *adr;
void *pAligned;
size_t newSize;
size_t extra;
@@ -499,10 +557,16 @@ static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size)
return NULL;
pAligned = (char *)MY_ALIGN_PTR_DOWN((char *)adr +
alignSize - p->offset + extra + ADJUST_ALLOC_SIZE, alignSize) + p->offset;
+#if 0
+ printf("\nalignSize = %6x, offset=%6x, size=%8x \n", (unsigned)alignSize, (unsigned)p->offset, (unsigned)size);
+ PrintPtr("base", adr);
+ PrintPtr("alig", pAligned);
+#endif
+
PrintLn();
Print("- Aligned: ");
Print(" size="); PrintHex(size, 8);
Print(" a_size="); PrintHex(newSize, 8);
Print(" ptr="); PrintAddr(adr);
@@ -510,23 +574,29 @@ static void *AlignOffsetAlloc_Alloc(ISzAllocPtr pp, size_t size)
PrintLn();
REAL_BLOCK_PTR_VAR(pAligned) = adr;
return pAligned;
+#endif
}
static void AlignOffsetAlloc_Free(ISzAllocPtr pp, void *address)
{
+#if defined(Z7_ALLOC_NO_OFFSET_ALLOCATOR)
+ UNUSED_VAR(pp)
+ z7_AlignedFree(address);
+#else
if (address)
{
const CAlignOffsetAlloc *p = Z7_CONTAINER_FROM_VTBL_CONST(pp, CAlignOffsetAlloc, vt);
PrintLn();
Print("- Aligned Free: ");
PrintLn();
ISzAlloc_Free(p->baseAlloc, REAL_BLOCK_PTR_VAR(address));
}
+#endif
}
void AlignOffsetAlloc_CreateVTable(CAlignOffsetAlloc *p)
{
diff --git a/src/Common/lzma/Alloc.h b/src/Common/lzma/Alloc.h
index fac5b62f..01bf6b7d 100644
--- a/src/Common/lzma/Alloc.h
+++ b/src/Common/lzma/Alloc.h
@@ -1,7 +1,7 @@
/* Alloc.h -- Memory allocation functions
-2023-03-04 : Igor Pavlov : Public domain */
+2024-01-22 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_ALLOC_H
#define ZIP7_INC_ALLOC_H
#include "7zTypes.h"
@@ -20,10 +20,13 @@ MyRealloc() is similar to realloc() for the following cases:
void *MyAlloc(size_t size);
void MyFree(void *address);
void *MyRealloc(void *address, size_t size);
+void *z7_AlignedAlloc(size_t size);
+void z7_AlignedFree(void *p);
+
#ifdef _WIN32
#ifdef Z7_LARGE_PAGES
void SetLargePageSize(void);
#endif
@@ -31,16 +34,18 @@ void SetLargePageSize(void);
void *MidAlloc(size_t size);
void MidFree(void *address);
void *BigAlloc(size_t size);
void BigFree(void *address);
+/* #define Z7_BIG_ALLOC_IS_ZERO_FILLED */
+
#else
-#define MidAlloc(size) MyAlloc(size)
-#define MidFree(address) MyFree(address)
-#define BigAlloc(size) MyAlloc(size)
-#define BigFree(address) MyFree(address)
+#define MidAlloc(size) z7_AlignedAlloc(size)
+#define MidFree(address) z7_AlignedFree(address)
+#define BigAlloc(size) z7_AlignedAlloc(size)
+#define BigFree(address) z7_AlignedFree(address)
#endif
extern const ISzAlloc g_Alloc;
diff --git a/src/Common/lzma/Compiler.h b/src/Common/lzma/Compiler.h
index 185a52de..2a9c2b7a 100644
--- a/src/Common/lzma/Compiler.h
+++ b/src/Common/lzma/Compiler.h
@@ -1,7 +1,7 @@
/* Compiler.h : Compiler specific defines and pragmas
-2023-04-02 : Igor Pavlov : Public domain */
+2024-01-22 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_COMPILER_H
#define ZIP7_INC_COMPILER_H
#if defined(__clang__)
@@ -23,15 +23,83 @@
#if defined(__MINGW32__) || defined(__MINGW64__)
#define Z7_MINGW
#endif
+#if defined(__LCC__) && (defined(__MCST__) || defined(__e2k__))
+#define Z7_MCST_LCC
+#define Z7_MCST_LCC_VERSION (__LCC__ * 100 + __LCC_MINOR__)
+#endif
+
+/*
+#if defined(__AVX2__) \
+ || defined(Z7_GCC_VERSION) && (Z7_GCC_VERSION >= 40900) \
+ || defined(Z7_APPLE_CLANG_VERSION) && (Z7_APPLE_CLANG_VERSION >= 40600) \
+ || defined(Z7_LLVM_CLANG_VERSION) && (Z7_LLVM_CLANG_VERSION >= 30100) \
+ || defined(Z7_MSC_VER_ORIGINAL) && (Z7_MSC_VER_ORIGINAL >= 1800) \
+ || defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1400)
+ #define Z7_COMPILER_AVX2_SUPPORTED
+ #endif
+#endif
+*/
+
// #pragma GCC diagnostic ignored "-Wunknown-pragmas"
#ifdef __clang__
// padding size of '' with 4 bytes to alignment boundary
#pragma GCC diagnostic ignored "-Wpadded"
+
+#if defined(Z7_LLVM_CLANG_VERSION) && (__clang_major__ == 13) \
+ && defined(__FreeBSD__)
+// freebsd:
+#pragma GCC diagnostic ignored "-Wexcess-padding"
+#endif
+
+#if __clang_major__ >= 16
+#pragma GCC diagnostic ignored "-Wunsafe-buffer-usage"
+#endif
+
+#if __clang_major__ == 13
+#if defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 16)
+// cheri
+#pragma GCC diagnostic ignored "-Wcapability-to-integer-cast"
+#endif
+#endif
+
+#if __clang_major__ == 13
+ // for <arm_neon.h>
+ #pragma GCC diagnostic ignored "-Wreserved-identifier"
+#endif
+
+#endif // __clang__
+
+#if defined(_WIN32) && defined(__clang__) && __clang_major__ >= 16
+// #pragma GCC diagnostic ignored "-Wcast-function-type-strict"
+#define Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION \
+ _Pragma("GCC diagnostic ignored \"-Wcast-function-type-strict\"")
+#else
+#define Z7_DIAGNOSTIC_IGNORE_CAST_FUNCTION
+#endif
+
+typedef void (*Z7_void_Function)(void);
+#if defined(__clang__) || defined(__GNUC__)
+#define Z7_CAST_FUNC_C (Z7_void_Function)
+#elif defined(_MSC_VER) && _MSC_VER > 1920
+#define Z7_CAST_FUNC_C (void *)
+// #pragma warning(disable : 4191) // 'type cast': unsafe conversion from 'FARPROC' to 'void (__cdecl *)()'
+#else
+#define Z7_CAST_FUNC_C
+#endif
+/*
+#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__)
+ // #pragma GCC diagnostic ignored "-Wcast-function-type"
+#endif
+*/
+#ifdef __GNUC__
+#if defined(Z7_GCC_VERSION) && (Z7_GCC_VERSION >= 40000) && (Z7_GCC_VERSION < 70000)
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
+#endif
#endif
#ifdef _MSC_VER
@@ -99,11 +167,12 @@
#if defined(__clang__) && (__clang_major__ >= 4)
#define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \
_Pragma("clang loop unroll(disable)") \
_Pragma("clang loop vectorize(disable)")
#define Z7_ATTRIB_NO_VECTORIZE
-#elif defined(__GNUC__) && (__GNUC__ >= 5)
+#elif defined(__GNUC__) && (__GNUC__ >= 5) \
+ && (!defined(Z7_MCST_LCC_VERSION) || (Z7_MCST_LCC_VERSION >= 12610))
#define Z7_ATTRIB_NO_VECTORIZE __attribute__((optimize("no-tree-vectorize")))
// __attribute__((optimize("no-unroll-loops")));
#define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE
#elif defined(_MSC_VER) && (_MSC_VER >= 1920)
#define Z7_PRAGMA_OPT_DISABLE_LOOP_UNROLL_VECTORIZE \
@@ -140,19 +209,27 @@
#define Z7_UNLIKELY(x) (x)
// #define Z7_likely
#endif
-#if (defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 36000))
-#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER \
+#if (defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 30600))
+
+#if (Z7_CLANG_VERSION < 130000)
+#define Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER \
+ _Pragma("GCC diagnostic push") \
+ _Pragma("GCC diagnostic ignored \"-Wreserved-id-macro\"")
+#else
+#define Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER \
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wreserved-macro-identifier\"")
-#define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER \
+#endif
+
+#define Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER \
_Pragma("GCC diagnostic pop")
#else
-#define Z7_DIAGNOSCTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
-#define Z7_DIAGNOSCTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
+#define Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
+#define Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
#endif
#define UNUSED_VAR(x) (void)x;
/* #define UNUSED_VAR(x) x=x; */
diff --git a/src/Common/lzma/CpuArch.c b/src/Common/lzma/CpuArch.c
index 33f8a3ab..6e02551e 100644
--- a/src/Common/lzma/CpuArch.c
+++ b/src/Common/lzma/CpuArch.c
@@ -1,7 +1,7 @@
/* CpuArch.c -- CPU specific code
-2023-05-18 : Igor Pavlov : Public domain */
+Igor Pavlov : Public domain */
#include "Precomp.h"
// #include <stdio.h>
@@ -15,11 +15,11 @@
#endif
/*
cpuid instruction supports (subFunction) parameter in ECX,
that is used only with some specific (function) parameter values.
- But we always use only (subFunction==0).
+ most functions use only (subFunction==0).
*/
/*
__cpuid(): MSVC and GCC/CLANG use same function/macro name
but parameters are different.
We use MSVC __cpuid() parameters style for our z7_x86_cpuid() function.
@@ -47,47 +47,53 @@
#define ASM_LN "\n"
#if defined(MY_CPU_AMD64) && defined(__PIC__) \
&& ((defined (__GNUC__) && (__GNUC__ < 5)) || defined(__clang__))
-#define x86_cpuid_MACRO(p, func) { \
+ /* "=&r" selects free register. It can select even rbx, if that register is free.
+ "=&D" for (RDI) also works, but the code can be larger with "=&D"
+ "2"(subFun) : 2 is (zero-based) index in the output constraint list "=c" (ECX). */
+
+#define x86_cpuid_MACRO_2(p, func, subFunc) { \
__asm__ __volatile__ ( \
ASM_LN "mov %%rbx, %q1" \
ASM_LN "cpuid" \
ASM_LN "xchg %%rbx, %q1" \
- : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); }
-
- /* "=&r" selects free register. It can select even rbx, if that register is free.
- "=&D" for (RDI) also works, but the code can be larger with "=&D"
- "2"(0) means (subFunction = 0),
- 2 is (zero-based) index in the output constraint list "=c" (ECX). */
+ : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(subFunc)); }
#elif defined(MY_CPU_X86) && defined(__PIC__) \
&& ((defined (__GNUC__) && (__GNUC__ < 5)) || defined(__clang__))
-#define x86_cpuid_MACRO(p, func) { \
+#define x86_cpuid_MACRO_2(p, func, subFunc) { \
__asm__ __volatile__ ( \
ASM_LN "mov %%ebx, %k1" \
ASM_LN "cpuid" \
ASM_LN "xchg %%ebx, %k1" \
- : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); }
+ : "=a" ((p)[0]), "=&r" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(subFunc)); }
#else
-#define x86_cpuid_MACRO(p, func) { \
+#define x86_cpuid_MACRO_2(p, func, subFunc) { \
__asm__ __volatile__ ( \
ASM_LN "cpuid" \
- : "=a" ((p)[0]), "=b" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(0)); }
+ : "=a" ((p)[0]), "=b" ((p)[1]), "=c" ((p)[2]), "=d" ((p)[3]) : "0" (func), "2"(subFunc)); }
#endif
+#define x86_cpuid_MACRO(p, func) x86_cpuid_MACRO_2(p, func, 0)
void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func)
{
x86_cpuid_MACRO(p, func)
}
+static
+void Z7_FASTCALL z7_x86_cpuid_subFunc(UInt32 p[4], UInt32 func, UInt32 subFunc)
+{
+ x86_cpuid_MACRO_2(p, func, subFunc)
+}
+
Z7_NO_INLINE
UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void)
{
#if defined(NEED_CHECK_FOR_CPUID)
@@ -203,54 +209,87 @@ void __declspec(naked) Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func)
__asm pop edi
__asm pop ebx
__asm ret 0
}
+static
+void __declspec(naked) Z7_FASTCALL z7_x86_cpuid_subFunc(UInt32 p[4], UInt32 func, UInt32 subFunc)
+{
+ UNUSED_VAR(p)
+ UNUSED_VAR(func)
+ UNUSED_VAR(subFunc)
+ __asm push ebx
+ __asm push edi
+ __asm mov edi, ecx // p
+ __asm mov eax, edx // func
+ __asm mov ecx, [esp + 12] // subFunc
+ __asm cpuid
+ __asm mov [edi ], eax
+ __asm mov [edi + 4], ebx
+ __asm mov [edi + 8], ecx
+ __asm mov [edi + 12], edx
+ __asm pop edi
+ __asm pop ebx
+ __asm ret 4
+}
+
#else // MY_CPU_AMD64
#if _MSC_VER >= 1600
#include <intrin.h>
#define MY_cpuidex __cpuidex
+
+static
+void Z7_FASTCALL z7_x86_cpuid_subFunc(UInt32 p[4], UInt32 func, UInt32 subFunc)
+{
+ __cpuidex((int *)p, func, subFunc);
+}
+
#else
/*
__cpuid (func == (0 or 7)) requires subfunction number in ECX.
MSDN: The __cpuid intrinsic clears the ECX register before calling the cpuid instruction.
__cpuid() in new MSVC clears ECX.
__cpuid() in old MSVC (14.00) x64 doesn't clear ECX
We still can use __cpuid for low (func) values that don't require ECX,
but __cpuid() in old MSVC will be incorrect for some func values: (func == 7).
So here we use the hack for old MSVC to send (subFunction) in ECX register to cpuid instruction,
- where ECX value is first parameter for FASTCALL / NO_INLINE func,
+ where ECX value is first parameter for FASTCALL / NO_INLINE func.
So the caller of MY_cpuidex_HACK() sets ECX as subFunction, and
old MSVC for __cpuid() doesn't change ECX and cpuid instruction gets (subFunction) value.
DON'T remove Z7_NO_INLINE and Z7_FASTCALL for MY_cpuidex_HACK(): !!!
*/
static
-Z7_NO_INLINE void Z7_FASTCALL MY_cpuidex_HACK(UInt32 subFunction, UInt32 func, int *CPUInfo)
+Z7_NO_INLINE void Z7_FASTCALL MY_cpuidex_HACK(Int32 subFunction, Int32 func, Int32 *CPUInfo)
{
UNUSED_VAR(subFunction)
__cpuid(CPUInfo, func);
}
#define MY_cpuidex(info, func, func2) MY_cpuidex_HACK(func2, func, info)
#pragma message("======== MY_cpuidex_HACK WAS USED ========")
+static
+void Z7_FASTCALL z7_x86_cpuid_subFunc(UInt32 p[4], UInt32 func, UInt32 subFunc)
+{
+ MY_cpuidex_HACK(subFunc, func, (Int32 *)p);
+}
#endif // _MSC_VER >= 1600
#if !defined(MY_CPU_AMD64)
/* inlining for __cpuid() in MSVC x86 (32-bit) produces big ineffective code,
so we disable inlining here */
Z7_NO_INLINE
#endif
void Z7_FASTCALL z7_x86_cpuid(UInt32 p[4], UInt32 func)
{
- MY_cpuidex((int *)p, (int)func, 0);
+ MY_cpuidex((Int32 *)p, (Int32)func, 0);
}
Z7_NO_INLINE
UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void)
{
- int a[4];
+ Int32 a[4];
MY_cpuidex(a, 0, 0);
return a[0];
}
#endif // MY_CPU_AMD64
@@ -382,29 +421,29 @@ static BoolInt CPU_Sys_Is_SSE_Supported(void)
BoolInt CPU_IsSupported_CMOV(void)
{
UInt32 a[4];
if (!x86cpuid_Func_1(&a[0]))
return 0;
- return (a[3] >> 15) & 1;
+ return (BoolInt)(a[3] >> 15) & 1;
}
BoolInt CPU_IsSupported_SSE(void)
{
UInt32 a[4];
CHECK_SYS_SSE_SUPPORT
if (!x86cpuid_Func_1(&a[0]))
return 0;
- return (a[3] >> 25) & 1;
+ return (BoolInt)(a[3] >> 25) & 1;
}
BoolInt CPU_IsSupported_SSE2(void)
{
UInt32 a[4];
CHECK_SYS_SSE_SUPPORT
if (!x86cpuid_Func_1(&a[0]))
return 0;
- return (a[3] >> 26) & 1;
+ return (BoolInt)(a[3] >> 26) & 1;
}
#endif
@@ -417,21 +456,21 @@ static UInt32 x86cpuid_Func_1_ECX(void)
return a[2];
}
BoolInt CPU_IsSupported_AES(void)
{
- return (x86cpuid_Func_1_ECX() >> 25) & 1;
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 25) & 1;
}
BoolInt CPU_IsSupported_SSSE3(void)
{
- return (x86cpuid_Func_1_ECX() >> 9) & 1;
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 9) & 1;
}
BoolInt CPU_IsSupported_SSE41(void)
{
- return (x86cpuid_Func_1_ECX() >> 19) & 1;
+ return (BoolInt)(x86cpuid_Func_1_ECX() >> 19) & 1;
}
BoolInt CPU_IsSupported_SHA(void)
{
CHECK_SYS_SSE_SUPPORT
@@ -439,11 +478,28 @@ BoolInt CPU_IsSupported_SHA(void)
if (z7_x86_cpuid_GetMaxFunc() < 7)
return False;
{
UInt32 d[4];
z7_x86_cpuid(d, 7);
- return (d[1] >> 29) & 1;
+ return (BoolInt)(d[1] >> 29) & 1;
+ }
+}
+
+
+BoolInt CPU_IsSupported_SHA512(void)
+{
+ if (!CPU_IsSupported_AVX2()) return False; // maybe CPU_IsSupported_AVX() is enough here
+
+ if (z7_x86_cpuid_GetMaxFunc() < 7)
+ return False;
+ {
+ UInt32 d[4];
+ z7_x86_cpuid_subFunc(d, 7, 0);
+ if (d[0] < 1) // d[0] - is max supported subleaf value
+ return False;
+ z7_x86_cpuid_subFunc(d, 7, 1);
+ return (BoolInt)(d[0]) & 1;
}
}
/*
MSVC: _xgetbv() intrinsic is available since VS2010SP1.
@@ -636,14 +692,14 @@ BoolInt CPU_IsSupported_AVX(void)
what exact states(registers) OS have enabled for storing/restoring.
*/
{
const UInt32 bm = (UInt32)x86_xgetbv_0(MY_XCR_XFEATURE_ENABLED_MASK);
- // printf("\n=== XGetBV=%d\n", bm);
+ // printf("\n=== XGetBV=0x%x\n", bm);
return 1
- & (bm >> 1) // SSE state is supported (set by OS) for storing/restoring
- & (bm >> 2); // AVX state is supported (set by OS) for storing/restoring
+ & (BoolInt)(bm >> 1) // SSE state is supported (set by OS) for storing/restoring
+ & (BoolInt)(bm >> 2); // AVX state is supported (set by OS) for storing/restoring
}
// since Win7SP1: we can use GetEnabledXStateFeatures();
}
@@ -656,13 +712,42 @@ BoolInt CPU_IsSupported_AVX2(void)
{
UInt32 d[4];
z7_x86_cpuid(d, 7);
// printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]);
return 1
- & (d[1] >> 5); // avx2
+ & (BoolInt)(d[1] >> 5); // avx2
+ }
+}
+
+#if 0
+BoolInt CPU_IsSupported_AVX512F_AVX512VL(void)
+{
+ if (!CPU_IsSupported_AVX())
+ return False;
+ if (z7_x86_cpuid_GetMaxFunc() < 7)
+ return False;
+ {
+ UInt32 d[4];
+ BoolInt v;
+ z7_x86_cpuid(d, 7);
+ // printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]);
+ v = 1
+ & (BoolInt)(d[1] >> 16) // avx512f
+ & (BoolInt)(d[1] >> 31); // avx512vl
+ if (!v)
+ return False;
+ }
+ {
+ const UInt32 bm = (UInt32)x86_xgetbv_0(MY_XCR_XFEATURE_ENABLED_MASK);
+ // printf("\n=== XGetBV=0x%x\n", bm);
+ return 1
+ & (BoolInt)(bm >> 5) // OPMASK
+ & (BoolInt)(bm >> 6) // ZMM upper 256-bit
+ & (BoolInt)(bm >> 7); // ZMM16 ... ZMM31
}
}
+#endif
BoolInt CPU_IsSupported_VAES_AVX2(void)
{
if (!CPU_IsSupported_AVX())
return False;
@@ -671,13 +756,13 @@ BoolInt CPU_IsSupported_VAES_AVX2(void)
{
UInt32 d[4];
z7_x86_cpuid(d, 7);
// printf("\ncpuid(7): ebx=%8x ecx=%8x\n", d[1], d[2]);
return 1
- & (d[1] >> 5) // avx2
+ & (BoolInt)(d[1] >> 5) // avx2
// & (d[1] >> 31) // avx512vl
- & (d[2] >> 9); // vaes // VEX-256/EVEX
+ & (BoolInt)(d[2] >> 9); // vaes // VEX-256/EVEX
}
}
BoolInt CPU_IsSupported_PageGB(void)
{
@@ -686,11 +771,11 @@ BoolInt CPU_IsSupported_PageGB(void)
UInt32 d[4];
z7_x86_cpuid(d, 0x80000000);
if (d[0] < 0x80000001)
return False;
z7_x86_cpuid(d, 0x80000001);
- return (d[3] >> 26) & 1;
+ return (BoolInt)(d[3] >> 26) & 1;
}
}
#elif defined(MY_CPU_ARM_OR_ARM64)
@@ -745,10 +830,22 @@ BoolInt CPU_IsSupported_CRC32(void)
BoolInt CPU_IsSupported_NEON(void)
{
return z7_sysctlbyname_Get_BoolInt("hw.optional.neon");
}
+BoolInt CPU_IsSupported_SHA512(void)
+{
+ return z7_sysctlbyname_Get_BoolInt("hw.optional.armv8_2_sha512");
+}
+
+/*
+BoolInt CPU_IsSupported_SHA3(void)
+{
+ return z7_sysctlbyname_Get_BoolInt("hw.optional.armv8_2_sha3");
+}
+*/
+
#ifdef MY_CPU_ARM64
#define APPLE_CRYPTO_SUPPORT_VAL 1
#else
#define APPLE_CRYPTO_SUPPORT_VAL 0
#endif
@@ -758,44 +855,94 @@ BoolInt CPU_IsSupported_SHA2(void) { return APPLE_CRYPTO_SUPPORT_VAL; }
BoolInt CPU_IsSupported_AES (void) { return APPLE_CRYPTO_SUPPORT_VAL; }
#else // __APPLE__
-#include <sys/auxv.h>
+#if defined(__GLIBC__) && (__GLIBC__ * 100 + __GLIBC_MINOR__ >= 216)
+ #define Z7_GETAUXV_AVAILABLE
+#else
+// #pragma message("=== is not NEW GLIBC === ")
+ #if defined __has_include
+ #if __has_include (<sys/auxv.h>)
+// #pragma message("=== sys/auxv.h is avail=== ")
+ #define Z7_GETAUXV_AVAILABLE
+ #endif
+ #endif
+#endif
+#ifdef Z7_GETAUXV_AVAILABLE
+// #pragma message("=== Z7_GETAUXV_AVAILABLE === ")
+#include <sys/auxv.h>
#define USE_HWCAP
+#endif
#ifdef USE_HWCAP
+#if defined(__FreeBSD__)
+static unsigned long MY_getauxval(int aux)
+{
+ unsigned long val;
+ if (elf_aux_info(aux, &val, sizeof(val)))
+ return 0;
+ return val;
+}
+#else
+#define MY_getauxval getauxval
+ #if defined __has_include
+ #if __has_include (<asm/hwcap.h>)
#include <asm/hwcap.h>
+ #endif
+ #endif
+#endif
#define MY_HWCAP_CHECK_FUNC_2(name1, name2) \
- BoolInt CPU_IsSupported_ ## name1() { return (getauxval(AT_HWCAP) & (HWCAP_ ## name2)) ? 1 : 0; }
+ BoolInt CPU_IsSupported_ ## name1(void) { return (MY_getauxval(AT_HWCAP) & (HWCAP_ ## name2)); }
#ifdef MY_CPU_ARM64
#define MY_HWCAP_CHECK_FUNC(name) \
MY_HWCAP_CHECK_FUNC_2(name, name)
+#if 1 || defined(__ARM_NEON)
+ BoolInt CPU_IsSupported_NEON(void) { return True; }
+#else
MY_HWCAP_CHECK_FUNC_2(NEON, ASIMD)
+#endif
// MY_HWCAP_CHECK_FUNC (ASIMD)
#elif defined(MY_CPU_ARM)
#define MY_HWCAP_CHECK_FUNC(name) \
- BoolInt CPU_IsSupported_ ## name() { return (getauxval(AT_HWCAP2) & (HWCAP2_ ## name)) ? 1 : 0; }
+ BoolInt CPU_IsSupported_ ## name(void) { return (MY_getauxval(AT_HWCAP2) & (HWCAP2_ ## name)); }
MY_HWCAP_CHECK_FUNC_2(NEON, NEON)
#endif
#else // USE_HWCAP
#define MY_HWCAP_CHECK_FUNC(name) \
- BoolInt CPU_IsSupported_ ## name() { return 0; }
+ BoolInt CPU_IsSupported_ ## name(void) { return 0; }
+#if defined(__ARM_NEON)
+ BoolInt CPU_IsSupported_NEON(void) { return True; }
+#else
MY_HWCAP_CHECK_FUNC(NEON)
+#endif
#endif // USE_HWCAP
MY_HWCAP_CHECK_FUNC (CRC32)
MY_HWCAP_CHECK_FUNC (SHA1)
MY_HWCAP_CHECK_FUNC (SHA2)
MY_HWCAP_CHECK_FUNC (AES)
+#ifdef MY_CPU_ARM64
+// <hwcap.h> supports HWCAP_SHA512 and HWCAP_SHA3 since 2017.
+// we define them here, if they are not defined
+#ifndef HWCAP_SHA3
+// #define HWCAP_SHA3 (1 << 17)
+#endif
+#ifndef HWCAP_SHA512
+// #pragma message("=== HWCAP_SHA512 define === ")
+#define HWCAP_SHA512 (1 << 21)
+#endif
+MY_HWCAP_CHECK_FUNC (SHA512)
+// MY_HWCAP_CHECK_FUNC (SHA3)
+#endif
#endif // __APPLE__
#endif // _WIN32
#endif // MY_CPU_ARM_OR_ARM64
diff --git a/src/Common/lzma/CpuArch.h b/src/Common/lzma/CpuArch.h
index 8e5d8a54..a6297ea4 100644
--- a/src/Common/lzma/CpuArch.h
+++ b/src/Common/lzma/CpuArch.h
@@ -1,7 +1,7 @@
/* CpuArch.h -- CPU specific code
-2023-04-02 : Igor Pavlov : Public domain */
+Igor Pavlov : Public domain */
#ifndef ZIP7_INC_CPU_ARCH_H
#define ZIP7_INC_CPU_ARCH_H
#include "7zTypes.h"
@@ -18,10 +18,11 @@ MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned mem
MY_CPU_64BIT means that processor can work with 64-bit registers.
MY_CPU_64BIT can be used to select fast code branch
MY_CPU_64BIT doesn't mean that (sizeof(void *) == 8)
*/
+#if !defined(_M_ARM64EC)
#if defined(_M_X64) \
|| defined(_M_AMD64) \
|| defined(__x86_64__) \
|| defined(__AMD64__) \
|| defined(__amd64__)
@@ -33,10 +34,11 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#define MY_CPU_NAME "x64"
#define MY_CPU_SIZEOF_POINTER 8
#endif
#define MY_CPU_64BIT
#endif
+#endif
#if defined(_M_IX86) \
|| defined(__i386__)
#define MY_CPU_X86
@@ -45,21 +47,30 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#define MY_CPU_SIZEOF_POINTER 4
#endif
#if defined(_M_ARM64) \
+ || defined(_M_ARM64EC) \
|| defined(__AARCH64EL__) \
|| defined(__AARCH64EB__) \
|| defined(__aarch64__)
#define MY_CPU_ARM64
- #ifdef __ILP32__
+#if defined(__ILP32__) \
+ || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 4)
#define MY_CPU_NAME "arm64-32"
#define MY_CPU_SIZEOF_POINTER 4
- #else
+#elif defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 16)
+ #define MY_CPU_NAME "arm64-128"
+ #define MY_CPU_SIZEOF_POINTER 16
+#else
+#if defined(_M_ARM64EC)
+ #define MY_CPU_NAME "arm64ec"
+#else
#define MY_CPU_NAME "arm64"
+#endif
#define MY_CPU_SIZEOF_POINTER 8
- #endif
+#endif
#define MY_CPU_64BIT
#endif
#if defined(_M_ARM) \
@@ -131,22 +142,83 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
/* #define MY_CPU_32BIT */
#endif
#endif
+#if defined(__sparc__) \
+ || defined(__sparc)
+ #define MY_CPU_SPARC
+ #if defined(__LP64__) \
+ || defined(_LP64) \
+ || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 8)
+ #define MY_CPU_NAME "sparcv9"
+ #define MY_CPU_SIZEOF_POINTER 8
+ #define MY_CPU_64BIT
+ #elif defined(__sparc_v9__) \
+ || defined(__sparcv9)
+ #define MY_CPU_64BIT
+ #if defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 4)
+ #define MY_CPU_NAME "sparcv9-32"
+ #else
+ #define MY_CPU_NAME "sparcv9m"
+ #endif
+ #elif defined(__sparc_v8__) \
+ || defined(__sparcv8)
+ #define MY_CPU_NAME "sparcv8"
+ #define MY_CPU_SIZEOF_POINTER 4
+ #else
+ #define MY_CPU_NAME "sparc"
+ #endif
+#endif
+
+
#if defined(__riscv) \
|| defined(__riscv__)
+ #define MY_CPU_RISCV
#if __riscv_xlen == 32
#define MY_CPU_NAME "riscv32"
#elif __riscv_xlen == 64
#define MY_CPU_NAME "riscv64"
#else
#define MY_CPU_NAME "riscv"
#endif
#endif
+#if defined(__loongarch__)
+ #define MY_CPU_LOONGARCH
+ #if defined(__loongarch64) || defined(__loongarch_grlen) && (__loongarch_grlen == 64)
+ #define MY_CPU_64BIT
+ #endif
+ #if defined(__loongarch64)
+ #define MY_CPU_NAME "loongarch64"
+ #define MY_CPU_LOONGARCH64
+ #else
+ #define MY_CPU_NAME "loongarch"
+ #endif
+#endif
+
+
+// #undef MY_CPU_NAME
+// #undef MY_CPU_SIZEOF_POINTER
+// #define __e2k__
+// #define __SIZEOF_POINTER__ 4
+#if defined(__e2k__)
+ #define MY_CPU_E2K
+ #if defined(__ILP32__) || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 4)
+ #define MY_CPU_NAME "e2k-32"
+ #define MY_CPU_SIZEOF_POINTER 4
+ #else
+ #define MY_CPU_NAME "e2k"
+ #if defined(__LP64__) || defined(__SIZEOF_POINTER__) && (__SIZEOF_POINTER__ == 8)
+ #define MY_CPU_SIZEOF_POINTER 8
+ #endif
+ #endif
+ #define MY_CPU_64BIT
+#endif
+
+
#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64)
#define MY_CPU_X86_OR_AMD64
#endif
#if defined(MY_CPU_ARM) || defined(MY_CPU_ARM64)
@@ -173,10 +245,11 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#if defined(MY_CPU_X86_OR_AMD64) \
|| defined(MY_CPU_ARM_LE) \
|| defined(MY_CPU_ARM64_LE) \
|| defined(MY_CPU_IA64_LE) \
+ || defined(_LITTLE_ENDIAN) \
|| defined(__LITTLE_ENDIAN__) \
|| defined(__ARMEL__) \
|| defined(__THUMBEL__) \
|| defined(__AARCH64EL__) \
|| defined(__MIPSEL__) \
@@ -249,10 +322,11 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#endif
#endif
#ifndef MY_CPU_NAME
+ // #define MY_CPU_IS_UNKNOWN
#ifdef MY_CPU_LE
#define MY_CPU_NAME "LE"
#elif defined(MY_CPU_BE)
#define MY_CPU_NAME "BE"
#else
@@ -293,13 +367,23 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#define Z7_BSWAP16(v) _byteswap_ushort(v)
#define Z7_BSWAP32(v) _byteswap_ulong (v)
#define Z7_BSWAP64(v) _byteswap_uint64(v)
#define Z7_CPU_FAST_BSWAP_SUPPORTED
-#elif (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
- || (defined(__clang__) && Z7_has_builtin(__builtin_bswap16))
-
+/* GCC can generate slow code that calls function for __builtin_bswap32() for:
+ - GCC for RISCV, if Zbb/XTHeadBb extension is not used.
+ - GCC for SPARC.
+ The code from CLANG for SPARC also is not fastest.
+ So we don't define Z7_CPU_FAST_BSWAP_SUPPORTED in some cases.
+*/
+#elif (!defined(MY_CPU_RISCV) || defined (__riscv_zbb) || defined(__riscv_xtheadbb)) \
+ && !defined(MY_CPU_SPARC) \
+ && ( \
+ (defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))) \
+ || (defined(__clang__) && Z7_has_builtin(__builtin_bswap16)) \
+ )
+
#define Z7_BSWAP16(v) __builtin_bswap16(v)
#define Z7_BSWAP32(v) __builtin_bswap32(v)
#define Z7_BSWAP64(v) __builtin_bswap64(v)
#define Z7_CPU_FAST_BSWAP_SUPPORTED
@@ -327,17 +411,52 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#ifdef MY_CPU_LE
#if defined(MY_CPU_X86_OR_AMD64) \
- || defined(MY_CPU_ARM64)
+ || defined(MY_CPU_ARM64) \
+ || defined(MY_CPU_RISCV) && defined(__riscv_misaligned_fast) \
+ || defined(MY_CPU_E2K) && defined(__iset__) && (__iset__ >= 6)
#define MY_CPU_LE_UNALIGN
#define MY_CPU_LE_UNALIGN_64
#elif defined(__ARM_FEATURE_UNALIGNED)
- /* gcc9 for 32-bit arm can use LDRD instruction that requires 32-bit alignment.
- So we can't use unaligned 64-bit operations. */
- #define MY_CPU_LE_UNALIGN
+/* === ALIGNMENT on 32-bit arm and LDRD/STRD/LDM/STM instructions.
+ Description of problems:
+problem-1 : 32-bit ARM architecture:
+ multi-access (pair of 32-bit accesses) instructions (LDRD/STRD/LDM/STM)
+ require 32-bit (WORD) alignment (by 32-bit ARM architecture).
+ So there is "Alignment fault exception", if data is not aligned for 32-bit.
+
+problem-2 : 32-bit kernels and arm64 kernels:
+ 32-bit linux kernels provide fixup for these "paired" instruction "Alignment fault exception".
+ So unaligned paired-access instructions work via exception handler in kernel in 32-bit linux.
+
+ But some arm64 kernels do not handle these faults in 32-bit programs.
+ So we have unhandled exception for such instructions.
+ Probably some new arm64 kernels have fixed it, and unaligned
+ paired-access instructions work in new kernels?
+
+problem-3 : compiler for 32-bit arm:
+ Compilers use LDRD/STRD/LDM/STM for UInt64 accesses
+ and for another cases where two 32-bit accesses are fused
+ to one multi-access instruction.
+ So UInt64 variables must be aligned for 32-bit, and each
+ 32-bit access must be aligned for 32-bit, if we want to
+ avoid "Alignment fault" exception (handled or unhandled).
+
+problem-4 : performace:
+ Even if unaligned access is handled by kernel, it will be slow.
+ So if we allow unaligned access, we can get fast unaligned
+ single-access, and slow unaligned paired-access.
+
+ We don't allow unaligned access on 32-bit arm, because compiler
+ genarates paired-access instructions that require 32-bit alignment,
+ and some arm64 kernels have no handler for these instructions.
+ Also unaligned paired-access instructions will be slow, if kernel handles them.
+*/
+ // it must be disabled:
+ // #define MY_CPU_LE_UNALIGN
#endif
#endif
#ifdef MY_CPU_LE_UNALIGN
@@ -388,15 +507,23 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#endif
#if defined(MY_CPU_LE_UNALIGN) && defined(Z7_CPU_FAST_BSWAP_SUPPORTED)
+#if 0
+// Z7_BSWAP16 can be slow for x86-msvc
+#define GetBe16_to32(p) (Z7_BSWAP16 (*(const UInt16 *)(const void *)(p)))
+#else
+#define GetBe16_to32(p) (Z7_BSWAP32 (*(const UInt16 *)(const void *)(p)) >> 16)
+#endif
+
#define GetBe32(p) Z7_BSWAP32 (*(const UInt32 *)(const void *)(p))
#define SetBe32(p, v) { (*(UInt32 *)(void *)(p)) = Z7_BSWAP32(v); }
#if defined(MY_CPU_LE_UNALIGN_64)
#define GetBe64(p) Z7_BSWAP64 (*(const UInt64 *)(const void *)(p))
+#define SetBe64(p, v) { (*(UInt64 *)(void *)(p)) = Z7_BSWAP64(v); }
#endif
#else
#define GetBe32(p) ( \
@@ -415,15 +542,31 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#ifndef GetBe64
#define GetBe64(p) (((UInt64)GetBe32(p) << 32) | GetBe32(((const Byte *)(p)) + 4))
#endif
+#ifndef SetBe64
+#define SetBe64(p, v) { Byte *_ppp_ = (Byte *)(p); UInt64 _vvv_ = (v); \
+ _ppp_[0] = (Byte)(_vvv_ >> 56); \
+ _ppp_[1] = (Byte)(_vvv_ >> 48); \
+ _ppp_[2] = (Byte)(_vvv_ >> 40); \
+ _ppp_[3] = (Byte)(_vvv_ >> 32); \
+ _ppp_[4] = (Byte)(_vvv_ >> 24); \
+ _ppp_[5] = (Byte)(_vvv_ >> 16); \
+ _ppp_[6] = (Byte)(_vvv_ >> 8); \
+ _ppp_[7] = (Byte)_vvv_; }
+#endif
+
#ifndef GetBe16
+#ifdef GetBe16_to32
+#define GetBe16(p) ( (UInt16) GetBe16_to32(p))
+#else
#define GetBe16(p) ( (UInt16) ( \
((UInt16)((const Byte *)(p))[0] << 8) | \
((const Byte *)(p))[1] ))
#endif
+#endif
#if defined(MY_CPU_BE)
#define Z7_CONV_BE_TO_NATIVE_CONST32(v) (v)
#define Z7_CONV_LE_TO_NATIVE_CONST32(v) Z7_BSWAP32_CONST(v)
@@ -437,37 +580,46 @@ MY_CPU_64BIT means that processor can work with 64-bit registers.
#endif
#if defined(MY_CPU_BE)
+#define GetBe64a(p) (*(const UInt64 *)(const void *)(p))
#define GetBe32a(p) (*(const UInt32 *)(const void *)(p))
#define GetBe16a(p) (*(const UInt16 *)(const void *)(p))
#define SetBe32a(p, v) { *(UInt32 *)(void *)(p) = (v); }
#define SetBe16a(p, v) { *(UInt16 *)(void *)(p) = (v); }
+#define GetUi64a(p) GetUi64(p)
#define GetUi32a(p) GetUi32(p)
#define GetUi16a(p) GetUi16(p)
#define SetUi32a(p, v) SetUi32(p, v)
#define SetUi16a(p, v) SetUi16(p, v)
#elif defined(MY_CPU_LE)
+#define GetUi64a(p) (*(const UInt64 *)(const void *)(p))
#define GetUi32a(p) (*(const UInt32 *)(const void *)(p))
#define GetUi16a(p) (*(const UInt16 *)(const void *)(p))
#define SetUi32a(p, v) { *(UInt32 *)(void *)(p) = (v); }
#define SetUi16a(p, v) { *(UInt16 *)(void *)(p) = (v); }
+#define GetBe64a(p) GetBe64(p)
#define GetBe32a(p) GetBe32(p)
#define GetBe16a(p) GetBe16(p)
#define SetBe32a(p, v) SetBe32(p, v)
#define SetBe16a(p, v) SetBe16(p, v)
#else
#error Stop_Compiling_Unknown_Endian_CPU_a
#endif
+#ifndef GetBe16_to32
+#define GetBe16_to32(p) GetBe16(p)
+#endif
+
+
#if defined(MY_CPU_X86_OR_AMD64) \
|| defined(MY_CPU_ARM_OR_ARM64) \
|| defined(MY_CPU_PPC_OR_PPC64)
#define Z7_CPU_FAST_ROTATE_SUPPORTED
#endif
@@ -484,17 +636,19 @@ UInt32 Z7_FASTCALL z7_x86_cpuid_GetMaxFunc(void);
#endif
BoolInt CPU_IsSupported_AES(void);
BoolInt CPU_IsSupported_AVX(void);
BoolInt CPU_IsSupported_AVX2(void);
+BoolInt CPU_IsSupported_AVX512F_AVX512VL(void);
BoolInt CPU_IsSupported_VAES_AVX2(void);
BoolInt CPU_IsSupported_CMOV(void);
BoolInt CPU_IsSupported_SSE(void);
BoolInt CPU_IsSupported_SSE2(void);
BoolInt CPU_IsSupported_SSSE3(void);
BoolInt CPU_IsSupported_SSE41(void);
BoolInt CPU_IsSupported_SHA(void);
+BoolInt CPU_IsSupported_SHA512(void);
BoolInt CPU_IsSupported_PageGB(void);
#elif defined(MY_CPU_ARM_OR_ARM64)
BoolInt CPU_IsSupported_CRC32(void);
@@ -508,10 +662,11 @@ BoolInt CPU_IsSupported_CRYPTO(void);
#else
BoolInt CPU_IsSupported_SHA1(void);
BoolInt CPU_IsSupported_SHA2(void);
BoolInt CPU_IsSupported_AES(void);
#endif
+BoolInt CPU_IsSupported_SHA512(void);
#endif
#if defined(__APPLE__)
int z7_sysctlbyname_Get(const char *name, void *buf, size_t *bufSize);
diff --git a/src/Common/lzma/LzFind.c b/src/Common/lzma/LzFind.c
index 0fbd5aae..1ce40464 100644
--- a/src/Common/lzma/LzFind.c
+++ b/src/Common/lzma/LzFind.c
@@ -1,7 +1,7 @@
/* LzFind.c -- Match finder for LZ algorithms
-2023-03-14 : Igor Pavlov : Public domain */
+2024-03-01 : Igor Pavlov : Public domain */
#include "Precomp.h"
#include <string.h>
// #include <stdio.h>
@@ -106,13 +106,19 @@ static int LzInWindow_Create2(CMatchFinder *p, UInt32 blockSize, ISzAllocPtr all
// return 0; // for debug
}
return (p->bufBase != NULL);
}
-static const Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
+static const Byte *MatchFinder_GetPointerToCurrentPos(void *p)
+{
+ return ((CMatchFinder *)p)->buffer;
+}
-static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return GET_AVAIL_BYTES(p); }
+static UInt32 MatchFinder_GetNumAvailableBytes(void *p)
+{
+ return GET_AVAIL_BYTES((CMatchFinder *)p);
+}
Z7_NO_INLINE
static void MatchFinder_ReadBlock(CMatchFinder *p)
{
@@ -569,12 +575,13 @@ void MatchFinder_Init_4(CMatchFinder *p)
// (CYC_TO_POS_OFFSET == 0) is expected by some optimized code
#define CYC_TO_POS_OFFSET 0
// #define CYC_TO_POS_OFFSET 1 // for debug
-void MatchFinder_Init(CMatchFinder *p)
+void MatchFinder_Init(void *_p)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
MatchFinder_Init_HighHash(p);
MatchFinder_Init_LowHash(p);
MatchFinder_Init_4(p);
// if (readData)
MatchFinder_ReadBlock(p);
@@ -605,29 +612,29 @@ void MatchFinder_Init(CMatchFinder *p)
#if (_MSC_VER >= 1900)
#define USE_LZFIND_SATUR_SUB_256
#endif
#endif
-// #elif defined(MY_CPU_ARM_OR_ARM64)
-#elif defined(MY_CPU_ARM64)
+#elif defined(MY_CPU_ARM64) \
+ /* || (defined(__ARM_ARCH) && (__ARM_ARCH >= 7)) */
- #if defined(__clang__) && (__clang_major__ >= 8) \
- || defined(__GNUC__) && (__GNUC__ >= 8)
+ #if defined(Z7_CLANG_VERSION) && (Z7_CLANG_VERSION >= 30800) \
+ || defined(__GNUC__) && (__GNUC__ >= 6)
#define USE_LZFIND_SATUR_SUB_128
#ifdef MY_CPU_ARM64
// #define LZFIND_ATTRIB_SSE41 __attribute__((__target__("")))
#else
- // #define LZFIND_ATTRIB_SSE41 __attribute__((__target__("fpu=crypto-neon-fp-armv8")))
+ #define LZFIND_ATTRIB_SSE41 __attribute__((__target__("fpu=neon")))
#endif
#elif defined(_MSC_VER)
#if (_MSC_VER >= 1910)
#define USE_LZFIND_SATUR_SUB_128
#endif
#endif
- #if defined(_MSC_VER) && defined(MY_CPU_ARM64)
+ #if defined(Z7_MSC_VER_ORIGINAL) && defined(MY_CPU_ARM64)
#include <arm64_neon.h>
#else
#include <arm_neon.h>
#endif
@@ -1080,13 +1087,15 @@ static void SkipMatchesSpec(UInt32 lenLimit, UInt32 curMatch, UInt32 pos, const
return;
}
#define MOVE_POS \
- ++p->cyclicBufferPos; \
+ p->cyclicBufferPos++; \
p->buffer++; \
- { const UInt32 pos1 = p->pos + 1; p->pos = pos1; if (pos1 == p->posLimit) MatchFinder_CheckLimits(p); }
+ { const UInt32 pos1 = p->pos + 1; \
+ p->pos = pos1; \
+ if (pos1 == p->posLimit) MatchFinder_CheckLimits(p); }
#define MOVE_POS_RET MOVE_POS return distances;
Z7_NO_INLINE
static void MatchFinder_MovePos(CMatchFinder *p)
@@ -1101,24 +1110,30 @@ static void MatchFinder_MovePos(CMatchFinder *p)
*/
MOVE_POS
}
#define GET_MATCHES_HEADER2(minLen, ret_op) \
- unsigned lenLimit; UInt32 hv; const Byte *cur; UInt32 curMatch; \
- lenLimit = (unsigned)p->lenLimit; { if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; }} \
+ UInt32 hv; const Byte *cur; UInt32 curMatch; \
+ UInt32 lenLimit = p->lenLimit; \
+ if (lenLimit < minLen) { MatchFinder_MovePos(p); ret_op; } \
cur = p->buffer;
#define GET_MATCHES_HEADER(minLen) GET_MATCHES_HEADER2(minLen, return distances)
-#define SKIP_HEADER(minLen) do { GET_MATCHES_HEADER2(minLen, continue)
+#define SKIP_HEADER(minLen) \
+ do { GET_MATCHES_HEADER2(minLen, continue)
-#define MF_PARAMS(p) lenLimit, curMatch, p->pos, p->buffer, p->son, p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
+#define MF_PARAMS(p) lenLimit, curMatch, p->pos, p->buffer, p->son, \
+ p->cyclicBufferPos, p->cyclicBufferSize, p->cutValue
-#define SKIP_FOOTER SkipMatchesSpec(MF_PARAMS(p)); MOVE_POS } while (--num);
+#define SKIP_FOOTER \
+ SkipMatchesSpec(MF_PARAMS(p)); \
+ MOVE_POS \
+ } while (--num);
#define GET_MATCHES_FOOTER_BASE(_maxLen_, func) \
- distances = func(MF_PARAMS(p), \
- distances, (UInt32)_maxLen_); MOVE_POS_RET
+ distances = func(MF_PARAMS(p), distances, (UInt32)_maxLen_); \
+ MOVE_POS_RET
#define GET_MATCHES_FOOTER_BT(_maxLen_) \
GET_MATCHES_FOOTER_BASE(_maxLen_, GetMatchesSpec1)
#define GET_MATCHES_FOOTER_HC(_maxLen_) \
@@ -1131,12 +1146,13 @@ static void MatchFinder_MovePos(CMatchFinder *p)
const Byte *c = cur + maxLen; \
const Byte *lim = cur + lenLimit; \
for (; c != lim; c++) if (*(c + diff) != *c) break; \
maxLen = (unsigned)(c - cur); }
-static UInt32* Bt2_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32* Bt2_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
GET_MATCHES_HEADER(2)
HASH2_CALC
curMatch = p->hash[hv];
p->hash[hv] = p->pos;
GET_MATCHES_FOOTER_BT(1)
@@ -1156,12 +1172,13 @@ UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
mmm = p->cyclicBufferSize; \
if (pos < mmm) \
mmm = pos;
-static UInt32* Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32* Bt3_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
UInt32 mmm;
UInt32 h2, d2, pos;
unsigned maxLen;
UInt32 *hash;
GET_MATCHES_HEADER(3)
@@ -1197,12 +1214,13 @@ static UInt32* Bt3_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER_BT(maxLen)
}
-static UInt32* Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32* Bt4_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
UInt32 mmm;
UInt32 h2, h3, d2, d3, pos;
unsigned maxLen;
UInt32 *hash;
GET_MATCHES_HEADER(4)
@@ -1265,14 +1283,16 @@ static UInt32* Bt4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER_BT(maxLen)
}
-static UInt32* Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32* Bt5_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
UInt32 mmm;
- UInt32 h2, h3, d2, d3, maxLen, pos;
+ UInt32 h2, h3, d2, d3, pos;
+ unsigned maxLen;
UInt32 *hash;
GET_MATCHES_HEADER(5)
HASH5_CALC
@@ -1337,12 +1357,13 @@ static UInt32* Bt5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER_BT(maxLen)
}
-static UInt32* Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32* Hc4_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
UInt32 mmm;
UInt32 h2, h3, d2, d3, pos;
unsigned maxLen;
UInt32 *hash;
GET_MATCHES_HEADER(4)
@@ -1405,14 +1426,16 @@ static UInt32* Hc4_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
GET_MATCHES_FOOTER_HC(maxLen)
}
-static UInt32 * Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
+static UInt32 * Hc5_MatchFinder_GetMatches(void *_p, UInt32 *distances)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
UInt32 mmm;
- UInt32 h2, h3, d2, d3, maxLen, pos;
+ UInt32 h2, h3, d2, d3, pos;
+ unsigned maxLen;
UInt32 *hash;
GET_MATCHES_HEADER(5)
HASH5_CALC
@@ -1464,11 +1487,11 @@ static UInt32 * Hc5_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
distances[-2] = 3;
if (*(cur - d2 + 3) != cur[3])
break;
UPDATE_maxLen
- distances[-2] = maxLen;
+ distances[-2] = (UInt32)maxLen;
if (maxLen == lenLimit)
{
p->son[p->cyclicBufferPos] = curMatch;
MOVE_POS_RET
}
@@ -1487,12 +1510,13 @@ UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances)
p->hash[hv] = p->pos;
GET_MATCHES_FOOTER_HC(2)
}
-static void Bt2_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt2_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
SKIP_HEADER(2)
{
HASH2_CALC
curMatch = p->hash[hv];
p->hash[hv] = p->pos;
@@ -1509,12 +1533,13 @@ void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->hash[hv] = p->pos;
}
SKIP_FOOTER
}
-static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt3_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
SKIP_HEADER(3)
{
UInt32 h2;
UInt32 *hash;
HASH3_CALC
@@ -1524,12 +1549,13 @@ static void Bt3_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
(hash + kFix3HashSize)[hv] = p->pos;
}
SKIP_FOOTER
}
-static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt4_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
SKIP_HEADER(4)
{
UInt32 h2, h3;
UInt32 *hash;
HASH4_CALC
@@ -1540,12 +1566,13 @@ static void Bt4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
(hash + kFix4HashSize)[hv] = p->pos;
}
SKIP_FOOTER
}
-static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Bt5_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
SKIP_HEADER(5)
{
UInt32 h2, h3;
UInt32 *hash;
HASH5_CALC
@@ -1587,12 +1614,13 @@ static void Bt5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
p->pos = pos; \
if (pos == p->posLimit) MatchFinder_CheckLimits(p); \
}} while(num); \
-static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Hc4_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
HC_SKIP_HEADER(4)
UInt32 h2, h3;
HASH4_CALC
curMatch = (hash + kFix4HashSize)[hv];
@@ -1602,12 +1630,13 @@ static void Hc4_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
HC_SKIP_FOOTER
}
-static void Hc5_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
+static void Hc5_MatchFinder_Skip(void *_p, UInt32 num)
{
+ CMatchFinder *p = (CMatchFinder *)_p;
HC_SKIP_HEADER(5)
UInt32 h2, h3;
HASH5_CALC
curMatch = (hash + kFix5HashSize)[hv];
@@ -1632,45 +1661,45 @@ void Hc3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num)
}
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable)
{
- vTable->Init = (Mf_Init_Func)MatchFinder_Init;
- vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinder_GetNumAvailableBytes;
- vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinder_GetPointerToCurrentPos;
+ vTable->Init = MatchFinder_Init;
+ vTable->GetNumAvailableBytes = MatchFinder_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = MatchFinder_GetPointerToCurrentPos;
if (!p->btMode)
{
if (p->numHashBytes <= 4)
{
- vTable->GetMatches = (Mf_GetMatches_Func)Hc4_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Hc4_MatchFinder_Skip;
+ vTable->GetMatches = Hc4_MatchFinder_GetMatches;
+ vTable->Skip = Hc4_MatchFinder_Skip;
}
else
{
- vTable->GetMatches = (Mf_GetMatches_Func)Hc5_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Hc5_MatchFinder_Skip;
+ vTable->GetMatches = Hc5_MatchFinder_GetMatches;
+ vTable->Skip = Hc5_MatchFinder_Skip;
}
}
else if (p->numHashBytes == 2)
{
- vTable->GetMatches = (Mf_GetMatches_Func)Bt2_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt2_MatchFinder_Skip;
+ vTable->GetMatches = Bt2_MatchFinder_GetMatches;
+ vTable->Skip = Bt2_MatchFinder_Skip;
}
else if (p->numHashBytes == 3)
{
- vTable->GetMatches = (Mf_GetMatches_Func)Bt3_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt3_MatchFinder_Skip;
+ vTable->GetMatches = Bt3_MatchFinder_GetMatches;
+ vTable->Skip = Bt3_MatchFinder_Skip;
}
else if (p->numHashBytes == 4)
{
- vTable->GetMatches = (Mf_GetMatches_Func)Bt4_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt4_MatchFinder_Skip;
+ vTable->GetMatches = Bt4_MatchFinder_GetMatches;
+ vTable->Skip = Bt4_MatchFinder_Skip;
}
else
{
- vTable->GetMatches = (Mf_GetMatches_Func)Bt5_MatchFinder_GetMatches;
- vTable->Skip = (Mf_Skip_Func)Bt5_MatchFinder_Skip;
+ vTable->GetMatches = Bt5_MatchFinder_GetMatches;
+ vTable->Skip = Bt5_MatchFinder_Skip;
}
}
diff --git a/src/Common/lzma/LzFind.h b/src/Common/lzma/LzFind.h
index a3f72c98..67e8a6e0 100644
--- a/src/Common/lzma/LzFind.h
+++ b/src/Common/lzma/LzFind.h
@@ -1,7 +1,7 @@
/* LzFind.h -- Match finder for LZ algorithms
-2023-03-04 : Igor Pavlov : Public domain */
+2024-01-22 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_LZ_FIND_H
#define ZIP7_INC_LZ_FIND_H
#include "7zTypes.h"
@@ -142,11 +142,12 @@ typedef struct
void MatchFinder_CreateVTable(CMatchFinder *p, IMatchFinder2 *vTable);
void MatchFinder_Init_LowHash(CMatchFinder *p);
void MatchFinder_Init_HighHash(CMatchFinder *p);
void MatchFinder_Init_4(CMatchFinder *p);
-void MatchFinder_Init(CMatchFinder *p);
+// void MatchFinder_Init(CMatchFinder *p);
+void MatchFinder_Init(void *p);
UInt32* Bt3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
UInt32* Hc3Zip_MatchFinder_GetMatches(CMatchFinder *p, UInt32 *distances);
void Bt3Zip_MatchFinder_Skip(CMatchFinder *p, UInt32 num);
diff --git a/src/Common/lzma/LzFindMt.c b/src/Common/lzma/LzFindMt.c
index 5253e6eb..ac9d59d0 100644
--- a/src/Common/lzma/LzFindMt.c
+++ b/src/Common/lzma/LzFindMt.c
@@ -1,7 +1,7 @@
/* LzFindMt.c -- multithreaded Match finder for LZ algorithms
-2023-04-02 : Igor Pavlov : Public domain */
+2024-01-22 : Igor Pavlov : Public domain */
#include "Precomp.h"
// #include <stdio.h>
@@ -92,11 +92,11 @@ static void MtSync_Construct(CMtSync *p)
Semaphore_Construct(&p->freeSemaphore);
Semaphore_Construct(&p->filledSemaphore);
}
-#define DEBUG_BUFFER_LOCK // define it to debug lock state
+// #define DEBUG_BUFFER_LOCK // define it to debug lock state
#ifdef DEBUG_BUFFER_LOCK
#include <stdlib.h>
#define BUFFER_MUST_BE_LOCKED(p) if (!(p)->csWasEntered) exit(1);
#define BUFFER_MUST_BE_UNLOCKED(p) if ( (p)->csWasEntered) exit(1);
@@ -875,12 +875,13 @@ SRes MatchFinderMt_InitMt(CMatchFinderMt *p)
RINOK(MtSync_Init(&p->hashSync, kMtHashNumBlocks))
return MtSync_Init(&p->btSync, kMtBtNumBlocks);
}
-static void MatchFinderMt_Init(CMatchFinderMt *p)
+static void MatchFinderMt_Init(void *_p)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
CMatchFinder *mf = MF(p);
p->btBufPos =
p->btBufPosLimit = NULL;
p->hashBufPos =
@@ -979,21 +980,23 @@ static UInt32 MatchFinderMt_GetNextBlock_Bt(CMatchFinderMt *p)
return p->btNumAvailBytes;
}
-static const Byte * MatchFinderMt_GetPointerToCurrentPos(CMatchFinderMt *p)
+static const Byte * MatchFinderMt_GetPointerToCurrentPos(void *_p)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
return p->pointerToCurPos;
}
#define GET_NEXT_BLOCK_IF_REQUIRED if (p->btBufPos == p->btBufPosLimit) MatchFinderMt_GetNextBlock_Bt(p);
-static UInt32 MatchFinderMt_GetNumAvailableBytes(CMatchFinderMt *p)
+static UInt32 MatchFinderMt_GetNumAvailableBytes(void *_p)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
if (p->btBufPos != p->btBufPosLimit)
return p->btNumAvailBytes;
return MatchFinderMt_GetNextBlock_Bt(p);
}
@@ -1241,12 +1244,13 @@ static UInt32 * MixMatches4(CMatchFinderMt *p, UInt32 matchMinPos, UInt32 *d)
return d;
}
-static UInt32 * MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *d)
+static UInt32 * MatchFinderMt2_GetMatches(void *_p, UInt32 *d)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
const UInt32 *bt = p->btBufPos;
const UInt32 len = *bt++;
const UInt32 *btLim = bt + len;
p->btBufPos = btLim;
p->btNumAvailBytes--;
@@ -1265,12 +1269,13 @@ static UInt32 * MatchFinderMt2_GetMatches(CMatchFinderMt *p, UInt32 *d)
return d;
}
-static UInt32 * MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *d)
+static UInt32 * MatchFinderMt_GetMatches(void *_p, UInt32 *d)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
const UInt32 *bt = p->btBufPos;
UInt32 len = *bt++;
const UInt32 avail = p->btNumAvailBytes - 1;
p->btNumAvailBytes = avail;
p->btBufPos = bt + len;
@@ -1313,27 +1318,30 @@ static UInt32 * MatchFinderMt_GetMatches(CMatchFinderMt *p, UInt32 *d)
#define SKIP_HEADER2_MT do { GET_NEXT_BLOCK_IF_REQUIRED
#define SKIP_HEADER_MT(n) SKIP_HEADER2_MT if (p->btNumAvailBytes-- >= (n)) { const Byte *cur = p->pointerToCurPos; UInt32 *hash = p->hash;
#define SKIP_FOOTER_MT } INCREASE_LZ_POS p->btBufPos += (size_t)*p->btBufPos + 1; } while (--num != 0);
-static void MatchFinderMt0_Skip(CMatchFinderMt *p, UInt32 num)
+static void MatchFinderMt0_Skip(void *_p, UInt32 num)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
SKIP_HEADER2_MT { p->btNumAvailBytes--;
SKIP_FOOTER_MT
}
-static void MatchFinderMt2_Skip(CMatchFinderMt *p, UInt32 num)
+static void MatchFinderMt2_Skip(void *_p, UInt32 num)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
SKIP_HEADER_MT(2)
UInt32 h2;
MT_HASH2_CALC
hash[h2] = p->lzPos;
SKIP_FOOTER_MT
}
-static void MatchFinderMt3_Skip(CMatchFinderMt *p, UInt32 num)
+static void MatchFinderMt3_Skip(void *_p, UInt32 num)
{
+ CMatchFinderMt *p = (CMatchFinderMt *)_p;
SKIP_HEADER_MT(3)
UInt32 h2, h3;
MT_HASH3_CALC
(hash + kFix3HashSize)[h3] =
hash[ h2] =
@@ -1359,43 +1367,43 @@ static void MatchFinderMt4_Skip(CMatchFinderMt *p, UInt32 num)
}
*/
void MatchFinderMt_CreateVTable(CMatchFinderMt *p, IMatchFinder2 *vTable)
{
- vTable->Init = (Mf_Init_Func)MatchFinderMt_Init;
- vTable->GetNumAvailableBytes = (Mf_GetNumAvailableBytes_Func)MatchFinderMt_GetNumAvailableBytes;
- vTable->GetPointerToCurrentPos = (Mf_GetPointerToCurrentPos_Func)MatchFinderMt_GetPointerToCurrentPos;
- vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches;
+ vTable->Init = MatchFinderMt_Init;
+ vTable->GetNumAvailableBytes = MatchFinderMt_GetNumAvailableBytes;
+ vTable->GetPointerToCurrentPos = MatchFinderMt_GetPointerToCurrentPos;
+ vTable->GetMatches = MatchFinderMt_GetMatches;
switch (MF(p)->numHashBytes)
{
case 2:
p->GetHeadsFunc = GetHeads2;
- p->MixMatchesFunc = (Mf_Mix_Matches)NULL;
- vTable->Skip = (Mf_Skip_Func)MatchFinderMt0_Skip;
- vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt2_GetMatches;
+ p->MixMatchesFunc = NULL;
+ vTable->Skip = MatchFinderMt0_Skip;
+ vTable->GetMatches = MatchFinderMt2_GetMatches;
break;
case 3:
p->GetHeadsFunc = MF(p)->bigHash ? GetHeads3b : GetHeads3;
- p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches2;
- vTable->Skip = (Mf_Skip_Func)MatchFinderMt2_Skip;
+ p->MixMatchesFunc = MixMatches2;
+ vTable->Skip = MatchFinderMt2_Skip;
break;
case 4:
p->GetHeadsFunc = MF(p)->bigHash ? GetHeads4b : GetHeads4;
// it's fast inline version of GetMatches()
- // vTable->GetMatches = (Mf_GetMatches_Func)MatchFinderMt_GetMatches_Bt4;
+ // vTable->GetMatches = MatchFinderMt_GetMatches_Bt4;
- p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches3;
- vTable->Skip = (Mf_Skip_Func)MatchFinderMt3_Skip;
+ p->MixMatchesFunc = MixMatches3;
+ vTable->Skip = MatchFinderMt3_Skip;
break;
default:
p->GetHeadsFunc = MF(p)->bigHash ? GetHeads5b : GetHeads5;
- p->MixMatchesFunc = (Mf_Mix_Matches)MixMatches4;
+ p->MixMatchesFunc = MixMatches4;
vTable->Skip =
- (Mf_Skip_Func)MatchFinderMt3_Skip;
- // (Mf_Skip_Func)MatchFinderMt4_Skip;
+ MatchFinderMt3_Skip;
+ // MatchFinderMt4_Skip;
break;
}
}
#undef RINOK_THREAD
diff --git a/src/Common/lzma/LzFindMt.h b/src/Common/lzma/LzFindMt.h
index db5923ea..fcb479da 100644
--- a/src/Common/lzma/LzFindMt.h
+++ b/src/Common/lzma/LzFindMt.h
@@ -1,7 +1,7 @@
/* LzFindMt.h -- multithreaded Match finder for LZ algorithms
-2023-03-05 : Igor Pavlov : Public domain */
+2024-01-22 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_LZ_FIND_MT_H
#define ZIP7_INC_LZ_FIND_MT_H
#include "LzFind.h"
@@ -29,19 +29,22 @@ typedef struct
CSemaphore filledSemaphore;
CCriticalSection cs;
// UInt32 numBlocks_Sent;
} CMtSync;
-typedef UInt32 * (*Mf_Mix_Matches)(void *p, UInt32 matchMinPos, UInt32 *distances);
+
+struct CMatchFinderMt_;
+
+typedef UInt32 * (*Mf_Mix_Matches)(struct CMatchFinderMt_ *p, UInt32 matchMinPos, UInt32 *distances);
/* kMtCacheLineDummy must be >= size_of_CPU_cache_line */
#define kMtCacheLineDummy 128
typedef void (*Mf_GetHeads)(const Byte *buffer, UInt32 pos,
UInt32 *hash, UInt32 hashMask, UInt32 *heads, UInt32 numHeads, const UInt32 *crc);
-typedef struct
+typedef struct CMatchFinderMt_
{
/* LZ */
const Byte *pointerToCurPos;
UInt32 *btBuf;
const UInt32 *btBufPos;
diff --git a/src/Common/lzma/LzmaEnc.c b/src/Common/lzma/LzmaEnc.c
index 6d13cac8..088b78f8 100644
--- a/src/Common/lzma/LzmaEnc.c
+++ b/src/Common/lzma/LzmaEnc.c
@@ -1,7 +1,7 @@
/* LzmaEnc.c -- LZMA Encoder
-2023-04-13: Igor Pavlov : Public domain */
+Igor Pavlov : Public domain */
#include "Precomp.h"
#include <string.h>
@@ -70,15 +70,15 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
int level = p->level;
if (level < 0) level = 5;
p->level = level;
if (p->dictSize == 0)
- p->dictSize =
- ( level <= 3 ? ((UInt32)1 << (level * 2 + 16)) :
- ( level <= 6 ? ((UInt32)1 << (level + 19)) :
- ( level <= 7 ? ((UInt32)1 << 25) : ((UInt32)1 << 26)
- )));
+ p->dictSize = (unsigned)level <= 4 ?
+ (UInt32)1 << (level * 2 + 16) :
+ (unsigned)level <= sizeof(size_t) / 2 + 4 ?
+ (UInt32)1 << (level + 20) :
+ (UInt32)1 << (sizeof(size_t) / 2 + 24);
if (p->dictSize > p->reduceSize)
{
UInt32 v = (UInt32)p->reduceSize;
const UInt32 kReduceMin = ((UInt32)1 << 12);
@@ -90,12 +90,12 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p)
if (p->lc < 0) p->lc = 3;
if (p->lp < 0) p->lp = 0;
if (p->pb < 0) p->pb = 2;
- if (p->algo < 0) p->algo = (level < 5 ? 0 : 1);
- if (p->fb < 0) p->fb = (level < 7 ? 32 : 64);
+ if (p->algo < 0) p->algo = (unsigned)level < 5 ? 0 : 1;
+ if (p->fb < 0) p->fb = (unsigned)level < 7 ? 32 : 64;
if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1);
if (p->numHashBytes < 0) p->numHashBytes = (p->btMode ? 4 : 5);
if (p->mc == 0) p->mc = (16 + ((unsigned)p->fb >> 1)) >> (p->btMode ? 0 : 1);
if (p->numThreads < 0)
@@ -193,15 +193,15 @@ LZCNT can be faster than BSR, if supported.
unsigned GetPosSlot1(UInt32 pos);
unsigned GetPosSlot1(UInt32 pos)
{
unsigned res;
- BSR2_RET(pos, res);
+ BSR2_RET(pos, res)
return res;
}
-#define GetPosSlot2(pos, res) { BSR2_RET(pos, res); }
-#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res); }
+#define GetPosSlot2(pos, res) { BSR2_RET(pos, res) }
+#define GetPosSlot(pos, res) { if (pos < 2) res = pos; else BSR2_RET(pos, res) }
#else // ! LZMA_LOG_BSR
#define kNumLogBits (11 + sizeof(size_t) / 8 * 3)
@@ -510,11 +510,11 @@ struct CLzmaEnc
COPY_ARR(d, s, isRep0Long) \
COPY_ARR(d, s, posSlotEncoder) \
COPY_ARR(d, s, posEncoders) \
(d)->lenProbs = (s)->lenProbs; \
(d)->repLenProbs = (s)->repLenProbs; \
- memcpy((d)->litProbs, (s)->litProbs, ((UInt32)0x300 << (p)->lclp) * sizeof(CLzmaProb));
+ memcpy((d)->litProbs, (s)->litProbs, ((size_t)0x300 * sizeof(CLzmaProb)) << (p)->lclp);
void LzmaEnc_SaveState(CLzmaEncHandle p)
{
// GET_CLzmaEnc_p
CSaveState *v = &p->saveState;
@@ -1038,27 +1038,27 @@ Z7_NO_INLINE static void Z7_FASTCALL LenPriceEnc_UpdateTables(
// UInt32 price = a + RcTree_GetPrice(probs, kLenNumHighBits - 1, sym, ProbPrices);
unsigned sym = --i + (1 << (kLenNumHighBits - 1));
UInt32 price = b;
do
{
- unsigned bit = sym & 1;
+ const unsigned bit = sym & 1;
sym >>= 1;
price += GET_PRICEa(probs[sym], bit);
}
while (sym >= 2);
{
- unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))];
+ const unsigned prob = probs[(size_t)i + (1 << (kLenNumHighBits - 1))];
prices[(size_t)i * 2 ] = price + GET_PRICEa_0(prob);
prices[(size_t)i * 2 + 1] = price + GET_PRICEa_1(prob);
}
}
while (i);
{
unsigned posState;
- size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]);
+ const size_t num = (p->tableSize - kLenNumLowSymbols * 2) * sizeof(p->prices[0][0]);
for (posState = 1; posState < numPosStates; posState++)
memcpy(p->prices[posState] + kLenNumLowSymbols * 2, p->prices[0] + kLenNumLowSymbols * 2, num);
}
}
}
@@ -2694,16 +2694,16 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, UInt32 keepWindowSize, ISzAllocPtr alloc,
#ifndef Z7_ST
p->mtMode = (p->multiThread && !p->fastMode && (MFB.btMode != 0));
#endif
{
- unsigned lclp = p->lc + p->lp;
+ const unsigned lclp = p->lc + p->lp;
if (!p->litProbs || !p->saveState.litProbs || p->lclp != lclp)
{
LzmaEnc_FreeLits(p, alloc);
- p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
- p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((UInt32)0x300 << lclp) * sizeof(CLzmaProb));
+ p->litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((size_t)0x300 * sizeof(CLzmaProb)) << lclp);
+ p->saveState.litProbs = (CLzmaProb *)ISzAlloc_Alloc(alloc, ((size_t)0x300 * sizeof(CLzmaProb)) << lclp);
if (!p->litProbs || !p->saveState.litProbs)
{
LzmaEnc_FreeLits(p, alloc);
return SZ_ERROR_MEM;
}
@@ -2800,12 +2800,12 @@ static void LzmaEnc_Init(CLzmaEnc *p)
for (i = 0; i < kNumFullDistances; i++)
p->posEncoders[i] = kProbInitValue;
}
{
- UInt32 num = (UInt32)0x300 << (p->lp + p->lc);
- UInt32 k;
+ const size_t num = (size_t)0x300 << (p->lp + p->lc);
+ size_t k;
CLzmaProb *probs = p->litProbs;
for (k = 0; k < num; k++)
probs[k] = kProbInitValue;
}
diff --git a/src/Common/lzma/Precomp.h b/src/Common/lzma/Precomp.h
index 69afb2ff..7747fdd7 100644
--- a/src/Common/lzma/Precomp.h
+++ b/src/Common/lzma/Precomp.h
@@ -1,10 +1,127 @@
-/* Precomp.h -- StdAfx
-2023-04-02 : Igor Pavlov : Public domain */
+/* Precomp.h -- precompilation file
+2024-01-25 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_PRECOMP_H
#define ZIP7_INC_PRECOMP_H
+/*
+ this file must be included before another *.h files and before <windows.h>.
+ this file is included from the following files:
+ C\*.c
+ C\Util\*\Precomp.h <- C\Util\*\*.c
+ CPP\Common\Common.h <- *\StdAfx.h <- *\*.cpp
+
+ this file can set the following macros:
+ Z7_LARGE_PAGES 1
+ Z7_LONG_PATH 1
+ Z7_WIN32_WINNT_MIN 0x0500 (or higher) : we require at least win2000+ for 7-Zip
+ _WIN32_WINNT 0x0500 (or higher)
+ WINVER _WIN32_WINNT
+ UNICODE 1
+ _UNICODE 1
+*/
+
#include "Compiler.h"
-/* #include "7zTypes.h" */
+
+#ifdef _MSC_VER
+// #pragma warning(disable : 4206) // nonstandard extension used : translation unit is empty
+#if _MSC_VER >= 1912
+// #pragma warning(disable : 5039) // pointer or reference to potentially throwing function passed to 'extern "C"' function under - EHc.Undefined behavior may occur if this function throws an exception.
+#endif
+#endif
+
+/*
+// for debug:
+#define UNICODE 1
+#define _UNICODE 1
+#define _WIN32_WINNT 0x0500 // win2000
+#ifndef WINVER
+ #define WINVER _WIN32_WINNT
+#endif
+*/
+
+#ifdef _WIN32
+/*
+ this "Precomp.h" file must be included before <windows.h>,
+ if we want to define _WIN32_WINNT before <windows.h>.
+*/
+
+#ifndef Z7_LARGE_PAGES
+#ifndef Z7_NO_LARGE_PAGES
+#define Z7_LARGE_PAGES 1
+#endif
+#endif
+
+#ifndef Z7_LONG_PATH
+#ifndef Z7_NO_LONG_PATH
+#define Z7_LONG_PATH 1
+#endif
+#endif
+
+#ifndef Z7_DEVICE_FILE
+#ifndef Z7_NO_DEVICE_FILE
+// #define Z7_DEVICE_FILE 1
+#endif
+#endif
+
+// we don't change macros if included after <windows.h>
+#ifndef _WINDOWS_
+
+#ifndef Z7_WIN32_WINNT_MIN
+ #if defined(_M_ARM64) || defined(__aarch64__)
+ // #define Z7_WIN32_WINNT_MIN 0x0a00 // win10
+ #define Z7_WIN32_WINNT_MIN 0x0600 // vista
+ #elif defined(_M_ARM) && defined(_M_ARMT) && defined(_M_ARM_NT)
+ // #define Z7_WIN32_WINNT_MIN 0x0602 // win8
+ #define Z7_WIN32_WINNT_MIN 0x0600 // vista
+ #elif defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) || defined(_M_IA64)
+ #define Z7_WIN32_WINNT_MIN 0x0503 // win2003
+ // #elif defined(_M_IX86) || defined(__i386__)
+ // #define Z7_WIN32_WINNT_MIN 0x0500 // win2000
+ #else // x86 and another(old) systems
+ #define Z7_WIN32_WINNT_MIN 0x0500 // win2000
+ // #define Z7_WIN32_WINNT_MIN 0x0502 // win2003 // for debug
+ #endif
+#endif // Z7_WIN32_WINNT_MIN
+
+
+#ifndef Z7_DO_NOT_DEFINE_WIN32_WINNT
+#ifdef _WIN32_WINNT
+ // #error Stop_Compiling_Bad_WIN32_WINNT
+#else
+ #ifndef Z7_NO_DEFINE_WIN32_WINNT
+Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
+ #define _WIN32_WINNT Z7_WIN32_WINNT_MIN
+Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
+ #endif
+#endif // _WIN32_WINNT
+
+#ifndef WINVER
+ #define WINVER _WIN32_WINNT
+#endif
+#endif // Z7_DO_NOT_DEFINE_WIN32_WINNT
+
+
+#ifndef _MBCS
+#ifndef Z7_NO_UNICODE
+// UNICODE and _UNICODE are used by <windows.h> and by 7-zip code.
+
+#ifndef UNICODE
+#define UNICODE 1
+#endif
+
+#ifndef _UNICODE
+Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
+#define _UNICODE 1
+Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
+#endif
+
+#endif // Z7_NO_UNICODE
+#endif // _MBCS
+#endif // _WINDOWS_
+
+// #include "7zWindows.h"
+
+#endif // _WIN32
#endif
diff --git a/src/Common/lzma/Threads.c b/src/Common/lzma/Threads.c
index cf52bd30..464efeca 100644
--- a/src/Common/lzma/Threads.c
+++ b/src/Common/lzma/Threads.c
@@ -1,7 +1,7 @@
/* Threads.c -- multithreading library
-2023-03-04 : Igor Pavlov : Public domain */
+2024-03-28 : Igor Pavlov : Public domain */
#include "Precomp.h"
#ifdef _WIN32
@@ -193,24 +193,23 @@ WRes CriticalSection_Init(CCriticalSection *p)
#else // _WIN32
// ---------- POSIX ----------
-#ifndef __APPLE__
+#if defined(__linux__) && !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__)
#ifndef Z7_AFFINITY_DISABLE
// _GNU_SOURCE can be required for pthread_setaffinity_np() / CPU_ZERO / CPU_SET
// clang < 3.6 : unknown warning group '-Wreserved-id-macro'
// clang 3.6 - 12.01 : gives warning "macro name is a reserved identifier"
// clang >= 13 : do not give warning
#if !defined(_GNU_SOURCE)
- #if defined(__clang__) && (__clang_major__ >= 4) && (__clang_major__ <= 12)
- #pragma GCC diagnostic ignored "-Wreserved-id-macro"
- #endif
-#define _GNU_SOURCE
+Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
+// #define _GNU_SOURCE
+Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
#endif // !defined(_GNU_SOURCE)
#endif // Z7_AFFINITY_DISABLE
-#endif // __APPLE__
+#endif // __linux__
#include "Threads.h"
#include <errno.h>
#include <stdlib.h>
@@ -242,12 +241,13 @@ WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param,
if (!ret)
{
if (cpuSet)
{
- #ifdef Z7_AFFINITY_SUPPORTED
-
+ // pthread_attr_setaffinity_np() is not supported for MUSL compile.
+ // so we check for __GLIBC__ here
+#if defined(Z7_AFFINITY_SUPPORTED) && defined( __GLIBC__)
/*
printf("\n affinity :");
unsigned i;
for (i = 0; i < sizeof(*cpuSet) && i < 8; i++)
{
@@ -265,11 +265,11 @@ WRes Thread_Create_With_CpuSet(CThread *p, THREAD_FUNC_TYPE func, LPVOID param,
*/
// ret2 =
pthread_attr_setaffinity_np(&attr, sizeof(*cpuSet), cpuSet);
// if (ret2) ret = ret2;
- #endif
+#endif
}
ret = pthread_create(&p->_tid, &attr, func, param);
if (!ret)
@@ -367,17 +367,24 @@ WRes AutoResetEvent_Create(CAutoResetEvent *p, int signaled)
{ return Event_Create(p, False, signaled); }
WRes AutoResetEvent_CreateNotSignaled(CAutoResetEvent *p)
{ return AutoResetEvent_Create(p, 0); }
+#if defined(Z7_LLVM_CLANG_VERSION) && (__clang_major__ == 13)
+// freebsd:
+#pragma GCC diagnostic ignored "-Wthread-safety-analysis"
+#endif
+
WRes Event_Set(CEvent *p)
{
RINOK(pthread_mutex_lock(&p->_mutex))
p->_state = True;
- int res1 = pthread_cond_broadcast(&p->_cond);
- int res2 = pthread_mutex_unlock(&p->_mutex);
- return (res2 ? res2 : res1);
+ {
+ const int res1 = pthread_cond_broadcast(&p->_cond);
+ const int res2 = pthread_mutex_unlock(&p->_mutex);
+ return (res2 ? res2 : res1);
+ }
}
WRes Event_Reset(CEvent *p)
{
RINOK(pthread_mutex_lock(&p->_mutex))
@@ -406,12 +413,12 @@ WRes Event_Close(CEvent *p)
{
if (!p->_created)
return 0;
p->_created = 0;
{
- int res1 = pthread_mutex_destroy(&p->_mutex);
- int res2 = pthread_cond_destroy(&p->_cond);
+ const int res1 = pthread_mutex_destroy(&p->_mutex);
+ const int res2 = pthread_cond_destroy(&p->_cond);
return (res1 ? res1 : res2);
}
}
@@ -485,12 +492,12 @@ WRes Semaphore_Close(CSemaphore *p)
{
if (!p->_created)
return 0;
p->_created = 0;
{
- int res1 = pthread_mutex_destroy(&p->_mutex);
- int res2 = pthread_cond_destroy(&p->_cond);
+ const int res1 = pthread_mutex_destroy(&p->_mutex);
+ const int res2 = pthread_cond_destroy(&p->_cond);
return (res1 ? res1 : res2);
}
}
@@ -547,10 +554,22 @@ LONG InterlockedIncrement(LONG volatile *addend)
#endif
return __sync_add_and_fetch(addend, 1);
#endif
}
+LONG InterlockedDecrement(LONG volatile *addend)
+{
+ // Print("InterlockedDecrement")
+ #ifdef USE_HACK_UNSAFE_ATOMIC
+ LONG val = *addend - 1;
+ *addend = val;
+ return val;
+ #else
+ return __sync_sub_and_fetch(addend, 1);
+ #endif
+}
+
#endif // _WIN32
WRes AutoResetEvent_OptCreate_And_Reset(CAutoResetEvent *p)
{
if (Event_IsCreated(p))
diff --git a/src/Common/lzma/Threads.h b/src/Common/lzma/Threads.h
index 4028464a..c1484a27 100644
--- a/src/Common/lzma/Threads.h
+++ b/src/Common/lzma/Threads.h
@@ -1,22 +1,31 @@
/* Threads.h -- multithreading library
-2023-04-02 : Igor Pavlov : Public domain */
+2024-03-28 : Igor Pavlov : Public domain */
#ifndef ZIP7_INC_THREADS_H
#define ZIP7_INC_THREADS_H
#ifdef _WIN32
#include "7zWindows.h"
#else
+#include "Compiler.h"
+
+// #define Z7_AFFINITY_DISABLE
#if defined(__linux__)
#if !defined(__APPLE__) && !defined(_AIX) && !defined(__ANDROID__)
#ifndef Z7_AFFINITY_DISABLE
#define Z7_AFFINITY_SUPPORTED
// #pragma message(" ==== Z7_AFFINITY_SUPPORTED")
-// #define _GNU_SOURCE
+#if !defined(_GNU_SOURCE)
+// #pragma message(" ==== _GNU_SOURCE set")
+// we need _GNU_SOURCE for cpu_set_t, if we compile for MUSL
+Z7_DIAGNOSTIC_IGNORE_BEGIN_RESERVED_MACRO_IDENTIFIER
+#define _GNU_SOURCE
+Z7_DIAGNOSTIC_IGNORE_END_RESERVED_MACRO_IDENTIFIER
+#endif
#endif
#endif
#endif
#include <pthread.h>
@@ -171,11 +180,11 @@ WRes CriticalSection_Init(CCriticalSection *p);
#define CriticalSection_Leave(p) LeaveCriticalSection(p)
#else // _WIN32
-typedef struct _CEvent
+typedef struct
{
int _created;
int _manual_reset;
int _state;
pthread_mutex_t _mutex;
@@ -197,11 +206,11 @@ WRes Event_Set(CEvent *p);
WRes Event_Reset(CEvent *p);
WRes Event_Wait(CEvent *p);
WRes Event_Close(CEvent *p);
-typedef struct _CSemaphore
+typedef struct
{
int _created;
UInt32 _count;
UInt32 _maxCount;
pthread_mutex_t _mutex;
@@ -217,21 +226,22 @@ WRes Semaphore_ReleaseN(CSemaphore *p, UInt32 num);
#define Semaphore_Release1(p) Semaphore_ReleaseN(p, 1)
WRes Semaphore_Wait(CSemaphore *p);
WRes Semaphore_Close(CSemaphore *p);
-typedef struct _CCriticalSection
+typedef struct
{
pthread_mutex_t _mutex;
} CCriticalSection;
WRes CriticalSection_Init(CCriticalSection *p);
void CriticalSection_Delete(CCriticalSection *cs);
void CriticalSection_Enter(CCriticalSection *cs);
void CriticalSection_Leave(CCriticalSection *cs);
LONG InterlockedIncrement(LONG volatile *addend);
+LONG InterlockedDecrement(LONG volatile *addend);
#endif // _WIN32
WRes AutoResetEvent_OptCreate_And_Reset(CAutoResetEvent *p);
diff --git a/src/Common/lzma/lzma-history.txt b/src/Common/lzma/lzma-history.txt
index a151c4b9..20e0a441 100644
--- a/src/Common/lzma/lzma-history.txt
+++ b/src/Common/lzma/lzma-history.txt
@@ -1,8 +1,82 @@
HISTORY of the LZMA SDK
-----------------------
+24.09 2024-11-29
+-------------------------
+- The default dictionary size values for LZMA/LZMA2 compression methods were increased:
+ dictionary size compression level
+ v24.08 v24.09 v24.09
+ 32-bit 64-bit
+ 8 MB 16 MB 16 MB -mx4
+ 16 MB 32 MB 32 MB -mx5 : Normal
+ 32 MB 64 MB 64 MB -mx6
+ 32 MB 64 MB 128 MB -mx7 : Maximum
+ 64 MB 64 MB 256 MB -mx8
+ 64 MB 64 MB 256 MB -mx9 : Ultra
+ The default dictionary size values for 32-bit versions of LZMA/LZMA2 don't exceed 64 MB.
+- If an archive update operation uses a temporary archive folder and
+ the archive is moved to the destination folder, 7-Zip shows the progress of moving
+ the archive file, as this operation can take a long time if the archive is large.
+- Some bugs were fixed.
+
+
+24.07 2024-06-19
+-------------------------
+- Changes in files:
+ Asm/x86/Sha256Opt.asm
+ Now it uses "READONLY" flag for constant array segment.
+ It fixes an issue where ".rodata" section in 7-Zip for x86/x64 Linux had a "WRITE" attribute.
+
+
+24.05 2024-05-14
+-------------------------
+- New switch -myv={MMNN} to set decoder compatibility version for 7z archive creating.
+ {MMNN} is 4-digit number that represents the version of 7-Zip without a dot.
+ If -myv={MMNN} switch is specified, 7-Zip will only use compression methods that can
+ be decoded by the specified version {MMNN} of 7-Zip and newer versions.
+ If -myv={MMNN} switch is not specified, -myv=2300 is used, and 7-Zip will only
+ use compression methods that can be decoded by 7-Zip 23.00 and newer versions.
+- New switch -myfa={FilterID} to allow 7-Zip to use the specified filter method for 7z archive creating.
+- New switch -myfd={FilterID} to disallow 7-Zip to use the specified filter method for 7z archive creating.
+
+
+24.03 2024-03-23
+-------------------------
+- 7-Zip now can use new RISCV filter for compression to 7z and xz archives.
+ RISCV filter can increase compression ratio for data containing executable
+ files compiled for RISC-V architecture.
+- The speed for LZMA and LZMA2 decompression in ARM64 version for Windows
+ was increased by 20%-60%.
+ It uses arm64 assembler code, and clang-cl is required for arm64 assembler code compiling.
+- -slmu switch : to show timestamps as UTC instead of LOCAL TIME.
+- -slsl switch : in console 7-Zip for Windows : to show file paths with
+ linux path separator slash '/' instead of backslash separator '\'.
+- 7-Zip supports .sha256 files that use backslash path separator '\'.
+- Some bugs were fixed.
+
+
+24.01 2024-01-31
+-------------------------
+- 7-Zip uses file C/Precomp.h that is included to all c and c++ files.
+ CPP/Common/Common.h also includes C/Precomp.h.
+ C/Precomp.h defines the following macros (if _WIN32 is defined):
+ Z7_LARGE_PAGES 1
+ Z7_LONG_PATH 1
+ Z7_WIN32_WINNT_MIN 0x0500 (or higher)
+ _WIN32_WINNT 0x0500 (or higher)
+ WINVER _WIN32_WINNT
+ UNICODE 1
+ _UNICODE 1
+ if _WIN32_WINNT is defined already, C/Precomp.h doesn't redefine it.
+
+- Speed optimizations for hash caclulation: CRC-32, CRC-64.
+- The bug was fixed: 7-Zip for Linux could fail for multivolume creation in some cases.
+- 7zr.exe for arm64 is included to LZMA SDK package.
+- Some bugs were fixed.
+
+
23.01 2023-06-20
-------------------------
- 7-Zip now can use new ARM64 filter for compression to 7z and xz archives.
ARM64 filter can increase compression ratio for data containing executable
files compiled for ARM64 (AArch64) architecture.
diff --git a/src/Common/lzma/lzma-sdk.txt b/src/Common/lzma/lzma-sdk.txt
index 141b0fd4..f7016709 100644
--- a/src/Common/lzma/lzma-sdk.txt
+++ b/src/Common/lzma/lzma-sdk.txt
@@ -1,6 +1,6 @@
-LZMA SDK 23.01
+LZMA SDK 24.09
--------------
LZMA SDK provides the documentation, samples, header files,
libraries, and tools you need to develop applications that
use 7z / LZMA / LZMA2 / XZ compression.
@@ -135,13 +135,16 @@ DOC/lzma-history.txt - history of LZMA SDK
DOC/lzma-specification.txt - Specification of LZMA
DOC/Methods.txt - Compression method IDs for .7z
bin/installer/ - example script to create installer that uses SFX module,
-bin/7zdec.exe - simplified 7z archive decoder
-bin/7zr.exe - 7-Zip console program (reduced version)
+bin/7zdec.exe - simplified 7z archive decoder (x86 32-bit version)
+bin/7zr.exe - 7-Zip console program (reduced version) (x86 32-bit version)
bin/x64/7zr.exe - 7-Zip console program (reduced version) (x64 version)
+bin/x64/7zdec.exe - simplified 7z archive decoder (x64 version)
+bin/arm64/7zr.exe - 7-Zip console program (reduced version) (arm64 version)
+bin/arm64/7zdec.exe - simplified 7z archive decoder (arm64 version)
bin/lzma.exe - file->file LZMA encoder/decoder for Windows
bin/7zS2.sfx - small SFX module for installers (GUI version)
bin/7zS2con.sfx - small SFX module for installers (Console version)
bin/7zSD.sfx - SFX module for installers.
@@ -233,11 +236,11 @@ Note:
LZMA features
-------------
- - Variable dictionary size (up to 1 GB)
+ - Variable dictionary size (up to 4 GB)
- Estimated compressing speed: about 2 MB/s on 2 GHz CPU
- Estimated decompressing speed:
- 20-30 MB/s on modern 2 GHz cpu
- 1-2 MB/s on 200 MHz simple RISC cpu: (ARM, MIPS, PowerPC)
- Small memory requirements for decompressing (16 KB + DictionarySize)
@@ -283,12 +286,12 @@ Usage: LZMA <e|d> inputFile outputFile [<switches>...]
-a{N}: set compression mode 0 = fast, 1 = normal
default: 1 (normal)
- d{N}: Sets Dictionary size - [0, 30], default: 23 (8MB)
- The maximum value for dictionary size is 1 GB = 2^30 bytes.
+ d{N}: Sets Dictionary size - [0, 31], default: N=24 (32 MB)
+ The maximum value for dictionary size is N=31 (2 GB).
Dictionary size is calculated as DictionarySize = 2^N bytes.
For decompressing file compressed by LZMA method with dictionary
size D = 2^N you need about D bytes of memory (RAM).
-fb{N}: set number of fast bytes - [5, 273], default: 128
@@ -319,11 +322,13 @@ Usage: LZMA <e|d> inputFile outputFile [<switches>...]
MF_ID Memory Description
bt2 d * 9.5 + 4MB Binary Tree with 2 bytes hashing.
bt3 d * 11.5 + 4MB Binary Tree with 3 bytes hashing.
bt4 d * 11.5 + 4MB Binary Tree with 4 bytes hashing.
+ bt5 d * 11.5 + 4MB Binary Tree with 5 bytes hashing.
hc4 d * 7.5 + 4MB Hash Chain with 4 bytes hashing.
+ hc5 d * 7.5 + 4MB Hash Chain with 5 bytes hashing.
-eos: write End Of Stream marker. By default LZMA doesn't write
eos marker, since LZMA decoder knows uncompressed size
stored in .lzma file header.
diff --git a/src/Common/zlib/ChangeLog b/src/Common/zlib/ChangeLog
new file mode 100644
index 00000000..b801a103
--- /dev/null
+++ b/src/Common/zlib/ChangeLog
@@ -0,0 +1,1618 @@
+
+ ChangeLog file for zlib
+
+Changes in 1.3.1 (22 Jan 2024)
+- Reject overflows of zip header fields in minizip
+- Fix bug in inflateSync() for data held in bit buffer
+- Add LIT_MEM define to use more memory for a small deflate speedup
+- Fix decision on the emission of Zip64 end records in minizip
+- Add bounds checking to ERR_MSG() macro, used by zError()
+- Neutralize zip file traversal attacks in miniunz
+- Fix a bug in ZLIB_DEBUG compiles in check_match()
+- Various portability and appearance improvements
+
+Changes in 1.3 (18 Aug 2023)
+- Remove K&R function definitions and zlib2ansi
+- Fix bug in deflateBound() for level 0 and memLevel 9
+- Fix bug when gzungetc() is used immediately after gzopen()
+- Fix bug when using gzflush() with a very small buffer
+- Fix crash when gzsetparams() attempted for transparent write
+- Fix test/example.c to work with FORCE_STORED
+- Rewrite of zran in examples (see zran.c version history)
+- Fix minizip to allow it to open an empty zip file
+- Fix reading disk number start on zip64 files in minizip
+- Fix logic error in minizip argument processing
+- Add minizip testing to Makefile
+- Read multiple bytes instead of byte-by-byte in minizip unzip.c
+- Add memory sanitizer to configure (--memory)
+- Various portability improvements
+- Various documentation improvements
+- Various spelling and typo corrections
+
+Changes in 1.2.13 (13 Oct 2022)
+- Fix configure issue that discarded provided CC definition
+- Correct incorrect inputs provided to the CRC functions
+- Repair prototypes and exporting of new CRC functions
+- Fix inflateBack to detect invalid input with distances too far
+- Have infback() deliver all of the available output up to any error
+- Fix a bug when getting a gzip header extra field with inflate()
+- Fix bug in block type selection when Z_FIXED used
+- Tighten deflateBound bounds
+- Remove deleted assembler code references
+- Various portability and appearance improvements
+
+Changes in 1.2.12 (27 Mar 2022)
+- Cygwin does not have _wopen(), so do not create gzopen_w() there
+- Permit a deflateParams() parameter change as soon as possible
+- Limit hash table inserts after switch from stored deflate
+- Fix bug when window full in deflate_stored()
+- Fix CLEAR_HASH macro to be usable as a single statement
+- Avoid a conversion error in gzseek when off_t type too small
+- Have Makefile return non-zero error code on test failure
+- Avoid some conversion warnings in gzread.c and gzwrite.c
+- Update use of errno for newer Windows CE versions
+- Small speedup to inflate [psumbera]
+- Return an error if the gzputs string length can't fit in an int
+- Add address checking in clang to -w option of configure
+- Don't compute check value for raw inflate if asked to validate
+- Handle case where inflateSync used when header never processed
+- Avoid the use of ptrdiff_t
+- Avoid an undefined behavior of memcpy() in gzappend()
+- Avoid undefined behaviors of memcpy() in gz*printf()
+- Avoid an undefined behavior of memcpy() in _tr_stored_block()
+- Make the names in functions declarations identical to definitions
+- Remove old assembler code in which bugs have manifested
+- Fix deflateEnd() to not report an error at start of raw deflate
+- Add legal disclaimer to README
+- Emphasize the need to continue decompressing gzip members
+- Correct the initialization requirements for deflateInit2()
+- Fix a bug that can crash deflate on some input when using Z_FIXED
+- Assure that the number of bits for deflatePrime() is valid
+- Use a structure to make globals in enough.c evident
+- Use a macro for the printf format of big_t in enough.c
+- Clean up code style in enough.c, update version
+- Use inline function instead of macro for index in enough.c
+- Clarify that prefix codes are counted in enough.c
+- Show all the codes for the maximum tables size in enough.c
+- Add gznorm.c example, which normalizes gzip files
+- Fix the zran.c example to work on a multiple-member gzip file
+- Add tables for crc32_combine(), to speed it up by a factor of 200
+- Add crc32_combine_gen() and crc32_combine_op() for fast combines
+- Speed up software CRC-32 computation by a factor of 1.5 to 3
+- Use atomic test and set, if available, for dynamic CRC tables
+- Don't bother computing check value after successful inflateSync()
+- Correct comment in crc32.c
+- Add use of the ARMv8 crc32 instructions when requested
+- Use ARM crc32 instructions if the ARM architecture has them
+- Explicitly note that the 32-bit check values are 32 bits
+- Avoid adding empty gzip member after gzflush with Z_FINISH
+- Fix memory leak on error in gzlog.c
+- Fix error in comment on the polynomial representation of a byte
+- Clarify gz* function interfaces, referring to parameter names
+- Change macro name in inflate.c to avoid collision in VxWorks
+- Correct typo in blast.c
+- Improve portability of contrib/minizip
+- Fix indentation in minizip's zip.c
+- Replace black/white with allow/block. (theresa-m)
+- minizip warning fix if MAXU32 already defined. (gvollant)
+- Fix unztell64() in minizip to work past 4GB. (Daniël Hörchner)
+- Clean up minizip to reduce warnings for testing
+- Add fallthrough comments for gcc
+- Eliminate use of ULL constants
+- Separate out address sanitizing from warnings in configure
+- Remove destructive aspects of make distclean
+- Check for cc masquerading as gcc or clang in configure
+- Fix crc32.c to compile local functions only if used
+
+Changes in 1.2.11 (15 Jan 2017)
+- Fix deflate stored bug when pulling last block from window
+- Permit immediate deflateParams changes before any deflate input
+
+Changes in 1.2.10 (2 Jan 2017)
+- Avoid warnings on snprintf() return value
+- Fix bug in deflate_stored() for zero-length input
+- Fix bug in gzwrite.c that produced corrupt gzip files
+- Remove files to be installed before copying them in Makefile.in
+- Add warnings when compiling with assembler code
+
+Changes in 1.2.9 (31 Dec 2016)
+- Fix contrib/minizip to permit unzipping with desktop API [Zouzou]
+- Improve contrib/blast to return unused bytes
+- Assure that gzoffset() is correct when appending
+- Improve compress() and uncompress() to support large lengths
+- Fix bug in test/example.c where error code not saved
+- Remedy Coverity warning [Randers-Pehrson]
+- Improve speed of gzprintf() in transparent mode
+- Fix inflateInit2() bug when windowBits is 16 or 32
+- Change DEBUG macro to ZLIB_DEBUG
+- Avoid uninitialized access by gzclose_w()
+- Allow building zlib outside of the source directory
+- Fix bug that accepted invalid zlib header when windowBits is zero
+- Fix gzseek() problem on MinGW due to buggy _lseeki64 there
+- Loop on write() calls in gzwrite.c in case of non-blocking I/O
+- Add --warn (-w) option to ./configure for more compiler warnings
+- Reject a window size of 256 bytes if not using the zlib wrapper
+- Fix bug when level 0 used with Z_HUFFMAN or Z_RLE
+- Add --debug (-d) option to ./configure to define ZLIB_DEBUG
+- Fix bugs in creating a very large gzip header
+- Add uncompress2() function, which returns the input size used
+- Assure that deflateParams() will not switch functions mid-block
+- Dramatically speed up deflation for level 0 (storing)
+- Add gzfread(), duplicating the interface of fread()
+- Add gzfwrite(), duplicating the interface of fwrite()
+- Add deflateGetDictionary() function
+- Use snprintf() for later versions of Microsoft C
+- Fix *Init macros to use z_ prefix when requested
+- Replace as400 with os400 for OS/400 support [Monnerat]
+- Add crc32_z() and adler32_z() functions with size_t lengths
+- Update Visual Studio project files [AraHaan]
+
+Changes in 1.2.8 (28 Apr 2013)
+- Update contrib/minizip/iowin32.c for Windows RT [Vollant]
+- Do not force Z_CONST for C++
+- Clean up contrib/vstudio [Roß]
+- Correct spelling error in zlib.h
+- Fix mixed line endings in contrib/vstudio
+
+Changes in 1.2.7.3 (13 Apr 2013)
+- Fix version numbers and DLL names in contrib/vstudio/*/zlib.rc
+
+Changes in 1.2.7.2 (13 Apr 2013)
+- Change check for a four-byte type back to hexadecimal
+- Fix typo in win32/Makefile.msc
+- Add casts in gzwrite.c for pointer differences
+
+Changes in 1.2.7.1 (24 Mar 2013)
+- Replace use of unsafe string functions with snprintf if available
+- Avoid including stddef.h on Windows for Z_SOLO compile [Niessink]
+- Fix gzgetc undefine when Z_PREFIX set [Turk]
+- Eliminate use of mktemp in Makefile (not always available)
+- Fix bug in 'F' mode for gzopen()
+- Add inflateGetDictionary() function
+- Correct comment in deflate.h
+- Use _snprintf for snprintf in Microsoft C
+- On Darwin, only use /usr/bin/libtool if libtool is not Apple
+- Delete "--version" file if created by "ar --version" [Richard G.]
+- Fix configure check for veracity of compiler error return codes
+- Fix CMake compilation of static lib for MSVC2010 x64
+- Remove unused variable in infback9.c
+- Fix argument checks in gzlog_compress() and gzlog_write()
+- Clean up the usage of z_const and respect const usage within zlib
+- Clean up examples/gzlog.[ch] comparisons of different types
+- Avoid shift equal to bits in type (caused endless loop)
+- Fix uninitialized value bug in gzputc() introduced by const patches
+- Fix memory allocation error in examples/zran.c [Nor]
+- Fix bug where gzopen(), gzclose() would write an empty file
+- Fix bug in gzclose() when gzwrite() runs out of memory
+- Check for input buffer malloc failure in examples/gzappend.c
+- Add note to contrib/blast to use binary mode in stdio
+- Fix comparisons of differently signed integers in contrib/blast
+- Check for invalid code length codes in contrib/puff
+- Fix serious but very rare decompression bug in inftrees.c
+- Update inflateBack() comments, since inflate() can be faster
+- Use underscored I/O function names for WINAPI_FAMILY
+- Add _tr_flush_bits to the external symbols prefixed by --zprefix
+- Add contrib/vstudio/vc10 pre-build step for static only
+- Quote --version-script argument in CMakeLists.txt
+- Don't specify --version-script on Apple platforms in CMakeLists.txt
+- Fix casting error in contrib/testzlib/testzlib.c
+- Fix types in contrib/minizip to match result of get_crc_table()
+- Simplify contrib/vstudio/vc10 with 'd' suffix
+- Add TOP support to win32/Makefile.msc
+- Support i686 and amd64 assembler builds in CMakeLists.txt
+- Fix typos in the use of _LARGEFILE64_SOURCE in zconf.h
+- Add vc11 and vc12 build files to contrib/vstudio
+- Add gzvprintf() as an undocumented function in zlib
+- Fix configure for Sun shell
+- Remove runtime check in configure for four-byte integer type
+- Add casts and consts to ease user conversion to C++
+- Add man pages for minizip and miniunzip
+- In Makefile uninstall, don't rm if preceding cd fails
+- Do not return Z_BUF_ERROR if deflateParam() has nothing to write
+
+Changes in 1.2.7 (2 May 2012)
+- Replace use of memmove() with a simple copy for portability
+- Test for existence of strerror
+- Restore gzgetc_ for backward compatibility with 1.2.6
+- Fix build with non-GNU make on Solaris
+- Require gcc 4.0 or later on Mac OS X to use the hidden attribute
+- Include unistd.h for Watcom C
+- Use __WATCOMC__ instead of __WATCOM__
+- Do not use the visibility attribute if NO_VIZ defined
+- Improve the detection of no hidden visibility attribute
+- Avoid using __int64 for gcc or solo compilation
+- Cast to char * in gzprintf to avoid warnings [Zinser]
+- Fix make_vms.com for VAX [Zinser]
+- Don't use library or built-in byte swaps
+- Simplify test and use of gcc hidden attribute
+- Fix bug in gzclose_w() when gzwrite() fails to allocate memory
+- Add "x" (O_EXCL) and "e" (O_CLOEXEC) modes support to gzopen()
+- Fix bug in test/minigzip.c for configure --solo
+- Fix contrib/vstudio project link errors [Mohanathas]
+- Add ability to choose the builder in make_vms.com [Schweda]
+- Add DESTDIR support to mingw32 win32/Makefile.gcc
+- Fix comments in win32/Makefile.gcc for proper usage
+- Allow overriding the default install locations for cmake
+- Generate and install the pkg-config file with cmake
+- Build both a static and a shared version of zlib with cmake
+- Include version symbols for cmake builds
+- If using cmake with MSVC, add the source directory to the includes
+- Remove unneeded EXTRA_CFLAGS from win32/Makefile.gcc [Truta]
+- Move obsolete emx makefile to old [Truta]
+- Allow the use of -Wundef when compiling or using zlib
+- Avoid the use of the -u option with mktemp
+- Improve inflate() documentation on the use of Z_FINISH
+- Recognize clang as gcc
+- Add gzopen_w() in Windows for wide character path names
+- Rename zconf.h in CMakeLists.txt to move it out of the way
+- Add source directory in CMakeLists.txt for building examples
+- Look in build directory for zlib.pc in CMakeLists.txt
+- Remove gzflags from zlibvc.def in vc9 and vc10
+- Fix contrib/minizip compilation in the MinGW environment
+- Update ./configure for Solaris, support --64 [Mooney]
+- Remove -R. from Solaris shared build (possible security issue)
+- Avoid race condition for parallel make (-j) running example
+- Fix type mismatch between get_crc_table() and crc_table
+- Fix parsing of version with "-" in CMakeLists.txt [Snider, Ziegler]
+- Fix the path to zlib.map in CMakeLists.txt
+- Force the native libtool in Mac OS X to avoid GNU libtool [Beebe]
+- Add instructions to win32/Makefile.gcc for shared install [Torri]
+
+Changes in 1.2.6.1 (12 Feb 2012)
+- Avoid the use of the Objective-C reserved name "id"
+- Include io.h in gzguts.h for Microsoft compilers
+- Fix problem with ./configure --prefix and gzgetc macro
+- Include gz_header definition when compiling zlib solo
+- Put gzflags() functionality back in zutil.c
+- Avoid library header include in crc32.c for Z_SOLO
+- Use name in GCC_CLASSIC as C compiler for coverage testing, if set
+- Minor cleanup in contrib/minizip/zip.c [Vollant]
+- Update make_vms.com [Zinser]
+- Remove unnecessary gzgetc_ function
+- Use optimized byte swap operations for Microsoft and GNU [Snyder]
+- Fix minor typo in zlib.h comments [Rzesniowiecki]
+
+Changes in 1.2.6 (29 Jan 2012)
+- Update the Pascal interface in contrib/pascal
+- Fix function numbers for gzgetc_ in zlibvc.def files
+- Fix configure.ac for contrib/minizip [Schiffer]
+- Fix large-entry detection in minizip on 64-bit systems [Schiffer]
+- Have ./configure use the compiler return code for error indication
+- Fix CMakeLists.txt for cross compilation [McClure]
+- Fix contrib/minizip/zip.c for 64-bit architectures [Dalsnes]
+- Fix compilation of contrib/minizip on FreeBSD [Marquez]
+- Correct suggested usages in win32/Makefile.msc [Shachar, Horvath]
+- Include io.h for Turbo C / Borland C on all platforms [Truta]
+- Make version explicit in contrib/minizip/configure.ac [Bosmans]
+- Avoid warning for no encryption in contrib/minizip/zip.c [Vollant]
+- Minor cleanup up contrib/minizip/unzip.c [Vollant]
+- Fix bug when compiling minizip with C++ [Vollant]
+- Protect for long name and extra fields in contrib/minizip [Vollant]
+- Avoid some warnings in contrib/minizip [Vollant]
+- Add -I../.. -L../.. to CFLAGS for minizip and miniunzip
+- Add missing libs to minizip linker command
+- Add support for VPATH builds in contrib/minizip
+- Add an --enable-demos option to contrib/minizip/configure
+- Add the generation of configure.log by ./configure
+- Exit when required parameters not provided to win32/Makefile.gcc
+- Have gzputc return the character written instead of the argument
+- Use the -m option on ldconfig for BSD systems [Tobias]
+- Correct in zlib.map when deflateResetKeep was added
+
+Changes in 1.2.5.3 (15 Jan 2012)
+- Restore gzgetc function for binary compatibility
+- Do not use _lseeki64 under Borland C++ [Truta]
+- Update win32/Makefile.msc to build test/*.c [Truta]
+- Remove old/visualc6 given CMakefile and other alternatives
+- Update AS400 build files and documentation [Monnerat]
+- Update win32/Makefile.gcc to build test/*.c [Truta]
+- Permit stronger flushes after Z_BLOCK flushes
+- Avoid extraneous empty blocks when doing empty flushes
+- Permit Z_NULL arguments to deflatePending
+- Allow deflatePrime() to insert bits in the middle of a stream
+- Remove second empty static block for Z_PARTIAL_FLUSH
+- Write out all of the available bits when using Z_BLOCK
+- Insert the first two strings in the hash table after a flush
+
+Changes in 1.2.5.2 (17 Dec 2011)
+- fix ld error: unable to find version dependency 'ZLIB_1.2.5'
+- use relative symlinks for shared libs
+- Avoid searching past window for Z_RLE strategy
+- Assure that high-water mark initialization is always applied in deflate
+- Add assertions to fill_window() in deflate.c to match comments
+- Update python link in README
+- Correct spelling error in gzread.c
+- Fix bug in gzgets() for a concatenated empty gzip stream
+- Correct error in comment for gz_make()
+- Change gzread() and related to ignore junk after gzip streams
+- Allow gzread() and related to continue after gzclearerr()
+- Allow gzrewind() and gzseek() after a premature end-of-file
+- Simplify gzseek() now that raw after gzip is ignored
+- Change gzgetc() to a macro for speed (~40% speedup in testing)
+- Fix gzclose() to return the actual error last encountered
+- Always add large file support for windows
+- Include zconf.h for windows large file support
+- Include zconf.h.cmakein for windows large file support
+- Update zconf.h.cmakein on make distclean
+- Merge vestigial vsnprintf determination from zutil.h to gzguts.h
+- Clarify how gzopen() appends in zlib.h comments
+- Correct documentation of gzdirect() since junk at end now ignored
+- Add a transparent write mode to gzopen() when 'T' is in the mode
+- Update python link in zlib man page
+- Get inffixed.h and MAKEFIXED result to match
+- Add a ./config --solo option to make zlib subset with no library use
+- Add undocumented inflateResetKeep() function for CAB file decoding
+- Add --cover option to ./configure for gcc coverage testing
+- Add #define ZLIB_CONST option to use const in the z_stream interface
+- Add comment to gzdopen() in zlib.h to use dup() when using fileno()
+- Note behavior of uncompress() to provide as much data as it can
+- Add files in contrib/minizip to aid in building libminizip
+- Split off AR options in Makefile.in and configure
+- Change ON macro to Z_ARG to avoid application conflicts
+- Facilitate compilation with Borland C++ for pragmas and vsnprintf
+- Include io.h for Turbo C / Borland C++
+- Move example.c and minigzip.c to test/
+- Simplify incomplete code table filling in inflate_table()
+- Remove code from inflate.c and infback.c that is impossible to execute
+- Test the inflate code with full coverage
+- Allow deflateSetDictionary, inflateSetDictionary at any time (in raw)
+- Add deflateResetKeep and fix inflateResetKeep to retain dictionary
+- Fix gzwrite.c to accommodate reduced memory zlib compilation
+- Have inflate() with Z_FINISH avoid the allocation of a window
+- Do not set strm->adler when doing raw inflate
+- Fix gzeof() to behave just like feof() when read is not past end of file
+- Fix bug in gzread.c when end-of-file is reached
+- Avoid use of Z_BUF_ERROR in gz* functions except for premature EOF
+- Document gzread() capability to read concurrently written files
+- Remove hard-coding of resource compiler in CMakeLists.txt [Blammo]
+
+Changes in 1.2.5.1 (10 Sep 2011)
+- Update FAQ entry on shared builds (#13)
+- Avoid symbolic argument to chmod in Makefile.in
+- Fix bug and add consts in contrib/puff [Oberhumer]
+- Update contrib/puff/zeros.raw test file to have all block types
+- Add full coverage test for puff in contrib/puff/Makefile
+- Fix static-only-build install in Makefile.in
+- Fix bug in unzGetCurrentFileInfo() in contrib/minizip [Kuno]
+- Add libz.a dependency to shared in Makefile.in for parallel builds
+- Spell out "number" (instead of "nb") in zlib.h for total_in, total_out
+- Replace $(...) with `...` in configure for non-bash sh [Bowler]
+- Add darwin* to Darwin* and solaris* to SunOS\ 5* in configure [Groffen]
+- Add solaris* to Linux* in configure to allow gcc use [Groffen]
+- Add *bsd* to Linux* case in configure [Bar-Lev]
+- Add inffast.obj to dependencies in win32/Makefile.msc
+- Correct spelling error in deflate.h [Kohler]
+- Change libzdll.a again to libz.dll.a (!) in win32/Makefile.gcc
+- Add test to configure for GNU C looking for gcc in output of $cc -v
+- Add zlib.pc generation to win32/Makefile.gcc [Weigelt]
+- Fix bug in zlib.h for _FILE_OFFSET_BITS set and _LARGEFILE64_SOURCE not
+- Add comment in zlib.h that adler32_combine with len2 < 0 makes no sense
+- Make NO_DIVIDE option in adler32.c much faster (thanks to John Reiser)
+- Make stronger test in zconf.h to include unistd.h for LFS
+- Apply Darwin patches for 64-bit file offsets to contrib/minizip [Slack]
+- Fix zlib.h LFS support when Z_PREFIX used
+- Add updated as400 support (removed from old) [Monnerat]
+- Avoid deflate sensitivity to volatile input data
+- Avoid division in adler32_combine for NO_DIVIDE
+- Clarify the use of Z_FINISH with deflateBound() amount of space
+- Set binary for output file in puff.c
+- Use u4 type for crc_table to avoid conversion warnings
+- Apply casts in zlib.h to avoid conversion warnings
+- Add OF to prototypes for adler32_combine_ and crc32_combine_ [Miller]
+- Improve inflateSync() documentation to note indeterminacy
+- Add deflatePending() function to return the amount of pending output
+- Correct the spelling of "specification" in FAQ [Randers-Pehrson]
+- Add a check in configure for stdarg.h, use for gzprintf()
+- Check that pointers fit in ints when gzprint() compiled old style
+- Add dummy name before $(SHAREDLIBV) in Makefile [Bar-Lev, Bowler]
+- Delete line in configure that adds -L. libz.a to LDFLAGS [Weigelt]
+- Add debug records in assembler code [Londer]
+- Update RFC references to use http://tools.ietf.org/html/... [Li]
+- Add --archs option, use of libtool to configure for Mac OS X [Borstel]
+
+Changes in 1.2.5 (19 Apr 2010)
+- Disable visibility attribute in win32/Makefile.gcc [Bar-Lev]
+- Default to libdir as sharedlibdir in configure [Nieder]
+- Update copyright dates on modified source files
+- Update trees.c to be able to generate modified trees.h
+- Exit configure for MinGW, suggesting win32/Makefile.gcc
+- Check for NULL path in gz_open [Homurlu]
+
+Changes in 1.2.4.5 (18 Apr 2010)
+- Set sharedlibdir in configure [Torok]
+- Set LDFLAGS in Makefile.in [Bar-Lev]
+- Avoid mkdir objs race condition in Makefile.in [Bowler]
+- Add ZLIB_INTERNAL in front of internal inter-module functions and arrays
+- Define ZLIB_INTERNAL to hide internal functions and arrays for GNU C
+- Don't use hidden attribute when it is a warning generator (e.g. Solaris)
+
+Changes in 1.2.4.4 (18 Apr 2010)
+- Fix CROSS_PREFIX executable testing, CHOST extract, mingw* [Torok]
+- Undefine _LARGEFILE64_SOURCE in zconf.h if it is zero, but not if empty
+- Try to use bash or ksh regardless of functionality of /bin/sh
+- Fix configure incompatibility with NetBSD sh
+- Remove attempt to run under bash or ksh since have better NetBSD fix
+- Fix win32/Makefile.gcc for MinGW [Bar-Lev]
+- Add diagnostic messages when using CROSS_PREFIX in configure
+- Added --sharedlibdir option to configure [Weigelt]
+- Use hidden visibility attribute when available [Frysinger]
+
+Changes in 1.2.4.3 (10 Apr 2010)
+- Only use CROSS_PREFIX in configure for ar and ranlib if they exist
+- Use CROSS_PREFIX for nm [Bar-Lev]
+- Assume _LARGEFILE64_SOURCE defined is equivalent to true
+- Avoid use of undefined symbols in #if with && and ||
+- Make *64 prototypes in gzguts.h consistent with functions
+- Add -shared load option for MinGW in configure [Bowler]
+- Move z_off64_t to public interface, use instead of off64_t
+- Remove ! from shell test in configure (not portable to Solaris)
+- Change +0 macro tests to -0 for possibly increased portability
+
+Changes in 1.2.4.2 (9 Apr 2010)
+- Add consistent carriage returns to readme.txt's in masmx86 and masmx64
+- Really provide prototypes for *64 functions when building without LFS
+- Only define unlink() in minigzip.c if unistd.h not included
+- Update README to point to contrib/vstudio project files
+- Move projects/vc6 to old/ and remove projects/
+- Include stdlib.h in minigzip.c for setmode() definition under WinCE
+- Clean up assembler builds in win32/Makefile.msc [Rowe]
+- Include sys/types.h for Microsoft for off_t definition
+- Fix memory leak on error in gz_open()
+- Symbolize nm as $NM in configure [Weigelt]
+- Use TEST_LDSHARED instead of LDSHARED to link test programs [Weigelt]
+- Add +0 to _FILE_OFFSET_BITS and _LFS64_LARGEFILE in case not defined
+- Fix bug in gzeof() to take into account unused input data
+- Avoid initialization of structures with variables in puff.c
+- Updated win32/README-WIN32.txt [Rowe]
+
+Changes in 1.2.4.1 (28 Mar 2010)
+- Remove the use of [a-z] constructs for sed in configure [gentoo 310225]
+- Remove $(SHAREDLIB) from LIBS in Makefile.in [Creech]
+- Restore "for debugging" comment on sprintf() in gzlib.c
+- Remove fdopen for MVS from gzguts.h
+- Put new README-WIN32.txt in win32 [Rowe]
+- Add check for shell to configure and invoke another shell if needed
+- Fix big fat stinking bug in gzseek() on uncompressed files
+- Remove vestigial F_OPEN64 define in zutil.h
+- Set and check the value of _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE
+- Avoid errors on non-LFS systems when applications define LFS macros
+- Set EXE to ".exe" in configure for MINGW [Kahle]
+- Match crc32() in crc32.c exactly to the prototype in zlib.h [Sherrill]
+- Add prefix for cross-compilation in win32/makefile.gcc [Bar-Lev]
+- Add DLL install in win32/makefile.gcc [Bar-Lev]
+- Allow Linux* or linux* from uname in configure [Bar-Lev]
+- Allow ldconfig to be redefined in configure and Makefile.in [Bar-Lev]
+- Add cross-compilation prefixes to configure [Bar-Lev]
+- Match type exactly in gz_load() invocation in gzread.c
+- Match type exactly of zcalloc() in zutil.c to zlib.h alloc_func
+- Provide prototypes for *64 functions when building zlib without LFS
+- Don't use -lc when linking shared library on MinGW
+- Remove errno.h check in configure and vestigial errno code in zutil.h
+
+Changes in 1.2.4 (14 Mar 2010)
+- Fix VER3 extraction in configure for no fourth subversion
+- Update zlib.3, add docs to Makefile.in to make .pdf out of it
+- Add zlib.3.pdf to distribution
+- Don't set error code in gzerror() if passed pointer is NULL
+- Apply destination directory fixes to CMakeLists.txt [Lowman]
+- Move #cmakedefine's to a new zconf.in.cmakein
+- Restore zconf.h for builds that don't use configure or cmake
+- Add distclean to dummy Makefile for convenience
+- Update and improve INDEX, README, and FAQ
+- Update CMakeLists.txt for the return of zconf.h [Lowman]
+- Update contrib/vstudio/vc9 and vc10 [Vollant]
+- Change libz.dll.a back to libzdll.a in win32/Makefile.gcc
+- Apply license and readme changes to contrib/asm686 [Raiter]
+- Check file name lengths and add -c option in minigzip.c [Li]
+- Update contrib/amd64 and contrib/masmx86/ [Vollant]
+- Avoid use of "eof" parameter in trees.c to not shadow library variable
+- Update make_vms.com for removal of zlibdefs.h [Zinser]
+- Update assembler code and vstudio projects in contrib [Vollant]
+- Remove outdated assembler code contrib/masm686 and contrib/asm586
+- Remove old vc7 and vc8 from contrib/vstudio
+- Update win32/Makefile.msc, add ZLIB_VER_SUBREVISION [Rowe]
+- Fix memory leaks in gzclose_r() and gzclose_w(), file leak in gz_open()
+- Add contrib/gcc_gvmat64 for longest_match and inflate_fast [Vollant]
+- Remove *64 functions from win32/zlib.def (they're not 64-bit yet)
+- Fix bug in void-returning vsprintf() case in gzwrite.c
+- Fix name change from inflate.h in contrib/inflate86/inffas86.c
+- Check if temporary file exists before removing in make_vms.com [Zinser]
+- Fix make install and uninstall for --static option
+- Fix usage of _MSC_VER in gzguts.h and zutil.h [Truta]
+- Update readme.txt in contrib/masmx64 and masmx86 to assemble
+
+Changes in 1.2.3.9 (21 Feb 2010)
+- Expunge gzio.c
+- Move as400 build information to old
+- Fix updates in contrib/minizip and contrib/vstudio
+- Add const to vsnprintf test in configure to avoid warnings [Weigelt]
+- Delete zconf.h (made by configure) [Weigelt]
+- Change zconf.in.h to zconf.h.in per convention [Weigelt]
+- Check for NULL buf in gzgets()
+- Return empty string for gzgets() with len == 1 (like fgets())
+- Fix description of gzgets() in zlib.h for end-of-file, NULL return
+- Update minizip to 1.1 [Vollant]
+- Avoid MSVC loss of data warnings in gzread.c, gzwrite.c
+- Note in zlib.h that gzerror() should be used to distinguish from EOF
+- Remove use of snprintf() from gzlib.c
+- Fix bug in gzseek()
+- Update contrib/vstudio, adding vc9 and vc10 [Kuno, Vollant]
+- Fix zconf.h generation in CMakeLists.txt [Lowman]
+- Improve comments in zconf.h where modified by configure
+
+Changes in 1.2.3.8 (13 Feb 2010)
+- Clean up text files (tabs, trailing whitespace, etc.) [Oberhumer]
+- Use z_off64_t in gz_zero() and gz_skip() to match state->skip
+- Avoid comparison problem when sizeof(int) == sizeof(z_off64_t)
+- Revert to Makefile.in from 1.2.3.6 (live with the clutter)
+- Fix missing error return in gzflush(), add zlib.h note
+- Add *64 functions to zlib.map [Levin]
+- Fix signed/unsigned comparison in gz_comp()
+- Use SFLAGS when testing shared linking in configure
+- Add --64 option to ./configure to use -m64 with gcc
+- Fix ./configure --help to correctly name options
+- Have make fail if a test fails [Levin]
+- Avoid buffer overrun in contrib/masmx64/gvmat64.asm [Simpson]
+- Remove assembler object files from contrib
+
+Changes in 1.2.3.7 (24 Jan 2010)
+- Always gzopen() with O_LARGEFILE if available
+- Fix gzdirect() to work immediately after gzopen() or gzdopen()
+- Make gzdirect() more precise when the state changes while reading
+- Improve zlib.h documentation in many places
+- Catch memory allocation failure in gz_open()
+- Complete close operation if seek forward in gzclose_w() fails
+- Return Z_ERRNO from gzclose_r() if close() fails
+- Return Z_STREAM_ERROR instead of EOF for gzclose() being passed NULL
+- Return zero for gzwrite() errors to match zlib.h description
+- Return -1 on gzputs() error to match zlib.h description
+- Add zconf.in.h to allow recovery from configure modification [Weigelt]
+- Fix static library permissions in Makefile.in [Weigelt]
+- Avoid warnings in configure tests that hide functionality [Weigelt]
+- Add *BSD and DragonFly to Linux case in configure [gentoo 123571]
+- Change libzdll.a to libz.dll.a in win32/Makefile.gcc [gentoo 288212]
+- Avoid access of uninitialized data for first inflateReset2 call [Gomes]
+- Keep object files in subdirectories to reduce the clutter somewhat
+- Remove default Makefile and zlibdefs.h, add dummy Makefile
+- Add new external functions to Z_PREFIX, remove duplicates, z_z_ -> z_
+- Remove zlibdefs.h completely -- modify zconf.h instead
+
+Changes in 1.2.3.6 (17 Jan 2010)
+- Avoid void * arithmetic in gzread.c and gzwrite.c
+- Make compilers happier with const char * for gz_error message
+- Avoid unused parameter warning in inflate.c
+- Avoid signed-unsigned comparison warning in inflate.c
+- Indent #pragma's for traditional C
+- Fix usage of strwinerror() in glib.c, change to gz_strwinerror()
+- Correct email address in configure for system options
+- Update make_vms.com and add make_vms.com to contrib/minizip [Zinser]
+- Update zlib.map [Brown]
+- Fix Makefile.in for Solaris 10 make of example64 and minizip64 [Torok]
+- Apply various fixes to CMakeLists.txt [Lowman]
+- Add checks on len in gzread() and gzwrite()
+- Add error message for no more room for gzungetc()
+- Remove zlib version check in gzwrite()
+- Defer compression of gzprintf() result until need to
+- Use snprintf() in gzdopen() if available
+- Remove USE_MMAP configuration determination (only used by minigzip)
+- Remove examples/pigz.c (available separately)
+- Update examples/gun.c to 1.6
+
+Changes in 1.2.3.5 (8 Jan 2010)
+- Add space after #if in zutil.h for some compilers
+- Fix relatively harmless bug in deflate_fast() [Exarevsky]
+- Fix same problem in deflate_slow()
+- Add $(SHAREDLIBV) to LIBS in Makefile.in [Brown]
+- Add deflate_rle() for faster Z_RLE strategy run-length encoding
+- Add deflate_huff() for faster Z_HUFFMAN_ONLY encoding
+- Change name of "write" variable in inffast.c to avoid library collisions
+- Fix premature EOF from gzread() in gzio.c [Brown]
+- Use zlib header window size if windowBits is 0 in inflateInit2()
+- Remove compressBound() call in deflate.c to avoid linking compress.o
+- Replace use of errno in gz* with functions, support WinCE [Alves]
+- Provide alternative to perror() in minigzip.c for WinCE [Alves]
+- Don't use _vsnprintf on later versions of MSVC [Lowman]
+- Add CMake build script and input file [Lowman]
+- Update contrib/minizip to 1.1 [Svensson, Vollant]
+- Moved nintendods directory from contrib to root
+- Replace gzio.c with a new set of routines with the same functionality
+- Add gzbuffer(), gzoffset(), gzclose_r(), gzclose_w() as part of above
+- Update contrib/minizip to 1.1b
+- Change gzeof() to return 0 on error instead of -1 to agree with zlib.h
+
+Changes in 1.2.3.4 (21 Dec 2009)
+- Use old school .SUFFIXES in Makefile.in for FreeBSD compatibility
+- Update comments in configure and Makefile.in for default --shared
+- Fix test -z's in configure [Marquess]
+- Build examplesh and minigzipsh when not testing
+- Change NULL's to Z_NULL's in deflate.c and in comments in zlib.h
+- Import LDFLAGS from the environment in configure
+- Fix configure to populate SFLAGS with discovered CFLAGS options
+- Adapt make_vms.com to the new Makefile.in [Zinser]
+- Add zlib2ansi script for C++ compilation [Marquess]
+- Add _FILE_OFFSET_BITS=64 test to make test (when applicable)
+- Add AMD64 assembler code for longest match to contrib [Teterin]
+- Include options from $SFLAGS when doing $LDSHARED
+- Simplify 64-bit file support by introducing z_off64_t type
+- Make shared object files in objs directory to work around old Sun cc
+- Use only three-part version number for Darwin shared compiles
+- Add rc option to ar in Makefile.in for when ./configure not run
+- Add -WI,-rpath,. to LDFLAGS for OSF 1 V4*
+- Set LD_LIBRARYN32_PATH for SGI IRIX shared compile
+- Protect against _FILE_OFFSET_BITS being defined when compiling zlib
+- Rename Makefile.in targets allstatic to static and allshared to shared
+- Fix static and shared Makefile.in targets to be independent
+- Correct error return bug in gz_open() by setting state [Brown]
+- Put spaces before ;;'s in configure for better sh compatibility
+- Add pigz.c (parallel implementation of gzip) to examples/
+- Correct constant in crc32.c to UL [Leventhal]
+- Reject negative lengths in crc32_combine()
+- Add inflateReset2() function to work like inflateEnd()/inflateInit2()
+- Include sys/types.h for _LARGEFILE64_SOURCE [Brown]
+- Correct typo in doc/algorithm.txt [Janik]
+- Fix bug in adler32_combine() [Zhu]
+- Catch missing-end-of-block-code error in all inflates and in puff
+ Assures that random input to inflate eventually results in an error
+- Added enough.c (calculation of ENOUGH for inftrees.h) to examples/
+- Update ENOUGH and its usage to reflect discovered bounds
+- Fix gzerror() error report on empty input file [Brown]
+- Add ush casts in trees.c to avoid pedantic runtime errors
+- Fix typo in zlib.h uncompress() description [Reiss]
+- Correct inflate() comments with regard to automatic header detection
+- Remove deprecation comment on Z_PARTIAL_FLUSH (it stays)
+- Put new version of gzlog (2.0) in examples with interruption recovery
+- Add puff compile option to permit invalid distance-too-far streams
+- Add puff TEST command options, ability to read piped input
+- Prototype the *64 functions in zlib.h when _FILE_OFFSET_BITS == 64, but
+ _LARGEFILE64_SOURCE not defined
+- Fix Z_FULL_FLUSH to truly erase the past by resetting s->strstart
+- Fix deflateSetDictionary() to use all 32K for output consistency
+- Remove extraneous #define MIN_LOOKAHEAD in deflate.c (in deflate.h)
+- Clear bytes after deflate lookahead to avoid use of uninitialized data
+- Change a limit in inftrees.c to be more transparent to Coverity Prevent
+- Update win32/zlib.def with exported symbols from zlib.h
+- Correct spelling errors in zlib.h [Willem, Sobrado]
+- Allow Z_BLOCK for deflate() to force a new block
+- Allow negative bits in inflatePrime() to delete existing bit buffer
+- Add Z_TREES flush option to inflate() to return at end of trees
+- Add inflateMark() to return current state information for random access
+- Add Makefile for NintendoDS to contrib [Costa]
+- Add -w in configure compile tests to avoid spurious warnings [Beucler]
+- Fix typos in zlib.h comments for deflateSetDictionary()
+- Fix EOF detection in transparent gzread() [Maier]
+
+Changes in 1.2.3.3 (2 October 2006)
+- Make --shared the default for configure, add a --static option
+- Add compile option to permit invalid distance-too-far streams
+- Add inflateUndermine() function which is required to enable above
+- Remove use of "this" variable name for C++ compatibility [Marquess]
+- Add testing of shared library in make test, if shared library built
+- Use ftello() and fseeko() if available instead of ftell() and fseek()
+- Provide two versions of all functions that use the z_off_t type for
+ binary compatibility -- a normal version and a 64-bit offset version,
+ per the Large File Support Extension when _LARGEFILE64_SOURCE is
+ defined; use the 64-bit versions by default when _FILE_OFFSET_BITS
+ is defined to be 64
+- Add a --uname= option to configure to perhaps help with cross-compiling
+
+Changes in 1.2.3.2 (3 September 2006)
+- Turn off silly Borland warnings [Hay]
+- Use off64_t and define _LARGEFILE64_SOURCE when present
+- Fix missing dependency on inffixed.h in Makefile.in
+- Rig configure --shared to build both shared and static [Teredesai, Truta]
+- Remove zconf.in.h and instead create a new zlibdefs.h file
+- Fix contrib/minizip/unzip.c non-encrypted after encrypted [Vollant]
+- Add treebuild.xml (see http://treebuild.metux.de/) [Weigelt]
+
+Changes in 1.2.3.1 (16 August 2006)
+- Add watcom directory with OpenWatcom make files [Daniel]
+- Remove #undef of FAR in zconf.in.h for MVS [Fedtke]
+- Update make_vms.com [Zinser]
+- Use -fPIC for shared build in configure [Teredesai, Nicholson]
+- Use only major version number for libz.so on IRIX and OSF1 [Reinholdtsen]
+- Use fdopen() (not _fdopen()) for Interix in zutil.h [Bäck]
+- Add some FAQ entries about the contrib directory
+- Update the MVS question in the FAQ
+- Avoid extraneous reads after EOF in gzio.c [Brown]
+- Correct spelling of "successfully" in gzio.c [Randers-Pehrson]
+- Add comments to zlib.h about gzerror() usage [Brown]
+- Set extra flags in gzip header in gzopen() like deflate() does
+- Make configure options more compatible with double-dash conventions
+ [Weigelt]
+- Clean up compilation under Solaris SunStudio cc [Rowe, Reinholdtsen]
+- Fix uninstall target in Makefile.in [Truta]
+- Add pkgconfig support [Weigelt]
+- Use $(DESTDIR) macro in Makefile.in [Reinholdtsen, Weigelt]
+- Replace set_data_type() with a more accurate detect_data_type() in
+ trees.c, according to the txtvsbin.txt document [Truta]
+- Swap the order of #include <stdio.h> and #include "zlib.h" in
+ gzio.c, example.c and minigzip.c [Truta]
+- Shut up annoying VS2005 warnings about standard C deprecation [Rowe,
+ Truta] (where?)
+- Fix target "clean" from win32/Makefile.bor [Truta]
+- Create .pdb and .manifest files in win32/makefile.msc [Ziegler, Rowe]
+- Update zlib www home address in win32/DLL_FAQ.txt [Truta]
+- Update contrib/masmx86/inffas32.asm for VS2005 [Vollant, Van Wassenhove]
+- Enable browse info in the "Debug" and "ASM Debug" configurations in
+ the Visual C++ 6 project, and set (non-ASM) "Debug" as default [Truta]
+- Add pkgconfig support [Weigelt]
+- Add ZLIB_VER_MAJOR, ZLIB_VER_MINOR and ZLIB_VER_REVISION in zlib.h,
+ for use in win32/zlib1.rc [Polushin, Rowe, Truta]
+- Add a document that explains the new text detection scheme to
+ doc/txtvsbin.txt [Truta]
+- Add rfc1950.txt, rfc1951.txt and rfc1952.txt to doc/ [Truta]
+- Move algorithm.txt into doc/ [Truta]
+- Synchronize FAQ with website
+- Fix compressBound(), was low for some pathological cases [Fearnley]
+- Take into account wrapper variations in deflateBound()
+- Set examples/zpipe.c input and output to binary mode for Windows
+- Update examples/zlib_how.html with new zpipe.c (also web site)
+- Fix some warnings in examples/gzlog.c and examples/zran.c (it seems
+ that gcc became pickier in 4.0)
+- Add zlib.map for Linux: "All symbols from zlib-1.1.4 remain
+ un-versioned, the patch adds versioning only for symbols introduced in
+ zlib-1.2.0 or later. It also declares as local those symbols which are
+ not designed to be exported." [Levin]
+- Update Z_PREFIX list in zconf.in.h, add --zprefix option to configure
+- Do not initialize global static by default in trees.c, add a response
+ NO_INIT_GLOBAL_POINTERS to initialize them if needed [Marquess]
+- Don't use strerror() in gzio.c under WinCE [Yakimov]
+- Don't use errno.h in zutil.h under WinCE [Yakimov]
+- Move arguments for AR to its usage to allow replacing ar [Marot]
+- Add HAVE_VISIBILITY_PRAGMA in zconf.in.h for Mozilla [Randers-Pehrson]
+- Improve inflateInit() and inflateInit2() documentation
+- Fix structure size comment in inflate.h
+- Change configure help option from --h* to --help [Santos]
+
+Changes in 1.2.3 (18 July 2005)
+- Apply security vulnerability fixes to contrib/infback9 as well
+- Clean up some text files (carriage returns, trailing space)
+- Update testzlib, vstudio, masmx64, and masmx86 in contrib [Vollant]
+
+Changes in 1.2.2.4 (11 July 2005)
+- Add inflatePrime() function for starting inflation at bit boundary
+- Avoid some Visual C warnings in deflate.c
+- Avoid more silly Visual C warnings in inflate.c and inftrees.c for 64-bit
+ compile
+- Fix some spelling errors in comments [Betts]
+- Correct inflateInit2() error return documentation in zlib.h
+- Add zran.c example of compressed data random access to examples
+ directory, shows use of inflatePrime()
+- Fix cast for assignments to strm->state in inflate.c and infback.c
+- Fix zlibCompileFlags() in zutil.c to use 1L for long shifts [Oberhumer]
+- Move declarations of gf2 functions to right place in crc32.c [Oberhumer]
+- Add cast in trees.c t avoid a warning [Oberhumer]
+- Avoid some warnings in fitblk.c, gun.c, gzjoin.c in examples [Oberhumer]
+- Update make_vms.com [Zinser]
+- Initialize state->write in inflateReset() since copied in inflate_fast()
+- Be more strict on incomplete code sets in inflate_table() and increase
+ ENOUGH and MAXD -- this repairs a possible security vulnerability for
+ invalid inflate input. Thanks to Tavis Ormandy and Markus Oberhumer for
+ discovering the vulnerability and providing test cases
+- Add ia64 support to configure for HP-UX [Smith]
+- Add error return to gzread() for format or i/o error [Levin]
+- Use malloc.h for OS/2 [Necasek]
+
+Changes in 1.2.2.3 (27 May 2005)
+- Replace 1U constants in inflate.c and inftrees.c for 64-bit compile
+- Typecast fread() return values in gzio.c [Vollant]
+- Remove trailing space in minigzip.c outmode (VC++ can't deal with it)
+- Fix crc check bug in gzread() after gzungetc() [Heiner]
+- Add the deflateTune() function to adjust internal compression parameters
+- Add a fast gzip decompressor, gun.c, to examples (use of inflateBack)
+- Remove an incorrect assertion in examples/zpipe.c
+- Add C++ wrapper in infback9.h [Donais]
+- Fix bug in inflateCopy() when decoding fixed codes
+- Note in zlib.h how much deflateSetDictionary() actually uses
+- Remove USE_DICT_HEAD in deflate.c (would mess up inflate if used)
+- Add _WIN32_WCE to define WIN32 in zconf.in.h [Spencer]
+- Don't include stderr.h or errno.h for _WIN32_WCE in zutil.h [Spencer]
+- Add gzdirect() function to indicate transparent reads
+- Update contrib/minizip [Vollant]
+- Fix compilation of deflate.c when both ASMV and FASTEST [Oberhumer]
+- Add casts in crc32.c to avoid warnings [Oberhumer]
+- Add contrib/masmx64 [Vollant]
+- Update contrib/asm586, asm686, masmx86, testzlib, vstudio [Vollant]
+
+Changes in 1.2.2.2 (30 December 2004)
+- Replace structure assignments in deflate.c and inflate.c with zmemcpy to
+ avoid implicit memcpy calls (portability for no-library compilation)
+- Increase sprintf() buffer size in gzdopen() to allow for large numbers
+- Add INFLATE_STRICT to check distances against zlib header
+- Improve WinCE errno handling and comments [Chang]
+- Remove comment about no gzip header processing in FAQ
+- Add Z_FIXED strategy option to deflateInit2() to force fixed trees
+- Add updated make_vms.com [Coghlan], update README
+- Create a new "examples" directory, move gzappend.c there, add zpipe.c,
+ fitblk.c, gzlog.[ch], gzjoin.c, and zlib_how.html
+- Add FAQ entry and comments in deflate.c on uninitialized memory access
+- Add Solaris 9 make options in configure [Gilbert]
+- Allow strerror() usage in gzio.c for STDC
+- Fix DecompressBuf in contrib/delphi/ZLib.pas [ManChesTer]
+- Update contrib/masmx86/inffas32.asm and gvmat32.asm [Vollant]
+- Use z_off_t for adler32_combine() and crc32_combine() lengths
+- Make adler32() much faster for small len
+- Use OS_CODE in deflate() default gzip header
+
+Changes in 1.2.2.1 (31 October 2004)
+- Allow inflateSetDictionary() call for raw inflate
+- Fix inflate header crc check bug for file names and comments
+- Add deflateSetHeader() and gz_header structure for custom gzip headers
+- Add inflateGetheader() to retrieve gzip headers
+- Add crc32_combine() and adler32_combine() functions
+- Add alloc_func, free_func, in_func, out_func to Z_PREFIX list
+- Use zstreamp consistently in zlib.h (inflate_back functions)
+- Remove GUNZIP condition from definition of inflate_mode in inflate.h
+ and in contrib/inflate86/inffast.S [Truta, Anderson]
+- Add support for AMD64 in contrib/inflate86/inffas86.c [Anderson]
+- Update projects/README.projects and projects/visualc6 [Truta]
+- Update win32/DLL_FAQ.txt [Truta]
+- Avoid warning under NO_GZCOMPRESS in gzio.c; fix typo [Truta]
+- Deprecate Z_ASCII; use Z_TEXT instead [Truta]
+- Use a new algorithm for setting strm->data_type in trees.c [Truta]
+- Do not define an exit() prototype in zutil.c unless DEBUG defined
+- Remove prototype of exit() from zutil.c, example.c, minigzip.c [Truta]
+- Add comment in zlib.h for Z_NO_FLUSH parameter to deflate()
+- Fix Darwin build version identification [Peterson]
+
+Changes in 1.2.2 (3 October 2004)
+- Update zlib.h comments on gzip in-memory processing
+- Set adler to 1 in inflateReset() to support Java test suite [Walles]
+- Add contrib/dotzlib [Ravn]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update contrib/minizip [Vollant]
+- Move contrib/visual-basic.txt to old/ [Truta]
+- Fix assembler builds in projects/visualc6/ [Truta]
+
+Changes in 1.2.1.2 (9 September 2004)
+- Update INDEX file
+- Fix trees.c to update strm->data_type (no one ever noticed!)
+- Fix bug in error case in inflate.c, infback.c, and infback9.c [Brown]
+- Add "volatile" to crc table flag declaration (for DYNAMIC_CRC_TABLE)
+- Add limited multitasking protection to DYNAMIC_CRC_TABLE
+- Add NO_vsnprintf for VMS in zutil.h [Mozilla]
+- Don't declare strerror() under VMS [Mozilla]
+- Add comment to DYNAMIC_CRC_TABLE to use get_crc_table() to initialize
+- Update contrib/ada [Anisimkov]
+- Update contrib/minizip [Vollant]
+- Fix configure to not hardcode directories for Darwin [Peterson]
+- Fix gzio.c to not return error on empty files [Brown]
+- Fix indentation; update version in contrib/delphi/ZLib.pas and
+ contrib/pascal/zlibpas.pas [Truta]
+- Update mkasm.bat in contrib/masmx86 [Truta]
+- Update contrib/untgz [Truta]
+- Add projects/README.projects [Truta]
+- Add project for MS Visual C++ 6.0 in projects/visualc6 [Cadieux, Truta]
+- Update win32/DLL_FAQ.txt [Truta]
+- Update list of Z_PREFIX symbols in zconf.h [Randers-Pehrson, Truta]
+- Remove an unnecessary assignment to curr in inftrees.c [Truta]
+- Add OS/2 to exe builds in configure [Poltorak]
+- Remove err dummy parameter in zlib.h [Kientzle]
+
+Changes in 1.2.1.1 (9 January 2004)
+- Update email address in README
+- Several FAQ updates
+- Fix a big fat bug in inftrees.c that prevented decoding valid
+ dynamic blocks with only literals and no distance codes --
+ Thanks to "Hot Emu" for the bug report and sample file
+- Add a note to puff.c on no distance codes case
+
+Changes in 1.2.1 (17 November 2003)
+- Remove a tab in contrib/gzappend/gzappend.c
+- Update some interfaces in contrib for new zlib functions
+- Update zlib version number in some contrib entries
+- Add Windows CE definition for ptrdiff_t in zutil.h [Mai, Truta]
+- Support shared libraries on Hurd and KFreeBSD [Brown]
+- Fix error in NO_DIVIDE option of adler32.c
+
+Changes in 1.2.0.8 (4 November 2003)
+- Update version in contrib/delphi/ZLib.pas and contrib/pascal/zlibpas.pas
+- Add experimental NO_DIVIDE #define in adler32.c
+ - Possibly faster on some processors (let me know if it is)
+- Correct Z_BLOCK to not return on first inflate call if no wrap
+- Fix strm->data_type on inflate() return to correctly indicate EOB
+- Add deflatePrime() function for appending in the middle of a byte
+- Add contrib/gzappend for an example of appending to a stream
+- Update win32/DLL_FAQ.txt [Truta]
+- Delete Turbo C comment in README [Truta]
+- Improve some indentation in zconf.h [Truta]
+- Fix infinite loop on bad input in configure script [Church]
+- Fix gzeof() for concatenated gzip files [Johnson]
+- Add example to contrib/visual-basic.txt [Michael B.]
+- Add -p to mkdir's in Makefile.in [vda]
+- Fix configure to properly detect presence or lack of printf functions
+- Add AS400 support [Monnerat]
+- Add a little Cygwin support [Wilson]
+
+Changes in 1.2.0.7 (21 September 2003)
+- Correct some debug formats in contrib/infback9
+- Cast a type in a debug statement in trees.c
+- Change search and replace delimiter in configure from % to # [Beebe]
+- Update contrib/untgz to 0.2 with various fixes [Truta]
+- Add build support for Amiga [Nikl]
+- Remove some directories in old that have been updated to 1.2
+- Add dylib building for Mac OS X in configure and Makefile.in
+- Remove old distribution stuff from Makefile
+- Update README to point to DLL_FAQ.txt, and add comment on Mac OS X
+- Update links in README
+
+Changes in 1.2.0.6 (13 September 2003)
+- Minor FAQ updates
+- Update contrib/minizip to 1.00 [Vollant]
+- Remove test of gz functions in example.c when GZ_COMPRESS defined [Truta]
+- Update POSTINC comment for 68060 [Nikl]
+- Add contrib/infback9 with deflate64 decoding (unsupported)
+- For MVS define NO_vsnprintf and undefine FAR [van Burik]
+- Add pragma for fdopen on MVS [van Burik]
+
+Changes in 1.2.0.5 (8 September 2003)
+- Add OF to inflateBackEnd() declaration in zlib.h
+- Remember start when using gzdopen in the middle of a file
+- Use internal off_t counters in gz* functions to properly handle seeks
+- Perform more rigorous check for distance-too-far in inffast.c
+- Add Z_BLOCK flush option to return from inflate at block boundary
+- Set strm->data_type on return from inflate
+ - Indicate bits unused, if at block boundary, and if in last block
+- Replace size_t with ptrdiff_t in crc32.c, and check for correct size
+- Add condition so old NO_DEFLATE define still works for compatibility
+- FAQ update regarding the Windows DLL [Truta]
+- INDEX update: add qnx entry, remove aix entry [Truta]
+- Install zlib.3 into mandir [Wilson]
+- Move contrib/zlib_dll_FAQ.txt to win32/DLL_FAQ.txt; update [Truta]
+- Adapt the zlib interface to the new DLL convention guidelines [Truta]
+- Introduce ZLIB_WINAPI macro to allow the export of functions using
+ the WINAPI calling convention, for Visual Basic [Vollant, Truta]
+- Update msdos and win32 scripts and makefiles [Truta]
+- Export symbols by name, not by ordinal, in win32/zlib.def [Truta]
+- Add contrib/ada [Anisimkov]
+- Move asm files from contrib/vstudio/vc70_32 to contrib/asm386 [Truta]
+- Rename contrib/asm386 to contrib/masmx86 [Truta, Vollant]
+- Add contrib/masm686 [Truta]
+- Fix offsets in contrib/inflate86 and contrib/masmx86/inffas32.asm
+ [Truta, Vollant]
+- Update contrib/delphi; rename to contrib/pascal; add example [Truta]
+- Remove contrib/delphi2; add a new contrib/delphi [Truta]
+- Avoid inclusion of the nonstandard <memory.h> in contrib/iostream,
+ and fix some method prototypes [Truta]
+- Fix the ZCR_SEED2 constant to avoid warnings in contrib/minizip
+ [Truta]
+- Avoid the use of backslash (\) in contrib/minizip [Vollant]
+- Fix file time handling in contrib/untgz; update makefiles [Truta]
+- Update contrib/vstudio/vc70_32 to comply with the new DLL guidelines
+ [Vollant]
+- Remove contrib/vstudio/vc15_16 [Vollant]
+- Rename contrib/vstudio/vc70_32 to contrib/vstudio/vc7 [Truta]
+- Update README.contrib [Truta]
+- Invert the assignment order of match_head and s->prev[...] in
+ INSERT_STRING [Truta]
+- Compare TOO_FAR with 32767 instead of 32768, to avoid 16-bit warnings
+ [Truta]
+- Compare function pointers with 0, not with NULL or Z_NULL [Truta]
+- Fix prototype of syncsearch in inflate.c [Truta]
+- Introduce ASMINF macro to be enabled when using an ASM implementation
+ of inflate_fast [Truta]
+- Change NO_DEFLATE to NO_GZCOMPRESS [Truta]
+- Modify test_gzio in example.c to take a single file name as a
+ parameter [Truta]
+- Exit the example.c program if gzopen fails [Truta]
+- Add type casts around strlen in example.c [Truta]
+- Remove casting to sizeof in minigzip.c; give a proper type
+ to the variable compared with SUFFIX_LEN [Truta]
+- Update definitions of STDC and STDC99 in zconf.h [Truta]
+- Synchronize zconf.h with the new Windows DLL interface [Truta]
+- Use SYS16BIT instead of __32BIT__ to distinguish between
+ 16- and 32-bit platforms [Truta]
+- Use far memory allocators in small 16-bit memory models for
+ Turbo C [Truta]
+- Add info about the use of ASMV, ASMINF and ZLIB_WINAPI in
+ zlibCompileFlags [Truta]
+- Cygwin has vsnprintf [Wilson]
+- In Windows16, OS_CODE is 0, as in MSDOS [Truta]
+- In Cygwin, OS_CODE is 3 (Unix), not 11 (Windows32) [Wilson]
+
+Changes in 1.2.0.4 (10 August 2003)
+- Minor FAQ updates
+- Be more strict when checking inflateInit2's windowBits parameter
+- Change NO_GUNZIP compile option to NO_GZIP to cover deflate as well
+- Add gzip wrapper option to deflateInit2 using windowBits
+- Add updated QNX rule in configure and qnx directory [Bonnefoy]
+- Make inflate distance-too-far checks more rigorous
+- Clean up FAR usage in inflate
+- Add casting to sizeof() in gzio.c and minigzip.c
+
+Changes in 1.2.0.3 (19 July 2003)
+- Fix silly error in gzungetc() implementation [Vollant]
+- Update contrib/minizip and contrib/vstudio [Vollant]
+- Fix printf format in example.c
+- Correct cdecl support in zconf.in.h [Anisimkov]
+- Minor FAQ updates
+
+Changes in 1.2.0.2 (13 July 2003)
+- Add ZLIB_VERNUM in zlib.h for numerical preprocessor comparisons
+- Attempt to avoid warnings in crc32.c for pointer-int conversion
+- Add AIX to configure, remove aix directory [Bakker]
+- Add some casts to minigzip.c
+- Improve checking after insecure sprintf() or vsprintf() calls
+- Remove #elif's from crc32.c
+- Change leave label to inf_leave in inflate.c and infback.c to avoid
+ library conflicts
+- Remove inflate gzip decoding by default--only enable gzip decoding by
+ special request for stricter backward compatibility
+- Add zlibCompileFlags() function to return compilation information
+- More typecasting in deflate.c to avoid warnings
+- Remove leading underscore from _Capital #defines [Truta]
+- Fix configure to link shared library when testing
+- Add some Windows CE target adjustments [Mai]
+- Remove #define ZLIB_DLL in zconf.h [Vollant]
+- Add zlib.3 [Rodgers]
+- Update RFC URL in deflate.c and algorithm.txt [Mai]
+- Add zlib_dll_FAQ.txt to contrib [Truta]
+- Add UL to some constants [Truta]
+- Update minizip and vstudio [Vollant]
+- Remove vestigial NEED_DUMMY_RETURN from zconf.in.h
+- Expand use of NO_DUMMY_DECL to avoid all dummy structures
+- Added iostream3 to contrib [Schwardt]
+- Replace rewind() with fseek() for WinCE [Truta]
+- Improve setting of zlib format compression level flags
+ - Report 0 for huffman and rle strategies and for level == 0 or 1
+ - Report 2 only for level == 6
+- Only deal with 64K limit when necessary at compile time [Truta]
+- Allow TOO_FAR check to be turned off at compile time [Truta]
+- Add gzclearerr() function [Souza]
+- Add gzungetc() function
+
+Changes in 1.2.0.1 (17 March 2003)
+- Add Z_RLE strategy for run-length encoding [Truta]
+ - When Z_RLE requested, restrict matches to distance one
+ - Update zlib.h, minigzip.c, gzopen(), gzdopen() for Z_RLE
+- Correct FASTEST compilation to allow level == 0
+- Clean up what gets compiled for FASTEST
+- Incorporate changes to zconf.in.h [Vollant]
+ - Refine detection of Turbo C need for dummy returns
+ - Refine ZLIB_DLL compilation
+ - Include additional header file on VMS for off_t typedef
+- Try to use _vsnprintf where it supplants vsprintf [Vollant]
+- Add some casts in inffast.c
+- Enhance comments in zlib.h on what happens if gzprintf() tries to
+ write more than 4095 bytes before compression
+- Remove unused state from inflateBackEnd()
+- Remove exit(0) from minigzip.c, example.c
+- Get rid of all those darn tabs
+- Add "check" target to Makefile.in that does the same thing as "test"
+- Add "mostlyclean" and "maintainer-clean" targets to Makefile.in
+- Update contrib/inflate86 [Anderson]
+- Update contrib/testzlib, contrib/vstudio, contrib/minizip [Vollant]
+- Add msdos and win32 directories with makefiles [Truta]
+- More additions and improvements to the FAQ
+
+Changes in 1.2.0 (9 March 2003)
+- New and improved inflate code
+ - About 20% faster
+ - Does not allocate 32K window unless and until needed
+ - Automatically detects and decompresses gzip streams
+ - Raw inflate no longer needs an extra dummy byte at end
+ - Added inflateBack functions using a callback interface--even faster
+ than inflate, useful for file utilities (gzip, zip)
+ - Added inflateCopy() function to record state for random access on
+ externally generated deflate streams (e.g. in gzip files)
+ - More readable code (I hope)
+- New and improved crc32()
+ - About 50% faster, thanks to suggestions from Rodney Brown
+- Add deflateBound() and compressBound() functions
+- Fix memory leak in deflateInit2()
+- Permit setting dictionary for raw deflate (for parallel deflate)
+- Fix const declaration for gzwrite()
+- Check for some malloc() failures in gzio.c
+- Fix bug in gzopen() on single-byte file 0x1f
+- Fix bug in gzread() on concatenated file with 0x1f at end of buffer
+ and next buffer doesn't start with 0x8b
+- Fix uncompress() to return Z_DATA_ERROR on truncated input
+- Free memory at end of example.c
+- Remove MAX #define in trees.c (conflicted with some libraries)
+- Fix static const's in deflate.c, gzio.c, and zutil.[ch]
+- Declare malloc() and free() in gzio.c if STDC not defined
+- Use malloc() instead of calloc() in zutil.c if int big enough
+- Define STDC for AIX
+- Add aix/ with approach for compiling shared library on AIX
+- Add HP-UX support for shared libraries in configure
+- Add OpenUNIX support for shared libraries in configure
+- Use $cc instead of gcc to build shared library
+- Make prefix directory if needed when installing
+- Correct Macintosh avoidance of typedef Byte in zconf.h
+- Correct Turbo C memory allocation when under Linux
+- Use libz.a instead of -lz in Makefile (assure use of compiled library)
+- Update configure to check for snprintf or vsnprintf functions and their
+ return value, warn during make if using an insecure function
+- Fix configure problem with compile-time knowledge of HAVE_UNISTD_H that
+ is lost when library is used--resolution is to build new zconf.h
+- Documentation improvements (in zlib.h):
+ - Document raw deflate and inflate
+ - Update RFCs URL
+ - Point out that zlib and gzip formats are different
+ - Note that Z_BUF_ERROR is not fatal
+ - Document string limit for gzprintf() and possible buffer overflow
+ - Note requirement on avail_out when flushing
+ - Note permitted values of flush parameter of inflate()
+- Add some FAQs (and even answers) to the FAQ
+- Add contrib/inflate86/ for x86 faster inflate
+- Add contrib/blast/ for PKWare Data Compression Library decompression
+- Add contrib/puff/ simple inflate for deflate format description
+
+Changes in 1.1.4 (11 March 2002)
+- ZFREE was repeated on same allocation on some error conditions
+ This creates a security problem described in
+ http://www.zlib.org/advisory-2002-03-11.txt
+- Returned incorrect error (Z_MEM_ERROR) on some invalid data
+- Avoid accesses before window for invalid distances with inflate window
+ less than 32K
+- force windowBits > 8 to avoid a bug in the encoder for a window size
+ of 256 bytes. (A complete fix will be available in 1.1.5)
+
+Changes in 1.1.3 (9 July 1998)
+- fix "an inflate input buffer bug that shows up on rare but persistent
+ occasions" (Mark)
+- fix gzread and gztell for concatenated .gz files (Didier Le Botlan)
+- fix gzseek(..., SEEK_SET) in write mode
+- fix crc check after a gzeek (Frank Faubert)
+- fix miniunzip when the last entry in a zip file is itself a zip file
+ (J Lillge)
+- add contrib/asm586 and contrib/asm686 (Brian Raiter)
+ See http://www.muppetlabs.com/~breadbox/software/assembly.html
+- add support for Delphi 3 in contrib/delphi (Bob Dellaca)
+- add support for C++Builder 3 and Delphi 3 in contrib/delphi2 (Davide Moretti)
+- do not exit prematurely in untgz if 0 at start of block (Magnus Holmgren)
+- use macro EXTERN instead of extern to support DLL for BeOS (Sander Stoks)
+- added a FAQ file
+
+- Support gzdopen on Mac with Metrowerks (Jason Linhart)
+- Do not redefine Byte on Mac (Brad Pettit & Jason Linhart)
+- define SEEK_END too if SEEK_SET is not defined (Albert Chin-A-Young)
+- avoid some warnings with Borland C (Tom Tanner)
+- fix a problem in contrib/minizip/zip.c for 16-bit MSDOS (Gilles Vollant)
+- emulate utime() for WIN32 in contrib/untgz (Gilles Vollant)
+- allow several arguments to configure (Tim Mooney, Frodo Looijaard)
+- use libdir and includedir in Makefile.in (Tim Mooney)
+- support shared libraries on OSF1 V4 (Tim Mooney)
+- remove so_locations in "make clean" (Tim Mooney)
+- fix maketree.c compilation error (Glenn, Mark)
+- Python interface to zlib now in Python 1.5 (Jeremy Hylton)
+- new Makefile.riscos (Rich Walker)
+- initialize static descriptors in trees.c for embedded targets (Nick Smith)
+- use "foo-gz" in example.c for RISCOS and VMS (Nick Smith)
+- add the OS/2 files in Makefile.in too (Andrew Zabolotny)
+- fix fdopen and halloc macros for Microsoft C 6.0 (Tom Lane)
+- fix maketree.c to allow clean compilation of inffixed.h (Mark)
+- fix parameter check in deflateCopy (Gunther Nikl)
+- cleanup trees.c, use compressed_len only in debug mode (Christian Spieler)
+- Many portability patches by Christian Spieler:
+ . zutil.c, zutil.h: added "const" for zmem*
+ . Make_vms.com: fixed some typos
+ . Make_vms.com: msdos/Makefile.*: removed zutil.h from some dependency lists
+ . msdos/Makefile.msc: remove "default rtl link library" info from obj files
+ . msdos/Makefile.*: use model-dependent name for the built zlib library
+ . msdos/Makefile.emx, nt/Makefile.emx, nt/Makefile.gcc:
+ new makefiles, for emx (DOS/OS2), emx&rsxnt and mingw32 (Windows 9x / NT)
+- use define instead of typedef for Bytef also for MSC small/medium (Tom Lane)
+- replace __far with _far for better portability (Christian Spieler, Tom Lane)
+- fix test for errno.h in configure (Tim Newsham)
+
+Changes in 1.1.2 (19 March 98)
+- added contrib/minzip, mini zip and unzip based on zlib (Gilles Vollant)
+ See http://www.winimage.com/zLibDll/unzip.html
+- preinitialize the inflate tables for fixed codes, to make the code
+ completely thread safe (Mark)
+- some simplifications and slight speed-up to the inflate code (Mark)
+- fix gzeof on non-compressed files (Allan Schrum)
+- add -std1 option in configure for OSF1 to fix gzprintf (Martin Mokrejs)
+- use default value of 4K for Z_BUFSIZE for 16-bit MSDOS (Tim Wegner + Glenn)
+- added os2/Makefile.def and os2/zlib.def (Andrew Zabolotny)
+- add shared lib support for UNIX_SV4.2MP (MATSUURA Takanori)
+- do not wrap extern "C" around system includes (Tom Lane)
+- mention zlib binding for TCL in README (Andreas Kupries)
+- added amiga/Makefile.pup for Amiga powerUP SAS/C PPC (Andreas Kleinert)
+- allow "make install prefix=..." even after configure (Glenn Randers-Pehrson)
+- allow "configure --prefix $HOME" (Tim Mooney)
+- remove warnings in example.c and gzio.c (Glenn Randers-Pehrson)
+- move Makefile.sas to amiga/Makefile.sas
+
+Changes in 1.1.1 (27 Feb 98)
+- fix macros _tr_tally_* in deflate.h for debug mode (Glenn Randers-Pehrson)
+- remove block truncation heuristic which had very marginal effect for zlib
+ (smaller lit_bufsize than in gzip 1.2.4) and degraded a little the
+ compression ratio on some files. This also allows inlining _tr_tally for
+ matches in deflate_slow
+- added msdos/Makefile.w32 for WIN32 Microsoft Visual C++ (Bob Frazier)
+
+Changes in 1.1.0 (24 Feb 98)
+- do not return STREAM_END prematurely in inflate (John Bowler)
+- revert to the zlib 1.0.8 inflate to avoid the gcc 2.8.0 bug (Jeremy Buhler)
+- compile with -DFASTEST to get compression code optimized for speed only
+- in minigzip, try mmap'ing the input file first (Miguel Albrecht)
+- increase size of I/O buffers in minigzip.c and gzio.c (not a big gain
+ on Sun but significant on HP)
+
+- add a pointer to experimental unzip library in README (Gilles Vollant)
+- initialize variable gcc in configure (Chris Herborth)
+
+Changes in 1.0.9 (17 Feb 1998)
+- added gzputs and gzgets functions
+- do not clear eof flag in gzseek (Mark Diekhans)
+- fix gzseek for files in transparent mode (Mark Diekhans)
+- do not assume that vsprintf returns the number of bytes written (Jens Krinke)
+- replace EXPORT with ZEXPORT to avoid conflict with other programs
+- added compress2 in zconf.h, zlib.def, zlib.dnt
+- new asm code from Gilles Vollant in contrib/asm386
+- simplify the inflate code (Mark):
+ . Replace ZALLOC's in huft_build() with single ZALLOC in inflate_blocks_new()
+ . ZALLOC the length list in inflate_trees_fixed() instead of using stack
+ . ZALLOC the value area for huft_build() instead of using stack
+ . Simplify Z_FINISH check in inflate()
+
+- Avoid gcc 2.8.0 comparison bug a little differently than zlib 1.0.8
+- in inftrees.c, avoid cc -O bug on HP (Farshid Elahi)
+- in zconf.h move the ZLIB_DLL stuff earlier to avoid problems with
+ the declaration of FAR (Gilles Vollant)
+- install libz.so* with mode 755 (executable) instead of 644 (Marc Lehmann)
+- read_buf buf parameter of type Bytef* instead of charf*
+- zmemcpy parameters are of type Bytef*, not charf* (Joseph Strout)
+- do not redeclare unlink in minigzip.c for WIN32 (John Bowler)
+- fix check for presence of directories in "make install" (Ian Willis)
+
+Changes in 1.0.8 (27 Jan 1998)
+- fixed offsets in contrib/asm386/gvmat32.asm (Gilles Vollant)
+- fix gzgetc and gzputc for big endian systems (Markus Oberhumer)
+- added compress2() to allow setting the compression level
+- include sys/types.h to get off_t on some systems (Marc Lehmann & QingLong)
+- use constant arrays for the static trees in trees.c instead of computing
+ them at run time (thanks to Ken Raeburn for this suggestion). To create
+ trees.h, compile with GEN_TREES_H and run "make test"
+- check return code of example in "make test" and display result
+- pass minigzip command line options to file_compress
+- simplifying code of inflateSync to avoid gcc 2.8 bug
+
+- support CC="gcc -Wall" in configure -s (QingLong)
+- avoid a flush caused by ftell in gzopen for write mode (Ken Raeburn)
+- fix test for shared library support to avoid compiler warnings
+- zlib.lib -> zlib.dll in msdos/zlib.rc (Gilles Vollant)
+- check for TARGET_OS_MAC in addition to MACOS (Brad Pettit)
+- do not use fdopen for Metrowerks on Mac (Brad Pettit))
+- add checks for gzputc and gzputc in example.c
+- avoid warnings in gzio.c and deflate.c (Andreas Kleinert)
+- use const for the CRC table (Ken Raeburn)
+- fixed "make uninstall" for shared libraries
+- use Tracev instead of Trace in infblock.c
+- in example.c use correct compressed length for test_sync
+- suppress +vnocompatwarnings in configure for HPUX (not always supported)
+
+Changes in 1.0.7 (20 Jan 1998)
+- fix gzseek which was broken in write mode
+- return error for gzseek to negative absolute position
+- fix configure for Linux (Chun-Chung Chen)
+- increase stack space for MSC (Tim Wegner)
+- get_crc_table and inflateSyncPoint are EXPORTed (Gilles Vollant)
+- define EXPORTVA for gzprintf (Gilles Vollant)
+- added man page zlib.3 (Rick Rodgers)
+- for contrib/untgz, fix makedir() and improve Makefile
+
+- check gzseek in write mode in example.c
+- allocate extra buffer for seeks only if gzseek is actually called
+- avoid signed/unsigned comparisons (Tim Wegner, Gilles Vollant)
+- add inflateSyncPoint in zconf.h
+- fix list of exported functions in nt/zlib.dnt and mdsos/zlib.def
+
+Changes in 1.0.6 (19 Jan 1998)
+- add functions gzprintf, gzputc, gzgetc, gztell, gzeof, gzseek, gzrewind and
+ gzsetparams (thanks to Roland Giersig and Kevin Ruland for some of this code)
+- Fix a deflate bug occurring only with compression level 0 (thanks to
+ Andy Buckler for finding this one)
+- In minigzip, pass transparently also the first byte for .Z files
+- return Z_BUF_ERROR instead of Z_OK if output buffer full in uncompress()
+- check Z_FINISH in inflate (thanks to Marc Schluper)
+- Implement deflateCopy (thanks to Adam Costello)
+- make static libraries by default in configure, add --shared option
+- move MSDOS or Windows specific files to directory msdos
+- suppress the notion of partial flush to simplify the interface
+ (but the symbol Z_PARTIAL_FLUSH is kept for compatibility with 1.0.4)
+- suppress history buffer provided by application to simplify the interface
+ (this feature was not implemented anyway in 1.0.4)
+- next_in and avail_in must be initialized before calling inflateInit or
+ inflateInit2
+- add EXPORT in all exported functions (for Windows DLL)
+- added Makefile.nt (thanks to Stephen Williams)
+- added the unsupported "contrib" directory:
+ contrib/asm386/ by Gilles Vollant <info@winimage.com>
+ 386 asm code replacing longest_match()
+ contrib/iostream/ by Kevin Ruland <kevin@rodin.wustl.edu>
+ A C++ I/O streams interface to the zlib gz* functions
+ contrib/iostream2/ by Tyge Løvset <Tyge.Lovset@cmr.no>
+ Another C++ I/O streams interface
+ contrib/untgz/ by "Pedro A. Aranda Guti\irrez" <paag@tid.es>
+ A very simple tar.gz file extractor using zlib
+ contrib/visual-basic.txt by Carlos Rios <c_rios@sonda.cl>
+ How to use compress(), uncompress() and the gz* functions from VB
+- pass params -f (filtered data), -h (huffman only), -1 to -9 (compression
+ level) in minigzip (thanks to Tom Lane)
+
+- use const for rommable constants in deflate
+- added test for gzseek and gztell in example.c
+- add undocumented function inflateSyncPoint() (hack for Paul Mackerras)
+- add undocumented function zError to convert error code to string
+ (for Tim Smithers)
+- Allow compilation of gzio with -DNO_DEFLATE to avoid the compression code
+- Use default memcpy for Symantec MSDOS compiler
+- Add EXPORT keyword for check_func (needed for Windows DLL)
+- add current directory to LD_LIBRARY_PATH for "make test"
+- create also a link for libz.so.1
+- added support for FUJITSU UXP/DS (thanks to Toshiaki Nomura)
+- use $(SHAREDLIB) instead of libz.so in Makefile.in (for HPUX)
+- added -soname for Linux in configure (Chun-Chung Chen,
+- assign numbers to the exported functions in zlib.def (for Windows DLL)
+- add advice in zlib.h for best usage of deflateSetDictionary
+- work around compiler bug on Atari (cast Z_NULL in call of s->checkfn)
+- allow compilation with ANSI keywords only enabled for TurboC in large model
+- avoid "versionString"[0] (Borland bug)
+- add NEED_DUMMY_RETURN for Borland
+- use variable z_verbose for tracing in debug mode (L. Peter Deutsch)
+- allow compilation with CC
+- defined STDC for OS/2 (David Charlap)
+- limit external names to 8 chars for MVS (Thomas Lund)
+- in minigzip.c, use static buffers only for 16-bit systems
+- fix suffix check for "minigzip -d foo.gz"
+- do not return an error for the 2nd of two consecutive gzflush() (Felix Lee)
+- use _fdopen instead of fdopen for MSC >= 6.0 (Thomas Fanslau)
+- added makelcc.bat for lcc-win32 (Tom St Denis)
+- in Makefile.dj2, use copy and del instead of install and rm (Frank Donahoe)
+- Avoid expanded $Id$. Use "rcs -kb" or "cvs admin -kb" to avoid Id expansion
+- check for unistd.h in configure (for off_t)
+- remove useless check parameter in inflate_blocks_free
+- avoid useless assignment of s->check to itself in inflate_blocks_new
+- do not flush twice in gzclose (thanks to Ken Raeburn)
+- rename FOPEN as F_OPEN to avoid clash with /usr/include/sys/file.h
+- use NO_ERRNO_H instead of enumeration of operating systems with errno.h
+- work around buggy fclose on pipes for HP/UX
+- support zlib DLL with BORLAND C++ 5.0 (thanks to Glenn Randers-Pehrson)
+- fix configure if CC is already equal to gcc
+
+Changes in 1.0.5 (3 Jan 98)
+- Fix inflate to terminate gracefully when fed corrupted or invalid data
+- Use const for rommable constants in inflate
+- Eliminate memory leaks on error conditions in inflate
+- Removed some vestigial code in inflate
+- Update web address in README
+
+Changes in 1.0.4 (24 Jul 96)
+- In very rare conditions, deflate(s, Z_FINISH) could fail to produce an EOF
+ bit, so the decompressor could decompress all the correct data but went
+ on to attempt decompressing extra garbage data. This affected minigzip too
+- zlibVersion and gzerror return const char* (needed for DLL)
+- port to RISCOS (no fdopen, no multiple dots, no unlink, no fileno)
+- use z_error only for DEBUG (avoid problem with DLLs)
+
+Changes in 1.0.3 (2 Jul 96)
+- use z_streamp instead of z_stream *, which is now a far pointer in MSDOS
+ small and medium models; this makes the library incompatible with previous
+ versions for these models. (No effect in large model or on other systems.)
+- return OK instead of BUF_ERROR if previous deflate call returned with
+ avail_out as zero but there is nothing to do
+- added memcmp for non STDC compilers
+- define NO_DUMMY_DECL for more Mac compilers (.h files merged incorrectly)
+- define __32BIT__ if __386__ or i386 is defined (pb. with Watcom and SCO)
+- better check for 16-bit mode MSC (avoids problem with Symantec)
+
+Changes in 1.0.2 (23 May 96)
+- added Windows DLL support
+- added a function zlibVersion (for the DLL support)
+- fixed declarations using Bytef in infutil.c (pb with MSDOS medium model)
+- Bytef is define's instead of typedef'd only for Borland C
+- avoid reading uninitialized memory in example.c
+- mention in README that the zlib format is now RFC1950
+- updated Makefile.dj2
+- added algorithm.doc
+
+Changes in 1.0.1 (20 May 96) [1.0 skipped to avoid confusion]
+- fix array overlay in deflate.c which sometimes caused bad compressed data
+- fix inflate bug with empty stored block
+- fix MSDOS medium model which was broken in 0.99
+- fix deflateParams() which could generate bad compressed data
+- Bytef is define'd instead of typedef'ed (work around Borland bug)
+- added an INDEX file
+- new makefiles for DJGPP (Makefile.dj2), 32-bit Borland (Makefile.b32),
+ Watcom (Makefile.wat), Amiga SAS/C (Makefile.sas)
+- speed up adler32 for modern machines without auto-increment
+- added -ansi for IRIX in configure
+- static_init_done in trees.c is an int
+- define unlink as delete for VMS
+- fix configure for QNX
+- add configure branch for SCO and HPUX
+- avoid many warnings (unused variables, dead assignments, etc...)
+- no fdopen for BeOS
+- fix the Watcom fix for 32 bit mode (define FAR as empty)
+- removed redefinition of Byte for MKWERKS
+- work around an MWKERKS bug (incorrect merge of all .h files)
+
+Changes in 0.99 (27 Jan 96)
+- allow preset dictionary shared between compressor and decompressor
+- allow compression level 0 (no compression)
+- add deflateParams in zlib.h: allow dynamic change of compression level
+ and compression strategy
+- test large buffers and deflateParams in example.c
+- add optional "configure" to build zlib as a shared library
+- suppress Makefile.qnx, use configure instead
+- fixed deflate for 64-bit systems (detected on Cray)
+- fixed inflate_blocks for 64-bit systems (detected on Alpha)
+- declare Z_DEFLATED in zlib.h (possible parameter for deflateInit2)
+- always return Z_BUF_ERROR when deflate() has nothing to do
+- deflateInit and inflateInit are now macros to allow version checking
+- prefix all global functions and types with z_ with -DZ_PREFIX
+- make falloc completely reentrant (inftrees.c)
+- fixed very unlikely race condition in ct_static_init
+- free in reverse order of allocation to help memory manager
+- use zlib-1.0/* instead of zlib/* inside the tar.gz
+- make zlib warning-free with "gcc -O3 -Wall -Wwrite-strings -Wpointer-arith
+ -Wconversion -Wstrict-prototypes -Wmissing-prototypes"
+- allow gzread on concatenated .gz files
+- deflateEnd now returns Z_DATA_ERROR if it was premature
+- deflate is finally (?) fully deterministic (no matches beyond end of input)
+- Document Z_SYNC_FLUSH
+- add uninstall in Makefile
+- Check for __cpluplus in zlib.h
+- Better test in ct_align for partial flush
+- avoid harmless warnings for Borland C++
+- initialize hash_head in deflate.c
+- avoid warning on fdopen (gzio.c) for HP cc -Aa
+- include stdlib.h for STDC compilers
+- include errno.h for Cray
+- ignore error if ranlib doesn't exist
+- call ranlib twice for NeXTSTEP
+- use exec_prefix instead of prefix for libz.a
+- renamed ct_* as _tr_* to avoid conflict with applications
+- clear z->msg in inflateInit2 before any error return
+- initialize opaque in example.c, gzio.c, deflate.c and inflate.c
+- fixed typo in zconf.h (_GNUC__ => __GNUC__)
+- check for WIN32 in zconf.h and zutil.c (avoid farmalloc in 32-bit mode)
+- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
+- in fcalloc, normalize pointer if size > 65520 bytes
+- don't use special fcalloc for 32 bit Borland C++
+- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
+- use Z_BINARY instead of BINARY
+- document that gzclose after gzdopen will close the file
+- allow "a" as mode in gzopen
+- fix error checking in gzread
+- allow skipping .gz extra-field on pipes
+- added reference to Perl interface in README
+- put the crc table in FAR data (I dislike more and more the medium model :)
+- added get_crc_table
+- added a dimension to all arrays (Borland C can't count)
+- workaround Borland C bug in declaration of inflate_codes_new & inflate_fast
+- guard against multiple inclusion of *.h (for precompiled header on Mac)
+- Watcom C pretends to be Microsoft C small model even in 32 bit mode
+- don't use unsized arrays to avoid silly warnings by Visual C++:
+ warning C4746: 'inflate_mask' : unsized array treated as '__far'
+ (what's wrong with far data in far model?)
+- define enum out of inflate_blocks_state to allow compilation with C++
+
+Changes in 0.95 (16 Aug 95)
+- fix MSDOS small and medium model (now easier to adapt to any compiler)
+- inlined send_bits
+- fix the final (:-) bug for deflate with flush (output was correct but
+ not completely flushed in rare occasions)
+- default window size is same for compression and decompression
+ (it's now sufficient to set MAX_WBITS in zconf.h)
+- voidp -> voidpf and voidnp -> voidp (for consistency with other
+ typedefs and because voidnp was not near in large model)
+
+Changes in 0.94 (13 Aug 95)
+- support MSDOS medium model
+- fix deflate with flush (could sometimes generate bad output)
+- fix deflateReset (zlib header was incorrectly suppressed)
+- added support for VMS
+- allow a compression level in gzopen()
+- gzflush now calls fflush
+- For deflate with flush, flush even if no more input is provided
+- rename libgz.a as libz.a
+- avoid complex expression in infcodes.c triggering Turbo C bug
+- work around a problem with gcc on Alpha (in INSERT_STRING)
+- don't use inline functions (problem with some gcc versions)
+- allow renaming of Byte, uInt, etc... with #define
+- avoid warning about (unused) pointer before start of array in deflate.c
+- avoid various warnings in gzio.c, example.c, infblock.c, adler32.c, zutil.c
+- avoid reserved word 'new' in trees.c
+
+Changes in 0.93 (25 June 95)
+- temporarily disable inline functions
+- make deflate deterministic
+- give enough lookahead for PARTIAL_FLUSH
+- Set binary mode for stdin/stdout in minigzip.c for OS/2
+- don't even use signed char in inflate (not portable enough)
+- fix inflate memory leak for segmented architectures
+
+Changes in 0.92 (3 May 95)
+- don't assume that char is signed (problem on SGI)
+- Clear bit buffer when starting a stored block
+- no memcpy on Pyramid
+- suppressed inftest.c
+- optimized fill_window, put longest_match inline for gcc
+- optimized inflate on stored blocks
+- untabify all sources to simplify patches
+
+Changes in 0.91 (2 May 95)
+- Default MEM_LEVEL is 8 (not 9 for Unix) as documented in zlib.h
+- Document the memory requirements in zconf.h
+- added "make install"
+- fix sync search logic in inflateSync
+- deflate(Z_FULL_FLUSH) now works even if output buffer too short
+- after inflateSync, don't scare people with just "lo world"
+- added support for DJGPP
+
+Changes in 0.9 (1 May 95)
+- don't assume that zalloc clears the allocated memory (the TurboC bug
+ was Mark's bug after all :)
+- let again gzread copy uncompressed data unchanged (was working in 0.71)
+- deflate(Z_FULL_FLUSH), inflateReset and inflateSync are now fully implemented
+- added a test of inflateSync in example.c
+- moved MAX_WBITS to zconf.h because users might want to change that
+- document explicitly that zalloc(64K) on MSDOS must return a normalized
+ pointer (zero offset)
+- added Makefiles for Microsoft C, Turbo C, Borland C++
+- faster crc32()
+
+Changes in 0.8 (29 April 95)
+- added fast inflate (inffast.c)
+- deflate(Z_FINISH) now returns Z_STREAM_END when done. Warning: this
+ is incompatible with previous versions of zlib which returned Z_OK
+- work around a TurboC compiler bug (bad code for b << 0, see infutil.h)
+ (actually that was not a compiler bug, see 0.81 above)
+- gzread no longer reads one extra byte in certain cases
+- In gzio destroy(), don't reference a freed structure
+- avoid many warnings for MSDOS
+- avoid the ERROR symbol which is used by MS Windows
+
+Changes in 0.71 (14 April 95)
+- Fixed more MSDOS compilation problems :( There is still a bug with
+ TurboC large model
+
+Changes in 0.7 (14 April 95)
+- Added full inflate support
+- Simplified the crc32() interface. The pre- and post-conditioning
+ (one's complement) is now done inside crc32(). WARNING: this is
+ incompatible with previous versions; see zlib.h for the new usage
+
+Changes in 0.61 (12 April 95)
+- workaround for a bug in TurboC. example and minigzip now work on MSDOS
+
+Changes in 0.6 (11 April 95)
+- added minigzip.c
+- added gzdopen to reopen a file descriptor as gzFile
+- added transparent reading of non-gziped files in gzread
+- fixed bug in gzread (don't read crc as data)
+- fixed bug in destroy (gzio.c) (don't return Z_STREAM_END for gzclose)
+- don't allocate big arrays in the stack (for MSDOS)
+- fix some MSDOS compilation problems
+
+Changes in 0.5:
+- do real compression in deflate.c. Z_PARTIAL_FLUSH is supported but
+ not yet Z_FULL_FLUSH
+- support decompression but only in a single step (forced Z_FINISH)
+- added opaque object for zalloc and zfree
+- added deflateReset and inflateReset
+- added a variable zlib_version for consistency checking
+- renamed the 'filter' parameter of deflateInit2 as 'strategy'
+ Added Z_FILTERED and Z_HUFFMAN_ONLY constants
+
+Changes in 0.4:
+- avoid "zip" everywhere, use zlib instead of ziplib
+- suppress Z_BLOCK_FLUSH, interpret Z_PARTIAL_FLUSH as block flush
+ if compression method == 8
+- added adler32 and crc32
+- renamed deflateOptions as deflateInit2, call one or the other but not both
+- added the method parameter for deflateInit2
+- added inflateInit2
+- simplified considerably deflateInit and inflateInit by not supporting
+ user-provided history buffer. This is supported only in deflateInit2
+ and inflateInit2
+
+Changes in 0.3:
+- prefix all macro names with Z_
+- use Z_FINISH instead of deflateEnd to finish compression
+- added Z_HUFFMAN_ONLY
+- added gzerror()
diff --git a/src/Common/zlib/README b/src/Common/zlib/README
index e02fc5aa..c5f91754 100644
--- a/src/Common/zlib/README
+++ b/src/Common/zlib/README
@@ -1,8 +1,8 @@
ZLIB DATA COMPRESSION LIBRARY
-zlib 1.3 is a general purpose data compression library. All the code is
+zlib 1.3.1 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
rfc1952 (gzip format).
@@ -29,11 +29,11 @@ PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://marknelson.us/posts/1997/01/01/zlib-engine.html .
-The changes made in version 1.3 are documented in the file ChangeLog.
+The changes made in version 1.3.1 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
zlib is available in Java using the java.util.zip package. Follow the API
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
@@ -81,11 +81,11 @@ Acknowledgments:
people who reported problems and suggested various improvements in zlib; they
are too numerous to cite here.
Copyright notice:
- (C) 1995-2023 Jean-loup Gailly and Mark Adler
+ (C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
diff --git a/src/Common/zlib/deflate.c b/src/Common/zlib/deflate.c
index bd011751..012ea814 100644
--- a/src/Common/zlib/deflate.c
+++ b/src/Common/zlib/deflate.c
@@ -1,7 +1,7 @@
/* deflate.c -- compress data using the deflation algorithm
- * Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
+ * Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
* ALGORITHM
@@ -50,11 +50,11 @@
/* @(#) $Id$ */
#include "deflate.h"
const char deflate_copyright[] =
- " deflate 1.3 Copyright 1995-2023 Jean-loup Gailly and Mark Adler ";
+ " deflate 1.3.1 Copyright 1995-2024 Jean-loup Gailly and Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
include such an acknowledgment, I would appreciate that you keep this
copyright string in the executable of your product.
@@ -491,22 +491,28 @@ int ZEXPORT deflateInit2_(z_streamp strm, int level, int method,
* Therefore its average symbol length is assured to be less than 31. So
* the compressed data for a dynamic block also cannot overwrite the
* symbols from which it is being constructed.
*/
- s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, 4);
+ s->pending_buf = (uchf *) ZALLOC(strm, s->lit_bufsize, LIT_BUFS);
s->pending_buf_size = (ulg)s->lit_bufsize * 4;
if (s->window == Z_NULL || s->prev == Z_NULL || s->head == Z_NULL ||
s->pending_buf == Z_NULL) {
s->status = FINISH_STATE;
strm->msg = ERR_MSG(Z_MEM_ERROR);
deflateEnd (strm);
return Z_MEM_ERROR;
}
+#ifdef LIT_MEM
+ s->d_buf = (ushf *)(s->pending_buf + (s->lit_bufsize << 1));
+ s->l_buf = s->pending_buf + (s->lit_bufsize << 2);
+ s->sym_end = s->lit_bufsize - 1;
+#else
s->sym_buf = s->pending_buf + s->lit_bufsize;
s->sym_end = (s->lit_bufsize - 1) * 3;
+#endif
/* We avoid equality with lit_bufsize*3 because of wraparound at 64K
* on 16 bit machines and because stored blocks are restricted to
* 64K-1 bytes.
*/
@@ -718,13 +724,19 @@ int ZEXPORT deflatePrime(z_streamp strm, int bits, int value) {
deflate_state *s;
int put;
if (deflateStateCheck(strm)) return Z_STREAM_ERROR;
s = strm->state;
+#ifdef LIT_MEM
+ if (bits < 0 || bits > 16 ||
+ (uchf *)s->d_buf < s->pending_out + ((Buf_size + 7) >> 3))
+ return Z_BUF_ERROR;
+#else
if (bits < 0 || bits > 16 ||
s->sym_buf < s->pending_out + ((Buf_size + 7) >> 3))
return Z_BUF_ERROR;
+#endif
do {
put = Buf_size - s->bi_valid;
if (put > bits)
put = bits;
s->bi_buf |= (ush)((value & ((1 << put) - 1)) << s->bi_valid);
@@ -1292,25 +1304,30 @@ int ZEXPORT deflateCopy(z_streamp dest, z_streamp source) {
ds->strm = dest;
ds->window = (Bytef *) ZALLOC(dest, ds->w_size, 2*sizeof(Byte));
ds->prev = (Posf *) ZALLOC(dest, ds->w_size, sizeof(Pos));
ds->head = (Posf *) ZALLOC(dest, ds->hash_size, sizeof(Pos));
- ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, 4);
+ ds->pending_buf = (uchf *) ZALLOC(dest, ds->lit_bufsize, LIT_BUFS);
if (ds->window == Z_NULL || ds->prev == Z_NULL || ds->head == Z_NULL ||
ds->pending_buf == Z_NULL) {
deflateEnd (dest);
return Z_MEM_ERROR;
}
/* following zmemcpy do not work for 16-bit MSDOS */
zmemcpy(ds->window, ss->window, ds->w_size * 2 * sizeof(Byte));
zmemcpy((voidpf)ds->prev, (voidpf)ss->prev, ds->w_size * sizeof(Pos));
zmemcpy((voidpf)ds->head, (voidpf)ss->head, ds->hash_size * sizeof(Pos));
- zmemcpy(ds->pending_buf, ss->pending_buf, (uInt)ds->pending_buf_size);
+ zmemcpy(ds->pending_buf, ss->pending_buf, ds->lit_bufsize * LIT_BUFS);
ds->pending_out = ds->pending_buf + (ss->pending_out - ss->pending_buf);
+#ifdef LIT_MEM
+ ds->d_buf = (ushf *)(ds->pending_buf + (ds->lit_bufsize << 1));
+ ds->l_buf = ds->pending_buf + (ds->lit_bufsize << 2);
+#else
ds->sym_buf = ds->pending_buf + ds->lit_bufsize;
+#endif
ds->l_desc.dyn_tree = ds->dyn_ltree;
ds->d_desc.dyn_tree = ds->dyn_dtree;
ds->bl_desc.dyn_tree = ds->bl_tree;
@@ -1537,17 +1554,25 @@ local uInt longest_match(deflate_state *s, IPos cur_match) {
/* ===========================================================================
* Check that the match at match_start is indeed a match.
*/
local void check_match(deflate_state *s, IPos start, IPos match, int length) {
/* check that the match is indeed a match */
- if (zmemcmp(s->window + match,
- s->window + start, length) != EQUAL) {
- fprintf(stderr, " start %u, match %u, length %d\n",
- start, match, length);
+ Bytef *back = s->window + (int)match, *here = s->window + start;
+ IPos len = length;
+ if (match == (IPos)-1) {
+ /* match starts one byte before the current window -- just compare the
+ subsequent length-1 bytes */
+ back++;
+ here++;
+ len--;
+ }
+ if (zmemcmp(back, here, len) != EQUAL) {
+ fprintf(stderr, " start %u, match %d, length %d\n",
+ start, (int)match, length);
do {
- fprintf(stderr, "%c%c", s->window[match++], s->window[start++]);
- } while (--length != 0);
+ fprintf(stderr, "(%02x %02x)", *back++, *here++);
+ } while (--len != 0);
z_error("invalid match");
}
if (z_verbose > 1) {
fprintf(stderr,"\\[%d,%d]", start - match, length);
do { putc(s->window[start++], stderr); } while (--length != 0);
diff --git a/src/Common/zlib/deflate.h b/src/Common/zlib/deflate.h
index 86967914..300c6ada 100644
--- a/src/Common/zlib/deflate.h
+++ b/src/Common/zlib/deflate.h
@@ -1,7 +1,7 @@
/* deflate.h -- internal compression state
- * Copyright (C) 1995-2018 Jean-loup Gailly
+ * Copyright (C) 1995-2024 Jean-loup Gailly
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
@@ -21,10 +21,14 @@
should be left enabled. */
#ifndef NO_GZIP
# define GZIP
#endif
+/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
+ the cost of a larger memory footprint */
+/* #define LIT_MEM */
+
/* ===========================================================================
* Internal compression state.
*/
#define LENGTH_CODES 29
@@ -215,11 +219,18 @@ typedef struct internal_state {
uch depth[2*L_CODES+1];
/* Depth of each subtree used as tie breaker for trees of equal frequency
*/
+#ifdef LIT_MEM
+# define LIT_BUFS 5
+ ushf *d_buf; /* buffer for distances */
+ uchf *l_buf; /* buffer for literals/lengths */
+#else
+# define LIT_BUFS 4
uchf *sym_buf; /* buffer for distances and literals/lengths */
+#endif
uInt lit_bufsize;
/* Size of match buffer for literals/lengths. There are 4 reasons for
* limiting lit_bufsize to 64K:
* - frequencies can be kept in 16 bit counters
@@ -237,11 +248,11 @@ typedef struct internal_state {
* fast adaptation but have of course the overhead of transmitting
* trees more frequently.
* - I can't count above 4
*/
- uInt sym_next; /* running index in sym_buf */
+ uInt sym_next; /* running index in symbol buffer */
uInt sym_end; /* symbol table full when sym_next reaches this */
ulg opt_len; /* bit length of current block with optimal trees */
ulg static_len; /* bit length of current block with static trees */
uInt matches; /* number of string matches in current block */
@@ -316,10 +327,29 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
#else
extern const uch ZLIB_INTERNAL _length_code[];
extern const uch ZLIB_INTERNAL _dist_code[];
#endif
+#ifdef LIT_MEM
+# define _tr_tally_lit(s, c, flush) \
+ { uch cc = (c); \
+ s->d_buf[s->sym_next] = 0; \
+ s->l_buf[s->sym_next++] = cc; \
+ s->dyn_ltree[cc].Freq++; \
+ flush = (s->sym_next == s->sym_end); \
+ }
+# define _tr_tally_dist(s, distance, length, flush) \
+ { uch len = (uch)(length); \
+ ush dist = (ush)(distance); \
+ s->d_buf[s->sym_next] = dist; \
+ s->l_buf[s->sym_next++] = len; \
+ dist--; \
+ s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
+ s->dyn_dtree[d_code(dist)].Freq++; \
+ flush = (s->sym_next == s->sym_end); \
+ }
+#else
# define _tr_tally_lit(s, c, flush) \
{ uch cc = (c); \
s->sym_buf[s->sym_next++] = 0; \
s->sym_buf[s->sym_next++] = 0; \
s->sym_buf[s->sym_next++] = cc; \
@@ -335,10 +365,11 @@ void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
dist--; \
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
s->dyn_dtree[d_code(dist)].Freq++; \
flush = (s->sym_next == s->sym_end); \
}
+#endif
#else
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
# define _tr_tally_dist(s, distance, length, flush) \
flush = _tr_tally(s, distance, length)
#endif
diff --git a/src/Common/zlib/gzguts.h b/src/Common/zlib/gzguts.h
index f9375047..eba72085 100644
--- a/src/Common/zlib/gzguts.h
+++ b/src/Common/zlib/gzguts.h
@@ -1,7 +1,7 @@
/* gzguts.h -- zlib internal header definitions for gz* operations
- * Copyright (C) 2004-2019 Mark Adler
+ * Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#ifdef _LARGEFILE64_SOURCE
# ifndef _LARGEFILE_SOURCE
@@ -208,11 +208,7 @@ char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
#endif
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
value -- needed when comparing unsigned to z_off64_t, which is signed
(possible z_off64_t types off_t, off64_t, and long are all signed) */
-#ifdef INT_MAX
-# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
-#else
unsigned ZLIB_INTERNAL gz_intmax(void);
-# define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
-#endif
+#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
diff --git a/src/Common/zlib/gzlib.c b/src/Common/zlib/gzlib.c
index 29fc4486..983153cc 100644
--- a/src/Common/zlib/gzlib.c
+++ b/src/Common/zlib/gzlib.c
@@ -1,7 +1,7 @@
/* gzlib.c -- zlib functions common to reading and writing gzip files
- * Copyright (C) 2004-2019 Mark Adler
+ * Copyright (C) 2004-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "gzguts.h"
@@ -561,22 +561,22 @@ void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
strcat(state->msg, ": ");
strcat(state->msg, msg);
#endif
}
-#ifndef INT_MAX
/* portably return maximum value for an int (when limits.h presumed not
available) -- we need to do this to cover cases where 2's complement not
used, since C standard permits 1's complement and sign-bit representations,
otherwise we could just use ((unsigned)-1) >> 1 */
unsigned ZLIB_INTERNAL gz_intmax(void) {
- unsigned p, q;
-
- p = 1;
+#ifdef INT_MAX
+ return INT_MAX;
+#else
+ unsigned p = 1, q;
do {
q = p;
p <<= 1;
p++;
} while (p > q);
return q >> 1;
-}
#endif
+}
diff --git a/src/Common/zlib/inflate.c b/src/Common/zlib/inflate.c
index b0757a9b..94ecff01 100644
--- a/src/Common/zlib/inflate.c
+++ b/src/Common/zlib/inflate.c
@@ -1385,11 +1385,11 @@ int ZEXPORT inflateSync(z_streamp strm) {
if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
/* if first time, start search in bit buffer */
if (state->mode != SYNC) {
state->mode = SYNC;
- state->hold <<= state->bits & 7;
+ state->hold >>= state->bits & 7;
state->bits -= state->bits & 7;
len = 0;
while (state->bits >= 8) {
buf[len++] = (unsigned char)(state->hold);
state->hold >>= 8;
diff --git a/src/Common/zlib/inftrees.c b/src/Common/zlib/inftrees.c
index 8a208c2d..98cfe164 100644
--- a/src/Common/zlib/inftrees.c
+++ b/src/Common/zlib/inftrees.c
@@ -1,17 +1,17 @@
/* inftrees.c -- generate Huffman trees for efficient decoding
- * Copyright (C) 1995-2023 Mark Adler
+ * Copyright (C) 1995-2024 Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
#include "zutil.h"
#include "inftrees.h"
#define MAXBITS 15
const char inflate_copyright[] =
- " inflate 1.3 Copyright 1995-2023 Mark Adler ";
+ " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
/*
If you use the zlib library in a product, an acknowledgment is welcome
in the documentation of your product. If for some reason you cannot
include such an acknowledgment, I would appreciate that you keep this
copyright string in the executable of your product.
@@ -55,11 +55,11 @@ int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 198, 203};
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
8193, 12289, 16385, 24577, 0, 0};
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
diff --git a/src/Common/zlib/inftrees.h b/src/Common/zlib/inftrees.h
index a10712d8..396f74b5 100644
--- a/src/Common/zlib/inftrees.h
+++ b/src/Common/zlib/inftrees.h
@@ -39,12 +39,12 @@ typedef struct {
1444, which is the sum of 852 for literal/length codes and 592 for distance
codes. These values were found by exhaustive searches using the program
examples/enough.c found in the zlib distribution. The arguments to that
program are the number of symbols, the initial root table size, and the
maximum bit length of a code. "enough 286 9 15" for literal/length codes
- returns returns 852, and "enough 30 6 15" for distance codes returns 592.
- The initial root table size (9 or 6) is found in the fifth argument of the
+ returns 852, and "enough 30 6 15" for distance codes returns 592. The
+ initial root table size (9 or 6) is found in the fifth argument of the
inflate_table() calls in inflate.c and infback.c. If the root table size is
changed, then these maximum sizes would be need to be recalculated and
updated. */
#define ENOUGH_LENS 852
#define ENOUGH_DISTS 592
diff --git a/src/Common/zlib/trees.c b/src/Common/zlib/trees.c
index 8dbdc40b..6a523ef3 100644
--- a/src/Common/zlib/trees.c
+++ b/src/Common/zlib/trees.c
@@ -1,7 +1,7 @@
/* trees.c -- output deflated data using Huffman coding
- * Copyright (C) 1995-2021 Jean-loup Gailly
+ * Copyright (C) 1995-2024 Jean-loup Gailly
* detect_data_type() function provided freely by Cosmin Truta, 2006
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/*
@@ -897,18 +897,23 @@ void ZLIB_INTERNAL _tr_align(deflate_state *s) {
*/
local void compress_block(deflate_state *s, const ct_data *ltree,
const ct_data *dtree) {
unsigned dist; /* distance of matched string */
int lc; /* match length or unmatched char (if dist == 0) */
- unsigned sx = 0; /* running index in sym_buf */
+ unsigned sx = 0; /* running index in symbol buffers */
unsigned code; /* the code to send */
int extra; /* number of extra bits to send */
if (s->sym_next != 0) do {
+#ifdef LIT_MEM
+ dist = s->d_buf[sx];
+ lc = s->l_buf[sx++];
+#else
dist = s->sym_buf[sx++] & 0xff;
dist += (unsigned)(s->sym_buf[sx++] & 0xff) << 8;
lc = s->sym_buf[sx++];
+#endif
if (dist == 0) {
send_code(s, lc, ltree); /* send a literal byte */
Tracecv(isgraph(lc), (stderr," '%c' ", lc));
} else {
/* Here, lc is the match length - MIN_MATCH */
@@ -929,12 +934,16 @@ local void compress_block(deflate_state *s, const ct_data *ltree,
dist -= (unsigned)base_dist[code];
send_bits(s, dist, extra); /* send the extra distance bits */
}
} /* literal or match pair ? */
- /* Check that the overlay between pending_buf and sym_buf is ok: */
+ /* Check for no overlay of pending_buf on needed symbols */
+#ifdef LIT_MEM
+ Assert(s->pending < 2 * (s->lit_bufsize + sx), "pendingBuf overflow");
+#else
Assert(s->pending < s->lit_bufsize + sx, "pendingBuf overflow");
+#endif
} while (sx < s->sym_next);
send_code(s, END_BLOCK, ltree);
}
@@ -1080,13 +1089,18 @@ void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
/* ===========================================================================
* Save the match info and tally the frequency counts. Return true if
* the current block must be flushed.
*/
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc) {
+#ifdef LIT_MEM
+ s->d_buf[s->sym_next] = (ush)dist;
+ s->l_buf[s->sym_next++] = (uch)lc;
+#else
s->sym_buf[s->sym_next++] = (uch)dist;
s->sym_buf[s->sym_next++] = (uch)(dist >> 8);
s->sym_buf[s->sym_next++] = (uch)lc;
+#endif
if (dist == 0) {
/* lc is the unmatched char */
s->dyn_ltree[lc].Freq++;
} else {
s->matches++;
diff --git a/src/Common/zlib/zconf.h b/src/Common/zlib/zconf.h
index fb76ffe3..62adc8d8 100644
--- a/src/Common/zlib/zconf.h
+++ b/src/Common/zlib/zconf.h
@@ -1,7 +1,7 @@
/* zconf.h -- configuration of the zlib compression library
- * Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* @(#) $Id$ */
@@ -298,18 +298,10 @@
# else
# define OF(args) ()
# endif
#endif
-#ifndef Z_ARG /* function prototypes for stdarg */
-# if defined(STDC) || defined(Z_HAVE_STDARG_H)
-# define Z_ARG(args) args
-# else
-# define Z_ARG(args) ()
-# endif
-#endif
-
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
* just define FAR to be empty.
diff --git a/src/Common/zlib/zlib.h b/src/Common/zlib/zlib.h
index 6b7244f9..8d4b932e 100644
--- a/src/Common/zlib/zlib.h
+++ b/src/Common/zlib/zlib.h
@@ -1,9 +1,9 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
- version 1.3, August 18th, 2023
+ version 1.3.1, January 22nd, 2024
- Copyright (C) 1995-2023 Jean-loup Gailly and Mark Adler
+ Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
@@ -35,15 +35,15 @@
#ifdef __cplusplus
extern "C" {
#endif
-#define ZLIB_VERSION "1.3"
-#define ZLIB_VERNUM 0x1300
+#define ZLIB_VERSION "1.3.1"
+#define ZLIB_VERNUM 0x1310
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 3
-#define ZLIB_VER_REVISION 0
+#define ZLIB_VER_REVISION 1
#define ZLIB_VER_SUBREVISION 0
/*
The 'zlib' compression library provides in-memory compression and
decompression functions, including integrity checks of the uncompressed data.
@@ -934,14 +934,14 @@ ZEXTERN int ZEXPORT inflateSync(z_streamp strm);
pattern are full flush points.
inflateSync returns Z_OK if a possible full flush point has been found,
Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
- In the success case, the application may save the current current value of
- total_in which indicates where valid compressed data was found. In the
- error case, the application may repeatedly call inflateSync, providing more
- input each time, until success or end of the input data.
+ In the success case, the application may save the current value of total_in
+ which indicates where valid compressed data was found. In the error case,
+ the application may repeatedly call inflateSync, providing more input each
+ time, until success or end of the input data.
*/
ZEXTERN int ZEXPORT inflateCopy(z_streamp dest,
z_streamp source);
/*
@@ -1756,18 +1756,18 @@ ZEXTERN uLong ZEXPORT crc32_combine(uLong crc1, uLong crc2, z_off_t len2);
Combine two CRC-32 check values into one. For two sequences of bytes,
seq1 and seq2 with lengths len1 and len2, CRC-32 check values were
calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32
check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and
- len2.
+ len2. len2 must be non-negative.
*/
/*
ZEXTERN uLong ZEXPORT crc32_combine_gen(z_off_t len2);
Return the operator corresponding to length len2, to be used with
- crc32_combine_op().
+ crc32_combine_op(). len2 must be non-negative.
*/
ZEXTERN uLong ZEXPORT crc32_combine_op(uLong crc1, uLong crc2, uLong op);
/*
Give the same result as crc32_combine(), using op in place of len2. op is
diff --git a/src/Common/zlib/zutil.h b/src/Common/zlib/zutil.h
index 902a304c..48dd7feb 100644
--- a/src/Common/zlib/zutil.h
+++ b/src/Common/zlib/zutil.h
@@ -1,7 +1,7 @@
/* zutil.h -- internal interface and configuration of the compression library
- * Copyright (C) 1995-2022 Jean-loup Gailly, Mark Adler
+ * Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
/* WARNING: this file should *not* be used by applications. It is
part of the implementation of the compression library and is
@@ -54,11 +54,11 @@ typedef unsigned long ulg;
#endif
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
-#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
+#define ERR_MSG(err) z_errmsg[(err) < -6 || (err) > 2 ? 9 : 2 - (err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
@@ -135,21 +135,12 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h>
# endif
#endif
-#if defined(MACOS) || defined(TARGET_OS_MAC)
+#if defined(MACOS)
# define OS_CODE 7
-# ifndef Z_SOLO
-# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
-# include <unix.h> /* for fdopen */
-# else
-# ifndef fdopen
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# endif
-# endif
-# endif
#endif
#ifdef __acorn
# define OS_CODE 13
#endif
@@ -168,22 +159,10 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef __APPLE__
# define OS_CODE 19
#endif
-#if defined(_BEOS_) || defined(RISCOS)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-#endif
-
-#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
-# if defined(_WIN32_WCE)
-# define fdopen(fd,mode) NULL /* No fdopen() */
-# else
-# define fdopen(fd,type) _fdopen(fd,type)
-# endif
-#endif
-
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#endif