+2023-09-01 Bruno Haible <bruno@clisp.org>
+
+ crypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26).
+ Reported by Agostino Sarubbo via Sam James <sam@gentoo.org> in
+ <https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00000.html>.
+ * lib/sha1.h: Test the OpenSSL major version before attempting to
+ include <openssl/configuration.h>.
+ * lib/sha256.h: Likewise.
+ * lib/sha512.h: Likewise.
+ * lib/md5.h: Likewise.
+ * lib/sm3.h: Likewise.
+
2023-08-31 Bruno Haible <bruno@clisp.org>
readutmp: Fix memory leak introduced by last commit.
# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
# endif
/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
-# include <openssl/configuration.h>
-# if (OPENSSL_CONFIGURED_API \
- < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
- ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
- + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
- + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
-# undef HAVE_OPENSSL_MD5
-# else
+# include <openssl/opensslv.h>
+# if OPENSSL_VERSION_MAJOR >= 3
+# include <openssl/configuration.h>
+# if (OPENSSL_CONFIGURED_API \
+ < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
+ ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
+ + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+ + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
+# undef HAVE_OPENSSL_MD5
+# endif
+# endif
+# if HAVE_OPENSSL_MD5
# include <openssl/md5.h>
# endif
# endif
# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
# endif
/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
-# include <openssl/configuration.h>
-# if (OPENSSL_CONFIGURED_API \
- < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
- ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
- + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
- + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
-# undef HAVE_OPENSSL_SHA1
-# else
+# include <openssl/opensslv.h>
+# if OPENSSL_VERSION_MAJOR >= 3
+# include <openssl/configuration.h>
+# if (OPENSSL_CONFIGURED_API \
+ < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
+ ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
+ + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+ + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
+# undef HAVE_OPENSSL_SHA1
+# endif
+# endif
+# if HAVE_OPENSSL_SHA1
# include <openssl/sha.h>
# endif
# endif
# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
# endif
/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
-# include <openssl/configuration.h>
-# if (OPENSSL_CONFIGURED_API \
- < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
- ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
- + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
- + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
-# undef HAVE_OPENSSL_SHA256
-# else
+# include <openssl/opensslv.h>
+# if OPENSSL_VERSION_MAJOR >= 3
+# include <openssl/configuration.h>
+# if (OPENSSL_CONFIGURED_API \
+ < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
+ ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
+ + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+ + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
+# undef HAVE_OPENSSL_SHA256
+# endif
+# endif
+# if HAVE_OPENSSL_SHA256
# include <openssl/sha.h>
# endif
# endif
# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
# endif
/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
-# include <openssl/configuration.h>
-# if (OPENSSL_CONFIGURED_API \
- < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
- ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
- + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
- + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
-# undef HAVE_OPENSSL_SHA512
-# else
+# include <openssl/opensslv.h>
+# if OPENSSL_VERSION_MAJOR >= 3
+# include <openssl/configuration.h>
+# if (OPENSSL_CONFIGURED_API \
+ < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
+ ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
+ + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+ + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
+# undef HAVE_OPENSSL_SHA512
+# endif
+# endif
+# if HAVE_OPENSSL_SHA512
# include <openssl/sha.h>
# endif
# endif
# define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */
# endif
/* If <openssl/macros.h> would give a compile-time error, don't use OpenSSL. */
-# include <openssl/configuration.h>
-# if (OPENSSL_CONFIGURED_API \
- < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
- ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
- + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
- + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
-# undef HAVE_OPENSSL_SM3
-# else
+# include <openssl/opensslv.h>
+# if OPENSSL_VERSION_MAJOR >= 3
+# include <openssl/configuration.h>
+# if (OPENSSL_CONFIGURED_API \
+ < (OPENSSL_API_COMPAT < 0x900000L ? OPENSSL_API_COMPAT : \
+ ((OPENSSL_API_COMPAT >> 28) & 0xF) * 10000 \
+ + ((OPENSSL_API_COMPAT >> 20) & 0xFF) * 100 \
+ + ((OPENSSL_API_COMPAT >> 12) & 0xFF)))
+# undef HAVE_OPENSSL_SM3
+# endif
+# endif
+# if HAVE_OPENSSL_SM3
# include <openssl/sm3.h>
# endif
# endif