chiark / gitweb /
2efcd0027111aa7e6620e25932cc140f360fae91
[catacomb] / symm / latinpoly.h
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.)
47  */
48
49 #ifndef CATACOMB_LATINPOLY_H
50 #define CATACOMB_LATINPOLY_H
51
52 #ifdef __cplusplus
53   extern "C" {
54 #endif
55
56 /*----- Header files ------------------------------------------------------*/
57
58 #ifndef CATACOMB_GAEAD_H
59 #  include "gaead.h"
60 #endif
61
62 /*----- Definitions -------------------------------------------------------*/
63
64 extern const gcaead
65   chacha20_poly1305, chacha12_poly1305, chacha8_poly1305,
66   salsa20_poly1305, salsa2012_poly1305, salsa208_poly1305;
67
68 /*----- That's all, folks -------------------------------------------------*/
69
70 #ifdef __cplusplus
71   }
72 #endif
73
74 #endif