Skip to content
0.2.0-dev Download ZIP
23 lines ·757 B Raw
1#include "mbedtls/pk.h"
2#include "psa/crypto.h"
3
4#ifndef MBEDTLS_UTILS_H
5#define MBEDTLS_UTILS_H
6
7/* Return the PSA algorithm associated to the given combination of "sigalg" and "hash_alg". */
8static inline psa_algorithm_t mbedtls_psa_alg_from_pk_sigalg(mbedtls_pk_sigalg_t sigalg,
9 psa_algorithm_t hash_alg)
10{
11 switch (sigalg) {
12 case MBEDTLS_PK_SIGALG_RSA_PKCS1V15:
13 return PSA_ALG_RSA_PKCS1V15_SIGN(hash_alg);
14 case MBEDTLS_PK_SIGALG_RSA_PSS:
15 return PSA_ALG_RSA_PSS(hash_alg);
16 case MBEDTLS_PK_SIGALG_ECDSA:
17 return MBEDTLS_PK_ALG_ECDSA(hash_alg);
18 default:
19 return PSA_ALG_NONE;
20 }
21}
22
23#endif /* MBEDTLS_UTILS_H */