Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ option(MZ_FORCE_FETCH_LIBS "Enables fetching third-party libraries always" OFF)
option(MZ_PKCRYPT "Enables PKWARE traditional encryption" ON)
option(MZ_WZAES "Enables WinZIP AES encryption" ON)
option(MZ_OPENSSL "Enables OpenSSL for encryption" ${UNIX})
option(MZ_PBKDF2 "Enables Password-Based Key Derivation Function 2" OFF)
cmake_dependent_option(MZ_LIBBSD "Builds with libbsd crypto random" ON "UNIX" OFF)
# Character conversion options
option(MZ_ICONV "Enables iconv for string encoding conversion" ON)
Expand Down Expand Up @@ -607,7 +608,15 @@ else()
endif()
endif()

if(MZ_WZAES)
# WinZIP AES encryption requires PBKDF2
set(MZ_PBKDF2 ON)
endif()

# Setup predefined macros
if(MZ_PBKDF2)
list(APPEND MINIZIP_DEF -DHAVE_PBKDF2)
endif()
if(MZ_COMPRESS_ONLY)
list(APPEND MINIZIP_DEF -DMZ_ZIP_NO_DECOMPRESSION)
endif()
Expand Down
2 changes: 1 addition & 1 deletion mz_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ uint32_t mz_crypt_crc32_update(uint32_t value, const uint8_t *buf, int32_t size)
#endif
}

#if defined(HAVE_WZAES)
#if defined(HAVE_PBKDF2)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's remove all CMake changes. Then do #if !define(NO_PBKDF2).

Then in our CMake, let's use set_target_properties on minizip-ng to set -D NO_PBKDF2.

I don't think this is worthy of a feature flag.

@sergio-nsk sergio-nsk Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess you have meant a macro and a condition like this:

// Don't remove the right hand of the condition. Client apps may use the guarded function.
#if defined(HAVE_WZAES) || defined(HAVE_PBKDF2)

int32_t mz_crypt_pbkdf2(const uint8_t *password, int32_t password_length, const uint8_t *salt, int32_t salt_length,
uint32_t iteration_count, uint8_t *key, uint16_t key_length) {
void *hmac1 = NULL;
Expand Down
Loading