From 59ba4e983b5a51e87ba86d0ed835b3850a0305cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Sat, 29 Mar 2014 14:43:44 +0100 Subject: [PATCH] Test generic md_hmac_reset() --- tests/suites/test_suite_md.function | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index c972cc2cf..502df4533 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -197,11 +197,23 @@ void md_hmac_multi( char *text_md_name, int trunc_size, char *hex_key_string, TEST_ASSERT ( ctx.md_ctx != NULL ); TEST_ASSERT ( 0 == md_hmac_update( &ctx, src_str, src_len ) ); TEST_ASSERT ( 0 == md_hmac_finish( &ctx, output ) ); + + hexify( hash_str, output, md_get_size(md_info) ); + TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); + + /* Test again, for reset() */ + memset(hash_str, 0x00, 10000); + memset(output, 0x00, 100); + + TEST_ASSERT ( 0 == md_hmac_reset( &ctx ) ); + TEST_ASSERT ( 0 == md_hmac_update( &ctx, src_str, src_len ) ); + TEST_ASSERT ( 0 == md_hmac_finish( &ctx, output ) ); TEST_ASSERT ( 0 == md_free_ctx( &ctx ) ); hexify( hash_str, output, md_get_size(md_info) ); - TEST_ASSERT( strncmp( (char *) hash_str, hex_hash_string, trunc_size * 2 ) == 0 ); + + TEST_ASSERT ( 0 == md_free_ctx( &ctx ) ); } /* END_CASE */