openssl_link.c revision 832f5803f69f4548ba3777f8b5741768bbbf5f75
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews * Portions Copyright (C) 1999-2012, 2014-2016 Internet Systems Consortium, Inc. ("ISC")
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * This Source Code Form is subject to the terms of the Mozilla Public
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * License, v. 2.0. If a copy of the MPL was not distributed with this
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * file, You can obtain one at http://mozilla.org/MPL/2.0/.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Portions Copyright (C) 1995-2000 by Network Associates, Inc.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Permission to use, copy, modify, and/or distribute this software for any
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * purpose with or without fee is hereby granted, provided that the above
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * copyright notice and this permission notice appear in all copies.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * THE SOFTWARE IS PROVIDED "AS IS" AND ISC AND NETWORK ASSOCIATES DISCLAIMS
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Principal Author: Brian Wellington
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (-1);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein result = dst__entropy_getdata(buf, (unsigned int) num, ISC_FALSE);
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews return (-1);
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews result = dst__entropy_getdata(buf, (unsigned int) num, ISC_TRUE);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrewsentropy_add(const void *buf, int num, double entropy) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Do nothing. The only call to this provides no useful data anyway.
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrewsentropy_add(const void *buf, int num, double entropy) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein * Do nothing. The only call to this provides no useful data anyway.
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinlock_callback(int mode, int type, const char *file, int line) {
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstatic unsigned long
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews return ((unsigned long)isc_thread_self());
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrewsstatic void *
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein ptr = isc__mem_allocate(dst__memory_pool, size FLARG_PASS);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (isc__mem_allocate(dst__memory_pool, size FLARG_PASS));
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein isc__mem_free(dst__memory_pool, ptr FLARG_PASS);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austeinstatic void *
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews rptr = isc__mem_reallocate(dst__memory_pool, ptr, size FLARG_PASS);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein return (isc__mem_reallocate(dst__memory_pool, ptr, size FLARG_PASS));
297be3708069ef31814d6d75c0d71a50a78feb03Mark Andrews CRYPTO_set_mem_debug_options(V_CRYPTO_MDEBUG_ALL);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein CRYPTO_set_mem_functions(mem_alloc, mem_realloc, mem_free);
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER)
71c66a876ecca77923638d3f94cc0783152b2f03Mark Andrews locks = mem_alloc(sizeof(isc_mutex_t) * nlocks FILELINE);
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * OPENSSL_config() can only be called a single time as of
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews * 1.0.2e so do the steps individually.
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein /* This will init the engine. */
60e5e10f8d2e2b0c41e8abad38cacd867caa6ab2Rob Austein if (!ENGINE_set_default(e, ENGINE_METHOD_ALL)) {
return (ISC_R_SUCCESS);
#ifdef USE_ENGINE
if (e != NULL)
ENGINE_free(e);
e = NULL;
return (result);
dst__openssl_destroy(void) {
RAND_cleanup();
OBJ_cleanup();
EVP_cleanup();
#if defined(USE_ENGINE)
if (e != NULL)
ENGINE_free(e);
e = NULL;
ERR_remove_state(0);
#ifdef DNS_CRYPTO_LEAKS
static isc_result_t
#if defined(HAVE_OPENSSL_ECDSA) && \
switch (reason) {
case ERR_R_MALLOC_FAILURE:
#if defined(HAVE_OPENSSL_ECDSA) && \
return (result);
return (result);
unsigned long err;
goto done;
if (err == 0U)
goto done;
done:
return (result);
#if defined(USE_ENGINE)
ENGINE *
return (NULL);
if (e == NULL)
return (NULL);
return (NULL);