Remove PRNG argument from `mbedtls_rsa_complete`
diff --git a/include/mbedtls/rsa.h b/include/mbedtls/rsa.h
index 0c64907..c85e6c8 100644
--- a/include/mbedtls/rsa.h
+++ b/include/mbedtls/rsa.h
@@ -382,8 +382,6 @@
* a set of imported core parameters.
*
* \param ctx Initialized RSA context to store parameters
- * \param f_rng RNG function, or NULL
- * \param p_rng RNG parameter, or NULL
*
* \note
* - To setup an RSA public key, precisely N and E
@@ -399,10 +397,6 @@
* - Alternative implementations need not support these
* and may return \c MBEDTLS_ERR_RSA_BAD_INPUT_DATA instead.
*
- * \note The PRNG is used for the probabilistic algorithm
- * used in the derivation of P, Q from N, D, E. If it
- * not present, a deterministic heuristic is used.
- *
* \return
* - 0 if successful. In this case, it is guaranteed
* that the RSA context can be used for RSA operations
@@ -417,9 +411,7 @@
* of the key material, see \c mbedtls_rsa_check_privkey.
*
*/
-int mbedtls_rsa_complete( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng );
+int mbedtls_rsa_complete( mbedtls_rsa_context *ctx );
/**
* \brief Export core parameters of an RSA key
diff --git a/library/rsa.c b/library/rsa.c
index b932d97..66abcf7 100644
--- a/library/rsa.c
+++ b/library/rsa.c
@@ -601,9 +601,7 @@
return( 0 );
}
-int mbedtls_rsa_complete( mbedtls_rsa_context *ctx,
- int (*f_rng)(void *, unsigned char *, size_t),
- void *p_rng )
+int mbedtls_rsa_complete( mbedtls_rsa_context *ctx )
{
int ret = 0;
@@ -658,7 +656,6 @@
/* This includes sanity checking of core parameters,
* so no further checks necessary. */
ret = mbedtls_rsa_deduce_primes( &ctx->N, &ctx->D, &ctx->E,
- f_rng, p_rng,
&ctx->P, &ctx->Q );
if( ret != 0 )
return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
@@ -666,15 +663,6 @@
}
else if( d_missing )
{
-#if defined(MBEDTLS_GENPRIME)
- /* If a PRNG is provided, check if P, Q are prime. */
- if( f_rng != NULL &&
- ( ( ret = mbedtls_mpi_is_prime( &ctx->P, f_rng, p_rng ) ) != 0 ||
- ( ret = mbedtls_mpi_is_prime( &ctx->Q, f_rng, p_rng ) ) != 0 ) )
- {
- return( MBEDTLS_ERR_RSA_BAD_INPUT_DATA + ret );
- }
-#endif /* MBEDTLS_GENPRIME */
/* Deduce private exponent. This includes double-checking of the result,
* so together with the primality test above all core parameters are
diff --git a/tests/suites/test_suite_rsa.function b/tests/suites/test_suite_rsa.function
index fc27353..8b99eed 100644
--- a/tests/suites/test_suite_rsa.function
+++ b/tests/suites/test_suite_rsa.function
@@ -732,20 +732,11 @@
{
mbedtls_mpi N, P, Pp, Q, Qp, D, E;
- mbedtls_entropy_context entropy;
- mbedtls_ctr_drbg_context ctr_drbg;
- const char *pers = "test_suite_rsa";
-
mbedtls_mpi_init( &N );
mbedtls_mpi_init( &P ); mbedtls_mpi_init( &Q );
mbedtls_mpi_init( &Pp ); mbedtls_mpi_init( &Qp );
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
- mbedtls_ctr_drbg_init( &ctr_drbg );
- mbedtls_entropy_init( &entropy );
- TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy,
- (const unsigned char *) pers, strlen( pers ) ) == 0 );
-
TEST_ASSERT( mbedtls_mpi_read_string( &N, radix_N, input_N ) == 0 );
TEST_ASSERT( mbedtls_mpi_read_string( &D, radix_D, input_D ) == 0 );
TEST_ASSERT( mbedtls_mpi_read_string( &E, radix_E, input_E ) == 0 );
@@ -756,8 +747,7 @@
TEST_ASSERT( mbedtls_mpi_add_int( &D, &D, 2 ) == 0 );
/* Try to deduce P, Q from N, D, E only. */
- TEST_ASSERT( mbedtls_rsa_deduce_primes( &N, &D, &E, mbedtls_ctr_drbg_random,
- &ctr_drbg, &P, &Q ) == result );
+ TEST_ASSERT( mbedtls_rsa_deduce_primes( &N, &D, &E, &P, &Q ) == result );
if( !corrupt )
{
@@ -767,14 +757,10 @@
}
exit:
-
mbedtls_mpi_free( &N );
mbedtls_mpi_free( &P ); mbedtls_mpi_free( &Q );
mbedtls_mpi_free( &Pp ); mbedtls_mpi_free( &Qp );
mbedtls_mpi_free( &D ); mbedtls_mpi_free( &E );
-
- mbedtls_ctr_drbg_free( &ctr_drbg );
- mbedtls_entropy_free( &entropy );
}
/* END_CASE */