mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2025-01-22 13:01:10 +00:00
Check transport in the extension parser/writer
Signed-off-by: Johan Pascal <johan.pascal@belledonne-communications.com>
This commit is contained in:
parent
5ef72d214f
commit
c3ccd98a91
|
@ -768,7 +768,8 @@ static int ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl,
|
|||
|
||||
*olen = 0;
|
||||
|
||||
if( ( ssl->conf->dtls_srtp_profile_list == NULL ) ||
|
||||
if( ( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list == NULL ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list_len == 0 ) )
|
||||
{
|
||||
return( 0 );
|
||||
|
@ -1397,8 +1398,6 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
|
|||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_SRTP)
|
||||
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
|
||||
{
|
||||
if( ( ret = ssl_write_use_srtp_ext( ssl, p + 2 + ext_len,
|
||||
end, &olen ) ) != 0 )
|
||||
{
|
||||
|
@ -1406,7 +1405,6 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
|
|||
return( ret );
|
||||
}
|
||||
ext_len += olen;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
|
@ -1852,8 +1850,9 @@ static int ssl_parse_use_srtp_ext( mbedtls_ssl_context *ssl,
|
|||
uint16_t server_protection_profile_value = 0;
|
||||
|
||||
/* If use_srtp is not configured, just ignore the extension */
|
||||
if( ssl->conf->dtls_srtp_profile_list == NULL ||
|
||||
ssl->conf->dtls_srtp_profile_list_len == 0 )
|
||||
if( ( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list == NULL ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list_len == 0 ) )
|
||||
return( 0 );
|
||||
|
||||
/* RFC 5764 section 4.1.1
|
||||
|
@ -2530,11 +2529,8 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
|
|||
case MBEDTLS_TLS_EXT_USE_SRTP:
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found use_srtp extension" ) );
|
||||
|
||||
if ( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
|
||||
{
|
||||
if( ( ret = ssl_parse_use_srtp_ext( ssl, ext + 4, ext_size ) ) != 0 )
|
||||
return( ret );
|
||||
}
|
||||
|
||||
break;
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
|
|
|
@ -789,8 +789,9 @@ static int ssl_parse_use_srtp_ext( mbedtls_ssl_context *ssl,
|
|||
const size_t size_of_lengths = 3;
|
||||
|
||||
/* If use_srtp is not configured, just ignore the extension */
|
||||
if( ssl->conf->dtls_srtp_profile_list == NULL ||
|
||||
ssl->conf->dtls_srtp_profile_list_len == 0 )
|
||||
if( ( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list == NULL ) ||
|
||||
( ssl->conf->dtls_srtp_profile_list_len == 0 ) )
|
||||
{
|
||||
return( 0 );
|
||||
}
|
||||
|
@ -2065,12 +2066,9 @@ read_record_header:
|
|||
case MBEDTLS_TLS_EXT_USE_SRTP:
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "found use_srtp extension" ) );
|
||||
|
||||
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
|
||||
{
|
||||
ret = ssl_parse_use_srtp_ext( ssl, ext + 4, ext_size );
|
||||
if( ret != 0 )
|
||||
return( ret );
|
||||
}
|
||||
break;
|
||||
#endif /* MBEDTLS_SSL_DTLS_SRTP */
|
||||
|
||||
|
@ -2643,7 +2641,8 @@ static void ssl_write_use_srtp_ext( mbedtls_ssl_context *ssl,
|
|||
|
||||
*olen = 0;
|
||||
|
||||
if( ssl->dtls_srtp_info.chosen_dtls_srtp_profile == MBEDTLS_TLS_SRTP_UNSET )
|
||||
if( ( ssl->conf->transport != MBEDTLS_SSL_TRANSPORT_DATAGRAM ) ||
|
||||
( ssl->dtls_srtp_info.chosen_dtls_srtp_profile == MBEDTLS_TLS_SRTP_UNSET ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -2992,11 +2991,8 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
|||
#endif
|
||||
|
||||
#if defined(MBEDTLS_SSL_DTLS_SRTP)
|
||||
if( ssl->conf->transport == MBEDTLS_SSL_TRANSPORT_DATAGRAM )
|
||||
{
|
||||
ssl_write_use_srtp_ext( ssl, p + 2 + ext_len, &olen );
|
||||
ext_len += olen;
|
||||
}
|
||||
#endif
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG( 3, ( "server hello, total extension length: %d", ext_len ) );
|
||||
|
|
Loading…
Reference in a new issue