mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 15:38:08 +00:00
Introduce function to indicate if record is fully processed
This commit introduces a function ssl_record_is_in_progress() to indicate if there is there is more data within the current record to be processed. Further, it moves the corresponding call from ssl_read_record_layer() to the parent function mbedtls_ssl_read_record(). With this change, ssl_read_record_layer() has the sole purpose of fetching and decoding a new record, and hence this commit also renames it to ssl_get_next_record().
This commit is contained in:
parent
2699459529
commit
e74d556b43
1 changed files with 22 additions and 18 deletions
|
@ -4286,7 +4286,8 @@ static void ssl_handshake_wrapup_free_hs_transform( mbedtls_ssl_context *ssl );
|
|||
|
||||
/* Helper functions for mbedtls_ssl_read_record(). */
|
||||
static int ssl_consume_current_message( mbedtls_ssl_context *ssl );
|
||||
static int ssl_read_record_layer( mbedtls_ssl_context *ssl );
|
||||
static int ssl_get_next_record( mbedtls_ssl_context *ssl );
|
||||
static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl );
|
||||
|
||||
int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
||||
unsigned update_digest )
|
||||
|
@ -4303,14 +4304,17 @@ int mbedtls_ssl_read_record( mbedtls_ssl_context *ssl,
|
|||
if( ret != 0 )
|
||||
return( ret );
|
||||
|
||||
ret = ssl_read_record_layer( ssl );
|
||||
if( ret == MBEDTLS_ERR_SSL_CONTINUE_PROCESSING )
|
||||
continue;
|
||||
|
||||
if( ret != 0 )
|
||||
if( ssl_record_is_in_progress( ssl ) == 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret );
|
||||
return( ret );
|
||||
ret = ssl_get_next_record( ssl );
|
||||
if( ret == MBEDTLS_ERR_SSL_CONTINUE_PROCESSING )
|
||||
continue;
|
||||
|
||||
if( ret != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, ( "mbedtls_ssl_read_record_layer" ), ret );
|
||||
return( ret );
|
||||
}
|
||||
}
|
||||
|
||||
ret = mbedtls_ssl_handle_message_type( ssl );
|
||||
|
@ -4428,22 +4432,22 @@ static int ssl_consume_current_message( mbedtls_ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
static int ssl_read_record_layer( mbedtls_ssl_context *ssl )
|
||||
static int ssl_record_is_in_progress( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
if( ssl->in_msglen > 0 )
|
||||
return( 1 );
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
static int ssl_get_next_record( mbedtls_ssl_context *ssl )
|
||||
{
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Fetch and decode new record if current one is fully consumed.
|
||||
* Fetch and decode new record
|
||||
*/
|
||||
|
||||
if( ssl->in_msglen > 0 )
|
||||
{
|
||||
/* There's something left to be processed in the current record. */
|
||||
return( 0 );
|
||||
}
|
||||
|
||||
/* Current record either fully processed or to be discarded. */
|
||||
|
||||
if( ( ret = mbedtls_ssl_fetch_input( ssl, mbedtls_ssl_hdr_len( ssl ) ) ) != 0 )
|
||||
{
|
||||
MBEDTLS_SSL_DEBUG_RET( 1, "mbedtls_ssl_fetch_input", ret );
|
||||
|
|
Loading…
Reference in a new issue