2014-12-19 09:56:51 -07:00
|
|
|
/* logging.c
|
|
|
|
|
*
|
2022-12-30 17:12:11 -07:00
|
|
|
* Copyright (C) 2006-2023 wolfSSL Inc.
|
2014-12-19 09:56:51 -07:00
|
|
|
*
|
2016-03-17 16:02:13 -06:00
|
|
|
* This file is part of wolfSSL.
|
2014-12-19 09:56:51 -07:00
|
|
|
*
|
2015-01-04 23:26:26 -07:00
|
|
|
* wolfSSL is free software; you can redistribute it and/or modify
|
2014-12-19 09:56:51 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
2015-01-04 23:26:26 -07:00
|
|
|
* wolfSSL is distributed in the hope that it will be useful,
|
2014-12-19 09:56:51 -07:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
2016-03-17 16:02:13 -06:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
|
2014-12-19 09:56:51 -07:00
|
|
|
*/
|
|
|
|
|
|
2016-03-17 16:02:13 -06:00
|
|
|
|
2014-12-19 09:56:51 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/wolfcrypt/settings.h>
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
#include <wolfssl/wolfcrypt/logging.h>
|
|
|
|
|
#include <wolfssl/wolfcrypt/error-crypt.h>
|
2017-04-20 21:29:16 -06:00
|
|
|
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
|
|
|
|
/* avoid adding WANT_READ and WANT_WRITE to error queue */
|
|
|
|
|
#include <wolfssl/error-ssl.h>
|
|
|
|
|
#endif
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2018-04-09 13:53:05 +10:00
|
|
|
#ifdef WOLFSSL_FUNC_TIME
|
2018-04-13 12:13:31 +10:00
|
|
|
/* WARNING: This code is only to be used for debugging performance.
|
|
|
|
|
* The code is not thread-safe.
|
|
|
|
|
* Do not use WOLFSSL_FUNC_TIME in production code.
|
|
|
|
|
*/
|
2018-04-09 13:53:05 +10:00
|
|
|
static double wc_func_start[WC_FUNC_COUNT];
|
|
|
|
|
static double wc_func_time[WC_FUNC_COUNT] = { 0, };
|
|
|
|
|
static const char* wc_func_name[WC_FUNC_COUNT] = {
|
2018-10-02 15:38:45 -07:00
|
|
|
"SendHelloRequest",
|
|
|
|
|
"DoHelloRequest",
|
2018-04-09 13:53:05 +10:00
|
|
|
"SendClientHello",
|
|
|
|
|
"DoClientHello",
|
|
|
|
|
"SendServerHello",
|
|
|
|
|
"DoServerHello",
|
|
|
|
|
"SendEncryptedExtensions",
|
|
|
|
|
"DoEncryptedExtensions",
|
|
|
|
|
"SendCertificateRequest",
|
|
|
|
|
"DoCertificateRequest",
|
|
|
|
|
"SendCertificate",
|
|
|
|
|
"DoCertificate",
|
|
|
|
|
"SendCertificateVerify",
|
|
|
|
|
"DoCertificateVerify",
|
|
|
|
|
"SendFinished",
|
|
|
|
|
"DoFinished",
|
|
|
|
|
"SendKeyUpdate",
|
|
|
|
|
"DoKeyUpdate",
|
|
|
|
|
"SendEarlyData",
|
|
|
|
|
"DoEarlyData",
|
|
|
|
|
"SendNewSessionTicket",
|
|
|
|
|
"DoNewSessionTicket",
|
|
|
|
|
"SendServerHelloDone",
|
|
|
|
|
"DoServerHelloDone",
|
|
|
|
|
"SendTicket",
|
|
|
|
|
"DoTicket",
|
|
|
|
|
"SendClientKeyExchange",
|
|
|
|
|
"DoClientKeyExchange",
|
|
|
|
|
"SendCertificateStatus",
|
|
|
|
|
"DoCertificateStatus",
|
|
|
|
|
"SendServerKeyExchange",
|
|
|
|
|
"DoServerKeyExchange",
|
|
|
|
|
"SendEarlyData",
|
|
|
|
|
"DoEarlyData",
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-13 12:13:31 +10:00
|
|
|
#include <sys/time.h>
|
2018-04-09 13:53:05 +10:00
|
|
|
|
2018-04-13 12:13:31 +10:00
|
|
|
/* WARNING: This function is not portable. */
|
2018-06-26 11:40:34 -07:00
|
|
|
static WC_INLINE double current_time(int reset)
|
2018-04-13 12:13:31 +10:00
|
|
|
{
|
|
|
|
|
struct timeval tv;
|
|
|
|
|
gettimeofday(&tv, 0);
|
|
|
|
|
(void)reset;
|
2018-04-09 13:53:05 +10:00
|
|
|
|
2018-04-13 12:13:31 +10:00
|
|
|
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
|
|
|
|
|
}
|
|
|
|
|
#endif /* WOLFSSL_FUNC_TIME */
|
2017-02-09 16:28:32 +10:00
|
|
|
|
2020-10-27 12:39:49 -05:00
|
|
|
#ifdef HAVE_WC_INTROSPECTION
|
|
|
|
|
|
2020-10-27 18:38:29 -05:00
|
|
|
const char *wolfSSL_configure_args(void) {
|
2020-10-27 12:39:49 -05:00
|
|
|
#ifdef LIBWOLFSSL_CONFIGURE_ARGS
|
|
|
|
|
/* the spaces on either side are to make matching simple and efficient. */
|
|
|
|
|
return " " LIBWOLFSSL_CONFIGURE_ARGS " ";
|
|
|
|
|
#else
|
|
|
|
|
return NULL;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-19 12:28:07 -07:00
|
|
|
PEDANTIC_EXTENSION const char *wolfSSL_global_cflags(void) {
|
2020-10-27 12:39:49 -05:00
|
|
|
#ifdef LIBWOLFSSL_GLOBAL_CFLAGS
|
|
|
|
|
/* the spaces on either side are to make matching simple and efficient. */
|
|
|
|
|
return " " LIBWOLFSSL_GLOBAL_CFLAGS " ";
|
|
|
|
|
#else
|
|
|
|
|
return NULL;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* HAVE_WC_INTROSPECTION */
|
|
|
|
|
|
|
|
|
|
#ifdef HAVE_STACK_SIZE_VERBOSE
|
|
|
|
|
|
|
|
|
|
THREAD_LS_T unsigned char *StackSizeCheck_myStack = NULL;
|
|
|
|
|
THREAD_LS_T size_t StackSizeCheck_stackSize = 0;
|
|
|
|
|
THREAD_LS_T size_t StackSizeCheck_stackSizeHWM = 0;
|
|
|
|
|
THREAD_LS_T size_t *StackSizeCheck_stackSizeHWM_ptr = 0;
|
|
|
|
|
THREAD_LS_T void *StackSizeCheck_stackOffsetPointer = 0;
|
|
|
|
|
|
|
|
|
|
#endif /* HAVE_STACK_SIZE_VERBOSE */
|
|
|
|
|
|
2017-12-29 10:44:51 -08:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2014-12-19 09:56:51 -07:00
|
|
|
|
|
|
|
|
/* Set these to default values initially. */
|
2017-02-09 16:28:32 +10:00
|
|
|
static wolfSSL_Logging_cb log_function = NULL;
|
2014-12-19 09:56:51 -07:00
|
|
|
static int loggingEnabled = 0;
|
|
|
|
|
|
2018-03-13 00:58:49 +09:00
|
|
|
#if defined(WOLFSSL_APACHE_MYNEWT)
|
|
|
|
|
#include "log/log.h"
|
|
|
|
|
static struct log mynewt_log;
|
|
|
|
|
#endif /* WOLFSSL_APACHE_MYNEWT */
|
|
|
|
|
|
2015-01-04 23:26:26 -07:00
|
|
|
#endif /* DEBUG_WOLFSSL */
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2021-10-18 23:45:02 -05:00
|
|
|
#ifdef DEBUG_VECTOR_REGISTER_ACCESS
|
|
|
|
|
THREAD_LS_T int wc_svr_count = 0;
|
|
|
|
|
THREAD_LS_T const char *wc_svr_last_file = NULL;
|
|
|
|
|
THREAD_LS_T int wc_svr_last_line = -1;
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2017-12-29 10:44:51 -08:00
|
|
|
/* allow this to be set to NULL, so logs can be redirected to default output */
|
2014-12-29 10:27:03 -07:00
|
|
|
int wolfSSL_SetLoggingCb(wolfSSL_Logging_cb f)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
2015-01-04 23:26:26 -07:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2017-12-29 10:44:51 -08:00
|
|
|
log_function = f;
|
|
|
|
|
return 0;
|
2014-12-19 09:56:51 -07:00
|
|
|
#else
|
|
|
|
|
(void)f;
|
|
|
|
|
return NOT_COMPILED_IN;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2019-12-13 19:34:14 +01:00
|
|
|
/* allow this to be set to NULL, so logs can be redirected to default output */
|
|
|
|
|
wolfSSL_Logging_cb wolfSSL_GetLoggingCb(void)
|
|
|
|
|
{
|
2019-12-20 16:23:41 +01:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2019-12-13 19:34:14 +01:00
|
|
|
return log_function;
|
2019-12-20 16:23:41 +01:00
|
|
|
#else
|
|
|
|
|
return NULL;
|
|
|
|
|
#endif
|
2019-12-13 19:34:14 +01:00
|
|
|
}
|
|
|
|
|
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
int wolfSSL_Debugging_ON(void)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
2015-01-04 23:26:26 -07:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2014-12-19 09:56:51 -07:00
|
|
|
loggingEnabled = 1;
|
2018-03-13 00:58:49 +09:00
|
|
|
#if defined(WOLFSSL_APACHE_MYNEWT)
|
|
|
|
|
log_register("wolfcrypt", &mynewt_log, &log_console_handler, NULL, LOG_SYSLEVEL);
|
|
|
|
|
#endif /* WOLFSSL_APACHE_MYNEWT */
|
2014-12-19 09:56:51 -07:00
|
|
|
return 0;
|
|
|
|
|
#else
|
|
|
|
|
return NOT_COMPILED_IN;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
void wolfSSL_Debugging_OFF(void)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
2015-01-04 23:26:26 -07:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2014-12-19 09:56:51 -07:00
|
|
|
loggingEnabled = 0;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-09 13:53:05 +10:00
|
|
|
#ifdef WOLFSSL_FUNC_TIME
|
2018-04-13 12:13:31 +10:00
|
|
|
/* WARNING: This code is only to be used for debugging performance.
|
|
|
|
|
* The code is not thread-safe.
|
|
|
|
|
* Do not use WOLFSSL_FUNC_TIME in production code.
|
|
|
|
|
*/
|
2018-04-09 13:53:05 +10:00
|
|
|
void WOLFSSL_START(int funcNum)
|
|
|
|
|
{
|
2021-01-12 12:25:52 +10:00
|
|
|
if (funcNum < WC_FUNC_COUNT) {
|
|
|
|
|
double now = current_time(0) * 1000.0;
|
|
|
|
|
#ifdef WOLFSSL_FUNC_TIME_LOG
|
|
|
|
|
fprintf(stderr, "%17.3f: START - %s\n", now, wc_func_name[funcNum]);
|
|
|
|
|
#endif
|
|
|
|
|
wc_func_start[funcNum] = now;
|
|
|
|
|
}
|
2018-04-09 13:53:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WOLFSSL_END(int funcNum)
|
|
|
|
|
{
|
2021-01-12 12:25:52 +10:00
|
|
|
if (funcNum < WC_FUNC_COUNT) {
|
|
|
|
|
double now = current_time(0) * 1000.0;
|
|
|
|
|
wc_func_time[funcNum] += now - wc_func_start[funcNum];
|
|
|
|
|
#ifdef WOLFSSL_FUNC_TIME_LOG
|
|
|
|
|
fprintf(stderr, "%17.3f: END - %s\n", now, wc_func_name[funcNum]);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2018-04-09 13:53:05 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WOLFSSL_TIME(int count)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
double avg, total = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < WC_FUNC_COUNT; i++) {
|
|
|
|
|
if (wc_func_time[i] > 0) {
|
|
|
|
|
avg = wc_func_time[i] / count;
|
|
|
|
|
fprintf(stderr, "%8.3f ms: %s\n", avg, wc_func_name[i]);
|
|
|
|
|
total += avg;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
fprintf(stderr, "%8.3f ms\n", total);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2015-01-04 23:26:26 -07:00
|
|
|
#ifdef DEBUG_WOLFSSL
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2016-01-15 14:32:20 -07:00
|
|
|
#if defined(FREESCALE_MQX) || defined(FREESCALE_KSDK_MQX)
|
2019-11-18 12:14:34 -08:00
|
|
|
/* see wc_port.h for fio.h and nio.h includes */
|
2017-06-12 15:18:12 -07:00
|
|
|
#elif defined(WOLFSSL_SGX)
|
|
|
|
|
/* Declare sprintf for ocall */
|
|
|
|
|
int sprintf(char* buf, const char *fmt, ...);
|
2018-11-30 13:08:30 -08:00
|
|
|
#elif defined(WOLFSSL_DEOS)
|
2017-08-11 11:42:25 -06:00
|
|
|
#elif defined(MICRIUM)
|
2018-10-29 10:51:41 -07:00
|
|
|
#if (BSP_SER_COMM_EN == DEF_ENABLED)
|
|
|
|
|
#include <bsp_ser.h>
|
|
|
|
|
#endif
|
2017-12-29 10:44:51 -08:00
|
|
|
#elif defined(WOLFSSL_USER_LOG)
|
|
|
|
|
/* user includes their own headers */
|
2018-11-05 01:54:34 +09:00
|
|
|
#elif defined(WOLFSSL_ESPIDF)
|
|
|
|
|
#include "esp_types.h"
|
|
|
|
|
#include "esp_log.h"
|
2019-04-08 06:43:25 -07:00
|
|
|
#elif defined(WOLFSSL_TELIT_M2MB)
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "m2m_log.h"
|
2020-02-04 10:07:26 -07:00
|
|
|
#elif defined(WOLFSSL_ANDROID_DEBUG)
|
|
|
|
|
#include <android/log.h>
|
2020-09-03 15:25:13 -07:00
|
|
|
#elif defined(WOLFSSL_XILINX)
|
|
|
|
|
#include "xil_printf.h"
|
2015-11-19 13:36:21 -08:00
|
|
|
#elif defined(WOLFSSL_LINUXKM)
|
2020-08-13 23:43:39 -05:00
|
|
|
/* the requisite linux/kernel.h is included in wc_port.h, with incompatible warnings masked out. */
|
2021-02-08 18:05:22 -07:00
|
|
|
#elif defined(FUSION_RTOS)
|
|
|
|
|
#include <fclstdio.h>
|
|
|
|
|
#include <wolfssl/wolfcrypt/wc_port.h>
|
|
|
|
|
#define fprintf FCL_FPRINTF
|
2014-12-19 09:56:51 -07:00
|
|
|
#else
|
2021-02-10 09:14:54 -07:00
|
|
|
#include <stdio.h> /* for default printf stuff */
|
2014-12-19 09:56:51 -07:00
|
|
|
#endif
|
|
|
|
|
|
2017-06-14 11:12:27 -06:00
|
|
|
#if defined(THREADX) && !defined(THREADX_NO_DC_PRINTF)
|
2014-12-19 09:56:51 -07:00
|
|
|
int dc_log_printf(char*, ...);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-09-30 13:53:10 -07:00
|
|
|
#ifdef HAVE_STACK_SIZE_VERBOSE
|
|
|
|
|
#include <wolfssl/wolfcrypt/mem_track.h>
|
|
|
|
|
#endif
|
|
|
|
|
|
2015-01-04 23:26:26 -07:00
|
|
|
static void wolfssl_log(const int logLevel, const char *const logMessage)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
|
|
|
|
if (log_function)
|
|
|
|
|
log_function(logLevel, logMessage);
|
|
|
|
|
else {
|
2017-12-29 10:44:51 -08:00
|
|
|
#if defined(WOLFSSL_USER_LOG)
|
2018-01-02 19:30:33 -08:00
|
|
|
WOLFSSL_USER_LOG(logMessage);
|
2017-12-29 10:44:51 -08:00
|
|
|
#elif defined(WOLFSSL_LOG_PRINTF)
|
2018-01-02 19:30:33 -08:00
|
|
|
printf("%s\n", logMessage);
|
2017-12-29 10:44:51 -08:00
|
|
|
|
|
|
|
|
#elif defined(THREADX) && !defined(THREADX_NO_DC_PRINTF)
|
2018-01-02 19:30:33 -08:00
|
|
|
dc_log_printf("%s\n", logMessage);
|
2018-11-30 13:08:30 -08:00
|
|
|
#elif defined(WOLFSSL_DEOS)
|
|
|
|
|
printf("%s\r\n", logMessage);
|
2014-12-19 09:56:51 -07:00
|
|
|
#elif defined(MICRIUM)
|
2018-01-02 19:30:33 -08:00
|
|
|
BSP_Ser_Printf("%s\r\n", logMessage);
|
2015-01-04 23:26:26 -07:00
|
|
|
#elif defined(WOLFSSL_MDK_ARM)
|
2018-01-02 19:30:33 -08:00
|
|
|
fflush(stdout) ;
|
|
|
|
|
printf("%s\n", logMessage);
|
|
|
|
|
fflush(stdout) ;
|
2016-03-24 11:07:05 -06:00
|
|
|
#elif defined(WOLFSSL_UTASKER)
|
2018-01-02 19:30:33 -08:00
|
|
|
fnDebugMsg((char*)logMessage);
|
|
|
|
|
fnDebugMsg("\r\n");
|
2017-06-28 12:28:40 -06:00
|
|
|
#elif defined(MQX_USE_IO_OLD)
|
2018-01-02 19:30:33 -08:00
|
|
|
fprintf(_mqxio_stderr, "%s\n", logMessage);
|
2018-03-13 00:58:49 +09:00
|
|
|
#elif defined(WOLFSSL_APACHE_MYNEWT)
|
|
|
|
|
LOG_DEBUG(&mynewt_log, LOG_MODULE_DEFAULT, "%s\n", logMessage);
|
2018-11-05 01:54:34 +09:00
|
|
|
#elif defined(WOLFSSL_ESPIDF)
|
2019-01-17 12:25:28 +09:00
|
|
|
ESP_LOGI("wolfssl", "%s", logMessage);
|
2019-02-07 16:11:17 +10:00
|
|
|
#elif defined(WOLFSSL_ZEPHYR)
|
|
|
|
|
printk("%s\n", logMessage);
|
2019-04-08 06:43:25 -07:00
|
|
|
#elif defined(WOLFSSL_TELIT_M2MB)
|
|
|
|
|
M2M_LOG_INFO("%s\n", logMessage);
|
2020-02-04 10:07:26 -07:00
|
|
|
#elif defined(WOLFSSL_ANDROID_DEBUG)
|
|
|
|
|
__android_log_print(ANDROID_LOG_VERBOSE, "[wolfSSL]", "%s", logMessage);
|
2020-09-03 15:25:13 -07:00
|
|
|
#elif defined(WOLFSSL_XILINX)
|
|
|
|
|
xil_printf("%s\r\n", logMessage);
|
2015-11-19 13:36:21 -08:00
|
|
|
#elif defined(WOLFSSL_LINUXKM)
|
|
|
|
|
printk("%s\n", logMessage);
|
2022-04-08 15:53:24 +09:00
|
|
|
#elif defined(WOLFSSL_RENESAS_RA6M4)
|
|
|
|
|
myprintf("%s\n", logMessage);
|
2022-09-30 13:53:10 -07:00
|
|
|
#elif defined(STACK_SIZE_CHECKPOINT_MSG) && \
|
|
|
|
|
defined(HAVE_STACK_SIZE_VERBOSE) && defined(HAVE_STACK_SIZE_VERBOSE_LOG)
|
|
|
|
|
STACK_SIZE_CHECKPOINT_MSG(logMessage);
|
2014-12-19 09:56:51 -07:00
|
|
|
#else
|
2018-01-02 19:30:33 -08:00
|
|
|
fprintf(stderr, "%s\n", logMessage);
|
2014-12-19 09:56:51 -07:00
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-29 10:44:51 -08:00
|
|
|
#ifndef WOLFSSL_DEBUG_ERRORS_ONLY
|
2022-04-27 22:04:32 +02:00
|
|
|
|
|
|
|
|
#if !defined(_WIN32) && defined(XVSNPRINTF) && !defined(NO_WOLFSSL_MSG_EX)
|
|
|
|
|
#include <stdarg.h> /* for var args */
|
|
|
|
|
#ifndef WOLFSSL_MSG_EX_BUF_SZ
|
|
|
|
|
#define WOLFSSL_MSG_EX_BUF_SZ 100
|
|
|
|
|
#endif
|
2022-04-25 15:59:07 +02:00
|
|
|
#ifdef __clang__
|
|
|
|
|
/* tell clang argument 1 is format */
|
|
|
|
|
__attribute__((__format__ (__printf__, 1, 0)))
|
|
|
|
|
#endif
|
|
|
|
|
void WOLFSSL_MSG_EX(const char* fmt, ...)
|
|
|
|
|
{
|
|
|
|
|
if (loggingEnabled) {
|
2022-04-27 22:04:32 +02:00
|
|
|
char msg[WOLFSSL_MSG_EX_BUF_SZ];
|
2022-04-25 15:59:07 +02:00
|
|
|
int written;
|
|
|
|
|
va_list args;
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
|
written = XVSNPRINTF(msg, sizeof(msg), fmt, args);
|
|
|
|
|
va_end(args);
|
|
|
|
|
if (written > 0)
|
|
|
|
|
wolfssl_log(INFO_LOG , msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
void WOLFSSL_MSG(const char* msg)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
|
|
|
|
if (loggingEnabled)
|
2015-01-04 23:26:26 -07:00
|
|
|
wolfssl_log(INFO_LOG , msg);
|
2014-12-19 09:56:51 -07:00
|
|
|
}
|
|
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
#ifndef LINE_LEN
|
|
|
|
|
#define LINE_LEN 16
|
|
|
|
|
#endif
|
2016-11-24 01:31:07 +10:00
|
|
|
void WOLFSSL_BUFFER(const byte* buffer, word32 length)
|
2015-12-28 19:38:04 -03:00
|
|
|
{
|
2023-04-03 16:51:07 +10:00
|
|
|
int i, buflen = (int)length;
|
2019-09-10 08:45:52 -07:00
|
|
|
char line[(LINE_LEN * 4) + 3]; /* \t00..0F | chars...chars\0 */
|
2015-12-28 19:38:04 -03:00
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
if (!loggingEnabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-12-28 19:38:04 -03:00
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
if (!buffer) {
|
|
|
|
|
wolfssl_log(INFO_LOG, "\tNULL");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-12-28 19:38:04 -03:00
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
while (buflen > 0) {
|
2023-04-03 16:51:07 +10:00
|
|
|
int bufidx = 0;
|
2019-09-10 08:45:52 -07:00
|
|
|
XSNPRINTF(&line[bufidx], sizeof(line)-bufidx, "\t");
|
|
|
|
|
bufidx++;
|
2015-12-28 19:38:04 -03:00
|
|
|
|
|
|
|
|
for (i = 0; i < LINE_LEN; i++) {
|
2019-09-10 08:45:52 -07:00
|
|
|
if (i < buflen) {
|
|
|
|
|
XSNPRINTF(&line[bufidx], sizeof(line)-bufidx, "%02x ", buffer[i]);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
XSNPRINTF(&line[bufidx], sizeof(line)-bufidx, " ");
|
|
|
|
|
}
|
|
|
|
|
bufidx += 3;
|
2015-12-28 19:38:04 -03:00
|
|
|
}
|
|
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
XSNPRINTF(&line[bufidx], sizeof(line)-bufidx, "| ");
|
|
|
|
|
bufidx++;
|
2015-12-28 19:38:04 -03:00
|
|
|
|
2019-09-10 08:45:52 -07:00
|
|
|
for (i = 0; i < LINE_LEN; i++) {
|
|
|
|
|
if (i < buflen) {
|
|
|
|
|
XSNPRINTF(&line[bufidx], sizeof(line)-bufidx,
|
2015-12-28 19:38:04 -03:00
|
|
|
"%c", 31 < buffer[i] && buffer[i] < 127 ? buffer[i] : '.');
|
2019-09-10 08:45:52 -07:00
|
|
|
bufidx++;
|
|
|
|
|
}
|
|
|
|
|
}
|
2015-12-28 19:38:04 -03:00
|
|
|
|
|
|
|
|
wolfssl_log(INFO_LOG, line);
|
2019-09-10 08:45:52 -07:00
|
|
|
buffer += LINE_LEN;
|
|
|
|
|
buflen -= LINE_LEN;
|
2015-12-28 19:38:04 -03:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
void WOLFSSL_ENTER(const char* msg)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
|
|
|
|
if (loggingEnabled) {
|
2017-11-09 17:07:00 -07:00
|
|
|
char buffer[WOLFSSL_MAX_ERROR_SZ];
|
2017-11-09 15:54:24 -07:00
|
|
|
XSNPRINTF(buffer, sizeof(buffer), "wolfSSL Entering %s", msg);
|
2015-01-04 23:26:26 -07:00
|
|
|
wolfssl_log(ENTER_LOG , buffer);
|
2014-12-19 09:56:51 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-12-29 10:27:03 -07:00
|
|
|
void WOLFSSL_LEAVE(const char* msg, int ret)
|
2014-12-19 09:56:51 -07:00
|
|
|
{
|
|
|
|
|
if (loggingEnabled) {
|
2017-11-09 17:07:00 -07:00
|
|
|
char buffer[WOLFSSL_MAX_ERROR_SZ];
|
2017-11-09 15:54:24 -07:00
|
|
|
XSNPRINTF(buffer, sizeof(buffer), "wolfSSL Leaving %s, return %d",
|
|
|
|
|
msg, ret);
|
2015-01-04 23:26:26 -07:00
|
|
|
wolfssl_log(LEAVE_LOG , buffer);
|
2014-12-19 09:56:51 -07:00
|
|
|
}
|
|
|
|
|
}
|
2019-12-13 19:34:14 +01:00
|
|
|
|
|
|
|
|
WOLFSSL_API int WOLFSSL_IS_DEBUG_ON(void)
|
|
|
|
|
{
|
|
|
|
|
return loggingEnabled;
|
|
|
|
|
}
|
2017-12-29 10:44:51 -08:00
|
|
|
#endif /* !WOLFSSL_DEBUG_ERRORS_ONLY */
|
|
|
|
|
#endif /* DEBUG_WOLFSSL */
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
#if defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE)
|
2017-12-29 10:44:51 -08:00
|
|
|
|
2021-12-16 12:39:58 +01:00
|
|
|
#ifdef WOLFSSL_HAVE_ERROR_QUEUE
|
2021-10-04 11:45:18 -06:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
#ifdef ERROR_QUEUE_PER_THREAD
|
|
|
|
|
/* Keep the error queue in thread-local-storage. The only ways this
|
|
|
|
|
* API can deliver meaningful semantics in a multi-threaded setup.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef ERROR_QUEUE_MAX
|
|
|
|
|
/* Same as OpenSSL v1.1.x limit, note that this is per thread */
|
|
|
|
|
#define ERROR_QUEUE_MAX 16
|
|
|
|
|
#endif
|
2017-12-29 10:44:51 -08:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
struct wc_error_entry {
|
|
|
|
|
char reason[WOLFSSL_MAX_ERROR_SZ];
|
|
|
|
|
char file[WOLFSSL_MAX_ERROR_SZ];
|
|
|
|
|
int line;
|
|
|
|
|
int err;
|
|
|
|
|
};
|
2017-12-29 10:44:51 -08:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
struct wc_error_queue {
|
|
|
|
|
struct wc_error_entry entries[ERROR_QUEUE_MAX];
|
|
|
|
|
size_t head_idx;
|
|
|
|
|
size_t count;
|
|
|
|
|
};
|
2014-12-19 09:56:51 -07:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
/* The complete queue in a thread local without allocations */
|
|
|
|
|
static THREAD_LS_T struct wc_error_queue wc_errors;
|
2017-12-29 10:44:51 -08:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
/* Using thread-local-storage, we do not need a mutex. */
|
|
|
|
|
#define ERRQ_LOCK() 0
|
|
|
|
|
#define ERRQ_UNLOCK() (void)0
|
2017-01-06 14:29:16 -07:00
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Given a relative index (from head of the error list), return
|
|
|
|
|
* the absolute index in the `wc_errors->entries` array for
|
|
|
|
|
* the entry or -1 if no such entry exists/is present.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
static int get_abs_idx(int relative_idx)
|
2017-02-03 11:52:36 -07:00
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
if ((wc_errors.count == 0) || (relative_idx >= (int)wc_errors.count)) {
|
|
|
|
|
return -1;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
if (relative_idx < 0) {
|
|
|
|
|
return (int)((wc_errors.head_idx + wc_errors.count - 1)
|
|
|
|
|
% ERROR_QUEUE_MAX);
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
return (int)((wc_errors.head_idx + relative_idx) % ERROR_QUEUE_MAX);
|
|
|
|
|
}
|
2017-02-03 11:52:36 -07:00
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Return the error entry at the given relative index, if
|
|
|
|
|
* it exists, e.g. `relative_idx` is in a valid range.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
static struct wc_error_entry *get_entry(int relative_idx)
|
|
|
|
|
{
|
|
|
|
|
int abs_idx;
|
|
|
|
|
|
|
|
|
|
abs_idx = get_abs_idx(relative_idx);
|
|
|
|
|
if (abs_idx < 0) {
|
|
|
|
|
return NULL;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
return &wc_errors.entries[abs_idx];
|
|
|
|
|
}
|
2017-02-03 11:52:36 -07:00
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Return the error code in the given error `entry` and populate
|
|
|
|
|
* `file`, `reason` and `line` with its values.
|
|
|
|
|
* `entry` may be NULL, in which case BAD_STATE_E is returned.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
static int pass_entry(struct wc_error_entry *entry,
|
|
|
|
|
const char **file, const char **reason,
|
|
|
|
|
int *line)
|
|
|
|
|
{
|
|
|
|
|
if (entry == NULL) {
|
|
|
|
|
WOLFSSL_MSG("No Error found in queue");
|
Add Apache HTTP Server compatibility and --enable-apachehttpd option (#2466)
* Added Apache httpd support `--enable-apachehttpd`.
* Added `SSL_CIPHER_get_version`, `BIO_new_fp`, `SSL_SESSION_print` and `SSL_in_connect_init` compatibility API's.
* Fix to expose `ASN1_UTCTIME_print` stub.
* Pulled in `wolfSSL_X509_get_ext_count` from QT.
* Added `X509_get_ext_count`, `BIO_set_callback`, `BIO_set_callback_arg` and `BIO_get_callback_arg`.
* Added `wolfSSL_ERR_print_errors`.
* Added `BIO_set_nbio` template.
* Fixes for building with Apache httpd.
* Added DH prime functions required for Apache httpd.
* Fix and move the BN DH prime macros.
* Fix for `SSL_CTX_set_tlsext_servername_arg` to have return code.
* Only add the `BN_get_rfc*_prime_*` macro's if older than 1.1.0.
* Added `ERR_GET_FUNC`, `SSL_CTX_clear_extra_chain_certs` prototypes.
* Added `wolfSSL_CTX_set_client_cert_cb` template and `OPENSSL_load_builtin_modules` stub macro.
* Added `X509_INFO` templates (`X509_INFO_new`, `X509_INFO_free`, `sk_X509_INFO_new_null`, `sk_X509_INFO_num`, `sk_X509_INFO_value`, `sk_X509_INFO_free`). Added `sk_X509_shift`.
* Added BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg
* add BIO_set_nbio, ERR_print_errors and tests
* add X509 INFO stack push function
* Add ASN1_UTCTIME_print and unit test
* Add X509_get_ext_count unit test
* initial commit of wolfSSL_PEM_X509_INFO_read_bio
* Added `sk_X509_NAME_new`, `sk_X509_NAME_push`, `sk_X509_NAME_find`, `sk_X509_NAME_set_cmp_func` and `sk_X509_NAME_free`. Grouped `sk_X509_NAME_*` functions.
* Cleanup sk X509 NAME/INFO pop free template.
* Advance openssl compatibility to v1.1.0 for Apache httpd. Added TLS version macros. Implemented sk X509 NAME/INFO pop and pop_free.
* Added `TLS_client_method` support.
* Added `SSL_get_server_tmp_key` and `EC_curve_nid2nist`.
* Added `SSL_CTX_set_min_proto_version` and `SSL_CTX_set_max_proto_version`. Fix for `BN_get_rfc*_prime_*` with the v1.1.0 change.
* add test cases for PEM_X509_INFO_read_bio
* Fixes for `BN_get_rfc*_prime_*` macros. Added template for `SSL_DH_set0_pqg`. Fix for `SSL_OP_NO_` to use Macro's (as is done in openssl). Added `SSL_set_verify_result`. Added stub for `OPENSSL_malloc_init`.
* Apache httpd compatibility functions. BIO setter/getters.
* implement ASN1_TIME_check and add test case
* add SSL_get_client_CA_list
* add initial implementation of wolfSSL_DH_set0_pqg
* Add apache support to OBJ_txt2nid and unit test, add stub for OBJ_create
* add X509_STORE_CTX_get1_chain, sk_free, sk_X509_dup
* Add sk_SSL_COMP_num and SSL_COMP struct
* implement and test of SSL_SESSION_print
* add SSL_CTX_set_client_cert_cb
* expand BIO_printf and add test case
* Added `OCSP_CERTID_dup`. Added `ASN1_TYPE`.
* add implementation for wolfSSL_get_server_tmp_key
* add wolfSSL_BIO_puts and test case
* Add X509_EXTENSION_get_object and X509_EXTENSION_get_data
* add helper for bio flag set and null x509 stack
* add test adn implementation for wolfSSL_i2d_PrivateKey
* Added `ASN1_OTHERNAME`, `ACCESS_DESCRIPTION` and `GENERAL_NAME`. Added `sk_ACCESS_DESCRIPTION_pop_free` and `ACCESS_DESCRIPTION_free` stubs.
* add wolfSSL_PEM_read_bio_ECPKParameters
* add BIO_vfree
* add X509_up_ref
* add X509_STORE_CTX_set_ex_data
* add _GNU_SOURCE macro and wolfSSL_EVP_read_pw_string
* add wolfSSL_EVP_PKEY_ref_up function
* X509_get_ext, X509V3_EXT_print, and d2i_DISPLAYTEXT stubs
* add X509_set_issuer_name
* add wolfSSL_sk_SSL_CIPHER_* functions and tests
* add prototype for sk_X509_EXTENSION and ACCESS_DESCRIPTION
* fix casting to avoid clang warning
* adjust test_wolfSSL_X509_STORE_CTX test case
* Added `OpenSSL_version`
* renegotiate functions and additional stack functions
* add aditional stub functions
* Add Apache httpd requirements for ALPN, CRL, Cert Gen/Req/Ext and SecRen. Fix for `sk_X509_INFO_new_null`.
* add ocsp stub functions
* Proper fix for `sk_X509_INFO_new_null`. Added templates for `X509_get_ext_by_NID` and `X509_add_ext`. Added templates for `ASN1_TIME_diff` and `ASN1_TIME_set`.
* x509 extension stack additions
* Fixed template for `OCSP_id_get0_info`.
* add X509 stub functions
* add X509_STORE_CTX_get0_store() and unit test
* Added `EVP_PKEY_CTX_new_id`, `EVP_PKEY_CTX_set_rsa_keygen_bits`, `EVP_PKEY_keygen_init`, `EVP_PKEY_keygen` and `BN_to_ASN1_INTEGER`.
* x509v3 stubs and req add extensions
* Add OBJ_txt2obj and unit test; add long name to wolfssl_object_info table for use by OBJ_* functions
* wolfSSL_set_alpn_protos implementation
* Added `EVP_SignInit_ex` and `TLS_server_method` implementation. Added stubs for `RSA_get0_key` and `i2d_OCSP_REQUEST_bio`. Fix typo on `OCSP_response_create`. Fix warning in `wolfSSL_set_alpn_protos`.
* Added `X509_EXTENSION_free` stub. Fixed a few macro typos/adding missing.
* add X509_STORE_CTX_get0_current_issuer and unit test
* add OBJ_cmp and unit test
* add RSA_get0_key and unit test
* add OCSP_check_nonce
* Implement X509_set_notAfter/notBefore/serialNumber/version,X509_STORE_CTX_set_depth,X509V3_set_ctx.
* Modify wolfSSL_X509_set_notAfter/notBefore and add tests for each.
* Add test_wolfSSL_X509_set_version w/ fixes to _set_version and fix _set_notBefore/notAfter tests
* add OCSP_id_get0_info and unit test, move WOLFSSL_ASN1_INTEGER to asn_public.h from ssl.h
* inital implementation of wolfSSL_X509_sign
* add debugging messages and set data for BIO's
* Add i2d_OCSP_REQUEST_bio.
* implementation of some WOLFSSL_BIO_METHOD custom functions
* fix for ASN time structure and remove log node
* initial eNULL support and sanity checks
* fixes after rebasing code
* adjust test cases and ASN1_TIME print
* Various fixes for memory leaks
* Apache compatibility in CTX_set_client_CA_list for X509_NAME use; add X509_NAME_dup as supporting function
* Add initial X509_STORE_load_locations stub for Apache
* Updates to X509_get_ext_d2i to return GENERAL_NAME struct instead of ASN1_OBJECT for alternative names and add supporting GENERAL_NAME functions
* Add X509_STORE_load_locations implementation; add wolfSSL_CertManagerLoadCRL_ex; initial renegotiation fixes/updates
* Fix for freeing peer cert in wolfSSL_Rehandshake instead of FreeHandShakeResources during secure renegotiation
* Add X509_ALGOR and X509_PUBKEY structs for X509_PUBKEY_get0_param and X509_get_X509_PUBKEY implementation
* Initial implementation of wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Add implementation for X509_get0_tbs_sigalg and X509_ALGOR_get0
* Add OBJ_nid2ln implementation
* Fix compile errors in tests/api.c for some build options
* Updates to X509_STORE_load_locations for non-CRL types; Add additional DETECT_CERT_TYPE enum and logic for detecting certificate type in ProcessFile
* Add X509_STORE_load_locations unit test and minor error handling fixes
* Add unit test for X509_sign
* Set correct alert type for revoked certificates; add/fix a few WOLFSSL_ENTER messages
* Add X509_ALGOR member to X509 struct; refactoring and unit tests for wolfSSL_X509_ALGOR_get0 and wolfSSL_X509_get0_tbs_sigalg
* Add X509_PUBKEY member to X509 struct; refactoring and unit tests for wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Stack fixes after rebase
* Secure renegotiation refactoring: add ACCEPT_BEGIN_RENEG to AcceptState for use in wolfSSL_SSL_in_connect_init; free old peer cert when receiving new cert to fix memory leak
* Move enc-then-mac enable option in configure.ac for apache httpd compatibility
* Simplify wolfSSL_SSL_in_connect_init logic
* Remove unneeded wolfSSL_CertManagerLoadCRL_ex
* Fixes for jenkins test failures
* SSL_get_secure_renegotiation_support for print statement in Apache
2019-09-19 18:11:10 -06:00
|
|
|
return BAD_STATE_E;
|
|
|
|
|
}
|
2017-02-03 11:52:36 -07:00
|
|
|
if (file != NULL) {
|
2022-12-07 18:14:45 +01:00
|
|
|
*file = entry->file;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
|
|
|
|
if (reason != NULL) {
|
2022-12-07 18:14:45 +01:00
|
|
|
*reason = entry->reason;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
|
|
|
|
if (line != NULL) {
|
2022-12-07 18:14:45 +01:00
|
|
|
*line = entry->line;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
return entry->err;
|
2017-02-03 11:52:36 -07:00
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Assign entry with values, resets all previously present values.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
static void set_entry(struct wc_error_entry *entry, int error,
|
|
|
|
|
const char *file, const char *reason, int line)
|
2017-02-24 09:33:04 -07:00
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
int sz;
|
2017-02-24 09:33:04 -07:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
XMEMSET(entry, 0, sizeof(struct wc_error_entry));
|
|
|
|
|
entry->err = error;
|
2017-02-24 09:33:04 -07:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
entry->line = line;
|
|
|
|
|
sz = (int)XSTRLEN(reason);
|
|
|
|
|
if (sz > WOLFSSL_MAX_ERROR_SZ - 1) {
|
|
|
|
|
sz = WOLFSSL_MAX_ERROR_SZ - 1;
|
2017-02-24 09:33:04 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
if (sz > 0) {
|
|
|
|
|
XMEMCPY(entry->reason, reason, sz);
|
|
|
|
|
entry->reason[WOLFSSL_MAX_ERROR_SZ - 1] = '\0';
|
2017-02-24 09:33:04 -07:00
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
sz = (int)XSTRLEN(file);
|
|
|
|
|
if (sz > WOLFSSL_MAX_ERROR_SZ - 1) {
|
|
|
|
|
sz = WOLFSSL_MAX_ERROR_SZ - 1;
|
2017-02-24 09:33:04 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
if (sz > 0) {
|
|
|
|
|
XMEMCPY(entry->file, file, sz);
|
|
|
|
|
entry->file[WOLFSSL_MAX_ERROR_SZ - 1] = '\0';
|
2017-02-24 09:33:04 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
}
|
2017-02-24 09:33:04 -07:00
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/* Internal function that is called by wolfCrypt_Init() */
|
|
|
|
|
int wc_LoggingInit(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* internal function that is called by wolfCrypt_Cleanup */
|
|
|
|
|
int wc_LoggingCleanup(void)
|
|
|
|
|
{
|
|
|
|
|
/* clear logging entries */
|
|
|
|
|
wc_ClearErrorNodes();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the values from the HEAD of the ERR queue, but keep it in place.
|
|
|
|
|
* If the queue is empty, return BAD_STATE_E.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
int wc_PeekErrorNode(int idx, const char **file, const char **reason,
|
|
|
|
|
int *line)
|
|
|
|
|
{
|
|
|
|
|
return pass_entry(get_entry(idx), file, reason, line);
|
2017-02-24 09:33:04 -07:00
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Get the values from the HEAD of the ERR queue and remove it.
|
|
|
|
|
* If the queue is empty, return BAD_STATE_E.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
int wc_PullErrorNode(const char **file, const char **reason, int *line)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_entry *entry;
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
entry = get_entry(0);
|
|
|
|
|
ret = pass_entry(entry, file, reason, line);
|
|
|
|
|
|
|
|
|
|
if (entry != NULL) {
|
|
|
|
|
wc_RemoveErrorNode(0);
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
2017-02-24 09:33:04 -07:00
|
|
|
|
2017-01-06 14:29:16 -07:00
|
|
|
/* create new error node and add it to the queue
|
|
|
|
|
* buffers are assumed to be of size WOLFSSL_MAX_ERROR_SZ for this internal
|
2022-12-07 18:14:45 +01:00
|
|
|
* function. */
|
|
|
|
|
int wc_AddErrorNode(int error, int line, char* reason, char* file)
|
2017-01-06 14:29:16 -07:00
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
struct wc_error_entry *entry;
|
|
|
|
|
size_t idx;
|
2021-10-06 11:55:40 -06:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
if (wc_errors.count >= ERROR_QUEUE_MAX) {
|
2021-10-06 11:55:40 -06:00
|
|
|
WOLFSSL_MSG("Error queue is full, at ERROR_QUEUE_MAX");
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
idx = (wc_errors.head_idx + wc_errors.count) % ERROR_QUEUE_MAX;
|
|
|
|
|
entry = &wc_errors.entries[idx];
|
|
|
|
|
set_entry(entry, error, file, reason, line);
|
|
|
|
|
++wc_errors.count;
|
2017-01-27 15:14:25 -07:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Remove the entry at relative position `relative_idx` from the ERR queue.
|
|
|
|
|
* For `relative_idx == 0` it removes the queue's head entry, for -1
|
|
|
|
|
* it removes the last entry in the queue.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
void wc_RemoveErrorNode(int relative_idx)
|
|
|
|
|
{
|
2023-04-03 16:51:07 +10:00
|
|
|
int abs_idx = get_abs_idx(relative_idx);
|
2022-12-07 18:14:45 +01:00
|
|
|
|
|
|
|
|
if (abs_idx >= 0) {
|
2023-04-03 16:51:07 +10:00
|
|
|
size_t move_count;
|
2022-12-07 18:14:45 +01:00
|
|
|
if (abs_idx >= (int)wc_errors.head_idx) {
|
|
|
|
|
/* removed entry sits "above" head (or is head),
|
|
|
|
|
* move entries below it "up" */
|
|
|
|
|
move_count = (abs_idx - (int)wc_errors.head_idx);
|
|
|
|
|
if (move_count > 0) {
|
|
|
|
|
XMEMMOVE(&wc_errors.entries[wc_errors.head_idx + 1],
|
|
|
|
|
&wc_errors.entries[wc_errors.head_idx],
|
|
|
|
|
sizeof(wc_errors.entries[0]) * move_count);
|
|
|
|
|
}
|
|
|
|
|
wc_errors.head_idx = (wc_errors.head_idx + 1) % ERROR_QUEUE_MAX;
|
|
|
|
|
--wc_errors.count;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* removed entry sits "below" head (wrap around),
|
|
|
|
|
* move entries above it "down" */
|
2023-04-03 16:51:07 +10:00
|
|
|
int last_idx = get_abs_idx(-1);
|
2022-12-07 18:14:45 +01:00
|
|
|
if (last_idx >= abs_idx) { /* this SHOULD always be true */
|
|
|
|
|
move_count = (last_idx - abs_idx);
|
|
|
|
|
if (move_count > 0) {
|
|
|
|
|
XMEMMOVE(&wc_errors.entries[abs_idx],
|
|
|
|
|
&wc_errors.entries[abs_idx + 1],
|
|
|
|
|
sizeof(wc_errors.entries[0]) * move_count);
|
|
|
|
|
}
|
|
|
|
|
--wc_errors.count;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Clear the ERR queue.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
void wc_ClearErrorNodes(void)
|
|
|
|
|
{
|
|
|
|
|
if (wc_errors.count > 0) {
|
|
|
|
|
XMEMSET(&wc_errors, 0, sizeof(wc_errors));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_SetLoggingHeap(void* h)
|
|
|
|
|
{
|
|
|
|
|
(void)h;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_ERR_remove_state(void)
|
|
|
|
|
{
|
|
|
|
|
wc_ClearErrorNodes();
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Get the first entry's values in the ERR queue that is not filtered
|
|
|
|
|
* by the provided `ignore_err` callback. All ignored entries are removed,
|
|
|
|
|
* making the returned entry the head of the ERR queue afterwards.
|
|
|
|
|
*
|
|
|
|
|
* In case all entries are ignored, the ERR queue will be empty afterwards.
|
|
|
|
|
* For an empty ERR queue 0 is returned.
|
|
|
|
|
*
|
2022-12-09 10:36:35 -08:00
|
|
|
* `ignore_err` may be NULL, in which case this returns the HEAD values.
|
2022-12-08 09:53:05 +01:00
|
|
|
*
|
|
|
|
|
* `flags` is present for OpenSSL compatibility, but will always be
|
|
|
|
|
* set to 0, since we do not keep flags at ERR entries.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
unsigned long wc_PeekErrorNodeLineData(const char **file, int *line,
|
|
|
|
|
const char **data, int *flags,
|
|
|
|
|
int (*ignore_err)(int err))
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_PeekErrorNodeLineData");
|
|
|
|
|
|
|
|
|
|
/* No data or flags stored - error display only in Nginx. */
|
|
|
|
|
if (data != NULL) {
|
|
|
|
|
*data = "";
|
|
|
|
|
}
|
|
|
|
|
if (flags != NULL) {
|
|
|
|
|
*flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while (1) {
|
2023-04-03 16:51:07 +10:00
|
|
|
int ret = wc_PeekErrorNode(0, file, NULL, line);
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ret == BAD_STATE_E) {
|
|
|
|
|
WOLFSSL_MSG("Issue peeking at error node in queue");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/* OpenSSL uses positive error codes */
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
ret = -ret;
|
|
|
|
|
}
|
|
|
|
|
/* an error that the caller wants to ignore? */
|
|
|
|
|
if (ignore_err && ignore_err(ret)) {
|
|
|
|
|
wc_RemoveErrorNode(0);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (unsigned long)ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-08 09:53:05 +01:00
|
|
|
/**
|
|
|
|
|
* Get the error value at the HEAD of the ERR queue or 0 if the queue
|
|
|
|
|
* is emtpy. The HEAD entry is removed by this call.
|
|
|
|
|
*/
|
2022-12-07 18:14:45 +01:00
|
|
|
unsigned long wc_GetErrorNodeErr(void)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
WOLFSSL_ENTER("wc_GetErrorNodeErr");
|
|
|
|
|
|
|
|
|
|
ret = wc_PullErrorNode(NULL, NULL, NULL);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
if (ret == BAD_STATE_E) {
|
|
|
|
|
ret = 0; /* no errors in queue */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
WOLFSSL_MSG("Error with pulling error node!");
|
|
|
|
|
WOLFSSL_LEAVE("wolfSSL_ERR_get_error", ret);
|
|
|
|
|
ret = 0 - ret; /* return absolute value of error */
|
|
|
|
|
/* panic and try to clear out nodes */
|
|
|
|
|
wc_ClearErrorNodes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
|
|
|
|
/* This callback allows the application to provide a custom error printing
|
|
|
|
|
* function. */
|
|
|
|
|
void wc_ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
|
|
|
|
void *u)
|
|
|
|
|
{
|
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
|
|
WOLFSSL_ENTER("wc_ERR_print_errors_cb");
|
|
|
|
|
|
|
|
|
|
if (cb == NULL) {
|
|
|
|
|
/* Invalid param */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < wc_errors.count; ++i) {
|
2023-04-03 16:51:07 +10:00
|
|
|
struct wc_error_entry *entry = get_entry((int)i);
|
2022-12-07 18:14:45 +01:00
|
|
|
if (entry == NULL)
|
|
|
|
|
break;
|
|
|
|
|
cb(entry->reason, XSTRLEN(entry->reason), u);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
wc_ClearErrorNodes();
|
|
|
|
|
}
|
|
|
|
|
#endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */
|
|
|
|
|
|
|
|
|
|
#else /* ERROR_QUEUE_PER_THREAD */
|
|
|
|
|
/* Error queue is a global list. This is the original implementation and
|
|
|
|
|
* the fallback on platforms that do not have thread-local-storage.
|
|
|
|
|
*
|
|
|
|
|
* Access and manipulations of the list are protected by a mutex, however
|
|
|
|
|
* that does not prevent errors from another thread showing up. Therefore,
|
|
|
|
|
* its usefulness is limited to applications with restricted thread
|
|
|
|
|
* concurrency in using wolfSSL.
|
|
|
|
|
*/
|
|
|
|
|
#ifndef ERROR_QUEUE_MAX
|
|
|
|
|
/* With a global list, we allow a higher limit. */
|
|
|
|
|
#define ERROR_QUEUE_MAX 100
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* The information we keep about a single error */
|
|
|
|
|
struct wc_error_queue {
|
|
|
|
|
void* heap; /* the heap hint used with nodes creation */
|
|
|
|
|
struct wc_error_queue* next;
|
|
|
|
|
struct wc_error_queue* prev;
|
|
|
|
|
char error[WOLFSSL_MAX_ERROR_SZ];
|
|
|
|
|
char file[WOLFSSL_MAX_ERROR_SZ];
|
|
|
|
|
int value;
|
|
|
|
|
int line;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/* The global list of errors encountered */
|
|
|
|
|
static struct wc_error_queue* wc_errors;
|
|
|
|
|
static int wc_errors_count = 0;
|
|
|
|
|
/* pointer to last node in queue to make insertion O(1) */
|
|
|
|
|
static struct wc_error_queue* wc_last_node;
|
|
|
|
|
/* The 'current' cursor the application is using to access the list */
|
|
|
|
|
static struct wc_error_queue* wc_current_node;
|
|
|
|
|
|
|
|
|
|
/* heap info currently used for allocation of entries */
|
|
|
|
|
static void* wc_error_heap;
|
|
|
|
|
|
|
|
|
|
/* mutex for list operation protection */
|
|
|
|
|
static wolfSSL_Mutex wc_error_mutex;
|
|
|
|
|
#define ERRQ_MUTEX_INIT() wc_InitMutex(&wc_error_mutex)
|
|
|
|
|
#define ERRQ_MUTEX_FREE() wc_FreeMutex(&wc_error_mutex)
|
|
|
|
|
#define ERRQ_LOCK() wc_LockMutex(&wc_error_mutex)
|
|
|
|
|
#define ERRQ_UNLOCK() wc_UnLockMutex(&wc_error_mutex)
|
|
|
|
|
|
|
|
|
|
/* Internal function that is called by wolfCrypt_Init() */
|
|
|
|
|
int wc_LoggingInit(void)
|
|
|
|
|
{
|
|
|
|
|
if (ERRQ_MUTEX_INIT() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Bad Init Mutex");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
wc_errors_count = 0;
|
|
|
|
|
wc_errors = NULL;
|
|
|
|
|
wc_current_node = NULL;
|
|
|
|
|
wc_last_node = NULL;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* internal function that is called by wolfCrypt_Cleanup */
|
|
|
|
|
int wc_LoggingCleanup(void)
|
|
|
|
|
{
|
|
|
|
|
/* clear logging entries */
|
|
|
|
|
wc_ClearErrorNodes();
|
|
|
|
|
/* free mutex */
|
|
|
|
|
if (ERRQ_MUTEX_FREE() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Bad Mutex free");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int peekErrorNode(int idx, const char **file, const char **reason,
|
|
|
|
|
int *line)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_queue* err;
|
|
|
|
|
|
|
|
|
|
if (idx < 0) {
|
|
|
|
|
err = wc_last_node;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
err = (struct wc_error_queue*)wc_errors;
|
|
|
|
|
for (i = 0; i < idx; i++) {
|
|
|
|
|
if (err == NULL) {
|
|
|
|
|
WOLFSSL_MSG("Error node not found. Bad index?");
|
|
|
|
|
return BAD_FUNC_ARG;
|
|
|
|
|
}
|
|
|
|
|
err = err->next;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (err == NULL) {
|
|
|
|
|
WOLFSSL_MSG("No Errors in queue");
|
|
|
|
|
return BAD_STATE_E;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file != NULL) {
|
|
|
|
|
*file = err->file;
|
|
|
|
|
}
|
|
|
|
|
if (reason != NULL) {
|
|
|
|
|
*reason = err->error;
|
|
|
|
|
}
|
|
|
|
|
if (line != NULL) {
|
|
|
|
|
*line = err->line;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return err->value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* peek at an error node
|
|
|
|
|
*
|
|
|
|
|
* idx : if -1 then the most recent node is looked at,
|
|
|
|
|
* otherwise search through queue for node at the given index starting
|
|
|
|
|
* from the absolute head wc_errors
|
|
|
|
|
* file : pointer to internal file string
|
|
|
|
|
* reason : pointer to internal error reason
|
|
|
|
|
* line : line number that error happened at
|
|
|
|
|
*
|
|
|
|
|
* Returns a negative value in error case, on success returns the nodes error
|
|
|
|
|
* value which is positive (absolute value)
|
|
|
|
|
*/
|
|
|
|
|
int wc_PeekErrorNode(int idx, const char **file, const char **reason,
|
|
|
|
|
int *line)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
ret = peekErrorNode(idx, file, reason, line);
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static int pullErrorNode(const char **file, const char **reason, int *line)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_queue* err;
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
err = wc_current_node;
|
|
|
|
|
if (err == NULL) {
|
|
|
|
|
WOLFSSL_MSG("No Errors in queue");
|
|
|
|
|
return BAD_STATE_E;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (file != NULL) {
|
|
|
|
|
*file = err->file;
|
|
|
|
|
}
|
|
|
|
|
if (reason != NULL) {
|
|
|
|
|
*reason = err->error;
|
|
|
|
|
}
|
|
|
|
|
if (line != NULL) {
|
|
|
|
|
*line = err->line;
|
|
|
|
|
}
|
|
|
|
|
value = err->value;
|
|
|
|
|
wc_current_node = err->next;
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Pulls the current node from error queue and increments current state.
|
|
|
|
|
* Note: this does not delete nodes because input arguments are pointing to
|
|
|
|
|
* node buffers.
|
|
|
|
|
*
|
|
|
|
|
* file pointer to file that error was in. Can be NULL to return no file.
|
|
|
|
|
* reason error string giving reason for error. Can be NULL to return no reason.
|
|
|
|
|
* line return line number of where error happened.
|
|
|
|
|
*
|
|
|
|
|
* returns the error value on success and BAD_MUTEX_E or BAD_STATE_E on failure
|
|
|
|
|
*/
|
|
|
|
|
int wc_PullErrorNode(const char **file, const char **reason, int *line)
|
|
|
|
|
{
|
|
|
|
|
int value;
|
|
|
|
|
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
value = pullErrorNode(file, reason, line);
|
|
|
|
|
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* create new error node and add it to the queue
|
|
|
|
|
* buffers are assumed to be of size WOLFSSL_MAX_ERROR_SZ for this internal
|
|
|
|
|
* function. */
|
|
|
|
|
int wc_AddErrorNode(int error, int line, char* buf, char* file)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_queue* err;
|
|
|
|
|
|
|
|
|
|
if (wc_errors_count >= ERROR_QUEUE_MAX) {
|
|
|
|
|
WOLFSSL_MSG("Error queue is full, at ERROR_QUEUE_MAX");
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
err = (struct wc_error_queue*)XMALLOC(
|
|
|
|
|
sizeof(struct wc_error_queue), wc_error_heap, DYNAMIC_TYPE_LOG);
|
|
|
|
|
if (err == NULL) {
|
|
|
|
|
WOLFSSL_MSG("Unable to create error node for log");
|
|
|
|
|
return MEMORY_E;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int sz;
|
|
|
|
|
|
|
|
|
|
XMEMSET(err, 0, sizeof(struct wc_error_queue));
|
|
|
|
|
err->heap = wc_error_heap;
|
|
|
|
|
sz = (int)XSTRLEN(buf);
|
|
|
|
|
if (sz > WOLFSSL_MAX_ERROR_SZ - 1) {
|
|
|
|
|
sz = WOLFSSL_MAX_ERROR_SZ - 1;
|
2017-01-27 15:14:25 -07:00
|
|
|
}
|
|
|
|
|
if (sz > 0) {
|
|
|
|
|
XMEMCPY(err->error, buf, sz);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sz = (int)XSTRLEN(file);
|
|
|
|
|
if (sz > WOLFSSL_MAX_ERROR_SZ - 1) {
|
|
|
|
|
sz = WOLFSSL_MAX_ERROR_SZ - 1;
|
|
|
|
|
}
|
|
|
|
|
if (sz > 0) {
|
|
|
|
|
XMEMCPY(err->file, file, sz);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-06 14:29:16 -07:00
|
|
|
err->value = error;
|
|
|
|
|
err->line = line;
|
|
|
|
|
|
|
|
|
|
/* make sure is terminated */
|
|
|
|
|
err->error[WOLFSSL_MAX_ERROR_SZ - 1] = '\0';
|
|
|
|
|
err->file[WOLFSSL_MAX_ERROR_SZ - 1] = '\0';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* since is queue place new node at last of the list */
|
|
|
|
|
if (wc_last_node == NULL) {
|
|
|
|
|
/* case of first node added to queue */
|
|
|
|
|
if (wc_errors != NULL) {
|
|
|
|
|
/* check for unexpected case before over writing wc_errors */
|
2021-12-16 13:30:43 -07:00
|
|
|
WOLFSSL_MSG("ERROR in adding new node to logging queue!!");
|
2018-07-29 06:46:07 -06:00
|
|
|
/* In the event both wc_last_node and wc_errors are NULL, err
|
|
|
|
|
* goes unassigned to external wc_errors, wc_last_node. Free
|
|
|
|
|
* err in this instance since wc_ClearErrorNodes will not
|
|
|
|
|
*/
|
|
|
|
|
XFREE(err, wc_error_heap, DYNAMIC_TYPE_LOG);
|
2017-01-06 14:29:16 -07:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wc_errors = err;
|
|
|
|
|
wc_last_node = err;
|
2017-02-24 09:33:04 -07:00
|
|
|
wc_current_node = err;
|
2017-01-06 14:29:16 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
wc_last_node->next = err;
|
2017-02-09 16:28:32 +10:00
|
|
|
err->prev = wc_last_node;
|
2017-01-06 14:29:16 -07:00
|
|
|
wc_last_node = err;
|
2017-02-24 09:33:04 -07:00
|
|
|
|
|
|
|
|
/* check the case where have read to the end of the queue and the
|
|
|
|
|
* current node to read needs updated */
|
|
|
|
|
if (wc_current_node == NULL) {
|
|
|
|
|
wc_current_node = err;
|
|
|
|
|
}
|
2017-01-06 14:29:16 -07:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
wc_errors_count++;
|
2017-01-06 14:29:16 -07:00
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2017-02-09 16:28:32 +10:00
|
|
|
|
2022-11-22 11:22:38 -07:00
|
|
|
/* returns the current index into the queue, which is the node that
|
|
|
|
|
* wc_current_node is pointing to. It can be greater than zero in cases
|
|
|
|
|
* where wc_PullErrorNode() has been called without the node having been
|
|
|
|
|
* removed. */
|
2022-12-07 18:14:45 +01:00
|
|
|
static int getErrorNodeCurrentIdx(void)
|
2022-11-17 14:51:37 -08:00
|
|
|
{
|
|
|
|
|
int ret = 0;
|
|
|
|
|
struct wc_error_queue* current;
|
|
|
|
|
|
|
|
|
|
current = (struct wc_error_queue*)wc_errors;
|
|
|
|
|
while (current != wc_current_node && current != NULL) {
|
|
|
|
|
current = current->next;
|
|
|
|
|
ret++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* wc_current_node was not found in the list! use index 0 */
|
|
|
|
|
if (current == NULL) {
|
|
|
|
|
ret = 0;
|
|
|
|
|
}
|
|
|
|
|
return ret;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
static void removeErrorNode(int idx)
|
2017-02-09 16:28:32 +10:00
|
|
|
{
|
|
|
|
|
struct wc_error_queue* current;
|
|
|
|
|
|
2022-11-17 14:51:37 -08:00
|
|
|
if (idx == -1) {
|
2017-02-09 16:28:32 +10:00
|
|
|
current = wc_last_node;
|
2022-11-17 14:51:37 -08:00
|
|
|
}
|
2017-02-09 16:28:32 +10:00
|
|
|
else {
|
|
|
|
|
current = (struct wc_error_queue*)wc_errors;
|
2017-04-28 17:57:48 -06:00
|
|
|
for (; current != NULL && idx > 0; idx--)
|
2017-02-09 16:28:32 +10:00
|
|
|
current = current->next;
|
|
|
|
|
}
|
|
|
|
|
if (current != NULL) {
|
|
|
|
|
if (current->prev != NULL)
|
|
|
|
|
current->prev->next = current->next;
|
Add Apache HTTP Server compatibility and --enable-apachehttpd option (#2466)
* Added Apache httpd support `--enable-apachehttpd`.
* Added `SSL_CIPHER_get_version`, `BIO_new_fp`, `SSL_SESSION_print` and `SSL_in_connect_init` compatibility API's.
* Fix to expose `ASN1_UTCTIME_print` stub.
* Pulled in `wolfSSL_X509_get_ext_count` from QT.
* Added `X509_get_ext_count`, `BIO_set_callback`, `BIO_set_callback_arg` and `BIO_get_callback_arg`.
* Added `wolfSSL_ERR_print_errors`.
* Added `BIO_set_nbio` template.
* Fixes for building with Apache httpd.
* Added DH prime functions required for Apache httpd.
* Fix and move the BN DH prime macros.
* Fix for `SSL_CTX_set_tlsext_servername_arg` to have return code.
* Only add the `BN_get_rfc*_prime_*` macro's if older than 1.1.0.
* Added `ERR_GET_FUNC`, `SSL_CTX_clear_extra_chain_certs` prototypes.
* Added `wolfSSL_CTX_set_client_cert_cb` template and `OPENSSL_load_builtin_modules` stub macro.
* Added `X509_INFO` templates (`X509_INFO_new`, `X509_INFO_free`, `sk_X509_INFO_new_null`, `sk_X509_INFO_num`, `sk_X509_INFO_value`, `sk_X509_INFO_free`). Added `sk_X509_shift`.
* Added BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg
* add BIO_set_nbio, ERR_print_errors and tests
* add X509 INFO stack push function
* Add ASN1_UTCTIME_print and unit test
* Add X509_get_ext_count unit test
* initial commit of wolfSSL_PEM_X509_INFO_read_bio
* Added `sk_X509_NAME_new`, `sk_X509_NAME_push`, `sk_X509_NAME_find`, `sk_X509_NAME_set_cmp_func` and `sk_X509_NAME_free`. Grouped `sk_X509_NAME_*` functions.
* Cleanup sk X509 NAME/INFO pop free template.
* Advance openssl compatibility to v1.1.0 for Apache httpd. Added TLS version macros. Implemented sk X509 NAME/INFO pop and pop_free.
* Added `TLS_client_method` support.
* Added `SSL_get_server_tmp_key` and `EC_curve_nid2nist`.
* Added `SSL_CTX_set_min_proto_version` and `SSL_CTX_set_max_proto_version`. Fix for `BN_get_rfc*_prime_*` with the v1.1.0 change.
* add test cases for PEM_X509_INFO_read_bio
* Fixes for `BN_get_rfc*_prime_*` macros. Added template for `SSL_DH_set0_pqg`. Fix for `SSL_OP_NO_` to use Macro's (as is done in openssl). Added `SSL_set_verify_result`. Added stub for `OPENSSL_malloc_init`.
* Apache httpd compatibility functions. BIO setter/getters.
* implement ASN1_TIME_check and add test case
* add SSL_get_client_CA_list
* add initial implementation of wolfSSL_DH_set0_pqg
* Add apache support to OBJ_txt2nid and unit test, add stub for OBJ_create
* add X509_STORE_CTX_get1_chain, sk_free, sk_X509_dup
* Add sk_SSL_COMP_num and SSL_COMP struct
* implement and test of SSL_SESSION_print
* add SSL_CTX_set_client_cert_cb
* expand BIO_printf and add test case
* Added `OCSP_CERTID_dup`. Added `ASN1_TYPE`.
* add implementation for wolfSSL_get_server_tmp_key
* add wolfSSL_BIO_puts and test case
* Add X509_EXTENSION_get_object and X509_EXTENSION_get_data
* add helper for bio flag set and null x509 stack
* add test adn implementation for wolfSSL_i2d_PrivateKey
* Added `ASN1_OTHERNAME`, `ACCESS_DESCRIPTION` and `GENERAL_NAME`. Added `sk_ACCESS_DESCRIPTION_pop_free` and `ACCESS_DESCRIPTION_free` stubs.
* add wolfSSL_PEM_read_bio_ECPKParameters
* add BIO_vfree
* add X509_up_ref
* add X509_STORE_CTX_set_ex_data
* add _GNU_SOURCE macro and wolfSSL_EVP_read_pw_string
* add wolfSSL_EVP_PKEY_ref_up function
* X509_get_ext, X509V3_EXT_print, and d2i_DISPLAYTEXT stubs
* add X509_set_issuer_name
* add wolfSSL_sk_SSL_CIPHER_* functions and tests
* add prototype for sk_X509_EXTENSION and ACCESS_DESCRIPTION
* fix casting to avoid clang warning
* adjust test_wolfSSL_X509_STORE_CTX test case
* Added `OpenSSL_version`
* renegotiate functions and additional stack functions
* add aditional stub functions
* Add Apache httpd requirements for ALPN, CRL, Cert Gen/Req/Ext and SecRen. Fix for `sk_X509_INFO_new_null`.
* add ocsp stub functions
* Proper fix for `sk_X509_INFO_new_null`. Added templates for `X509_get_ext_by_NID` and `X509_add_ext`. Added templates for `ASN1_TIME_diff` and `ASN1_TIME_set`.
* x509 extension stack additions
* Fixed template for `OCSP_id_get0_info`.
* add X509 stub functions
* add X509_STORE_CTX_get0_store() and unit test
* Added `EVP_PKEY_CTX_new_id`, `EVP_PKEY_CTX_set_rsa_keygen_bits`, `EVP_PKEY_keygen_init`, `EVP_PKEY_keygen` and `BN_to_ASN1_INTEGER`.
* x509v3 stubs and req add extensions
* Add OBJ_txt2obj and unit test; add long name to wolfssl_object_info table for use by OBJ_* functions
* wolfSSL_set_alpn_protos implementation
* Added `EVP_SignInit_ex` and `TLS_server_method` implementation. Added stubs for `RSA_get0_key` and `i2d_OCSP_REQUEST_bio`. Fix typo on `OCSP_response_create`. Fix warning in `wolfSSL_set_alpn_protos`.
* Added `X509_EXTENSION_free` stub. Fixed a few macro typos/adding missing.
* add X509_STORE_CTX_get0_current_issuer and unit test
* add OBJ_cmp and unit test
* add RSA_get0_key and unit test
* add OCSP_check_nonce
* Implement X509_set_notAfter/notBefore/serialNumber/version,X509_STORE_CTX_set_depth,X509V3_set_ctx.
* Modify wolfSSL_X509_set_notAfter/notBefore and add tests for each.
* Add test_wolfSSL_X509_set_version w/ fixes to _set_version and fix _set_notBefore/notAfter tests
* add OCSP_id_get0_info and unit test, move WOLFSSL_ASN1_INTEGER to asn_public.h from ssl.h
* inital implementation of wolfSSL_X509_sign
* add debugging messages and set data for BIO's
* Add i2d_OCSP_REQUEST_bio.
* implementation of some WOLFSSL_BIO_METHOD custom functions
* fix for ASN time structure and remove log node
* initial eNULL support and sanity checks
* fixes after rebasing code
* adjust test cases and ASN1_TIME print
* Various fixes for memory leaks
* Apache compatibility in CTX_set_client_CA_list for X509_NAME use; add X509_NAME_dup as supporting function
* Add initial X509_STORE_load_locations stub for Apache
* Updates to X509_get_ext_d2i to return GENERAL_NAME struct instead of ASN1_OBJECT for alternative names and add supporting GENERAL_NAME functions
* Add X509_STORE_load_locations implementation; add wolfSSL_CertManagerLoadCRL_ex; initial renegotiation fixes/updates
* Fix for freeing peer cert in wolfSSL_Rehandshake instead of FreeHandShakeResources during secure renegotiation
* Add X509_ALGOR and X509_PUBKEY structs for X509_PUBKEY_get0_param and X509_get_X509_PUBKEY implementation
* Initial implementation of wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Add implementation for X509_get0_tbs_sigalg and X509_ALGOR_get0
* Add OBJ_nid2ln implementation
* Fix compile errors in tests/api.c for some build options
* Updates to X509_STORE_load_locations for non-CRL types; Add additional DETECT_CERT_TYPE enum and logic for detecting certificate type in ProcessFile
* Add X509_STORE_load_locations unit test and minor error handling fixes
* Add unit test for X509_sign
* Set correct alert type for revoked certificates; add/fix a few WOLFSSL_ENTER messages
* Add X509_ALGOR member to X509 struct; refactoring and unit tests for wolfSSL_X509_ALGOR_get0 and wolfSSL_X509_get0_tbs_sigalg
* Add X509_PUBKEY member to X509 struct; refactoring and unit tests for wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Stack fixes after rebase
* Secure renegotiation refactoring: add ACCEPT_BEGIN_RENEG to AcceptState for use in wolfSSL_SSL_in_connect_init; free old peer cert when receiving new cert to fix memory leak
* Move enc-then-mac enable option in configure.ac for apache httpd compatibility
* Simplify wolfSSL_SSL_in_connect_init logic
* Remove unneeded wolfSSL_CertManagerLoadCRL_ex
* Fixes for jenkins test failures
* SSL_get_secure_renegotiation_support for print statement in Apache
2019-09-19 18:11:10 -06:00
|
|
|
if (current->next != NULL)
|
|
|
|
|
current->next->prev = current->prev;
|
2017-02-09 16:28:32 +10:00
|
|
|
if (wc_last_node == current)
|
|
|
|
|
wc_last_node = current->prev;
|
|
|
|
|
if (wc_errors == current)
|
|
|
|
|
wc_errors = current->next;
|
Add Apache HTTP Server compatibility and --enable-apachehttpd option (#2466)
* Added Apache httpd support `--enable-apachehttpd`.
* Added `SSL_CIPHER_get_version`, `BIO_new_fp`, `SSL_SESSION_print` and `SSL_in_connect_init` compatibility API's.
* Fix to expose `ASN1_UTCTIME_print` stub.
* Pulled in `wolfSSL_X509_get_ext_count` from QT.
* Added `X509_get_ext_count`, `BIO_set_callback`, `BIO_set_callback_arg` and `BIO_get_callback_arg`.
* Added `wolfSSL_ERR_print_errors`.
* Added `BIO_set_nbio` template.
* Fixes for building with Apache httpd.
* Added DH prime functions required for Apache httpd.
* Fix and move the BN DH prime macros.
* Fix for `SSL_CTX_set_tlsext_servername_arg` to have return code.
* Only add the `BN_get_rfc*_prime_*` macro's if older than 1.1.0.
* Added `ERR_GET_FUNC`, `SSL_CTX_clear_extra_chain_certs` prototypes.
* Added `wolfSSL_CTX_set_client_cert_cb` template and `OPENSSL_load_builtin_modules` stub macro.
* Added `X509_INFO` templates (`X509_INFO_new`, `X509_INFO_free`, `sk_X509_INFO_new_null`, `sk_X509_INFO_num`, `sk_X509_INFO_value`, `sk_X509_INFO_free`). Added `sk_X509_shift`.
* Added BIO_set_callback, BIO_get_callback, BIO_set_callback_arg, BIO_get_callback_arg
* add BIO_set_nbio, ERR_print_errors and tests
* add X509 INFO stack push function
* Add ASN1_UTCTIME_print and unit test
* Add X509_get_ext_count unit test
* initial commit of wolfSSL_PEM_X509_INFO_read_bio
* Added `sk_X509_NAME_new`, `sk_X509_NAME_push`, `sk_X509_NAME_find`, `sk_X509_NAME_set_cmp_func` and `sk_X509_NAME_free`. Grouped `sk_X509_NAME_*` functions.
* Cleanup sk X509 NAME/INFO pop free template.
* Advance openssl compatibility to v1.1.0 for Apache httpd. Added TLS version macros. Implemented sk X509 NAME/INFO pop and pop_free.
* Added `TLS_client_method` support.
* Added `SSL_get_server_tmp_key` and `EC_curve_nid2nist`.
* Added `SSL_CTX_set_min_proto_version` and `SSL_CTX_set_max_proto_version`. Fix for `BN_get_rfc*_prime_*` with the v1.1.0 change.
* add test cases for PEM_X509_INFO_read_bio
* Fixes for `BN_get_rfc*_prime_*` macros. Added template for `SSL_DH_set0_pqg`. Fix for `SSL_OP_NO_` to use Macro's (as is done in openssl). Added `SSL_set_verify_result`. Added stub for `OPENSSL_malloc_init`.
* Apache httpd compatibility functions. BIO setter/getters.
* implement ASN1_TIME_check and add test case
* add SSL_get_client_CA_list
* add initial implementation of wolfSSL_DH_set0_pqg
* Add apache support to OBJ_txt2nid and unit test, add stub for OBJ_create
* add X509_STORE_CTX_get1_chain, sk_free, sk_X509_dup
* Add sk_SSL_COMP_num and SSL_COMP struct
* implement and test of SSL_SESSION_print
* add SSL_CTX_set_client_cert_cb
* expand BIO_printf and add test case
* Added `OCSP_CERTID_dup`. Added `ASN1_TYPE`.
* add implementation for wolfSSL_get_server_tmp_key
* add wolfSSL_BIO_puts and test case
* Add X509_EXTENSION_get_object and X509_EXTENSION_get_data
* add helper for bio flag set and null x509 stack
* add test adn implementation for wolfSSL_i2d_PrivateKey
* Added `ASN1_OTHERNAME`, `ACCESS_DESCRIPTION` and `GENERAL_NAME`. Added `sk_ACCESS_DESCRIPTION_pop_free` and `ACCESS_DESCRIPTION_free` stubs.
* add wolfSSL_PEM_read_bio_ECPKParameters
* add BIO_vfree
* add X509_up_ref
* add X509_STORE_CTX_set_ex_data
* add _GNU_SOURCE macro and wolfSSL_EVP_read_pw_string
* add wolfSSL_EVP_PKEY_ref_up function
* X509_get_ext, X509V3_EXT_print, and d2i_DISPLAYTEXT stubs
* add X509_set_issuer_name
* add wolfSSL_sk_SSL_CIPHER_* functions and tests
* add prototype for sk_X509_EXTENSION and ACCESS_DESCRIPTION
* fix casting to avoid clang warning
* adjust test_wolfSSL_X509_STORE_CTX test case
* Added `OpenSSL_version`
* renegotiate functions and additional stack functions
* add aditional stub functions
* Add Apache httpd requirements for ALPN, CRL, Cert Gen/Req/Ext and SecRen. Fix for `sk_X509_INFO_new_null`.
* add ocsp stub functions
* Proper fix for `sk_X509_INFO_new_null`. Added templates for `X509_get_ext_by_NID` and `X509_add_ext`. Added templates for `ASN1_TIME_diff` and `ASN1_TIME_set`.
* x509 extension stack additions
* Fixed template for `OCSP_id_get0_info`.
* add X509 stub functions
* add X509_STORE_CTX_get0_store() and unit test
* Added `EVP_PKEY_CTX_new_id`, `EVP_PKEY_CTX_set_rsa_keygen_bits`, `EVP_PKEY_keygen_init`, `EVP_PKEY_keygen` and `BN_to_ASN1_INTEGER`.
* x509v3 stubs and req add extensions
* Add OBJ_txt2obj and unit test; add long name to wolfssl_object_info table for use by OBJ_* functions
* wolfSSL_set_alpn_protos implementation
* Added `EVP_SignInit_ex` and `TLS_server_method` implementation. Added stubs for `RSA_get0_key` and `i2d_OCSP_REQUEST_bio`. Fix typo on `OCSP_response_create`. Fix warning in `wolfSSL_set_alpn_protos`.
* Added `X509_EXTENSION_free` stub. Fixed a few macro typos/adding missing.
* add X509_STORE_CTX_get0_current_issuer and unit test
* add OBJ_cmp and unit test
* add RSA_get0_key and unit test
* add OCSP_check_nonce
* Implement X509_set_notAfter/notBefore/serialNumber/version,X509_STORE_CTX_set_depth,X509V3_set_ctx.
* Modify wolfSSL_X509_set_notAfter/notBefore and add tests for each.
* Add test_wolfSSL_X509_set_version w/ fixes to _set_version and fix _set_notBefore/notAfter tests
* add OCSP_id_get0_info and unit test, move WOLFSSL_ASN1_INTEGER to asn_public.h from ssl.h
* inital implementation of wolfSSL_X509_sign
* add debugging messages and set data for BIO's
* Add i2d_OCSP_REQUEST_bio.
* implementation of some WOLFSSL_BIO_METHOD custom functions
* fix for ASN time structure and remove log node
* initial eNULL support and sanity checks
* fixes after rebasing code
* adjust test cases and ASN1_TIME print
* Various fixes for memory leaks
* Apache compatibility in CTX_set_client_CA_list for X509_NAME use; add X509_NAME_dup as supporting function
* Add initial X509_STORE_load_locations stub for Apache
* Updates to X509_get_ext_d2i to return GENERAL_NAME struct instead of ASN1_OBJECT for alternative names and add supporting GENERAL_NAME functions
* Add X509_STORE_load_locations implementation; add wolfSSL_CertManagerLoadCRL_ex; initial renegotiation fixes/updates
* Fix for freeing peer cert in wolfSSL_Rehandshake instead of FreeHandShakeResources during secure renegotiation
* Add X509_ALGOR and X509_PUBKEY structs for X509_PUBKEY_get0_param and X509_get_X509_PUBKEY implementation
* Initial implementation of wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Add implementation for X509_get0_tbs_sigalg and X509_ALGOR_get0
* Add OBJ_nid2ln implementation
* Fix compile errors in tests/api.c for some build options
* Updates to X509_STORE_load_locations for non-CRL types; Add additional DETECT_CERT_TYPE enum and logic for detecting certificate type in ProcessFile
* Add X509_STORE_load_locations unit test and minor error handling fixes
* Add unit test for X509_sign
* Set correct alert type for revoked certificates; add/fix a few WOLFSSL_ENTER messages
* Add X509_ALGOR member to X509 struct; refactoring and unit tests for wolfSSL_X509_ALGOR_get0 and wolfSSL_X509_get0_tbs_sigalg
* Add X509_PUBKEY member to X509 struct; refactoring and unit tests for wolfSSL_X509_get_X509_PUBKEY and wolfSSL_X509_PUBKEY_get0_param
* Stack fixes after rebase
* Secure renegotiation refactoring: add ACCEPT_BEGIN_RENEG to AcceptState for use in wolfSSL_SSL_in_connect_init; free old peer cert when receiving new cert to fix memory leak
* Move enc-then-mac enable option in configure.ac for apache httpd compatibility
* Simplify wolfSSL_SSL_in_connect_init logic
* Remove unneeded wolfSSL_CertManagerLoadCRL_ex
* Fixes for jenkins test failures
* SSL_get_secure_renegotiation_support for print statement in Apache
2019-09-19 18:11:10 -06:00
|
|
|
if (wc_current_node == current)
|
|
|
|
|
wc_current_node = current->next;
|
2017-02-09 16:28:32 +10:00
|
|
|
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
2022-12-07 18:14:45 +01:00
|
|
|
wc_errors_count--;
|
2022-11-17 14:51:37 -08:00
|
|
|
|
|
|
|
|
/* last node left in list was free'd, reset list head */
|
2022-12-07 18:14:45 +01:00
|
|
|
if (wc_errors_count == 0) {
|
2022-11-17 14:51:37 -08:00
|
|
|
wc_errors = NULL;
|
|
|
|
|
wc_last_node = NULL;
|
|
|
|
|
wc_current_node = NULL;
|
|
|
|
|
}
|
2017-02-09 16:28:32 +10:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Removes the error node at the specified index.
|
|
|
|
|
* idx : if -1 then the most recent node is looked at,
|
|
|
|
|
* otherwise search through queue for node at the given index starting
|
|
|
|
|
* from the absolute head wc_errors
|
|
|
|
|
*/
|
|
|
|
|
void wc_RemoveErrorNode(int idx)
|
|
|
|
|
{
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
removeErrorNode(idx);
|
|
|
|
|
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void clearErrorNodes(void)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_queue* current;
|
|
|
|
|
struct wc_error_queue* next;
|
|
|
|
|
/* free all nodes from error queue (even previously 'pulled' ones) starting
|
|
|
|
|
* at the lists absolute head of wc_errors */
|
|
|
|
|
|
|
|
|
|
current = (struct wc_error_queue*)wc_errors;
|
|
|
|
|
while (current != NULL) {
|
|
|
|
|
next = current->next;
|
|
|
|
|
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
|
|
|
|
current = next;
|
|
|
|
|
}
|
2017-02-09 16:28:32 +10:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
wc_errors_count = 0;
|
|
|
|
|
wc_errors = NULL;
|
|
|
|
|
wc_last_node = NULL;
|
|
|
|
|
wc_current_node = NULL;
|
2017-02-09 16:28:32 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Clears out the list of error nodes.
|
|
|
|
|
*/
|
|
|
|
|
void wc_ClearErrorNodes(void)
|
|
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ERRQ_LOCK() != 0) {
|
2017-02-09 16:28:32 +10:00
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
clearErrorNodes();
|
2017-02-09 16:28:32 +10:00
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
ERRQ_UNLOCK();
|
2017-02-09 16:28:32 +10:00
|
|
|
}
|
2017-01-06 14:29:16 -07:00
|
|
|
|
|
|
|
|
int wc_SetLoggingHeap(void* h)
|
|
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ERRQ_LOCK() != 0) {
|
2017-01-06 14:29:16 -07:00
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
wc_error_heap = h;
|
2022-12-07 18:14:45 +01:00
|
|
|
ERRQ_UNLOCK();
|
2017-01-06 14:29:16 -07:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2017-03-08 13:50:38 -07:00
|
|
|
/* frees all nodes in the queue
|
|
|
|
|
*
|
|
|
|
|
* id this is the thread id
|
|
|
|
|
*/
|
|
|
|
|
int wc_ERR_remove_state(void)
|
|
|
|
|
{
|
|
|
|
|
struct wc_error_queue* current;
|
|
|
|
|
struct wc_error_queue* next;
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ERRQ_LOCK() != 0) {
|
2017-03-08 13:50:38 -07:00
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
return BAD_MUTEX_E;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* free all nodes from error queue */
|
|
|
|
|
current = (struct wc_error_queue*)wc_errors;
|
|
|
|
|
while (current != NULL) {
|
|
|
|
|
next = current->next;
|
|
|
|
|
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
|
|
|
|
current = next;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
wc_errors_count = 0;
|
2017-03-08 13:50:38 -07:00
|
|
|
wc_errors = NULL;
|
|
|
|
|
wc_last_node = NULL;
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
ERRQ_UNLOCK();
|
2017-03-08 13:50:38 -07:00
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
unsigned long wc_PeekErrorNodeLineData(const char **file, int *line,
|
|
|
|
|
const char **data, int *flags,
|
|
|
|
|
int (*ignore_err)(int err))
|
2017-01-06 14:29:16 -07:00
|
|
|
{
|
2022-12-07 18:14:45 +01:00
|
|
|
int idx;
|
|
|
|
|
|
|
|
|
|
WOLFSSL_ENTER("wc_PeekErrorNodeLineData");
|
|
|
|
|
|
|
|
|
|
/* No data or flags stored - error display only in Nginx. */
|
|
|
|
|
if (data != NULL) {
|
|
|
|
|
*data = "";
|
|
|
|
|
}
|
|
|
|
|
if (flags != NULL) {
|
|
|
|
|
*flags = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
2023-03-15 07:46:22 -05:00
|
|
|
return (unsigned long)(0 - BAD_MUTEX_E);
|
2022-12-07 18:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
idx = getErrorNodeCurrentIdx();
|
|
|
|
|
while (1) {
|
2023-04-03 16:51:07 +10:00
|
|
|
int ret = peekErrorNode(idx, file, NULL, line);
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ret == BAD_MUTEX_E || ret == BAD_FUNC_ARG || ret == BAD_STATE_E) {
|
2023-04-28 16:35:49 -07:00
|
|
|
ERRQ_UNLOCK();
|
2022-12-07 18:14:45 +01:00
|
|
|
WOLFSSL_MSG("Issue peeking at error node in queue");
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
/* OpenSSL uses positive error codes */
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
ret = -ret;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ignore_err && ignore_err(ret)) {
|
|
|
|
|
removeErrorNode(idx);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
return (unsigned long)ret;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long wc_GetErrorNodeErr(void)
|
|
|
|
|
{
|
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
|
|
WOLFSSL_ENTER("wc_GetErrorNodeErr");
|
|
|
|
|
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
2023-03-15 07:46:22 -05:00
|
|
|
return (unsigned long)(0 - BAD_MUTEX_E);
|
2022-12-07 18:14:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ret = pullErrorNode(NULL, NULL, NULL);
|
|
|
|
|
if (ret < 0) {
|
|
|
|
|
if (ret == BAD_STATE_E) {
|
|
|
|
|
ret = 0; /* no errors in queue */
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
WOLFSSL_MSG("Error with pulling error node!");
|
|
|
|
|
WOLFSSL_LEAVE("wolfSSL_ERR_get_error", ret);
|
|
|
|
|
ret = 0 - ret; /* return absolute value of error */
|
|
|
|
|
/* panic and try to clear out nodes */
|
|
|
|
|
clearErrorNodes();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
int idx = getErrorNodeCurrentIdx();
|
|
|
|
|
if (idx < 0) {
|
|
|
|
|
WOLFSSL_MSG("Error with getting current index!");
|
|
|
|
|
ret = BAD_STATE_E;
|
|
|
|
|
WOLFSSL_LEAVE("wolfSSL_ERR_get_error", ret);
|
|
|
|
|
|
|
|
|
|
/* panic and try to clear out nodes and reset queue state */
|
|
|
|
|
clearErrorNodes();
|
|
|
|
|
}
|
|
|
|
|
else if (idx > 0) {
|
|
|
|
|
idx -= 1;
|
|
|
|
|
removeErrorNode(idx);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* if current idx is 0 then the queue only had one node */
|
|
|
|
|
removeErrorNode(idx);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
return ret;
|
2020-02-13 12:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
2020-02-13 12:32:59 -06:00
|
|
|
/* This callback allows the application to provide a custom error printing
|
|
|
|
|
* function. */
|
|
|
|
|
void wc_ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
|
|
|
|
void *u)
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_ERR_print_errors_cb");
|
2017-01-06 14:29:16 -07:00
|
|
|
|
2020-02-13 16:58:06 -06:00
|
|
|
if (cb == NULL) {
|
|
|
|
|
/* Invalid param */
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
if (ERRQ_LOCK() != 0) {
|
2020-02-13 12:32:59 -06:00
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
else {
|
2020-02-13 12:32:59 -06:00
|
|
|
/* free all nodes from error queue and print them to file */
|
|
|
|
|
struct wc_error_queue *current;
|
|
|
|
|
struct wc_error_queue *next;
|
|
|
|
|
|
|
|
|
|
current = (struct wc_error_queue *)wc_errors;
|
|
|
|
|
while (current != NULL)
|
2017-01-06 14:29:16 -07:00
|
|
|
{
|
2020-02-13 12:32:59 -06:00
|
|
|
next = current->next;
|
2021-02-08 18:05:22 -07:00
|
|
|
cb(current->error, XSTRLEN(current->error), u);
|
2020-02-13 12:32:59 -06:00
|
|
|
XFREE(current, current->heap, DYNAMIC_TYPE_LOG);
|
|
|
|
|
current = next;
|
2018-07-04 06:52:22 +09:00
|
|
|
}
|
2017-01-06 14:29:16 -07:00
|
|
|
|
2020-02-13 12:32:59 -06:00
|
|
|
/* set global pointers to match having been freed */
|
2022-12-07 18:14:45 +01:00
|
|
|
wc_errors_count = 0;
|
2020-02-13 12:32:59 -06:00
|
|
|
wc_errors = NULL;
|
|
|
|
|
wc_last_node = NULL;
|
|
|
|
|
|
2022-12-07 18:14:45 +01:00
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */
|
|
|
|
|
|
|
|
|
|
#endif /* !ERROR_QUEUE_PER_THREAD */
|
|
|
|
|
|
|
|
|
|
#else /* WOLFSSL_HAVE_ERROR_QUEUE */
|
|
|
|
|
/* NO ERROR_QUEUE at all */
|
|
|
|
|
|
|
|
|
|
int wc_LoggingInit(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* internal function that is called by wolfCrypt_Cleanup */
|
|
|
|
|
int wc_LoggingCleanup(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_PeekErrorNode(int idx, const char **file, const char **reason,
|
|
|
|
|
int *line)
|
|
|
|
|
{
|
|
|
|
|
(void)idx;
|
|
|
|
|
(void)file;
|
|
|
|
|
(void)reason;
|
|
|
|
|
(void)line;
|
|
|
|
|
WOLFSSL_MSG("Error queue turned off, can not peak nodes");
|
|
|
|
|
return NOT_COMPILED_IN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_PullErrorNode(const char **file, const char **reason, int *line)
|
|
|
|
|
{
|
|
|
|
|
(void)file;
|
|
|
|
|
(void)reason;
|
|
|
|
|
(void)line;
|
|
|
|
|
WOLFSSL_MSG("Error queue turned off, can not pull nodes");
|
|
|
|
|
return NOT_COMPILED_IN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_AddErrorNode(int error, int line, char* buf, char* file)
|
|
|
|
|
{
|
|
|
|
|
(void)error;
|
|
|
|
|
(void)line;
|
|
|
|
|
(void)buf;
|
|
|
|
|
(void)file;
|
|
|
|
|
WOLFSSL_MSG("Error queue turned off, can not add nodes");
|
|
|
|
|
return NOT_COMPILED_IN;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wc_RemoveErrorNode(int idx)
|
|
|
|
|
{
|
|
|
|
|
(void)idx;
|
|
|
|
|
WOLFSSL_MSG("Error queue turned off, can not remove nodes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void wc_ClearErrorNodes(void)
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_MSG("Error queue turned off, can not clear nodes");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_SetLoggingHeap(void* h)
|
|
|
|
|
{
|
|
|
|
|
(void)h;
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wc_ERR_remove_state(void)
|
|
|
|
|
{
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long wc_PeekErrorNodeLineData(const char **file, int *line,
|
|
|
|
|
const char **data, int *flags,
|
|
|
|
|
int (*ignore_err)(int err))
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_PeekErrorNodeLineData");
|
|
|
|
|
|
|
|
|
|
(void)line;
|
|
|
|
|
(void)file;
|
|
|
|
|
(void)ignore_err;
|
|
|
|
|
if (data != NULL) {
|
|
|
|
|
*data = "";
|
2020-02-13 12:32:59 -06:00
|
|
|
}
|
2022-12-07 18:14:45 +01:00
|
|
|
if (flags != NULL) {
|
|
|
|
|
*flags = 0;
|
|
|
|
|
}
|
|
|
|
|
return (unsigned long)(0 - NOT_COMPILED_IN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned long wc_GetErrorNodeErr(void)
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_GetErrorNodeErr");
|
|
|
|
|
return (unsigned long)(0 - NOT_COMPILED_IN);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
|
|
|
|
void wc_ERR_print_errors_cb(int (*cb)(const char *str, size_t len, void *u),
|
|
|
|
|
void *u)
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_ERR_print_errors_cb");
|
|
|
|
|
(void)cb;
|
|
|
|
|
(void)u;
|
|
|
|
|
}
|
|
|
|
|
#endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */
|
|
|
|
|
|
|
|
|
|
#endif /* !WOLFSSL_HAVE_ERROR_QUEUE */
|
|
|
|
|
|
|
|
|
|
#if !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM)
|
|
|
|
|
/* empties out the error queue into the file */
|
|
|
|
|
static int wc_ERR_dump_to_file (const char *str, size_t len, void *u)
|
|
|
|
|
{
|
|
|
|
|
XFILE fp = (XFILE ) u;
|
|
|
|
|
if (fprintf(fp, "%-*.*s\n", (int)len, (int)len, str) < 0)
|
|
|
|
|
return IO_FAILED_E;
|
|
|
|
|
return 0;
|
2017-01-06 14:29:16 -07:00
|
|
|
}
|
2020-02-13 12:32:59 -06:00
|
|
|
|
|
|
|
|
void wc_ERR_print_errors_fp(XFILE fp)
|
|
|
|
|
{
|
|
|
|
|
WOLFSSL_ENTER("wc_ERR_print_errors_fp");
|
|
|
|
|
|
|
|
|
|
/* Send all errors to the wc_ERR_dump_to_file function */
|
2020-02-13 16:58:06 -06:00
|
|
|
wc_ERR_print_errors_cb(wc_ERR_dump_to_file, fp);
|
2020-02-13 12:32:59 -06:00
|
|
|
}
|
|
|
|
|
|
2017-01-06 14:29:16 -07:00
|
|
|
#endif /* !defined(NO_FILESYSTEM) && !defined(NO_STDIO_FILESYSTEM) */
|
|
|
|
|
|
|
|
|
|
#endif /* defined(OPENSSL_EXTRA) || defined(DEBUG_WOLFSSL_VERBOSE) */
|
2022-12-07 18:14:45 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* When using OPENSSL_EXTRA or DEBUG_WOLFSSL_VERBOSE macro then WOLFSSL_ERROR is
|
|
|
|
|
* mapped to new function WOLFSSL_ERROR_LINE which gets the line # and function
|
|
|
|
|
* name where WOLFSSL_ERROR is called at.
|
|
|
|
|
*/
|
|
|
|
|
#if defined(DEBUG_WOLFSSL) || defined(OPENSSL_ALL) || \
|
|
|
|
|
defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) || \
|
|
|
|
|
defined(OPENSSL_EXTRA)
|
|
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_HAVE_ERROR_QUEUE
|
|
|
|
|
void WOLFSSL_ERROR_LINE(int error, const char* func, unsigned int line,
|
|
|
|
|
const char* file, void* usrCtx)
|
|
|
|
|
#else
|
|
|
|
|
void WOLFSSL_ERROR(int error)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
#ifdef WOLFSSL_ASYNC_CRYPT
|
|
|
|
|
if (error != WC_PENDING_E)
|
|
|
|
|
#endif
|
|
|
|
|
{
|
|
|
|
|
char buffer[WOLFSSL_MAX_ERROR_SZ];
|
|
|
|
|
|
|
|
|
|
#ifdef WOLFSSL_HAVE_ERROR_QUEUE
|
|
|
|
|
(void)usrCtx; /* a user ctx for future flexibility */
|
|
|
|
|
(void)func;
|
|
|
|
|
|
|
|
|
|
if (ERRQ_LOCK() != 0) {
|
|
|
|
|
WOLFSSL_MSG("Lock debug mutex failed");
|
|
|
|
|
(void)XSNPRINTF(buffer, sizeof(buffer),
|
|
|
|
|
"wolfSSL error occurred, error = %d", error);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
|
|
|
|
/* If running in compatibility mode do not add want read and
|
|
|
|
|
want right to error queue */
|
|
|
|
|
if (error != WANT_READ && error != WANT_WRITE) {
|
|
|
|
|
#endif
|
|
|
|
|
if (error < 0)
|
|
|
|
|
error = error - (2 * error); /* get absolute value */
|
|
|
|
|
(void)XSNPRINTF(buffer, sizeof(buffer),
|
|
|
|
|
"wolfSSL error occurred, error = %d line:%u file:%s",
|
|
|
|
|
error, line, file);
|
|
|
|
|
|
|
|
|
|
if (wc_AddErrorNode(error, line, buffer, (char*)file) != 0) {
|
|
|
|
|
WOLFSSL_MSG("Error creating logging node");
|
|
|
|
|
/* with void function there is no return here, continue on
|
|
|
|
|
* to unlock mutex and log what buffer was created. */
|
|
|
|
|
}
|
|
|
|
|
#if defined(OPENSSL_EXTRA) && !defined(WOLFCRYPT_ONLY)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
(void)XSNPRINTF(buffer, sizeof(buffer),
|
|
|
|
|
"wolfSSL error occurred, error = %d", error);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
ERRQ_UNLOCK();
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
(void)XSNPRINTF(buffer, sizeof(buffer),
|
|
|
|
|
"wolfSSL error occurred, error = %d", error);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG_WOLFSSL
|
|
|
|
|
if (loggingEnabled)
|
|
|
|
|
wolfssl_log(ERROR_LOG , buffer);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WOLFSSL_ERROR_MSG(const char* msg)
|
|
|
|
|
{
|
|
|
|
|
#ifdef DEBUG_WOLFSSL
|
|
|
|
|
if (loggingEnabled)
|
|
|
|
|
wolfssl_log(ERROR_LOG , msg);
|
|
|
|
|
#else
|
|
|
|
|
(void)msg;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif /* DEBUG_WOLFSSL || WOLFSSL_NGINX || WOLFSSL_HAPROXY */
|
|
|
|
|
|