1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-11-27 13:21:11 +03:00

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 <npocs@redhat.com>
Reviewed-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Norbert Pocs
2022-10-05 15:44:48 +02:00
committed by Jakub Jelen
parent eb40fb60ae
commit bafa59825e

View File

@@ -24,8 +24,6 @@
#include "libssh/threads.h" #include "libssh/threads.h"
#include <libssh/callbacks.h> #include <libssh/callbacks.h>
#if (OPENSSL_VERSION_NUMBER >= 0x10100000)
int crypto_thread_init(struct ssh_threads_callbacks_struct *cb) int crypto_thread_init(struct ssh_threads_callbacks_struct *cb)
{ {
(void) cb; (void) cb;
@@ -36,86 +34,3 @@ void crypto_thread_finalize(void)
{ {
return; 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