diff options
author | Niels Möller <nisse@lysator.liu.se> | 2020-07-06 10:57:25 +0200 |
---|---|---|
committer | Niels Möller <nisse@lysator.liu.se> | 2020-07-06 23:14:59 +0200 |
commit | 2ac58a1ce729a6cfe1d3703f4deb6da8862909e9 (patch) | |
tree | 9bc6d4b0ed52835a75d7b6372e88ae0793a9c44a /salsa20-crypt.c | |
parent | 8e3e05b1eb48f8e6f49d1e88a6b7c78cb7307a00 (diff) | |
download | nettle-2ac58a1ce729a6cfe1d3703f4deb6da8862909e9.tar.gz |
Two-way interleaving of salsa20 on Neon
Diffstat (limited to 'salsa20-crypt.c')
-rw-r--r-- | salsa20-crypt.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/salsa20-crypt.c b/salsa20-crypt.c index 770b3b4c..b25cfc3d 100644 --- a/salsa20-crypt.c +++ b/salsa20-crypt.c @@ -57,7 +57,30 @@ salsa20_crypt(struct salsa20_ctx *ctx, { 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, 20); + 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, 20); + ctx->input[9] += (++ctx->input[8] == 0); + memxor3 (c, m, x, length); + return; +#else for (;;) { uint32_t x[_SALSA20_INPUT_LENGTH]; @@ -79,4 +102,5 @@ salsa20_crypt(struct salsa20_ctx *ctx, c += SALSA20_BLOCK_SIZE; m += SALSA20_BLOCK_SIZE; } +#endif } |