mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-29 15:54:30 +01:00
Test parameter validation for DHM module
This commit is contained in:
parent
5c14ed6f86
commit
8c8a93c574
@ -1,3 +1,6 @@
|
||||
Diffie-Hellman parameter validation
|
||||
dhm_invalid_params:
|
||||
|
||||
Diffie-Hellman full exchange #1
|
||||
dhm_do_dhm:10:"23":10:"5":0
|
||||
|
||||
|
@ -7,6 +7,112 @@
|
||||
* END_DEPENDENCIES
|
||||
*/
|
||||
|
||||
/* BEGIN_CASE depends_on:MBEDTLS_CHECK_PARAMS:!MBEDTLS_PARAM_FAILED_ALT */
|
||||
void dhm_invalid_params( )
|
||||
{
|
||||
mbedtls_dhm_context ctx;
|
||||
unsigned char buf[42] = { 0 };
|
||||
unsigned char *buf_null = NULL;
|
||||
mbedtls_mpi X;
|
||||
size_t len;
|
||||
|
||||
TEST_INVALID_PARAM( mbedtls_dhm_init( NULL ) );
|
||||
TEST_VALID_PARAM( mbedtls_dhm_free( NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( NULL,
|
||||
(unsigned char**) &buf,
|
||||
buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx, &buf_null, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx, NULL, buf ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_params( &ctx,
|
||||
(unsigned char**) &buf,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( NULL, 42,
|
||||
buf, &len,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, 42,
|
||||
NULL, &len,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, 42,
|
||||
buf, NULL,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_params( &ctx, 42,
|
||||
buf, &len,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( NULL, &X, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( &ctx, NULL, &X ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_set_group( &ctx, &X, NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_public( NULL, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_read_public( &ctx, NULL, 42 ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( NULL, 42,
|
||||
buf, 42,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, 42,
|
||||
NULL, 42,
|
||||
rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_make_public( &ctx, 42,
|
||||
buf, 42,
|
||||
NULL,
|
||||
NULL ) );
|
||||
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( NULL, buf, 42,
|
||||
&len, rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, NULL, 42,
|
||||
&len, rnd_std_rand,
|
||||
NULL ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_calc_secret( &ctx, buf, 42,
|
||||
NULL, rnd_std_rand,
|
||||
NULL ) );
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhm( NULL, buf, 42 ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhm( &ctx, NULL, 42 ) );
|
||||
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhmfile( NULL, "" ) );
|
||||
TEST_INVALID_PARAM_RET( MBEDTLS_ERR_DHM_BAD_INPUT_DATA,
|
||||
mbedtls_dhm_parse_dhmfile( &ctx, NULL ) );
|
||||
#endif /* MBEDTLS_FS_IO */
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
|
||||
exit:
|
||||
return;
|
||||
}
|
||||
/* END_CASE */
|
||||
|
||||
/* BEGIN_CASE */
|
||||
void dhm_do_dhm( int radix_P, char *input_P,
|
||||
int radix_G, char *input_G, int result )
|
||||
|
Loading…
Reference in New Issue
Block a user