mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 16:14:20 +01:00
tests: Reformating due to rnd_* renaming
Command to find the files in which lines have gone larger than 79 characters due to the renaming: grep '.\{80\}' \ `git diff-tree --no-commit-id --name-only -r HEAD` \ | grep "\<mbedtls_test_rnd_" Signed-off-by: Ronald Cron <ronald.cron@arm.com>
This commit is contained in:
parent
351f0eee20
commit
6c5bd7fd51
@ -316,7 +316,8 @@ void ctr_drbg_seed_file( char * path, int ret )
|
|||||||
|
|
||||||
mbedtls_ctr_drbg_init( &ctx );
|
mbedtls_ctr_drbg_init( &ctx );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, mbedtls_test_rnd_std_rand, NULL, NULL, 0 ) == 0 );
|
TEST_ASSERT( mbedtls_ctr_drbg_seed( &ctx, mbedtls_test_rnd_std_rand,
|
||||||
|
NULL, NULL, 0 ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ctr_drbg_write_seed_file( &ctx, path ) == ret );
|
TEST_ASSERT( mbedtls_ctr_drbg_write_seed_file( &ctx, path ) == ret );
|
||||||
TEST_ASSERT( mbedtls_ctr_drbg_update_seed_file( &ctx, path ) == ret );
|
TEST_ASSERT( mbedtls_ctr_drbg_update_seed_file( &ctx, path ) == ret );
|
||||||
|
|
||||||
|
@ -83,16 +83,16 @@ void dhm_invalid_params( )
|
|||||||
NULL ) );
|
NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_calc_secret( NULL, buf, buflen,
|
mbedtls_dhm_calc_secret( NULL, buf, buflen, &len,
|
||||||
&len, mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_calc_secret( &ctx, NULL, buflen,
|
mbedtls_dhm_calc_secret( &ctx, NULL, buflen, &len,
|
||||||
&len, mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_calc_secret( &ctx, buf, buflen,
|
mbedtls_dhm_calc_secret( &ctx, buf, buflen, NULL,
|
||||||
NULL, mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
@ -151,7 +151,9 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
|||||||
/*
|
/*
|
||||||
* First key exchange
|
* First key exchange
|
||||||
*/
|
*/
|
||||||
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == result );
|
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == result );
|
||||||
if ( result != 0 )
|
if ( result != 0 )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
@ -159,10 +161,15 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
|||||||
ske[ske_len++] = 0;
|
ske[ske_len++] = 0;
|
||||||
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ),
|
||||||
|
&sec_srv_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||||
@ -173,7 +180,10 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
|||||||
for( i = 0; i < 3; i++ )
|
for( i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
sec_srv_len = 1000;
|
sec_srv_len = 1000;
|
||||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv,
|
||||||
|
sizeof( sec_srv ), &sec_srv_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||||
TEST_ASSERT( sec_srv_len != 0 );
|
TEST_ASSERT( sec_srv_len != 0 );
|
||||||
@ -185,15 +195,22 @@ void dhm_do_dhm( int radix_P, char *input_P,
|
|||||||
*/
|
*/
|
||||||
p = ske;
|
p = ske;
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_make_params( &ctx_srv, x_size, ske, &ske_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
ske[ske_len++] = 0;
|
ske[ske_len++] = 0;
|
||||||
ske[ske_len++] = 0;
|
ske[ske_len++] = 0;
|
||||||
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_read_params( &ctx_cli, &p, ske + ske_len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_make_public( &ctx_cli, x_size, pub_cli, pub_cli_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_read_public( &ctx_srv, pub_cli, pub_cli_len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ), &sec_srv_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_srv, sec_srv, sizeof( sec_srv ),
|
||||||
|
&sec_srv_len,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
TEST_ASSERT( mbedtls_dhm_calc_secret( &ctx_cli, sec_cli, sizeof( sec_cli ), &sec_cli_len, NULL, NULL ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
TEST_ASSERT( sec_srv_len == sec_cli_len );
|
||||||
|
@ -29,7 +29,8 @@ static int load_private_key( int grp_id, data_t *private_key,
|
|||||||
/* Calculate the public key from the private key. */
|
/* Calculate the public key from the private key. */
|
||||||
TEST_ASSERT( mbedtls_ecp_mul( &ecp->grp, &ecp->Q, &ecp->d,
|
TEST_ASSERT( mbedtls_ecp_mul( &ecp->grp, &ecp->Q, &ecp->d,
|
||||||
&ecp->grp.G,
|
&ecp->grp.G,
|
||||||
&mbedtls_test_rnd_pseudo_rand, rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
rnd_info ) == 0 );
|
||||||
ok = 1;
|
ok = 1;
|
||||||
exit:
|
exit:
|
||||||
return( ok );
|
return( ok );
|
||||||
@ -72,49 +73,54 @@ void ecdh_invalid_param( )
|
|||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_gen_public( NULL, &m, &P,
|
mbedtls_ecdh_gen_public( NULL, &m, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_gen_public( &grp, NULL, &P,
|
mbedtls_ecdh_gen_public( &grp, NULL, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_gen_public( &grp, &m, NULL,
|
mbedtls_ecdh_gen_public( &grp, &m, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_gen_public( &grp, &m, &P,
|
mbedtls_ecdh_gen_public( &grp, &m, &P,
|
||||||
NULL, NULL ) );
|
NULL, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_compute_shared( NULL, &m, &P, &m,
|
mbedtls_ecdh_compute_shared( NULL, &m, &P, &m,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_compute_shared( &grp, NULL, &P, &m,
|
mbedtls_ecdh_compute_shared( &grp, NULL, &P, &m,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_compute_shared( &grp, &m, NULL, &m,
|
mbedtls_ecdh_compute_shared( &grp, &m, NULL, &m,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_compute_shared( &grp, &m, &P, NULL,
|
mbedtls_ecdh_compute_shared( &grp, &m, &P, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_setup( NULL, valid_grp ) );
|
mbedtls_ecdh_setup( NULL, valid_grp ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_params( NULL, &olen,
|
mbedtls_ecdh_make_params( NULL, &olen, buf, buflen,
|
||||||
buf, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_params( &ctx, NULL,
|
mbedtls_ecdh_make_params( &ctx, NULL, buf, buflen,
|
||||||
buf, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_params( &ctx, &olen,
|
mbedtls_ecdh_make_params( &ctx, &olen, NULL, buflen,
|
||||||
NULL, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_params( &ctx, &olen,
|
mbedtls_ecdh_make_params( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||||
buf, buflen,
|
|
||||||
NULL, NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_read_params( NULL,
|
mbedtls_ecdh_read_params( NULL,
|
||||||
@ -141,25 +147,19 @@ void ecdh_invalid_param( )
|
|||||||
invalid_side ) );
|
invalid_side ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_public( NULL, &olen,
|
mbedtls_ecdh_make_public( NULL, &olen, buf, buflen,
|
||||||
buf, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_public( &ctx, NULL,
|
mbedtls_ecdh_make_public( &ctx, NULL, buf, buflen,
|
||||||
buf, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_public( &ctx, &olen,
|
mbedtls_ecdh_make_public( &ctx, &olen, NULL, buflen,
|
||||||
NULL, buflen,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_make_public( &ctx, &olen,
|
mbedtls_ecdh_make_public( &ctx, &olen, buf, buflen, NULL, NULL ) );
|
||||||
buf, buflen,
|
|
||||||
NULL,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_read_public( NULL, buf, buflen ) );
|
mbedtls_ecdh_read_public( NULL, buf, buflen ) );
|
||||||
@ -167,17 +167,16 @@ void ecdh_invalid_param( )
|
|||||||
mbedtls_ecdh_read_public( &ctx, NULL, buflen ) );
|
mbedtls_ecdh_read_public( &ctx, NULL, buflen ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen,
|
mbedtls_ecdh_calc_secret( NULL, &olen, buf, buflen,
|
||||||
mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen,
|
mbedtls_ecdh_calc_secret( &ctx, NULL, buf, buflen,
|
||||||
mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen,
|
mbedtls_ecdh_calc_secret( &ctx, &olen, NULL, buflen,
|
||||||
mbedtls_test_rnd_std_rand,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return;
|
return;
|
||||||
@ -200,12 +199,15 @@ void ecdh_primitive_random( int id )
|
|||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA, &mbedtls_test_rnd_pseudo_rand, &rnd_info )
|
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA,
|
||||||
== 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB, &mbedtls_test_rnd_pseudo_rand, &rnd_info )
|
&rnd_info ) == 0 );
|
||||||
== 0 );
|
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zA, &qB, &dA,
|
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zA, &qB, &dA,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zB, &qA, &dB,
|
TEST_ASSERT( mbedtls_ecdh_compute_shared( &grp, &zB, &qA, &dB,
|
||||||
NULL, NULL ) == 0 );
|
NULL, NULL ) == 0 );
|
||||||
|
|
||||||
@ -269,7 +271,8 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA,
|
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dA, &qA,
|
||||||
mbedtls_test_rnd_buffer_rand, &rnd_info_A ) == 0 );
|
mbedtls_test_rnd_buffer_rand,
|
||||||
|
&rnd_info_A ) == 0 );
|
||||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qA ) );
|
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qA ) );
|
||||||
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xA_str ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xA_str ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.X, &check ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.X, &check ) == 0 );
|
||||||
@ -277,7 +280,8 @@ void ecdh_primitive_testvec( int id, data_t * rnd_buf_A, char * xA_str,
|
|||||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.Y, &check ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qA.Y, &check ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
TEST_ASSERT( mbedtls_ecdh_gen_public( &grp, &dB, &qB,
|
||||||
mbedtls_test_rnd_buffer_rand, &rnd_info_B ) == 0 );
|
mbedtls_test_rnd_buffer_rand,
|
||||||
|
&rnd_info_B ) == 0 );
|
||||||
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qB ) );
|
TEST_ASSERT( ! mbedtls_ecp_is_zero( &qB ) );
|
||||||
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xB_str ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_read_string( &check, 16, xB_str ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qB.X, &check ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &qB.X, &check ) == 0 );
|
||||||
@ -317,16 +321,19 @@ void ecdh_exchange( int id )
|
|||||||
|
|
||||||
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
||||||
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
||||||
|
|
||||||
memset( buf, 0x00, sizeof( buf ) );
|
memset( buf, 0x00, sizeof( buf ) );
|
||||||
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &res_len, res_buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &res_len, res_buf, 1000,
|
||||||
NULL, NULL ) == 0 );
|
NULL, NULL ) == 0 );
|
||||||
TEST_ASSERT( len == res_len );
|
TEST_ASSERT( len == res_len );
|
||||||
@ -393,7 +400,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
|||||||
cnt_restart = 0;
|
cnt_restart = 0;
|
||||||
do {
|
do {
|
||||||
ret = mbedtls_ecdh_make_params( &srv, &len, buf, sizeof( buf ),
|
ret = mbedtls_ecdh_make_params( &srv, &len, buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_buffer_rand, &rnd_info_A );
|
mbedtls_test_rnd_buffer_rand,
|
||||||
|
&rnd_info_A );
|
||||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||||
|
|
||||||
TEST_ASSERT( ret == 0 );
|
TEST_ASSERT( ret == 0 );
|
||||||
@ -411,7 +419,8 @@ void ecdh_restart( int id, char *dA_str, char *dB_str, char *z_str,
|
|||||||
cnt_restart = 0;
|
cnt_restart = 0;
|
||||||
do {
|
do {
|
||||||
ret = mbedtls_ecdh_make_public( &cli, &len, buf, sizeof( buf ),
|
ret = mbedtls_ecdh_make_public( &cli, &len, buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_buffer_rand, &rnd_info_B );
|
mbedtls_test_rnd_buffer_rand,
|
||||||
|
&rnd_info_B );
|
||||||
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
} while( ret == MBEDTLS_ERR_ECP_IN_PROGRESS && ++cnt_restart );
|
||||||
|
|
||||||
TEST_ASSERT( ret == 0 );
|
TEST_ASSERT( ret == 0 );
|
||||||
@ -480,16 +489,19 @@ void ecdh_exchange_legacy( int id )
|
|||||||
|
|
||||||
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
memset( buf, 0x00, sizeof( buf ) ); vbuf = buf;
|
||||||
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_make_params( &srv, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
TEST_ASSERT( mbedtls_ecdh_read_params( &cli, &vbuf, buf + len ) == 0 );
|
||||||
|
|
||||||
memset( buf, 0x00, sizeof( buf ) );
|
memset( buf, 0x00, sizeof( buf ) );
|
||||||
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_make_public( &cli, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
TEST_ASSERT( mbedtls_ecdh_read_public( &srv, buf, len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
TEST_ASSERT( mbedtls_ecdh_calc_secret( &srv, &len, buf, 1000,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &len, buf, 1000, NULL,
|
TEST_ASSERT( mbedtls_ecdh_calc_secret( &cli, &len, buf, 1000, NULL,
|
||||||
NULL ) == 0 );
|
NULL ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &srv.z, &cli.z ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &srv.z, &cli.z ) == 0 );
|
||||||
|
@ -31,23 +31,28 @@ void ecdsa_invalid_param( )
|
|||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( NULL, &m, &m, &m,
|
mbedtls_ecdsa_sign( NULL, &m, &m, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( &grp, NULL, &m, &m,
|
mbedtls_ecdsa_sign( &grp, NULL, &m, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( &grp, &m, NULL, &m,
|
mbedtls_ecdsa_sign( &grp, &m, NULL, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( &grp, &m, &m, NULL,
|
mbedtls_ecdsa_sign( &grp, &m, &m, NULL,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||||
NULL, sizeof( buf ),
|
NULL, sizeof( buf ),
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
mbedtls_ecdsa_sign( &grp, &m, &m, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
@ -58,27 +63,32 @@ void ecdsa_invalid_param( )
|
|||||||
mbedtls_ecdsa_sign_det_ext( NULL, &m, &m, &m,
|
mbedtls_ecdsa_sign_det_ext( NULL, &m, &m, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
valid_md,
|
valid_md,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign_det_ext( &grp, NULL, &m, &m,
|
mbedtls_ecdsa_sign_det_ext( &grp, NULL, &m, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
valid_md,
|
valid_md,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, NULL, &m,
|
mbedtls_ecdsa_sign_det_ext( &grp, &m, NULL, &m,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
valid_md,
|
valid_md,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, NULL,
|
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, NULL,
|
||||||
buf, sizeof( buf ),
|
buf, sizeof( buf ),
|
||||||
valid_md,
|
valid_md,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, &m,
|
mbedtls_ecdsa_sign_det_ext( &grp, &m, &m, &m,
|
||||||
NULL, sizeof( buf ),
|
NULL, sizeof( buf ),
|
||||||
valid_md,
|
valid_md,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
#endif /* MBEDTLS_ECDSA_DETERMINISTIC */
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
@ -103,62 +113,48 @@ void ecdsa_invalid_param( )
|
|||||||
&P, &m, NULL ) );
|
&P, &m, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_write_signature( NULL,
|
mbedtls_ecdsa_write_signature( NULL, valid_md, buf, sizeof( buf ),
|
||||||
valid_md,
|
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||||
buf, sizeof( buf ),
|
NULL ) );
|
||||||
buf, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecdsa_write_signature( &ctx,
|
|
||||||
valid_md,
|
|
||||||
NULL, sizeof( buf ),
|
|
||||||
buf, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecdsa_write_signature( &ctx,
|
|
||||||
valid_md,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
NULL, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecdsa_write_signature( &ctx,
|
|
||||||
valid_md,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
buf, NULL,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_write_signature_restartable( NULL,
|
mbedtls_ecdsa_write_signature( &ctx, valid_md, NULL, sizeof( buf ),
|
||||||
valid_md,
|
buf, &slen, mbedtls_test_rnd_std_rand,
|
||||||
buf, sizeof( buf ),
|
NULL ) );
|
||||||
buf, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||||
valid_md,
|
NULL, &slen, mbedtls_test_rnd_std_rand,
|
||||||
NULL, sizeof( buf ),
|
NULL ) );
|
||||||
buf, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
mbedtls_ecdsa_write_signature( &ctx, valid_md, buf, sizeof( buf ),
|
||||||
valid_md,
|
buf, NULL, mbedtls_test_rnd_std_rand,
|
||||||
buf, sizeof( buf ),
|
NULL ) );
|
||||||
NULL, &slen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_write_signature_restartable( &ctx,
|
mbedtls_ecdsa_write_signature_restartable( NULL, valid_md, buf,
|
||||||
valid_md,
|
sizeof( buf ), buf, &slen,
|
||||||
buf, sizeof( buf ),
|
mbedtls_test_rnd_std_rand,
|
||||||
buf, NULL,
|
NULL, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL, NULL ) );
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
|
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, NULL,
|
||||||
|
sizeof( buf ), buf, &slen,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
|
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||||
|
sizeof( buf ), NULL, &slen,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
|
mbedtls_ecdsa_write_signature_restartable( &ctx, valid_md, buf,
|
||||||
|
sizeof( buf ), buf, NULL,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_read_signature( NULL,
|
mbedtls_ecdsa_read_signature( NULL,
|
||||||
@ -191,7 +187,8 @@ void ecdsa_invalid_param( )
|
|||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_genkey( NULL, valid_group,
|
mbedtls_ecdsa_genkey( NULL, valid_group,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecdsa_genkey( &ctx, valid_group,
|
mbedtls_ecdsa_genkey( &ctx, valid_group,
|
||||||
NULL, NULL ) );
|
NULL, NULL ) );
|
||||||
@ -223,13 +220,16 @@ void ecdsa_prim_random( int id )
|
|||||||
memset( buf, 0, sizeof( buf ) );
|
memset( buf, 0, sizeof( buf ) );
|
||||||
|
|
||||||
/* prepare material for signature */
|
/* prepare material for signature */
|
||||||
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info, buf, sizeof( buf ) ) == 0 );
|
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info,
|
||||||
|
buf, sizeof( buf ) ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q, &mbedtls_test_rnd_pseudo_rand, &rnd_info )
|
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q,
|
||||||
== 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, buf, sizeof( buf ),
|
TEST_ASSERT( mbedtls_ecdsa_sign( &grp, &r, &s, &d, buf, sizeof( buf ),
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdsa_verify( &grp, buf, sizeof( buf ), &Q, &r, &s ) == 0 );
|
TEST_ASSERT( mbedtls_ecdsa_verify( &grp, buf, sizeof( buf ), &Q, &r, &s ) == 0 );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -332,7 +332,8 @@ void ecdsa_det_test_vectors( int id, char * d_str, int md_alg, char * msg,
|
|||||||
|
|
||||||
TEST_ASSERT(
|
TEST_ASSERT(
|
||||||
mbedtls_ecdsa_sign_det_ext( &grp, &r, &s, &d, hash, hlen,
|
mbedtls_ecdsa_sign_det_ext( &grp, &r, &s, &d, hash, hlen,
|
||||||
md_alg, mbedtls_test_rnd_std_rand, NULL )
|
md_alg, mbedtls_test_rnd_std_rand,
|
||||||
|
NULL )
|
||||||
== 0 );
|
== 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_cmp_mpi( &r, &r_check ) == 0 );
|
||||||
@ -360,15 +361,19 @@ void ecdsa_write_read_random( int id )
|
|||||||
memset( sig, 0x2a, sizeof( sig ) );
|
memset( sig, 0x2a, sizeof( sig ) );
|
||||||
|
|
||||||
/* prepare material for signature */
|
/* prepare material for signature */
|
||||||
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info, hash, sizeof( hash ) ) == 0 );
|
TEST_ASSERT( mbedtls_test_rnd_pseudo_rand( &rnd_info,
|
||||||
|
hash, sizeof( hash ) ) == 0 );
|
||||||
|
|
||||||
/* generate signing key */
|
/* generate signing key */
|
||||||
TEST_ASSERT( mbedtls_ecdsa_genkey( &ctx, id, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_ecdsa_genkey( &ctx, id,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
|
|
||||||
/* generate and write signature, then read and verify it */
|
/* generate and write signature, then read and verify it */
|
||||||
TEST_ASSERT( mbedtls_ecdsa_write_signature( &ctx, MBEDTLS_MD_SHA256,
|
TEST_ASSERT( mbedtls_ecdsa_write_signature( &ctx, MBEDTLS_MD_SHA256,
|
||||||
hash, sizeof( hash ),
|
hash, sizeof( hash ),
|
||||||
sig, &sig_len, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
sig, &sig_len, &mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
TEST_ASSERT( mbedtls_ecdsa_read_signature( &ctx, hash, sizeof( hash ),
|
||||||
sig, sig_len ) == 0 );
|
sig, sig_len ) == 0 );
|
||||||
|
|
||||||
|
@ -136,54 +136,33 @@ void ecjpake_invalid_param( )
|
|||||||
mbedtls_ecjpake_check( NULL ) );
|
mbedtls_ecjpake_check( NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_write_round_one( NULL,
|
mbedtls_ecjpake_write_round_one( NULL, buf, len, &olen,
|
||||||
buf, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecjpake_write_round_one( &ctx,
|
|
||||||
NULL, len,
|
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecjpake_write_round_one( &ctx,
|
|
||||||
buf, len,
|
|
||||||
NULL,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
|
||||||
mbedtls_ecjpake_write_round_one( &ctx,
|
|
||||||
buf, len,
|
|
||||||
&olen,
|
|
||||||
NULL,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_write_round_two( NULL,
|
mbedtls_ecjpake_write_round_one( &ctx, NULL, len, &olen,
|
||||||
buf, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_write_round_two( &ctx,
|
mbedtls_ecjpake_write_round_one( &ctx, buf, len, NULL,
|
||||||
NULL, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_write_round_two( &ctx,
|
mbedtls_ecjpake_write_round_one( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||||
buf, len,
|
|
||||||
NULL,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_write_round_two( &ctx,
|
mbedtls_ecjpake_write_round_two( NULL, buf, len, &olen,
|
||||||
buf, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
NULL,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
NULL ) );
|
mbedtls_ecjpake_write_round_two( &ctx, NULL, len, &olen,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
|
mbedtls_ecjpake_write_round_two( &ctx, buf, len, NULL,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
|
mbedtls_ecjpake_write_round_two( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_read_round_one( NULL,
|
mbedtls_ecjpake_read_round_one( NULL,
|
||||||
@ -200,29 +179,19 @@ void ecjpake_invalid_param( )
|
|||||||
NULL, len ) );
|
NULL, len ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_derive_secret( NULL,
|
mbedtls_ecjpake_derive_secret( NULL, buf, len, &olen,
|
||||||
buf, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_derive_secret( &ctx,
|
mbedtls_ecjpake_derive_secret( &ctx, NULL, len, &olen,
|
||||||
NULL, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
&olen,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_derive_secret( &ctx,
|
mbedtls_ecjpake_derive_secret( &ctx, buf, len, NULL,
|
||||||
buf, len,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
NULL,
|
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecjpake_derive_secret( &ctx,
|
mbedtls_ecjpake_derive_secret( &ctx, buf, len, &olen, NULL, NULL ) );
|
||||||
buf, len,
|
|
||||||
&olen,
|
|
||||||
NULL,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
return;
|
return;
|
||||||
|
@ -222,29 +222,37 @@ void ecp_invalid_param( )
|
|||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul( NULL, &P, &m, &P,
|
mbedtls_ecp_mul( NULL, &P, &m, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul( &grp, NULL, &m, &P,
|
mbedtls_ecp_mul( &grp, NULL, &m, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul( &grp, &P, NULL, &P,
|
mbedtls_ecp_mul( &grp, &P, NULL, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul( &grp, &P, &m, NULL,
|
mbedtls_ecp_mul( &grp, &P, &m, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul_restartable( NULL, &P, &m, &P,
|
mbedtls_ecp_mul_restartable( NULL, &P, &m, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL , NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL , NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul_restartable( &grp, NULL, &m, &P,
|
mbedtls_ecp_mul_restartable( &grp, NULL, &m, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL , NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL , NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul_restartable( &grp, &P, NULL, &P,
|
mbedtls_ecp_mul_restartable( &grp, &P, NULL, &P,
|
||||||
mbedtls_test_rnd_std_rand, NULL , NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL , NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_mul_restartable( &grp, &P, &m, NULL,
|
mbedtls_ecp_mul_restartable( &grp, &P, &m, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL , NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL , NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_muladd( NULL, &P, &m, &P,
|
mbedtls_ecp_muladd( NULL, &P, &m, &P,
|
||||||
@ -300,30 +308,23 @@ void ecp_invalid_param( )
|
|||||||
mbedtls_ecp_check_privkey( &grp, NULL ) );
|
mbedtls_ecp_check_privkey( &grp, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair_base( NULL, &P,
|
mbedtls_ecp_gen_keypair_base( NULL, &P, &m, &P,
|
||||||
&m, &P,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair_base( &grp, NULL,
|
mbedtls_ecp_gen_keypair_base( &grp, NULL, &m, &P,
|
||||||
&m, &P,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
mbedtls_ecp_gen_keypair_base( &grp, &P, NULL, &P,
|
||||||
NULL, &P,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, NULL,
|
||||||
&m, NULL,
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair_base( &grp, &P,
|
mbedtls_ecp_gen_keypair_base( &grp, &P, &m, &P, NULL, NULL ) );
|
||||||
&m, &P,
|
|
||||||
NULL,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_keypair( NULL,
|
mbedtls_ecp_gen_keypair( NULL,
|
||||||
@ -348,7 +349,8 @@ void ecp_invalid_param( )
|
|||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_key( valid_group, NULL,
|
mbedtls_ecp_gen_key( valid_group, NULL,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_ECP_BAD_INPUT_DATA,
|
||||||
mbedtls_ecp_gen_key( valid_group, &kp,
|
mbedtls_ecp_gen_key( valid_group, &kp,
|
||||||
NULL, NULL ) );
|
NULL, NULL ) );
|
||||||
@ -740,7 +742,8 @@ void ecp_test_mul_rng( int id, data_t * d_hex)
|
|||||||
|
|
||||||
TEST_ASSERT( mbedtls_mpi_read_binary( &d, d_hex->x, d_hex->len ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_read_binary( &d, d_hex->x, d_hex->len ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_mul( &grp, &Q, &d, &grp.G, &mbedtls_test_rnd_zero_rand, NULL )
|
TEST_ASSERT( mbedtls_ecp_mul( &grp, &Q, &d, &grp.G,
|
||||||
|
&mbedtls_test_rnd_zero_rand, NULL )
|
||||||
== MBEDTLS_ERR_ECP_RANDOM_FAILED );
|
== MBEDTLS_ERR_ECP_RANDOM_FAILED );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -1061,8 +1064,9 @@ void mbedtls_ecp_gen_keypair( int id )
|
|||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_group_load( &grp, id ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q, &mbedtls_test_rnd_pseudo_rand, &rnd_info )
|
TEST_ASSERT( mbedtls_ecp_gen_keypair( &grp, &d, &Q,
|
||||||
== 0 );
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &Q ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_check_pubkey( &grp, &Q ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecp_check_privkey( &grp, &d ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_check_privkey( &grp, &d ) == 0 );
|
||||||
@ -1083,7 +1087,9 @@ void mbedtls_ecp_gen_key( int id )
|
|||||||
mbedtls_ecp_keypair_init( &key );
|
mbedtls_ecp_keypair_init( &key );
|
||||||
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
memset( &rnd_info, 0x00, sizeof( mbedtls_test_rnd_pseudo_info ) );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_gen_key( id, &key, &mbedtls_test_rnd_pseudo_rand, &rnd_info ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_gen_key( id, &key,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_ecp_check_pubkey( &key.grp, &key.Q ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_check_pubkey( &key.grp, &key.Q ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_ecp_check_privkey( &key.grp, &key.d ) == 0 );
|
TEST_ASSERT( mbedtls_ecp_check_privkey( &key.grp, &key.d ) == 0 );
|
||||||
|
@ -129,8 +129,9 @@ void hmac_drbg_seed_file( int md_alg, char * path, int ret )
|
|||||||
md_info = mbedtls_md_info_from_type( md_alg );
|
md_info = mbedtls_md_info_from_type( md_alg );
|
||||||
TEST_ASSERT( md_info != NULL );
|
TEST_ASSERT( md_info != NULL );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info, mbedtls_test_rnd_std_rand, NULL,
|
TEST_ASSERT( mbedtls_hmac_drbg_seed( &ctx, md_info,
|
||||||
NULL, 0 ) == 0 );
|
mbedtls_test_rnd_std_rand, NULL,
|
||||||
|
NULL, 0 ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_hmac_drbg_write_seed_file( &ctx, path ) == ret );
|
TEST_ASSERT( mbedtls_hmac_drbg_write_seed_file( &ctx, path ) == ret );
|
||||||
TEST_ASSERT( mbedtls_hmac_drbg_update_seed_file( &ctx, path ) == ret );
|
TEST_ASSERT( mbedtls_hmac_drbg_update_seed_file( &ctx, path ) == ret );
|
||||||
|
@ -240,7 +240,8 @@ void mpi_invalid_param( )
|
|||||||
mbedtls_mpi_exp_mod( &X, &X, &X, NULL, NULL ) );
|
mbedtls_mpi_exp_mod( &X, &X, &X, NULL, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||||
mbedtls_mpi_fill_random( NULL, 42, mbedtls_test_rnd_std_rand,
|
mbedtls_mpi_fill_random( NULL, 42,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_MPI_BAD_INPUT_DATA,
|
||||||
mbedtls_mpi_fill_random( &X, 42, NULL, NULL ) );
|
mbedtls_mpi_fill_random( &X, 42, NULL, NULL ) );
|
||||||
@ -1244,7 +1245,8 @@ void mbedtls_mpi_gen_prime( int bits, int flags, int ref_ret )
|
|||||||
|
|
||||||
mbedtls_mpi_init( &X );
|
mbedtls_mpi_init( &X );
|
||||||
|
|
||||||
my_ret = mbedtls_mpi_gen_prime( &X, bits, flags, mbedtls_test_rnd_std_rand, NULL );
|
my_ret = mbedtls_mpi_gen_prime( &X, bits, flags,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL );
|
||||||
TEST_ASSERT( my_ret == ref_ret );
|
TEST_ASSERT( my_ret == ref_ret );
|
||||||
|
|
||||||
if( ref_ret == 0 )
|
if( ref_ret == 0 )
|
||||||
@ -1254,14 +1256,16 @@ void mbedtls_mpi_gen_prime( int bits, int flags, int ref_ret )
|
|||||||
TEST_ASSERT( actual_bits >= (size_t) bits );
|
TEST_ASSERT( actual_bits >= (size_t) bits );
|
||||||
TEST_ASSERT( actual_bits <= (size_t) bits + 1 );
|
TEST_ASSERT( actual_bits <= (size_t) bits + 1 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, mbedtls_test_rnd_std_rand, NULL )
|
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40,
|
||||||
== 0 );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) == 0 );
|
||||||
if( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_DH )
|
if( flags & MBEDTLS_MPI_GEN_PRIME_FLAG_DH )
|
||||||
{
|
{
|
||||||
/* X = ( X - 1 ) / 2 */
|
/* X = ( X - 1 ) / 2 */
|
||||||
TEST_ASSERT( mbedtls_mpi_shift_r( &X, 1 ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_shift_r( &X, 1 ) == 0 );
|
||||||
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40, mbedtls_test_rnd_std_rand, NULL )
|
TEST_ASSERT( mbedtls_mpi_is_prime_ext( &X, 40,
|
||||||
== 0 );
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) == 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,8 +62,10 @@ static int pk_genkey( mbedtls_pk_context *pk, int parameter )
|
|||||||
parameter ) ) != 0 )
|
parameter ) ) != 0 )
|
||||||
return( ret );
|
return( ret );
|
||||||
|
|
||||||
return mbedtls_ecp_gen_keypair( &mbedtls_pk_ec( *pk )->grp, &mbedtls_pk_ec( *pk )->d,
|
return mbedtls_ecp_gen_keypair( &mbedtls_pk_ec( *pk )->grp,
|
||||||
&mbedtls_pk_ec( *pk )->Q, mbedtls_test_rnd_std_rand, NULL );
|
&mbedtls_pk_ec( *pk )->d,
|
||||||
|
&mbedtls_pk_ec( *pk )->Q,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL );
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return( -1 );
|
return( -1 );
|
||||||
@ -75,8 +77,8 @@ int mbedtls_rsa_decrypt_func( void *ctx, int mode, size_t *olen,
|
|||||||
size_t output_max_len )
|
size_t output_max_len )
|
||||||
{
|
{
|
||||||
return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx,
|
return( mbedtls_rsa_pkcs1_decrypt( (mbedtls_rsa_context *) ctx,
|
||||||
mbedtls_test_rnd_std_rand, NULL, mode, olen,
|
mbedtls_test_rnd_std_rand, NULL, mode,
|
||||||
input, output, output_max_len ) );
|
olen, input, output, output_max_len ) );
|
||||||
}
|
}
|
||||||
int mbedtls_rsa_sign_func( void *ctx,
|
int mbedtls_rsa_sign_func( void *ctx,
|
||||||
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
|
int (*f_rng)(void *, unsigned char *, size_t), void *p_rng,
|
||||||
@ -85,8 +87,9 @@ int mbedtls_rsa_sign_func( void *ctx,
|
|||||||
{
|
{
|
||||||
((void) f_rng);
|
((void) f_rng);
|
||||||
((void) p_rng);
|
((void) p_rng);
|
||||||
return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx, mbedtls_test_rnd_std_rand, NULL, mode,
|
return( mbedtls_rsa_pkcs1_sign( (mbedtls_rsa_context *) ctx,
|
||||||
md_alg, hashlen, hash, sig ) );
|
mbedtls_test_rnd_std_rand, NULL, mode,
|
||||||
|
md_alg, hashlen, hash, sig ) );
|
||||||
}
|
}
|
||||||
size_t mbedtls_rsa_key_len_func( void *ctx )
|
size_t mbedtls_rsa_key_len_func( void *ctx )
|
||||||
{
|
{
|
||||||
@ -431,100 +434,71 @@ void invalid_parameters( )
|
|||||||
NULL, sizeof( buf ) ) );
|
NULL, sizeof( buf ) ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_sign_restartable( NULL,
|
mbedtls_pk_sign_restartable( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||||
MBEDTLS_MD_NONE,
|
buf, &len, mbedtls_test_rnd_std_rand,
|
||||||
buf, sizeof( buf ),
|
NULL, NULL ) );
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign_restartable( &pk,
|
|
||||||
MBEDTLS_MD_NONE,
|
|
||||||
NULL, sizeof( buf ),
|
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign_restartable( &pk,
|
|
||||||
valid_md,
|
|
||||||
NULL, 0,
|
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL,
|
|
||||||
NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign_restartable( &pk,
|
|
||||||
MBEDTLS_MD_NONE,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
NULL, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL,
|
|
||||||
NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_sign( NULL,
|
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||||
MBEDTLS_MD_NONE,
|
buf, &len, mbedtls_test_rnd_std_rand,
|
||||||
buf, sizeof( buf ),
|
NULL, NULL ) );
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign( &pk,
|
|
||||||
MBEDTLS_MD_NONE,
|
|
||||||
NULL, sizeof( buf ),
|
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign( &pk,
|
|
||||||
valid_md,
|
|
||||||
NULL, 0,
|
|
||||||
buf, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_sign( &pk,
|
|
||||||
MBEDTLS_MD_NONE,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
NULL, &len,
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_decrypt( NULL,
|
mbedtls_pk_sign_restartable( &pk, valid_md, NULL, 0, buf, &len,
|
||||||
buf, sizeof( buf ),
|
mbedtls_test_rnd_std_rand, NULL, NULL ) );
|
||||||
buf, &len, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_decrypt( &pk,
|
|
||||||
NULL, sizeof( buf ),
|
|
||||||
buf, &len, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_decrypt( &pk,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
NULL, &len, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
|
||||||
mbedtls_pk_decrypt( &pk,
|
|
||||||
buf, sizeof( buf ),
|
|
||||||
buf, NULL, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_encrypt( NULL,
|
mbedtls_pk_sign_restartable( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||||
buf, sizeof( buf ),
|
NULL, &len, mbedtls_test_rnd_std_rand,
|
||||||
buf, &len, sizeof( buf ),
|
NULL, NULL ) );
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_encrypt( &pk,
|
mbedtls_pk_sign( NULL, MBEDTLS_MD_NONE, buf, sizeof( buf ),
|
||||||
NULL, sizeof( buf ),
|
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
buf, &len, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_encrypt( &pk,
|
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, NULL, sizeof( buf ),
|
||||||
buf, sizeof( buf ),
|
buf, &len, mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
NULL, &len, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_encrypt( &pk,
|
mbedtls_pk_sign( &pk, valid_md, NULL, 0, buf, &len,
|
||||||
buf, sizeof( buf ),
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
buf, NULL, sizeof( buf ),
|
|
||||||
mbedtls_test_rnd_std_rand, NULL ) );
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, buf, sizeof( buf ), NULL, &len,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_decrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_decrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_decrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_encrypt( NULL, buf, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_encrypt( &pk, NULL, sizeof( buf ), buf, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), NULL, &len, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
|
mbedtls_pk_encrypt( &pk, buf, sizeof( buf ), buf, NULL, sizeof( buf ),
|
||||||
|
mbedtls_test_rnd_std_rand, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_PK_BAD_INPUT_DATA,
|
||||||
mbedtls_pk_check_pair( NULL, &pk ) );
|
mbedtls_pk_check_pair( NULL, &pk ) );
|
||||||
@ -968,7 +942,9 @@ void pk_sign_verify( int type, int parameter, int sign_ret, int verify_ret )
|
|||||||
}
|
}
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash,
|
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_SHA256, hash, sizeof hash,
|
||||||
sig, &sig_len, mbedtls_test_rnd_std_rand, NULL ) == sign_ret );
|
sig, &sig_len,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
|
NULL ) == sign_ret );
|
||||||
if( sign_ret == 0 )
|
if( sign_ret == 0 )
|
||||||
TEST_ASSERT( sig_len <= MBEDTLS_PK_SIGNATURE_MAX_SIZE );
|
TEST_ASSERT( sig_len <= MBEDTLS_PK_SIGNATURE_MAX_SIZE );
|
||||||
else
|
else
|
||||||
@ -1023,8 +999,8 @@ void pk_rsa_encrypt_test_vec( data_t * message, int mod, int radix_N,
|
|||||||
TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 );
|
TEST_ASSERT( mbedtls_mpi_read_string( &rsa->E, radix_E, input_E ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk, message->x, message->len,
|
TEST_ASSERT( mbedtls_pk_encrypt( &pk, message->x, message->len,
|
||||||
output, &olen, sizeof( output ),
|
output, &olen, sizeof( output ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||||
TEST_ASSERT( olen == result->len );
|
TEST_ASSERT( olen == result->len );
|
||||||
TEST_ASSERT( memcmp( output, result->x, olen ) == 0 );
|
TEST_ASSERT( memcmp( output, result->x, olen ) == 0 );
|
||||||
|
|
||||||
@ -1072,8 +1048,8 @@ void pk_rsa_decrypt_test_vec( data_t * cipher, int mod, int radix_P,
|
|||||||
memset( output, 0, sizeof( output ) );
|
memset( output, 0, sizeof( output ) );
|
||||||
olen = 0;
|
olen = 0;
|
||||||
TEST_ASSERT( mbedtls_pk_decrypt( &pk, cipher->x, cipher->len,
|
TEST_ASSERT( mbedtls_pk_decrypt( &pk, cipher->x, cipher->len,
|
||||||
output, &olen, sizeof( output ),
|
output, &olen, sizeof( output ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||||
if( ret == 0 )
|
if( ret == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( olen == clear->len );
|
TEST_ASSERT( olen == clear->len );
|
||||||
@ -1106,12 +1082,12 @@ void pk_ec_nocrypt( int type )
|
|||||||
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( type ) ) == 0 );
|
TEST_ASSERT( mbedtls_pk_setup( &pk, mbedtls_pk_info_from_type( type ) ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_encrypt( &pk, input, sizeof( input ),
|
TEST_ASSERT( mbedtls_pk_encrypt( &pk, input, sizeof( input ),
|
||||||
output, &olen, sizeof( output ),
|
output, &olen, sizeof( output ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_decrypt( &pk, input, sizeof( input ),
|
TEST_ASSERT( mbedtls_pk_decrypt( &pk, input, sizeof( input ),
|
||||||
output, &olen, sizeof( output ),
|
output, &olen, sizeof( output ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info ) == ret );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free( &pk );
|
mbedtls_pk_free( &pk );
|
||||||
@ -1145,8 +1121,9 @@ void pk_rsa_overflow( )
|
|||||||
TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_NONE, hash, hash_len,
|
TEST_ASSERT( mbedtls_pk_verify( &pk, MBEDTLS_MD_NONE, hash, hash_len,
|
||||||
sig, sig_len ) == MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
sig, sig_len ) == MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, hash, hash_len, sig, &sig_len,
|
TEST_ASSERT( mbedtls_pk_sign( &pk, MBEDTLS_MD_NONE, hash, hash_len, sig,
|
||||||
mbedtls_test_rnd_std_rand, NULL ) == MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
&sig_len, mbedtls_test_rnd_std_rand, NULL )
|
||||||
|
== MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
mbedtls_pk_free( &pk );
|
mbedtls_pk_free( &pk );
|
||||||
@ -1199,12 +1176,13 @@ void pk_rsa_alt( )
|
|||||||
|
|
||||||
/* Test signature */
|
/* Test signature */
|
||||||
#if SIZE_MAX > UINT_MAX
|
#if SIZE_MAX > UINT_MAX
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, SIZE_MAX,
|
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, SIZE_MAX, sig,
|
||||||
sig, &sig_len, mbedtls_test_rnd_std_rand, NULL ) ==
|
&sig_len, mbedtls_test_rnd_std_rand, NULL )
|
||||||
MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
== MBEDTLS_ERR_PK_BAD_INPUT_DATA );
|
||||||
#endif /* SIZE_MAX > UINT_MAX */
|
#endif /* SIZE_MAX > UINT_MAX */
|
||||||
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, sizeof hash,
|
TEST_ASSERT( mbedtls_pk_sign( &alt, MBEDTLS_MD_NONE, hash, sizeof hash, sig,
|
||||||
sig, &sig_len, mbedtls_test_rnd_std_rand, NULL ) == 0 );
|
&sig_len, mbedtls_test_rnd_std_rand, NULL )
|
||||||
|
== 0 );
|
||||||
TEST_ASSERT( sig_len == RSA_KEY_LEN );
|
TEST_ASSERT( sig_len == RSA_KEY_LEN );
|
||||||
TEST_ASSERT( mbedtls_pk_verify( &rsa, MBEDTLS_MD_NONE,
|
TEST_ASSERT( mbedtls_pk_verify( &rsa, MBEDTLS_MD_NONE,
|
||||||
hash, sizeof hash, sig, sig_len ) == 0 );
|
hash, sizeof hash, sig, sig_len ) == 0 );
|
||||||
|
@ -34,7 +34,12 @@ void pkcs1_rsaes_v15_encrypt( int mod, int radix_N, char * input_N,
|
|||||||
|
|
||||||
if( message_str->len == 0 )
|
if( message_str->len == 0 )
|
||||||
message_str->x = NULL;
|
message_str->x = NULL;
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||||
|
&mbedtls_test_rnd_buffer_rand,
|
||||||
|
&info, MBEDTLS_RSA_PUBLIC,
|
||||||
|
message_str->len, message_str->x,
|
||||||
|
output ) == result );
|
||||||
|
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||||
@ -81,11 +86,20 @@ void pkcs1_rsaes_v15_decrypt( int mod, int radix_P, char * input_P,
|
|||||||
|
|
||||||
if( result_hex_str->len == 0 )
|
if( result_hex_str->len == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, NULL, 0 ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info,
|
||||||
|
MBEDTLS_RSA_PRIVATE,
|
||||||
|
&output_len, message_str->x,
|
||||||
|
NULL, 0 ) == result );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, 1000 ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||||
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info, MBEDTLS_RSA_PRIVATE,
|
||||||
|
&output_len, message_str->x,
|
||||||
|
output, 1000 ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||||
@ -196,16 +210,15 @@ void pkcs1_v15_decode( int mode,
|
|||||||
if( mode == MBEDTLS_RSA_PRIVATE )
|
if( mode == MBEDTLS_RSA_PRIVATE )
|
||||||
TEST_ASSERT( mbedtls_rsa_public( &ctx, original, intermediate ) == 0 );
|
TEST_ASSERT( mbedtls_rsa_public( &ctx, original, intermediate ) == 0 );
|
||||||
else
|
else
|
||||||
TEST_ASSERT( mbedtls_rsa_private( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_private( &ctx, &mbedtls_test_rnd_pseudo_rand,
|
||||||
original, intermediate ) == 0 );
|
&rnd_info, original,
|
||||||
|
intermediate ) == 0 );
|
||||||
|
|
||||||
memcpy( final, default_content, sizeof( final ) );
|
memcpy( final, default_content, sizeof( final ) );
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
mode,
|
&rnd_info, mode, &output_length,
|
||||||
&output_length,
|
intermediate, final,
|
||||||
intermediate,
|
|
||||||
final,
|
|
||||||
output_size ) == expected_result );
|
output_size ) == expected_result );
|
||||||
if( expected_result == 0 )
|
if( expected_result == 0 )
|
||||||
{
|
{
|
||||||
@ -286,7 +299,9 @@ void pkcs1_rsassa_v15_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
|||||||
if( mbedtls_md_info_from_type( digest ) != NULL )
|
if( mbedtls_md_info_from_type( digest ) != NULL )
|
||||||
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE, digest, 0, hash_result, output ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_buffer_rand,
|
||||||
|
&info, MBEDTLS_RSA_PRIVATE, digest,
|
||||||
|
0, hash_result, output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -34,7 +34,11 @@ void pkcs1_rsaes_oaep_encrypt( int mod, int radix_N, char * input_N,
|
|||||||
|
|
||||||
if( message_str->len == 0 )
|
if( message_str->len == 0 )
|
||||||
message_str->x = NULL;
|
message_str->x = NULL;
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_buffer_rand, &info, MBEDTLS_RSA_PUBLIC, message_str->len, message_str->x, output ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||||
|
&mbedtls_test_rnd_buffer_rand,
|
||||||
|
&info, MBEDTLS_RSA_PUBLIC,
|
||||||
|
message_str->len, message_str->x,
|
||||||
|
output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||||
@ -82,15 +86,21 @@ void pkcs1_rsaes_oaep_decrypt( int mod, int radix_P, char * input_P,
|
|||||||
|
|
||||||
if( result_hex_str->len == 0 )
|
if( result_hex_str->len == 0 )
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||||
MBEDTLS_RSA_PRIVATE, &output_len,
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
message_str->x, NULL, 0 ) == result );
|
&rnd_info,
|
||||||
|
MBEDTLS_RSA_PRIVATE,
|
||||||
|
&output_len, message_str->x,
|
||||||
|
NULL, 0 ) == result );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx,
|
||||||
MBEDTLS_RSA_PRIVATE, &output_len,
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
message_str->x, output,
|
&rnd_info,
|
||||||
|
MBEDTLS_RSA_PRIVATE,
|
||||||
|
&output_len, message_str->x,
|
||||||
|
output,
|
||||||
sizeof( output ) ) == result );
|
sizeof( output ) ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
@ -144,8 +154,9 @@ void pkcs1_rsassa_pss_sign( int mod, int radix_P, char * input_P, int radix_Q,
|
|||||||
if( mbedtls_md_info_from_type( digest ) != NULL )
|
if( mbedtls_md_info_from_type( digest ) != NULL )
|
||||||
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_buffer_rand, &info, MBEDTLS_RSA_PRIVATE,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_buffer_rand,
|
||||||
digest, 0, hash_result, output ) == result );
|
&info, MBEDTLS_RSA_PRIVATE, digest, 0,
|
||||||
|
hash_result, output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -67,7 +67,8 @@ void rsa_invalid_param( )
|
|||||||
invalid_padding, 0 ) );
|
invalid_padding, 0 ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||||
mbedtls_rsa_gen_key( NULL, mbedtls_test_rnd_std_rand,
|
mbedtls_rsa_gen_key( NULL,
|
||||||
|
mbedtls_test_rnd_std_rand,
|
||||||
NULL, 0, 0 ) );
|
NULL, 0, 0 ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_RSA_BAD_INPUT_DATA,
|
||||||
mbedtls_rsa_gen_key( &ctx, NULL,
|
mbedtls_rsa_gen_key( &ctx, NULL,
|
||||||
@ -500,9 +501,9 @@ void mbedtls_rsa_pkcs1_sign( data_t * message_str, int padding_mode,
|
|||||||
if( mbedtls_md_info_from_type( digest ) != NULL )
|
if( mbedtls_md_info_from_type( digest ) != NULL )
|
||||||
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
TEST_ASSERT( mbedtls_md( mbedtls_md_info_from_type( digest ), message_str->x, message_str->len, hash_result ) == 0 );
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_pseudo_rand,
|
||||||
MBEDTLS_RSA_PRIVATE, digest, 0,
|
&rnd_info, MBEDTLS_RSA_PRIVATE, digest,
|
||||||
hash_result, output ) == result );
|
0, hash_result, output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -581,10 +582,10 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
|||||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_sign( &ctx, &mbedtls_test_rnd_pseudo_rand,
|
||||||
MBEDTLS_RSA_PRIVATE, MBEDTLS_MD_NONE,
|
&rnd_info, MBEDTLS_RSA_PRIVATE,
|
||||||
hash_result->len, hash_result->x,
|
MBEDTLS_MD_NONE, hash_result->len,
|
||||||
output ) == 0 );
|
hash_result->x, output ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
TEST_ASSERT( mbedtls_test_hexcmp( output, result_hex_str->x,
|
||||||
@ -598,8 +599,9 @@ void rsa_pkcs1_sign_raw( data_t * hash_result,
|
|||||||
memset( output, 0x00, sizeof( output) );
|
memset( output, 0x00, sizeof( output) );
|
||||||
|
|
||||||
res = mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx,
|
res = mbedtls_rsa_rsaes_pkcs1_v15_encrypt( &ctx,
|
||||||
&mbedtls_test_rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE,
|
&mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
||||||
hash_result->len, hash_result->x, output );
|
MBEDTLS_RSA_PRIVATE, hash_result->len,
|
||||||
|
hash_result->x, output );
|
||||||
|
|
||||||
#if !defined(MBEDTLS_RSA_ALT)
|
#if !defined(MBEDTLS_RSA_ALT)
|
||||||
TEST_ASSERT( res == 0 );
|
TEST_ASSERT( res == 0 );
|
||||||
@ -712,9 +714,11 @@ void mbedtls_rsa_pkcs1_encrypt( data_t * message_str, int padding_mode,
|
|||||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx,
|
||||||
MBEDTLS_RSA_PUBLIC, message_str->len,
|
&mbedtls_test_rnd_pseudo_rand,
|
||||||
message_str->x, output ) == result );
|
&rnd_info, MBEDTLS_RSA_PUBLIC,
|
||||||
|
message_str->len, message_str->x,
|
||||||
|
output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -751,9 +755,10 @@ void rsa_pkcs1_encrypt_bad_rng( data_t * message_str, int padding_mode,
|
|||||||
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
TEST_ASSERT( mbedtls_rsa_check_pubkey( &ctx ) == 0 );
|
||||||
|
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_zero_rand, NULL,
|
TEST_ASSERT( mbedtls_rsa_pkcs1_encrypt( &ctx, &mbedtls_test_rnd_zero_rand,
|
||||||
MBEDTLS_RSA_PUBLIC, message_str->len,
|
NULL, MBEDTLS_RSA_PUBLIC,
|
||||||
message_str->x, output ) == result );
|
message_str->len, message_str->x,
|
||||||
|
output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -802,7 +807,10 @@ void mbedtls_rsa_pkcs1_decrypt( data_t * message_str, int padding_mode,
|
|||||||
|
|
||||||
output_len = 0;
|
output_len = 0;
|
||||||
|
|
||||||
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, mbedtls_test_rnd_pseudo_rand, &rnd_info, MBEDTLS_RSA_PRIVATE, &output_len, message_str->x, output, max_output ) == result );
|
TEST_ASSERT( mbedtls_rsa_pkcs1_decrypt( &ctx, mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info, MBEDTLS_RSA_PRIVATE,
|
||||||
|
&output_len, message_str->x, output,
|
||||||
|
max_output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -907,8 +915,9 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
|||||||
for( i = 0; i < 3; i++ )
|
for( i = 0; i < 3; i++ )
|
||||||
{
|
{
|
||||||
memset( output, 0x00, sizeof( output ) );
|
memset( output, 0x00, sizeof( output ) );
|
||||||
TEST_ASSERT( mbedtls_rsa_private( &ctx, mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_private( &ctx, mbedtls_test_rnd_pseudo_rand,
|
||||||
message_str->x, output ) == result );
|
&rnd_info, message_str->x,
|
||||||
|
output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -926,8 +935,9 @@ void mbedtls_rsa_private( data_t * message_str, int mod, int radix_P,
|
|||||||
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx2 ) == 0 );
|
TEST_ASSERT( mbedtls_rsa_check_privkey( &ctx2 ) == 0 );
|
||||||
|
|
||||||
memset( output, 0x00, sizeof( output ) );
|
memset( output, 0x00, sizeof( output ) );
|
||||||
TEST_ASSERT( mbedtls_rsa_private( &ctx2, mbedtls_test_rnd_pseudo_rand, &rnd_info,
|
TEST_ASSERT( mbedtls_rsa_private( &ctx2, mbedtls_test_rnd_pseudo_rand,
|
||||||
message_str->x, output ) == result );
|
&rnd_info, message_str->x,
|
||||||
|
output ) == result );
|
||||||
if( result == 0 )
|
if( result == 0 )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -3339,7 +3339,8 @@ void ssl_crypt_record_small( int cipher_type, int hash_id,
|
|||||||
rec_backup = rec;
|
rec_backup = rec;
|
||||||
|
|
||||||
/* Encrypt record */
|
/* Encrypt record */
|
||||||
ret = mbedtls_ssl_encrypt_buf( &ssl, t_enc, &rec, mbedtls_test_rnd_std_rand, NULL );
|
ret = mbedtls_ssl_encrypt_buf( &ssl, t_enc, &rec,
|
||||||
|
mbedtls_test_rnd_std_rand, NULL );
|
||||||
|
|
||||||
if( ( mode == 1 || mode == 2 ) && seen_success )
|
if( ( mode == 1 || mode == 2 ) && seen_success )
|
||||||
{
|
{
|
||||||
|
@ -111,7 +111,7 @@ void x509_csr_check( char * key_file, char * cert_req_check_file, int md_type,
|
|||||||
TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 );
|
TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 );
|
||||||
|
|
||||||
ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ),
|
ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
||||||
TEST_ASSERT( ret == 0 );
|
TEST_ASSERT( ret == 0 );
|
||||||
|
|
||||||
pem_len = strlen( (char *) buf );
|
pem_len = strlen( (char *) buf );
|
||||||
@ -125,14 +125,15 @@ void x509_csr_check( char * key_file, char * cert_req_check_file, int md_type,
|
|||||||
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
||||||
|
|
||||||
der_len = mbedtls_x509write_csr_der( &req, buf, sizeof( buf ),
|
der_len = mbedtls_x509write_csr_der( &req, buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info );
|
||||||
TEST_ASSERT( der_len >= 0 );
|
TEST_ASSERT( der_len >= 0 );
|
||||||
|
|
||||||
if( der_len == 0 )
|
if( der_len == 0 )
|
||||||
goto exit;
|
goto exit;
|
||||||
|
|
||||||
ret = mbedtls_x509write_csr_der( &req, buf, (size_t)( der_len - 1 ),
|
ret = mbedtls_x509write_csr_der( &req, buf, (size_t)( der_len - 1 ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
||||||
TEST_ASSERT( ret == MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
TEST_ASSERT( ret == MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
@ -175,7 +176,8 @@ void x509_csr_check_opaque( char *key_file, int md_type, int key_usage,
|
|||||||
TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 );
|
TEST_ASSERT( mbedtls_x509write_csr_set_ns_cert_type( &req, cert_type ) == 0 );
|
||||||
|
|
||||||
ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ) - 1,
|
ret = mbedtls_x509write_csr_pem( &req, buf, sizeof( buf ) - 1,
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
||||||
|
|
||||||
TEST_ASSERT( ret == 0 );
|
TEST_ASSERT( ret == 0 );
|
||||||
|
|
||||||
pem_len = strlen( (char *) buf );
|
pem_len = strlen( (char *) buf );
|
||||||
@ -284,7 +286,8 @@ void x509_crt_check( char *subject_key_file, char *subject_pwd,
|
|||||||
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
TEST_ASSERT( memcmp( buf, check_buf, pem_len - 1 ) == 0 );
|
||||||
|
|
||||||
der_len = mbedtls_x509write_crt_der( &crt, buf, sizeof( buf ),
|
der_len = mbedtls_x509write_crt_der( &crt, buf, sizeof( buf ),
|
||||||
mbedtls_test_rnd_pseudo_rand, &rnd_info );
|
mbedtls_test_rnd_pseudo_rand,
|
||||||
|
&rnd_info );
|
||||||
TEST_ASSERT( der_len >= 0 );
|
TEST_ASSERT( der_len >= 0 );
|
||||||
|
|
||||||
if( der_len == 0 )
|
if( der_len == 0 )
|
||||||
|
Loading…
Reference in New Issue
Block a user