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