]> 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:27:27 +0000 (12:27 +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 2c23db0c57b84dcd0446c7b47dfb96cc11c8160b..657819e6d6a727240b1cb70f059ca8c945037398 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 f34e7cb8dfa894e8351462ce1e8888d5a2ca0c40..7992999f8cb85ddb3f70345f92613681c5bb2d88 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 5a58b567ceb313e8275a5690758557eea84bff2c..9a7af6151235811e7e9dc7dc1dd46acfff7a078d 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 2879477e89c494865ba452911900ca5f8a54c526..67ef8d00e47052616a4693c8b91940fed84aa618 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 e3a98a2644c7250eec33e05baf54873ed07af22b..98db0a19210d66f95d63f91b3de7e7cb4a03725d 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 4ca7f7a103acbb07ab676c59e1526779bad359cf..f581f13420a7afbe8a18ebe1662efa6e8f77043f 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