From: Loup Vaillant Date: Fri, 17 Mar 2017 18:28:40 +0000 (+0100) Subject: cosmetic X-Git-Url: https://git.codecow.com/?a=commitdiff_plain;h=8bb65c352a90b2775a00f4880ea74fc68dae1335;p=Monocypher.git cosmetic --- diff --git a/monocypher.c b/monocypher.c index eed5679..bab9467 100644 --- a/monocypher.c +++ b/monocypher.c @@ -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--; } } diff --git a/monocypher.h b/monocypher.h index a6a56bd..71a797e 100644 --- a/monocypher.h +++ b/monocypher.h @@ -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]);