mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-26 10:05:46 +01:00
Fix blunder in 8a109f1
This commit is contained in:
parent
9013af76a3
commit
735b8fcb0b
@ -269,9 +269,9 @@ static int rsa_prepare_blinding( rsa_context *ctx,
|
|||||||
{
|
{
|
||||||
/* We already have blinding values, just update them by squaring */
|
/* We already have blinding values, just update them by squaring */
|
||||||
MPI_CHK( mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) );
|
MPI_CHK( mpi_mul_mpi( &ctx->Vi, &ctx->Vi, &ctx->Vi ) );
|
||||||
MPI_CHK( mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->P ) );
|
MPI_CHK( mpi_mod_mpi( &ctx->Vi, &ctx->Vi, &ctx->N ) );
|
||||||
MPI_CHK( mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) );
|
MPI_CHK( mpi_mul_mpi( &ctx->Vf, &ctx->Vf, &ctx->Vf ) );
|
||||||
MPI_CHK( mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->P ) );
|
MPI_CHK( mpi_mod_mpi( &ctx->Vf, &ctx->Vf, &ctx->N ) );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -374,13 +374,12 @@ void rsa_private( char *message_hex_string, int mod, int radix_P, char *input_P,
|
|||||||
rsa_context ctx;
|
rsa_context ctx;
|
||||||
mpi P1, Q1, H, G;
|
mpi P1, Q1, H, G;
|
||||||
rnd_pseudo_info rnd_info;
|
rnd_pseudo_info rnd_info;
|
||||||
|
int i;
|
||||||
|
|
||||||
mpi_init( &P1 ); mpi_init( &Q1 ); mpi_init( &H ); mpi_init( &G );
|
mpi_init( &P1 ); mpi_init( &Q1 ); mpi_init( &H ); mpi_init( &G );
|
||||||
rsa_init( &ctx, RSA_PKCS_V15, 0 );
|
rsa_init( &ctx, RSA_PKCS_V15, 0 );
|
||||||
|
|
||||||
memset( message_str, 0x00, 1000 );
|
memset( message_str, 0x00, 1000 );
|
||||||
memset( output, 0x00, 1000 );
|
|
||||||
memset( output_str, 0x00, 1000 );
|
|
||||||
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
memset( &rnd_info, 0, sizeof( rnd_pseudo_info ) );
|
||||||
|
|
||||||
ctx.len = mod / 8;
|
ctx.len = mod / 8;
|
||||||
@ -402,12 +401,20 @@ void rsa_private( char *message_hex_string, int mod, int radix_P, char *input_P,
|
|||||||
|
|
||||||
unhexify( message_str, message_hex_string );
|
unhexify( message_str, message_hex_string );
|
||||||
|
|
||||||
TEST_ASSERT( rsa_private( &ctx, rnd_pseudo_rand, &rnd_info, message_str, output ) == result );
|
/* repeat three times to test updating of blinding values */
|
||||||
if( result == 0 )
|
for( i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
hexify( output_str, output, ctx.len );
|
memset( output, 0x00, 1000 );
|
||||||
|
memset( output_str, 0x00, 1000 );
|
||||||
|
TEST_ASSERT( rsa_private( &ctx, rnd_pseudo_rand, &rnd_info,
|
||||||
|
message_str, output ) == result );
|
||||||
|
if( result == 0 )
|
||||||
|
{
|
||||||
|
hexify( output_str, output, ctx.len );
|
||||||
|
|
||||||
TEST_ASSERT( strcasecmp( (char *) output_str, result_hex_str ) == 0 );
|
TEST_ASSERT( strcasecmp( (char *) output_str,
|
||||||
|
result_hex_str ) == 0 );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
mpi_free( &P1 ); mpi_free( &Q1 ); mpi_free( &H ); mpi_free( &G );
|
||||||
|
Loading…
Reference in New Issue
Block a user