From 79aa721adee6042afecae06c124d35a36337b18a Mon Sep 17 00:00:00 2001 From: Jerry Yu Date: Tue, 8 Nov 2022 21:30:21 +0800 Subject: [PATCH] Rename ext print function and macro Signed-off-by: Jerry Yu --- library/ssl_debug_helpers.h | 19 +++++++++---------- library/ssl_tls.c | 14 ++++++-------- library/ssl_tls13_client.c | 6 +++--- library/ssl_tls13_generic.c | 8 ++++---- library/ssl_tls13_server.c | 2 +- 5 files changed, 23 insertions(+), 26 deletions(-) diff --git a/library/ssl_debug_helpers.h b/library/ssl_debug_helpers.h index 8fce87a98..ad84619a0 100644 --- a/library/ssl_debug_helpers.h +++ b/library/ssl_debug_helpers.h @@ -50,12 +50,10 @@ void mbedtls_ssl_print_extensions( const mbedtls_ssl_context *ssl, int hs_msg_type, uint32_t extensions_mask, const char *extra ); -void mbedtls_ssl_print_extension_type( const mbedtls_ssl_context *ssl, - int level, const char *file, int line, - int hs_msg_type, - unsigned int extension_type, - const char *extra_msg0, - const char *extra_msg1 ); +void mbedtls_ssl_print_extension( const mbedtls_ssl_context *ssl, + int level, const char *file, int line, + int hs_msg_type, unsigned int extension_type, + const char *extra_msg0, const char *extra_msg1 ); #define MBEDTLS_SSL_PRINT_SENT_EXTS( level, hs_msg_type ) \ mbedtls_ssl_print_extensions( ssl, level, __FILE__, __LINE__, \ @@ -69,16 +67,17 @@ void mbedtls_ssl_print_extension_type( const mbedtls_ssl_context *ssl, ssl->handshake->received_extensions, \ "received" ) -#define MBEDTLS_SSL_PRINT_EXT_TYPE( level, hs_msg_type, extension_type, extra ) \ - mbedtls_ssl_print_extension_type( ssl, level, __FILE__, __LINE__, \ - hs_msg_type, extension_type, extra, NULL ) +#define MBEDTLS_SSL_PRINT_EXT( level, hs_msg_type, extension_type, extra ) \ + mbedtls_ssl_print_extension( ssl, level, __FILE__, __LINE__, \ + hs_msg_type, extension_type, \ + extra, NULL ) #else #define MBEDTLS_SSL_PRINT_SENT_EXTS( level, hs_msg_type ) #define MBEDTLS_SSL_PRINT_RECEIVED_EXTS( level, hs_msg_type ) -#define MBEDTLS_SSL_PRINT_EXT_TYPE( level, hs_msg_type, extension_type, extra ) +#define MBEDTLS_SSL_PRINT_EXT( level, hs_msg_type, extension_type, extra ) #endif /* MBEDTLS_DEBUG_C */ diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 4787ca058..efe24634f 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -704,15 +704,13 @@ static const char *ssl_tls13_get_hs_msg_name( int hs_msg_type ) case MBEDTLS_SSL_HS_CERTIFICATE_REQUEST: return( "CertificateRequest" ); } - return( NULL ); + return( "Unknown" ); } -void mbedtls_ssl_print_extension_type( const mbedtls_ssl_context *ssl, - int level, const char *file, int line, - int hs_msg_type, - unsigned int extension_type, - const char *extra_msg0, - const char *extra_msg1 ) +void mbedtls_ssl_print_extension( const mbedtls_ssl_context *ssl, + int level, const char *file, int line, + int hs_msg_type, unsigned int extension_type, + const char *extra_msg0, const char *extra_msg1 ) { const char *extra_msg; if( extra_msg0 && extra_msg1 ) @@ -754,7 +752,7 @@ void mbedtls_ssl_print_extensions( const mbedtls_ssl_context *ssl, i < sizeof( extension_name_table ) / sizeof( extension_name_table[0] ); i++ ) { - mbedtls_ssl_print_extension_type( + mbedtls_ssl_print_extension( ssl, level, file, line, hs_msg_type, extension_type_table[i], extensions_mask & ( 1 << i ) ? "was" : "was not", extra ); } diff --git a/library/ssl_tls13_client.c b/library/ssl_tls13_client.c index fff0febed..f4502d290 100644 --- a/library/ssl_tls13_client.c +++ b/library/ssl_tls13_client.c @@ -2025,7 +2025,7 @@ static int ssl_tls13_parse_encrypted_extensions( mbedtls_ssl_context *ssl, break; #endif /* MBEDTLS_SSL_ALPN */ default: - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, MBEDTLS_SSL_HS_ENCRYPTED_EXTENSIONS, extension_type, "( ignored )" ); break; @@ -2213,7 +2213,7 @@ static int ssl_tls13_parse_certificate_request( mbedtls_ssl_context *ssl, break; default: - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, MBEDTLS_SSL_HS_CERTIFICATE_REQUEST, extension_type, "( ignored )" ); break; @@ -2504,7 +2504,7 @@ static int ssl_tls13_parse_new_session_ticket_exts( mbedtls_ssl_context *ssl, switch( extension_type ) { default: - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, MBEDTLS_SSL_HS_NEW_SESSION_TICKET, extension_type, "( ignored )" ); break; diff --git a/library/ssl_tls13_generic.c b/library/ssl_tls13_generic.c index a9c8c973f..39b86b984 100644 --- a/library/ssl_tls13_generic.c +++ b/library/ssl_tls13_generic.c @@ -537,7 +537,7 @@ int mbedtls_ssl_tls13_parse_certificate( mbedtls_ssl_context *ssl, switch( extension_type ) { default: - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, MBEDTLS_SSL_HS_CERTIFICATE, extension_type, "( ignored )" ); break; @@ -1545,12 +1545,12 @@ int mbedtls_ssl_tls13_check_received_extension( uint32_t extension_mask = mbedtls_ssl_get_extension_mask( received_extension_type ); - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, hs_msg_type, received_extension_type, "received" ); if( ( extension_mask & hs_msg_allowed_extensions_mask ) == 0 ) { - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, hs_msg_type, received_extension_type, "is illegal" ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_ILLEGAL_PARAMETER, @@ -1577,7 +1577,7 @@ int mbedtls_ssl_tls13_check_received_extension( return( 0 ); } - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, hs_msg_type, received_extension_type, "is unsupported" ); MBEDTLS_SSL_PEND_FATAL_ALERT( MBEDTLS_SSL_ALERT_MSG_UNSUPPORTED_EXT, diff --git a/library/ssl_tls13_server.c b/library/ssl_tls13_server.c index 051afa270..28f242295 100644 --- a/library/ssl_tls13_server.c +++ b/library/ssl_tls13_server.c @@ -1614,7 +1614,7 @@ static int ssl_tls13_parse_client_hello( mbedtls_ssl_context *ssl, #endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED */ default: - MBEDTLS_SSL_PRINT_EXT_TYPE( + MBEDTLS_SSL_PRINT_EXT( 3, MBEDTLS_SSL_HS_CLIENT_HELLO, extension_type, "( ignored )" ); break;