Commit 764a4813 authored by Niels Möller's avatar Niels Möller
Browse files

Renamed chacha_set_iv to chacha_set_nonce.

parent db9a1b61
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> 2014-02-08 Niels Möller <nisse@lysator.liu.se>
* testsuite/chacha-test.c (test_chacha): For 20 rounds, use * testsuite/chacha-test.c (test_chacha): For 20 rounds, use
......
...@@ -88,7 +88,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \ ...@@ -88,7 +88,7 @@ nettle_SOURCES = aes-decrypt-internal.c aes-decrypt.c \
camellia256-meta.c \ camellia256-meta.c \
cast128.c cast128-meta.c cbc.c \ cast128.c cast128-meta.c cbc.c \
chacha-crypt.c chacha-core-internal.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 \ chacha128-set-key.c chacha256-set-key.c \
ctr.c gcm.c \ ctr.c gcm.c \
des.c des3.c des-compat.c eax.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. * Based on the Salsa20 implementation in Nettle.
*/ */
...@@ -44,10 +44,10 @@ ...@@ -44,10 +44,10 @@
#include "macros.h" #include "macros.h"
void 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[12] = 0;
ctx->state[13] = 0; ctx->state[13] = 0;
ctx->state[14] = LE_READ_UINT32(iv + 0); ctx->state[14] = LE_READ_UINT32(nonce + 0);
ctx->state[15] = LE_READ_UINT32(iv + 4); ctx->state[15] = LE_READ_UINT32(nonce + 4);
} }
...@@ -39,7 +39,7 @@ extern "C" { ...@@ -39,7 +39,7 @@ extern "C" {
#define chacha_set_key nettle_chacha_set_key #define chacha_set_key nettle_chacha_set_key
#define chacha128_set_key nettle_chacha128_set_key #define chacha128_set_key nettle_chacha128_set_key
#define chacha256_set_key nettle_chacha256_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_crypt nettle_chacha_crypt
#define _chacha_core _nettle_chacha_core #define _chacha_core _nettle_chacha_core
...@@ -50,7 +50,7 @@ extern "C" { ...@@ -50,7 +50,7 @@ extern "C" {
#define CHACHA_BLOCK_SIZE 64 #define CHACHA_BLOCK_SIZE 64
#define CHACHA_IV_SIZE 8 #define CHACHA_NONCE_SIZE 8
#define _CHACHA_STATE_LENGTH 16 #define _CHACHA_STATE_LENGTH 16
...@@ -81,7 +81,7 @@ chacha_set_key(struct chacha_ctx *ctx, ...@@ -81,7 +81,7 @@ chacha_set_key(struct chacha_ctx *ctx,
size_t length, const uint8_t *key); size_t length, const uint8_t *key);
void void
chacha_set_iv(struct chacha_ctx *ctx, const uint8_t *iv); chacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce);
void void
chacha_crypt(struct chacha_ctx *ctx, size_t length, chacha_crypt(struct chacha_ctx *ctx, size_t length,
......
...@@ -77,9 +77,9 @@ nettle_blowfish128 = ...@@ -77,9 +77,9 @@ nettle_blowfish128 =
static void static void
chacha_set_key_hack(void *ctx, const uint8_t *key) 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); 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. */ /* Claim zero block size, to classify as a stream cipher. */
......
...@@ -29,13 +29,13 @@ ...@@ -29,13 +29,13 @@
#include "chacha.h" #include "chacha.h"
static void 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) const struct tstring *expected, unsigned rounds)
{ {
struct chacha_ctx ctx; struct chacha_ctx ctx;
chacha_set_key (&ctx, key->length, key->data); chacha_set_key (&ctx, key->length, key->data);
ASSERT (iv->length == CHACHA_IV_SIZE); ASSERT (nonce->length == CHACHA_NONCE_SIZE);
if (rounds == 20) if (rounds == 20)
{ {
...@@ -48,7 +48,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv, ...@@ -48,7 +48,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv,
data[-1] = 17; data[-1] = 17;
memset (data, 0, length); memset (data, 0, length);
data[length] = 17; data[length] = 17;
chacha_set_iv(&ctx, iv->data); chacha_set_nonce(&ctx, nonce->data);
chacha_crypt (&ctx, length, data, data); chacha_crypt (&ctx, length, data, data);
ASSERT (data[-1] == 17); ASSERT (data[-1] == 17);
...@@ -76,7 +76,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv, ...@@ -76,7 +76,7 @@ test_chacha(const struct tstring *key, const struct tstring *iv,
uint32_t out[_CHACHA_STATE_LENGTH]; uint32_t out[_CHACHA_STATE_LENGTH];
ASSERT (expected->length == CHACHA_BLOCK_SIZE); ASSERT (expected->length == CHACHA_BLOCK_SIZE);
chacha_set_iv(&ctx, iv->data); chacha_set_nonce(&ctx, nonce->data);
_chacha_core (out, ctx.state, rounds); _chacha_core (out, ctx.state, rounds);
if (!MEMEQ(CHACHA_BLOCK_SIZE, out, expected->data)) if (!MEMEQ(CHACHA_BLOCK_SIZE, out, expected->data))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment