]> git.codecow.com Git - Monocypher.git/commitdiff
cosmetic
authorLoup Vaillant <loup@loup-vaillant.fr>
Fri, 17 Mar 2017 18:28:40 +0000 (19:28 +0100)
committerLoup Vaillant <loup@loup-vaillant.fr>
Fri, 17 Mar 2017 18:29:48 +0000 (19:29 +0100)
monocypher.c
monocypher.h

index eed56792cf4b20a05d6a705fe792bdfb9907f2b8..bab9467a732f33270f080da925ff8c7068462887 100644 (file)
@@ -184,7 +184,7 @@ void crypto_chacha20_encrypt(crypto_chacha_ctx *ctx,
         }
         // use the pool for encryption (or random stream)
         cipher_text[i] =
-            (plain_text == 0 ? 0 : plain_text[i])
+            (plain_text == 0 ? 0 : plain_text[i]) // ignore null plaintext
             ^ ctx->random_pool[ctx->pool_index];
         ctx->pool_index++;
     }
@@ -272,18 +272,16 @@ void crypto_poly1305_init(crypto_poly1305_ctx *ctx, const u8 key[32])
 }
 
 void crypto_poly1305_update(crypto_poly1305_ctx *ctx,
-                            const u8 *m, size_t bytes)
+                            const u8 *msg, size_t msg_size)
 {
-    while (bytes > 0) {
+    FOR (i, 0, msg_size) {
         if (ctx->c_index == 16) {
             poly_block(ctx);
             poly_clear_c(ctx);
         }
         // feed the input buffer
-        ctx->c[ctx->c_index / 4] |= *m << ((ctx->c_index % 4) * 8);
+        ctx->c[ctx->c_index / 4] |= msg[i] << ((ctx->c_index % 4) * 8);
         ctx->c_index++;
-        m++;
-        bytes--;
     }
 }
 
index a6a56bd3cc1934e97fba393cba1318a5387aebb6..71a797ee61946bcc50d56bd63a4aa5ff450f01cc 100644 (file)
@@ -56,7 +56,7 @@ typedef struct {
 void crypto_poly1305_init(crypto_poly1305_ctx *ctx, const uint8_t key[32]);
 
 void crypto_poly1305_update(crypto_poly1305_ctx *ctx,
-                            const uint8_t *m, size_t bytes);
+                            const uint8_t *msg, size_t msg_size);
 
 void crypto_poly1305_final(crypto_poly1305_ctx *ctx, uint8_t mac[16]);