From 0b5295848ef9193708821a12eb9eab701a9e7703 Mon Sep 17 00:00:00 2001 From: Neil Armstrong Date: Wed, 11 May 2022 10:10:20 +0200 Subject: [PATCH] Add definition of mbedtls_pk_can_do_ext() Signed-off-by: Neil Armstrong --- include/mbedtls/pk.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/include/mbedtls/pk.h b/include/mbedtls/pk.h index 5225c57a7..57085de6a 100644 --- a/include/mbedtls/pk.h +++ b/include/mbedtls/pk.h @@ -411,6 +411,27 @@ static inline size_t mbedtls_pk_get_len( const mbedtls_pk_context *ctx ) */ int mbedtls_pk_can_do( const mbedtls_pk_context *ctx, mbedtls_pk_type_t type ); +#if defined(MBEDTLS_USE_PSA_CRYPTO) +/** + * \brief Tell if context can do the operation given by PSA algorighm + * + * \param ctx The context to query. It must have been initialized. + * \param alg PSA algorithm to check against, the following are allowed: + * PSA_ALG_RSA_PKCS1V15_SIGN(hash), + * PSA_ALG_RSA_PSS(hash), + * PSA_ALG_RSA_PKCS1V15_CRYPT, + * PSA_ALG_ECDSA(hash), + * PSA_ALG_ECDH, where hash is a specific hash. + * + * \return 1 if the context can do operations on the given type. + * \return 0 if the context cannot do the operations on the given + * type. This is always the case for a context that has + * been initialized but not set up, or that has been + * cleared with mbedtls_pk_free(). + */ +int mbedtls_pk_can_do_ext( const mbedtls_pk_context *ctx, psa_algorithm_t alg ); +#endif /* MBEDTLS_USE_PSA_CRYPTO */ + /** * \brief Verify signature (including padding if relevant). *