Rename ext print function and macro

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2022-11-08 21:30:21 +08:00
parent b95dd3683b
commit 79aa721ade
5 changed files with 23 additions and 26 deletions

View file

@ -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 */

View file

@ -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 );
}

View file

@ -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;

View file

@ -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,

View file

@ -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;