]> Savannah Git Hosting - gnulib.git/commitdiff
crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions.
authorBruno Haible <bruno@clisp.org>
Sat, 26 Aug 2023 20:45:17 +0000 (22:45 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 30 Aug 2023 10:02:35 +0000 (12:02 +0200)
* lib/sha1.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA1.
* lib/sha256.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA256.
* lib/sha512.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SHA512.
* lib/md5.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_MD5.
* lib/sm3.h: If <openssl/macros.h> would give a compile-time error,
undefine HAVE_OPENSSL_SM3.

ChangeLog
lib/md5.h
lib/sha1.h
lib/sha256.h
lib/sha512.h
lib/sm3.h

index a3cc6d3dffd6ca5323ac08208e50127615f80f40..3cdadae57f4e1f453d8d2be6f452380e17303a65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2023-08-26  Bruno Haible  <bruno@clisp.org>
+
+       crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions.
+       * lib/sha1.h: If <openssl/macros.h> would give a compile-time error,
+       undefine HAVE_OPENSSL_SHA1.
+       * lib/sha256.h: If <openssl/macros.h> would give a compile-time error,
+       undefine HAVE_OPENSSL_SHA256.
+       * lib/sha512.h: If <openssl/macros.h> would give a compile-time error,
+       undefine HAVE_OPENSSL_SHA512.
+       * lib/md5.h: If <openssl/macros.h> would give a compile-time error,
+       undefine HAVE_OPENSSL_MD5.
+       * lib/sm3.h: If <openssl/macros.h> would give a compile-time error,
+       undefine HAVE_OPENSSL_SM3.
+
 2023-08-26  Bruno Haible  <bruno@clisp.org>
 
        uchar: Make #include_next work right.
index 92dc603898857a9c3d3c054517165da26ed60dad..6ddf0091489497598a7614b2d58ee816d461c969 100644 (file)
--- a/lib/md5.h
+++ b/lib/md5.h
 #  ifndef OPENSSL_API_COMPAT
 #   define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API.  */
 #  endif
-#  include <openssl/md5.h>
+/* 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/md5.h>
+#  endif
 # endif
 
 #define MD5_DIGEST_SIZE 16
index 854213a9211cf839283a8731592ec30ca85c8ac6..d5a6e72e2ce8342da2acdb7e5e7f6e439ffc03da 100644 (file)
 #  ifndef OPENSSL_API_COMPAT
 #   define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API.  */
 #  endif
-#  include <openssl/sha.h>
+/* 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/sha.h>
+#  endif
 # endif
 
 # ifdef __cplusplus
index 938b10670628124a059365145d538f6fe4902852..508bce7de8f8131491cb7a9ebda390b002790fa8 100644 (file)
 #  ifndef OPENSSL_API_COMPAT
 #   define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API.  */
 #  endif
-#  include <openssl/sha.h>
+/* 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/sha.h>
+#  endif
 # endif
 
 # ifdef __cplusplus
index f3465bc8a6876a1d5c2d10129d63d8817a16f268..3259f1c7b89dbf3859b735c87f2dc6603679776a 100644 (file)
 #  ifndef OPENSSL_API_COMPAT
 #   define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API.  */
 #  endif
-#  include <openssl/sha.h>
+/* 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/sha.h>
+#  endif
 # endif
 
 # ifdef __cplusplus
index 28af4dff1c5fc94c7de4901b2d845d84470c32b3..f60efdfe9ac986412dfd08e1cb9f982f48b7d202 100644 (file)
--- a/lib/sm3.h
+++ b/lib/sm3.h
 #  ifndef OPENSSL_API_COMPAT
 #   define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API.  */
 #  endif
-#  include <openssl/sm3.h>
+/* 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/sm3.h>
+#  endif
 # endif
 
 # ifdef __cplusplus