MD: Implement config dep'n inlining of mbedtls_md_process()
diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h
index 899623f..104c577 100644
--- a/include/mbedtls/md.h
+++ b/include/mbedtls/md.h
@@ -508,7 +508,8 @@
unsigned char *output );
/* Internal use */
-int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data );
+MBEDTLS_MD_INLINABLE_API int mbedtls_md_process( mbedtls_md_context_t *ctx,
+ const unsigned char *data );
/*
* Internal wrapper functions for those MD API functions which should be
@@ -575,6 +576,20 @@
ilen, output) );
}
+MBEDTLS_ALWAYS_INLINE static inline int mbedtls_md_process_internal(
+ mbedtls_md_context_t *ctx, const unsigned char *data )
+{
+ mbedtls_md_handle_t md_info;
+ if( ctx == NULL )
+ return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
+
+ md_info = mbedtls_md_get_handle( ctx );
+ if( md_info == MBEDTLS_MD_INVALID_HANDLE )
+ return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
+
+ return( mbedtls_md_info_process( md_info, ctx->md_ctx, data ) );
+}
+
#if defined(MBEDTLS_MD_SINGLE_HASH)
MBEDTLS_MD_INLINABLE_API int mbedtls_md_starts(
mbedtls_md_context_t *ctx )
@@ -605,6 +620,12 @@
return( mbedtls_md_internal( md_info, input, ilen, output ) );
}
+MBEDTLS_MD_INLINABLE_API int mbedtls_md_process(
+ mbedtls_md_context_t *ctx, const unsigned char *data )
+{
+ return( mbedtls_md_process_internal( ctx, data ) );
+}
+
#endif /* MBEDTLS_MD_SINGLE_HASH */
#ifdef __cplusplus
diff --git a/library/md.c b/library/md.c
index b648baa..0998532 100644
--- a/library/md.c
+++ b/library/md.c
@@ -711,18 +711,12 @@
return( ret );
}
+#if !defined(MBEDTLS_MD_SINGLE_HASH)
int mbedtls_md_process( mbedtls_md_context_t *ctx, const unsigned char *data )
{
- mbedtls_md_handle_t md_info;
- if( ctx == NULL )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- md_info = mbedtls_md_get_handle( ctx );
- if( md_info == MBEDTLS_MD_INVALID_HANDLE )
- return( MBEDTLS_ERR_MD_BAD_INPUT_DATA );
-
- return( mbedtls_md_info_process( md_info, ctx->md_ctx, data ) );
+ return( mbedtls_md_process_internal( ctx, data ) );
}
+#endif /* !MBEDTLS_MD_SINGLE_HASH */
unsigned char mbedtls_md_get_size( mbedtls_md_handle_t md_info )
{