Allow use of continue in single-ciphersuite 'loops'

This commit is contained in:
Hanno Becker 2019-07-02 17:13:14 +01:00
parent c5db66af2f
commit f4d6b49352
3 changed files with 7 additions and 38 deletions

View File

@ -1475,12 +1475,12 @@ static inline unsigned int mbedtls_ssl_conf_get_ems_enforced(
#else /* !MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE */
#define MBEDTLS_SSL_BEGIN_FOR_EACH_CIPHERSUITE( ssl, ver, info ) \
{ \
do { \
const mbedtls_ssl_ciphersuite_handle_t info = \
MBEDTLS_SSL_CIPHERSUITE_UNIQUE_VALID_HANDLE;
#define MBEDTLS_SSL_END_FOR_EACH_CIPHERSUITE \
}
} while( 0 );
#endif /* MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE */

View File

@ -984,12 +984,7 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
ssl->conf->min_minor_ver,
ssl->conf->max_minor_ver ) != 0 )
{
/* Logically, we want to continue the ciphersuite iteration
* here, but We can't just use `continue` because
* MBEDTLS_SSL_BEGIN_FOR_EACH_CIPHERSUITE()
* doesn't unfold to a loop in case only a single
* ciphersuite is enabled. */
goto next_suite;
continue;
}
MBEDTLS_SSL_DEBUG_MSG( 3, ( "client hello, add ciphersuite: %04x",
@ -1005,11 +1000,6 @@ static int ssl_write_client_hello( mbedtls_ssl_context *ssl )
mbedtls_ssl_suite_get_id( ciphersuite_info ) >> 8 );
*p++ = (unsigned char)(
mbedtls_ssl_suite_get_id( ciphersuite_info ) );
next_suite:
/* Need something here to avoid
* 'label at end of compound statement' error. */
((void) 0);
}
MBEDTLS_SSL_END_FOR_EACH_CIPHERSUITE
@ -1899,23 +1889,13 @@ static int ssl_parse_server_hello( mbedtls_ssl_context *ssl )
ssl->conf->min_minor_ver,
ssl->conf->max_minor_ver ) != 0 )
{
/* Logically, we want to continue the ciphersuite iteration
* here, but We can't just use `continue` because
* MBEDTLS_SSL_BEGIN_FOR_EACH_CIPHERSUITE()
* doesn't unfold to a loop in case only a single
* ciphersuite is enabled. */
goto next_suite;
continue;
}
if( ciphersuite_info != server_suite_info )
goto next_suite;
continue;
goto server_picked_valid_suite;
next_suite:
/* Need something here to avoid
* 'label at end of compound statement' error. */
((void) 0);
}
MBEDTLS_SSL_END_FOR_EACH_CIPHERSUITE

View File

@ -1251,7 +1251,7 @@ static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl )
p[1] != ( ( ciphersuite_id >> 8 ) & 0xFF ) ||
p[2] != ( ( ciphersuite_id ) & 0xFF ) )
{
goto next_suite;
continue;
}
got_common_suite = 1;
@ -1264,11 +1264,6 @@ static int ssl_parse_client_hello_v2( mbedtls_ssl_context *ssl )
goto have_ciphersuite_v2;
}
next_suite:
/* Need something here to avoid
* 'label at end of compound statement' error. */
((void) 0);
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
}
MBEDTLS_SSL_END_FOR_EACH_CIPHERSUITE
@ -2174,7 +2169,7 @@ read_record_header:
if( p[0] != ( ( ciphersuite_id >> 8 ) & 0xFF ) ||
p[1] != ( ( ciphersuite_id ) & 0xFF ) )
{
goto next_suite;
continue;
}
got_common_suite = 1;
@ -2187,12 +2182,6 @@ read_record_header:
#endif /* MBEDTLS_SSL_CONF_SINGLE_CIPHERSUITE */
goto have_ciphersuite;
}
next_suite:
/* Need something here to avoid
* 'label at end of compound statement' error. */
((void) 0);
#if defined(MBEDTLS_SSL_SRV_RESPECT_CLIENT_PREFERENCE)
}
MBEDTLS_SSL_END_FOR_EACH_CIPHERSUITE