Remove radix arg from mbedtls_test_read_mpi
All uses have radix argument removed, using script. Signed-off-by: Werner Lewis <werner.lewis@arm.com>
This commit is contained in:
parent
78ddc3e8fc
commit
19b4cd893c
13 changed files with 255 additions and 256 deletions
|
@ -276,7 +276,7 @@ void mbedtls_test_err_add_check( int high, int low,
|
|||
#endif
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
/** Read an MPI from a string.
|
||||
/** Read an MPI from a hexadecimal string.
|
||||
*
|
||||
* Like mbedtls_mpi_read_string(), but size the resulting bignum based
|
||||
* on the number of digits in the string. In particular, construct a
|
||||
|
@ -287,13 +287,12 @@ void mbedtls_test_err_add_check( int high, int low,
|
|||
* "leading zeros" test cases do what they claim.
|
||||
*
|
||||
* \param[out] X The MPI object to populate. It must be initialized.
|
||||
* \param radix The radix (2 to 16).
|
||||
* \param[in] s The null-terminated string to read from.
|
||||
* \param[in] s The null-terminated hexadecimal string to read from.
|
||||
*
|
||||
* \return \c 0 on success, an \c MBEDTLS_ERR_MPI_xxx error code otherwise.
|
||||
*/
|
||||
/* Since the library has exactly the desired behavior, this is trivial. */
|
||||
int mbedtls_test_read_mpi( mbedtls_mpi *X, int radix, const char *s );
|
||||
int mbedtls_test_read_mpi( mbedtls_mpi *X, const char *s );
|
||||
#endif /* MBEDTLS_BIGNUM_C */
|
||||
|
||||
#endif /* TEST_HELPERS_H */
|
||||
|
|
|
@ -332,7 +332,7 @@ void mbedtls_test_err_add_check( int high, int low,
|
|||
#endif /* MBEDTLS_TEST_HOOKS */
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
int mbedtls_test_read_mpi( mbedtls_mpi *X, int radix, const char *s )
|
||||
int mbedtls_test_read_mpi( mbedtls_mpi *X, const char *s )
|
||||
{
|
||||
/* mbedtls_mpi_read_string() currently retains leading zeros.
|
||||
* It always allocates at least one limb for the value 0. */
|
||||
|
@ -342,6 +342,6 @@ int mbedtls_test_read_mpi( mbedtls_mpi *X, int radix, const char *s )
|
|||
return( 0 );
|
||||
}
|
||||
else
|
||||
return( mbedtls_mpi_read_string( X, radix, s ) );
|
||||
return( mbedtls_mpi_read_string( X, 16, s ) );
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -417,7 +417,7 @@ void get_integer( const data_t *input,
|
|||
}
|
||||
|
||||
#if defined(MBEDTLS_BIGNUM_C)
|
||||
ret = mbedtls_test_read_mpi( &expected_mpi, 16, expected_hex );
|
||||
ret = mbedtls_test_read_mpi( &expected_mpi, expected_hex );
|
||||
TEST_ASSERT( ret == 0 || ret == MBEDTLS_ERR_MPI_BAD_INPUT_DATA );
|
||||
if( ret == MBEDTLS_ERR_MPI_BAD_INPUT_DATA )
|
||||
{
|
||||
|
|
|
@ -206,7 +206,7 @@ void mbedtls_debug_print_mpi( int radix, char * value, char * file, int line,
|
|||
|
||||
TEST_ASSERT( mbedtls_ssl_setup( &ssl, &conf ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &val, radix, value ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &val, value ) == 0 );
|
||||
|
||||
mbedtls_debug_print_mpi( &ssl, 0, file, line, prefix, &val);
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ void dhm_do_dhm( int radix_P, char *input_P, int x_size,
|
|||
/*
|
||||
* Set params
|
||||
*/
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx_srv.P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx_srv.G, radix_G, input_G ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx_srv.P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx_srv.G, input_G ) == 0 );
|
||||
pub_cli_len = mbedtls_mpi_size( &ctx_srv.P );
|
||||
TEST_ASSERT( check_get_value( &ctx_srv, MBEDTLS_DHM_PARAM_P, &ctx_srv.P ) );
|
||||
TEST_ASSERT( check_get_value( &ctx_srv, MBEDTLS_DHM_PARAM_G, &ctx_srv.G ) );
|
||||
|
@ -239,7 +239,7 @@ void dhm_make_public( int P_bytes, int radix_G, char *input_G, int result )
|
|||
TEST_ASSERT( mbedtls_mpi_shift_l( &P, ( P_bytes * 8 ) - 1 ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &P, 0, 1 ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &G, radix_G, input_G ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &G, input_G ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_set_group( &ctx, &P, &G ) == 0 );
|
||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx, (int) mbedtls_mpi_size( &P ),
|
||||
|
@ -263,8 +263,8 @@ void dhm_file( char * filename, char * p, char * g, int len )
|
|||
mbedtls_dhm_init( &ctx );
|
||||
mbedtls_mpi_init( &P ); mbedtls_mpi_init( &G );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, 16, p ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &G, 16, g ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, p ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &G, g ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_dhm_parse_dhmfile( &ctx, filename ) == 0 );
|
||||
|
||||
|
|
|
@ -157,21 +157,21 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
|||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_A ) == 0 );
|
||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qA ) );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, 16, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.X, &check ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, 16, yA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, yA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.Y, &check ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
||||
mbedtls_test_rnd_buffer_rand,
|
||||
&rnd_info_B ) == 0 );
|
||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qB ) );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, 16, xB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, xB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qB.X, &check ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, 16, yB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, yB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qB.Y, &check ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, 16, z_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &check, z_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zA, &qB, &dA,
|
||||
&mbedtls_test_rnd_pseudo_rand,
|
||||
&rnd_info ) == 0 );
|
||||
|
|
|
@ -93,9 +93,9 @@ void ecdsa_prim_test_vectors( int id, char * d_str, char * xQ_str,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_string( &Q, 16, xQ_str, yQ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, 16, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &r_check, 16, r_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &s_check, 16, s_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &r_check, r_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &s_check, s_str ) == 0 );
|
||||
rnd_info.fallback_f_rng = mbedtls_test_rnd_std_rand;
|
||||
rnd_info.fallback_p_rng = NULL;
|
||||
rnd_info.buf = rnd_buf->x;
|
||||
|
@ -203,9 +203,9 @@ void ecdsa_det_test_vectors( int id, char * d_str, int md_alg, data_t * hash,
|
|||
mbedtls_mpi_init( &r_check ); mbedtls_mpi_init( &s_check );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, 16, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &r_check, 16, r_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &s_check, 16, s_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &r_check, r_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &s_check, s_str ) == 0 );
|
||||
|
||||
TEST_ASSERT(
|
||||
mbedtls_ecdsa_sign_det_ext( &grp, &r, &s, &d,
|
||||
|
@ -426,7 +426,7 @@ void ecdsa_write_restart( int id, char *d_str, int md_alg,
|
|||
memset( sig, 0, sizeof( sig ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &ctx.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.d, 16, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.d, d_str ) == 0 );
|
||||
|
||||
mbedtls_ecp_set_max_ops( max_ops );
|
||||
|
||||
|
|
|
@ -120,9 +120,9 @@ void ecp_check_pub( int grp_id, char * x_hex, char * y_hex, char * z_hex,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, grp_id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.X, 16, x_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Y, 16, y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Z, 16, z_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.X, x_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Y, y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Z, z_hex ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &P ) == ret );
|
||||
|
||||
|
@ -173,13 +173,13 @@ void ecp_test_vect_restart( int id,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, 16, dA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, 16, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yA, 16, yA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, dA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yA, yA_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, 16, dB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xZ, 16, xZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yZ, 16, yZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, dB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xZ, xZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yZ, yZ_str ) == 0 );
|
||||
|
||||
mbedtls_ecp_set_max_ops( (unsigned) max_ops );
|
||||
|
||||
|
@ -260,13 +260,13 @@ void ecp_muladd_restart( int id, char *xR_str, char *yR_str,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &u1, 16, u1_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &u2, 16, u2_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xR, 16, xR_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yR, 16, yR_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &u1, u1_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &u2, u2_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xR, xR_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yR, yR_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q.X, 16, xQ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q.Y, 16, yQ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q.X, xQ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q.Y, yQ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_lset( &Q.Z, 1 ) == 0 );
|
||||
|
||||
mbedtls_ecp_set_max_ops( (unsigned) max_ops );
|
||||
|
@ -323,14 +323,14 @@ void ecp_test_vect( int id, char * dA_str, char * xA_str, char * yA_str,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &grp.G ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, 16, dA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, 16, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yA, 16, yA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, 16, dB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xB, 16, xB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yB, 16, yB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xZ, 16, xZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yZ, 16, yZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, dA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, xA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yA, yA_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, dB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xB, xB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yB, yB_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xZ, xZ_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &yZ, yZ_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dA, &grp.G,
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
|
@ -380,11 +380,11 @@ void ecp_test_vec_x( int id, char * dA_hex, char * xA_hex, char * dB_hex,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &grp.G ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, 16, dA_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, 16, dB_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, 16, xA_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xB, 16, xB_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xS, 16, xS_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dA, dA_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dB, dB_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xA, xA_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xB, xB_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &xS, xS_hex ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &R, &dA, &grp.G,
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
||||
|
@ -546,7 +546,7 @@ void ecp_fast_mod( int id, char * N_str )
|
|||
mbedtls_mpi_init( &N ); mbedtls_mpi_init( &R );
|
||||
mbedtls_ecp_group_init( &grp );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, 16, N_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, N_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( grp.modp != NULL );
|
||||
|
||||
|
@ -585,9 +585,9 @@ void ecp_write_binary( int id, char * x, char * y, char * z, int format,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.X, 16, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Y, 16, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Z, 16, z ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.X, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Y, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P.Z, z ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_point_write_binary( &grp, &P, format,
|
||||
&olen, buf, blen ) == ret );
|
||||
|
@ -617,9 +617,9 @@ void ecp_read_binary( int id, data_t * buf, char * x, char * y, char * z,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Z, 16, z ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Z, z ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_binary( &grp, &P, buf->x, buf->len ) == ret );
|
||||
|
||||
|
@ -661,9 +661,9 @@ void mbedtls_ecp_tls_read_point( int id, data_t * buf, char * x, char * y,
|
|||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Z, 16, z ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, x ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Z, z ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_tls_read_point( &grp, &P, &vbuf, buf->len ) == ret );
|
||||
|
||||
|
@ -798,7 +798,7 @@ void mbedtls_ecp_check_privkey( int id, char * key_hex, int ret )
|
|||
mbedtls_mpi_init( &d );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, 16, key_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &d, key_hex ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_privkey( &grp, &d ) == ret );
|
||||
|
||||
|
@ -827,7 +827,7 @@ void mbedtls_ecp_check_pub_priv( int id_pub, char * Qx_pub, char * Qy_pub,
|
|||
if( id != MBEDTLS_ECP_DP_NONE )
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &prv.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_string( &prv.Q, 16, Qx, Qy ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.d, 16, d ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.d, d ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_check_pub_priv( &pub, &prv,
|
||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||
|
@ -1044,7 +1044,7 @@ void ecp_export( int id, char * Qx, char * Qy,char * d, int expected_ret, int in
|
|||
if( invalid_grp == 0 )
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &key.grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_point_read_string( &key.Q, 16, Qx, Qy ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &key.d, 16, d ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &key.d, d ) == 0 );
|
||||
|
||||
TEST_EQUAL( mbedtls_ecp_export( &key, &export_grp,
|
||||
&export_d, &export_Q ), expected_ret );
|
||||
|
@ -1074,7 +1074,7 @@ void ecp_check_order( int id, char * expected_order_hex )
|
|||
mbedtls_mpi_init( &expected_n );
|
||||
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &expected_n, 16, expected_order_hex ) == 0);
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &expected_n, expected_order_hex ) == 0);
|
||||
|
||||
// check sign bits are well-formed (i.e. 1 or -1) - see #5810
|
||||
TEST_ASSERT( grp.N.s == -1 || grp.N.s == 1);
|
||||
|
|
|
@ -229,7 +229,7 @@ void mbedtls_mpi_write_binary( int radix_X, char * input_X,
|
|||
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
buflen = mbedtls_mpi_size( &X );
|
||||
if( buflen > (size_t) output_size )
|
||||
|
@ -261,7 +261,7 @@ void mbedtls_mpi_write_binary_le( int radix_X, char * input_X,
|
|||
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
buflen = mbedtls_mpi_size( &X );
|
||||
if( buflen > (size_t) output_size )
|
||||
|
@ -326,7 +326,7 @@ void mbedtls_mpi_write_file( int radix_X, char * input_X, int output_radix,
|
|||
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
file_out = fopen( output_file, "w" );
|
||||
TEST_ASSERT( file_out != NULL );
|
||||
|
@ -352,7 +352,7 @@ void mbedtls_mpi_get_bit( int radix_X, char * input_X, int pos, int val )
|
|||
{
|
||||
mbedtls_mpi X;
|
||||
mbedtls_mpi_init( &X );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_get_bit( &X, pos ) == val );
|
||||
|
||||
exit:
|
||||
|
@ -367,8 +367,8 @@ void mbedtls_mpi_set_bit( int radix_X, char * input_X, int pos, int val,
|
|||
mbedtls_mpi X, Y;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, output_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, output_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_set_bit( &X, pos, val ) == result );
|
||||
|
||||
if( result == 0 )
|
||||
|
@ -388,7 +388,7 @@ void mbedtls_mpi_lsb( int radix_X, char * input_X, int nr_bits )
|
|||
mbedtls_mpi X;
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_lsb( &X ) == (size_t) nr_bits );
|
||||
|
||||
exit:
|
||||
|
@ -402,7 +402,7 @@ void mbedtls_mpi_bitlen( int radix_X, char * input_X, int nr_bits )
|
|||
mbedtls_mpi X;
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_bitlen( &X ) == (size_t) nr_bits );
|
||||
|
||||
exit:
|
||||
|
@ -417,9 +417,9 @@ void mbedtls_mpi_gcd( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi A, X, Y, Z;
|
||||
mbedtls_mpi_init( &A ); mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_gcd( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -450,8 +450,8 @@ void mbedtls_mpi_cmp_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &Y ) == input_A );
|
||||
|
||||
exit:
|
||||
|
@ -469,8 +469,8 @@ void mbedtls_mpi_lt_mpi_ct( int size_X, char * input_X,
|
|||
mbedtls_mpi X, Y;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_grow( &X, size_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_grow( &Y, size_Y ) == 0 );
|
||||
|
@ -491,8 +491,8 @@ void mbedtls_mpi_cmp_abs( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_abs( &X, &Y ) == input_A );
|
||||
|
||||
exit:
|
||||
|
@ -508,25 +508,25 @@ void mbedtls_mpi_copy( char *src_hex, char *dst_hex )
|
|||
mbedtls_mpi_init( &dst );
|
||||
mbedtls_mpi_init( &ref );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &src, 16, src_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ref, 16, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &src, src_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ref, dst_hex ) == 0 );
|
||||
|
||||
/* mbedtls_mpi_copy() */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, 16, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_copy( &dst, &src ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &dst ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &dst, &src ) == 0 );
|
||||
|
||||
/* mbedtls_mpi_safe_cond_assign(), assignment done */
|
||||
mbedtls_mpi_free( &dst );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, 16, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_safe_cond_assign( &dst, &src, 1 ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &dst ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &dst, &src ) == 0 );
|
||||
|
||||
/* mbedtls_mpi_safe_cond_assign(), assignment not done */
|
||||
mbedtls_mpi_free( &dst );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, 16, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &dst, dst_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_safe_cond_assign( &dst, &src, 0 ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &dst ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &dst, &ref ) == 0 );
|
||||
|
@ -545,10 +545,10 @@ void mpi_copy_self( char *input_X )
|
|||
mbedtls_mpi_init( &A );
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_copy( &X, &X ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, 16, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_X ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
|
@ -565,12 +565,12 @@ void mbedtls_mpi_swap( char *X_hex, char *Y_hex )
|
|||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y );
|
||||
mbedtls_mpi_init( &X0 ); mbedtls_mpi_init( &Y0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X0, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y0, 16, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X0, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y0, Y_hex ) == 0 );
|
||||
|
||||
/* mbedtls_mpi_swap() */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, Y_hex ) == 0 );
|
||||
mbedtls_mpi_swap( &X, &Y );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( sign_is_valid( &Y ) );
|
||||
|
@ -580,8 +580,8 @@ void mbedtls_mpi_swap( char *X_hex, char *Y_hex )
|
|||
/* mbedtls_mpi_safe_cond_swap(), swap done */
|
||||
mbedtls_mpi_free( &X );
|
||||
mbedtls_mpi_free( &Y );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_safe_cond_swap( &X, &Y, 1 ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( sign_is_valid( &Y ) );
|
||||
|
@ -591,8 +591,8 @@ void mbedtls_mpi_swap( char *X_hex, char *Y_hex )
|
|||
/* mbedtls_mpi_safe_cond_swap(), swap not done */
|
||||
mbedtls_mpi_free( &X );
|
||||
mbedtls_mpi_free( &Y );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, 16, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, Y_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_safe_cond_swap( &X, &Y, 0 ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( sign_is_valid( &Y ) );
|
||||
|
@ -611,8 +611,8 @@ void mpi_swap_self( char *X_hex )
|
|||
mbedtls_mpi X, X0;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &X0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X0, 16, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, X_hex ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X0, X_hex ) == 0 );
|
||||
|
||||
mbedtls_mpi_swap( &X, &X );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
|
@ -651,9 +651,9 @@ void mbedtls_mpi_add_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -662,7 +662,7 @@ void mbedtls_mpi_add_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
TEST_ASSERT( mbedtls_mpi_add_mpi( &X, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
/* result == second operand */
|
||||
TEST_ASSERT( mbedtls_mpi_add_mpi( &Y, &X, &Y ) == 0 );
|
||||
|
@ -681,19 +681,19 @@ void mbedtls_mpi_add_mpi_inplace( int radix_X, char * input_X, int radix_A,
|
|||
mbedtls_mpi X, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_sub_abs( &X, &X, &X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_int( &X, 0 ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_abs( &X, &X, &X ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_mpi( &X, &X, &X ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
@ -711,9 +711,9 @@ void mbedtls_mpi_add_abs( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_abs( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -722,7 +722,7 @@ void mbedtls_mpi_add_abs( int radix_X, char * input_X, int radix_Y,
|
|||
TEST_ASSERT( mbedtls_mpi_add_abs( &X, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
/* result == second operand */
|
||||
TEST_ASSERT( mbedtls_mpi_add_abs( &Y, &X, &Y ) == 0 );
|
||||
|
@ -741,8 +741,8 @@ void mbedtls_mpi_add_int( int radix_X, char * input_X, int input_Y,
|
|||
mbedtls_mpi X, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_add_int( &Z, &X, input_Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -759,9 +759,9 @@ void mbedtls_mpi_sub_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_sub_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -770,7 +770,7 @@ void mbedtls_mpi_sub_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
TEST_ASSERT( mbedtls_mpi_sub_mpi( &X, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
/* result == second operand */
|
||||
TEST_ASSERT( mbedtls_mpi_sub_mpi( &Y, &X, &Y ) == 0 );
|
||||
|
@ -791,9 +791,9 @@ void mbedtls_mpi_sub_abs( int radix_X, char * input_X, int radix_Y,
|
|||
int res;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
|
||||
res = mbedtls_mpi_sub_abs( &Z, &X, &Y );
|
||||
TEST_ASSERT( res == sub_result );
|
||||
|
@ -806,7 +806,7 @@ void mbedtls_mpi_sub_abs( int radix_X, char * input_X, int radix_Y,
|
|||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
if( sub_result == 0 )
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
/* result == second operand */
|
||||
TEST_ASSERT( mbedtls_mpi_sub_abs( &Y, &X, &Y ) == sub_result );
|
||||
|
@ -826,8 +826,8 @@ void mbedtls_mpi_sub_int( int radix_X, char * input_X, int input_Y,
|
|||
mbedtls_mpi X, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_sub_int( &Z, &X, input_Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -844,9 +844,9 @@ void mbedtls_mpi_mul_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi X, Y, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_mul_mpi( &Z, &X, &Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &Z, &A ) == 0 );
|
||||
|
@ -864,8 +864,8 @@ void mbedtls_mpi_mul_int( int radix_X, char * input_X, int input_Y,
|
|||
mbedtls_mpi X, Z, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_mul_int( &Z, &X, input_Y ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &Z ) );
|
||||
if( strcmp( result_comparison, "==" ) == 0 )
|
||||
|
@ -890,10 +890,10 @@ void mbedtls_mpi_div_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &R );
|
||||
mbedtls_mpi_init( &A ); mbedtls_mpi_init( &B );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &B, radix_B, input_B ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &B, input_B ) == 0 );
|
||||
res = mbedtls_mpi_div_mpi( &Q, &R, &X, &Y );
|
||||
TEST_ASSERT( res == div_result );
|
||||
if( res == 0 )
|
||||
|
@ -920,9 +920,9 @@ void mbedtls_mpi_div_int( int radix_X, char * input_X, int input_Y,
|
|||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Q ); mbedtls_mpi_init( &R ); mbedtls_mpi_init( &A );
|
||||
mbedtls_mpi_init( &B );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &B, radix_B, input_B ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &B, input_B ) == 0 );
|
||||
res = mbedtls_mpi_div_int( &Q, &R, &X, input_Y );
|
||||
TEST_ASSERT( res == div_result );
|
||||
if( res == 0 )
|
||||
|
@ -948,9 +948,9 @@ void mbedtls_mpi_mod_mpi( int radix_X, char * input_X, int radix_Y,
|
|||
int res;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
res = mbedtls_mpi_mod_mpi( &X, &X, &Y );
|
||||
TEST_ASSERT( res == div_result );
|
||||
if( res == 0 )
|
||||
|
@ -973,7 +973,7 @@ void mbedtls_mpi_mod_int( int radix_X, char * input_X, int input_Y,
|
|||
mbedtls_mpi_uint r;
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
res = mbedtls_mpi_mod_int( &r, &X, input_Y );
|
||||
TEST_ASSERT( res == div_result );
|
||||
if( res == 0 )
|
||||
|
@ -996,10 +996,10 @@ void mbedtls_mpi_exp_mod( int radix_A, char * input_A, int radix_E,
|
|||
mbedtls_mpi_init( &A ); mbedtls_mpi_init( &E ); mbedtls_mpi_init( &N );
|
||||
mbedtls_mpi_init( &RR ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
|
||||
res = mbedtls_mpi_exp_mod( &Z, &A, &E, &N, NULL );
|
||||
TEST_ASSERT( res == exp_result );
|
||||
|
@ -1057,7 +1057,7 @@ void mbedtls_mpi_exp_mod_size( int A_bytes, int E_bytes, int N_bytes,
|
|||
TEST_ASSERT( mbedtls_mpi_set_bit( &N, 0, 1 ) == 0 );
|
||||
|
||||
if( strlen( input_RR ) )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &RR, radix_RR, input_RR ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &RR, input_RR ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_mpi_exp_mod( &Z, &A, &E, &N, &RR ) == exp_result );
|
||||
|
||||
|
@ -1076,9 +1076,9 @@ void mbedtls_mpi_inv_mod( int radix_X, char * input_X, int radix_Y,
|
|||
int res;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &Y ); mbedtls_mpi_init( &Z ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, radix_Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Y, input_Y ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
res = mbedtls_mpi_inv_mod( &Z, &X, &Y );
|
||||
TEST_ASSERT( res == div_result );
|
||||
if( res == 0 )
|
||||
|
@ -1099,7 +1099,7 @@ void mbedtls_mpi_is_prime( int radix_X, char * input_X, int div_result )
|
|||
int res;
|
||||
mbedtls_mpi_init( &X );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
res = mbedtls_mpi_is_prime_ext( &X, 40, mbedtls_test_rnd_std_rand, NULL );
|
||||
TEST_ASSERT( res == div_result );
|
||||
|
||||
|
@ -1186,8 +1186,8 @@ void mbedtls_mpi_shift_l( int radix_X, char * input_X, int shift_X,
|
|||
mbedtls_mpi X, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_l( &X, shift_X ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
@ -1204,8 +1204,8 @@ void mbedtls_mpi_shift_r( int radix_X, char * input_X, int shift_X,
|
|||
mbedtls_mpi X, A;
|
||||
mbedtls_mpi_init( &X ); mbedtls_mpi_init( &A );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, radix_X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, radix_A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &X, input_X ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &A, input_A ) == 0 );
|
||||
TEST_ASSERT( mbedtls_mpi_shift_r( &X, shift_X ) == 0 );
|
||||
TEST_ASSERT( sign_is_valid( &X ) );
|
||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &X, &A ) == 0 );
|
||||
|
|
|
@ -503,8 +503,8 @@ void pk_rsa_verify_test_vec( data_t * message_str, int digest, int mod,
|
|||
rsa = mbedtls_pk_rsa( pk );
|
||||
|
||||
rsa->len = mod / 8;
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_verify( &pk, digest, message_str->x, 0,
|
||||
result_str->x, mbedtls_pk_get_len( &pk ) ) == result );
|
||||
|
@ -542,8 +542,8 @@ void pk_rsa_verify_ext_test_vec( data_t * message_str, int digest,
|
|||
rsa = mbedtls_pk_rsa( pk );
|
||||
|
||||
rsa->len = mod / 8;
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, input_E ) == 0 );
|
||||
|
||||
|
||||
if( mgf1_hash_id < 0 )
|
||||
|
@ -638,7 +638,7 @@ void pk_sign_verify_restart( int pk_type, int grp_id, char *d_str,
|
|||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &prv, mbedtls_pk_info_from_type( pk_type ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( prv )->grp, grp_id ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &mbedtls_pk_ec( prv )->d, 16, d_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &mbedtls_pk_ec( prv )->d, d_str ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_setup( &pub, mbedtls_pk_info_from_type( pk_type ) ) == 0 );
|
||||
TEST_ASSERT( mbedtls_ecp_group_load( &mbedtls_pk_ec( pub )->grp, grp_id ) == 0 );
|
||||
|
@ -824,8 +824,8 @@ void pk_rsa_encrypt_decrypt_test( data_t * message, int mod, int radix_P,
|
|||
|
||||
/* load public key */
|
||||
rsa->len = mod / 8;
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &rsa->E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk, message->x, message->len,
|
||||
output, &olen, sizeof( output ),
|
||||
|
@ -842,12 +842,12 @@ void pk_rsa_encrypt_decrypt_test( data_t * message, int mod, int radix_P,
|
|||
rsa = mbedtls_pk_rsa( pk );
|
||||
|
||||
/* load public key */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
/* load private key */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( rsa, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( rsa ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( rsa ) == 0 );
|
||||
|
@ -898,12 +898,12 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
|||
rsa = mbedtls_pk_rsa( pk );
|
||||
|
||||
/* load public key */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
/* load private key */
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( rsa, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( rsa ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_complete( rsa ) == 0 );
|
||||
|
@ -956,12 +956,12 @@ void pk_wrap_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
|||
rsa = mbedtls_pk_rsa( pk );
|
||||
|
||||
/* load public key */
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &N, radix_N, input_N ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &E, radix_E, input_E ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &N, input_N ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &E, input_E ), 0 );
|
||||
|
||||
/* load private key */
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &P, radix_P, input_P ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &P, input_P ), 0 );
|
||||
TEST_EQUAL( mbedtls_test_read_mpi( &Q, input_Q ), 0 );
|
||||
TEST_EQUAL( mbedtls_rsa_import( rsa, &N, &P, &Q, NULL, &E ), 0 );
|
||||
TEST_EQUAL( mbedtls_rsa_get_len( rsa ), (size_t) ( mod / 8 ) );
|
||||
TEST_EQUAL( mbedtls_rsa_complete( rsa ), 0 );
|
||||
|
|
|
@ -32,8 +32,8 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
|
|||
MBEDTLS_RSA_PKCS_V15, hash ) == 0 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
||||
|
@ -82,10 +82,10 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
|
|||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
|
@ -288,10 +288,10 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
|||
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
|
@ -331,8 +331,8 @@ void pkcs1_rsassa_v15_verify( int mod, int radix_N, char * input_N,
|
|||
TEST_ASSERT( mbedtls_rsa_set_padding( &ctx,
|
||||
MBEDTLS_RSA_PKCS_V15, hash ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( ( mod + 7 ) / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
||||
|
|
|
@ -92,10 +92,10 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
|
|||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -134,8 +134,8 @@ void mbedtls_rsa_pkcs1_verify( data_t * message_str, int padding_mode,
|
|||
TEST_ASSERT( mbedtls_rsa_set_padding( &ctx, padding_mode,
|
||||
MBEDTLS_MD_NONE ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
||||
|
@ -171,10 +171,10 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
|||
memset( output, 0x00, sizeof( output ) );
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -216,8 +216,8 @@ void rsa_pkcs1_verify_raw( data_t * hash_result,
|
|||
MBEDTLS_MD_NONE ) == 0 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -252,8 +252,8 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
|
|||
MBEDTLS_MD_NONE ) == 0 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -295,8 +295,8 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode,
|
|||
MBEDTLS_MD_NONE ) == 0 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -345,10 +345,10 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode,
|
|||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_rsa_get_len( &ctx ) == (size_t) ( mod / 8 ) );
|
||||
|
@ -391,8 +391,8 @@ void mbedtls_rsa_public( data_t * message_str, int mod, int radix_N,
|
|||
mbedtls_rsa_init( &ctx2 );
|
||||
memset( output, 0x00, sizeof( output ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
|
||||
|
@ -452,10 +452,10 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
|||
|
||||
memset( &rnd_info, 0, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, &P, &Q, NULL, &E ) == 0 );
|
||||
|
||||
|
@ -530,11 +530,11 @@ void mbedtls_rsa_check_pubkey( int radix_N, char * input_N, int radix_E,
|
|||
|
||||
if( strlen( input_N ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
}
|
||||
if( strlen( input_E ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
}
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx, &N, NULL, NULL, NULL, &E ) == 0 );
|
||||
|
@ -562,36 +562,36 @@ void mbedtls_rsa_check_privkey( int mod, int radix_P, char * input_P,
|
|||
ctx.len = mod / 8;
|
||||
if( strlen( input_P ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.P, input_P ) == 0 );
|
||||
}
|
||||
if( strlen( input_Q ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.Q, input_Q ) == 0 );
|
||||
}
|
||||
if( strlen( input_N ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.N, input_N ) == 0 );
|
||||
}
|
||||
if( strlen( input_E ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.E, input_E ) == 0 );
|
||||
}
|
||||
if( strlen( input_D ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.D, input_D ) == 0 );
|
||||
}
|
||||
#if !defined(MBEDTLS_RSA_NO_CRT)
|
||||
if( strlen( input_DP ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.DP, radix_DP, input_DP ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.DP, input_DP ) == 0 );
|
||||
}
|
||||
if( strlen( input_DQ ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.DQ, radix_DQ, input_DQ ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.DQ, input_DQ ) == 0 );
|
||||
}
|
||||
if( strlen( input_QP ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.QP, radix_QP, input_QP ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &ctx.QP, input_QP ) == 0 );
|
||||
}
|
||||
#else
|
||||
((void) radix_DP); ((void) input_DP);
|
||||
|
@ -626,45 +626,45 @@ void rsa_check_pubpriv( int mod, int radix_Npub, char * input_Npub,
|
|||
|
||||
if( strlen( input_Npub ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &pub.N, radix_Npub, input_Npub ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &pub.N, input_Npub ) == 0 );
|
||||
}
|
||||
if( strlen( input_Epub ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &pub.E, radix_Epub, input_Epub ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &pub.E, input_Epub ) == 0 );
|
||||
}
|
||||
|
||||
if( strlen( input_P ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.P, input_P ) == 0 );
|
||||
}
|
||||
if( strlen( input_Q ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.Q, input_Q ) == 0 );
|
||||
}
|
||||
if( strlen( input_N ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.N, input_N ) == 0 );
|
||||
}
|
||||
if( strlen( input_E ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.E, input_E ) == 0 );
|
||||
}
|
||||
if( strlen( input_D ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.D, input_D ) == 0 );
|
||||
}
|
||||
#if !defined(MBEDTLS_RSA_NO_CRT)
|
||||
if( strlen( input_DP ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.DP, radix_DP, input_DP ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.DP, input_DP ) == 0 );
|
||||
}
|
||||
if( strlen( input_DQ ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.DQ, radix_DQ, input_DQ ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.DQ, input_DQ ) == 0 );
|
||||
}
|
||||
if( strlen( input_QP ) )
|
||||
{
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.QP, radix_QP, input_QP ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &prv.QP, input_QP ) == 0 );
|
||||
}
|
||||
#else
|
||||
((void) radix_DP); ((void) input_DP);
|
||||
|
@ -715,11 +715,11 @@ void mbedtls_rsa_deduce_primes( int radix_N, char *input_N,
|
|||
mbedtls_mpi_init( &Pp ); mbedtls_mpi_init( &Qp );
|
||||
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Qp, radix_P, output_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Pp, radix_Q, output_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Qp, output_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Pp, output_Q ) == 0 );
|
||||
|
||||
if( corrupt )
|
||||
TEST_ASSERT( mbedtls_mpi_add_int( &D, &D, 2 ) == 0 );
|
||||
|
@ -756,10 +756,10 @@ void mbedtls_rsa_deduce_private_exponent( int radix_P, char *input_P,
|
|||
mbedtls_mpi_init( &E );
|
||||
mbedtls_mpi_init( &R ); mbedtls_mpi_init( &Rp );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Dp, radix_D, output_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Dp, output_D ) == 0 );
|
||||
|
||||
if( corrupt )
|
||||
{
|
||||
|
@ -833,19 +833,19 @@ void mbedtls_rsa_import( int radix_N, char *input_N,
|
|||
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
|
||||
|
||||
if( have_N )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
|
||||
if( have_P )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
|
||||
if( have_Q )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
|
||||
if( have_D )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, input_D ) == 0 );
|
||||
|
||||
if( have_E )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
if( !successive )
|
||||
{
|
||||
|
@ -978,19 +978,19 @@ void mbedtls_rsa_export( int radix_N, char *input_N,
|
|||
/* Setup RSA context */
|
||||
|
||||
if( have_N )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
|
||||
if( have_P )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
|
||||
if( have_Q )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
|
||||
if( have_D )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, input_D ) == 0 );
|
||||
|
||||
if( have_E )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
TEST_ASSERT( mbedtls_rsa_import( &ctx,
|
||||
strlen( input_N ) ? &N : NULL,
|
||||
|
@ -1088,19 +1088,19 @@ void mbedtls_rsa_validate_params( int radix_N, char *input_N,
|
|||
mbedtls_mpi_init( &D ); mbedtls_mpi_init( &E );
|
||||
|
||||
if( have_N )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, radix_N, input_N ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &N, input_N ) == 0 );
|
||||
|
||||
if( have_P )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, radix_P, input_P ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &P, input_P ) == 0 );
|
||||
|
||||
if( have_Q )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, radix_Q, input_Q ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &Q, input_Q ) == 0 );
|
||||
|
||||
if( have_D )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, radix_D, input_D ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &D, input_D ) == 0 );
|
||||
|
||||
if( have_E )
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, radix_E, input_E ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &E, input_E ) == 0 );
|
||||
|
||||
/* This test uses an insecure RNG, suitable only for testing.
|
||||
* In production, always use a cryptographically strong RNG! */
|
||||
|
|
|
@ -315,7 +315,7 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
|||
if( pk_wrap == 2 )
|
||||
TEST_ASSERT( mbedtls_pk_get_type( &issuer_key ) == MBEDTLS_PK_OPAQUE );
|
||||
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &serial, 10, serial_str ) == 0 );
|
||||
TEST_ASSERT( mbedtls_test_read_mpi( &serial, serial_str ) == 0 );
|
||||
|
||||
if( ver != -1 )
|
||||
mbedtls_x509write_crt_set_version( &crt, ver );
|
||||
|
|
Loading…
Reference in a new issue