Commit | Line | Data |
---|---|---|
aac19f0d MW |
1 | /* -*-c-*- |
2 | * | |
3 | * AEAD schemes based on Salsa20/ChaCha and Poly1305 | |
4 | * | |
5 | * (c) 2018 Straylight/Edgeware | |
6 | */ | |
7 | ||
8 | /*----- Licensing notice --------------------------------------------------* | |
9 | * | |
10 | * This file is part of Catacomb. | |
11 | * | |
12 | * Catacomb is free software: you can redistribute it and/or modify it | |
13 | * under the terms of the GNU Library General Public License as published | |
14 | * by the Free Software Foundation; either version 2 of the License, or | |
15 | * (at your option) any later version. | |
16 | * | |
17 | * Catacomb is distributed in the hope that it will be useful, but | |
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
20 | * Library General Public License for more details. | |
21 | * | |
22 | * You should have received a copy of the GNU Library General Public | |
23 | * License along with Catacomb. If not, write to the Free Software | |
24 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
25 | * USA. | |
26 | */ | |
27 | ||
28 | /*----- Notes on this construction ----------------------------------------* | |
29 | * | |
30 | * The AEAD class @chacha20_poly1305@ with a 96-bit nonce is exactly the | |
31 | * scheme specified in RFC7539. This implementation extends that | |
32 | * specification in two ways: | |
33 | * | |
34 | * * It permits ciphers other than ChaCha20: specifically ChaCha%$r$% and | |
35 | * Salsa20/%$r$% with %$r \in \{ 8, 12, 20 \}$%. | |
36 | * | |
37 | * * It allows nonces of 64, 96, and 192 bits. A 64-bit nonce matches | |
38 | * Bernstein's original specification of Salsa20 and ChaCha; the 96-bit | |
39 | * nonce matches RFC7539; and the 192-bit nonce matches Bernstein's | |
40 | * XSalsa20. The implementation uses XSalsa20 or XChaCha as appropriate | |
41 | * automatically based on the provided nonce length. | |
42 | * | |
43 | * These extensions do not significantly affect Procter's security analysis | |
44 | * except that an application should not mix nonce sizes with the same key. | |
45 | * (It is possible to do this safely, but it requires detailed understanding | |
46 | * of how everything fits together and isn't worth the effort.) | |
459d1a80 MW |
47 | * |
48 | * The @salsa20_naclbox@ with a 192-bit nonce is exactly the scheme | |
49 | * implemented in Bernstein's `NaCl' library as @crypto_secretbox@, except | |
50 | * that it's flexible regarding tag placement rather than insisting on | |
51 | * prefixing it to the ciphertext. Unlike NaCl, we provide a restartable | |
52 | * interface, and allow the use of other ciphers and nonce lengths. | |
aac19f0d MW |
53 | */ |
54 | ||
55 | #ifndef CATACOMB_LATINPOLY_H | |
56 | #define CATACOMB_LATINPOLY_H | |
57 | ||
58 | #ifdef __cplusplus | |
59 | extern "C" { | |
60 | #endif | |
61 | ||
62 | /*----- Header files ------------------------------------------------------*/ | |
63 | ||
64 | #ifndef CATACOMB_GAEAD_H | |
65 | # include "gaead.h" | |
66 | #endif | |
67 | ||
68 | /*----- Definitions -------------------------------------------------------*/ | |
69 | ||
70 | extern const gcaead | |
71 | chacha20_poly1305, chacha12_poly1305, chacha8_poly1305, | |
459d1a80 MW |
72 | chacha20_naclbox, chacha12_naclbox, chacha8_naclbox, |
73 | salsa20_poly1305, salsa2012_poly1305, salsa208_poly1305, | |
74 | salsa20_naclbox, salsa2012_naclbox, salsa208_naclbox; | |
aac19f0d MW |
75 | |
76 | /*----- That's all, folks -------------------------------------------------*/ | |
77 | ||
78 | #ifdef __cplusplus | |
79 | } | |
80 | #endif | |
81 | ||
82 | #endif |