From: Loup Vaillant Date: Sat, 24 Feb 2018 14:46:49 +0000 (+0100) Subject: Strength reduction for Chacha20 X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=c08d3c300b11adc9ac02d90e59c7306ea6c0bcd3;p=Monocypher.git Strength reduction for Chacha20 The performance gain is tiny, but measurable. --- diff --git a/src/monocypher.c b/src/monocypher.c index 5fee4de..a792b38 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -236,15 +236,16 @@ void crypto_chacha20_encrypt(crypto_chacha_ctx *ctx, if (plain_text != 0) { FOR (j, 0, 16) { u32 plain = load32_le(plain_text); - store32_le(cipher_text + j * 4, ctx->pool[j] ^ plain); - plain_text += 4; + store32_le(cipher_text, ctx->pool[j] ^ plain); + plain_text += 4; + cipher_text += 4; } } else { FOR (j, 0, 16) { - store32_le(cipher_text + j * 4, ctx->pool[j]); + store32_le(cipher_text, ctx->pool[j]); + cipher_text += 4; } } - cipher_text += 64; ctx->pool_idx = 64; }