diff --git a/include/mbedtls/md.h b/include/mbedtls/md.h index 97d3b0696..2810a9180 100644 --- a/include/mbedtls/md.h +++ b/include/mbedtls/md.h @@ -104,8 +104,10 @@ typedef int mbedtls_md_handle_t; */ typedef struct mbedtls_md_context_t { +#if !defined(MBEDTLS_MD_SINGLE_HASH) /** Information about the associated message digest. */ mbedtls_md_handle_t md_info; +#endif /** The digest-specific context. */ void *md_ctx; @@ -114,11 +116,20 @@ typedef struct mbedtls_md_context_t void *hmac_ctx; } mbedtls_md_context_t; +#if !defined(MBEDTLS_MD_SINGLE_HASH) static inline mbedtls_md_handle_t mbedtls_md_get_handle( struct mbedtls_md_context_t const *ctx ) { return( ctx->md_info ); } +#else /* !MBEDTLS_MD_SINGLE_HASH */ +static inline mbedtls_md_handle_t mbedtls_md_get_handle( + struct mbedtls_md_context_t const *ctx ) +{ + ((void) ctx); + return( MBEDTLS_MD_UNIQUE_VALID_HANDLE ); +} +#endif /* !MBEDTLS_MD_SINGLE_HASH */ /** * \brief This function returns the list of digests supported by the diff --git a/library/md.c b/library/md.c index abc2ad3f5..cbe92dd68 100644 --- a/library/md.c +++ b/library/md.c @@ -1167,7 +1167,9 @@ int mbedtls_md_setup( mbedtls_md_context_t *ctx, mbedtls_md_handle_t md_info, in } } +#if !defined(MBEDTLS_MD_SINGLE_HASH) ctx->md_info = md_info; +#endif return( 0 ); }