From f90c04d6465d1ad6b4c7e36d831acb526d010a39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Wed, 3 Dec 2025 11:35:28 +0100 Subject: [PATCH] RSA: remove undocumented check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This only made the function harder to use. Signed-off-by: Manuel Pégourié-Gonnard --- library/rsa.c | 1 - library/rsa_alt_helpers.c | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/library/rsa.c b/library/rsa.c index 41a437ba3f..93b47d52ed 100644 --- a/library/rsa.c +++ b/library/rsa.c @@ -1101,7 +1101,6 @@ int mbedtls_rsa_gen_key(mbedtls_rsa_context *ctx, * if it exists (FIPS 186-4 §B.3.1 criterion 2(a)) */ ret = mbedtls_rsa_deduce_private_exponent(&ctx->P, &ctx->Q, &ctx->E, &ctx->D); if (ret == MBEDTLS_ERR_MPI_NOT_ACCEPTABLE) { - mbedtls_mpi_lset(&ctx->D, 0); /* needed for the next call */ continue; } if (ret != 0) { diff --git a/library/rsa_alt_helpers.c b/library/rsa_alt_helpers.c index 50a5c4e0d7..8a09f93a3e 100644 --- a/library/rsa_alt_helpers.c +++ b/library/rsa_alt_helpers.c @@ -188,7 +188,7 @@ int mbedtls_rsa_deduce_private_exponent(mbedtls_mpi const *P, int ret = 0; mbedtls_mpi K, L; - if (D == NULL || mbedtls_mpi_cmp_int(D, 0) != 0) { + if (D == NULL) { return MBEDTLS_ERR_MPI_BAD_INPUT_DATA; }