diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index 6b4d09a6f..65aad13fc 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -29,9 +29,9 @@ void mbedtls_md_process() for (md_type_ptr = mbedtls_md_list(); *md_type_ptr != 0; md_type_ptr++) { info = mbedtls_md_info_from_type(*md_type_ptr); TEST_ASSERT(info != NULL); - TEST_ASSERT(mbedtls_md_setup(&ctx, info, 0) == 0); - TEST_ASSERT(mbedtls_md_starts(&ctx) == 0); - TEST_ASSERT(mbedtls_md_process(&ctx, buf) == 0); + TEST_EQUAL(0, mbedtls_md_setup(&ctx, info, 0)); + TEST_EQUAL(0, mbedtls_md_starts(&ctx)); + TEST_EQUAL(0, mbedtls_md_process(&ctx, buf)); mbedtls_md_free(&ctx); } @@ -49,7 +49,7 @@ void md_null_args() mbedtls_md_init(&ctx); - TEST_ASSERT(mbedtls_md_get_size(NULL) == 0); + TEST_EQUAL(0, mbedtls_md_get_size(NULL)); TEST_ASSERT(mbedtls_md_get_type(NULL) == MBEDTLS_MD_NONE); TEST_ASSERT(mbedtls_md_get_name(NULL) == NULL); @@ -57,47 +57,45 @@ void md_null_args() TEST_ASSERT(mbedtls_md_info_from_ctx(NULL) == NULL); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx) == NULL); - TEST_ASSERT(mbedtls_md_setup(&ctx, NULL, 0) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_setup(NULL, info, 0) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_setup(&ctx, NULL, 0), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_setup(NULL, info, 0), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_starts(NULL) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_starts(&ctx) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_starts(NULL), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_starts(&ctx), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_update(NULL, buf, 1) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_update(&ctx, buf, 1) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_update(NULL, buf, 1), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_update(&ctx, buf, 1), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_finish(NULL, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_finish(&ctx, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_finish(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_finish(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md(NULL, buf, 1, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md(NULL, buf, 1, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); #if defined(MBEDTLS_FS_IO) - TEST_ASSERT(mbedtls_md_file(NULL, "", buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_file(NULL, "", buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); #endif - TEST_ASSERT(mbedtls_md_hmac_starts(NULL, buf, 1) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_starts(&ctx, buf, 1) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_starts(NULL, buf, 1), + MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_starts(&ctx, buf, 1), + MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_update(NULL, buf, 1) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_update(&ctx, buf, 1) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_update(NULL, buf, 1), + MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_update(&ctx, buf, 1), + MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_finish(NULL, buf) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_finish(&ctx, buf) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_finish(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_finish(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_reset(NULL) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac_reset(&ctx) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_reset(NULL), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac_reset(&ctx), MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_hmac(NULL, buf, 1, buf, 1, buf) - == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_hmac(NULL, buf, 1, buf, 1, buf), + MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_process(NULL, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); - TEST_ASSERT(mbedtls_md_process(&ctx, buf) == MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_process(NULL, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); + TEST_EQUAL(mbedtls_md_process(&ctx, buf), MBEDTLS_ERR_MD_BAD_INPUT_DATA); /* Ok, this is not NULL arg but NULL return... */ TEST_ASSERT(mbedtls_md_info_from_type(MBEDTLS_MD_NONE) == NULL); @@ -116,9 +114,9 @@ void md_info(int md_type, char *md_name, int md_size) TEST_ASSERT(md_info != NULL); TEST_ASSERT(md_info == mbedtls_md_info_from_string(md_name)); - TEST_ASSERT(mbedtls_md_get_type(md_info) == (mbedtls_md_type_t) md_type); - TEST_ASSERT(mbedtls_md_get_size(md_info) == (unsigned char) md_size); - TEST_ASSERT(strcmp(mbedtls_md_get_name(md_info), md_name) == 0); + TEST_EQUAL(mbedtls_md_get_type(md_info), (mbedtls_md_type_t) md_type); + TEST_EQUAL(mbedtls_md_get_size(md_info), (unsigned char) md_size); + TEST_EQUAL(0, strcmp(mbedtls_md_get_name(md_info), md_name)); found = 0; for (md_type_ptr = mbedtls_md_list(); *md_type_ptr != 0; md_type_ptr++) { @@ -126,7 +124,7 @@ void md_info(int md_type, char *md_name, int md_size) found = 1; } } - TEST_ASSERT(found == 1); + TEST_EQUAL(found, 1); } /* END_CASE */ @@ -141,7 +139,7 @@ void md_text(int md_type, char *text_src_string, data_t *hash) md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(0 == mbedtls_md(md_info, src, src_len, output)); + TEST_EQUAL(0, mbedtls_md(md_info, src, src_len, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info), @@ -158,7 +156,7 @@ void md_hex(int md_type, data_t *src_str, data_t *hash) md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(0 == mbedtls_md(md_info, src_str->x, src_str->len, output)); + TEST_EQUAL(0, mbedtls_md(md_info, src_str->x, src_str->len, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, @@ -186,18 +184,18 @@ void md_text_multi(int md_type, char *text_src_string, md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 0)); - TEST_ASSERT(0 == mbedtls_md_setup(&ctx_copy, md_info, 0)); + TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 0)); + TEST_EQUAL(0, mbedtls_md_setup(&ctx_copy, md_info, 0)); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx) == md_info); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx_copy) == md_info); - TEST_ASSERT(0 == mbedtls_md_starts(&ctx)); + TEST_EQUAL(0, mbedtls_md_starts(&ctx)); TEST_ASSERT(ctx.md_ctx != NULL); - TEST_ASSERT(0 == mbedtls_md_update(&ctx, src, halfway)); - TEST_ASSERT(0 == mbedtls_md_clone(&ctx_copy, &ctx)); + TEST_EQUAL(0, mbedtls_md_update(&ctx, src, halfway)); + TEST_EQUAL(0, mbedtls_md_clone(&ctx_copy, &ctx)); - TEST_ASSERT(0 == mbedtls_md_update(&ctx, src + halfway, src_len - halfway)); - TEST_ASSERT(0 == mbedtls_md_finish(&ctx, output)); + TEST_EQUAL(0, mbedtls_md_update(&ctx, src + halfway, src_len - halfway)); + TEST_EQUAL(0, mbedtls_md_finish(&ctx, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info), hash->len) == 0); @@ -205,8 +203,8 @@ void md_text_multi(int md_type, char *text_src_string, /* Test clone */ memset(output, 0x00, sizeof(output)); - TEST_ASSERT(0 == mbedtls_md_update(&ctx_copy, src + halfway, src_len - halfway)); - TEST_ASSERT(0 == mbedtls_md_finish(&ctx_copy, output)); + TEST_EQUAL(0, mbedtls_md_update(&ctx_copy, src + halfway, src_len - halfway)); + TEST_EQUAL(0, mbedtls_md_finish(&ctx_copy, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info), hash->len) == 0); @@ -230,20 +228,20 @@ void md_hex_multi(int md_type, data_t *src_str, data_t *hash) md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 0)); - TEST_ASSERT(0 == mbedtls_md_setup(&ctx_copy, md_info, 0)); + TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 0)); + TEST_EQUAL(0, mbedtls_md_setup(&ctx_copy, md_info, 0)); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx) == md_info); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx_copy) == md_info); halfway = src_str->len / 2; - TEST_ASSERT(0 == mbedtls_md_starts(&ctx)); + TEST_EQUAL(0, mbedtls_md_starts(&ctx)); TEST_ASSERT(ctx.md_ctx != NULL); - TEST_ASSERT(0 == mbedtls_md_update(&ctx, src_str->x, halfway)); - TEST_ASSERT(0 == mbedtls_md_clone(&ctx_copy, &ctx)); + TEST_EQUAL(0, mbedtls_md_update(&ctx, src_str->x, halfway)); + TEST_EQUAL(0, mbedtls_md_clone(&ctx_copy, &ctx)); - TEST_ASSERT(0 == mbedtls_md_update(&ctx, src_str->x + halfway, src_str->len - halfway)); - TEST_ASSERT(0 == mbedtls_md_finish(&ctx, output)); + TEST_EQUAL(0, mbedtls_md_update(&ctx, src_str->x + halfway, src_str->len - halfway)); + TEST_EQUAL(0, mbedtls_md_finish(&ctx, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info), hash->len) == 0); @@ -251,8 +249,8 @@ void md_hex_multi(int md_type, data_t *src_str, data_t *hash) /* Test clone */ memset(output, 0x00, sizeof(output)); - TEST_ASSERT(0 == mbedtls_md_update(&ctx_copy, src_str->x + halfway, src_str->len - halfway)); - TEST_ASSERT(0 == mbedtls_md_finish(&ctx_copy, output)); + TEST_EQUAL(0, mbedtls_md_update(&ctx_copy, src_str->x + halfway, src_str->len - halfway)); + TEST_EQUAL(0, mbedtls_md_finish(&ctx_copy, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info), hash->len) == 0); @@ -275,8 +273,8 @@ void mbedtls_md_hmac(int md_type, int trunc_size, TEST_ASSERT(md_info != NULL); - TEST_ASSERT(mbedtls_md_hmac(md_info, key_str->x, key_str->len, src_str->x, src_str->len, - output) == 0); + TEST_EQUAL(0, mbedtls_md_hmac(md_info, key_str->x, key_str->len, + src_str->x, src_str->len, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, trunc_size, hash->len) == 0); @@ -296,16 +294,16 @@ void md_hmac_multi(int md_type, int trunc_size, data_t *key_str, md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(0 == mbedtls_md_setup(&ctx, md_info, 1)); + TEST_EQUAL(0, mbedtls_md_setup(&ctx, md_info, 1)); TEST_ASSERT(mbedtls_md_info_from_ctx(&ctx) == md_info); halfway = src_str->len / 2; - TEST_ASSERT(0 == mbedtls_md_hmac_starts(&ctx, key_str->x, key_str->len)); + TEST_EQUAL(0, mbedtls_md_hmac_starts(&ctx, key_str->x, key_str->len)); TEST_ASSERT(ctx.md_ctx != NULL); - TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x, halfway)); - TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway)); - TEST_ASSERT(0 == mbedtls_md_hmac_finish(&ctx, output)); + TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x, halfway)); + TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway)); + TEST_EQUAL(0, mbedtls_md_hmac_finish(&ctx, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, trunc_size, hash->len) == 0); @@ -313,10 +311,10 @@ void md_hmac_multi(int md_type, int trunc_size, data_t *key_str, /* Test again, for reset() */ memset(output, 0x00, sizeof(output)); - TEST_ASSERT(0 == mbedtls_md_hmac_reset(&ctx)); - TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x, halfway)); - TEST_ASSERT(0 == mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway)); - TEST_ASSERT(0 == mbedtls_md_hmac_finish(&ctx, output)); + TEST_EQUAL(0, mbedtls_md_hmac_reset(&ctx)); + TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x, halfway)); + TEST_EQUAL(0, mbedtls_md_hmac_update(&ctx, src_str->x + halfway, src_str->len - halfway)); + TEST_EQUAL(0, mbedtls_md_hmac_finish(&ctx, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, trunc_size, hash->len) == 0); @@ -336,7 +334,7 @@ void mbedtls_md_file(int md_type, char *filename, md_info = mbedtls_md_info_from_type(md_type); TEST_ASSERT(md_info != NULL); - TEST_ASSERT(mbedtls_md_file(md_info, filename, output) == 0); + TEST_EQUAL(0, mbedtls_md_file(md_info, filename, output)); TEST_ASSERT(mbedtls_test_hexcmp(output, hash->x, mbedtls_md_get_size(md_info),