chiark / gitweb /
site: Make return value of transforms be an enum
[secnet.git] / magic.h
1 /* Magic numbers used within secnet */
2 /*
3  * This file is part of secnet.
4  * See README for full list of copyright holders.
5  *
6  * secnet is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  * 
11  * secnet is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  * General Public License for more details.
15  * 
16  * You should have received a copy of the GNU General Public License
17  * version 3 along with secnet; if not, see
18  * https://www.gnu.org/licenses/gpl.html.
19  */
20
21 #ifndef magic_h
22 #define magic_h
23
24 #define LABEL_NAK     0x00000000
25 #define LABEL_MSG0    0x00020200
26 #define LABEL_MSG1    0x01010101
27 #define LABEL_MSG2    0x02020202
28 #define LABEL_MSG3    0x03030303
29 #define LABEL_MSG3BIS 0x13030313
30 #define LABEL_MSG4    0x04040404
31 #define LABEL_MSG5    0x05050505
32 #define LABEL_MSG6    0x06060606
33 #define LABEL_MSG7    0x07070707
34 #define LABEL_MSG8    0x08080808
35 #define LABEL_MSG9    0x09090909
36 #define LABEL_PROD    0x0a0a0a0a
37
38 /* uses of the 32-bit capability bitmap */
39 #define CAPAB_EARLY           CAPAB_PRIORITY_MOBILE
40 #define CAPAB_TRANSFORM_MASK  0x0000ffff
41 #define CAPAB_PRIORITY_MOBILE 0x80000000 /* mobile site has MSG1 priority */
42 /* remaining bits are unused */
43
44 /*
45  * The transform capability mask is a set of bits, one for each
46  * transform supported.  The transform capability numbers are set in
47  * the configuration (and should correspond between the two sites),
48  * although there are sensible defaults.
49  *
50  * Advertising a nonzero transform capability mask promises that
51  * the receiver understands LABEL_MSG3BIS messages, which
52  * contain an additional byte specifying the transform capability
53  * number actually chosen by the MSG3 sender.
54  *
55  * Aside from that, an empty bitmask is treated the same as
56  *  1u<<CAPAB_TRANSFORMNUM_ANCIENT
57  */
58
59 /* bit indices, 0 is ls bit */
60 #define CAPAB_TRANSFORMNUM_USER_MIN              0
61 #define CAPAB_TRANSFORMNUM_USER_MAX              7
62 #define CAPAB_TRANSFORMNUM_SERPENT256CBC         8
63 #define CAPAB_TRANSFORMNUM_EAXSERPENT            9
64 #define CAPAB_TRANSFORMNUM_MAX                  15
65
66 #define CAPAB_TRANSFORMNUM_ANCIENT CAPAB_TRANSFORMNUM_SERPENT256CBC
67
68 #endif /* magic_h */