Add additional verification that output hasn't been modified

Signed-off-by: Ben Taylor <[email protected]>
(cherry picked from commit 720ee2392a6ced5ee0220a87c20d6c3d43a10650)
This commit is contained in:
Ben Taylor
2026-06-11 14:11:16 +01:00
parent 29090200c2
commit bac83ee5de
@@ -84,6 +84,7 @@ void chachapoly_update_too_long()
unsigned char input[65] = { 0 };
unsigned char output[65] = { 0 };
mbedtls_chachapoly_context ctx;
size_t i;
mbedtls_chachapoly_init(&ctx);
@@ -93,8 +94,12 @@ void chachapoly_update_too_long()
/* Force the next update to be too long without processing a huge buffer. */
ctx.chacha20_ctx.state[12] = UINT32_MAX;
memset(output, 0x2a, sizeof(output));
TEST_EQUAL(mbedtls_chachapoly_update(&ctx, sizeof(input), input, output),
MBEDTLS_ERR_CHACHA20_BAD_INPUT_DATA);
for (i = 0; i < sizeof(output); i++) {
TEST_EQUAL(output[i], 0x2a);
}
exit:
mbedtls_chachapoly_free(&ctx);