|
16 | 16 | #include "debug_internal.h" |
17 | 17 | #include "mbedtls/error.h" |
18 | 18 | #include "mbedtls/constant_time.h" |
| 19 | +#include "mbedtls_utils.h" |
19 | 20 |
|
20 | 21 | #include "psa/crypto.h" |
21 | 22 | #if defined(MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED) |
@@ -1883,6 +1884,7 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl) |
1883 | 1884 | unsigned char hash[MBEDTLS_MD_MAX_SIZE]; |
1884 | 1885 |
|
1885 | 1886 | mbedtls_md_type_t md_alg = MBEDTLS_MD_NONE; |
| 1887 | + psa_algorithm_t psa_hash_alg; |
1886 | 1888 | mbedtls_pk_sigalg_t pk_alg = MBEDTLS_PK_SIGALG_NONE; |
1887 | 1889 | unsigned char *params = ssl->in_msg + mbedtls_ssl_hs_hdr_len(ssl); |
1888 | 1890 | size_t params_len = (size_t) (p - params); |
@@ -1921,7 +1923,10 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl) |
1921 | 1923 | } |
1922 | 1924 | p += 2; |
1923 | 1925 |
|
1924 | | - if (!mbedtls_pk_can_do(peer_pk, (mbedtls_pk_type_t) pk_alg)) { |
| 1926 | + psa_hash_alg = mbedtls_md_psa_alg_from_type(md_alg); |
| 1927 | + if (!mbedtls_pk_can_do_psa(peer_pk, |
| 1928 | + mbedtls_psa_alg_from_pk_sigalg(pk_alg, psa_hash_alg), |
| 1929 | + PSA_KEY_USAGE_VERIFY_HASH)) { |
1925 | 1930 | MBEDTLS_SSL_DEBUG_MSG(1, |
1926 | 1931 | ("bad server key exchange message")); |
1927 | 1932 | mbedtls_ssl_send_alert_message( |
@@ -1977,14 +1982,6 @@ static int ssl_parse_server_key_exchange(mbedtls_ssl_context *ssl) |
1977 | 1982 | /* |
1978 | 1983 | * Verify signature |
1979 | 1984 | */ |
1980 | | - if (!mbedtls_pk_can_do(peer_pk, (mbedtls_pk_type_t) pk_alg)) { |
1981 | | - MBEDTLS_SSL_DEBUG_MSG(1, ("bad server key exchange message")); |
1982 | | - mbedtls_ssl_send_alert_message( |
1983 | | - ssl, |
1984 | | - MBEDTLS_SSL_ALERT_LEVEL_FATAL, |
1985 | | - MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE); |
1986 | | - return MBEDTLS_ERR_SSL_PK_TYPE_MISMATCH; |
1987 | | - } |
1988 | 1985 |
|
1989 | 1986 | #if defined(MBEDTLS_SSL_ECP_RESTARTABLE_ENABLED) |
1990 | 1987 | if (ssl->handshake->ecrs_enabled) { |
|
0 commit comments