mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 15:05:45 +01:00
Remove PRNG argument from mbedtls_rsa_complete
This commit is contained in:
parent
1e801f5706
commit
f9e184b9df
@ -382,8 +382,6 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
|
||||
* 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 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
|
||||
* - 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 @@ int mbedtls_rsa_import_raw( mbedtls_rsa_context *ctx,
|
||||
* 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
|
||||
|
@ -601,9 +601,7 @@ cleanup:
|
||||
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 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx,
|
||||
/* 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 @@ int mbedtls_rsa_complete( mbedtls_rsa_context *ctx,
|
||||
}
|
||||
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
|
||||
|
@ -732,20 +732,11 @@ void mbedtls_rsa_deduce_primes( int radix_N, char *input_N,
|
||||
{
|
||||
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 @@ void mbedtls_rsa_deduce_primes( int radix_N, char *input_N,
|
||||
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 @@ void mbedtls_rsa_deduce_primes( int radix_N, char *input_N,
|
||||
}
|
||||
|
||||
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 */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user