From: Bruno Haible Date: Sat, 26 Aug 2023 20:45:17 +0000 (+0200) Subject: crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions. X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=9966b6738c1b4d491b8bcaabd06921e0e42f8030;p=gnulib.git crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions. * lib/sha1.h: If would give a compile-time error, undefine HAVE_OPENSSL_SHA1. * lib/sha256.h: If would give a compile-time error, undefine HAVE_OPENSSL_SHA256. * lib/sha512.h: If would give a compile-time error, undefine HAVE_OPENSSL_SHA512. * lib/md5.h: If would give a compile-time error, undefine HAVE_OPENSSL_MD5. * lib/sm3.h: If would give a compile-time error, undefine HAVE_OPENSSL_SM3. --- diff --git a/ChangeLog b/ChangeLog index a3cc6d3dff..3cdadae57f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2023-08-26 Bruno Haible + + crypto/{sha*,md5,sm3}-buffer: Ignore too old OpenSSL versions. + * lib/sha1.h: If would give a compile-time error, + undefine HAVE_OPENSSL_SHA1. + * lib/sha256.h: If would give a compile-time error, + undefine HAVE_OPENSSL_SHA256. + * lib/sha512.h: If would give a compile-time error, + undefine HAVE_OPENSSL_SHA512. + * lib/md5.h: If would give a compile-time error, + undefine HAVE_OPENSSL_MD5. + * lib/sm3.h: If would give a compile-time error, + undefine HAVE_OPENSSL_SM3. + 2023-08-26 Bruno Haible uchar: Make #include_next work right. diff --git a/lib/md5.h b/lib/md5.h index 92dc603898..6ddf009148 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -32,7 +32,17 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# 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 +# endif # endif #define MD5_DIGEST_SIZE 16 diff --git a/lib/sha1.h b/lib/sha1.h index 854213a921..d5a6e72e2c 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -31,7 +31,17 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# 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 +# endif # endif # ifdef __cplusplus diff --git a/lib/sha256.h b/lib/sha256.h index 938b106706..508bce7de8 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -30,7 +30,17 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# 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 +# endif # endif # ifdef __cplusplus diff --git a/lib/sha512.h b/lib/sha512.h index f3465bc8a6..3259f1c7b8 100644 --- a/lib/sha512.h +++ b/lib/sha512.h @@ -30,7 +30,17 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# 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 +# endif # endif # ifdef __cplusplus diff --git a/lib/sm3.h b/lib/sm3.h index 28af4dff1c..f60efdfe9a 100644 --- a/lib/sm3.h +++ b/lib/sm3.h @@ -39,7 +39,17 @@ # ifndef OPENSSL_API_COMPAT # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif -# include +/* If would give a compile-time error, don't use OpenSSL. */ +# include +# 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 +# endif # endif # ifdef __cplusplus