From 12cb39661cd8f2daceabc711c2d985c81a53a010 Mon Sep 17 00:00:00 2001 From: Yanray Wang Date: Wed, 1 Mar 2023 10:20:02 +0800 Subject: [PATCH] rsa.c: provide interface to get hash_id of RSA context Signed-off-by: Yanray Wang --- include/mbedtls/rsa.h | 11 +++++++++++ library/rsa.c | 8 ++++++++ 2 files changed, 19 insertions(+) diff --git a/include/mbedtls/rsa.h b/include/mbedtls/rsa.h index da5a47e54..ba3a7605d 100644 --- a/include/mbedtls/rsa.h +++ b/include/mbedtls/rsa.h @@ -191,6 +191,17 @@ int mbedtls_rsa_set_padding(mbedtls_rsa_context *ctx, int padding, */ int mbedtls_rsa_get_padding_mode(const mbedtls_rsa_context *ctx); +/** + * \brief This function retrieves hash identifier of mbedtls_md_type_t + * type. + * + * \param ctx The initialized RSA context. + * + * \return Hash identifier of mbedtls_md_type_t type. + * + */ +int mbedtls_rsa_get_hash_id(const mbedtls_rsa_context *ctx); + /** * \brief This function imports a set of core parameters into an * RSA context. diff --git a/library/rsa.c b/library/rsa.c index ba54d25bc..fc7f3bc27 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -507,6 +507,14 @@ int mbedtls_rsa_get_padding_mode(const mbedtls_rsa_context *ctx) return ctx->MBEDTLS_PRIVATE(padding); } +/* + * Get hash identifier of mbedtls_md_type_t type + */ +int mbedtls_rsa_get_hash_id(const mbedtls_rsa_context *ctx) +{ + return ctx->MBEDTLS_PRIVATE(hash_id); +} + /* * Get length in bytes of RSA modulus */