#undef _chacha_crypt32_3core
#define _chacha_crypt_3core chacha_crypt
#define _chacha_crypt32_3core chacha_crypt32
+#elif HAVE_NATIVE_chacha_2core
+#define _chacha_crypt_2core chacha_crypt
+#define _chacha_crypt32_2core chacha_crypt32
#elif !HAVE_NATIVE_fat_chacha_3core
#undef _chacha_crypt_1core
#undef _chacha_crypt32_1core
}
#endif
-#if !HAVE_NATIVE_chacha_3core
+#if HAVE_NATIVE_chacha_2core
+void
+_chacha_crypt_2core(struct chacha_ctx *ctx,
+ size_t length,
+ uint8_t *dst,
+ const uint8_t *src)
+{
+ uint32_t x[2*_CHACHA_STATE_LENGTH];
+
+ if (!length)
+ return;
+
+ while (length > CHACHA_BLOCK_SIZE)
+ {
+ _chacha_2core (x, ctx->state, CHACHA_ROUNDS);
+ ctx->state[12] += 2;
+ ctx->state[13] += (ctx->state[12] < 2);
+ if (length <= 2*CHACHA_BLOCK_SIZE)
+ {
+ memxor3 (dst, src, x, length);
+ return;
+ }
+ memxor3 (dst, src, x, 2*CHACHA_BLOCK_SIZE);
+
+ length -= 2*CHACHA_BLOCK_SIZE;
+ dst += 2*CHACHA_BLOCK_SIZE;
+ src += 2*CHACHA_BLOCK_SIZE;
+ }
+
+ _chacha_core (x, ctx->state, CHACHA_ROUNDS);
+ memxor3 (dst, src, x, length);
+ ctx->state[13] += (++ctx->state[12] == 0);
+}
+#endif
+
+#if !(HAVE_NATIVE_chacha_3core || HAVE_NATIVE_chacha_2core)
void
_chacha_crypt_1core(struct chacha_ctx *ctx,
size_t length,
}
#endif
+#if HAVE_NATIVE_chacha_2core
+void
+_chacha_crypt32_2core(struct chacha_ctx *ctx,
+ size_t length,
+ uint8_t *dst,
+ const uint8_t *src)
+{
+ uint32_t x[2*_CHACHA_STATE_LENGTH];
+
+ if (!length)
+ return;
+
+ while (length > CHACHA_BLOCK_SIZE)
+ {
+ _chacha_2core32 (x, ctx->state, CHACHA_ROUNDS);
+ ctx->state[12] += 2;
+ if (length <= 2*CHACHA_BLOCK_SIZE)
+ {
+ memxor3 (dst, src, x, length);
+ return;
+ }
+ memxor3 (dst, src, x, 2*CHACHA_BLOCK_SIZE);
+
+ length -= 2*CHACHA_BLOCK_SIZE;
+ dst += 2*CHACHA_BLOCK_SIZE;
+ src += 2*CHACHA_BLOCK_SIZE;
+ }
+
+ _chacha_core (x, ctx->state, CHACHA_ROUNDS);
+ memxor3 (dst, src, x, length);
+ ++ctx->state[12];
+}
+#endif
+
#if !HAVE_NATIVE_chacha_3core
void
_chacha_crypt32_1core(struct chacha_ctx *ctx,
#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
_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);
+
+void
+_chacha_2core32(uint32_t *dst, const uint32_t *src, unsigned rounds);
+
void
_chacha_3core(uint32_t *dst, const uint32_t *src, unsigned rounds);
# Assembler files which generate additional object files if they are used.
asm_nettle_optional_list="gcm-hash8.asm cpuid.asm \
aes-encrypt-internal-2.asm aes-decrypt-internal-2.asm memxor-2.asm \
- chacha-3core.asm chacha-core-internal-2.asm salsa20-2core.asm \
+ chacha-2core.asm chacha-3core.asm chacha-core-internal-2.asm salsa20-2core.asm \
salsa20-core-internal-2.asm sha1-compress-2.asm sha256-compress-2.asm \
sha3-permute-2.asm sha512-compress-2.asm \
umac-nh-n-2.asm umac-nh-2.asm"
#undef HAVE_NATIVE_aes_decrypt
#undef HAVE_NATIVE_aes_encrypt
#undef HAVE_NATIVE_chacha_core
+#undef HAVE_NATIVE_chacha_2core
#undef HAVE_NATIVE_chacha_3core
#undef HAVE_NATIVE_fat_chacha_3core
#undef HAVE_NATIVE_ecc_curve25519_modp