Remove internal function md_process()

It was already marked as internal use only, and no longer used
internally. Also, it won't work when we dispatch to PSA.

Remove it before the MD_LIGHT split to avoid a corner case: it's
technically a hashing function, no HMAC or extra metadata, but we still
don't want it in MD_LIGHT really.

Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
Manuel Pégourié-Gonnard 2023-02-16 18:44:46 +01:00
parent e2a9f86755
commit ba2412fd21
4 changed files with 6 additions and 59 deletions

View file

@ -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

View file

@ -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) {

View file

@ -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:

View file

@ -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);