tls13: rename mbedtls_ssl_session_check_ticket_flags

The function is renamed to mbedtls_ssl_session_ticket_has_flags.
Descriptions are added.

Signed-off-by: Pengyu Lv <pengyu.lv@arm.com>
This commit is contained in:
Pengyu Lv 2023-11-13 18:07:22 +08:00
parent d72e858fd1
commit 4f537f73fa
2 changed files with 15 additions and 9 deletions

View file

@ -2776,23 +2776,29 @@ static inline unsigned int mbedtls_ssl_session_get_ticket_flags(
(flags & MBEDTLS_SSL_TLS1_3_TICKET_FLAGS_MASK);
}
static inline unsigned int mbedtls_ssl_session_check_ticket_flags(
/**
* Check if at least one of the given flags is set in
* the session ticket. See the definition of
* `MBEDTLS_SSL_TLS1_3_TICKET_FLAGS_MASK` to get all
* permitted flags.
*/
static inline int mbedtls_ssl_session_ticket_has_flags(
mbedtls_ssl_session *session, unsigned int flags)
{
return mbedtls_ssl_session_get_ticket_flags(session, flags) == 0;
return mbedtls_ssl_session_get_ticket_flags(session, flags) != 0;
}
static inline unsigned int mbedtls_ssl_session_ticket_allow_psk(
static inline int mbedtls_ssl_session_ticket_allow_psk(
mbedtls_ssl_session *session)
{
return !mbedtls_ssl_session_check_ticket_flags(session,
return mbedtls_ssl_session_ticket_has_flags(session,
MBEDTLS_SSL_TLS1_3_TICKET_ALLOW_PSK_RESUMPTION);
}
static inline unsigned int mbedtls_ssl_session_ticket_allow_psk_ephemeral(
static inline int mbedtls_ssl_session_ticket_allow_psk_ephemeral(
mbedtls_ssl_session *session)
{
return !mbedtls_ssl_session_check_ticket_flags(session,
return mbedtls_ssl_session_ticket_has_flags(session,
MBEDTLS_SSL_TLS1_3_TICKET_ALLOW_PSK_EPHEMERAL_RESUMPTION);
}

View file

@ -1008,7 +1008,7 @@ static int ssl_tls13_ticket_is_kex_mode_permitted(mbedtls_ssl_context *ssl,
{
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
if (ssl->handshake->resume) {
if (mbedtls_ssl_session_check_ticket_flags(
if (!mbedtls_ssl_session_ticket_has_flags(
ssl->session_negotiate, kex_mode)) {
return 0;
}