From: Nick Mathewson Date: Wed, 28 Jan 2015 15:00:58 +0000 (-0500) Subject: Try to work around changes in openssl 1.1.0 X-Git-Tag: tor-0.2.6.3-alpha~92^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9caa8645e5da69ac503a365624896d33b91504b;p=thirdparty%2Ftor.git Try to work around changes in openssl 1.1.0 Prefer not to use a couple of deprecated functions; include more headers in tortls.c This is part of ticket 14188. --- diff --git a/changes/ticket14188_part1 b/changes/ticket14188_part1 new file mode 100644 index 0000000000..9d66bba1fc --- /dev/null +++ b/changes/ticket14188_part1 @@ -0,0 +1,2 @@ + o Compilation fixes: + - Compile correctly with (unreleased) OpenSSL 1.1.0 headers. diff --git a/src/common/crypto.c b/src/common/crypto.c index 370c04a315..218c7bea1e 100644 --- a/src/common/crypto.c +++ b/src/common/crypto.c @@ -1780,9 +1780,13 @@ crypto_generate_dynamic_dh_modulus(void) dynamic_dh_modulus = BN_new(); tor_assert(dynamic_dh_modulus); - dh_parameters = DH_generate_parameters(DH_BYTES*8, DH_GENERATOR, NULL, NULL); + dh_parameters = DH_new(); tor_assert(dh_parameters); + r = DH_generate_parameters_ex(dh_parameters, + DH_BYTES*8, DH_GENERATOR, NULL); + tor_assert(r == 0); + r = DH_check(dh_parameters, &dh_codes); tor_assert(r && !dh_codes); @@ -3115,6 +3119,14 @@ openssl_dynlock_destroy_cb_(struct CRYPTO_dynlock_value *v, tor_free(v); } +#if OPENSSL_VERSION_NUMBER >= OPENSSL_V_SERIES(1,0,0) +static void +tor_set_openssl_thread_id(CRYPTO_THREADID *threadid) +{ + CRYPTO_THREADID_set_numeric(threadid, tor_get_thread_id()); +} +#endif + /** @{ */ /** Helper: Construct mutexes, and set callbacks to help OpenSSL handle being * multithreaded. */ @@ -3128,7 +3140,11 @@ setup_openssl_threading(void) for (i=0; i < n; ++i) openssl_mutexes_[i] = tor_mutex_new(); CRYPTO_set_locking_callback(openssl_locking_cb_); +#if OPENSSL_VERSION_NUMBER < OPENSSL_V_SERIES(1,0,0) CRYPTO_set_id_callback(tor_get_thread_id); +#else + CRYPTO_THREADID_set_callback(tor_set_openssl_thread_id); +#endif CRYPTO_set_dynlock_create_callback(openssl_dynlock_create_cb_); CRYPTO_set_dynlock_lock_callback(openssl_dynlock_lock_cb_); CRYPTO_set_dynlock_destroy_callback(openssl_dynlock_destroy_cb_); diff --git a/src/common/tortls.c b/src/common/tortls.c index ca629135a6..5df6364393 100644 --- a/src/common/tortls.c +++ b/src/common/tortls.c @@ -50,6 +50,8 @@ #include #include #include +#include +#include #if __GNUC__ && GCC_VERSION >= 402 #if GCC_VERSION >= 406