MD: Embed digest context structure into MD wrapper context

This commit is contained in:
Hanno Becker 2019-09-05 13:02:52 +01:00
parent 4a99765f94
commit 52e36bc1a1
2 changed files with 21 additions and 3 deletions

View file

@ -108,6 +108,8 @@ typedef int mbedtls_md_handle_t;
#endif /* !MBEDTLS_MD_SINGLE_HASH */
#include "md_internal.h"
/**
* The generic message-digest context.
*/
@ -118,11 +120,20 @@ typedef struct mbedtls_md_context_t
mbedtls_md_handle_t md_info;
#endif
#if !defined(MBEDTLS_MD_SINGLE_HASH)
/** The digest-specific context. */
void *md_ctx;
/** The HMAC part of the context. */
void *hmac_ctx;
#else
unsigned char md_ctx[ sizeof( MBEDTLS_MD_INFO_CTX_TYPE(
MBEDTLS_MD_SINGLE_HASH ) ) ];
unsigned char hmac_ctx[ 2 * MBEDTLS_MD_INFO_BLOCKSIZE(
MBEDTLS_MD_SINGLE_HASH ) ];
#endif /* MBEDTLS_MD_SINGLE_HASH */
} mbedtls_md_context_t;
#if !defined(MBEDTLS_MD_SINGLE_HASH)
@ -140,8 +151,6 @@ static inline mbedtls_md_handle_t mbedtls_md_get_handle(
}
#endif /* !MBEDTLS_MD_SINGLE_HASH */
#include "md_internal.h"
/**
* \brief This function returns the list of digests supported by the
* generic digest module.