Update *_multi tests in test_suite_md to do more than 1 step
diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function
index 0fcaa38..e8fec28 100644
--- a/tests/suites/test_suite_md.function
+++ b/tests/suites/test_suite_md.function
@@ -187,6 +187,7 @@
unsigned char src_str[1000];
unsigned char hash_str[1000];
unsigned char output[100];
+ int halfway, len;
const mbedtls_md_info_t *md_info = NULL;
mbedtls_md_context_t ctx;
@@ -200,13 +201,17 @@
strncpy( (char *) src_str, text_src_string, sizeof(src_str) - 1 );
strncpy( (char *) md_name, text_md_name, sizeof(md_name) - 1 );
+ len = strlen( (char *) src_str );
+ halfway = len / 2;
+
md_info = mbedtls_md_info_from_string(md_name);
TEST_ASSERT( md_info != NULL );
TEST_ASSERT ( 0 == mbedtls_md_setup( &ctx, md_info, 0 ) );
TEST_ASSERT ( 0 == mbedtls_md_starts( &ctx ) );
TEST_ASSERT ( ctx.md_ctx != NULL );
- TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str, strlen( (char *) src_str ) ) );
+ TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str, halfway ) );
+ TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
hexify( hash_str, output, mbedtls_md_get_size(md_info) );
@@ -226,7 +231,7 @@
unsigned char src_str[10000];
unsigned char hash_str[10000];
unsigned char output[100];
- int src_len;
+ int src_len, halfway;
const mbedtls_md_info_t *md_info = NULL;
mbedtls_md_context_t ctx;
@@ -243,10 +248,12 @@
TEST_ASSERT ( 0 == mbedtls_md_setup( &ctx, md_info, 0 ) );
src_len = unhexify( src_str, hex_src_string );
+ halfway = src_len / 2;
TEST_ASSERT ( 0 == mbedtls_md_starts( &ctx ) );
TEST_ASSERT ( ctx.md_ctx != NULL );
- TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str, src_len ) );
+ TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str, halfway ) );
+ TEST_ASSERT ( 0 == mbedtls_md_update( &ctx, src_str + halfway, src_len - halfway) );
TEST_ASSERT ( 0 == mbedtls_md_finish( &ctx, output ) );
hexify( hash_str, output, mbedtls_md_get_size(md_info) );
@@ -299,7 +306,7 @@
unsigned char key_str[10000];
unsigned char hash_str[10000];
unsigned char output[100];
- int key_len, src_len;
+ int key_len, src_len, halfway;
const mbedtls_md_info_t *md_info = NULL;
mbedtls_md_context_t ctx;
@@ -318,10 +325,12 @@
key_len = unhexify( key_str, hex_key_string );
src_len = unhexify( src_str, hex_src_string );
+ halfway = src_len / 2;
TEST_ASSERT ( 0 == mbedtls_md_hmac_starts( &ctx, key_str, key_len ) );
TEST_ASSERT ( ctx.md_ctx != NULL );
- TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, src_len ) );
+ TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, halfway ) );
+ TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str + halfway, src_len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
hexify( hash_str, output, mbedtls_md_get_size(md_info) );
@@ -332,7 +341,8 @@
memset(output, 0x00, 100);
TEST_ASSERT ( 0 == mbedtls_md_hmac_reset( &ctx ) );
- TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, src_len ) );
+ TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str, halfway ) );
+ TEST_ASSERT ( 0 == mbedtls_md_hmac_update( &ctx, src_str + halfway, src_len - halfway ) );
TEST_ASSERT ( 0 == mbedtls_md_hmac_finish( &ctx, output ) );
hexify( hash_str, output, mbedtls_md_get_size(md_info) );