/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "randgen.h"
#include "dovecot-openssl-common.h"
static int openssl_init_refcount = 0;
#ifdef HAVE_SSL_NEW_MEM_FUNCS
#else
#endif
{
/* this may be performance critical, so don't use
i_malloc() or calloc() */
}
return mem;
}
#ifdef HAVE_SSL_NEW_MEM_FUNCS
static void *dovecot_openssl_realloc(void *ptr, size_t size, const char *u0 ATTR_UNUSED, int u1 ATTR_UNUSED)
#else
#endif
{
}
return mem;
}
#ifdef HAVE_SSL_NEW_MEM_FUNCS
#else
static void dovecot_openssl_free(void *ptr)
#endif
{
}
void dovecot_openssl_common_global_ref(void)
{
if (openssl_init_refcount++ > 0)
return;
/* use our own memory allocation functions that will die instead of
returning NULL. this avoids random failures on out-of-memory
conditions. */
dovecot_openssl_realloc, dovecot_openssl_free) == 0) {
/*i_warning("CRYPTO_set_mem_functions() was called too late");*/
}
}
bool dovecot_openssl_common_global_unref(void)
{
if (--openssl_init_refcount > 0)
return TRUE;
if (dovecot_openssl_engine != NULL) {
}
/* OBJ_cleanup() is called automatically by EVP_cleanup() in
newer versions. Doesn't hurt to call it anyway. */
OBJ_cleanup();
#endif
EVP_cleanup();
/* no cleanup needed */
#elif defined(HAVE_OPENSSL_ERR_REMOVE_THREAD_STATE)
/* This was marked as deprecated in v1.1. */
#else
/* This was deprecated by ERR_remove_thread_state(NULL) in v1.0.0. */
ERR_remove_state(0);
#endif
#ifdef HAVE_OPENSSL_CLEANUP
#endif
return FALSE;
}
const char **error_r)
{
if (dovecot_openssl_engine != NULL)
return 1;
if (dovecot_openssl_engine == NULL) {
return 0;
}
if (ENGINE_init(dovecot_openssl_engine) == 0) {
return -1;
}
return -1;
}
return 1;
}