From 347189c50c053cf13ce1310818c2913f4904c1eb Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Tue, 18 Jul 2017 12:02:02 +0200 Subject: [PATCH] fixed signed overflow --- src/monocypher.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/monocypher.c b/src/monocypher.c index 68691a0..e870896 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -290,7 +290,7 @@ void crypto_poly1305_update(crypto_poly1305_ctx *ctx, poly_clear_c(ctx); } // feed the input buffer - ctx->c[ctx->c_index / 4] |= msg[i] << ((ctx->c_index % 4) * 8); + ctx->c[ctx->c_index / 4] |= (u32)msg[i] << ((ctx->c_index % 4) * 8); ctx->c_index++; } } @@ -302,7 +302,7 @@ void crypto_poly1305_final(crypto_poly1305_ctx *ctx, u8 mac[16]) // move the final 1 according to remaining input length // (We may add less than 2^130 to the last input block) ctx->c[4] = 0; - ctx->c[ctx->c_index / 4] |= 1 << ((ctx->c_index % 4) * 8); + ctx->c[ctx->c_index / 4] |= (u32)1 << ((ctx->c_index % 4) * 8); // one last hash update poly_block(ctx); } -- 2.47.3