From d58ed587fda2059fc30a56e140de2d654b4d5637 Mon Sep 17 00:00:00 2001 From: Thomas Daubney Date: Fri, 21 May 2021 11:50:39 +0100 Subject: [PATCH] Restores erroneously removed checks Some padding checks in rsa.c were erroneously removed in a previous commit and are restored in this commit. Signed-off-by: Thomas Daubney --- library/rsa.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/library/rsa.c b/library/rsa.c index c3b54afda..36424bd19 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -1764,6 +1764,9 @@ static int rsa_rsassa_pss_sign( mbedtls_rsa_context *ctx, hash != NULL ); RSA_VALIDATE_RET( sig != NULL ); + if( ctx->padding != MBEDTLS_RSA_PKCS_V21 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + if( f_rng == NULL ) return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); @@ -2054,6 +2057,9 @@ int mbedtls_rsa_rsassa_pkcs1_v15_sign( mbedtls_rsa_context *ctx, hash != NULL ); RSA_VALIDATE_RET( sig != NULL ); + if( ctx->padding != MBEDTLS_RSA_PKCS_V15 ) + return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA ); + /* * Prepare PKCS1-v1.5 encoding (padding and hash identifier) */