mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-25 20:25:53 +01:00
Minor improvements to DHM module
This commit is contained in:
parent
8c8a93c574
commit
adc9b178ca
@ -108,7 +108,6 @@ static int dhm_check_range( const mbedtls_mpi *param, const mbedtls_mpi *P )
|
|||||||
mbedtls_mpi L, U;
|
mbedtls_mpi L, U;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
|
|
||||||
mbedtls_mpi_init( &L ); mbedtls_mpi_init( &U );
|
mbedtls_mpi_init( &L ); mbedtls_mpi_init( &U );
|
||||||
|
|
||||||
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &L, 2 ) );
|
MBEDTLS_MPI_CHK( mbedtls_mpi_lset( &L, 2 ) );
|
||||||
|
@ -14,6 +14,7 @@ void dhm_invalid_params( )
|
|||||||
unsigned char buf[42] = { 0 };
|
unsigned char buf[42] = { 0 };
|
||||||
unsigned char *buf_null = NULL;
|
unsigned char *buf_null = NULL;
|
||||||
mbedtls_mpi X;
|
mbedtls_mpi X;
|
||||||
|
size_t const buflen = sizeof( buf );
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
TEST_INVALID_PARAM( mbedtls_dhm_init( NULL ) );
|
TEST_INVALID_PARAM( mbedtls_dhm_init( NULL ) );
|
||||||
@ -33,22 +34,22 @@ 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_make_params( NULL, 42,
|
mbedtls_dhm_make_params( NULL, buflen,
|
||||||
buf, &len,
|
buf, &len,
|
||||||
rnd_std_rand,
|
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_make_params( &ctx, 42,
|
mbedtls_dhm_make_params( &ctx, buflen,
|
||||||
NULL, &len,
|
NULL, &len,
|
||||||
rnd_std_rand,
|
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_make_params( &ctx, 42,
|
mbedtls_dhm_make_params( &ctx, buflen,
|
||||||
buf, NULL,
|
buf, NULL,
|
||||||
rnd_std_rand,
|
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_make_params( &ctx, 42,
|
mbedtls_dhm_make_params( &ctx, buflen,
|
||||||
buf, &len,
|
buf, &len,
|
||||||
NULL,
|
NULL,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
@ -61,44 +62,44 @@ void dhm_invalid_params( )
|
|||||||
mbedtls_dhm_set_group( &ctx, &X, NULL ) );
|
mbedtls_dhm_set_group( &ctx, &X, NULL ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_read_public( NULL, buf, 42 ) );
|
mbedtls_dhm_read_public( NULL, buf, buflen ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_read_public( &ctx, NULL, 42 ) );
|
mbedtls_dhm_read_public( &ctx, NULL, buflen ) );
|
||||||
|
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_make_public( NULL, 42,
|
mbedtls_dhm_make_public( NULL, buflen,
|
||||||
buf, 42,
|
buf, buflen,
|
||||||
rnd_std_rand,
|
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_make_public( &ctx, 42,
|
mbedtls_dhm_make_public( &ctx, buflen,
|
||||||
NULL, 42,
|
NULL, buflen,
|
||||||
rnd_std_rand,
|
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_make_public( &ctx, 42,
|
mbedtls_dhm_make_public( &ctx, buflen,
|
||||||
buf, 42,
|
buf, buflen,
|
||||||
NULL,
|
NULL,
|
||||||
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, 42,
|
mbedtls_dhm_calc_secret( NULL, buf, buflen,
|
||||||
&len, rnd_std_rand,
|
&len, 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, 42,
|
mbedtls_dhm_calc_secret( &ctx, NULL, buflen,
|
||||||
&len, rnd_std_rand,
|
&len, 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, 42,
|
mbedtls_dhm_calc_secret( &ctx, buf, buflen,
|
||||||
NULL, rnd_std_rand,
|
NULL, rnd_std_rand,
|
||||||
NULL ) );
|
NULL ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_parse_dhm( NULL, buf, 42 ) );
|
mbedtls_dhm_parse_dhm( NULL, buf, buflen ) );
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
mbedtls_dhm_parse_dhm( &ctx, NULL, 42 ) );
|
mbedtls_dhm_parse_dhm( &ctx, NULL, buflen ) );
|
||||||
|
|
||||||
#if defined(MBEDTLS_FS_IO)
|
#if defined(MBEDTLS_FS_IO)
|
||||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||||
|
Loading…
Reference in New Issue
Block a user