From: Loup Vaillant Date: Fri, 14 Feb 2020 23:27:25 +0000 (+0100) Subject: Removed modulo operation in SHA-512 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=d36944946ecda0a48c885702fc4b0b20618ecd16;p=Monocypher.git Removed modulo operation in SHA-512 While I expect almost all compilers optimise those down to a bit mask in practice, it can help naive compilers generate better code. The rest of Monocypher already took this approach, I just forgot about this one. --- diff --git a/src/optional/monocypher-ed25519.c b/src/optional/monocypher-ed25519.c index f6b4628..fe844ce 100644 --- a/src/optional/monocypher-ed25519.c +++ b/src/optional/monocypher-ed25519.c @@ -163,8 +163,8 @@ static void sha512_set_input(crypto_sha512_ctx *ctx, u8 input) ctx->input[i] = 0; } } - size_t word = ctx->input_idx / 8; - size_t byte = ctx->input_idx % 8; + size_t word = ctx->input_idx >> 3; + size_t byte = ctx->input_idx & 7; ctx->input[word] |= (u64)input << (8 * (7 - byte)); }