]> git.codecow.com Git - Monocypher.git/commitdiff
Rolled loop for zero initialisation
authorLoup Vaillant <loup@loup-vaillant.fr>
Sun, 5 Jan 2020 20:32:41 +0000 (21:32 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Sun, 5 Jan 2020 20:32:41 +0000 (21:32 +0100)
- Compilers optimise loops better.
- We save one line of code this way.

(This is a nitpick: in practice, this doesn't change a thing.)

src/monocypher.c

index 53cbc48f91c8c580fc9dd56806a370726aeedfbc..7e55f24622fd8b5faa9dedfea81e02698387a5c4 100644 (file)
@@ -369,10 +369,9 @@ static void poly_block(crypto_poly1305_ctx *ctx)
 // (re-)initialises the input counter and input buffer
 static void poly_clear_c(crypto_poly1305_ctx *ctx)
 {
-    ctx->c[0]  = 0;
-    ctx->c[1]  = 0;
-    ctx->c[2]  = 0;
-    ctx->c[3]  = 0;
+    FOR (i, 0, 4) {
+        ctx->c[i] = 0;
+    }
     ctx->c_idx = 0;
 }