]> git.saurik.com Git - apple/ipsec.git/blob - ipsec-tools/racoon/ipsec_doi.h
ipsec-164.9.tar.gz
[apple/ipsec.git] / ipsec-tools / racoon / ipsec_doi.h
1 /* $Id: ipsec_doi.h,v 1.9.2.2 2005/10/17 16:23:50 monas Exp $ */
2
3 /*
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the project nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32 #ifndef _IPSEC_DOI_H
33 #define _IPSEC_DOI_H
34
35 /* refered to RFC2407 */
36
37 #define IPSEC_DOI 1
38
39 /* 4.2 IPSEC Situation Definition */
40 #define IPSECDOI_SIT_IDENTITY_ONLY 0x00000001
41 #define IPSECDOI_SIT_SECRECY 0x00000002
42 #define IPSECDOI_SIT_INTEGRITY 0x00000004
43
44 /* 4.4.1 IPSEC Security Protocol Identifiers */
45 /* 4.4.2 IPSEC ISAKMP Transform Values */
46 #define IPSECDOI_PROTO_ISAKMP 1
47 #define IPSECDOI_KEY_IKE 1
48
49 /* 4.4.1 IPSEC Security Protocol Identifiers */
50 #define IPSECDOI_PROTO_IPSEC_AH 2
51 /* 4.4.3 IPSEC AH Transform Values */
52 #define IPSECDOI_AH_MD5 2
53 #define IPSECDOI_AH_SHA 3
54 #define IPSECDOI_AH_DES 4
55 #define IPSECDOI_AH_SHA256 5
56 #define IPSECDOI_AH_SHA384 6
57 #define IPSECDOI_AH_SHA512 7
58
59 /* 4.4.1 IPSEC Security Protocol Identifiers */
60 #define IPSECDOI_PROTO_IPSEC_ESP 3
61 /* 4.4.4 IPSEC ESP Transform Identifiers */
62 #define IPSECDOI_ESP_DES_IV64 1
63 #define IPSECDOI_ESP_DES 2
64 #define IPSECDOI_ESP_3DES 3
65 #define IPSECDOI_ESP_RC5 4
66 #define IPSECDOI_ESP_IDEA 5
67 #define IPSECDOI_ESP_CAST 6
68 #define IPSECDOI_ESP_BLOWFISH 7
69 #define IPSECDOI_ESP_3IDEA 8
70 #define IPSECDOI_ESP_DES_IV32 9
71 #define IPSECDOI_ESP_RC4 10
72 #define IPSECDOI_ESP_NULL 11
73 #define IPSECDOI_ESP_AES 12
74 #if 1
75 /* draft-ietf-ipsec-ciph-aes-cbc-00.txt */
76 #define IPSECDOI_ESP_TWOFISH 253
77 #else
78 /* SSH uses these value for now */
79 #define IPSECDOI_ESP_TWOFISH 250
80 #endif
81
82 /* 4.4.1 IPSEC Security Protocol Identifiers */
83 #define IPSECDOI_PROTO_IPCOMP 4
84 /* 4.4.5 IPSEC IPCOMP Transform Identifiers */
85 #define IPSECDOI_IPCOMP_OUI 1
86 #define IPSECDOI_IPCOMP_DEFLATE 2
87 #define IPSECDOI_IPCOMP_LZS 3
88
89 /* 4.5 IPSEC Security Association Attributes */
90 /* NOTE: default value is not included in a packet. */
91 #define IPSECDOI_ATTR_SA_LD_TYPE 1 /* B */
92 #define IPSECDOI_ATTR_SA_LD_TYPE_DEFAULT 1
93 #define IPSECDOI_ATTR_SA_LD_TYPE_SEC 1
94 #define IPSECDOI_ATTR_SA_LD_TYPE_KB 2
95 #define IPSECDOI_ATTR_SA_LD_TYPE_MAX 3
96 #define IPSECDOI_ATTR_SA_LD 2 /* V */
97 #define IPSECDOI_ATTR_SA_LD_SEC_DEFAULT 28800 /* 8 hours */
98 #define IPSECDOI_ATTR_SA_LD_KB_MAX (~(1 << ((sizeof(int) << 3) - 1)))
99 #define IPSECDOI_ATTR_GRP_DESC 3 /* B */
100 #define IPSECDOI_ATTR_ENC_MODE 4 /* B */
101 /* default value: host dependent */
102 #define IPSECDOI_ATTR_ENC_MODE_ANY 0 /* NOTE:internal use */
103 #define IPSECDOI_ATTR_ENC_MODE_TUNNEL 1
104 #define IPSECDOI_ATTR_ENC_MODE_TRNS 2
105
106 /* NAT-T draft-ietf-ipsec-nat-t-ike-05 and later */
107 #define IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_RFC 3
108 #define IPSECDOI_ATTR_ENC_MODE_UDPTRNS_RFC 4
109
110 /* NAT-T up to draft-ietf-ipsec-nat-t-ike-04 */
111 #define IPSECDOI_ATTR_ENC_MODE_UDPTUNNEL_DRAFT 61443
112 #define IPSECDOI_ATTR_ENC_MODE_UDPTRNS_DRAFT 61444
113
114 #define IPSECDOI_ATTR_AUTH 5 /* B */
115 /* 0 means not to use authentication. */
116 #define IPSECDOI_ATTR_AUTH_HMAC_MD5 1
117 #define IPSECDOI_ATTR_AUTH_HMAC_SHA1 2
118 #define IPSECDOI_ATTR_AUTH_DES_MAC 3
119 #define IPSECDOI_ATTR_AUTH_KPDK 4 /*RFC-1826(Key/Pad/Data/Key)*/
120 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_256 5
121 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_384 6
122 #define IPSECDOI_ATTR_AUTH_HMAC_SHA2_512 7
123 #define IPSECDOI_ATTR_AUTH_NONE 254 /* NOTE:internal use */
124 /*
125 * When negotiating ESP without authentication, the Auth
126 * Algorithm attribute MUST NOT be included in the proposal.
127 * When negotiating ESP without confidentiality, the Auth
128 * Algorithm attribute MUST be included in the proposal and
129 * the ESP transform ID must be ESP_NULL.
130 */
131 #define IPSECDOI_ATTR_KEY_LENGTH 6 /* B */
132 #define IPSECDOI_ATTR_KEY_ROUNDS 7 /* B */
133 #define IPSECDOI_ATTR_COMP_DICT_SIZE 8 /* B */
134 #define IPSECDOI_ATTR_COMP_PRIVALG 9 /* V */
135
136 /* 4.6.1 Security Association Payload */
137 struct ipsecdoi_pl_sa {
138 struct isakmp_gen h;
139 struct ipsecdoi_sa_b {
140 u_int32_t doi; /* Domain of Interpretation */
141 u_int32_t sit; /* Situation */
142 } b;
143 /* followed by Leveled Domain Identifier and so on. */
144 } __attribute__((__packed__));
145
146 struct ipsecdoi_secrecy_h {
147 u_int16_t len;
148 u_int16_t reserved;
149 /* followed by the value */
150 } __attribute__((__packed__));
151
152 /* 4.6.2 Identification Payload Content */
153 struct ipsecdoi_pl_id {
154 struct isakmp_gen h;
155 struct ipsecdoi_id_b {
156 u_int8_t type; /* ID Type */
157 u_int8_t proto_id; /* Protocol ID */
158 u_int16_t port; /* Port */
159 } b;
160 /* followed by Identification Data */
161 } __attribute__((__packed__));
162
163 #define IPSECDOI_ID_IPV4_ADDR 1
164 #define IPSECDOI_ID_FQDN 2
165 #define IPSECDOI_ID_USER_FQDN 3
166 #define IPSECDOI_ID_IPV4_ADDR_SUBNET 4
167 #define IPSECDOI_ID_IPV6_ADDR 5
168 #define IPSECDOI_ID_IPV6_ADDR_SUBNET 6
169 #define IPSECDOI_ID_IPV4_ADDR_RANGE 7
170 #define IPSECDOI_ID_IPV6_ADDR_RANGE 8
171 #define IPSECDOI_ID_DER_ASN1_DN 9
172 #define IPSECDOI_ID_DER_ASN1_GN 10
173 #define IPSECDOI_ID_KEY_ID 11
174
175 /* compressing doi type, it's internal use. */
176 #define IDTYPE_UNDEFINED 0
177 #define IDTYPE_FQDN 1
178 #define IDTYPE_USERFQDN 2
179 #define IDTYPE_KEYID 3
180 #define IDTYPE_ADDRESS 4
181 #define IDTYPE_ASN1DN 5
182 #define IDTYPE_LOGIN 6
183 #define IDTYPE_SUBNET 7
184 #define IDTYPE_KEYIDUSE 8
185
186 /* shared secret type, it's internal use. */
187 #define SECRETTYPE_USE 0
188 #define SECRETTYPE_KEY 1
189 #define SECRETTYPE_KEYCHAIN 2
190 #define SECRETTYPE_KEYCHAIN_BY_ID 3
191
192 /* verification modules */
193 #define VERIFICATION_MODULE_OPENSSL 0
194 #define VERIFICATION_MODULE_SEC_FRAMEWORK 1
195
196 /* verification options */
197 #define VERIFICATION_OPTION_NONE 0
198 #define VERIFICATION_OPTION_PEERS_IDENTIFIER 1
199 #define VERIFICATION_OPTION_OPEN_DIR 2
200
201 /* qualifiers for KEYID (and maybe others) */
202 #define IDQUAL_UNSPEC 0
203 #define IDQUAL_FILE 1
204 #define IDQUAL_TAG 2
205
206
207 /* The use for checking proposal payload. This is not exchange type. */
208 #define IPSECDOI_TYPE_PH1 0
209 #define IPSECDOI_TYPE_PH2 1
210
211 struct isakmpsa;
212 struct ipsecdoi_pl_sa;
213 struct saprop;
214 struct saproto;
215 struct satrns;
216 struct prop_pair;
217
218 extern int ipsecdoi_checkph1proposal __P((vchar_t *, struct ph1handle *));
219 extern int ipsecdoi_selectph2proposal __P((struct ph2handle *));
220 extern int ipsecdoi_checkph2proposal __P((struct ph2handle *));
221
222 extern struct prop_pair **get_proppair __P((vchar_t *, int));
223 extern vchar_t *get_sabyproppair __P((struct prop_pair *, struct ph1handle *));
224 extern int ipsecdoi_updatespi __P((struct ph2handle *iph2));
225 extern vchar_t *get_sabysaprop __P((struct saprop *, vchar_t *));
226 extern int ipsecdoi_chkcmpids( const vchar_t *, const vchar_t *, int );
227 extern int ipsecdoi_checkid1 __P((struct ph1handle *));
228 extern int ipsecdoi_setid1 __P((struct ph1handle *));
229 extern int set_identifier __P((vchar_t **, int, vchar_t *));
230 extern int set_identifier_qual __P((vchar_t **, int, vchar_t *, int));
231 extern int ipsecdoi_setid2 __P((struct ph2handle *));
232 extern vchar_t *ipsecdoi_sockaddr2id __P((struct sockaddr_storage *, u_int, u_int));
233 extern int ipsecdoi_id2sockaddr __P((vchar_t *, struct sockaddr_storage *,
234 u_int8_t *, u_int16_t *));
235 extern char *ipsecdoi_id2str __P((const vchar_t *));
236 extern vchar_t *ipsecdoi_sockrange2id __P(( struct sockaddr_storage *,
237 struct sockaddr_storage *, u_int));
238
239 extern vchar_t *ipsecdoi_setph1proposal __P((struct isakmpsa *));
240 extern int ipsecdoi_setph2proposal __P((struct ph2handle *));
241 extern int ipsecdoi_transportmode __P((struct saprop *));
242 extern int ipsecdoi_tunnelmode __P((struct ph2handle *));
243 extern int ipsecdoi_any_transportmode __P((struct saprop *));
244 extern int ipsecdoi_get_defaultlifetime __P((void));
245 extern int ipsecdoi_checkalgtypes __P((int, int, int, int));
246 extern int ipproto2doi __P((int));
247 extern int doi2ipproto __P((int));
248
249 extern int ipsecdoi_t2satrns __P((struct isakmp_pl_t *,
250 struct saprop *, struct saproto *, struct satrns *));
251 extern int ipsecdoi_authalg2trnsid __P((int));
252 extern int idtype2doi __P((int));
253 extern int doi2idtype __P((int));
254
255
256 #endif /* _IPSEC_DOI_H */