From c726cddf1b1a2824000be44b56d0e5a7e6450a93 Mon Sep 17 00:00:00 2001 From: Elms Date: Thu, 27 May 2021 11:37:53 -0700 Subject: [PATCH] session_ticket: Add separate member to track compatCb This resolves an error: `ISO C forbids conversion of object pointer to function pointer type` Instead of casting the function pointer, the extra member contains the function pointer. --- src/ssl.c | 7 ++++--- wolfssl/internal.h | 4 ++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/ssl.c b/src/ssl.c index 645d21cd2..914f157f9 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -49666,7 +49666,7 @@ static int wolfSSL_TicketKeyCb(WOLFSSL* ssl, WOLFSSL_ENTER("wolfSSL_TicketKeyCb"); - if (ssl == NULL || ssl->ctx == NULL || ssl->ctx->ticketEncCtx == NULL) { + if (ssl == NULL || ssl->ctx == NULL || ssl->ctx->ticketEncWrapCb == NULL) { WOLFSSL_MSG("Bad parameter"); return WOLFSSL_TICKET_RET_FATAL; } @@ -49677,7 +49677,7 @@ static int wolfSSL_TicketKeyCb(WOLFSSL* ssl, WOLFSSL_MSG("wolfSSL_HMAC_CTX_Init error"); return WOLFSSL_TICKET_RET_FATAL; } - res = ((ticketCompatCb)ssl->ctx->ticketEncCtx)(ssl, keyName, + res = ssl->ctx->ticketEncWrapCb(ssl, keyName, iv, &evpCtx, &hmacCtx, enc); if (res != TICKET_KEY_CB_RET_OK && res != TICKET_KEY_CB_RET_RENEW) { WOLFSSL_MSG("Ticket callback error"); @@ -49743,11 +49743,12 @@ end: */ int wolfSSL_CTX_set_tlsext_ticket_key_cb(WOLFSSL_CTX *ctx, ticketCompatCb cb) { + /* Set the ticket encryption callback to be a wrapper around OpenSSL * callback. */ ctx->ticketEncCb = wolfSSL_TicketKeyCb; - ctx->ticketEncCtx = (void*)cb; + ctx->ticketEncWrapCb = cb; return WOLFSSL_SUCCESS; } diff --git a/wolfssl/internal.h b/wolfssl/internal.h index 263b60afd..920471c47 100644 --- a/wolfssl/internal.h +++ b/wolfssl/internal.h @@ -2955,6 +2955,10 @@ struct WOLFSSL_CTX { #if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER) SessionTicketEncCb ticketEncCb; /* enc/dec session ticket Cb */ void* ticketEncCtx; /* session encrypt context */ + #if defined(OPENSSL_ALL) || defined(WOLFSSL_NGINX) || defined(WOLFSSL_HAPROXY) \ + || defined(OPENSSL_EXTRA) || defined(HAVE_LIGHTY) + ticketCompatCb ticketEncWrapCb; /* callback for OpenSSL ticket key callback */ + #endif int ticketHint; /* ticket hint in seconds */ #ifndef WOLFSSL_NO_DEF_TICKET_ENC_CB TicketEncCbCtx ticketKeyCtx;