From 30690fcf996557755739e34c3373ebb64f557449 Mon Sep 17 00:00:00 2001 From: Mike Gelfand Date: Wed, 7 Jan 2015 13:41:22 +0000 Subject: [PATCH] Lower minimum PolarSSL version required down to 1.2 --- CMakeLists.txt | 2 +- configure.ac | 2 +- libtransmission/crypto-utils-polarssl.c | 26 +++++++++++++++++++++++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04f20f7ef..768d9ef08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -96,7 +96,7 @@ set(CURL_MINIMUM 7.15.4) set(EVENT2_MINIMUM 2.0.10) set(OPENSSL_MINIMUM 0.9.4) set(CYASSL_MINIMUM 3.0) -set(POLARSSL_MINIMUM 1.3) +set(POLARSSL_MINIMUM 1.2) set(ZLIB_MINIMUM 1.2.3) set(GTK_MINIMUM 3.4.0) set(GLIB_MINIMUM 2.32.0) diff --git a/configure.ac b/configure.ac index d619c4703..e994988da 100644 --- a/configure.ac +++ b/configure.ac @@ -50,7 +50,7 @@ OPENSSL_MINIMUM=0.9.4 AC_SUBST(OPENSSL_MINIMUM) CYASSL_MINIMUM=3.0 AC_SUBST(CYASSL_MINIMUM) -POLARSSL_MINIMUM=0x01030000 # 1.3 +POLARSSL_MINIMUM=0x01020000 # 1.2 AC_SUBST(POLARSSL_MINIMUM) ## diff --git a/libtransmission/crypto-utils-polarssl.c b/libtransmission/crypto-utils-polarssl.c index ac6fb538b..8e5583a1d 100644 --- a/libtransmission/crypto-utils-polarssl.c +++ b/libtransmission/crypto-utils-polarssl.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "transmission.h" #include "crypto-utils.h" @@ -110,7 +111,12 @@ get_rng_lock (void) tr_sha1_ctx_t tr_sha1_init (void) { - sha1_context * handle = tr_new (sha1_context, 1); + sha1_context * handle = tr_new0 (sha1_context, 1); + +#if POLARSSL_VERSION_NUMBER >= 0x01030800 + sha1_init (handle); +#endif + sha1_starts (handle); return handle; } @@ -142,6 +148,10 @@ tr_sha1_final (tr_sha1_ctx_t handle, sha1_finish (handle, hash); } +#if POLARSSL_VERSION_NUMBER >= 0x01030800 + sha1_free (handle); +#endif + tr_free (handle); return true; } @@ -153,12 +163,22 @@ tr_sha1_final (tr_sha1_ctx_t handle, tr_rc4_ctx_t tr_rc4_new (void) { - return tr_new0 (arc4_context, 1); + arc4_context * handle = tr_new0 (arc4_context, 1); + +#if POLARSSL_VERSION_NUMBER >= 0x01030800 + arc4_init (handle); +#endif + + return handle; } void tr_rc4_free (tr_rc4_ctx_t handle) { +#if POLARSSL_VERSION_NUMBER >= 0x01030800 + arc4_free (handle); +#endif + tr_free (handle); } @@ -205,7 +225,9 @@ tr_dh_new (const uint8_t * prime_num, assert (prime_num != NULL); assert (generator_num != NULL); +#if POLARSSL_VERSION_NUMBER >= 0x01030800 dhm_init (handle); +#endif if (!check_result (mpi_read_binary (&handle->P, prime_num, prime_num_length)) || !check_result (mpi_read_binary (&handle->G, generator_num, generator_num_length)))