From 3356b89b64837f4b0e9462e715218d5a3308eac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 5 Jul 2022 10:25:06 +0200 Subject: [PATCH] Add missing guard around call to MD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit PKCS#1 v1.5 mostly does not need hash operations. This is a first step towards allowing builds with PKCS#1 v1.5 only (no v2.1) without MD. Signed-off-by: Manuel Pégourié-Gonnard --- library/rsa.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/rsa.c b/library/rsa.c index e95768f1dd..20983c82ef 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -497,6 +497,7 @@ int mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, return( MBEDTLS_ERR_RSA_INVALID_PADDING ); } +#if defined(MBEDTLS_PKCS1_V21) if( ( padding == MBEDTLS_RSA_PKCS_V21 ) && ( hash_id != MBEDTLS_MD_NONE ) ) { @@ -506,6 +507,7 @@ int mbedtls_rsa_set_padding( mbedtls_rsa_context *ctx, int padding, if( md_info == NULL ) return( MBEDTLS_ERR_RSA_INVALID_PADDING ); } +#endif /* MBEDTLS_PKCS1_V21 */ ctx->padding = padding; ctx->hash_id = hash_id;