Refactor new session ticket

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2022-10-31 14:37:31 +08:00
parent 0d5cfb7703
commit edab637b51
2 changed files with 9 additions and 13 deletions

View file

@ -2484,7 +2484,7 @@ static int ssl_tls13_parse_new_session_ticket_exts( mbedtls_ssl_context *ssl,
const unsigned char *p = buf; const unsigned char *p = buf;
handshake->received_extensions = MBEDTLS_SSL_EXT_NONE; handshake->received_extensions = MBEDTLS_SSL_EXT_MASK_NONE;
while( p < end ) while( p < end )
{ {
@ -2500,30 +2500,24 @@ static int ssl_tls13_parse_new_session_ticket_exts( mbedtls_ssl_context *ssl,
MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extension_data_len ); MBEDTLS_SSL_CHK_BUF_READ_PTR( p, end, extension_data_len );
ret = mbedtls_ssl_tls13_check_received_extension( ret = mbedtls_ssl_tls13_check_received_extension(
ssl, MBEDTLS_SSL_HS_CLIENT_HELLO, extension_type, ssl, MBEDTLS_SSL_HS_NEW_SESSION_TICKET, extension_type,
MBEDTLS_SSL_TLS1_3_ALLOWED_EXTS_OF_CH ); MBEDTLS_SSL_TLS1_3_ALLOWED_EXTS_OF_NST );
if( ret != 0 ) if( ret != 0 )
return( ret ); return( ret );
switch( extension_type ) switch( extension_type )
{ {
case MBEDTLS_TLS_EXT_EARLY_DATA:
MBEDTLS_SSL_DEBUG_MSG( 4, ( "early_data extension received" ) );
break;
default: default:
MBEDTLS_SSL_DEBUG_MSG( 3, MBEDTLS_SSL_PRINT_EXT_TYPE(
( "NewSessionTicket : received %s(%u) extension ( ignored )", 3, MBEDTLS_SSL_HS_NEW_SESSION_TICKET,
mbedtls_tls13_get_extension_name( extension_type ), extension_type, "( ignored )" );
extension_type ) );
break; break;
} }
p += extension_data_len; p += extension_data_len;
} }
MBEDTLS_SSL_TLS1_3_PRINT_EXTS( MBEDTLS_SSL_PRINT_RECEIVED_EXTS( 3, MBEDTLS_SSL_HS_NEW_SESSION_TICKET );
3, MBEDTLS_SSL_HS_NEW_SESSION_TICKET, handshake->received_extensions );
return( 0 ); return( 0 );
} }

View file

@ -2832,6 +2832,8 @@ static int ssl_tls13_write_new_session_ticket_body( mbedtls_ssl_context *ssl,
* Note: We currently don't have any extensions. * Note: We currently don't have any extensions.
* Set length to zero. * Set length to zero.
*/ */
ssl->handshake->sent_extensions = MBEDTLS_SSL_EXT_MASK_NONE;
MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 ); MBEDTLS_SSL_CHK_BUF_PTR( p, end, 2 );
MBEDTLS_PUT_UINT16_BE( 0, p, 0 ); MBEDTLS_PUT_UINT16_BE( 0, p, 0 );
p += 2; p += 2;