Skip to content

Commit 7b2d72a

Browse files
committed
ssl: replace PSA_ALG_ECDSA with MBEDTLS_PK_ALG_ECDSA
When the key is parsed from PK it is assigned the pseudo-alg MBEDTLS_PK_ALG_ECDSA. Trying to run "mbedtls_pk_can_do_psa" with an hardcoded deterministc/randomized ECDSA can make the function to fail if the proper variant is not the one also used by PK. This commit fixes this problem. Signed-off-by: Valerio Setti <[email protected]>
1 parent 0009b04 commit 7b2d72a

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

library/ssl_ciphersuites.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ psa_algorithm_t mbedtls_ssl_get_ciphersuite_sig_pk_psa_alg(const mbedtls_ssl_cip
924924
mbedtls_md_psa_alg_from_type((mbedtls_md_type_t) info->mac));
925925

926926
case MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA:
927-
return PSA_ALG_ECDSA(mbedtls_md_psa_alg_from_type((mbedtls_md_type_t) info->mac));
927+
return MBEDTLS_PK_ALG_ECDSA(mbedtls_md_psa_alg_from_type((mbedtls_md_type_t) info->mac));
928928

929929
default:
930930
return PSA_ALG_NONE;

library/ssl_tls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8148,7 +8148,7 @@ unsigned int mbedtls_ssl_tls12_get_preferred_hash_for_sig_alg(
81488148

81498149
if (sig_alg_received == MBEDTLS_SSL_SIG_ECDSA &&
81508150
!mbedtls_pk_can_do_psa(ssl->handshake->key_cert->key,
8151-
PSA_ALG_ECDSA(psa_hash_alg),
8151+
MBEDTLS_PK_ALG_ECDSA(psa_hash_alg),
81528152
PSA_KEY_USAGE_SIGN_HASH)) {
81538153
continue;
81548154
}

library/ssl_tls13_server.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,11 +1076,11 @@ static psa_algorithm_t ssl_tls13_iana_sig_alg_to_psa_alg(uint16_t sig_alg)
10761076
{
10771077
switch (sig_alg) {
10781078
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP256R1_SHA256:
1079-
return PSA_ALG_ECDSA(PSA_ALG_SHA_256);
1079+
return MBEDTLS_PK_ALG_ECDSA(PSA_ALG_SHA_256);
10801080
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP384R1_SHA384:
1081-
return PSA_ALG_ECDSA(PSA_ALG_SHA_384);
1081+
return MBEDTLS_PK_ALG_ECDSA(PSA_ALG_SHA_384);
10821082
case MBEDTLS_TLS1_3_SIG_ECDSA_SECP521R1_SHA512:
1083-
return PSA_ALG_ECDSA(PSA_ALG_SHA_512);
1083+
return MBEDTLS_PK_ALG_ECDSA(PSA_ALG_SHA_512);
10841084
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA256:
10851085
return PSA_ALG_RSA_PSS(PSA_ALG_SHA_256);
10861086
case MBEDTLS_TLS1_3_SIG_RSA_PSS_RSAE_SHA384:

0 commit comments

Comments
 (0)