From 5121acaa665482c941d1b2a12769da128a6de8d7 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 15 Sep 2024 17:06:50 +0200 Subject: [PATCH] Support --with-openssl-argon2 on Windows (GH-15713) We change the error for ZTS builds to a warning, to not break snapshot builds which automatically will try to enable OpenSSL password hashing. We also change some messages to better fit building on Windows. And of course, we cannot easily check whether `OSSL_set_max_threads()` is actually available; instead we're looking up the function declaration in its header file. Co-authored-by: Peter Kokot --- ext/openssl/config.w32 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ext/openssl/config.w32 b/ext/openssl/config.w32 index e9c567dfa6510..24064ec2a5f8c 100644 --- a/ext/openssl/config.w32 +++ b/ext/openssl/config.w32 @@ -4,14 +4,25 @@ ARG_WITH("openssl", "OpenSSL support", "no,shared"); ARG_WITH("openssl-legacy-provider", "OPENSSL: Load legacy algorithm provider in addition to default provider", "no"); +ARG_WITH("openssl-argon2", "OPENSSL: Enable argon2 password hashing (requires OpenSSL >= 3.2)", "no"); + if (PHP_OPENSSL != "no") { var ret = SETUP_OPENSSL("openssl", PHP_OPENSSL); if (ret >= 2) { - EXTENSION("openssl", "openssl.c xp_ssl.c"); + EXTENSION("openssl", "openssl.c openssl_pwhash.c xp_ssl.c"); AC_DEFINE("HAVE_OPENSSL_EXT", 1, "Define to 1 if the PHP extension 'openssl' is available."); if (PHP_OPENSSL_LEGACY_PROVIDER != "no") { AC_DEFINE("LOAD_OPENSSL_LEGACY_PROVIDER", 1, "Define to 1 to load the OpenSSL legacy algorithm provider in addition to the default provider."); } + if (PHP_OPENSSL_ARGON2 != "no") { + if (PHP_ZTS != "no") { + WARNING("OpenSSL argon2 hashing not supported in ZTS mode for now"); + } else if (!CHECK_FUNC_IN_HEADER("openssl/thread.h", "OSSL_set_max_threads", PHP_PHP_BUILD + "\\include")) { + WARNING("OpenSSL argon2 hashing requires OpenSSL >= 3.2"); + } else { + AC_DEFINE("HAVE_OPENSSL_ARGON2", 1, "Define to 1 to enable OpenSSL argon2 password hashing."); + } + } } }