mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-12-14 02:22:15 +03:00
The correct return type should have been "psa_algorithm_t" since the beginning because this is what the function really returns and this is what the returned value is then used for in the calling functions. Change also the returned value in the default case from MBEDTLS_PK_SIGALG_NONE to PSA_ALG_NONE in order to return the same type as in other cases of the switch case. Signed-off-by: Valerio Setti <valerio.setti@nordicsemi.no>
24 lines
757 B
C
24 lines
757 B
C
#include "mbedtls/pk.h"
|
|
#include "psa/crypto.h"
|
|
|
|
#ifndef MBEDTLS_UTILS_H
|
|
#define MBEDTLS_UTILS_H
|
|
|
|
/* Return the PSA algorithm associated to the given combination of "sigalg" and "hash_alg". */
|
|
static inline psa_algorithm_t mbedtls_psa_alg_from_pk_sigalg(mbedtls_pk_sigalg_t sigalg,
|
|
psa_algorithm_t hash_alg)
|
|
{
|
|
switch (sigalg) {
|
|
case MBEDTLS_PK_SIGALG_RSA_PKCS1V15:
|
|
return PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg);
|
|
case MBEDTLS_PK_SIGALG_RSA_PSS:
|
|
return PSA_ALG_RSA_PSS(hash_alg);
|
|
case MBEDTLS_PK_SIGALG_ECDSA:
|
|
return MBEDTLS_PK_ALG_ECDSA(hash_alg);
|
|
default:
|
|
return PSA_ALG_NONE;
|
|
}
|
|
}
|
|
|
|
#endif /* MBEDTLS_UTILS_H */
|