// Shuffle the block thus: ctx->b = G((G(ctx->b, zero)), zero)
// (G "square" function), to get cheap pseudo-random numbers.
- unary_g(&(ctx->b));
- unary_g(&(ctx->b));
+ unary_g(&ctx->b);
+ unary_g(&ctx->b);
}
static void gidx_init(gidx_ctx *ctx,
}
}
}
- wipe_block(&(ctx.b));
+ wipe_block(&ctx.b);
wipe_block(&tmp);
// hash the very last block with H' into the output hash
u8 final_block[1024];
// An actual random number would work just fine, and would save us
// the trouble of hashing the message twice. If we did that
// however, the user could fuck it up and reuse the nonce.
- HASH_INIT (&(ctx->hash));
- HASH_UPDATE(&(ctx->hash), prefix , 32);
+ HASH_INIT (&ctx->hash);
+ HASH_UPDATE(&ctx->hash, prefix , 32);
}
void crypto_sign_update(crypto_sign_ctx *ctx, const u8 *msg, size_t msg_size)
{
- HASH_UPDATE(&(ctx->hash), msg, msg_size);
+ HASH_UPDATE(&ctx->hash, msg, msg_size);
}
void crypto_sign_init_second_pass(crypto_sign_ctx *ctx)
{
u8 *r = ctx->buf + 32;
u8 *half_sig = ctx->buf + 64;
- HASH_FINAL(&(ctx->hash), r);
+ HASH_FINAL(&ctx->hash, r);
reduce(r);
// first half of the signature = "random" nonce times basepoint
u8 *r = ctx->buf + 32;
u8 *half_sig = ctx->buf + 64;
u8 h_ram[64];
- HASH_FINAL(&(ctx->hash), h_ram);
+ HASH_FINAL(&ctx->hash, h_ram);
reduce(h_ram); // reduce the hash modulo L
i64 s[64]; // s = r + h_ram * a
{
FOR (i, 0, 64) { ctx->sig[i] = signature [i]; }
FOR (i, 0, 32) { ctx->pk [i] = public_key[i]; }
- HASH_INIT (&(ctx->hash));
- HASH_UPDATE(&(ctx->hash), signature , 32);
- HASH_UPDATE(&(ctx->hash), public_key, 32);
+ HASH_INIT (&ctx->hash);
+ HASH_UPDATE(&ctx->hash, signature , 32);
+ HASH_UPDATE(&ctx->hash, public_key, 32);
}
void crypto_check_update(crypto_check_ctx *ctx, const u8 *msg, size_t msg_size)
{
- HASH_UPDATE(&(ctx->hash), msg , msg_size);
+ HASH_UPDATE(&ctx->hash, msg , msg_size);
}
int crypto_check_final(crypto_check_ctx *ctx)
if (ge_frombytes_neg(&A, ctx->pk)) { // -A
return -1;
}
- HASH_FINAL(&(ctx->hash), h_ram);
+ HASH_FINAL(&ctx->hash, h_ram);
reduce(h_ram);
ge_scalarmult(&p, &A, h_ram); // p = -A*h_ram
ge_scalarmult_base(&sB, ctx->sig + 32);
static const u8 zero[15] = {0};
if (ctx->ad_phase) {
ctx->ad_phase = 0;
- crypto_poly1305_update(&(ctx->poly), zero, -ctx->ad_size & 15);
+ crypto_poly1305_update(&ctx->poly, zero, -ctx->ad_size & 15);
}
}
ctx->ad_phase = 1;
ctx->ad_size = 0;
ctx->message_size = 0;
- crypto_chacha20_x_init(&(ctx->chacha), key, nonce);
- crypto_chacha20_stream(&(ctx->chacha), auth_key, 64);
- crypto_poly1305_init (&(ctx->poly ), auth_key);
+ crypto_chacha20_x_init(&ctx->chacha, key, nonce);
+ crypto_chacha20_stream(&ctx->chacha, auth_key, 64);
+ crypto_poly1305_init (&ctx->poly , auth_key);
WIPE_BUFFER(auth_key);
}
void crypto_lock_auth_ad(crypto_lock_ctx *ctx, const u8 *msg, size_t msg_size)
{
- crypto_poly1305_update(&(ctx->poly), msg, msg_size);
+ crypto_poly1305_update(&ctx->poly, msg, msg_size);
ctx->ad_size += msg_size;
}
{
lock_ad_padding(ctx);
ctx->message_size += text_size;
- crypto_poly1305_update(&(ctx->poly), cipher_text, text_size);
+ crypto_poly1305_update(&ctx->poly, cipher_text, text_size);
}
void crypto_lock_update(crypto_lock_ctx *ctx, u8 *cipher_text,
const u8 *plain_text, size_t text_size)
{
- crypto_chacha20_encrypt(&(ctx->chacha), cipher_text, plain_text, text_size);
+ crypto_chacha20_encrypt(&ctx->chacha, cipher_text, plain_text, text_size);
crypto_lock_auth_message(ctx, cipher_text, text_size);
}
u8 sizes[16];
store64_le(sizes + 0, ctx->ad_size);
store64_le(sizes + 8, ctx->message_size);
- crypto_poly1305_update(&(ctx->poly), zero, -ctx->message_size & 15);
- crypto_poly1305_update(&(ctx->poly), sizes, 16);
- crypto_poly1305_final (&(ctx->poly), mac);
+ crypto_poly1305_update(&ctx->poly, zero, -ctx->message_size & 15);
+ crypto_poly1305_update(&ctx->poly, sizes, 16);
+ crypto_poly1305_final (&ctx->poly, mac);
WIPE_CTX(ctx);
}
const u8 *cipher_text, size_t text_size)
{
crypto_unlock_auth_message(ctx, cipher_text, text_size);
- crypto_chacha20_encrypt(&(ctx->chacha), plain_text, cipher_text, text_size);
+ crypto_chacha20_encrypt(&ctx->chacha, plain_text, cipher_text, text_size);
}
int crypto_unlock_final(crypto_lock_ctx *ctx, const u8 mac[16])