+2014-02-10 Niels Möller <nisse@lysator.liu.se>
+
+ * chacha-set-nonce.c (chacha_set_nonce): Renamed file and
+ function, updated callers and Makefile.in.
+ * chacha-set-iv.c (chacha_set_iv): ... from old names.
+
2014-02-08 Niels Möller <nisse@lysator.liu.se>
* testsuite/chacha-test.c (test_chacha): For 20 rounds, use
camellia256-meta.c \
cast128.c cast128-meta.c cbc.c \
chacha-crypt.c chacha-core-internal.c \
- chacha-set-iv.c chacha-set-key.c \
+ chacha-set-key.c chacha-set-nonce.c \
chacha128-set-key.c chacha256-set-key.c \
ctr.c gcm.c \
des.c des3.c des-compat.c eax.c \
-/* chacha-set-iv.c
+/* chacha-set-nonce.c
*
- * Setting the IV the ChaCha stream cipher.
+ * Setting the nonce the ChaCha stream cipher.
* Based on the Salsa20 implementation in Nettle.
*/
#include "macros.h"
void
-chacha_set_iv(struct chacha_ctx *ctx, const uint8_t *iv)
+chacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce)
{
ctx->state[12] = 0;
ctx->state[13] = 0;
- ctx->state[14] = LE_READ_UINT32(iv + 0);
- ctx->state[15] = LE_READ_UINT32(iv + 4);
+ ctx->state[14] = LE_READ_UINT32(nonce + 0);
+ ctx->state[15] = LE_READ_UINT32(nonce + 4);
}
#define chacha_set_key nettle_chacha_set_key
#define chacha128_set_key nettle_chacha128_set_key
#define chacha256_set_key nettle_chacha256_set_key
-#define chacha_set_iv nettle_chacha_set_iv
+#define chacha_set_nonce nettle_chacha_set_nonce
#define chacha_crypt nettle_chacha_crypt
#define _chacha_core _nettle_chacha_core
#define CHACHA_BLOCK_SIZE 64
-#define CHACHA_IV_SIZE 8
+#define CHACHA_NONCE_SIZE 8
#define _CHACHA_STATE_LENGTH 16
size_t length, const uint8_t *key);
void
-chacha_set_iv(struct chacha_ctx *ctx, const uint8_t *iv);
+chacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce);
void
chacha_crypt(struct chacha_ctx *ctx, size_t length,
static void
chacha_set_key_hack(void *ctx, const uint8_t *key)
{
- static const uint8_t iv[CHACHA_IV_SIZE];
+ static const uint8_t nonce[CHACHA_NONCE_SIZE];
chacha256_set_key (ctx, key);
- chacha_set_iv (ctx, iv);
+ chacha_set_nonce (ctx, nonce);
}
/* Claim zero block size, to classify as a stream cipher. */
#include "chacha.h"
static void
-test_chacha(const struct tstring *key, const struct tstring *iv,
+test_chacha(const struct tstring *key, const struct tstring *nonce,
const struct tstring *expected, unsigned rounds)
{
struct chacha_ctx ctx;
chacha_set_key (&ctx, key->length, key->data);
- ASSERT (iv->length == CHACHA_IV_SIZE);
+ ASSERT (nonce->length == CHACHA_NONCE_SIZE);
if (rounds == 20)
{
data[-1] = 17;
memset (data, 0, length);
data[length] = 17;
- chacha_set_iv(&ctx, iv->data);
+ chacha_set_nonce(&ctx, nonce->data);
chacha_crypt (&ctx, length, data, data);
ASSERT (data[-1] == 17);
uint32_t out[_CHACHA_STATE_LENGTH];
ASSERT (expected->length == CHACHA_BLOCK_SIZE);
- chacha_set_iv(&ctx, iv->data);
+ chacha_set_nonce(&ctx, nonce->data);
_chacha_core (out, ctx.state, rounds);
if (!MEMEQ(CHACHA_BLOCK_SIZE, out, expected->data))