mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 01:05:40 +01:00
- Fill full buffer (Wrong parameter usage)
This commit is contained in:
parent
380da53c48
commit
901c65620e
@ -1813,7 +1813,7 @@ int mpi_is_prime( mpi *X,
|
||||
/*
|
||||
* pick a random A, 1 < A < |X| - 1
|
||||
*/
|
||||
MPI_CHK( mpi_fill_random( &A, X->n, f_rng, p_rng ) );
|
||||
MPI_CHK( mpi_fill_random( &A, X->n * ciL, f_rng, p_rng ) );
|
||||
|
||||
if( mpi_cmp_mpi( &A, &W ) >= 0 )
|
||||
{
|
||||
@ -1885,7 +1885,7 @@ int mpi_gen_prime( mpi *X, size_t nbits, int dh_flag,
|
||||
|
||||
n = BITS_TO_LIMBS( nbits );
|
||||
|
||||
MPI_CHK( mpi_fill_random( X, n, f_rng, p_rng ) );
|
||||
MPI_CHK( mpi_fill_random( X, n * ciL, f_rng, p_rng ) );
|
||||
|
||||
k = mpi_msb( X );
|
||||
if( k < nbits ) MPI_CHK( mpi_shift_l( X, nbits - k ) );
|
||||
|
@ -124,16 +124,14 @@ int dhm_make_params( dhm_context *ctx, int x_size,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng )
|
||||
{
|
||||
int ret, n;
|
||||
int ret;
|
||||
size_t n1, n2, n3;
|
||||
unsigned char *p;
|
||||
|
||||
/*
|
||||
* Generate X as large as possible ( < P )
|
||||
*/
|
||||
n = x_size / sizeof( t_uint ) + 1;
|
||||
|
||||
mpi_fill_random( &ctx->X, n, f_rng, p_rng );
|
||||
mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
|
||||
|
||||
while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
|
||||
mpi_shift_r( &ctx->X, 1 );
|
||||
@ -201,7 +199,7 @@ int dhm_make_public( dhm_context *ctx, int x_size,
|
||||
int (*f_rng)(void *, unsigned char *, size_t),
|
||||
void *p_rng )
|
||||
{
|
||||
int ret, n;
|
||||
int ret;
|
||||
|
||||
if( ctx == NULL || olen < 1 || olen > ctx->len )
|
||||
return( POLARSSL_ERR_DHM_BAD_INPUT_DATA );
|
||||
@ -209,9 +207,7 @@ int dhm_make_public( dhm_context *ctx, int x_size,
|
||||
/*
|
||||
* generate X and calculate GX = G^X mod P
|
||||
*/
|
||||
n = x_size / sizeof( t_uint ) + 1;
|
||||
|
||||
mpi_fill_random( &ctx->X, n, f_rng, p_rng );
|
||||
mpi_fill_random( &ctx->X, x_size, f_rng, p_rng );
|
||||
|
||||
while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
|
||||
mpi_shift_r( &ctx->X, 1 );
|
||||
|
Loading…
Reference in New Issue
Block a user