Fix compilation issue when DTLS and SSL_HW_RECORD_ACCEL are on

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Andres Amaya Garcia 2018-12-05 21:57:57 +00:00 committed by Manuel Pégourié-Gonnard
parent 0fce215851
commit 52dbda62a0
2 changed files with 22 additions and 8 deletions

View File

@ -1,5 +1,11 @@
mbed TLS ChangeLog (Sorted per branch, date) mbed TLS ChangeLog (Sorted per branch, date)
= mbed TLS x.x.x branch released xxxx-xx-xx
Bugfix
* Fix compilation failure when both MBEDTLS_SSL_PROTO_DTLS and
MBEDTLS_SSL_HW_RECORD_ACCEL are enabled.
= mbed TLS 2.16.5 branch released 2020-02-20 = mbed TLS 2.16.5 branch released 2020-02-20
Security Security

View File

@ -1004,8 +1004,6 @@ int mbedtls_ssl_derive_keys( mbedtls_ssl_context *ssl )
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL) #if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
if( mbedtls_ssl_hw_record_init != NULL ) if( mbedtls_ssl_hw_record_init != NULL )
{ {
int ret = 0;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_init()" ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "going for mbedtls_ssl_hw_record_init()" ) );
if( ( ret = mbedtls_ssl_hw_record_init( ssl, key1, key2, transform->keylen, if( ( ret = mbedtls_ssl_hw_record_init( ssl, key1, key2, transform->keylen,
@ -2885,15 +2883,18 @@ static void ssl_dtls_replay_reset( mbedtls_ssl_context *ssl );
/* /*
* Swap transform_out and out_ctr with the alternative ones * Swap transform_out and out_ctr with the alternative ones
*/ */
static void ssl_swap_epochs( mbedtls_ssl_context *ssl ) static int ssl_swap_epochs( mbedtls_ssl_context *ssl )
{ {
mbedtls_ssl_transform *tmp_transform; mbedtls_ssl_transform *tmp_transform;
unsigned char tmp_out_ctr[8]; unsigned char tmp_out_ctr[8];
#if defined(MBEDTLS_SSL_HW_RECORD_ACCEL)
int ret;
#endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
if( ssl->transform_out == ssl->handshake->alt_transform_out ) if( ssl->transform_out == ssl->handshake->alt_transform_out )
{ {
MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip swap epochs" ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "skip swap epochs" ) );
return; return( 0 );
} }
MBEDTLS_SSL_DEBUG_MSG( 3, ( "swap epochs" ) ); MBEDTLS_SSL_DEBUG_MSG( 3, ( "swap epochs" ) );
@ -2920,7 +2921,9 @@ static void ssl_swap_epochs( mbedtls_ssl_context *ssl )
return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED ); return( MBEDTLS_ERR_SSL_HW_ACCEL_FAILED );
} }
} }
#endif #endif /* MBEDTLS_SSL_HW_RECORD_ACCEL */
return( 0 );
} }
/* /*
@ -2957,7 +2960,8 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl )
ssl->handshake->cur_msg = ssl->handshake->flight; ssl->handshake->cur_msg = ssl->handshake->flight;
ssl->handshake->cur_msg_p = ssl->handshake->flight->p + 12; ssl->handshake->cur_msg_p = ssl->handshake->flight->p + 12;
ssl_swap_epochs( ssl ); if( ( ret = ssl_swap_epochs( ssl ) ) != 0 )
return( ret );
ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING; ssl->handshake->retransmit_state = MBEDTLS_SSL_RETRANS_SENDING;
} }
@ -2980,7 +2984,8 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl )
if( is_finished && ssl->handshake->cur_msg_p == ( cur->p + 12 ) ) if( is_finished && ssl->handshake->cur_msg_p == ( cur->p + 12 ) )
{ {
MBEDTLS_SSL_DEBUG_MSG( 2, ( "swap epochs to send finished message" ) ); MBEDTLS_SSL_DEBUG_MSG( 2, ( "swap epochs to send finished message" ) );
ssl_swap_epochs( ssl ); if( ( ret = ssl_swap_epochs( ssl ) ) != 0 )
return( ret );
} }
ret = ssl_get_remaining_payload_in_datagram( ssl ); ret = ssl_get_remaining_payload_in_datagram( ssl );
@ -3017,7 +3022,10 @@ int mbedtls_ssl_flight_transmit( mbedtls_ssl_context *ssl )
if( ( max_frag_len < 12 ) || ( max_frag_len == 12 && hs_len != 0 ) ) if( ( max_frag_len < 12 ) || ( max_frag_len == 12 && hs_len != 0 ) )
{ {
if( is_finished ) if( is_finished )
ssl_swap_epochs( ssl ); {
if( ( ret = ssl_swap_epochs( ssl ) ) != 0 )
return( ret );
}
if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 ) if( ( ret = mbedtls_ssl_flush_output( ssl ) ) != 0 )
return( ret ); return( ret );