added ModeCfg push policy and states
[strongswan.git] / src / pluto / constants.h
1 /* manifest constants
2 * Copyright (C) 1997 Angelos D. Keromytis.
3 * Copyright (C) 1998-2002 D. Hugh Redelmeier.
4 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * for more details.
14 *
15 * RCSID $Id: constants.h,v 1.20 2006/02/28 19:13:33 as Exp $
16 */
17
18 #ifndef _CONSTANTS_H
19 #define _CONSTANTS_H
20
21 extern const char compile_time_interop_options[];
22
23 extern void init_constants(void);
24
25 /*
26 * NOTE:For debugging purposes, constants.c has tables to map numbers back to names.
27 * Any changes here should be reflected there.
28 */
29
30 #define elemsof(array) (sizeof(array) / sizeof(*(array))) /* number of elements in an array */
31
32 /* Many routines return only success or failure, but wish to describe
33 * the failure in a message. We use the convention that they return
34 * a NULL on success and a pointer to constant string on failure.
35 * The fact that the string is a constant is limiting, but it
36 * avoids storage management issues: the recipient is allowed to assume
37 * that the string will live "long enough" (usually forever).
38 * <freeswan.h> defines err_t for this return type.
39 */
40
41 typedef int bool;
42 #define FALSE 0
43 #define TRUE 1
44
45 #define NULL_FD (-1) /* NULL file descriptor */
46 #define dup_any(fd) ((fd) == NULL_FD? NULL_FD : dup(fd))
47 #define close_any(fd) { if ((fd) != NULL_FD) { close(fd); (fd) = NULL_FD; } }
48
49 #define BITS_PER_BYTE 8
50
51 #define streq(a, b) (strcmp((a), (b)) == 0) /* clearer shorthand */
52 #define strcaseeq(a, b) (strcasecmp((a), (b)) == 0) /* clearer shorthand */
53
54 /* set type with room for at least 64 elements for ALG opts (was 32 in stock FS) */
55
56 typedef unsigned long long lset_t;
57 #define LEMPTY 0ULL
58 #define LELEM(opt) (1ULL << (opt))
59 #define LRANGE(lwb, upb) LRANGES(LELEM(lwb), LELEM(upb))
60 #define LRANGES(first, last) (last - first + last)
61 #define LHAS(set, elem) ((LELEM(elem) & (set)) != LEMPTY)
62 #define LIN(subset, set) (((subset) & (set)) == (subset))
63 #define LDISJOINT(a, b) (((a) & (b)) == LEMPTY)
64
65 /* Control and lock pathnames */
66 #ifndef IPSEC_PIDDIR
67 # define IPSEC_PIDDIR "/var/run"
68 #endif
69 #ifndef DEFAULT_CTLBASE
70 # define DEFAULT_CTLBASE IPSEC_PIDDIR "/pluto"
71 #endif
72
73 #define CTL_SUFFIX ".ctl" /* for UNIX domain socket pathname */
74 #define LOCK_SUFFIX ".pid" /* for pluto's lock */
75 #define INFO_SUFFIX ".info" /* for UNIX domain socket for apps */
76
77 /* Routines to check and display values.
78 *
79 * An enum_names describes an enumeration.
80 * enum_name() returns the name of an enum value, or NULL if invalid.
81 * enum_show() is like enum_name, except it formats a numeric representation
82 * for any invalid value (in a static area!)
83 *
84 * bitnames() formats a display of a set of named bits (in a static area)
85 */
86
87 struct enum_names {
88 unsigned long en_first; /* first value in range */
89 unsigned long en_last; /* last value in range (inclusive) */
90 const char *const *en_names;
91 const struct enum_names *en_next_range; /* descriptor of next range */
92 };
93
94 typedef const struct enum_names enum_names;
95
96 extern const char *enum_name(enum_names *ed, unsigned long val);
97 extern const char *enum_show(enum_names *ed, unsigned long val);
98 extern int enum_search(enum_names *ed, const char *string);
99
100 extern bool testset(const char *const table[], lset_t val);
101 extern const char *bitnamesof(const char *const table[], lset_t val);
102
103 /* sparse_names is much like enum_names, except values are
104 * not known to be contiguous or ordered.
105 * The array of names is ended with one with the name sparse_end
106 * (this avoids having to reserve a value to signify the end).
107 * Often appropriate for enums defined by others.
108 */
109 struct sparse_name {
110 unsigned long val;
111 const char *const name;
112 };
113 typedef const struct sparse_name sparse_names[];
114
115 extern const char *sparse_name(sparse_names sd, unsigned long val);
116 extern const char *sparse_val_show(sparse_names sd, unsigned long val);
117 extern const char sparse_end[];
118
119 #define FULL_INET_ADDRESS_SIZE 6
120
121 /* Group parameters from draft-ietf-ike-01.txt section 6 */
122
123 #define MODP_GENERATOR "2"
124
125 #define MODP768_MODULUS \
126 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
127 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
128 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
129 "E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
130
131 #define MODP1024_MODULUS \
132 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
133 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
134 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
135 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED " \
136 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 " \
137 "FFFFFFFF FFFFFFFF"
138
139 #define MODP1536_MODULUS \
140 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
141 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
142 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
143 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED " \
144 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D " \
145 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F " \
146 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D " \
147 "670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF "
148
149 /* draft-ietf-ipsec-ike-modp-groups-03.txt */
150 #define MODP2048_MODULUS \
151 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
152 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
153 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
154 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
155 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
156 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
157 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
158 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
159 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
160 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
161 "15728E5A 8AACAA68 FFFFFFFF FFFFFFFF"
162
163 #define MODP3072_MODULUS \
164 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
165 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
166 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
167 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
168 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
169 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
170 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
171 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
172 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
173 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
174 "15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" \
175 "ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" \
176 "ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" \
177 "F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" \
178 "BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" \
179 "43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF"
180
181 #define MODP4096_MODULUS \
182 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
183 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
184 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
185 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
186 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
187 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
188 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
189 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
190 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
191 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
192 "15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" \
193 "ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" \
194 "ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" \
195 "F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" \
196 "BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" \
197 "43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" \
198 "88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" \
199 "2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" \
200 "287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" \
201 "1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" \
202 "93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199" \
203 "FFFFFFFF FFFFFFFF"
204
205 /* copy&pasted from rfc3526: */
206 #define MODP6144_MODULUS \
207 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 29024E08" \
208 "8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD EF9519B3 CD3A431B" \
209 "302B0A6D F25F1437 4FE1356D 6D51C245 E485B576 625E7EC6 F44C42E9" \
210 "A637ED6B 0BFF5CB6 F406B7ED EE386BFB 5A899FA5 AE9F2411 7C4B1FE6" \
211 "49286651 ECE45B3D C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8" \
212 "FD24CF5F 83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
213 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B E39E772C" \
214 "180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9 DE2BCBF6 95581718" \
215 "3995497C EA956AE5 15D22618 98FA0510 15728E5A 8AAAC42D AD33170D" \
216 "04507A33 A85521AB DF1CBA64 ECFB8504 58DBEF0A 8AEA7157 5D060C7D" \
217 "B3970F85 A6E1E4C7 ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226" \
218 "1AD2EE6B F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" \
219 "BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31 43DB5BFC" \
220 "E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7 88719A10 BDBA5B26" \
221 "99C32718 6AF4E23C 1A946834 B6150BDA 2583E9CA 2AD44CE8 DBBBC2DB" \
222 "04DE8EF9 2E8EFC14 1FBECAA6 287C5947 4E6BC05D 99B2964F A090C3A2" \
223 "233BA186 515BE7ED 1F612970 CEE2D7AF B81BDD76 2170481C D0069127" \
224 "D5B05AA9 93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" \
225 "36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD F8FF9406" \
226 "AD9E530E E5DB382F 413001AE B06A53ED 9027D831 179727B0 865A8918" \
227 "DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B DB7F1447 E6CC254B 33205151" \
228 "2BD7AF42 6FB8F401 378CD2BF 5983CA01 C64B92EC F032EA15 D1721D03" \
229 "F482D7CE 6E74FEF6 D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F" \
230 "BEC7E8F3 23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" \
231 "CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328 06A1D58B" \
232 "B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C DA56C9EC 2EF29632" \
233 "387FE8D7 6E3C0468 043E8F66 3F4860EE 12BF2D5B 0B7474D6 E694F91E" \
234 "6DCC4024 FFFFFFFF FFFFFFFF"
235
236 /* copy&pasted from rfc3526: */
237 #define MODP8192_MODULUS \
238 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
239 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
240 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
241 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
242 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
243 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
244 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
245 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
246 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
247 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
248 "15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" \
249 "ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" \
250 "ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" \
251 "F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" \
252 "BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" \
253 "43DB5BFC E0FD108E 4B82D120 A9210801 1A723C12 A787E6D7" \
254 "88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" \
255 "2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" \
256 "287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" \
257 "1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" \
258 "93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34028492" \
259 "36C3FAB4 D27C7026 C1D4DCB2 602646DE C9751E76 3DBA37BD" \
260 "F8FF9406 AD9E530E E5DB382F 413001AE B06A53ED 9027D831" \
261 "179727B0 865A8918 DA3EDBEB CF9B14ED 44CE6CBA CED4BB1B" \
262 "DB7F1447 E6CC254B 33205151 2BD7AF42 6FB8F401 378CD2BF" \
263 "5983CA01 C64B92EC F032EA15 D1721D03 F482D7CE 6E74FEF6" \
264 "D55E702F 46980C82 B5A84031 900B1C9E 59E7C97F BEC7E8F3" \
265 "23A97A7E 36CC88BE 0F1D45B7 FF585AC5 4BD407B2 2B4154AA" \
266 "CC8F6D7E BF48E1D8 14CC5ED2 0F8037E0 A79715EE F29BE328" \
267 "06A1D58B B7C5DA76 F550AA3D 8A1FBFF0 EB19CCB1 A313D55C" \
268 "DA56C9EC 2EF29632 387FE8D7 6E3C0468 043E8F66 3F4860EE" \
269 "12BF2D5B 0B7474D6 E694F91E 6DBE1159 74A3926F 12FEE5E4" \
270 "38777CB6 A932DF8C D8BEC4D0 73B931BA 3BC832B6 8D9DD300" \
271 "741FA7BF 8AFC47ED 2576F693 6BA42466 3AAB639C 5AE4F568" \
272 "3423B474 2BF1C978 238F16CB E39D652D E3FDB8BE FC848AD9" \
273 "22222E04 A4037C07 13EB57A8 1A23F0C7 3473FC64 6CEA306B" \
274 "4BCBC886 2F8385DD FA9D4B7F A2C087E8 79683303 ED5BDD3A" \
275 "062B3CF5 B3A278A6 6D2A13F8 3F44F82D DF310EE0 74AB6A36" \
276 "4597E899 A0255DC1 64F31CC5 0846851D F9AB4819 5DED7EA1" \
277 "B1D510BD 7EE74D73 FAF36BC3 1ECFA268 359046F4 EB879F92" \
278 "4009438B 481C6CD7 889A002E D5EE382B C9190DA6 FC026E47" \
279 "9558E447 5677E9AA 9E3050E2 765694DF C81F56E8 80B96E71" \
280 "60C980DD 98EDD3DF FFFFFFFF FFFFFFFF"
281 #define LOCALSECRETSIZE (256 / BITS_PER_BYTE)
282
283 /* limits on nonce sizes. See RFC2409 "The internet key exchange (IKE)" 5 */
284 #define MINIMUM_NONCE_SIZE 8 /* bytes */
285 #define DEFAULT_NONCE_SIZE 16 /* bytes */
286 #define MAXIMUM_NONCE_SIZE 256 /* bytes */
287
288 #define COOKIE_SIZE 8
289 #define MAX_ISAKMP_SPI_SIZE 16
290
291 #define MD2_DIGEST_SIZE (128 / BITS_PER_BYTE) /* ought to be supplied by md2.h */
292 #define MD5_DIGEST_SIZE (128 / BITS_PER_BYTE) /* ought to be supplied by md5.h */
293 #define SHA1_DIGEST_SIZE (160 / BITS_PER_BYTE) /* ought to be supplied by sha1.h */
294
295 #define DES_CBC_BLOCK_SIZE (64 / BITS_PER_BYTE)
296
297 #define DSS_QBITS 160 /* bits in DSS's "q" (FIPS 186-1) */
298
299 /* to statically allocate IV, we need max of
300 * MD5_DIGEST_SIZE, SHA1_DIGEST_SIZE, and DES_CBC_BLOCK_SIZE.
301 * To avoid combinatorial explosion, we leave out DES_CBC_BLOCK_SIZE.
302 */
303 #define MAX_DIGEST_LEN_OLD (MD5_DIGEST_SIZE > SHA1_DIGEST_SIZE? MD5_DIGEST_SIZE : SHA1_DIGEST_SIZE)
304
305 /* for max: SHA2_512 */
306 #define MAX_DIGEST_LEN (512/BITS_PER_BYTE)
307
308 /* RFC 2404 "HMAC-SHA-1-96" section 3 */
309 #define HMAC_SHA1_KEY_LEN SHA1_DIGEST_SIZE
310
311 /* RFC 2403 "HMAC-MD5-96" section 3 */
312 #define HMAC_MD5_KEY_LEN MD5_DIGEST_SIZE
313
314 #define IKE_UDP_PORT 500
315
316 /* RFC 2560 OCSP - certificate status */
317
318 typedef enum {
319 CERT_GOOD = 0,
320 CERT_REVOKED = 1,
321 CERT_UNKNOWN = 2,
322 CERT_UNDEFINED = 3
323 } cert_status_t;
324
325 /* RFC 2459 CRL reason codes */
326
327 extern enum_names crl_reason_names;
328
329 typedef enum {
330 REASON_UNSPECIFIED = 0,
331 REASON_KEY_COMPROMISE = 1,
332 REASON_CA_COMPROMISE = 2,
333 REASON_AFFILIATION_CHANGED = 3,
334 REASON_SUPERSEDED = 4,
335 REASON_CESSATION_OF_OPERATON = 5,
336 REASON_CERTIFICATE_HOLD = 6,
337 REASON_REMOVE_FROM_CRL = 8
338 } crl_reason_t;
339
340 /* RFC 3706 Dead Peer Detection */
341
342 extern enum_names dpd_action_names;
343
344 typedef enum {
345 DPD_ACTION_NONE = 0,
346 DPD_ACTION_CLEAR = 1,
347 DPD_ACTION_HOLD = 2,
348 DPD_ACTION_RESTART = 3,
349 DPD_ACTION_UNKNOWN = 4
350 } dpd_action_t;
351
352 /* Timer events */
353
354 extern enum_names timer_event_names;
355
356 enum event_type {
357 EVENT_NULL, /* non-event */
358 EVENT_REINIT_SECRET, /* Refresh cookie secret */
359 #ifdef KLIPS
360 EVENT_SHUNT_SCAN, /* scan shunt eroutes known to kernel */
361 #endif
362 EVENT_SO_DISCARD, /* discard unfinished state object */
363 EVENT_RETRANSMIT, /* Retransmit packet */
364 EVENT_SA_REPLACE, /* SA replacement event */
365 EVENT_SA_REPLACE_IF_USED, /* SA replacement event */
366 EVENT_SA_EXPIRE, /* SA expiration event */
367 EVENT_NAT_T_KEEPALIVE, /* NAT Traversal Keepalive */
368 EVENT_DPD, /* dead peer detection */
369 EVENT_DPD_TIMEOUT, /* dead peer detection timeout */
370 EVENT_LOG_DAILY /* reset certain log events/stats */
371 };
372
373 #define EVENT_REINIT_SECRET_DELAY 3600 /* 1 hour */
374 #define EVENT_RETRANSMIT_DELAY_0 10 /* 10 seconds */
375
376 /* Misc. stuff */
377
378 #define MAXIMUM_RETRANSMISSIONS 2
379 #define MAXIMUM_RETRANSMISSIONS_INITIAL 20
380
381 #define MAX_INPUT_UDP_SIZE 65536
382 #define MAX_OUTPUT_UDP_SIZE 65536
383
384 /* Version numbers */
385
386 #define ISAKMP_MAJOR_VERSION 0x1
387 #define ISAKMP_MINOR_VERSION 0x0
388
389 extern enum_names version_names;
390
391 /* Domain of Interpretation */
392
393 extern enum_names doi_names;
394
395 #define ISAKMP_DOI_ISAKMP 0
396 #define ISAKMP_DOI_IPSEC 1
397
398 /* IPsec DOI things */
399
400 #define IPSEC_DOI_SITUATION_LENGTH 4
401 #define IPSEC_DOI_LDI_LENGTH 4
402 #define IPSEC_DOI_SPI_SIZE 4
403
404 /* SPI value 0 is invalid and values 1-255 are reserved to IANA.
405 * ESP: RFC 2402 2.4; AH: RFC 2406 2.1
406 * IPComp RFC 2393 substitutes a CPI in the place of an SPI.
407 * see also draft-shacham-ippcp-rfc2393bis-05.txt.
408 * We (FreeS/WAN) reserve 0x100 to 0xFFF for manual keying, so
409 * Pluto won't generate these values.
410 */
411 #define IPSEC_DOI_SPI_MIN 0x100
412 #define IPSEC_DOI_SPI_OUR_MIN 0x1000
413
414 /* debugging settings: a set of selections for reporting
415 * These would be more naturally situated in log.h,
416 * but they are shared with whack.
417 * IMPAIR_* actually change behaviour, usually badly,
418 * to aid in testing. Naturally, these are not included in ALL.
419 *
420 * NOTE: changes here must be done in concert with changes to DBGOPT_*
421 * in whack.c. A change to WHACK_MAGIC in whack.h will be required too.
422 */
423 #ifdef DEBUG
424 extern const char *const debug_bit_names[];
425 #endif
426
427 #define DBG_RAW LELEM(0) /* raw packet I/O */
428 #define DBG_CRYPT LELEM(1) /* encryption/decryption of messages */
429 #define DBG_PARSING LELEM(2) /* show decoding of messages */
430 #define DBG_EMITTING LELEM(3) /* show encoding of messages */
431 #define DBG_CONTROL LELEM(4) /* control flow within Pluto */
432 #define DBG_LIFECYCLE LELEM(5) /* SA lifecycle */
433 #define DBG_KLIPS LELEM(6) /* messages to KLIPS */
434 #define DBG_DNS LELEM(7) /* DNS activity */
435 #define DBG_NATT LELEM(8) /* NAT-T */
436 #define DBG_OPPO LELEM(9) /* opportunism */
437 #define DBG_CONTROLMORE LELEM(10) /* more detailed debugging */
438
439 #define DBG_PRIVATE LELEM(11) /* private information: DANGER! */
440
441 #define IMPAIR0 12 /* first bit for IMPAIR_* */
442
443 #define IMPAIR_DELAY_ADNS_KEY_ANSWER LELEM(IMPAIR0+0) /* sleep before answering */
444 #define IMPAIR_DELAY_ADNS_TXT_ANSWER LELEM(IMPAIR0+1) /* sleep before answering */
445 #define IMPAIR_BUST_MI2 LELEM(IMPAIR0+2) /* make MI2 really large */
446 #define IMPAIR_BUST_MR2 LELEM(IMPAIR0+3) /* make MI2 really large */
447
448 #define DBG_NONE 0 /* no options on, including impairments */
449 #define DBG_ALL LRANGES(DBG_RAW, DBG_CONTROLMORE) /* all logging options on EXCEPT DBG_PRIVATE */
450
451 /* State of exchanges
452 *
453 * The name of the state describes the last message sent, not the
454 * message currently being input or output (except during retry).
455 * In effect, the state represents the last completed action.
456 *
457 * Messages are named [MQ][IR]n where
458 * - M stands for Main Mode (Phase 1);
459 * Q stands for Quick Mode (Phase 2)
460 * - I stands for Initiator;
461 * R stands for Responder
462 * - n, a digit, stands for the number of the message
463 *
464 * It would be more convenient if each state accepted a message
465 * and produced one. This is the case for states at the start
466 * or end of an exchange. To fix this, we pretend that there are
467 * MR0 and QR0 messages before the MI1 and QR1 messages. Similarly,
468 * we pretend that there are MR4 and QR2 messages.
469 *
470 * STATE_MAIN_R0 and STATE_QUICK_R0 are intermediate states (not
471 * retained between messages) representing the state that accepts the
472 * first message of an exchange has been read but not processed.
473 *
474 * state_microcode state_microcode_table in demux.c describes
475 * other important details.
476 */
477
478 extern enum_names state_names;
479 extern const char *const state_story[];
480
481 enum state_kind {
482 STATE_UNDEFINED, /* 0 -- most likely accident */
483
484 /* Opportunism states: see "Opportunistic Encryption" 2.2 */
485
486 OPPO_ACQUIRE, /* got an ACQUIRE message for this pair */
487 OPPO_GW_DISCOVERED, /* got TXT specifying gateway */
488
489 /* IKE states */
490
491 STATE_MAIN_R0,
492 STATE_MAIN_I1,
493 STATE_MAIN_R1,
494 STATE_MAIN_I2,
495 STATE_MAIN_R2,
496 STATE_MAIN_I3,
497 STATE_MAIN_R3,
498 STATE_MAIN_I4,
499
500 STATE_QUICK_R0,
501 STATE_QUICK_I1,
502 STATE_QUICK_R1,
503 STATE_QUICK_I2,
504 STATE_QUICK_R2,
505
506 STATE_INFO,
507 STATE_INFO_PROTECTED,
508
509 STATE_MODE_CFG_R0, /* these states are used on the responder */
510 STATE_MODE_CFG_R1,
511 STATE_MODE_CFG_R2,
512
513 STATE_MODE_CFG_I1, /* this is used on the initiator */
514 STATE_MODE_CFG_I2,
515 STATE_MODE_CFG_I3,
516
517 STATE_IKE_ROOF
518 };
519
520 #define STATE_IKE_FLOOR STATE_MAIN_R0
521
522 #define PHASE1_INITIATOR_STATES (LELEM(STATE_MAIN_I1) | LELEM(STATE_MAIN_I2) \
523 | LELEM(STATE_MAIN_I3) | LELEM(STATE_MAIN_I4))
524 #define ISAKMP_SA_ESTABLISHED_STATES (LELEM(STATE_MAIN_R3) | LELEM(STATE_MAIN_I4) \
525 | LELEM(STATE_MODE_CFG_R1) | LELEM(STATE_MODE_CFG_R2) \
526 | LELEM(STATE_MODE_CFG_I2) | LELEM(STATE_MODE_CFG_I3))
527
528 #define IS_PHASE1(s) ((STATE_MAIN_R0 <= (s) && (s) <= STATE_MAIN_I4) \
529 || (STATE_MODE_CFG_R0 <= (s) && (s) <= STATE_MODE_CFG_I3))
530 #define IS_QUICK(s) (STATE_QUICK_R0 <= (s) && (s) <= STATE_QUICK_R2)
531 #define IS_ISAKMP_ENCRYPTED(s) (STATE_MAIN_I2 <= (s))
532 #define IS_ISAKMP_SA_ESTABLISHED(s) ( \
533 (s) == STATE_MAIN_R3 \
534 || (s) == STATE_MAIN_I4 \
535 || (s) == STATE_MODE_CFG_R0 \
536 || (s) == STATE_MODE_CFG_R1 \
537 || (s) == STATE_MODE_CFG_R2 \
538 || (s) == STATE_MODE_CFG_I2 \
539 || (s) == STATE_MODE_CFG_I3)
540 #define IS_IPSEC_SA_ESTABLISHED(s) ((s) == STATE_QUICK_I2 || (s) == STATE_QUICK_R2)
541 #define IS_ONLY_INBOUND_IPSEC_SA_ESTABLISHED(s) ((s) == STATE_QUICK_R1)
542
543 /* kind of struct connection
544 * Ordered (mostly) by concreteness. Order is exploited.
545 */
546
547 extern enum_names connection_kind_names;
548
549 enum connection_kind {
550 CK_GROUP, /* policy group: instantiates to template */
551 CK_TEMPLATE, /* abstract connection, with wildcard */
552 CK_PERMANENT, /* normal connection */
553 CK_INSTANCE, /* instance of template, created for a particular attempt */
554 CK_GOING_AWAY /* instance being deleted -- don't delete again */
555 };
556
557
558 /* routing status.
559 * Note: routing ignores source address, but erouting does not!
560 * Note: a connection can only be routed if it is NEVER_NEGOTIATE
561 * or HAS_IPSEC_POLICY.
562 */
563
564 extern enum_names routing_story;
565
566 /* note that this is assumed to be ordered! */
567 enum routing_t {
568 RT_UNROUTED, /* unrouted */
569 RT_UNROUTED_HOLD, /* unrouted, but HOLD shunt installed */
570 RT_ROUTED_ECLIPSED, /* RT_ROUTED_PROSPECTIVE except bare HOLD or instance has eroute */
571 RT_ROUTED_PROSPECTIVE, /* routed, and prospective shunt installed */
572 RT_ROUTED_HOLD, /* routed, and HOLD shunt installed */
573 RT_ROUTED_FAILURE, /* routed, and failure-context shunt installed */
574 RT_ROUTED_TUNNEL, /* routed, and erouted to an IPSEC SA group */
575 RT_UNROUTED_KEYED /* keyed, but not routed, on purpose */
576 };
577
578 #define routed(rs) ((rs) > RT_UNROUTED_HOLD)
579 #define erouted(rs) ((rs) != RT_UNROUTED)
580 #define shunt_erouted(rs) (erouted(rs) && (rs) != RT_ROUTED_TUNNEL)
581
582 /* Payload types
583 * RFC2408 Internet Security Association and Key Management Protocol (ISAKMP)
584 * section 3.1
585 *
586 * RESERVED 14-127
587 * Private USE 128-255
588 */
589
590 extern enum_names payload_names;
591 extern const char *const payload_name[];
592
593 #define ISAKMP_NEXT_NONE 0 /* No other payload following */
594 #define ISAKMP_NEXT_SA 1 /* Security Association */
595 #define ISAKMP_NEXT_P 2 /* Proposal */
596 #define ISAKMP_NEXT_T 3 /* Transform */
597 #define ISAKMP_NEXT_KE 4 /* Key Exchange */
598 #define ISAKMP_NEXT_ID 5 /* Identification */
599 #define ISAKMP_NEXT_CERT 6 /* Certificate */
600 #define ISAKMP_NEXT_CR 7 /* Certificate Request */
601 #define ISAKMP_NEXT_HASH 8 /* Hash */
602 #define ISAKMP_NEXT_SIG 9 /* Signature */
603 #define ISAKMP_NEXT_NONCE 10 /* Nonce */
604 #define ISAKMP_NEXT_N 11 /* Notification */
605 #define ISAKMP_NEXT_D 12 /* Delete */
606 #define ISAKMP_NEXT_VID 13 /* Vendor ID */
607 #define ISAKMP_NEXT_ATTR 14 /* Mode config Attribute */
608
609 #define ISAKMP_NEXT_NATD_RFC 20 /* NAT-Traversal: NAT-D (rfc) */
610 #define ISAKMP_NEXT_NATOA_RFC 21 /* NAT-Traversal: NAT-OA (rfc) */
611 #define ISAKMP_NEXT_ROOF 22 /* roof on payload types */
612
613 #define ISAKMP_NEXT_NATD_DRAFTS 130 /* NAT-Traversal: NAT-D (drafts) */
614 #define ISAKMP_NEXT_NATOA_DRAFTS 131 /* NAT-Traversal: NAT-OA (drafts) */
615
616 /* These values are to be used within the Type field of an Attribute (14)
617 * ISAKMP payload.
618 */
619 #define ISAKMP_CFG_REQUEST 1
620 #define ISAKMP_CFG_REPLY 2
621 #define ISAKMP_CFG_SET 3
622 #define ISAKMP_CFG_ACK 4
623
624 extern enum_names attr_msg_type_names;
625
626 /* Mode Config attribute values */
627 #define INTERNAL_IP4_ADDRESS 1
628 #define INTERNAL_IP4_NETMASK 2
629 #define INTERNAL_IP4_DNS 3
630 #define INTERNAL_IP4_NBNS 4
631 #define INTERNAL_ADDRESS_EXPIRY 5
632 #define INTERNAL_IP4_DHCP 6
633 #define APPLICATION_VERSION 7
634 #define INTERNAL_IP6_ADDRESS 8
635 #define INTERNAL_IP6_NETMASK 9
636 #define INTERNAL_IP6_DNS 10
637 #define INTERNAL_IP6_NBNS 11
638 #define INTERNAL_IP6_DHCP 12
639 #define INTERNAL_IP4_SUBNET 13
640 #define SUPPORTED_ATTRIBUTES 14
641 #define INTERNAL_IP6_SUBNET 15
642
643 extern enum_names modecfg_attr_names;
644
645 /* Exchange types
646 * RFC2408 "Internet Security Association and Key Management Protocol (ISAKMP)"
647 * section 3.1
648 *
649 * ISAKMP Future Use 6 - 31
650 * DOI Specific Use 32 - 239
651 * Private Use 240 - 255
652 *
653 * Note: draft-ietf-ipsec-dhless-enc-mode-00.txt Appendix A
654 * defines "DHless RSA Encryption" as 6.
655 */
656
657 extern enum_names exchange_names;
658
659 #define ISAKMP_XCHG_NONE 0
660 #define ISAKMP_XCHG_BASE 1
661 #define ISAKMP_XCHG_IDPROT 2 /* ID Protection */
662 #define ISAKMP_XCHG_AO 3 /* Authentication Only */
663 #define ISAKMP_XCHG_AGGR 4 /* Aggressive */
664 #define ISAKMP_XCHG_INFO 5 /* Informational */
665 #define ISAKMP_XCHG_MODE_CFG 6 /* Mode Config */
666
667 /* Extra exchange types, defined by Oakley
668 * RFC2409 "The Internet Key Exchange (IKE)", near end of Appendix A
669 */
670 #define ISAKMP_XCHG_QUICK 32 /* Oakley Quick Mode */
671 #define ISAKMP_XCHG_NGRP 33 /* Oakley New Group Mode */
672 /* added in draft-ietf-ipsec-ike-01.txt, near end of Appendix A */
673 #define ISAKMP_XCHG_ACK_INFO 34 /* Oakley Acknowledged Informational */
674
675 /* Flag bits */
676
677 extern const char *const flag_bit_names[];
678
679 #define ISAKMP_FLAG_ENCRYPTION 0x1
680 #define ISAKMP_FLAG_COMMIT 0x2
681
682 /* Situation definition for IPsec DOI */
683
684 extern const char *const sit_bit_names[];
685
686 #define SIT_IDENTITY_ONLY 0x01
687 #define SIT_SECRECY 0x02
688 #define SIT_INTEGRITY 0x04
689
690 /* Protocol IDs
691 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.1
692 */
693
694 extern enum_names protocol_names;
695
696 #define PROTO_ISAKMP 1
697 #define PROTO_IPSEC_AH 2
698 #define PROTO_IPSEC_ESP 3
699 #define PROTO_IPCOMP 4
700
701 /* warning: trans_show uses enum_show, so same static buffer is used */
702 #define trans_show(p, t) \
703 ((p)==PROTO_IPSEC_AH ? enum_show(&ah_transformid_names, (t)) \
704 : (p)==PROTO_IPSEC_ESP ? enum_show(&esp_transformid_names, (t)) \
705 : (p)==PROTO_IPCOMP ? enum_show(&ipcomp_transformid_names, (t)) \
706 : "??")
707
708 /* many transform values are moved to freeswan/ipsec_policy.h */
709
710 extern enum_names isakmp_transformid_names;
711
712 #define KEY_IKE 1
713
714 extern enum_names ah_transformid_names;
715 extern enum_names esp_transformid_names;
716 extern enum_names ipcomp_transformid_names;
717
718 /* the following are from RFC 2393/draft-shacham-ippcp-rfc2393bis-05.txt 3.3 */
719 typedef u_int16_t cpi_t;
720 #define IPCOMP_CPI_SIZE 2
721 #define IPCOMP_FIRST_NEGOTIATED 256
722 #define IPCOMP_LAST_NEGOTIATED 61439
723
724 /* Identification type values
725 * RFC 2407 The Internet IP security Domain of Interpretation for ISAKMP 4.6.2.1
726 */
727
728 extern enum_names ident_names;
729 extern enum_names cert_type_names;
730 extern enum_names cert_policy_names;
731
732 typedef enum certpolicy {
733 CERT_ALWAYS_SEND = 0, /* the default */
734 CERT_SEND_IF_ASKED = 1,
735 CERT_NEVER_SEND = 2,
736
737 CERT_YES_SEND = 3, /* synonym for CERT_ALWAYS_SEND */
738 CERT_NO_SEND = 4 /* synonym for CERT_NEVER_SEND */
739 } certpolicy_t;
740
741 /* Policies for establishing an SA
742 *
743 * These are used to specify attributes (eg. encryption) and techniques
744 * (eg PFS) for an SA.
745 * Note: certain CD_ definitions in whack.c parallel these -- keep them
746 * in sync!
747 */
748
749 extern const char *const sa_policy_bit_names[];
750 extern const char *prettypolicy(lset_t policy);
751
752 /* ISAKMP auth techniques (none means never negotiate) */
753 #define POLICY_PSK LELEM(0)
754 #define POLICY_RSASIG LELEM(1)
755
756 #define POLICY_ISAKMP_SHIFT 0 /* log2(POLICY_PSK) */
757 #define POLICY_ID_AUTH_MASK LRANGES(POLICY_PSK, POLICY_RSASIG)
758 #define POLICY_ISAKMP_MASK POLICY_ID_AUTH_MASK /* all so far */
759
760 /* Quick Mode (IPSEC) attributes */
761 #define POLICY_ENCRYPT LELEM(2) /* must be first of IPSEC policies */
762 #define POLICY_AUTHENTICATE LELEM(3) /* must be second */
763 #define POLICY_COMPRESS LELEM(4) /* must be third */
764 #define POLICY_TUNNEL LELEM(5)
765 #define POLICY_PFS LELEM(6)
766 #define POLICY_DISABLEARRIVALCHECK LELEM(7) /* supress tunnel egress address checking */
767
768 #define POLICY_IPSEC_SHIFT 2 /* log2(POLICY_ENCRYPT) */
769 #define POLICY_IPSEC_MASK LRANGES(POLICY_ENCRYPT, POLICY_DISABLEARRIVALCHECK)
770
771 /* shunt attributes: what to do when routed without tunnel (2 bits) */
772 #define POLICY_SHUNT_SHIFT 8 /* log2(POLICY_SHUNT_PASS) */
773 #define POLICY_SHUNT_MASK (03ul << POLICY_SHUNT_SHIFT)
774
775 #define POLICY_SHUNT_TRAP (0ul << POLICY_SHUNT_SHIFT) /* default: negotiate */
776 #define POLICY_SHUNT_PASS (1ul << POLICY_SHUNT_SHIFT)
777 #define POLICY_SHUNT_DROP (2ul << POLICY_SHUNT_SHIFT)
778 #define POLICY_SHUNT_REJECT (3ul << POLICY_SHUNT_SHIFT)
779
780 /* fail attributes: what to do with failed negotiation (2 bits) */
781
782 #define POLICY_FAIL_SHIFT 10 /* log2(POLICY_FAIL_PASS) */
783 #define POLICY_FAIL_MASK (03ul << POLICY_FAIL_SHIFT)
784
785 #define POLICY_FAIL_NONE (0ul << POLICY_FAIL_SHIFT) /* default */
786 #define POLICY_FAIL_PASS (1ul << POLICY_FAIL_SHIFT)
787 #define POLICY_FAIL_DROP (2ul << POLICY_FAIL_SHIFT)
788 #define POLICY_FAIL_REJECT (3ul << POLICY_FAIL_SHIFT)
789
790 /* connection policy
791 * Other policies could vary per state object. These live in connection.
792 */
793 #define POLICY_DONT_REKEY LELEM(12) /* don't rekey state either Phase */
794 #define POLICY_OPPO LELEM(13) /* is this opportunistic? */
795 #define POLICY_GROUP LELEM(14) /* is this a group template? */
796 #define POLICY_GROUTED LELEM(15) /* do we want this group routed? */
797 #define POLICY_UP LELEM(16) /* do we want this up? */
798 #define POLICY_MODECFG_PUSH LELEM(17) /* is modecfg pushed by server? */
799
800
801 /* Any IPsec policy? If not, a connection description
802 * is only for ISAKMP SA, not IPSEC SA. (A pun, I admit.)
803 * Note: a connection can only be routed if it is NEVER_NEGOTIATE
804 * or HAS_IPSEC_POLICY.
805 */
806 #define HAS_IPSEC_POLICY(p) (((p) & POLICY_IPSEC_MASK) != 0)
807
808 /* Don't allow negotiation? */
809 #define NEVER_NEGOTIATE(p) (LDISJOINT((p), POLICY_PSK | POLICY_RSASIG))
810
811
812 /* Oakley transform attributes
813 * draft-ietf-ipsec-ike-01.txt appendix A
814 */
815
816 extern enum_names oakley_attr_names;
817 extern const char *const oakley_attr_bit_names[];
818
819 #define OAKLEY_ENCRYPTION_ALGORITHM 1
820 #define OAKLEY_HASH_ALGORITHM 2
821 #define OAKLEY_AUTHENTICATION_METHOD 3
822 #define OAKLEY_GROUP_DESCRIPTION 4
823 #define OAKLEY_GROUP_TYPE 5
824 #define OAKLEY_GROUP_PRIME 6 /* B/V */
825 #define OAKLEY_GROUP_GENERATOR_ONE 7 /* B/V */
826 #define OAKLEY_GROUP_GENERATOR_TWO 8 /* B/V */
827 #define OAKLEY_GROUP_CURVE_A 9 /* B/V */
828 #define OAKLEY_GROUP_CURVE_B 10 /* B/V */
829 #define OAKLEY_LIFE_TYPE 11
830 #define OAKLEY_LIFE_DURATION 12 /* B/V */
831 #define OAKLEY_PRF 13
832 #define OAKLEY_KEY_LENGTH 14
833 #define OAKLEY_FIELD_SIZE 15
834 #define OAKLEY_GROUP_ORDER 16 /* B/V */
835 #define OAKLEY_BLOCK_SIZE 17
836
837 /* for each Oakley attribute, which enum_names describes its values? */
838 extern enum_names *oakley_attr_val_descs[];
839
840 /* IPsec DOI attributes
841 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.5
842 */
843
844 extern enum_names ipsec_attr_names;
845
846 #define SA_LIFE_TYPE 1
847 #define SA_LIFE_DURATION 2 /* B/V */
848 #define GROUP_DESCRIPTION 3
849 #define ENCAPSULATION_MODE 4
850 #define AUTH_ALGORITHM 5
851 #define KEY_LENGTH 6
852 #define KEY_ROUNDS 7
853 #define COMPRESS_DICT_SIZE 8
854 #define COMPRESS_PRIVATE_ALG 9 /* B/V */
855
856 /* for each IPsec attribute, which enum_names describes its values? */
857 extern enum_names *ipsec_attr_val_descs[];
858
859 /* SA Lifetime Type attribute
860 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.5
861 * Default time specified in 4.5
862 *
863 * There are two defaults for IPSEC SA lifetime, SA_LIFE_DURATION_DEFAULT,
864 * and PLUTO_SA_LIFE_DURATION_DEFAULT.
865 * SA_LIFE_DURATION_DEFAULT is specified in RFC2407 "The Internet IP
866 * Security Domain of Interpretation for ISAKMP" 4.5. It applies when
867 * an ISAKMP negotiation does not explicitly specify a life duration.
868 * PLUTO_SA_LIFE_DURATION_DEFAULT is specified in pluto(8). It applies
869 * when a connection description does not specify --ipseclifetime.
870 * The value of SA_LIFE_DURATION_MAXIMUM is our local policy.
871 */
872
873 extern enum_names sa_lifetime_names;
874
875 #define SA_LIFE_TYPE_SECONDS 1
876 #define SA_LIFE_TYPE_KBYTES 2
877
878 #define SA_LIFE_DURATION_DEFAULT 28800 /* eight hours (RFC2407 4.5) */
879 #define PLUTO_SA_LIFE_DURATION_DEFAULT 3600 /* one hour (pluto(8)) */
880 #define SA_LIFE_DURATION_MAXIMUM 86400 /* one day */
881
882 #define SA_REPLACEMENT_MARGIN_DEFAULT 540 /* (IPSEC & IKE) nine minutes */
883 #define SA_REPLACEMENT_FUZZ_DEFAULT 100 /* (IPSEC & IKE) 100% of MARGIN */
884 #define SA_REPLACEMENT_RETRIES_DEFAULT 3 /* (IPSEC & IKE) */
885
886 #define SA_LIFE_DURATION_K_DEFAULT 0xFFFFFFFFlu
887
888 /* Encapsulation Mode attribute */
889
890 extern enum_names enc_mode_names;
891
892 #define ENCAPSULATION_MODE_UNSPECIFIED 0 /* not legal -- used internally */
893 #define ENCAPSULATION_MODE_TUNNEL 1
894 #define ENCAPSULATION_MODE_TRANSPORT 2
895
896 #define ENCAPSULATION_MODE_UDP_TUNNEL_RFC 3
897 #define ENCAPSULATION_MODE_UDP_TRANSPORT_RFC 4
898
899 #define ENCAPSULATION_MODE_UDP_TUNNEL_DRAFTS 61443
900 #define ENCAPSULATION_MODE_UDP_TRANSPORT_DRAFTS 61444
901
902 /* Auth Algorithm attribute */
903
904 extern enum_names auth_alg_names, extended_auth_alg_names;
905
906 #define AUTH_ALGORITHM_NONE 0 /* our private designation */
907 #define AUTH_ALGORITHM_HMAC_MD5 1
908 #define AUTH_ALGORITHM_HMAC_SHA1 2
909 #define AUTH_ALGORITHM_DES_MAC 3
910 #define AUTH_ALGORITHM_KPDK 4
911 #define AUTH_ALGORITHM_HMAC_SHA2_256 5
912 #define AUTH_ALGORITHM_HMAC_SHA2_384 6
913 #define AUTH_ALGORITHM_HMAC_SHA2_512 7
914 #define AUTH_ALGORITHM_HMAC_RIPEMD 8
915 #define AUTH_ALGORITHM_NULL 251
916
917 /* Oakley Lifetime Type attribute
918 * draft-ietf-ipsec-ike-01.txt appendix A
919 * As far as I can see, there is not specification for
920 * OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT. This could lead to interop problems!
921 * For no particular reason, we chose three hours.
922 * The value of OAKLEY_ISAKMP_SA_LIFETIME_MAXIMUM is our local policy.
923 */
924 extern enum_names oakley_lifetime_names;
925
926 #define OAKLEY_LIFE_SECONDS 1
927 #define OAKLEY_LIFE_KILOBYTES 2
928
929 #define OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT 10800 /* three hours */
930 #define OAKLEY_ISAKMP_SA_LIFETIME_MAXIMUM 86400 /* one day */
931
932 /* Oakley PRF attribute (none defined)
933 * draft-ietf-ipsec-ike-01.txt appendix A
934 */
935 extern enum_names oakley_prf_names;
936
937 /* HMAC (see rfc2104.txt) */
938
939 #define HMAC_IPAD 0x36
940 #define HMAC_OPAD 0x5C
941 #define HMAC_BUFSIZE 64
942
943 /* Oakley Encryption Algorithm attribute
944 * draft-ietf-ipsec-ike-01.txt appendix A
945 * and from http://www.isi.edu/in-notes/iana/assignments/ipsec-registry
946 */
947
948 extern enum_names oakley_enc_names;
949
950 #define OAKLEY_DES_CBC 1
951 #define OAKLEY_IDEA_CBC 2
952 #define OAKLEY_BLOWFISH_CBC 3
953 #define OAKLEY_RC5_R16_B64_CBC 4
954 #define OAKLEY_3DES_CBC 5
955 #define OAKLEY_CAST_CBC 6
956 #define OAKLEY_AES_CBC 7
957
958 #define OAKLEY_MARS_CBC 65001
959 #define OAKLEY_RC6_CBC 65002
960 #define OAKLEY_ID_65003 65003
961 #define OAKLEY_SERPENT_CBC 65004
962 #define OAKLEY_TWOFISH_CBC 65005
963
964 #define OAKLEY_TWOFISH_CBC_SSH 65289
965
966 #define OAKLEY_ENCRYPT_MAX 65535 /* pretty useless :) */
967
968 /* Oakley Hash Algorithm attribute
969 * draft-ietf-ipsec-ike-01.txt appendix A
970 * and from http://www.isi.edu/in-notes/iana/assignments/ipsec-registry
971 */
972
973 extern enum_names oakley_hash_names;
974
975 #define OAKLEY_MD5 1
976 #define OAKLEY_SHA 2
977 #define OAKLEY_TIGER 3
978 #define OAKLEY_SHA2_256 4
979 #define OAKLEY_SHA2_384 5
980 #define OAKLEY_SHA2_512 6
981
982 #define OAKLEY_HASH_MAX 7
983
984 /* Oakley Authentication Method attribute
985 * draft-ietf-ipsec-ike-01.txt appendix A
986 * Goofy Hybrid extensions from draft-ietf-ipsec-isakmp-hybrid-auth-05.txt
987 * Goofy XAUTH extensions from draft-ietf-ipsec-isakmp-xauth-06.txt
988 */
989
990 extern enum_names oakley_auth_names;
991
992 #define OAKLEY_PRESHARED_KEY 1
993 #define OAKLEY_DSS_SIG 2
994 #define OAKLEY_RSA_SIG 3
995 #define OAKLEY_RSA_ENC 4
996 #define OAKLEY_RSA_ENC_REV 5
997 #define OAKLEY_ELGAMAL_ENC 6
998 #define OAKLEY_ELGAMAL_ENC_REV 7
999
1000 #define OAKLEY_AUTH_ROOF 8 /* roof on auth values THAT WE SUPPORT */
1001
1002 #define HybridInitRSA 64221
1003 #define HybridRespRSA 64222
1004 #define HybridInitDSS 64223
1005 #define HybridRespDSS 64224
1006
1007 #define XAUTHInitPreShared 65001
1008 #define XAUTHRespPreShared 65002
1009 #define XAUTHInitDSS 65003
1010 #define XAUTHRespDSS 65004
1011 #define XAUTHInitRSA 65005
1012 #define XAUTHRespRSA 65006
1013 #define XAUTHInitRSAEncryption 65007
1014 #define XAUTHRespRSAEncryption 65008
1015 #define XAUTHInitRSARevisedEncryption 65009
1016 #define XAUTHRespRSARevisedEncryption 65010
1017
1018 /* Oakley Group Description attribute
1019 * draft-ietf-ipsec-ike-01.txt appendix A
1020 */
1021 extern enum_names oakley_group_names;
1022
1023 #define OAKLEY_GROUP_MODP768 1
1024 #define OAKLEY_GROUP_MODP1024 2
1025 #define OAKLEY_GROUP_GP155 3
1026 #define OAKLEY_GROUP_GP185 4
1027 #define OAKLEY_GROUP_MODP1536 5
1028
1029 #define OAKLEY_GROUP_MODP2048 14
1030 #define OAKLEY_GROUP_MODP3072 15
1031 #define OAKLEY_GROUP_MODP4096 16
1032 #define OAKLEY_GROUP_MODP6144 17
1033 #define OAKLEY_GROUP_MODP8192 18
1034 /* you must also touch: constants.c, crypto.c */
1035
1036 /* Oakley Group Type attribute
1037 * draft-ietf-ipsec-ike-01.txt appendix A
1038 */
1039 extern enum_names oakley_group_type_names;
1040
1041 #define OAKLEY_GROUP_TYPE_MODP 1
1042 #define OAKLEY_GROUP_TYPE_ECP 2
1043 #define OAKLEY_GROUP_TYPE_EC2N 3
1044
1045
1046 /* Notify messages -- error types
1047 * See RFC2408 ISAKMP 3.14.1
1048 */
1049
1050 extern enum_names notification_names;
1051 extern enum_names ipsec_notification_names;
1052
1053 typedef enum {
1054 NOTHING_WRONG = 0, /* unofficial! */
1055
1056 INVALID_PAYLOAD_TYPE = 1,
1057 DOI_NOT_SUPPORTED = 2,
1058 SITUATION_NOT_SUPPORTED = 3,
1059 INVALID_COOKIE = 4,
1060 INVALID_MAJOR_VERSION = 5,
1061 INVALID_MINOR_VERSION = 6,
1062 INVALID_EXCHANGE_TYPE = 7,
1063 INVALID_FLAGS = 8,
1064 INVALID_MESSAGE_ID = 9,
1065 INVALID_PROTOCOL_ID = 10,
1066 INVALID_SPI = 11,
1067 INVALID_TRANSFORM_ID = 12,
1068 ATTRIBUTES_NOT_SUPPORTED = 13,
1069 NO_PROPOSAL_CHOSEN = 14,
1070 BAD_PROPOSAL_SYNTAX = 15,
1071 PAYLOAD_MALFORMED = 16,
1072 INVALID_KEY_INFORMATION = 17,
1073 INVALID_ID_INFORMATION = 18,
1074 INVALID_CERT_ENCODING = 19,
1075 INVALID_CERTIFICATE = 20,
1076 CERT_TYPE_UNSUPPORTED = 21,
1077 INVALID_CERT_AUTHORITY = 22,
1078 INVALID_HASH_INFORMATION = 23,
1079 AUTHENTICATION_FAILED = 24,
1080 INVALID_SIGNATURE = 25,
1081 ADDRESS_NOTIFICATION = 26,
1082 NOTIFY_SA_LIFETIME = 27,
1083 CERTIFICATE_UNAVAILABLE = 28,
1084 UNSUPPORTED_EXCHANGE_TYPE = 29,
1085 UNEQUAL_PAYLOAD_LENGTHS = 30,
1086
1087 /* ISAKMP status type */
1088 CONNECTED = 16384,
1089
1090 /* IPSEC DOI additions; status types (RFC2407 IPSEC DOI 4.6.3)
1091 * These must be sent under the protection of an ISAKMP SA.
1092 */
1093 IPSEC_RESPONDER_LIFETIME = 24576,
1094 IPSEC_REPLAY_STATUS = 24577,
1095 IPSEC_INITIAL_CONTACT = 24578,
1096
1097 /* RFC 3706 DPD */
1098 R_U_THERE = 36136,
1099 R_U_THERE_ACK = 36137
1100
1101 } notification_t;
1102
1103
1104 /* Public key algorithm number
1105 * Same numbering as used in DNSsec
1106 * See RFC 2535 DNSsec 3.2 The KEY Algorithm Number Specification.
1107 * Also found in BIND 8.2.2 include/isc/dst.h as DST algorithm codes.
1108 */
1109
1110 enum pubkey_alg
1111 {
1112 PUBKEY_ALG_RSA = 1,
1113 PUBKEY_ALG_DSA = 3,
1114 };
1115
1116 /* Limits on size of RSA moduli.
1117 * The upper bound matches that of DNSsec (see RFC 2537).
1118 * The lower bound must be more than 11 octets for certain
1119 * the encoding to work, but it must be much larger for any
1120 * real security. For now, we require 512 bits.
1121 */
1122
1123 #define RSA_MIN_OCTETS_RFC 12
1124
1125 #define RSA_MIN_OCTETS (512 / BITS_PER_BYTE)
1126 #define RSA_MIN_OCTETS_UGH "RSA modulus too small for security: less than 512 bits"
1127
1128 #define RSA_MAX_OCTETS (8192 / BITS_PER_BYTE)
1129 #define RSA_MAX_OCTETS_UGH "RSA modulus too large: more than 8192 bits"
1130
1131 /* Note: RFC 2537 encoding adds a few bytes. If you use a small
1132 * modulus like 3, the overhead is only 2 bytes
1133 */
1134 #define RSA_MAX_ENCODING_BYTES (RSA_MAX_OCTETS + 2)
1135
1136 /* socket address family info */
1137
1138 struct af_info
1139 {
1140 int af;
1141 const char *name;
1142 size_t ia_sz;
1143 size_t sa_sz;
1144 int mask_cnt;
1145 u_int8_t id_addr, id_subnet, id_range;
1146 const ip_address *any;
1147 const ip_subnet *none; /* 0.0.0.0/32 or IPv6 equivalent */
1148 const ip_subnet *all; /* 0.0.0.0/0 or IPv6 equivalent */
1149 };
1150
1151 extern const struct af_info
1152 af_inet4_info,
1153 af_inet6_info;
1154
1155 extern const struct af_info *aftoinfo(int af);
1156
1157 extern enum_names af_names;
1158
1159 #define subnetisaddr(sn, a) (subnetishost(sn) && addrinsubnet((a), (sn)))
1160 extern bool subnetisnone(const ip_subnet *sn);
1161
1162 /* BIND enumerated types */
1163
1164 extern enum_names
1165 rr_qtype_names,
1166 rr_type_names,
1167 rr_class_names;
1168
1169 /* How authenticated is info that might have come from DNS?
1170 * In order of increasing confidence.
1171 */
1172 enum dns_auth_level {
1173 DAL_UNSIGNED, /* AD in response, but no signature: no authentication */
1174 DAL_NOTSEC, /* no AD in response: authentication impossible */
1175 DAL_SIGNED, /* AD and signature in response: authentic */
1176 DAL_LOCAL /* locally provided (pretty good) */
1177 };
1178
1179 /*
1180 * define a macro for use in error messages
1181 */
1182
1183 #ifdef USE_KEYRR
1184 #define RRNAME "TXT or KEY"
1185 #else
1186 #define RRNAME "TXT"
1187 #endif
1188
1189 /* natt traversal types */
1190 extern const char *const natt_type_bitnames[];
1191
1192 #endif /* _CONSTANTS_H */