Remove handle from MD context in single hash config

This commit is contained in:
Hanno Becker 2019-09-03 13:19:14 +01:00
parent 1292c35c03
commit ccb2b62f0a
2 changed files with 13 additions and 0 deletions

View file

@ -104,8 +104,10 @@ typedef int mbedtls_md_handle_t;
*/ */
typedef struct mbedtls_md_context_t typedef struct mbedtls_md_context_t
{ {
#if !defined(MBEDTLS_MD_SINGLE_HASH)
/** Information about the associated message digest. */ /** Information about the associated message digest. */
mbedtls_md_handle_t md_info; mbedtls_md_handle_t md_info;
#endif
/** The digest-specific context. */ /** The digest-specific context. */
void *md_ctx; void *md_ctx;
@ -114,11 +116,20 @@ typedef struct mbedtls_md_context_t
void *hmac_ctx; void *hmac_ctx;
} mbedtls_md_context_t; } mbedtls_md_context_t;
#if !defined(MBEDTLS_MD_SINGLE_HASH)
static inline mbedtls_md_handle_t mbedtls_md_get_handle( static inline mbedtls_md_handle_t mbedtls_md_get_handle(
struct mbedtls_md_context_t const *ctx ) struct mbedtls_md_context_t const *ctx )
{ {
return( ctx->md_info ); 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 * \brief This function returns the list of digests supported by the

View file

@ -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; ctx->md_info = md_info;
#endif
return( 0 ); return( 0 );
} }