3 The Salsa20 stream cipher, reduced round variant.
5 Copyright (C) 2013 Nikos Mavrogiannopoulos
7 This file is part of GNU Nettle.
9 GNU Nettle is free software: you can redistribute it and/or
10 modify it under the terms of either:
12 * the GNU Lesser General Public License as published by the Free
13 Software Foundation; either version 3 of the License, or (at your
14 option) any later version.
18 * the GNU General Public License as published by the Free
19 Software Foundation; either version 2 of the License, or (at your
20 option) any later version.
22 or both in parallel, as here.
24 GNU Nettle is distributed in the hope that it will be useful,
25 but WITHOUT ANY WARRANTY; without even the implied warranty of
26 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
27 General Public License for more details.
29 You should have received copies of the GNU General Public License and
30 the GNU Lesser General Public License along with this program. If
31 not, see http://www.gnu.org/licenses/.
35 salsa20-ref.c version 20051118
47 #include "salsa20-internal.h"
53 salsa20r12_crypt(struct salsa20_ctx *ctx,
58 uint32_t x[_SALSA20_INPUT_LENGTH];
66 _salsa20_core (x, ctx->input, 12);
68 ctx->input[9] += (++ctx->input[8] == 0);
70 /* stopping at 2^70 length per nonce is user's responsibility */
72 if (length <= SALSA20_BLOCK_SIZE)
74 memxor3 (c, m, x, length);
77 memxor3 (c, m, x, SALSA20_BLOCK_SIZE);
79 length -= SALSA20_BLOCK_SIZE;
80 c += SALSA20_BLOCK_SIZE;
81 m += SALSA20_BLOCK_SIZE;