Minimally test md_process and associated wrappers

This commit is contained in:
Manuel Pégourié-Gonnard 2014-04-02 17:52:04 +02:00
parent f8708ddc95
commit edb242fb2f
2 changed files with 22 additions and 4 deletions

View file

@ -1,5 +1,5 @@
MD list MD process
md_list: md_process:
Information on MD2 Information on MD2
depends_on:POLARSSL_MD2_C depends_on:POLARSSL_MD2_C

View file

@ -8,12 +8,30 @@
*/ */
/* BEGIN_CASE */ /* BEGIN_CASE */
void md_list( ) void md_process( )
{ {
const int *md_type_ptr; const int *md_type_ptr;
const md_info_t *info;
md_context_t ctx;
unsigned char buf[150];
memset( &ctx, 0, sizeof ctx );
/*
* Very minimal testing of md_process, just make sure the various
* xxx_process_wrap() function pointers are valid. (Testing that they
* indeed do the right thing whould require messing with the internal
* state of the underlying md/sha context.)
*
* Also tests that md_list() only returns valid MDs.
*/
for( md_type_ptr = md_list(); *md_type_ptr != 0; md_type_ptr++ ) for( md_type_ptr = md_list(); *md_type_ptr != 0; md_type_ptr++ )
TEST_ASSERT( md_info_from_type( *md_type_ptr ) != NULL ); {
TEST_ASSERT( ( info = md_info_from_type( *md_type_ptr ) ) != NULL );
TEST_ASSERT( md_init_ctx( &ctx, info ) == 0 );
TEST_ASSERT( md_process( &ctx, buf ) == 0 );
TEST_ASSERT( md_free_ctx( &ctx ) == 0 );
}
} }
/* END_CASE */ /* END_CASE */