From: Bruno Haible Date: Fri, 1 Sep 2023 10:55:30 +0000 (+0200) Subject: crypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26). X-Git-Tag: v1.0~841 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=ce20e238f0b4448a098bd7c076c131edbc759764;p=gnulib.git crypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26). Reported by Agostino Sarubbo via Sam James in . * lib/sha1.h: Test the OpenSSL major version before attempting to include . * lib/sha256.h: Likewise. * lib/sha512.h: Likewise. * lib/md5.h: Likewise. * lib/sm3.h: Likewise. --- diff --git a/ChangeLog b/ChangeLog index f34d2a7428..206f69216e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,15 @@ +2023-09-01 Bruno Haible + + crypto/{sha*,md5,sm3}-buffer: Fix --with-openssl (regr. 2023-08-26). + Reported by Agostino Sarubbo via Sam James in + . + * lib/sha1.h: Test the OpenSSL major version before attempting to + include . + * lib/sha256.h: Likewise. + * lib/sha512.h: Likewise. + * lib/md5.h: Likewise. + * lib/sm3.h: Likewise. + 2023-08-31 Bruno Haible readutmp: Fix memory leak introduced by last commit. diff --git a/lib/md5.h b/lib/md5.h index 6ddf009148..b298fc4cc3 100644 --- a/lib/md5.h +++ b/lib/md5.h @@ -33,14 +33,18 @@ # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif /* 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 +# if OPENSSL_VERSION_MAJOR >= 3 +# 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 +# endif +# endif +# if HAVE_OPENSSL_MD5 # include # endif # endif diff --git a/lib/sha1.h b/lib/sha1.h index d5a6e72e2c..cf67997f3d 100644 --- a/lib/sha1.h +++ b/lib/sha1.h @@ -32,14 +32,18 @@ # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif /* 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 +# if OPENSSL_VERSION_MAJOR >= 3 +# 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 +# endif +# endif +# if HAVE_OPENSSL_SHA1 # include # endif # endif diff --git a/lib/sha256.h b/lib/sha256.h index 508bce7de8..5a0b652b78 100644 --- a/lib/sha256.h +++ b/lib/sha256.h @@ -31,14 +31,18 @@ # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif /* 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 +# if OPENSSL_VERSION_MAJOR >= 3 +# 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 +# endif +# endif +# if HAVE_OPENSSL_SHA256 # include # endif # endif diff --git a/lib/sha512.h b/lib/sha512.h index 3259f1c7b8..37832da750 100644 --- a/lib/sha512.h +++ b/lib/sha512.h @@ -31,14 +31,18 @@ # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif /* 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 +# if OPENSSL_VERSION_MAJOR >= 3 +# 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 +# endif +# endif +# if HAVE_OPENSSL_SHA512 # include # endif # endif diff --git a/lib/sm3.h b/lib/sm3.h index f60efdfe9a..36f1cd5297 100644 --- a/lib/sm3.h +++ b/lib/sm3.h @@ -40,14 +40,18 @@ # define OPENSSL_API_COMPAT 0x10101000L /* FIXME: Use OpenSSL 1.1+ API. */ # endif /* 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 +# if OPENSSL_VERSION_MAJOR >= 3 +# 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 +# endif +# endif +# if HAVE_OPENSSL_SM3 # include # endif # endif