mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-22 17:15:38 +01:00
Tests and fix added for #309 (inplace mpi doubling).
This commit is contained in:
parent
a3a1cd33d1
commit
87f1494809
@ -893,7 +893,12 @@ int mpi_add_abs( mpi *X, const mpi *A, const mpi *B )
|
||||
|
||||
if( X == B )
|
||||
{
|
||||
const mpi *T = A; A = X; B = T;
|
||||
const mpi *T;
|
||||
|
||||
if( B == A)
|
||||
return mpi_shift_l( X, 1 );
|
||||
|
||||
T = A; A = X; B = T;
|
||||
}
|
||||
|
||||
if( X != A )
|
||||
|
@ -295,6 +295,12 @@ mpi_add_mpi:10:"2039568783564019774057658669290345772801939933143482630947726464
|
||||
Test mpi_add_mpi #2
|
||||
mpi_add_mpi:10:"643808006803554439230129854961492699151386107534013432918073439524138264842370630061369715394739134090922937332590384720397133335969549256322620979036686633213903952966175107096769180017646161851573147596390153":10:"56125680981752282333498088313568935051383833838594899821664631784577337171193624243181360054669678410455329112434552942717084003541384594864129940145043086760031292483340068923506115878221189886491132772739661669044958531131327771":10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924"
|
||||
|
||||
Base test mpi_add_mpi inplace #1
|
||||
mpi_add_mpi_inplace:10:"12345678":10:"24691356"
|
||||
|
||||
Test mpi_add_mpi inplace #2
|
||||
mpi_add_mpi_inplace:10:"643808006803554439230129854961492699151386107534013432918073439524138264842370630061369715394739134090922937332590384720397133335969549256322620979036686633213903952966175107096769180017646161851573147596390153":10:"1287616013607108878460259709922985398302772215068026865836146879048276529684741260122739430789478268181845874665180769440794266671939098512645241958073373266427807905932350214193538360035292323703146295192780306"
|
||||
|
||||
Test mpi_add_int #1
|
||||
mpi_add_int:10:"2039568783564019774057658669290345772801939933143482630947726464532830627227012776329":9871232:10:"2039568783564019774057658669290345772801939933143482630947726464532830627227022647561"
|
||||
|
||||
|
@ -439,6 +439,23 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_add_mpi_inplace( int radix_X, char *input_X, int radix_A, char *input_A )
|
||||
{
|
||||
mpi X, A;
|
||||
mpi_init( &X ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mpi_read_string( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mpi_add_mpi( &X, &X, &X ) == 0 );
|
||||
TEST_ASSERT( mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mpi_free( &X ); mbedtls_mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mpi_add_abs( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
int radix_A, char *input_A )
|
||||
|
Loading…
Reference in New Issue
Block a user