Make sure 'record from another epoch' is displayed for next epoch

The test 'DTLS proxy: delay ChangeCipherSpec' from ssl-opt.sh
relies on this.
This commit is contained in:
Hanno Becker 2019-07-19 10:59:12 +01:00
parent 5422981052
commit 552f747216

View file

@ -5141,6 +5141,15 @@ static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
return( MBEDTLS_ERR_SSL_INVALID_RECORD ); return( MBEDTLS_ERR_SSL_INVALID_RECORD );
} }
/* Records from other, non-matching epochs are silently discarded.
* (The case of same-port Client reconnects must be considered in
* the caller). */
if( rec_epoch != ssl->in_epoch )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "record from another epoch: "
"expected %d, received %d",
ssl->in_epoch, rec_epoch ) );
/* Records from the next epoch are considered for buffering /* Records from the next epoch are considered for buffering
* (concretely: early Finished messages). */ * (concretely: early Finished messages). */
if( rec_epoch == (unsigned) ssl->in_epoch + 1 ) if( rec_epoch == (unsigned) ssl->in_epoch + 1 )
@ -5148,14 +5157,7 @@ static int ssl_parse_record_header( mbedtls_ssl_context const *ssl,
MBEDTLS_SSL_DEBUG_MSG( 2, ( "Consider record for buffering" ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "Consider record for buffering" ) );
return( MBEDTLS_ERR_SSL_EARLY_MESSAGE ); return( MBEDTLS_ERR_SSL_EARLY_MESSAGE );
} }
/* Records from other, non-matching epochs are silently discarded.
* (The case of same-port Client reconnects must be considered in
* the caller). */
else if( rec_epoch != ssl->in_epoch )
{
MBEDTLS_SSL_DEBUG_MSG( 1, ( "record from another epoch: "
"expected %d, received %d",
ssl->in_epoch, rec_epoch ) );
return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD ); return( MBEDTLS_ERR_SSL_UNEXPECTED_RECORD );
} }
#if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY) #if defined(MBEDTLS_SSL_DTLS_ANTI_REPLAY)