From db690e0b61121dd415ac9254183e161676c2c23e Mon Sep 17 00:00:00 2001 From: Loup Vaillant Date: Sun, 16 Jul 2017 14:56:47 +0200 Subject: [PATCH] renamed chacha20_Xinit into chacha20_x_init --- MANUAL.md | 8 ++++---- src/monocypher.c | 10 +++++----- src/monocypher.h | 6 +++--- tests/sodium.c | 2 +- tests/vectors.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/MANUAL.md b/MANUAL.md index 9b8bb87..9acf34f 100644 --- a/MANUAL.md +++ b/MANUAL.md @@ -575,11 +575,11 @@ all an initial nonce of 0, 1 .. n-1 respectively, and have them increment their nonce by n. (Also make sure the counters never wrap around.) -### void crypto\_chacha20\_Xinit() +### void crypto\_chacha20\_x_init() - void crypto_chacha20_Xinit(crypto_chacha_ctx *ctx, - const uint8_t key[32], - const uint8_t nonce[24]); + void crypto_chacha20_x_init(crypto_chacha_ctx *ctx, + const uint8_t key[32], + const uint8_t nonce[24]); Initialises a chacha context with a big nonce (192 bits). This nonce is big enough to be selected at random (use the OS; avoid user space diff --git a/src/monocypher.c b/src/monocypher.c index 602ef5d..1c9da4a 100644 --- a/src/monocypher.c +++ b/src/monocypher.c @@ -161,9 +161,9 @@ void crypto_chacha20_init(crypto_chacha_ctx *ctx, ctx->input[15] = load32_le(nonce + 4); // nonce } -void crypto_chacha20_Xinit(crypto_chacha_ctx *ctx, - const u8 key[32], - const u8 nonce[24]) +void crypto_chacha20_x_init(crypto_chacha_ctx *ctx, + const u8 key[32], + const u8 nonce[24]) { u8 derived_key[32]; crypto_chacha20_H(derived_key, key, nonce); @@ -1420,7 +1420,7 @@ void crypto_aead_lock(u8 mac[16], { // encrypt then mac u8 auth_key[32]; crypto_chacha_ctx e_ctx; - crypto_chacha20_Xinit (&e_ctx, key, nonce); + crypto_chacha20_x_init (&e_ctx, key, nonce); crypto_chacha20_stream (&e_ctx, auth_key, 32); crypto_chacha20_encrypt(&e_ctx, ciphertext, plaintext, text_size); authenticate2(mac, auth_key, ad, ad_size, ciphertext, text_size); @@ -1435,7 +1435,7 @@ int crypto_aead_unlock(u8 *plaintext, { u8 auth_key[32], real_mac[16]; crypto_chacha_ctx e_ctx; - crypto_chacha20_Xinit (&e_ctx, key, nonce); + crypto_chacha20_x_init(&e_ctx, key, nonce); crypto_chacha20_stream(&e_ctx, auth_key, 32); authenticate2(real_mac, auth_key, ad, ad_size, ciphertext, text_size); if (crypto_memcmp(real_mac, mac, 16)) { return -1; } // reject forgeries diff --git a/src/monocypher.h b/src/monocypher.h index 3aeb40e..1aa513c 100644 --- a/src/monocypher.h +++ b/src/monocypher.h @@ -29,9 +29,9 @@ void crypto_chacha20_init(crypto_chacha_ctx *ctx, const uint8_t key[32], const uint8_t nonce[8]); -void crypto_chacha20_Xinit(crypto_chacha_ctx *ctx, - const uint8_t key[32], - const uint8_t nonce[24]); +void crypto_chacha20_x_init(crypto_chacha_ctx *ctx, + const uint8_t key[32], + const uint8_t nonce[24]); void crypto_chacha20_encrypt(crypto_chacha_ctx *ctx, uint8_t *cipher_text, diff --git a/tests/sodium.c b/tests/sodium.c index f8d0e96..d2819fa 100644 --- a/tests/sodium.c +++ b/tests/sodium.c @@ -50,7 +50,7 @@ static int xchacha20(void) p_random(nonce, 24); p_random(in, size); rename_chacha_ctx ctx; - rename_chacha20_Xinit(&ctx, key, nonce); + rename_chacha20_x_init(&ctx, key, nonce); rename_chacha20_encrypt(&ctx, mono, in, size); crypto_stream_xchacha20_xor(sodium, in, size, nonce, key); status |= rename_memcmp(mono, sodium, size); diff --git a/tests/vectors.c b/tests/vectors.c index 33f563a..fbd1925 100644 --- a/tests/vectors.c +++ b/tests/vectors.c @@ -108,7 +108,7 @@ sv x_chacha20(const vector in[], vector *out) const vector *key = in; const vector *nonce = in + 1; crypto_chacha_ctx ctx; - crypto_chacha20_Xinit (&ctx, key->buf, nonce->buf); + crypto_chacha20_x_init(&ctx, key->buf, nonce->buf); crypto_chacha20_stream(&ctx, out->buf, out->size); } -- 2.47.3