bfee0bacb119c3fed4934b11513e91eb62c5e535
[catacomb] / symm / salsa20-poly1305.c
1 /* -*-c-*-
2 *
3 * AEAD schemes based on Salsa20 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 /*----- Header files ------------------------------------------------------*/
29
30 #include "latinpoly-def.h"
31 #include "salsa20.h"
32
33 /*----- Main code ---------------------------------------------------------*/
34
35 LATINPOLY_DEF(salsa20, salsa20, "salsa20")
36 LATINPOLY_DEF(salsa2012, salsa20, "salsa20/12")
37 LATINPOLY_DEF(salsa208, salsa20, "salsa20/8")
38
39 /*----- Test rig ----------------------------------------------------------*/
40
41 #ifdef TEST_RIG
42
43 #include <mLib/quis.h>
44 #include <mLib/testrig.h>
45 #include "latinpoly-test.h"
46
47 static int check_salsa20(dstr *v)
48 { return latinpoly_test(&salsa20_poly1305, v); }
49 static int check_salsa2012(dstr *v)
50 { return latinpoly_test(&salsa2012_poly1305, v); }
51 static int check_salsa208(dstr *v)
52 { return latinpoly_test(&salsa208_poly1305, v); }
53
54 static const test_chunk tests[] = {
55 { "salsa20-poly1305", check_salsa20,
56 { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } },
57 { "salsa20/12-poly1305", check_salsa2012,
58 { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } },
59 { "salsa20/8-poly1305", check_salsa208,
60 { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } },
61 { 0, 0, { 0 } }
62 #undef TEST
63 };
64
65 int main(int argc, char *argv[])
66 {
67 ego(argv[0]);
68 test_run(argc, argv, tests, SRCDIR"/t/salsa20");
69 return (0);
70 }
71
72 #endif
73 /*----- That's all, folks -------------------------------------------------*/