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

Re: Build libssh against openssl 1.1.0


On Sunday, 6 November 2016 12:09:30 CET Andreas Schneider wrote:
> On Saturday, 5 November 2016 17:02:13 CET Andreas Schneider wrote:
> > On Wednesday, 2 November 2016 17:58:01 CET Jakub Jelen wrote:
> > > Andreas,
> > > thank you for the comments. I reworked the patch (attached) to smaller
> > > parts that finally build and passes the testsuite in master for both
> > > OpenSSL versions (sorry for the first bad version). It also improves the
> > > readability of some constructions according to your hints.
> > 
> > Thank you very much. I split up one patch which didn't have your sign off.
> > The patchset is attached. I need your ok to add your sign-off and push it.
> 
> And please also check the attached patch.
> 
> 
> Thanks.

EWRONGPATCH

-- 
Andreas Schneider                   GPG-ID: CC014E3D
www.cryptomilk.org                asn@xxxxxxxxxxxxxx
From 56657fbae93df23aee077f835a6563245d82d9a1 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn@xxxxxxxxxxxxxx>
Date: Sun, 6 Nov 2016 12:07:32 +0100
Subject: [PATCH] threads: Use new API call with OpenSSL 1.1.0

BUG: https://red.libssh.org/issues/222

Signed-off-by: Andreas Schneider <asn@xxxxxxxxxxxxxx>
---
 ConfigureChecks.cmake |  3 +++
 config.h.cmake        |  3 +++
 src/threads.c         | 19 +++++++++++++++++--
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index e18965a..04d9a1c 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -107,6 +107,9 @@ if (OPENSSL_FOUND)
     set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
     check_function_exists(EVP_aes_128_cbc HAVE_OPENSSL_EVP_AES_CBC)
 
+    set(CMAKE_REQUIRED_INCLUDES ${OPENSSL_INCLUDE_DIR})
+    set(CMAKE_REQUIRED_LIBRARIES ${OPENSSL_CRYPTO_LIBRARY})
+    check_function_exists(CRYPTO_THREADID_set_callback HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK)
 endif()
 
 if (CMAKE_HAVE_PTHREAD_H)
diff --git a/config.h.cmake b/config.h.cmake
index dd54d5d..726d85b 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -88,6 +88,9 @@
 /* Define to 1 if you have the `EVP_aes128_cbc' function. */
 #cmakedefine HAVE_OPENSSL_EVP_AES_CBC 1
 
+/* Define to 1 if you have the `CRYPTO_THREADID_set_callback' function. */
+#cmakedefine HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK 1
+
 /* Define to 1 if you have the `snprintf' function. */
 #cmakedefine HAVE_SNPRINTF 1
 
diff --git a/src/threads.c b/src/threads.c
index 7f3a304..062c3b8 100644
--- a/src/threads.c
+++ b/src/threads.c
@@ -116,6 +116,15 @@ static void libcrypto_lock_callback(int mode, int i, const char *file, int line)
 	}
 }
 
+#ifdef HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK
+static void libcrypto_THREADID_callback(CRYPTO_THREADID *id)
+{
+    unsigned long thread_id = (*user_callbacks->thread_id)();
+
+    CRYPTO_THREADID_set_numeric(id, thread_id);
+}
+#endif /* HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK */
+
 static int libcrypto_thread_init(void){
 	int n=CRYPTO_num_locks();
 	int i;
@@ -127,8 +136,14 @@ static int libcrypto_thread_init(void){
 	for (i=0;i<n;++i){
 		user_callbacks->mutex_init(&libcrypto_mutexes[i]);
 	}
-  CRYPTO_set_id_callback(user_callbacks->thread_id);
-	CRYPTO_set_locking_callback(libcrypto_lock_callback);
+
+#ifdef HAVE_OPENSSL_CRYPTO_THREADID_SET_CALLBACK
+    CRYPTO_THREADID_set_callback(libcrypto_THREADID_callback);
+#else
+    CRYPTO_set_id_callback(user_callbacks->thread_id);
+#endif
+
+    CRYPTO_set_locking_callback(libcrypto_lock_callback);
 
 	return SSH_OK;
 }
-- 
2.10.1


References:
Build libssh against openssl 1.1.0Jakub Jelen <jjelen@xxxxxxxxxx>
Re: Build libssh against openssl 1.1.0Andreas Schneider <asn@xxxxxxxxxxxxxx>
Re: Build libssh against openssl 1.1.0Andreas Schneider <asn@xxxxxxxxxxxxxx>
Archive administrator: postmaster@lists.cynapses.org