refactor: move ticket_flags check into a function
Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
parent
766796839b
commit
306a01da4d
1 changed files with 26 additions and 22 deletions
|
@ -964,6 +964,26 @@ static int ssl_tls13_client_hello_has_exts_for_psk_ephemeral_key_exchange(
|
|||
}
|
||||
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED */
|
||||
|
||||
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_PSK_ENABLED)
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_tls13_check_psk_mode_allowed_by_ticket(mbedtls_ssl_context *ssl,
|
||||
unsigned int kex_mode)
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
if (ssl->handshake->resume) {
|
||||
if (!mbedtls_ssl_session_get_ticket_flags(
|
||||
ssl->session_negotiate, kex_mode)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
((void) ssl);
|
||||
((void) kex_mode);
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
#endif /* MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_SOME_PSK_ENABLED */
|
||||
|
||||
MBEDTLS_CHECK_RETURN_CRITICAL
|
||||
static int ssl_tls13_check_ephemeral_key_exchange(mbedtls_ssl_context *ssl)
|
||||
{
|
||||
|
@ -981,17 +1001,9 @@ MBEDTLS_CHECK_RETURN_CRITICAL
|
|||
static int ssl_tls13_check_psk_key_exchange(mbedtls_ssl_context *ssl)
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED)
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
if (ssl->handshake->resume) {
|
||||
if (!mbedtls_ssl_session_get_ticket_flags(
|
||||
ssl->session_negotiate,
|
||||
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return mbedtls_ssl_conf_tls13_psk_enabled(ssl) &&
|
||||
return ssl_tls13_check_psk_mode_allowed_by_ticket(
|
||||
ssl, MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK) &&
|
||||
mbedtls_ssl_conf_tls13_psk_enabled(ssl) &&
|
||||
mbedtls_ssl_tls13_psk_enabled(ssl) &&
|
||||
ssl_tls13_client_hello_has_exts_for_psk_key_exchange(ssl);
|
||||
#else
|
||||
|
@ -1004,17 +1016,9 @@ MBEDTLS_CHECK_RETURN_CRITICAL
|
|||
static int ssl_tls13_check_psk_ephemeral_key_exchange(mbedtls_ssl_context *ssl)
|
||||
{
|
||||
#if defined(MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED)
|
||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||
if (ssl->handshake->resume) {
|
||||
if (!mbedtls_ssl_session_get_ticket_flags(
|
||||
ssl->session_negotiate,
|
||||
MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL)) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return mbedtls_ssl_conf_tls13_psk_ephemeral_enabled(ssl) &&
|
||||
return ssl_tls13_check_psk_mode_allowed_by_ticket(
|
||||
ssl, MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL) &&
|
||||
mbedtls_ssl_conf_tls13_psk_ephemeral_enabled(ssl) &&
|
||||
mbedtls_ssl_tls13_psk_ephemeral_enabled(ssl) &&
|
||||
ssl_tls13_client_hello_has_exts_for_psk_ephemeral_key_exchange(ssl);
|
||||
#else
|
||||
|
|
Loading…
Reference in a new issue