1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-08-08 17:42:09 +03:00

Ensure all md_<hash>_finish functions perform zeroization

Signed-off-by: Dave Rodgman <dave.rodgman@arm.com>
This commit is contained in:
Dave Rodgman
2023-09-11 12:59:36 +01:00
parent 33fbd373be
commit aafd1e0924
5 changed files with 35 additions and 16 deletions

View File

@@ -844,7 +844,7 @@ int mbedtls_sha512_finish(mbedtls_sha512_context *ctx,
memset(ctx->buffer + used, 0, SHA512_BLOCK_SIZE - used);
if ((ret = mbedtls_internal_sha512_process(ctx, ctx->buffer)) != 0) {
return ret;
goto exit;
}
memset(ctx->buffer, 0, 112);
@@ -861,7 +861,7 @@ int mbedtls_sha512_finish(mbedtls_sha512_context *ctx,
sha512_put_uint64_be(low, ctx->buffer, 120);
if ((ret = mbedtls_internal_sha512_process(ctx, ctx->buffer)) != 0) {
return ret;
goto exit;
}
/*
@@ -883,7 +883,11 @@ int mbedtls_sha512_finish(mbedtls_sha512_context *ctx,
sha512_put_uint64_be(ctx->state[7], output, 56);
}
return 0;
ret = 0;
exit:
mbedtls_sha512_free(ctx);
return ret;
}
#endif /* !MBEDTLS_SHA512_ALT */