Address kex_modes check function

Signed-off-by: Jerry Yu <jerry.h.yu@arm.com>
This commit is contained in:
Jerry Yu 2021-09-29 21:22:08 +08:00
parent e15e665cfb
commit adf861aad4

View file

@ -1441,6 +1441,16 @@ static inline int mbedtls_ssl_conf_tls13_some_psk_enabled( mbedtls_ssl_context *
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) );
} }
/**
* Given a list of key exchange modes, check if at least one of them is
* supported.
*
* \param[in] ssl SSL context
* \param key_modes_mask Mask of the key exchange modes to check
*
* \return 0 if at least one of the key exchange modes is supported,
* <>0 otherwise.
*/
static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl, static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *ssl,
int kex_modes_mask ) int kex_modes_mask )
{ {
@ -1449,32 +1459,32 @@ static inline unsigned mbedtls_ssl_tls1_3_check_kex_modes( mbedtls_ssl_context *
static inline int mbedtls_ssl_tls1_3_psk_enabled( mbedtls_ssl_context *ssl ) static inline int mbedtls_ssl_tls1_3_psk_enabled( mbedtls_ssl_context *ssl )
{ {
return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl,
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK ) );
} }
static inline int mbedtls_ssl_tls1_3_psk_ephemeral_enabled( static inline int mbedtls_ssl_tls1_3_psk_ephemeral_enabled(
mbedtls_ssl_context *ssl ) mbedtls_ssl_context *ssl )
{ {
return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl,
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_EPHEMERAL ) );
} }
static inline int mbedtls_ssl_tls1_3_ephemeral_enabled( mbedtls_ssl_context *ssl ) static inline int mbedtls_ssl_tls1_3_ephemeral_enabled( mbedtls_ssl_context *ssl )
{ {
return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl,
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL ) );
} }
static inline int mbedtls_ssl_tls1_3_some_ephemeral_enabled( mbedtls_ssl_context *ssl ) static inline int mbedtls_ssl_tls1_3_some_ephemeral_enabled( mbedtls_ssl_context *ssl )
{ {
return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl,
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_EPHEMERAL_ALL ) );
} }
static inline int mbedtls_ssl_tls1_3_some_psk_enabled( mbedtls_ssl_context *ssl ) static inline int mbedtls_ssl_tls1_3_some_psk_enabled( mbedtls_ssl_context *ssl )
{ {
return( mbedtls_ssl_tls1_3_check_kex_modes( ssl, return( ! mbedtls_ssl_tls1_3_check_kex_modes( ssl,
MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) ); MBEDTLS_SSL_TLS13_KEY_EXCHANGE_MODE_PSK_ALL ) );
} }