Permalink
Browse files

fixed signed overflow

  • Loading branch information...
LoupVaillant committed Jul 18, 2017
1 parent 4a444ff commit 347189c50c053cf13ce1310818c2913f4904c1eb
Showing with 2 additions and 2 deletions.
  1. +2 −2 src/monocypher.c
View
@@ -290,7 +290,7 @@ void crypto_poly1305_update(crypto_poly1305_ctx *ctx,
poly_clear_c(ctx); poly_clear_c(ctx);
} }
// feed the input buffer // 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++; 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 // move the final 1 according to remaining input length
// (We may add less than 2^130 to the last input block) // (We may add less than 2^130 to the last input block)
ctx->c[4] = 0; 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 // one last hash update
poly_block(ctx); poly_block(ctx);
} }

0 comments on commit 347189c

Please sign in to comment.