2 * Copyright (C) 1997 Angelos D. Keromytis.
3 * Copyright (C) 1998-2002 D. Hugh Redelmeier.
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>.
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
18 extern void init_constants(void);
21 * NOTE:For debugging purposes, constants.c has tables to map numbers back to names.
22 * Any changes here should be reflected there.
25 #define elemsof(array) (sizeof(array) / sizeof(*(array))) /* number of elements in an array */
27 /* Many routines return only success or failure, but wish to describe
28 * the failure in a message. We use the convention that they return
29 * a NULL on success and a pointer to constant string on failure.
30 * The fact that the string is a constant is limiting, but it
31 * avoids storage management issues: the recipient is allowed to assume
32 * that the string will live "long enough" (usually forever).
33 * <freeswan.h> defines err_t for this return type.
40 #define NULL_FD (-1) /* NULL file descriptor */
41 #define dup_any(fd) ((fd) == NULL_FD? NULL_FD : dup(fd))
42 #define close_any(fd) { if ((fd) != NULL_FD) { close(fd); (fd) = NULL_FD; } }
44 #define BITS_PER_BYTE 8
46 #define streq(a, b) (strcmp((a), (b)) == 0) /* clearer shorthand */
48 /* set type with room for at least 32 elements */
50 typedef unsigned long long lset_t;
52 #define LELEM(opt) (1ULL << (opt))
53 #define LRANGE(lwb, upb) LRANGES(LELEM(lwb), LELEM(upb))
54 #define LRANGES(first, last) (last - first + last)
55 #define LALLIN(set, probe) (((set) & (probe)) == (probe))
57 /* Control and lock pathnames */
59 #ifndef DEFAULT_CTLBASE
60 # define DEFAULT_CTLBASE "/var/run/pluto"
63 #define CTL_SUFFIX ".ctl" /* for UNIX domain socket pathname */
64 #define LOCK_SUFFIX ".pid" /* for pluto's lock */
66 /* Routines to check and display values.
68 * An enum_names describes an enumeration.
69 * enum_name() returns the name of an enum value, or NULL if invalid.
70 * enum_show() is like enum_name, except it formats a numeric representation
71 * for any invalid value (in a static area!)
73 * bitnames() formats a display of a set of named bits (in a static area)
76 typedef const struct enum_names enum_names;
78 extern const char *enum_name(enum_names *ed, unsigned long val);
79 extern const char *enum_show(enum_names *ed, unsigned long val);
80 extern int enum_search(enum_names *ed, const char *string);
82 extern bool testset(const char *const table[], lset_t val);
83 extern const char *bitnamesof(const char *const table[], lset_t val);
85 /* sparse_names is much like enum_names, except values are
86 * not known to be contiguous or ordered.
87 * The array of names is ended with one with the name sparse_end
88 * (this avoids having to reserve a value to signify the end).
89 * Often appropriate for enums defined by others.
93 const char *const name;
95 typedef const struct sparse_name sparse_names[];
97 extern const char *sparse_name(sparse_names sd, unsigned long val);
98 extern const char *sparse_val_show(sparse_names sd, unsigned long val);
99 extern const char sparse_end[];
101 #define FULL_INET_ADDRESS_SIZE 6
103 /* Group parameters from draft-ietf-ike-01.txt section 6 */
105 #define MODP_GENERATOR "2"
107 #define MODP768_MODULUS \
108 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
109 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
110 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
111 "E485B576 625E7EC6 F44C42E9 A63A3620 FFFFFFFF FFFFFFFF"
113 #define MODP1024_MODULUS \
114 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
115 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
116 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
117 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED " \
118 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 " \
121 #define MODP1536_MODULUS \
122 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1 " \
123 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD " \
124 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245 " \
125 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED " \
126 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D " \
127 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F " \
128 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D " \
129 "670C354E 4ABC9804 F1746C08 CA237327 FFFFFFFF FFFFFFFF "
131 /* draft-ietf-ipsec-ike-modp-groups-03.txt */
132 #define MODP2048_MODULUS \
133 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
134 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
135 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
136 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
137 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
138 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
139 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
140 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
141 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
142 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
143 "15728E5A 8AACAA68 FFFFFFFF FFFFFFFF"
145 #define MODP3072_MODULUS \
146 "FFFFFFFF FFFFFFFF C90FDAA2 2168C234 C4C6628B 80DC1CD1" \
147 "29024E08 8A67CC74 020BBEA6 3B139B22 514A0879 8E3404DD" \
148 "EF9519B3 CD3A431B 302B0A6D F25F1437 4FE1356D 6D51C245" \
149 "E485B576 625E7EC6 F44C42E9 A637ED6B 0BFF5CB6 F406B7ED" \
150 "EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE45B3D" \
151 "C2007CB8 A163BF05 98DA4836 1C55D39A 69163FA8 FD24CF5F" \
152 "83655D23 DCA3AD96 1C62F356 208552BB 9ED52907 7096966D" \
153 "670C354E 4ABC9804 F1746C08 CA18217C 32905E46 2E36CE3B" \
154 "E39E772C 180E8603 9B2783A2 EC07A28F B5C55DF0 6F4C52C9" \
155 "DE2BCBF6 95581718 3995497C EA956AE5 15D22618 98FA0510" \
156 "15728E5A 8AAAC42D AD33170D 04507A33 A85521AB DF1CBA64" \
157 "ECFB8504 58DBEF0A 8AEA7157 5D060C7D B3970F85 A6E1E4C7" \
158 "ABF5AE8C DB0933D7 1E8C94E0 4A25619D CEE3D226 1AD2EE6B" \
159 "F12FFA06 D98A0864 D8760273 3EC86A64 521F2B18 177B200C" \
160 "BBE11757 7A615D6C 770988C0 BAD946E2 08E24FA0 74E5AB31" \
161 "43DB5BFC E0FD108E 4B82D120 A93AD2CA FFFFFFFF FFFFFFFF"
163 #define MODP4096_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 A9210801 1A723C12 A787E6D7" \
180 "88719A10 BDBA5B26 99C32718 6AF4E23C 1A946834 B6150BDA" \
181 "2583E9CA 2AD44CE8 DBBBC2DB 04DE8EF9 2E8EFC14 1FBECAA6" \
182 "287C5947 4E6BC05D 99B2964F A090C3A2 233BA186 515BE7ED" \
183 "1F612970 CEE2D7AF B81BDD76 2170481C D0069127 D5B05AA9" \
184 "93B4EA98 8D8FDDC1 86FFB7DC 90A6C08F 4DF435C9 34063199" \
187 #define LOCALSECRETSIZE (256 / BITS_PER_BYTE)
189 /* limits on nonce sizes. See RFC2409 "The internet key exchange (IKE)" 5 */
190 #define MINIMUM_NONCE_SIZE 8 /* bytes */
191 #define DEFAULT_NONCE_SIZE 16 /* bytes */
192 #define MAXIMUM_NONCE_SIZE 256 /* bytes */
194 #define COOKIE_SIZE 8
195 #define MAX_ISAKMP_SPI_SIZE 16
197 #define MD2_DIGEST_SIZE (128 / BITS_PER_BYTE) /* ought to be supplied by md2.h */
198 #define MD5_DIGEST_SIZE (128 / BITS_PER_BYTE) /* ought to be supplied by md5.h */
199 #define SHA1_DIGEST_SIZE (160 / BITS_PER_BYTE) /* ought to be supplied by sha1.h */
201 #define DES_CBC_BLOCK_SIZE (64 / BITS_PER_BYTE)
203 #define DSS_QBITS 160 /* bits in DSS's "q" (FIPS 186-1) */
205 /* to statically allocate IV, we need max of
206 * MD5_DIGEST_SIZE, SHA1_DIGEST_SIZE, and DES_CBC_BLOCK_SIZE.
207 * To avoid combinatorial explosion, we leave out DES_CBC_BLOCK_SIZE.
209 #define MAX_DIGEST_LEN_OLD (MD5_DIGEST_SIZE > SHA1_DIGEST_SIZE? MD5_DIGEST_SIZE : SHA1_DIGEST_SIZE)
211 /* for max: SHA2_512 */
212 #define MAX_DIGEST_LEN (512/BITS_PER_BYTE)
213 /* draft-ietf-ipsec-auth-hmac-sha196-01.txt section 3 */
214 #define HMAC_SHA1_KEY_LEN SHA1_DIGEST_SIZE
216 /* draft-ietf-ipsec-auth-hmac-md5-96-01.txt section 3 */
217 #define HMAC_MD5_KEY_LEN MD5_DIGEST_SIZE
219 #define IKE_UDP_PORT 500
223 extern enum_names timer_event_names;
226 EVENT_NULL, /* non-event */
227 EVENT_REINIT_SECRET, /* Refresh cookie secret */
229 EVENT_SHUNT_SCAN, /* scan shunt eroutes known to kernel */
231 EVENT_SO_DISCARD, /* discard unfinished state object */
232 EVENT_RETRANSMIT, /* Retransmit packet */
233 EVENT_SA_REPLACE, /* SA replacement event */
234 EVENT_SA_EXPIRE, /* SA expiration event */
236 EVENT_NAT_T_KEEPALIVE,
238 EVENT_DPD, /* dead peer detection */
239 EVENT_DPD_TIMEOUT /* dead peer detection timeout */
242 #define EVENT_REINIT_SECRET_DELAY 3600 /* 1 hour */
243 #define EVENT_RETRANSMIT_DELAY_0 10 /* 10 seconds */
247 #define MAXIMUM_RETRANSMISSIONS 2
248 #define MAXIMUM_RETRANSMISSIONS_INITIAL 20
250 /* We don't really want to handle 64k byte packets */
251 #include <net/ethernet.h>
252 #define MAX_INPUT_UDP_SIZE 4096
253 #define MAX_OUTPUT_UDP_SIZE 4096
255 /* Version numbers */
257 #define ISAKMP_MAJOR_VERSION 0x1
258 #define ISAKMP_MINOR_VERSION 0x0
260 extern enum_names version_names;
262 /* Domain of Interpretation */
264 extern enum_names doi_names;
266 #define ISAKMP_DOI_ISAKMP 0
267 #define ISAKMP_DOI_IPSEC 1
269 /* IPsec DOI things */
271 #define IPSEC_DOI_SITUATION_LENGTH 4
272 #define IPSEC_DOI_LDI_LENGTH 4
273 #define IPSEC_DOI_SPI_SIZE 4
275 /* SPI value 0 is invalid and values 1-255 are reserved to IANA.
276 * ESP: RFC 2402 2.4; AH: RFC 2406 2.1
277 * IPComp RFC 2393 substitutes a CPI in the place of an SPI.
278 * see also draft-shacham-ippcp-rfc2393bis-05.txt.
279 * We (FreeS/WAN) reserve 0x100 to 0xFFF for manual keying, so
280 * Pluto won't generate these values.
282 #define IPSEC_DOI_SPI_MIN 0x100
283 #define IPSEC_DOI_SPI_OUR_MIN 0x1000
285 /* debugging settings: a set selections for reporting
286 * These would be more naturally situated in log.h,
287 * but they are shared with whack.
290 extern const char *const debug_bit_names[];
292 #define DBG_RAW 0x01 /* raw packet I/O */
293 #define DBG_CRYPT 0x02 /* encryption/decryption of messages */
294 #define DBG_PARSING 0x04 /* show decoding of messages */
295 #define DBG_EMITTING 0x08 /* show encoding of messages */
296 #define DBG_CONTROL 0x10 /* control flow within Pluto */
297 #define DBG_LIFECYCLE 0x20 /* SA lifecycle */
298 #define DBG_KLIPS 0x40 /* messages to KLIPS */
300 #define DBG_NATT 0x80 /* NAT-Traversal */
301 #define DBG_DNS 0x100 /* DNS activity */
302 #define DBG_PRIVATE 0x200 /* private information: DANGER! */
304 #define DBG_DNS 0x80 /* DNS activity */
305 #define DBG_PRIVATE 0x100 /* private information: DANGER! */
308 #define DBG_NONE 0 /* no options on */
309 #define DBG_ALL LRANGES(DBG_RAW, DBG_DNS) /* all options on EXCEPT DBG_PRIVATE */
312 /* State of exchanges
314 * The name of the state describes the last message sent, not the
315 * message currently being input or output (except during retry).
316 * In effect, the state represents the last completed action.
318 * Messages are named [MQ][IR]n where
319 * - M stands for Main Mode (Phase 1);
320 * Q stands for Quick Mode (Phase 2)
321 * - I stands for Initiator;
322 * R stands for Responder
323 * - n, a digit, stands for the number of the message
325 * It would be more convenient if each state accepted a message
326 * and produced one. This is the case for states at the start
327 * or end of an exchange. To fix this, we pretend that there are
328 * MR0 and QR0 messages before the MI1 and QR1 messages. Similarly,
329 * we pretend that there are MR4 and QR2 messages.
331 * STATE_MAIN_R0 and STATE_QUICK_R0 are intermediate states (not
332 * retained between messages) representing the state that accepts the
333 * first message of an exchange has been read but not processed.
335 * state_microcode state_microcode_table in demux.c describes
336 * other important details.
339 extern enum_names state_names;
340 extern const char *const state_story[];
343 STATE_UNDEFINED, /* 0 -- most likely accident */
345 /* Opportunism states: see "Opportunistic Encryption" 2.2 */
347 OPPO_ACQUIRE, /* got an ACQUIRE message for this pair */
348 OPPO_GW_DISCOVERED, /* got TXT specifying gateway */
377 #define STATE_IKE_FLOOR STATE_MAIN_R0
378 #define STATE_IKE_ROOF (STATE_INFO_PROTECTED + 1)
380 #define IS_PHASE1(s) (STATE_MAIN_R0 <= (s) && ((s) <= STATE_MAIN_I4 || (s) <= STATE_AGGR_R2))
381 #define IS_QUICK(s) (STATE_QUICK_R0 <= (s) && (s) <= STATE_QUICK_R2)
382 #define IS_ISAKMP_SA_ESTABLISHED(s) ((s) == STATE_MAIN_R3 || (s) == STATE_MAIN_I4 \
383 || (s) == STATE_AGGR_I2 || (s) == STATE_AGGR_R2)
384 #define IS_IPSEC_SA_ESTABLISHED(s) ((s) == STATE_QUICK_I2 || (s) == STATE_QUICK_R2)
385 #define IS_ONLY_INBOUND_IPSEC_SA_ESTABLISHED(s) ((s) == STATE_QUICK_R1)
387 /* kind of struct connection */
389 extern enum_names connection_kind_names;
391 enum connection_kind {
392 CK_TEMPLATE, /* abstract connection, with wildcard */
393 CK_PERMANENT, /* normal connection */
394 CK_INSTANCE, /* instance of template, created for a particular attempt */
395 CK_GOING_AWAY /* instance being deleted -- don't delete again */
400 * Note: routing ignores source address, but erouting does not!
403 extern enum_names routing_story;
406 RT_UNROUTED, /* unrouted */
407 RT_UNROUTED_HOLD, /* unrouted, but HOLD shunt installed */
408 RT_ROUTED_PROSPECTIVE, /* routed, and TRAP shunt installed */
409 RT_ROUTED_HOLD, /* routed, and HOLD shunt installed */
410 RT_ROUTED_FAILURE, /* routed, and failure-context shunt installed */
411 RT_ROUTED_TUNNEL /* routed, and erouted to an IPSEC SA group */
414 #define routed(rs) ((rs) > RT_UNROUTED_HOLD)
415 #define erouted(rs) ((rs) != RT_UNROUTED)
416 #define shunt_erouted(rs) (erouted(rs) && (rs) != RT_ROUTED_TUNNEL)
419 * RFC2408 Internet Security Association and Key Management Protocol (ISAKMP)
423 * Private USE 128-255
426 extern enum_names payload_names;
427 extern const char *const payload_name[];
429 #define ISAKMP_NEXT_NONE 0 /* No other payload following */
430 #define ISAKMP_NEXT_SA 1 /* Security Association */
431 #define ISAKMP_NEXT_P 2 /* Proposal */
432 #define ISAKMP_NEXT_T 3 /* Transform */
433 #define ISAKMP_NEXT_KE 4 /* Key Exchange */
434 #define ISAKMP_NEXT_ID 5 /* Identification */
435 #define ISAKMP_NEXT_CERT 6 /* Certificate */
436 #define ISAKMP_NEXT_CR 7 /* Certificate Request */
437 #define ISAKMP_NEXT_HASH 8 /* Hash */
438 #define ISAKMP_NEXT_SIG 9 /* Signature */
439 #define ISAKMP_NEXT_NONCE 10 /* Nonce */
440 #define ISAKMP_NEXT_N 11 /* Notification */
441 #define ISAKMP_NEXT_D 12 /* Delete */
442 #define ISAKMP_NEXT_VID 13 /* Vendor ID */
445 #define ISAKMP_NEXT_NATD_RFC 15 /* NAT-Traversal: NAT-D (rfc) */
446 #define ISAKMP_NEXT_NATOA_RFC 16 /* NAT-Traversal: NAT-OA (rfc) */
447 #define ISAKMP_NEXT_ROOF 17 /* roof on payload types */
448 #define ISAKMP_NEXT_NATD_DRAFTS 130 /* NAT-Traversal: NAT-D (drafts) */
449 #define ISAKMP_NEXT_NATOA_DRAFTS 131 /* NAT-Traversal: NAT-OA (drafts) */
451 #define ISAKMP_NEXT_ROOF 14 /* roof on payload types */
455 * RFC2408 "Internet Security Association and Key Management Protocol (ISAKMP)"
458 * ISAKMP Future Use 6 - 31
459 * DOI Specific Use 32 - 239
460 * Private Use 240 - 255
462 * Note: draft-ietf-ipsec-dhless-enc-mode-00.txt Appendix A
463 * defines "DHless RSA Encryption" as 6.
466 extern enum_names exchange_names;
468 #define ISAKMP_XCHG_NONE 0
469 #define ISAKMP_XCHG_BASE 1
470 #define ISAKMP_XCHG_IDPROT 2 /* ID Protection */
471 #define ISAKMP_XCHG_AO 3 /* Authentication Only */
472 #define ISAKMP_XCHG_AGGR 4 /* Aggressive */
473 #define ISAKMP_XCHG_INFO 5 /* Informational */
475 /* Extra exchange types, defined by Oakley
476 * RFC2409 "The Internet Key Exchange (IKE)", near end of Appendix A
478 #define ISAKMP_XCHG_QUICK 32 /* Oakley Quick Mode */
479 #define ISAKMP_XCHG_NGRP 33 /* Oakley New Group Mode */
480 /* added in draft-ietf-ipsec-ike-01.txt, near end of Appendix A */
481 #define ISAKMP_XCHG_ACK_INFO 34 /* Oakley Acknowledged Informational */
485 extern const char *const flag_bit_names[];
487 #define ISAKMP_FLAG_ENCRYPTION 0x1
488 #define ISAKMP_FLAG_COMMIT 0x2
490 /* Situation definition for IPsec DOI */
492 extern const char *const sit_bit_names[];
494 #define SIT_IDENTITY_ONLY 0x01
495 #define SIT_SECRECY 0x02
496 #define SIT_INTEGRITY 0x04
499 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.1
502 extern enum_names protocol_names;
504 #define PROTO_ISAKMP 1
505 #define PROTO_IPSEC_AH 2
506 #define PROTO_IPSEC_ESP 3
507 #define PROTO_IPCOMP 4
509 /* warning: trans_show uses enum_show, so same static buffer is used */
510 #define trans_show(p, t) \
511 ((p)==PROTO_IPSEC_AH ? enum_show(&ah_transformid_names, (t)) \
512 : (p)==PROTO_IPSEC_ESP ? enum_show(&esp_transformid_names, (t)) \
513 : (p)==PROTO_IPCOMP ? enum_show(&ipcomp_transformid_names, (t)) \
516 /* IPsec ISAKMP transform values
517 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.2
520 extern enum_names isakmp_transformid_names;
524 /* IPsec AH transform values
525 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.3
526 * and in http://www.isi.edu/in-notes/iana/assignments/isakmp-registry
529 extern enum_names ah_transformid_names;
534 #define AH_SHA2_256 5
535 #define AH_SHA2_384 6
536 #define AH_SHA2_512 7
538 /* IPsec ESP transform values
539 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.4
540 * and from http://www.isi.edu/in-notes/iana/assignments/isakmp-registry
543 extern enum_names esp_transformid_names;
545 #define ESP_reserved 0
546 #define ESP_DES_IV64 1
552 #define ESP_BLOWFISH 7
554 #define ESP_DES_IV32 9
559 /* IPCOMP transform values
560 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.4.5
563 extern enum_names ipcomp_transformid_names;
566 #define IPCOMP_DEFLATE 2
568 #define IPCOMP_V42BIS 4
570 /* the following are from RFC 2393/draft-shacham-ippcp-rfc2393bis-05.txt 3.3 */
571 typedef u_int16_t cpi_t;
572 #define IPCOMP_CPI_SIZE 2
573 #define IPCOMP_FIRST_NEGOTIATED 256
574 #define IPCOMP_LAST_NEGOTIATED 61439
576 /* Identification type values
577 * RFC 2407 The Internet IP security Domain of Interpretation for ISAKMP 4.6.2.1
580 extern enum_names ident_names;
582 #define ID_NONE 0 /* private to Pluto */
583 #define ID_IPV4_ADDR 1
585 #define ID_USER_FQDN 3
586 #define ID_IPV4_ADDR_SUBNET 4
587 #define ID_IPV6_ADDR 5
588 #define ID_IPV6_ADDR_SUBNET 6
589 #define ID_IPV4_ADDR_RANGE 7
590 #define ID_IPV6_ADDR_RANGE 8
591 #define ID_DER_ASN1_DN 9
592 #define ID_DER_ASN1_GN 10
595 /* Certificate type values
596 * RFC 2408 ISAKMP, chapter 3.9
599 extern enum_names cert_type_names;
602 #define CERT_PKCS7_WRAPPED_X509 1
604 #define CERT_DNS_SIGNED_KEY 3
605 #define CERT_X509_SIGNATURE 4
606 #define CERT_X509_KEY_EXCHANGE 5
607 #define CERT_KERBEROS_TOKENS 6
611 #define CERT_X509_ATTRIBUTE 10
613 /* Policies for establishing an SA
615 * These are used to specify attributes (eg. encryption) and techniques
616 * (eg PFS) for an SA.
619 extern const char *const sa_policy_bit_names[];
621 /* ISAKMP auth techniques */
622 #define POLICY_AGGRESSIVE LELEM(0)
623 #define POLICY_PSK LELEM(1)
624 #define POLICY_RSASIG LELEM(2)
626 #define POLICY_ISAKMP_SHIFT 1 /* log2(POLICY_PSK) */
627 #define POLICY_ID_AUTH_MASK LRANGES(POLICY_AGGRESSIVE, POLICY_RSASIG)
628 #define POLICY_ISAKMP_MASK POLICY_ID_AUTH_MASK /* all so far */
630 /* Quick Mode (IPSEC) attributes */
631 #define POLICY_ENCRYPT LELEM(3) /* must be first of IPSEC policies */
632 #define POLICY_AUTHENTICATE LELEM(4) /* must be second */
633 #define POLICY_COMPRESS LELEM(5) /* must be third */
634 #define POLICY_TUNNEL LELEM(6)
635 #define POLICY_PFS LELEM(7)
636 #define POLICY_DISABLEARRIVALCHECK LELEM(8) /* supress tunnel egress address checking */
638 #define POLICY_IPSEC_SHIFT 3 /* log2(POLICY_ENCRYPT) */
639 #define POLICY_IPSEC_MASK LRANGES(POLICY_ENCRYPT, POLICY_DISABLEARRIVALCHECK)
641 /* opportunistic attributes: what to do with a packet without a tunnel */
642 #define POLICY_PASS LELEM(9)
643 #define POLICY_DROP LELEM(10)
644 /* PASS | DROP is construed as REJECT */
646 #define POLICY_OPPO_SHIFT 9 /* log2(POLICY_PASS) */
647 #define POLICY_OPPO_MASK (POLICY_PASS | POLICY_DROP)
650 * Other policies could vary per state object. These live in connection.
652 #define POLICY_DONT_REKEY LELEM(11) /* don't rekey state either Phase */
653 #define POLICY_OPPO LELEM(12) /* is this opportunistic? */
656 /* Any IPsec policy? If not, a connection description
657 * is only for ISAKMP SA, not IPSEC SA. (A pun, I admit.)
659 #define HAS_IPSEC_POLICY(p) (((p) & POLICY_IPSEC_MASK) != 0)
661 /* Oakley transform attributes
662 * draft-ietf-ipsec-ike-01.txt appendix A
665 extern enum_names oakley_attr_names;
666 extern const char *const oakley_attr_bit_names[];
668 #define OAKLEY_ENCRYPTION_ALGORITHM 1
669 #define OAKLEY_HASH_ALGORITHM 2
670 #define OAKLEY_AUTHENTICATION_METHOD 3
671 #define OAKLEY_GROUP_DESCRIPTION 4
672 #define OAKLEY_GROUP_TYPE 5
673 #define OAKLEY_GROUP_PRIME 6 /* B/V */
674 #define OAKLEY_GROUP_GENERATOR_ONE 7 /* B/V */
675 #define OAKLEY_GROUP_GENERATOR_TWO 8 /* B/V */
676 #define OAKLEY_GROUP_CURVE_A 9 /* B/V */
677 #define OAKLEY_GROUP_CURVE_B 10 /* B/V */
678 #define OAKLEY_LIFE_TYPE 11
679 #define OAKLEY_LIFE_DURATION 12 /* B/V */
680 #define OAKLEY_PRF 13
681 #define OAKLEY_KEY_LENGTH 14
682 #define OAKLEY_FIELD_SIZE 15
683 #define OAKLEY_GROUP_ORDER 16 /* B/V */
684 #define OAKLEY_BLOCK_SIZE 17
686 /* for each Oakley attribute, which enum_names describes its values? */
687 extern enum_names *oakley_attr_val_descs[];
689 /* IPsec DOI attributes
690 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.5
693 extern enum_names ipsec_attr_names;
695 #define SA_LIFE_TYPE 1
696 #define SA_LIFE_DURATION 2 /* B/V */
697 #define GROUP_DESCRIPTION 3
698 #define ENCAPSULATION_MODE 4
699 #define AUTH_ALGORITHM 5
702 #define COMPRESS_DICT_SIZE 8
703 #define COMPRESS_PRIVATE_ALG 9 /* B/V */
705 /* for each IPsec attribute, which enum_names describes its values? */
706 extern enum_names *ipsec_attr_val_descs[];
708 /* SA Lifetime Type attribute
709 * RFC2407 The Internet IP security Domain of Interpretation for ISAKMP 4.5
710 * Default time specified in 4.5
712 * There are two defaults for IPSEC SA lifetime, SA_LIFE_DURATION_DEFAULT,
713 * and PLUTO_SA_LIFE_DURATION_DEFAULT.
714 * SA_LIFE_DURATION_DEFAULT is specified in RFC2407 "The Internet IP
715 * Security Domain of Interpretation for ISAKMP" 4.5. It applies when
716 * an ISAKMP negotiation does not explicitly specify a life duration.
717 * PLUTO_SA_LIFE_DURATION_DEFAULT is specified in pluto(8). It applies
718 * when a connection description does not specify --ipseclifetime.
719 * The value of SA_LIFE_DURATION_MAXIMUM is our local policy.
722 extern enum_names sa_lifetime_names;
724 #define SA_LIFE_TYPE_SECONDS 1
725 #define SA_LIFE_TYPE_KBYTES 2
727 #define SA_LIFE_DURATION_DEFAULT 28800 /* eight hours (RFC2407 4.5) */
728 #define PLUTO_SA_LIFE_DURATION_DEFAULT 28800 /* eight hours (pluto(8)) */
729 #define SA_LIFE_DURATION_MAXIMUM 86400 /* one day */
731 #define SA_REPLACEMENT_MARGIN_DEFAULT 540 /* (IPSEC & IKE) nine minutes */
732 #define SA_REPLACEMENT_FUZZ_DEFAULT 100 /* (IPSEC & IKE) 100% of MARGIN */
733 #define SA_REPLACEMENT_RETRIES_DEFAULT 3 /* (IPSEC & IKE) */
735 #define SA_LIFE_DURATION_K_DEFAULT 0xFFFFFFFFlu
737 /* Encapsulation Mode attribute */
739 extern enum_names enc_mode_names;
741 #define ENCAPSULATION_MODE_UNSPECIFIED 0 /* not legal -- used internally */
742 #define ENCAPSULATION_MODE_TUNNEL 1
743 #define ENCAPSULATION_MODE_TRANSPORT 2
746 #define ENCAPSULATION_MODE_UDP_TUNNEL_DRAFTS 61443
747 #define ENCAPSULATION_MODE_UDP_TRANSPORT_DRAFTS 61444
748 #define ENCAPSULATION_MODE_UDP_TUNNEL_RFC 3
749 #define ENCAPSULATION_MODE_UDP_TRANSPORT_RFC 4
752 /* Auth Algorithm attribute */
754 extern enum_names auth_alg_names, extended_auth_alg_names;
756 #define AUTH_ALGORITHM_NONE 0 /* our private designation */
757 #define AUTH_ALGORITHM_HMAC_MD5 1
758 #define AUTH_ALGORITHM_HMAC_SHA1 2
759 #define AUTH_ALGORITHM_DES_MAC 3
760 #define AUTH_ALGORITHM_KPDK 4
761 #define AUTH_ALGORITHM_HMAC_SHA2_256 5
762 #define AUTH_ALGORITHM_HMAC_SHA2_384 6
763 #define AUTH_ALGORITHM_HMAC_SHA2_512 7
764 #define AUTH_ALGORITHM_HMAC_RIPEMD 8
767 /* Oakley Lifetime Type attribute
768 * draft-ietf-ipsec-ike-01.txt appendix A
769 * As far as I can see, there is not specification for
770 * OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT. This could lead to interop problems!
771 * For no particular reason, we chose one hour.
772 * The value of OAKLEY_ISAKMP_SA_LIFETIME_MAXIMUM is our local policy.
774 extern enum_names oakley_lifetime_names;
776 #define OAKLEY_LIFE_SECONDS 1
777 #define OAKLEY_LIFE_KILOBYTES 2
779 #define OAKLEY_ISAKMP_SA_LIFETIME_DEFAULT 3600 /* one hour */
780 #define OAKLEY_ISAKMP_SA_LIFETIME_MAXIMUM 86400 /* one day */
782 /* Oakley PRF attribute (none defined)
783 * draft-ietf-ipsec-ike-01.txt appendix A
785 extern enum_names oakley_prf_names;
787 /* HMAC (see rfc2104.txt) */
789 #define HMAC_IPAD 0x36
790 #define HMAC_OPAD 0x5C
791 #define HMAC_BUFSIZE 64
793 /* Oakley Encryption Algorithm attribute
794 * draft-ietf-ipsec-ike-01.txt appendix A
795 * and from http://www.isi.edu/in-notes/iana/assignments/ipsec-registry
798 extern enum_names oakley_enc_names;
800 #define OAKLEY_DES_CBC 1
801 #define OAKLEY_IDEA_CBC 2
802 #define OAKLEY_BLOWFISH_CBC 3
803 #define OAKLEY_RC5_R16_B64_CBC 4
804 #define OAKLEY_3DES_CBC 5
805 #define OAKLEY_CAST_CBC 6
806 #define OAKLEY_AES_CBC 7
808 #define OAKLEY_ENCRYPT_MAX 65535 /* pretty useless :) */
810 /* Oakley Hash Algorithm attribute
811 * draft-ietf-ipsec-ike-01.txt appendix A
812 * and from http://www.isi.edu/in-notes/iana/assignments/ipsec-registry
815 extern enum_names oakley_hash_names;
819 #define OAKLEY_TIGER 3
820 #define OAKLEY_SHA2_256 4
821 #define OAKLEY_SHA2_384 5
822 #define OAKLEY_SHA2_512 6
824 #define OAKLEY_HASH_MAX 7
826 /* Oakley Authentication Method attribute
827 * draft-ietf-ipsec-ike-01.txt appendix A
828 * Goofy Hybrid extensions from draft-ietf-ipsec-isakmp-hybrid-auth-05.txt
829 * Goofy XAUTH extensions from draft-ietf-ipsec-isakmp-xauth-06.txt
832 extern enum_names oakley_auth_names;
834 #define OAKLEY_PRESHARED_KEY 1
835 #define OAKLEY_DSS_SIG 2
836 #define OAKLEY_RSA_SIG 3
837 #define OAKLEY_RSA_ENC 4
838 #define OAKLEY_RSA_ENC_REV 5
839 #define OAKLEY_ELGAMAL_ENC 6
840 #define OAKLEY_ELGAMAL_ENC_REV 7
842 #define OAKLEY_AUTH_ROOF 8 /* roof on auth values THAT WE SUPPORT */
844 #define HybridInitRSA 64221
845 #define HybridRespRSA 64222
846 #define HybridInitDSS 64223
847 #define HybridRespDSS 64224
849 #define XAUTHInitPreShared 65001
850 #define XAUTHRespPreShared 65002
851 #define XAUTHInitDSS 65003
852 #define XAUTHRespDSS 65004
853 #define XAUTHInitRSA 65005
854 #define XAUTHRespRSA 65006
855 #define XAUTHInitRSAEncryption 65007
856 #define XAUTHRespRSAEncryption 65008
857 #define XAUTHInitRSARevisedEncryption 65009
858 #define XAUTHRespRSARevisedEncryption 65010
860 /* Oakley Group Description attribute
861 * draft-ietf-ipsec-ike-01.txt appendix A
863 extern enum_names oakley_group_names;
865 #define OAKLEY_GROUP_MODP768 1
866 #define OAKLEY_GROUP_MODP1024 2
867 #define OAKLEY_GROUP_GP155 3
868 #define OAKLEY_GROUP_GP185 4
869 #define OAKLEY_GROUP_MODP1536 5
871 /* you must also touch: constants.c, crypto.c */
872 #define OAKLEY_GROUP_MODP2048 42048
873 #define OAKLEY_GROUP_MODP3072 43072
874 #define OAKLEY_GROUP_MODP4096 44096
876 /* Oakley Group Type attribute
877 * draft-ietf-ipsec-ike-01.txt appendix A
879 extern enum_names oakley_group_type_names;
881 #define OAKLEY_GROUP_TYPE_MODP 1
882 #define OAKLEY_GROUP_TYPE_ECP 2
883 #define OAKLEY_GROUP_TYPE_EC2N 3
886 /* Notify messages -- error types
887 * See RFC2408 ISAKMP 3.14.1
890 extern enum_names notification_names;
891 extern enum_names ipsec_notification_names;
894 NOTHING_WRONG = 0, /* unofficial! */
896 INVALID_PAYLOAD_TYPE = 1,
897 DOI_NOT_SUPPORTED = 2,
898 SITUATION_NOT_SUPPORTED = 3,
900 INVALID_MAJOR_VERSION = 5,
901 INVALID_MINOR_VERSION = 6,
902 INVALID_EXCHANGE_TYPE = 7,
904 INVALID_MESSAGE_ID = 9,
905 INVALID_PROTOCOL_ID = 10,
907 INVALID_TRANSFORM_ID = 12,
908 ATTRIBUTES_NOT_SUPPORTED = 13,
909 NO_PROPOSAL_CHOSEN = 14,
910 BAD_PROPOSAL_SYNTAX = 15,
911 PAYLOAD_MALFORMED = 16,
912 INVALID_KEY_INFORMATION = 17,
913 INVALID_ID_INFORMATION = 18,
914 INVALID_CERT_ENCODING = 19,
915 INVALID_CERTIFICATE = 20,
916 CERT_TYPE_UNSUPPORTED = 21,
917 INVALID_CERT_AUTHORITY = 22,
918 INVALID_HASH_INFORMATION = 23,
919 AUTHENTICATION_FAILED = 24,
920 INVALID_SIGNATURE = 25,
921 ADDRESS_NOTIFICATION = 26,
922 NOTIFY_SA_LIFETIME = 27,
923 CERTIFICATE_UNAVAILABLE = 28,
924 UNSUPPORTED_EXCHANGE_TYPE = 29,
925 UNEQUAL_PAYLOAD_LENGTHS = 30,
927 /* ISAKMP status type */
930 /* IPSEC DOI additions; status types (RFC2407 IPSEC DOI 4.6.3)
931 * These must be sent under the protection of an ISAKMP SA.
933 IPSEC_RESPONDER_LIFETIME = 24576,
934 IPSEC_REPLAY_STATUS = 24577,
935 IPSEC_INITIAL_CONTACT = 24578,
937 /* DPD notification types */
939 R_U_THERE_ACK = 36137
943 /* Public key algorithm number
944 * Same numbering as used in DNSsec
945 * See RFC 2535 DNSsec 3.2 The KEY Algorithm Number Specification.
946 * Also found in BIND 8.2.2 include/isc/dst.h as DST algorithm codes.
955 /* Limits on size of RSA moduli.
956 * The upper bound matches that of DNSsec (see RFC 2537).
957 * The lower bound must be more than 11 octets for certain
958 * the encoding to work, but it must be much larger for any
959 * real security. For now, we require 512 bits.
962 #define RSA_MIN_OCTETS_RFC 12
964 #define RSA_MIN_OCTETS (512 / BITS_PER_BYTE)
965 #define RSA_MIN_OCTETS_UGH "RSA modulus too small for security: less than 512 bits"
967 #define RSA_MAX_OCTETS (4096 / BITS_PER_BYTE)
968 #define RSA_MAX_OCTETS_UGH "RSA modulus too large: more than 4096 bits"
970 /* socket address family info */
979 u_int8_t id_addr, id_subnet, id_range;
980 const ip_address *any;
981 const ip_subnet *wildcard; /* 0.0.0.0/32 or IPv6 equivalent */
982 const ip_subnet *all; /* 0.0.0.0/0 or IPv6 equivalent */
985 extern const struct af_info
989 extern const struct af_info *aftoinfo(int af);
991 extern enum_names af_names;
993 /* BIND enumerated types */
1000 /* How authenticated is info that might have come from DNS?
1001 * In order of increasing confidence.
1003 enum dns_auth_level {
1004 DAL_UNSIGNED, /* AD in response, but no signature: no authentication */
1005 DAL_NOTSEC, /* no AD in response: authentication impossible */
1006 DAL_SIGNED, /* AD and signature in response: authentic */
1007 DAL_LOCAL /* locally provided (pretty good) */
1011 #define NUM_INTERFACES 4
1012 extern char *phys_interfaces[NUM_INTERFACES];