diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | chacha-core-internal.c | 2 | ||||
-rw-r--r-- | chacha-crypt.c | 90 | ||||
-rw-r--r-- | chacha-internal.h | 70 | ||||
-rw-r--r-- | chacha-poly1305.c | 2 | ||||
-rw-r--r-- | testsuite/chacha-test.c | 6 |
6 files changed, 77 insertions, 94 deletions
@@ -3,6 +3,7 @@ * aes-internal.h: Delete name mangling of internal symbols. Update all internal references to use _nettle prefix. * camellia-internal.h: Likewise. + * chacha-internal.h: Likewise. * ctr-internal.h: Likewise. * dsa-internal.h: Likewise. diff --git a/chacha-core-internal.c b/chacha-core-internal.c index 0905834e..23e68334 100644 --- a/chacha-core-internal.c +++ b/chacha-core-internal.c @@ -96,7 +96,7 @@ _nettle_chacha_core_c(uint32_t *dst, const uint32_t *src, unsigned rounds); } while(0) void -_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds) +_nettle_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds) { uint32_t x[_CHACHA_STATE_LENGTH]; unsigned i; diff --git a/chacha-crypt.c b/chacha-crypt.c index 0d6ecee1..58d0b0c2 100644 --- a/chacha-crypt.c +++ b/chacha-crypt.c @@ -55,28 +55,22 @@ #define CHACHA_ROUNDS 20 #if HAVE_NATIVE_chacha_3core -#undef _chacha_crypt_3core -#undef _chacha_crypt32_3core -#define _chacha_crypt_3core chacha_crypt -#define _chacha_crypt32_3core chacha_crypt32 +#define _nettle_chacha_crypt_3core chacha_crypt +#define _nettle_chacha_crypt32_3core chacha_crypt32 #elif HAVE_NATIVE_chacha_2core -#undef _chacha_crypt_2core -#undef _chacha_crypt32_2core -#define _chacha_crypt_2core chacha_crypt -#define _chacha_crypt32_2core chacha_crypt32 +#define _nettle_chacha_crypt_2core chacha_crypt +#define _nettle_chacha_crypt32_2core chacha_crypt32 #elif !(HAVE_NATIVE_fat_chacha_3core || HAVE_NATIVE_fat_chacha_2core) -#undef _chacha_crypt_1core -#undef _chacha_crypt32_1core -#define _chacha_crypt_1core chacha_crypt -#define _chacha_crypt32_1core chacha_crypt32 +#define _nettle_chacha_crypt_1core chacha_crypt +#define _nettle_chacha_crypt32_1core chacha_crypt32 #endif #if HAVE_NATIVE_chacha_3core || HAVE_NATIVE_fat_chacha_3core void -_chacha_crypt_3core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt_3core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { uint32_t x[3*_CHACHA_STATE_LENGTH]; @@ -85,7 +79,7 @@ _chacha_crypt_3core(struct chacha_ctx *ctx, while (length > 2*CHACHA_BLOCK_SIZE) { - _chacha_3core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_3core (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 3; ctx->state[13] += (ctx->state[12] < 3); if (length <= 3*CHACHA_BLOCK_SIZE) @@ -101,12 +95,12 @@ _chacha_crypt_3core(struct chacha_ctx *ctx, } if (length <= CHACHA_BLOCK_SIZE) { - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); ctx->state[13] += (++ctx->state[12] == 0); } else { - _chacha_3core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_3core (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 2; ctx->state[13] += (ctx->state[12] < 2); } @@ -116,10 +110,10 @@ _chacha_crypt_3core(struct chacha_ctx *ctx, #if HAVE_NATIVE_chacha_2core || HAVE_NATIVE_fat_chacha_2core void -_chacha_crypt_2core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt_2core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { uint32_t x[2*_CHACHA_STATE_LENGTH]; @@ -128,7 +122,7 @@ _chacha_crypt_2core(struct chacha_ctx *ctx, while (length > CHACHA_BLOCK_SIZE) { - _chacha_2core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_2core (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 2; ctx->state[13] += (ctx->state[12] < 2); if (length <= 2*CHACHA_BLOCK_SIZE) @@ -143,7 +137,7 @@ _chacha_crypt_2core(struct chacha_ctx *ctx, src += 2*CHACHA_BLOCK_SIZE; } - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); memxor3 (dst, src, x, length); ctx->state[13] += (++ctx->state[12] == 0); } @@ -151,10 +145,10 @@ _chacha_crypt_2core(struct chacha_ctx *ctx, #if !(HAVE_NATIVE_chacha_3core || HAVE_NATIVE_chacha_2core) void -_chacha_crypt_1core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt_1core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { if (!length) return; @@ -163,7 +157,7 @@ _chacha_crypt_1core(struct chacha_ctx *ctx, { uint32_t x[_CHACHA_STATE_LENGTH]; - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); ctx->state[13] += (++ctx->state[12] == 0); @@ -185,10 +179,10 @@ _chacha_crypt_1core(struct chacha_ctx *ctx, #if HAVE_NATIVE_chacha_3core || HAVE_NATIVE_fat_chacha_3core void -_chacha_crypt32_3core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt32_3core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { uint32_t x[3*_CHACHA_STATE_LENGTH]; @@ -197,7 +191,7 @@ _chacha_crypt32_3core(struct chacha_ctx *ctx, while (length > 2*CHACHA_BLOCK_SIZE) { - _chacha_3core32 (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_3core32 (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 3; ctx->state[13] += (ctx->state[12] < 3); if (length <= 3*CHACHA_BLOCK_SIZE) @@ -213,12 +207,12 @@ _chacha_crypt32_3core(struct chacha_ctx *ctx, } if (length <= CHACHA_BLOCK_SIZE) { - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); ctx->state[13] += (++ctx->state[12] == 0); } else { - _chacha_3core32 (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_3core32 (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 2; ctx->state[13] += (ctx->state[12] < 2); } @@ -228,10 +222,10 @@ _chacha_crypt32_3core(struct chacha_ctx *ctx, #if HAVE_NATIVE_chacha_2core || HAVE_NATIVE_fat_chacha_2core void -_chacha_crypt32_2core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt32_2core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { uint32_t x[2*_CHACHA_STATE_LENGTH]; @@ -240,7 +234,7 @@ _chacha_crypt32_2core(struct chacha_ctx *ctx, while (length > CHACHA_BLOCK_SIZE) { - _chacha_2core32 (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_2core32 (x, ctx->state, CHACHA_ROUNDS); ctx->state[12] += 2; if (length <= 2*CHACHA_BLOCK_SIZE) { @@ -254,7 +248,7 @@ _chacha_crypt32_2core(struct chacha_ctx *ctx, src += 2*CHACHA_BLOCK_SIZE; } - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); memxor3 (dst, src, x, length); ++ctx->state[12]; } @@ -262,10 +256,10 @@ _chacha_crypt32_2core(struct chacha_ctx *ctx, #if !(HAVE_NATIVE_chacha_3core || HAVE_NATIVE_chacha_2core) void -_chacha_crypt32_1core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src) +_nettle_chacha_crypt32_1core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src) { if (!length) return; @@ -274,7 +268,7 @@ _chacha_crypt32_1core(struct chacha_ctx *ctx, { uint32_t x[_CHACHA_STATE_LENGTH]; - _chacha_core (x, ctx->state, CHACHA_ROUNDS); + _nettle_chacha_core (x, ctx->state, CHACHA_ROUNDS); ++ctx->state[12]; diff --git a/chacha-internal.h b/chacha-internal.h index 0f790459..d92a6779 100644 --- a/chacha-internal.h +++ b/chacha-internal.h @@ -39,68 +39,56 @@ #include "nettle-types.h" #include "chacha.h" -#define _chacha_core _nettle_chacha_core -#define _chacha_2core _nettle_chacha_2core -#define _chacha_2core32 _nettle_chacha_2core32 -#define _chacha_3core _nettle_chacha_3core -#define _chacha_3core32 _nettle_chacha_3core32 -#define _chacha_crypt_1core _nettle_chacha_crypt_1core -#define _chacha_crypt_2core _nettle_chacha_crypt_2core -#define _chacha_crypt_3core _nettle_chacha_crypt_3core -#define _chacha_crypt32_1core _nettle_chacha_crypt32_1core -#define _chacha_crypt32_2core _nettle_chacha_crypt32_2core -#define _chacha_crypt32_3core _nettle_chacha_crypt32_3core - void -_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds); +_nettle_chacha_core(uint32_t *dst, const uint32_t *src, unsigned rounds); /* Functions available only in some configurations */ void -_chacha_2core(uint32_t *dst, const uint32_t *src, unsigned rounds); +_nettle_chacha_2core(uint32_t *dst, const uint32_t *src, unsigned rounds); void -_chacha_2core32(uint32_t *dst, const uint32_t *src, unsigned rounds); +_nettle_chacha_2core32(uint32_t *dst, const uint32_t *src, unsigned rounds); void -_chacha_3core(uint32_t *dst, const uint32_t *src, unsigned rounds); +_nettle_chacha_3core(uint32_t *dst, const uint32_t *src, unsigned rounds); void -_chacha_3core32(uint32_t *dst, const uint32_t *src, unsigned rounds); +_nettle_chacha_3core32(uint32_t *dst, const uint32_t *src, unsigned rounds); void -_chacha_crypt_1core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt_1core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); void -_chacha_crypt_2core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt_2core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); void -_chacha_crypt_3core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt_3core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); void -_chacha_crypt32_1core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt32_1core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); void -_chacha_crypt32_2core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt32_2core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); void -_chacha_crypt32_3core(struct chacha_ctx *ctx, - size_t length, - uint8_t *dst, - const uint8_t *src); +_nettle_chacha_crypt32_3core(struct chacha_ctx *ctx, + size_t length, + uint8_t *dst, + const uint8_t *src); #endif /* NETTLE_CHACHA_INTERNAL_H_INCLUDED */ diff --git a/chacha-poly1305.c b/chacha-poly1305.c index 47ca86bb..3eb37cd5 100644 --- a/chacha-poly1305.c +++ b/chacha-poly1305.c @@ -80,7 +80,7 @@ chacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx, chacha_set_nonce96 (&ctx->chacha, nonce); /* Generate authentication key */ - _chacha_core (u.x, ctx->chacha.state, CHACHA_ROUNDS); + _nettle_chacha_core (u.x, ctx->chacha.state, CHACHA_ROUNDS); _poly1305_set_key (&ctx->poly1305, u.subkey); /* For final poly1305 processing */ memcpy (ctx->s.b, u.subkey + 16, 16); diff --git a/testsuite/chacha-test.c b/testsuite/chacha-test.c index f51ff19f..5efe4ee2 100644 --- a/testsuite/chacha-test.c +++ b/testsuite/chacha-test.c @@ -193,8 +193,8 @@ _test_chacha(const struct tstring *key, const struct tstring *nonce, } else { - /* Uses the _chacha_core function to be able to test different - numbers of rounds. */ + /* Uses the _nettle_chacha_core function to be able to test + different numbers of rounds. */ uint32_t out[_CHACHA_STATE_LENGTH]; ASSERT (expected->length == CHACHA_BLOCK_SIZE); ASSERT (nonce->length == CHACHA_NONCE_SIZE); @@ -202,7 +202,7 @@ _test_chacha(const struct tstring *key, const struct tstring *nonce, chacha_set_nonce(&ctx, nonce->data); if (counter) chacha_set_counter(&ctx, counter->data); - _chacha_core (out, ctx.state, rounds); + _nettle_chacha_core (out, ctx.state, rounds); if (!MEMEQ(CHACHA_BLOCK_SIZE, out, expected->data)) { |