Merge pull request #3763 from embhorn/zd11726

Adding wolfSSL_CTX_get_TicketEncCtx
This commit is contained in:
Sean Parkinson 2021-02-18 08:35:03 +10:00 committed by GitHub
commit 276e090a1f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 0 deletions

View File

@ -11214,6 +11214,27 @@ WOLFSSL_API int wolfSSL_CTX_set_TicketHint(WOLFSSL_CTX* ctx, int);
*/
WOLFSSL_API int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void*);
/*!
\brief This function gets the session ticket encrypt user context for the
callback. For server side use.
\return userCtx will be returned upon successfully getting the session.
\return NULL will be returned on failure. This is caused by
passing invalid arguments to the function, or when the user context has
not been set.
\param ctx pointer to the WOLFSSL_CTX object, created
with wolfSSL_CTX_new().
_Example_
\code
none
\endcode
\sa wolfSSL_CTX_set_TicketEncCtx
*/
WOLFSSL_API void* wolfSSL_CTX_get_TicketEncCtx(WOLFSSL_CTX* ctx);
/*!
\ingroup IO

View File

@ -2893,6 +2893,14 @@ int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void* userCtx)
return WOLFSSL_SUCCESS;
}
/* get user context - returns userCtx on success, NULL on failure */
void* wolfSSL_CTX_get_TicketEncCtx(WOLFSSL_CTX* ctx)
{
if (ctx == NULL)
return NULL;
return ctx->ticketEncCtx;
}
#endif /* !NO_WOLFSSL_SERVER */
#if !defined(NO_WOLFSSL_CLIENT)

View File

@ -1748,6 +1748,26 @@ static void test_wolfSSL_CTX_enable_disable(void)
wolfSSL_CTX_free(ctx);
#endif /* NO_CERTS */
}
static void test_wolfSSL_CTX_ticket_API(void)
{
#if defined(HAVE_SESSION_TICKET) && !defined(NO_WOLFSSL_SERVER)
WOLFSSL_CTX* ctx = NULL;
void *userCtx = (void*)"this is my ctx";
AssertNotNull(ctx = wolfSSL_CTX_new(wolfSSLv23_server_method()));
AssertIntEQ(WOLFSSL_SUCCESS, wolfSSL_CTX_set_TicketEncCtx(ctx, userCtx));
AssertTrue(userCtx == wolfSSL_CTX_get_TicketEncCtx(ctx));
wolfSSL_CTX_free(ctx);
AssertIntNE(WOLFSSL_SUCCESS, wolfSSL_CTX_set_TicketEncCtx(NULL, userCtx));
AssertNull(wolfSSL_CTX_get_TicketEncCtx(NULL));
#endif /* HAVE_SESSION_TICKET && !NO_WOLFSSL_SERVER */
}
/*----------------------------------------------------------------------------*
| SSL
*----------------------------------------------------------------------------*/
@ -40289,6 +40309,7 @@ void ApiTest(void)
test_wolfSSL_CTX_SetMinMaxDhKey_Sz();
test_wolfSSL_CTX_der_load_verify_locations();
test_wolfSSL_CTX_enable_disable();
test_wolfSSL_CTX_ticket_API();
test_server_wolfSSL_new();
test_client_wolfSSL_new();
test_wolfSSL_SetTmpDH_file();

View File

@ -3261,6 +3261,7 @@ WOLFSSL_API int wolfSSL_CTX_set_TicketEncCb(WOLFSSL_CTX* ctx,
SessionTicketEncCb);
WOLFSSL_API int wolfSSL_CTX_set_TicketHint(WOLFSSL_CTX* ctx, int);
WOLFSSL_API int wolfSSL_CTX_set_TicketEncCtx(WOLFSSL_CTX* ctx, void*);
WOLFSSL_API void* wolfSSL_CTX_get_TicketEncCtx(WOLFSSL_CTX* ctx);
#endif /* NO_WOLFSSL_SERVER */