mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 03:55:44 +01:00
Add tests to constant time mpi comparison
This commit is contained in:
parent
ee6abcedfd
commit
385d5b8682
@ -175,6 +175,39 @@ mbedtls_mpi_cmp_mpi:10:"2":10:"-3":1
|
||||
Base test mbedtls_mpi_cmp_mpi (Mixed values) #6
|
||||
mbedtls_mpi_cmp_mpi:10:"-2":10:"31231231289798":-1
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct #1
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"693":1:10:"693":0:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct #2
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"693":1:10:"692":1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct #3
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"693":1:10:"694":-1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Negative values) #1
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"-2":1:10:"-2":0:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Negative values) #2
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"-2":1:10:"-3":1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Negative values) #3
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"-2":1:10:"-1":-1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Mixed values) #4
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"-3":1:10:"2":-1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Mixed values) #5
|
||||
mbedtls_mpi_cmp_mpi_ct:1:10:"2":1:10:"-3":1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Mixed values) #6
|
||||
mbedtls_mpi_cmp_mpi_ct:2:10:"-2":2:10:"31231231289798":-1:0
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (X is longer in storage) #7
|
||||
mbedtls_mpi_cmp_mpi_ct:3:10:"693":2:10:"693":0:MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Base test mbedtls_mpi_cmp_mpi_ct (Y is longer in storage) #8
|
||||
mbedtls_mpi_cmp_mpi_ct:3:10:"693":4:10:"693":0:MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Base test mbedtls_mpi_cmp_abs #1
|
||||
mbedtls_mpi_cmp_abs:10:"693":10:"693":0
|
||||
|
||||
|
@ -587,6 +587,29 @@ exit:
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_cmp_mpi_ct( int size_X, int radix_X, char * input_X, int size_Y,
|
||||
int radix_Y, char * input_Y, int input_ret, int input_err )
|
||||
{
|
||||
int ret;
|
||||
mbedtls_mpi X, Y;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &Y, radix_Y, input_Y ) == 0 );
|
||||
|
||||
mbedtls_mpi_grow( &X, size_X );
|
||||
mbedtls_mpi_grow( &Y, size_Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi_ct( &X, &Y, &ret ) == input_err );
|
||||
if( input_err == 0 )
|
||||
TEST_ASSERT( ret == input_ret );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free( &X ); mbedtls_mpi_free( &Y );
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_cmp_abs( int radix_X, char * input_X, int radix_Y,
|
||||
char * input_Y, int input_A )
|
||||
|
Loading…
Reference in New Issue
Block a user