add ctx set msg callback

This commit is contained in:
JacobBarthelmeh
2021-08-04 16:49:01 +07:00
parent f1377ed861
commit d39893baa0
4 changed files with 40 additions and 12 deletions

View File

@@ -6309,6 +6309,12 @@ int InitSSL(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
XMEMCPY(ssl->sessionCtx, ctx->sessionCtx, ctx->sessionCtxSz);
ssl->cbioFlag = ctx->cbioFlag;
ssl->protoMsgCb = ctx->protoMsgCb;
ssl->protoMsgCtx = ctx->protoMsgCtx;
if (ctx->protoMsgCb != NULL) {
ssl->toInfoOn = 1;
}
#endif
InitCiphers(ssl);

View File

@@ -47894,15 +47894,25 @@ int wolfSSL_set1_curves_list(WOLFSSL* ssl, const char* names)
#endif /* OPENSSL_EXTRA && HAVE_ECC */
#ifdef OPENSSL_EXTRA
#ifndef NO_WOLFSSL_STUB
/* Sets a callback for when sending and receiving protocol messages.
* This callback is copied to all WOLFSSL objects created from the ctx.
*
* ctx WOLFSSL_CTX structure to set callback in
* cb callback to use
*
* return WOLFSSL_SUCCESS on success and SSL_FAILURE with error case
*/
int wolfSSL_CTX_set_msg_callback(WOLFSSL_CTX *ctx, SSL_Msg_Cb cb)
{
WOLFSSL_STUB("SSL_CTX_set_msg_callback");
(void)ctx;
(void)cb;
return WOLFSSL_FAILURE;
WOLFSSL_ENTER("wolfSSL_CTX_set_msg_callback");
if (ctx == NULL) {
WOLFSSL_MSG("Null ctx passed in");
return WOLFSSL_FAILURE;
}
ctx->protoMsgCb = cb;
return WOLFSSL_SUCCESS;
}
#endif
/* Sets a callback for when sending and receiving protocol messages.
@@ -47927,15 +47937,22 @@ int wolfSSL_set_msg_callback(WOLFSSL *ssl, SSL_Msg_Cb cb)
ssl->protoMsgCb = cb;
return WOLFSSL_SUCCESS;
}
#ifndef NO_WOLFSSL_STUB
/* set the user argument to pass to the msg callback when called
* return WOLFSSL_SUCCESS on success */
int wolfSSL_CTX_set_msg_callback_arg(WOLFSSL_CTX *ctx, void* arg)
{
WOLFSSL_STUB("SSL_CTX_set_msg_callback_arg");
(void)ctx;
(void)arg;
return WOLFSSL_FAILURE;
WOLFSSL_ENTER("wolfSSL_CTX_set_msg_callback_arg");
if (ctx == NULL) {
WOLFSSL_MSG("Null WOLFSSL_CTX passed in");
return WOLFSSL_FAILURE;
}
ctx->protoMsgCtx = arg;
return WOLFSSL_SUCCESS;
}
#endif
int wolfSSL_set_msg_callback_arg(WOLFSSL *ssl, void* arg)
{

View File

@@ -31959,6 +31959,7 @@ static void test_wolfSSL_set_options(void)
#endif
AssertTrue(SSL_CTX_use_certificate_file(ctx, svrCertFile, SSL_FILETYPE_PEM));
AssertTrue(SSL_CTX_use_PrivateKey_file(ctx, svrKeyFile, SSL_FILETYPE_PEM));
AssertTrue(SSL_CTX_set_msg_callback(ctx, msg_cb) == SSL_SUCCESS);
AssertNotNull(ssl = SSL_new(ctx));
#if defined(HAVE_EX_DATA) || defined(FORTRESS)

View File

@@ -2916,6 +2916,10 @@ struct WOLFSSL_CTX {
CertVerifyCallback verifyCertCb;
void* verifyCertCbArg;
#endif /* OPENSSL_ALL */
#ifdef OPENSSL_EXTRA
SSL_Msg_Cb protoMsgCb; /* inspect protocol message callback */
void* protoMsgCtx; /* user set context with msg callback */
#endif
word32 timeout; /* session timeout */
#if defined(HAVE_ECC) || defined(HAVE_CURVE25519) || defined(HAVE_ED448)
word32 ecdhCurveOID; /* curve Ecc_Sum */