diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index 1a92c57611..bcf56a5499 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -471,10 +471,6 @@ int mbedtls_md_hmac(const mbedtls_md_info_t *md_info, const unsigned char *key, const unsigned char *input, size_t ilen, unsigned char *output); -/* Internal use */ -MBEDTLS_CHECK_RETURN_TYPICAL -int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data); - #ifdef __cplusplus } #endif diff --git a/library/md.c b/library/md.c index a729878990..dd5553aa9a 100644 --- a/library/md.c +++ b/library/md.c @@ -774,46 +774,6 @@ cleanup: return ret; } -int mbedtls_md_process(mbedtls_md_context_t *ctx, const unsigned char *data) -{ - if (ctx == NULL || ctx->md_info == NULL) { - return MBEDTLS_ERR_MD_BAD_INPUT_DATA; - } - - switch (ctx->md_info->type) { -#if defined(MBEDTLS_MD5_C) - case MBEDTLS_MD_MD5: - return mbedtls_internal_md5_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_RIPEMD160_C) - case MBEDTLS_MD_RIPEMD160: - return mbedtls_internal_ripemd160_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_SHA1_C) - case MBEDTLS_MD_SHA1: - return mbedtls_internal_sha1_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_SHA224_C) - case MBEDTLS_MD_SHA224: - return mbedtls_internal_sha256_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_SHA256_C) - case MBEDTLS_MD_SHA256: - return mbedtls_internal_sha256_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_SHA384_C) - case MBEDTLS_MD_SHA384: - return mbedtls_internal_sha512_process(ctx->md_ctx, data); -#endif -#if defined(MBEDTLS_SHA512_C) - case MBEDTLS_MD_SHA512: - return mbedtls_internal_sha512_process(ctx->md_ctx, data); -#endif - default: - return MBEDTLS_ERR_MD_BAD_INPUT_DATA; - } -} - unsigned char mbedtls_md_get_size(const mbedtls_md_info_t *md_info) { if (md_info == NULL) { diff --git a/tests/suites/test_suite_md.data b/tests/suites/test_suite_md.data index 5659ff4316..79b837619b 100644 --- a/tests/suites/test_suite_md.data +++ b/tests/suites/test_suite_md.data @@ -1,6 +1,6 @@ # Tests of the generic message digest interface -MD process -mbedtls_md_process: +MD list +mbedtls_md_list: MD NULL/uninitialised arguments md_null_args: diff --git a/tests/suites/test_suite_md.function b/tests/suites/test_suite_md.function index 2f60c4e999..ac3a8baf4f 100644 --- a/tests/suites/test_suite_md.function +++ b/tests/suites/test_suite_md.function @@ -8,30 +8,24 @@ */ /* BEGIN_CASE */ -void mbedtls_md_process() +void mbedtls_md_list() { const int *md_type_ptr; const mbedtls_md_info_t *info; mbedtls_md_context_t ctx; - unsigned char buf[150]; + unsigned char out[MBEDTLS_MD_MAX_SIZE] = { 0 }; mbedtls_md_init(&ctx); - memset(buf, 0, sizeof(buf)); /* - * Very minimal testing of mbedtls_md_process, just make sure the various - * xxx_process_wrap() function pointers are valid. (Testing that they - * indeed do the right thing would require messing with the internal - * state of the underlying mbedtls_md/sha context.) - * - * Also tests that mbedtls_md_list() only returns valid MDs. + * Test that mbedtls_md_list() only returns valid MDs. */ 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_EQUAL(0, mbedtls_md_setup(&ctx, info, 0)); TEST_EQUAL(0, mbedtls_md_starts(&ctx)); - TEST_EQUAL(0, mbedtls_md_process(&ctx, buf)); + TEST_EQUAL(0, mbedtls_md_finish(&ctx, out)); mbedtls_md_free(&ctx); } @@ -94,9 +88,6 @@ void md_null_args() TEST_EQUAL(mbedtls_md_hmac(NULL, buf, 1, buf, 1, 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); TEST_ASSERT(mbedtls_md_info_from_string("no such md") == NULL);