mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-25 03:48:53 +00:00
Tests and fix added for #309 (inplace mpi doubling).
This commit is contained in:
parent
c4e7d8a381
commit
044a86bde8
3 changed files with 29 additions and 1 deletions
|
@ -862,7 +862,12 @@ int mbedtls_mpi_add_abs( mbedtls_mpi *X, const mbedtls_mpi *A, const mbedtls_mpi
|
|||
|
||||
if( X == B )
|
||||
{
|
||||
const mbedtls_mpi *T = A; A = X; B = T;
|
||||
const mbedtls_mpi *T;
|
||||
|
||||
if( B == A)
|
||||
return mbedtls_mpi_shift_l( X, 1 );
|
||||
|
||||
T = A; A = X; B = T;
|
||||
}
|
||||
|
||||
if( X != A )
|
||||
|
|
|
@ -295,6 +295,12 @@ mbedtls_mpi_add_mpi:10:"20395687835640197740576586692903457728019399331434826309
|
|||
Test mbedtls_mpi_add_mpi #2
|
||||
mbedtls_mpi_add_mpi:10:"643808006803554439230129854961492699151386107534013432918073439524138264842370630061369715394739134090922937332590384720397133335969549256322620979036686633213903952966175107096769180017646161851573147596390153":10:"56125680981752282333498088313568935051383833838594899821664631784577337171193624243181360054669678410455329112434552942717084003541384594864129940145043086760031292483340068923506115878221189886491132772739661669044958531131327771":10:"56125680981752282334141896320372489490613963693556392520816017892111350604111697682705498319512049040516698827829292076808006940873974979584527073481012636016353913462376755556720019831187364993587901952757307830896531678727717924"
|
||||
|
||||
Base test mbedtls_mpi_add_mpi inplace #1
|
||||
mbedtls_mpi_add_mpi_inplace:10:"12345678":10:"24691356"
|
||||
|
||||
Test mbedtls_mpi_add_mpi inplace #2
|
||||
mbedtls_mpi_add_mpi_inplace:10:"643808006803554439230129854961492699151386107534013432918073439524138264842370630061369715394739134090922937332590384720397133335969549256322620979036686633213903952966175107096769180017646161851573147596390153":10:"1287616013607108878460259709922985398302772215068026865836146879048276529684741260122739430789478268181845874665180769440794266671939098512645241958073373266427807905932350214193538360035292323703146295192780306"
|
||||
|
||||
Test mbedtls_mpi_add_int #1
|
||||
mbedtls_mpi_add_int:10:"2039568783564019774057658669290345772801939933143482630947726464532830627227012776329":9871232:10:"2039568783564019774057658669290345772801939933143482630947726464532830627227022647561"
|
||||
|
||||
|
|
|
@ -442,6 +442,23 @@ exit:
|
|||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_add_mpi_inplace( int radix_X, char *input_X, int radix_A, char *input_A )
|
||||
{
|
||||
mbedtls_mpi X, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_mpi( &X, &X, &X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free( &X ); mbedtls_mpi_free( &A );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_add_abs( int radix_X, char *input_X, int radix_Y, char *input_Y,
|
||||
int radix_A, char *input_A )
|
||||
|
|
Loading…
Reference in a new issue