mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-24 15:08:20 +00:00
- Minor DHM code cleanup/comments
This commit is contained in:
parent
f55ec08bc8
commit
ff7fe670bb
2 changed files with 6 additions and 4 deletions
|
@ -64,7 +64,7 @@ int dhm_read_params( dhm_context *ctx,
|
|||
* \brief Setup and write the ServerKeyExchange parameters
|
||||
*
|
||||
* \param ctx DHM context
|
||||
* \param x_size private value size in bits
|
||||
* \param x_size private value size in bytes
|
||||
* \param output destination buffer
|
||||
* \param olen number of chars written
|
||||
* \param f_rng RNG function
|
||||
|
|
|
@ -99,20 +99,22 @@ int dhm_make_params( dhm_context *ctx, int x_size,
|
|||
unsigned char *p;
|
||||
|
||||
/*
|
||||
* generate X and calculate GX = G^X mod P
|
||||
* Generate X as large as possible ( < P )
|
||||
*/
|
||||
n = x_size / sizeof( t_int );
|
||||
MPI_CHK( mpi_grow( &ctx->X, n ) );
|
||||
MPI_CHK( mpi_lset( &ctx->X, 0 ) );
|
||||
|
||||
n = x_size - 1;
|
||||
p = (unsigned char *) ctx->X.p;
|
||||
for( i = 0; i < n; i++ )
|
||||
for( i = 0; i < x_size - 1; i++ )
|
||||
*p++ = (unsigned char) f_rng( p_rng );
|
||||
|
||||
while( mpi_cmp_mpi( &ctx->X, &ctx->P ) >= 0 )
|
||||
mpi_shift_r( &ctx->X, 1 );
|
||||
|
||||
/*
|
||||
* Calculate GX = G^X mod P
|
||||
*/
|
||||
MPI_CHK( mpi_exp_mod( &ctx->GX, &ctx->G, &ctx->X,
|
||||
&ctx->P , &ctx->RP ) );
|
||||
|
||||
|
|
Loading…
Reference in a new issue