mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Turn _SSL_SRV_RESPECT_CLIENT_PREFERENCE config option to a runtime option
Signed-off-by: TRodziewicz <tomasz.rodziewicz@mobica.com>
This commit is contained in:
@ -1872,27 +1872,43 @@ read_record_header:
|
||||
got_common_suite = 0;
|
||||
ciphersuites = ssl->conf->ciphersuite_list;
|
||||
ciphersuite_info = NULL;
|
||||
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
|
||||
for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
|
||||
for( i = 0; ciphersuites[i] != 0; i++ )
|
||||
#else
|
||||
for( i = 0; ciphersuites[i] != 0; i++ )
|
||||
|
||||
if (ssl->conf->respect_cli_pref == MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREF_ENABLED)
|
||||
{
|
||||
for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
|
||||
#endif
|
||||
{
|
||||
if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) ||
|
||||
p[1] != ( ( ciphersuites[i] ) & 0xFF ) )
|
||||
continue;
|
||||
for( i = 0; ciphersuites[i] != 0; i++ )
|
||||
{
|
||||
if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) ||
|
||||
p[1] != ( ( ciphersuites[i] ) & 0xFF ) )
|
||||
continue;
|
||||
|
||||
got_common_suite = 1;
|
||||
got_common_suite = 1;
|
||||
|
||||
if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i],
|
||||
&ciphersuite_info ) ) != 0 )
|
||||
return( ret );
|
||||
if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i],
|
||||
&ciphersuite_info ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
if( ciphersuite_info != NULL )
|
||||
goto have_ciphersuite;
|
||||
}
|
||||
if( ciphersuite_info != NULL )
|
||||
goto have_ciphersuite;
|
||||
}
|
||||
} else {
|
||||
for( i = 0; ciphersuites[i] != 0; i++ )
|
||||
for( j = 0, p = buf + ciph_offset + 2; j < ciph_len; j += 2, p += 2 )
|
||||
{
|
||||
if( p[0] != ( ( ciphersuites[i] >> 8 ) & 0xFF ) ||
|
||||
p[1] != ( ( ciphersuites[i] ) & 0xFF ) )
|
||||
continue;
|
||||
|
||||
got_common_suite = 1;
|
||||
|
||||
if( ( ret = ssl_ciphersuite_match( ssl, ciphersuites[i],
|
||||
&ciphersuite_info ) ) != 0 )
|
||||
return( ret );
|
||||
|
||||
if( ciphersuite_info != NULL )
|
||||
goto have_ciphersuite;
|
||||
}
|
||||
}
|
||||
|
||||
if( got_common_suite )
|
||||
{
|
||||
@ -4416,4 +4432,10 @@ int mbedtls_ssl_handshake_server_step( mbedtls_ssl_context *ssl )
|
||||
|
||||
return( ret );
|
||||
}
|
||||
|
||||
void mbedtls_ssl_conf_respect_client_preference( mbedtls_ssl_config *conf, int enable )
|
||||
{
|
||||
conf->respect_cli_pref = enable;
|
||||
}
|
||||
|
||||
#endif /* MBEDTLS_SSL_SRV_C */
|
||||
|
Reference in New Issue
Block a user