Code cleanup
Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
parent
1051f856dc
commit
75a5a9c205
15 changed files with 65 additions and 118 deletions
|
@ -248,11 +248,6 @@ static int ssl_tls13_get_default_group_id(mbedtls_ssl_context *ssl,
|
|||
((void) group_id);
|
||||
#endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
|
||||
|
||||
/*
|
||||
* Add DHE named groups here.
|
||||
* Pick first available DHE group compatible with TLS 1.3
|
||||
*/
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -386,7 +381,7 @@ static int ssl_tls13_parse_hrr_key_share_ext(mbedtls_ssl_context *ssl,
|
|||
const unsigned char *buf,
|
||||
const unsigned char *end)
|
||||
{
|
||||
#if defined(PSA_WANT_ALG_ECDH)
|
||||
#if defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)
|
||||
const unsigned char *p = buf;
|
||||
int selected_group;
|
||||
int found = 0;
|
||||
|
@ -413,6 +408,7 @@ static int ssl_tls13_parse_hrr_key_share_ext(mbedtls_ssl_context *ssl,
|
|||
* then the client MUST abort the handshake with an "illegal_parameter" alert.
|
||||
*/
|
||||
for (; *group_list != 0; group_list++) {
|
||||
#if defined(PSA_WANT_ALG_ECDH)
|
||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(*group_list)) {
|
||||
if ((mbedtls_ssl_get_psa_curve_info_from_tls_id(
|
||||
*group_list, NULL, NULL) == PSA_ERROR_NOT_SUPPORTED) ||
|
||||
|
@ -421,10 +417,13 @@ static int ssl_tls13_parse_hrr_key_share_ext(mbedtls_ssl_context *ssl,
|
|||
break;
|
||||
}
|
||||
}
|
||||
#endif /* PSA_WANT_ALG_ECDH */
|
||||
#if defined(PSA_WANT_ALG_FFDH)
|
||||
if (mbedtls_ssl_tls13_named_group_is_dhe(*group_list)) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
#endif /* PSA_WANT_ALG_FFDH */
|
||||
}
|
||||
|
||||
/* Client MUST verify that the selected_group field does not
|
||||
|
@ -446,12 +445,12 @@ static int ssl_tls13_parse_hrr_key_share_ext(mbedtls_ssl_context *ssl,
|
|||
ssl->handshake->offered_group_id = selected_group;
|
||||
|
||||
return 0;
|
||||
#else
|
||||
#else /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
|
||||
(void) ssl;
|
||||
(void) buf;
|
||||
(void) end;
|
||||
return MBEDTLS_ERR_SSL_BAD_CONFIG;
|
||||
#endif
|
||||
#endif /* PSA_WANT_ALG_ECDH || PSA_WANT_ALG_FFDH */
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -497,25 +496,10 @@ static int ssl_tls13_parse_key_share_ext(mbedtls_ssl_context *ssl,
|
|||
#if defined(PSA_WANT_ALG_ECDH) || defined(PSA_WANT_ALG_FFDH)
|
||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group) ||
|
||||
mbedtls_ssl_tls13_named_group_is_dhe(group)) {
|
||||
#if defined(PSA_WANT_ALG_ECDH)
|
||||
if (mbedtls_ssl_tls13_named_group_is_ecdhe(group)) {
|
||||
if (mbedtls_ssl_get_psa_curve_info_from_tls_id(group, NULL, NULL)
|
||||
== PSA_ERROR_NOT_SUPPORTED) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(1, ("Invalid TLS curve group id"));
|
||||
return MBEDTLS_ERR_SSL_INTERNAL_ERROR;
|
||||
}
|
||||
|
||||
MBEDTLS_SSL_DEBUG_MSG(
|
||||
2,
|
||||
("ECDH curve: %s", mbedtls_ssl_get_curve_name_from_tls_id(group)));
|
||||
}
|
||||
#endif /* PSA_WANT_ALG_ECDH */
|
||||
#if defined(PSA_WANT_ALG_FFDH)
|
||||
if (mbedtls_ssl_tls13_named_group_is_dhe(group)) {
|
||||
MBEDTLS_SSL_DEBUG_MSG(2,
|
||||
("DHE group name: %s", mbedtls_ssl_ffdh_name_from_group(group)));
|
||||
}
|
||||
#endif /* PSA_WANT_ALG_FFDH */
|
||||
#if defined(MBEDTLS_DEBUG_C)
|
||||
MBEDTLS_SSL_DEBUG_MSG(2,
|
||||
("DHE group name: %s", mbedtls_ssl_named_group_to_str(group)));
|
||||
#endif
|
||||
ret = mbedtls_ssl_tls13_read_public_ecdhe_share(ssl, p, end - p);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue