3 * The Salsa20 stream cipher.
6 /* nettle, low-level cryptographics library
8 * Copyright (C) 2012 Simon Josefsson
9 * Copyright (C) 2001 Niels Möller
11 * The nettle library is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation; either version 2.1 of the License, or (at your
14 * option) any later version.
16 * The nettle library is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
18 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
19 * License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with the nettle library; see the file COPYING.LIB. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
27 #ifndef NETTLE_SALSA20_H_INCLUDED
28 #define NETTLE_SALSA20_H_INCLUDED
30 #include "nettle-types.h"
37 #define salsa20_set_key nettle_salsa20_set_key
38 #define salsa20_set_iv nettle_salsa20_set_iv
39 #define salsa20_crypt nettle_salsa20_crypt
40 #define _salsa20_core _nettle_salsa20_core
42 #define salsa20r12_crypt nettle_salsa20r12_crypt
44 /* Minimum and maximum keysizes, and a reasonable default. In
46 #define SALSA20_MIN_KEY_SIZE 16
47 #define SALSA20_MAX_KEY_SIZE 32
48 #define SALSA20_KEY_SIZE 32
49 #define SALSA20_BLOCK_SIZE 64
51 #define SALSA20_IV_SIZE 8
53 #define _SALSA20_INPUT_LENGTH 16
57 /* Indices 1-4 and 11-14 holds the key (two identical copies for the
58 shorter key size), indices 0, 5, 10, 15 are constant, indices 6, 7
59 are the IV, and indices 8, 9 are the block counter:
66 uint32_t input
[_SALSA20_INPUT_LENGTH
];
70 salsa20_set_key(struct salsa20_ctx
*ctx
,
71 unsigned length
, const uint8_t *key
);
74 salsa20_set_iv(struct salsa20_ctx
*ctx
, const uint8_t *iv
);
77 salsa20_crypt(struct salsa20_ctx
*ctx
,
78 unsigned length
, uint8_t *dst
,
82 salsa20r12_crypt(struct salsa20_ctx
*ctx
,
83 unsigned length
, uint8_t *dst
,
87 _salsa20_core(uint32_t *dst
, const uint32_t *src
, unsigned rounds
);
93 #endif /* NETTLE_SALSA20_H_INCLUDED */