Commit | Line | Data |
---|---|---|
aac19f0d MW |
1 | /* -*-c-*- |
2 | * | |
3 | * AEAD schemes based on 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 | /*----- Header files ------------------------------------------------------*/ | |
29 | ||
30 | #include "chacha.h" | |
31 | #include "latinpoly-def.h" | |
32 | ||
33 | /*----- Main code ---------------------------------------------------------*/ | |
34 | ||
35 | LATINPOLY_DEF(chacha20, chacha, "chacha20") | |
36 | LATINPOLY_DEF(chacha12, chacha, "chacha12") | |
37 | LATINPOLY_DEF(chacha8, chacha, "chacha8") | |
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 | ||
0cf9e22f | 47 | static int check_chacha20_poly1305(dstr *v) |
aac19f0d | 48 | { return latinpoly_test(&chacha20_poly1305, v); } |
0cf9e22f | 49 | static int check_chacha12_poly1305(dstr *v) |
aac19f0d | 50 | { return latinpoly_test(&chacha12_poly1305, v); } |
0cf9e22f | 51 | static int check_chacha8_poly1305(dstr *v) |
aac19f0d | 52 | { return latinpoly_test(&chacha8_poly1305, v); } |
459d1a80 MW |
53 | static int check_chacha20_naclbox(dstr *v) |
54 | { return latinpoly_test(&chacha20_naclbox, v); } | |
55 | static int check_chacha12_naclbox(dstr *v) | |
56 | { return latinpoly_test(&chacha12_naclbox, v); } | |
57 | static int check_chacha8_naclbox(dstr *v) | |
58 | { return latinpoly_test(&chacha8_naclbox, v); } | |
aac19f0d MW |
59 | |
60 | static const test_chunk tests[] = { | |
0cf9e22f | 61 | { "chacha20-poly1305", check_chacha20_poly1305, |
aac19f0d | 62 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, |
0cf9e22f | 63 | { "chacha12-poly1305", check_chacha12_poly1305, |
aac19f0d | 64 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, |
0cf9e22f | 65 | { "chacha8-poly1305", check_chacha8_poly1305, |
aac19f0d | 66 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, |
459d1a80 MW |
67 | { "chacha20-naclbox", check_chacha20_naclbox, |
68 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, | |
69 | { "chacha12-naclbox", check_chacha12_naclbox, | |
70 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, | |
71 | { "chacha8-naclbox", check_chacha8_naclbox, | |
72 | { &type_hex, &type_hex, &type_hex, &type_hex, &type_hex, &type_hex } }, | |
aac19f0d MW |
73 | { 0, 0, { 0 } } |
74 | #undef TEST | |
75 | }; | |
76 | ||
77 | int main(int argc, char *argv[]) | |
78 | { | |
79 | ego(argv[0]); | |
80 | test_run(argc, argv, tests, SRCDIR"/t/chacha"); | |
81 | return (0); | |
82 | } | |
83 | ||
84 | #endif | |
85 | ||
86 | /*----- That's all, folks -------------------------------------------------*/ |