rsa.c: provide interface to get padding mode of RSA context
Signed-off-by: Yanray Wang <yanray.wang@arm.com>
diff --git a/include/mbedtls/rsa.h b/include/mbedtls/rsa.h
index d77a538..da5a47e 100644
--- a/include/mbedtls/rsa.h
+++ b/include/mbedtls/rsa.h
@@ -182,6 +182,16 @@
mbedtls_md_type_t hash_id);
/**
+ * \brief This function retrieves padding mode of RSA modulus.
+ *
+ * \param ctx The initialized RSA context.
+ *
+ * \return RSA padding mode.
+ *
+ */
+int mbedtls_rsa_get_padding_mode(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 df7d797..ba54d25 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -500,9 +500,16 @@
}
/*
+ * Get padding mode of RSA modulus
+ */
+int mbedtls_rsa_get_padding_mode(const mbedtls_rsa_context *ctx)
+{
+ return ctx->MBEDTLS_PRIVATE(padding);
+}
+
+/*
* Get length in bytes of RSA modulus
*/
-
size_t mbedtls_rsa_get_len(const mbedtls_rsa_context *ctx)
{
return ctx->len;