mirror of
https://github.com/espressif/mbedtls.git
synced 2025-05-11 20:42:22 +08:00
Finish removing HMAC from MD-light
Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
parent
c9e0ad23c1
commit
39a376a417
@ -205,8 +205,10 @@ typedef struct mbedtls_md_context_t {
|
|||||||
/** The digest-specific context (legacy) or the PSA operation. */
|
/** The digest-specific context (legacy) or the PSA operation. */
|
||||||
void *MBEDTLS_PRIVATE(md_ctx);
|
void *MBEDTLS_PRIVATE(md_ctx);
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
/** The HMAC part of the context. */
|
/** The HMAC part of the context. */
|
||||||
void *MBEDTLS_PRIVATE(hmac_ctx);
|
void *MBEDTLS_PRIVATE(hmac_ctx);
|
||||||
|
#endif
|
||||||
} mbedtls_md_context_t;
|
} mbedtls_md_context_t;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
10
library/md.c
10
library/md.c
@ -287,11 +287,13 @@ void mbedtls_md_free(mbedtls_md_context_t *ctx)
|
|||||||
mbedtls_free(ctx->md_ctx);
|
mbedtls_free(ctx->md_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
if (ctx->hmac_ctx != NULL) {
|
if (ctx->hmac_ctx != NULL) {
|
||||||
mbedtls_platform_zeroize(ctx->hmac_ctx,
|
mbedtls_platform_zeroize(ctx->hmac_ctx,
|
||||||
2 * ctx->md_info->block_size);
|
2 * ctx->md_info->block_size);
|
||||||
mbedtls_free(ctx->hmac_ctx);
|
mbedtls_free(ctx->hmac_ctx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
mbedtls_platform_zeroize(ctx, sizeof(mbedtls_md_context_t));
|
mbedtls_platform_zeroize(ctx, sizeof(mbedtls_md_context_t));
|
||||||
}
|
}
|
||||||
@ -380,7 +382,13 @@ int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info
|
|||||||
|
|
||||||
ctx->md_info = md_info;
|
ctx->md_info = md_info;
|
||||||
ctx->md_ctx = NULL;
|
ctx->md_ctx = NULL;
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
ctx->hmac_ctx = NULL;
|
ctx->hmac_ctx = NULL;
|
||||||
|
#else
|
||||||
|
if (hmac != 0) {
|
||||||
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_MD_SOME_PSA)
|
#if defined(MBEDTLS_MD_SOME_PSA)
|
||||||
if (md_uses_psa(ctx->md_info)) {
|
if (md_uses_psa(ctx->md_info)) {
|
||||||
@ -431,6 +439,7 @@ int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info
|
|||||||
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
return MBEDTLS_ERR_MD_BAD_INPUT_DATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_MD_C)
|
||||||
if (hmac != 0) {
|
if (hmac != 0) {
|
||||||
ctx->hmac_ctx = mbedtls_calloc(2, md_info->block_size);
|
ctx->hmac_ctx = mbedtls_calloc(2, md_info->block_size);
|
||||||
if (ctx->hmac_ctx == NULL) {
|
if (ctx->hmac_ctx == NULL) {
|
||||||
@ -438,6 +447,7 @@ int mbedtls_md_setup(mbedtls_md_context_t *ctx, const mbedtls_md_info_t *md_info
|
|||||||
return MBEDTLS_ERR_MD_ALLOC_FAILED;
|
return MBEDTLS_ERR_MD_ALLOC_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user