mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 13:04:30 +01:00
Reword test cases
Reword test cases to be easier to read and understand. Adds comments to better explain what the test is doing. Signed-off-by: Chris Jones <christopher.jones@arm.com>
This commit is contained in:
parent
4a0ccb6862
commit
a18813ea1c
@ -682,22 +682,22 @@ mbedtls_mpi_exp_mod:10:"23":10:"-13":10:"29":10:"":10:"0":MBEDTLS_ERR_MPI_BAD_IN
|
||||
Base test mbedtls_mpi_exp_mod #6 (Negative base + exponent)
|
||||
mbedtls_mpi_exp_mod:10:"-23":10:"-13":10:"29":10:"":10:"0":MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #7 (MAX_SIZE exponent)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE exponent
|
||||
mbedtls_mpi_exp_mod_size:2:MBEDTLS_MPI_MAX_SIZE:2:10:"":0
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #8 (MAX_SIZE + 1 exponent)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE + 1 exponent
|
||||
mbedtls_mpi_exp_mod_size:2:MBEDTLS_MPI_MAX_SIZE + 1:2:10:"":MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #9 (MAX_SIZE modulus)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE modulus
|
||||
mbedtls_mpi_exp_mod_size:2:2:MBEDTLS_MPI_MAX_SIZE:10:"":0
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #10 (MAX_SIZE + 1 modulus)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE + 1 modulus
|
||||
mbedtls_mpi_exp_mod_size:2:2:MBEDTLS_MPI_MAX_SIZE + 1:10:"":MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #11 (MAX_SIZE exponent and modulus)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE exponent and modulus
|
||||
mbedtls_mpi_exp_mod_size:2:MBEDTLS_MPI_MAX_SIZE:MBEDTLS_MPI_MAX_SIZE:10:"":0
|
||||
|
||||
Base test mbedtls_mpi_exp_mod #12 (MAX_SIZE + 1 exponent and modulus)
|
||||
Test mbedtls_mpi_exp_mod: MAX_SIZE + 1 exponent and modulus
|
||||
mbedtls_mpi_exp_mod_size:2:MBEDTLS_MPI_MAX_SIZE + 1:MBEDTLS_MPI_MAX_SIZE + 1:10:"":MBEDTLS_ERR_MPI_BAD_INPUT_DATA
|
||||
|
||||
Test mbedtls_mpi_exp_mod #1
|
||||
|
@ -1112,28 +1112,31 @@ exit:
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void mbedtls_mpi_exp_mod_size( int A_bytes, int E_bytes, int N_bytes,
|
||||
int radix_RR, char * input_RR, int div_result )
|
||||
int radix_RR, char * input_RR, int exp_result )
|
||||
{
|
||||
mbedtls_mpi A, E, N, RR, Z;
|
||||
mbedtls_mpi_init( &A ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &N );
|
||||
mbedtls_mpi_init( &RR ); mbedtls_mpi_init( &Z );
|
||||
|
||||
/* Set A to 2^(A_bytes - 1) + 1 */
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &A, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &E, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &N, 1 ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &A, ( A_bytes * 8 ) - 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &E, ( E_bytes * 8 ) - 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &N, ( N_bytes * 8 ) - 1 ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &A, 0, 1 ) == 0 );
|
||||
|
||||
/* Set E to 2^(E_bytes - 1) + 1 */
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &E, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &E, ( E_bytes * 8 ) - 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &E, 0, 1 ) == 0 );
|
||||
|
||||
/* Set N to 2^(N_bytes - 1) + 1 */
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &N, 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &N, ( N_bytes * 8 ) - 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &N, 0, 1 ) == 0 );
|
||||
|
||||
if( strlen( input_RR ) )
|
||||
TEST_ASSERT( mbedtls_mpi_read_string( &RR, radix_RR, input_RR ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_exp_mod( &Z, &A, &E, &N, &RR ) == div_result );
|
||||
TEST_ASSERT( mbedtls_mpi_exp_mod( &Z, &A, &E, &N, &RR ) == exp_result );
|
||||
|
||||
exit:
|
||||
mbedtls_mpi_free( &A ); mbedtls_mpi_free( &E ); mbedtls_mpi_free( &N );
|
||||
|
Loading…
Reference in New Issue
Block a user