Refactor sent extension message output

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2022-10-31 13:31:22 +08:00
parent d25cab0327
commit 4b8f2f7266
5 changed files with 22 additions and 38 deletions

View file

@ -108,10 +108,6 @@ static int ssl_write_hostname_ext( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_SERVERNAME );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_SERVERNAME ) ) );
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
return( 0 );
}
@ -186,10 +182,6 @@ static int ssl_write_alpn_ext( mbedtls_ssl_context *ssl,
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_ALPN );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_ALPN ) ) );
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
return( 0 );
}
@ -310,10 +302,8 @@ static int ssl_write_supported_groups_ext( mbedtls_ssl_context *ssl,
*out_len = p - buf;
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_SUPPORTED_GROUPS );
MBEDTLS_SSL_DEBUG_MSG( 4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_SUPPORTED_GROUPS ) ) );
mbedtls_ssl_tls13_set_hs_sent_ext_mask(
ssl, MBEDTLS_TLS_EXT_SUPPORTED_GROUPS );
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
return( 0 );
@ -684,6 +674,10 @@ static int ssl_write_client_hello_body( mbedtls_ssl_context *ssl,
p_extensions_len, extensions_len );
}
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
MBEDTLS_SSL_PRINT_SENT_EXTS( 3, MBEDTLS_SSL_HS_CLIENT_HELLO );
#endif
*out_len = p - buf;
return( 0 );
}

View file

@ -8955,10 +8955,6 @@ int mbedtls_ssl_write_sig_alg_ext( mbedtls_ssl_context *ssl, unsigned char *buf,
#if defined(MBEDTLS_SSL_PROTO_TLS1_3)
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_SIG_ALG );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_SIG_ALG ) ) );
#endif /* MBEDTLS_SSL_PROTO_TLS1_3 */
return( 0 );

View file

@ -89,12 +89,10 @@ static int ssl_tls13_write_supported_versions_ext( mbedtls_ssl_context *ssl,
}
*out_len = 5 + versions_len;
mbedtls_ssl_tls13_set_hs_sent_ext_mask(
ssl, MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_SUPPORTED_VERSIONS ) ) );
return( 0 );
}
@ -366,11 +364,6 @@ static int ssl_tls13_write_key_share_ext( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_DEBUG_BUF( 3, "client hello, key_share extension", buf, *out_len );
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_KEY_SHARE );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_KEY_SHARE ) ) );
cleanup:
@ -610,12 +603,8 @@ static int ssl_tls13_write_cookie_ext( mbedtls_ssl_context *ssl,
*out_len = handshake->hrr_cookie_len + 6;
mbedtls_ssl_tls13_set_hs_sent_ext_mask( ssl, MBEDTLS_TLS_EXT_COOKIE );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_COOKIE ) ) );
return( 0 );
}
@ -688,10 +677,7 @@ static int ssl_tls13_write_psk_key_exchange_modes_ext( mbedtls_ssl_context *ssl,
mbedtls_ssl_tls13_set_hs_sent_ext_mask(
ssl, MBEDTLS_TLS_EXT_PSK_KEY_EXCHANGE_MODES );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_PSK_KEY_EXCHANGE_MODES ) ) );
return ( 0 );
}
@ -1059,10 +1045,6 @@ int mbedtls_ssl_tls13_write_binders_of_pre_shared_key_ext(
mbedtls_ssl_tls13_set_hs_sent_ext_mask(
ssl, MBEDTLS_TLS_EXT_PRE_SHARED_KEY );
MBEDTLS_SSL_DEBUG_MSG(
4, ( "sent %s extension",
mbedtls_tls13_get_extension_name(
MBEDTLS_TLS_EXT_PRE_SHARED_KEY ) ) );
return( 0 );
}

View file

@ -887,6 +887,8 @@ static int ssl_tls13_write_certificate_body( mbedtls_ssl_context *ssl,
*out_len = p - buf;
MBEDTLS_SSL_PRINT_SENT_EXTS( 3, MBEDTLS_SSL_HS_CERTIFICATE );
return( 0 );
}

View file

@ -2128,6 +2128,10 @@ static int ssl_tls13_write_server_hello_body( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_DEBUG_BUF( 3, "server hello", buf, *out_len );
MBEDTLS_SSL_PRINT_SENT_EXTS(
3, is_hrr ? MBEDTLS_SSL_TLS1_3_HS_HELLO_RETRY_REQUEST :
MBEDTLS_SSL_HS_SERVER_HELLO );
return( ret );
}
@ -2312,6 +2316,8 @@ static int ssl_tls13_write_encrypted_extensions_body( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_DEBUG_BUF( 4, "encrypted extensions", buf, *out_len );
MBEDTLS_SSL_PRINT_SENT_EXTS( 3, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSIONS );
return( 0 );
}
@ -2441,6 +2447,8 @@ static int ssl_tls13_write_certificate_request_body( mbedtls_ssl_context *ssl,
*out_len = p - buf;
MBEDTLS_SSL_PRINT_SENT_EXTS( 3, MBEDTLS_SSL_HS_CERTIFICATE_REQUEST );
return( 0 );
}
@ -2834,6 +2842,8 @@ static int ssl_tls13_write_new_session_ticket_body( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_DEBUG_BUF( 4, "ticket", buf, *out_len );
MBEDTLS_SSL_DEBUG_MSG( 2, ( "<= write new session ticket" ) );
MBEDTLS_SSL_PRINT_SENT_EXTS( 3, MBEDTLS_SSL_HS_NEW_SESSION_TICKET );
return( 0 );
}