From bafa59825e6ba1d4b3772fe66fa0e78ef8dd9cdf Mon Sep 17 00:00:00 2001 From: Norbert Pocs Date: Wed, 5 Oct 2022 15:44:48 +0200 Subject: [PATCH] threads/libcrypto.c: Remove no longer supported openssl versions As openssl 1.1.0, 1.0.2, 1.0.1, 1.0.0 and 0.9.8 are no longer supported let's remove them. Signed-off-by: Norbert Pocs Reviewed-by: Jakub Jelen Reviewed-by: Andreas Schneider --- src/threads/libcrypto.c | 85 ----------------------------------------- 1 file changed, 85 deletions(-) diff --git a/src/threads/libcrypto.c b/src/threads/libcrypto.c index dac840d3..18951b6a 100644 --- a/src/threads/libcrypto.c +++ b/src/threads/libcrypto.c @@ -24,8 +24,6 @@ #include "libssh/threads.h" #include -#if (OPENSSL_VERSION_NUMBER >= 0x10100000) - int crypto_thread_init(struct ssh_threads_callbacks_struct *cb) { (void) cb; @@ -36,86 +34,3 @@ void crypto_thread_finalize(void) { return; } - -#else - -static struct ssh_threads_callbacks_struct *user_callbacks = NULL; - -static void **libcrypto_mutexes; - -void libcrypto_lock_callback(int mode, int i, const char *file, int line); - -void libcrypto_lock_callback(int mode, int i, const char *file, int line) -{ - (void)file; - (void)line; - - if (mode & CRYPTO_LOCK) { - user_callbacks->mutex_lock(&libcrypto_mutexes[i]); - } else { - user_callbacks->mutex_unlock(&libcrypto_mutexes[i]); - } -} - -static void libcrypto_THREADID_callback(CRYPTO_THREADID *id) -{ - unsigned long thread_id = (*user_callbacks->thread_id)(); - - CRYPTO_THREADID_set_numeric(id, thread_id); -} - -int crypto_thread_init(struct ssh_threads_callbacks_struct *cb) -{ - int n = CRYPTO_num_locks(); - int cmp; - int i; - - if (cb == NULL) { - return SSH_OK; - } - - if (user_callbacks != NULL) { - crypto_thread_finalize(); - } - - user_callbacks = cb; - - cmp = strcmp(user_callbacks->type, "threads_noop"); - if (cmp == 0) { - return SSH_OK; - } - - libcrypto_mutexes = calloc(n, sizeof(void *)); - if (libcrypto_mutexes == NULL) { - return SSH_ERROR; - } - - for (i = 0; i < n; ++i){ - user_callbacks->mutex_init(&libcrypto_mutexes[i]); - } - - CRYPTO_THREADID_set_callback(libcrypto_THREADID_callback); - CRYPTO_set_locking_callback(libcrypto_lock_callback); - - return SSH_OK; -} - -void crypto_thread_finalize(void) -{ - int n = CRYPTO_num_locks(); - int i; - - if (libcrypto_mutexes == NULL) { - return; - } - - CRYPTO_THREADID_set_callback(NULL); - CRYPTO_set_locking_callback(NULL); - - for (i = 0; i < n; ++i) { - user_callbacks->mutex_destroy(&libcrypto_mutexes[i]); - } - SAFE_FREE(libcrypto_mutexes); -} - -#endif