diff --git a/ChangeLog b/ChangeLog index f5b9b1aa654bbe394a4c9fd73a1594728694b5ac..25c161b52b35581ef96eb359cdc17bcc73b67d18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +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 diff --git a/Makefile.in b/Makefile.in index 61db7831127c2a315cf148eba6049818a644977c..5782a38fd7b71d44eb61b1a43d3f6361296b36e3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -88,7 +88,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \ 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 \ diff --git a/chacha-set-iv.c b/chacha-set-nonce.c similarity index 85% rename from chacha-set-iv.c rename to chacha-set-nonce.c index ab872bbea85599ee558b0f48ee7bc3b6734c5fed..78da9ff37df4bfa206d79cac1038de4c75d44f24 100644 --- a/chacha-set-iv.c +++ b/chacha-set-nonce.c @@ -1,6 +1,6 @@ -/* 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. */ @@ -44,10 +44,10 @@ #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); } diff --git a/chacha.h b/chacha.h index c8ec92b07c0cb11acf94cd3cda7f1d383ef9ee34..ae3934358f7ba7a25e1b8143ba1efb3f9e5bf796 100644 --- a/chacha.h +++ b/chacha.h @@ -39,7 +39,7 @@ extern "C" { #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 @@ -50,7 +50,7 @@ extern "C" { #define CHACHA_BLOCK_SIZE 64 -#define CHACHA_IV_SIZE 8 +#define CHACHA_NONCE_SIZE 8 #define _CHACHA_STATE_LENGTH 16 @@ -81,7 +81,7 @@ chacha_set_key(struct chacha_ctx *ctx, 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, diff --git a/nettle-internal.c b/nettle-internal.c index 6733a3f19e5749f06d1b148c263b3a4db7c4dfdd..92156982c8ca9809f11d5712c3e8ef72ce76a55e 100644 --- a/nettle-internal.c +++ b/nettle-internal.c @@ -77,9 +77,9 @@ nettle_blowfish128 = 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. */ diff --git a/testsuite/chacha-test.c b/testsuite/chacha-test.c index 0095333d045a81f87260289e65cc7f19355252f9..8f16a5a1fedab52c36fc76089431b8ad25567dbd 100644 --- a/testsuite/chacha-test.c +++ b/testsuite/chacha-test.c @@ -29,13 +29,13 @@ #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) { @@ -48,7 +48,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv, 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); @@ -76,7 +76,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv, 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))