From fe473506566a3a8770ac14bc21d0d8f681ac5eca Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Wed, 7 Jan 2015 14:05:58 +0000 Subject: [PATCH] Further adjustments to support PolarSSL 1.2 --- configure.ac | 2 +- libtransmission/crypto-utils-polarssl.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index e994988da..19930182c 100644 --- a/configure.ac +++ b/configure.ac @@ -150,7 +150,7 @@ AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xpolarssl"], [ #if defined (POLARSSL_VERSION_NUMBER) && POLARSSL_VERSION_NUMBER >= $POLARSSL_MINIMUM version_ok #endif], - [AC_CHECK_LIB([polarssl], [dhm_init], + [AC_CHECK_LIB([polarssl], [dhm_calc_secret], [want_crypto="polarssl"; CRYPTO_PKG="polarssl"; CRYPTO_CFLAGS=""; CRYPTO_LIBS="-lpolarssl"], [AS_IF([test "x$want_crypto" = "xpolarssl"], [AC_MSG_ERROR([PolarSSL support requested, but library not found.])] diff --git a/libtransmission/crypto-utils-polarssl.c b/libtransmission/crypto-utils-polarssl.c index 8e5583a1d..1c59a7f6e 100644 --- a/libtransmission/crypto-utils-polarssl.c +++ b/libtransmission/crypto-utils-polarssl.c @@ -40,7 +40,13 @@ log_polarssl_error (int error_code, if (tr_logLevelIsActive (TR_LOG_ERROR)) { char error_message[256]; + +#if POLARSSL_VERSION_NUMBER >= 0x01030000 polarssl_strerror (error_code, error_message, sizeof (error_message)); +#else + error_strerror (error_code, error_message, sizeof (error_message)); +#endif + tr_logAddMessage (file, line, TR_LOG_ERROR, MY_NAME, "PolarSSL error: %s", error_message); } } @@ -288,8 +294,12 @@ tr_dh_agree (tr_dh_ctx_t raw_handle, secret_key_length = handle->len; +#if POLARSSL_VERSION_NUMBER >= 0x01030000 if (!check_result (dhm_calc_secret (handle, ret->key, &secret_key_length, my_rand, NULL))) +#else + if (!check_result (dhm_calc_secret (handle, ret->key, &secret_key_length))) +#endif { tr_dh_secret_free (ret); return NULL;