diff --git a/tests/suites/test_suite_md.data b/tests/suites/test_suite_md.data index bd25a5353..85be7df0b 100644 --- a/tests/suites/test_suite_md.data +++ b/tests/suites/test_suite_md.data @@ -1,6 +1,9 @@ MD process md_process: +MD NULL/uninitialised arguments +md_null_args: + Information on MD2 depends_on:POLARSSL_MD2_C md_info:POLARSSL_MD_MD2:"MD2":16 diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index 74c5a6681..9f064434c 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -36,6 +36,63 @@ void md_process( ) } /* END_CASE */ +/* BEGIN_CASE */ +void md_null_args( ) +{ + md_context_t ctx; + const md_info_t *info = md_info_from_type( *( md_list() ) ); + unsigned char buf[1] = { 0 }; + + memset( &ctx, 0, sizeof( md_context_t ) ); + + TEST_ASSERT( md_get_size( NULL ) == 0 ); + + TEST_ASSERT( md_get_type( NULL ) == POLARSSL_MD_NONE ); + + TEST_ASSERT( md_info_from_string( NULL ) == NULL ); + + TEST_ASSERT( md_init_ctx( &ctx, NULL ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_init_ctx( NULL, info ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_starts( NULL ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_starts( &ctx ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_update( NULL, buf, 1 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_update( &ctx, buf, 1 ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_finish( NULL, buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_finish( &ctx, buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md( NULL, buf, 1, buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_file( NULL, "", buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_hmac_starts( NULL, buf, 1 ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_hmac_starts( &ctx, buf, 1 ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_hmac_update( NULL, buf, 1 ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_hmac_update( &ctx, buf, 1 ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_hmac_finish( NULL, buf ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_hmac_finish( &ctx, buf ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_hmac_reset( NULL ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_hmac_reset( &ctx ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_hmac( NULL, buf, 1, buf, 1, buf ) + == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + + TEST_ASSERT( md_process( NULL, buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); + TEST_ASSERT( md_process( &ctx, buf ) == POLARSSL_ERR_MD_BAD_INPUT_DATA ); +} +/* END_CASE */ + /* BEGIN_CASE */ void md_info( int md_type, char *md_name, int md_size ) {