diff options
author | Florin Coras <fcoras@cisco.com> | 2023-10-17 11:59:49 -0700 |
---|---|---|
committer | Dave Barach <vpp@barachs.net> | 2024-09-26 20:44:34 +0000 |
commit | d0e8bd75f6371d09f31f48ffaf5843dce86ca8e6 (patch) | |
tree | 60afbb7769d3c4abce413d5055387ef031c975d5 /src/plugins/tlsmbedtls/tls_mbedtls.c | |
parent | 2193fd06492ee0f9a8c9b89fe665ecbc4d50cefe (diff) |
tls: cleanup engine hs cb and improve ctx formatting
Handshake completion is now tracked via a ctx flag so we no longer need
ctx_handshake_is_over.
Also, as we no longer prealloc application sessions, improve ctx state
formatting.
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: If48588ecde13e56fb99d1a46238bda53ed4eae1b
Diffstat (limited to 'src/plugins/tlsmbedtls/tls_mbedtls.c')
-rw-r--r-- | src/plugins/tlsmbedtls/tls_mbedtls.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/plugins/tlsmbedtls/tls_mbedtls.c b/src/plugins/tlsmbedtls/tls_mbedtls.c index af04f1adeb0..2f4757e28a1 100644 --- a/src/plugins/tlsmbedtls/tls_mbedtls.c +++ b/src/plugins/tlsmbedtls/tls_mbedtls.c @@ -396,6 +396,8 @@ mbedtls_ctx_handshake_rx (tls_ctx_t * ctx) if (mc->ssl.state != MBEDTLS_SSL_HANDSHAKE_OVER) return 0; + ctx->flags |= TLS_CONN_F_HS_DONE; + /* * Handshake complete */ @@ -532,17 +534,10 @@ mbedtls_ctx_read (tls_ctx_t * ctx, session_t * tls_session) return enq; } -static u8 -mbedtls_handshake_is_over (tls_ctx_t * ctx) -{ - mbedtls_ctx_t *mc = (mbedtls_ctx_t *) ctx; - return (mc->ssl.state == MBEDTLS_SSL_HANDSHAKE_OVER); -} - static int mbedtls_transport_close (tls_ctx_t * ctx) { - if (!mbedtls_handshake_is_over (ctx)) + if (!(ctx->flags & TLS_CONN_F_HS_DONE)) { session_close (session_get_from_handle (ctx->tls_session_handle)); return 0; @@ -554,7 +549,7 @@ mbedtls_transport_close (tls_ctx_t * ctx) static int mbedtls_transport_reset (tls_ctx_t *ctx) { - if (!mbedtls_handshake_is_over (ctx)) + if (!(ctx->flags & TLS_CONN_F_HS_DONE)) { session_close (session_get_from_handle (ctx->tls_session_handle)); return 0; @@ -590,7 +585,6 @@ const static tls_engine_vft_t mbedtls_engine = { .ctx_init_client = mbedtls_ctx_init_client, .ctx_write = mbedtls_ctx_write, .ctx_read = mbedtls_ctx_read, - .ctx_handshake_is_over = mbedtls_handshake_is_over, .ctx_start_listen = mbedtls_start_listen, .ctx_stop_listen = mbedtls_stop_listen, .ctx_transport_close = mbedtls_transport_close, |