mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2026-08-13 22:57:51 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user