[PATCH 3/3] configure.ac,imap-send.c: check HMAC_CTX_cleanup

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Older versions of OpenSSL have HMAC_cleanup, but not HMAC_CTX_cleanup.
This change checks for both, uses HMAC_CTX_cleanup on platforms which
have it, otherwise falls back to HMAC_cleanup.

This changes makes building GIT on older platforms less tedious.
---
 Makefile     |  6 ++++++
 configure.ac | 13 +++++++++++++
 imap-send.c  |  6 ++++++
 3 files changed, 25 insertions(+)

diff --git a/Makefile b/Makefile
index 7482a4d..a495d94 100644
--- a/Makefile
+++ b/Makefile
@@ -1059,6 +1059,12 @@ ifndef NO_OPENSSL
 	ifdef NEEDS_CRYPTO_WITH_SSL
 		OPENSSL_LIBSSL += -lcrypto
 	endif
+	ifdef HAVE_HMAC_CTX_CLEANUP
+		BASIC_CFLAGS += -DHAVE_HMAC_CTX_CLEANUP
+	endif
+	ifdef HAVE_HMAC_CLEANUP
+		BASIC_CFLAGS += -DHAVE_HMAC_CLEANUP
+	endif
 else
 	BASIC_CFLAGS += -DNO_OPENSSL
 	BLK_SHA1 = 1
diff --git a/configure.ac b/configure.ac
index 3900044..b22788c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -899,6 +899,7 @@ GIT_CONF_SUBST([SNPRINTF_RETURNS_BOGUS])
 ## Checks for library functions.
 ## (in default C library and libraries checked by AC_CHECK_LIB)
 AC_MSG_NOTICE([CHECKS for library functions])
+
 #
 # Define NO_LIBGEN_H if you don't have libgen.h.
 AC_CHECK_HEADER([libgen.h],
@@ -932,6 +933,18 @@ AC_CHECK_LIB([iconv], [locale_charset],
                      [CHARSET_LIB=-lcharset])])
 GIT_CONF_SUBST([CHARSET_LIB])
 #
+# Define HAVE_HMAC_CTX_CLEANUP=Yes if we have the newer HMAC cleanup function
+AC_CHECK_LIB([crypto], [HMAC_CTX_cleanup],
+	[HAVE_HMAC_CTX_CLEANUP=Yes],
+	[], [])
+GIT_CONF_SUBST([HAVE_HMAC_CTX_CLEANUP])
+#
+# Define HAVE_HMAC_CLEANUP=Yes if we have the older HMAC cleanup function
+AC_CHECK_LIB([crypto], [HMAC_cleanup],
+	[HAVE_HMAC_CLEANUP=Yes],
+	[], [])
+GIT_CONF_SUBST([HAVE_HMAC_CLEANUP])
+#
 # Define NO_CLOCK_GETTIME if you don't have clock_gettime.
 GIT_CHECK_FUNC(clock_gettime,
 [HAVE_CLOCK_GETTIME=Yes],
diff --git a/imap-send.c b/imap-send.c
index 70bcc7a..eec2378 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -861,7 +861,13 @@ static char *cram(const char *challenge_64, const char *user, const char *pass)
 	HMAC_Init(&hmac, (unsigned char *)pass, strlen(pass), EVP_md5());
 	HMAC_Update(&hmac, (unsigned char *)challenge, decoded_len);
 	HMAC_Final(&hmac, hash, NULL);
+#if defined(HAVE_HMAC_CTX_CLEANUP)
 	HMAC_CTX_cleanup(&hmac);
+#elif defined(HAVE_HMAC_CLEANUP)
+	HMAC_cleanup(&hmac);
+#else
+# error "no HMAC_cleanup function"
+#endif
 
 	hex[32] = 0;
 	for (i = 0; i < 16; i++) {
-- 
2.2.0.GIT

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]