summaryrefslogtreecommitdiff
path: root/salsa20r12-crypt.c
diff options
context:
space:
mode:
authorNiels Möller <nisse@lysator.liu.se>2020-07-06 10:57:25 +0200
committerNiels Möller <nisse@lysator.liu.se>2020-07-06 23:14:59 +0200
commit2ac58a1ce729a6cfe1d3703f4deb6da8862909e9 (patch)
tree9bc6d4b0ed52835a75d7b6372e88ae0793a9c44a /salsa20r12-crypt.c
parent8e3e05b1eb48f8e6f49d1e88a6b7c78cb7307a00 (diff)
downloadnettle-2ac58a1ce729a6cfe1d3703f4deb6da8862909e9.tar.gz
Two-way interleaving of salsa20 on Neon
Diffstat (limited to 'salsa20r12-crypt.c')
-rw-r--r--salsa20r12-crypt.c27
1 files changed, 25 insertions, 2 deletions
diff --git a/salsa20r12-crypt.c b/salsa20r12-crypt.c
index 20aecfc0..41e32d8b 100644
--- a/salsa20r12-crypt.c
+++ b/salsa20r12-crypt.c
@@ -55,13 +55,35 @@ salsa20r12_crypt(struct salsa20_ctx *ctx,
uint8_t *c,
const uint8_t *m)
{
- uint32_t x[_SALSA20_INPUT_LENGTH];
-
if (!length)
return;
+#if HAVE_NATIVE_salsa20_2core
+ uint32_t x[2*_SALSA20_INPUT_LENGTH];
+ while (length > SALSA20_BLOCK_SIZE)
+ {
+ _salsa20_2core (x, ctx->input, 12);
+ ctx->input[8] += 2;
+ ctx->input[9] += (ctx->input[8] < 2);
+ if (length < 2 * SALSA20_BLOCK_SIZE)
+ {
+ memxor3 (c, m, x, length);
+ return;
+ }
+ memxor3 (c, m, x, 2*SALSA20_BLOCK_SIZE);
+
+ length -= 2*SALSA20_BLOCK_SIZE;
+ c += 2*SALSA20_BLOCK_SIZE;
+ m += 2*SALSA20_BLOCK_SIZE;
+ }
+ _salsa20_core (x, ctx->input, 12);
+ ctx->input[9] += (++ctx->input[8] == 0);
+ memxor3 (c, m, x, length);
+ return;
+#else
for (;;)
{
+ uint32_t x[_SALSA20_INPUT_LENGTH];
_salsa20_core (x, ctx->input, 12);
@@ -80,4 +102,5 @@ salsa20r12_crypt(struct salsa20_ctx *ctx,
c += SALSA20_BLOCK_SIZE;
m += SALSA20_BLOCK_SIZE;
}
+#endif
}