From 48e40df7b13d317a21de78fc84a2eeca32c46068 Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Tue, 19 Jan 2016 05:32:56 -0800 Subject: [PATCH] Fix nettle library probe = Only use it if we can find the library *and* the headers = When probing the library, try to link a function that's actually in the library (not 'main') --- configure.ac | 16 ++++++++-------- libarchive/archive_cryptor.c | 2 +- libarchive/archive_cryptor_private.h | 2 +- libarchive/archive_hmac.c | 2 +- libarchive/archive_hmac_private.h | 2 +- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/configure.ac b/configure.ac index 7a9cb9fec..cce432cf2 100644 --- a/configure.ac +++ b/configure.ac @@ -780,8 +780,9 @@ esac if test "x$with_nettle" != "xno"; then AC_CHECK_HEADERS([nettle/md5.h nettle/ripemd160.h nettle/sha.h]) + AC_CHECK_HEADERS([nettle/pbkdf2.h nettle/aes.h nettle/hmac.h]) saved_LIBS=$LIBS - AC_CHECK_LIB(nettle,main) + AC_CHECK_LIB(nettle,nettle_sha1_init) CRYPTO_CHECK(MD5, NETTLE, md5) CRYPTO_CHECK(RMD160, NETTLE, rmd160) CRYPTO_CHECK(SHA1, NETTLE, sha1) @@ -790,10 +791,9 @@ if test "x$with_nettle" != "xno"; then CRYPTO_CHECK(SHA512, NETTLE, sha512) if test "x$found_NETTLE" != "xyes"; then LIBS=$saved_LIBS - else - AC_CHECK_HEADERS([nettle/pbkdf2.h]) fi fi + if test "x$with_openssl" != "xno"; then AC_CHECK_HEADERS([openssl/evp.h]) saved_LIBS=$LIBS @@ -801,18 +801,18 @@ if test "x$with_openssl" != "xno"; then *mingw* | *cygwin*) case "$host_cpu" in x86_64) - AC_CHECK_LIB(eay64,main) + AC_CHECK_LIB(eay64,OPENSSL_config) if test "x$ac_cv_lib_eay64_main" != "xyes"; then - AC_CHECK_LIB(eay32,main) + AC_CHECK_LIB(eay32,OPENSSL_config) fi ;; *) - AC_CHECK_LIB(eay32,main) + AC_CHECK_LIB(eay32,OPENSSL_config) ;; esac ;; *) - AC_CHECK_LIB(crypto,main) + AC_CHECK_LIB(crypto,OPENSSL_config) ;; esac CRYPTO_CHECK(MD5, OPENSSL, md5) @@ -832,7 +832,7 @@ fi # The two are incompatible and OpenSSL is more complete. AC_CHECK_HEADERS([md5.h ripemd.h sha.h sha256.h sha512.h]) saved_LIBS=$LIBS -AC_CHECK_LIB(md,main) +AC_CHECK_LIB(md,MD5Init) CRYPTO_CHECK(MD5, LIBMD, md5) CRYPTO_CHECK(RMD160, LIBMD, rmd160) CRYPTO_CHECK(SHA1, LIBMD, sha1) diff --git a/libarchive/archive_cryptor.c b/libarchive/archive_cryptor.c index efd350d29..f9615a64a 100644 --- a/libarchive/archive_cryptor.c +++ b/libarchive/archive_cryptor.c @@ -256,7 +256,7 @@ aes_ctr_release(archive_crypto_ctx *ctx) return 0; } -#elif defined(HAVE_LIBNETTLE) +#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H) static int aes_ctr_init(archive_crypto_ctx *ctx, const uint8_t *key, size_t key_len) diff --git a/libarchive/archive_cryptor_private.h b/libarchive/archive_cryptor_private.h index 9a96aeea6..f629bc13b 100644 --- a/libarchive/archive_cryptor_private.h +++ b/libarchive/archive_cryptor_private.h @@ -72,7 +72,7 @@ typedef struct { unsigned encr_pos; } archive_crypto_ctx; -#elif defined(HAVE_LIBNETTLE) +#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_AES_H) #if defined(HAVE_NETTLE_PBKDF2_H) #include #endif diff --git a/libarchive/archive_hmac.c b/libarchive/archive_hmac.c index 36e3e1c6f..12fca4561 100644 --- a/libarchive/archive_hmac.c +++ b/libarchive/archive_hmac.c @@ -129,7 +129,7 @@ __hmac_sha1_cleanup(archive_hmac_sha1_ctx *ctx) } } -#elif defined(HAVE_LIBNETTLE) +#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H) static int __hmac_sha1_init(archive_hmac_sha1_ctx *ctx, const uint8_t *key, size_t key_len) diff --git a/libarchive/archive_hmac_private.h b/libarchive/archive_hmac_private.h index a9fb8eca5..1f182d92b 100644 --- a/libarchive/archive_hmac_private.h +++ b/libarchive/archive_hmac_private.h @@ -53,7 +53,7 @@ typedef struct { } archive_hmac_sha1_ctx; -#elif defined(HAVE_LIBNETTLE) +#elif defined(HAVE_LIBNETTLE) && defined(HAVE_NETTLE_HMAC_H) #include typedef struct hmac_sha1_ctx archive_hmac_sha1_ctx; -- 2.47.2