]> git.saurik.com Git - apple/network_cmds.git/blob - racoon.tproj/isakmp.h
d4e3afbac34a7b9947ce3c855a865f377fdd82b5
[apple/network_cmds.git] / racoon.tproj / isakmp.h
1 /* $KAME: isakmp.h,v 1.18 2001/03/26 17:27:40 thorpej 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 /* refer to RFC 2408 */
33
34 /* must include <netinet/in.h> first. */
35 /* must include "isakmp_var.h" first. */
36
37 #define INITIATOR 0 /* synonym sender */
38 #define RESPONDER 1 /* synonym receiver */
39
40 #define GENERATE 1
41 #define VALIDATE 0
42
43 /* 3.1 ISAKMP Header Format
44 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
45 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 ! Initiator !
47 ! Cookie !
48 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 ! Responder !
50 ! Cookie !
51 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 ! Next Payload ! MjVer ! MnVer ! Exchange Type ! Flags !
53 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 ! Message ID !
55 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 ! Length !
57 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
58 */
59 struct isakmp {
60 cookie_t i_ck; /* Initiator Cookie */
61 cookie_t r_ck; /* Responder Cookie */
62 u_int8_t np; /* Next Payload Type */
63 u_int8_t v;
64 u_int8_t etype; /* Exchange Type */
65 u_int8_t flags; /* Flags */
66 u_int32_t msgid;
67 u_int32_t len; /* Length */
68 } __attribute__((__packed__));
69
70 /* Next Payload Type */
71 #define ISAKMP_NPTYPE_NONE 0 /* NONE*/
72 #define ISAKMP_NPTYPE_SA 1 /* Security Association */
73 #define ISAKMP_NPTYPE_P 2 /* Proposal */
74 #define ISAKMP_NPTYPE_T 3 /* Transform */
75 #define ISAKMP_NPTYPE_KE 4 /* Key Exchange */
76 #define ISAKMP_NPTYPE_ID 5 /* Identification */
77 #define ISAKMP_NPTYPE_CERT 6 /* Certificate */
78 #define ISAKMP_NPTYPE_CR 7 /* Certificate Request */
79 #define ISAKMP_NPTYPE_HASH 8 /* Hash */
80 #define ISAKMP_NPTYPE_SIG 9 /* Signature */
81 #define ISAKMP_NPTYPE_NONCE 10 /* Nonce */
82 #define ISAKMP_NPTYPE_N 11 /* Notification */
83 #define ISAKMP_NPTYPE_D 12 /* Delete */
84 #define ISAKMP_NPTYPE_VID 13 /* Vendor ID */
85 #define ISAKMP_NPTYPE_MAX 14
86 /* 128 - 255 Private Use */
87
88 /*
89 * The following are valid when the Vendor ID is one of the
90 * following:
91 *
92 * MD5("A GSS-API Authentication Method for IKE")
93 * MD5("GSSAPI") (recognized by Windows 2000)
94 * MD5("MS NT5 ISAKMPOAKLEY") (sent by Windows 2000)
95 *
96 * See draft-ietf-ipsec-isakmp-gss-auth-06.txt.
97 */
98 #define ISAKMP_NPTYPE_GSS 129 /* GSS token */
99
100 #define ISAKMP_MAJOR_VERSION 1
101 #define ISAKMP_MINOR_VERSION 0
102 #define ISAKMP_VERSION_NUMBER 0x10
103 #define ISAKMP_GETMAJORV(v) (((v) & 0xf0) >> 4)
104 #define ISAKMP_SETMAJORV(v, m) ((v) = ((v) & 0x0f) | (((m) << 4) & 0xf0))
105 #define ISAKMP_GETMINORV(v) ((v) & 0x0f)
106 #define ISAKMP_SETMINORV(v, m) ((v) = ((v) & 0xf0) | ((m) & 0x0f))
107
108 /* Exchange Type */
109 #define ISAKMP_ETYPE_NONE 0 /* NONE */
110 #define ISAKMP_ETYPE_BASE 1 /* Base */
111 #define ISAKMP_ETYPE_IDENT 2 /* Identity Proteciton */
112 #define ISAKMP_ETYPE_AUTH 3 /* Authentication Only */
113 #define ISAKMP_ETYPE_AGG 4 /* Aggressive */
114 #define ISAKMP_ETYPE_INFO 5 /* Informational */
115 /* Additional Exchange Type */
116 #define ISAKMP_ETYPE_QUICK 32 /* Quick Mode */
117 #define ISAKMP_ETYPE_NEWGRP 33 /* New group Mode */
118 #define ISAKMP_ETYPE_ACKINFO 34 /* Acknowledged Informational */
119
120 /* Flags */
121 #define ISAKMP_FLAG_E 0x01 /* Encryption Bit */
122 #define ISAKMP_FLAG_C 0x02 /* Commit Bit */
123 #define ISAKMP_FLAG_A 0x04 /* Authentication Only Bit */
124
125 /* 3.2 Payload Generic Header
126 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
127 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
128 ! Next Payload ! RESERVED ! Payload Length !
129 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
130 */
131 struct isakmp_gen {
132 u_int8_t np; /* Next Payload */
133 u_int8_t reserved; /* RESERVED, unused, must set to 0 */
134 u_int16_t len; /* Payload Length */
135 } __attribute__((__packed__));
136
137 /* 3.3 Data Attributes
138 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
139 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
140 !A! Attribute Type ! AF=0 Attribute Length !
141 !F! ! AF=1 Attribute Value !
142 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
143 . AF=0 Attribute Value .
144 . AF=1 Not Transmitted .
145 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
146 */
147 struct isakmp_data {
148 u_int16_t type; /* defined by DOI-spec, and Attribute Format */
149 u_int16_t lorv; /* if f equal 1, Attribute Length */
150 /* if f equal 0, Attribute Value */
151 /* if f equal 1, Attribute Value */
152 } __attribute__((__packed__));
153 #define ISAKMP_GEN_TLV 0x0000
154 #define ISAKMP_GEN_TV 0x8000
155 /* mask for type of attribute format */
156 #define ISAKMP_GEN_MASK 0x8000
157
158 #if 0
159 /* MAY NOT be used, because of being defined in ipsec-doi. */
160 /* 3.4 Security Association Payload */
161 struct isakmp_pl_sa {
162 struct isakmp_gen h;
163 u_int32_t doi; /* Domain of Interpretation */
164 u_int32_t sit; /* Situation */
165 } __attribute__((__packed__));
166 #endif
167
168 /* 3.5 Proposal Payload */
169 /*
170 The value of the next payload field MUST only contain the value "2"
171 or "0". If there are additional Proposal payloads in the message,
172 then this field will be 2. If the current Proposal payload is the
173 last within the security association proposal, then this field will
174 be 0.
175 */
176 struct isakmp_pl_p {
177 struct isakmp_gen h;
178 u_int8_t p_no; /* Proposal # */
179 u_int8_t proto_id; /* Protocol */
180 u_int8_t spi_size; /* SPI Size */
181 u_int8_t num_t; /* Number of Transforms */
182 /* SPI */
183 } __attribute__((__packed__));
184
185 /* 3.6 Transform Payload */
186 /*
187 The value of the next payload field MUST only contain the value "3"
188 or "0". If there are additional Transform payloads in the proposal,
189 then this field will be 3. If the current Transform payload is the
190 last within the proposal, then this field will be 0.
191 */
192 struct isakmp_pl_t {
193 struct isakmp_gen h;
194 u_int8_t t_no; /* Transform # */
195 u_int8_t t_id; /* Transform-Id */
196 u_int16_t reserved; /* RESERVED2 */
197 /* SA Attributes */
198 } __attribute__((__packed__));
199
200 /* 3.7 Key Exchange Payload */
201 struct isakmp_pl_ke {
202 struct isakmp_gen h;
203 /* Key Exchange Data */
204 } __attribute__((__packed__));
205
206 #if 0
207 /* NOTE: MUST NOT use because of being defined in ipsec-doi instead them. */
208 /* 3.8 Identification Payload */
209 struct isakmp_pl_id {
210 struct isakmp_gen h;
211 union {
212 u_int8_t id_type; /* ID Type */
213 u_int32_t doi_data; /* DOI Specific ID Data */
214 } d;
215 /* Identification Data */
216 } __attribute__((__packed__));
217 /* A.4 ISAKMP Identification Type Values */
218 #define ISAKMP_ID_IPV4_ADDR 0
219 #define ISAKMP_ID_IPV4_ADDR_SUBNET 1
220 #define ISAKMP_ID_IPV6_ADDR 2
221 #define ISAKMP_ID_IPV6_ADDR_SUBNET 3
222 #endif
223
224 /* 3.9 Certificate Payload */
225 struct isakmp_pl_cert {
226 struct isakmp_gen h;
227 /*
228 * Encoding type of 1 octet follows immediately,
229 * variable length CERT data follows encoding type.
230 */
231 } __attribute__((__packed__));
232
233 /* Certificate Type */
234 #define ISAKMP_CERT_NONE 0
235 #define ISAKMP_CERT_PKCS7 1
236 #define ISAKMP_CERT_PGP 2
237 #define ISAKMP_CERT_DNS 3
238 #define ISAKMP_CERT_X509SIGN 4
239 #define ISAKMP_CERT_X509KE 5
240 #define ISAKMP_CERT_KERBEROS 6
241 #define ISAKMP_CERT_CRL 7
242 #define ISAKMP_CERT_ARL 8
243 #define ISAKMP_CERT_SPKI 9
244 #define ISAKMP_CERT_X509ATTR 10
245
246 /* the method to get peers certificate */
247 #define ISAKMP_GETCERT_PAYLOAD 1
248 #define ISAKMP_GETCERT_LOCALFILE 2
249 #define ISAKMP_GETCERT_DNS 3
250
251 /* 3.10 Certificate Request Payload */
252 struct isakmp_pl_cr {
253 struct isakmp_gen h;
254 u_int8_t num_cert; /* # Cert. Types */
255 /*
256 Certificate Types (variable length)
257 -- Contains a list of the types of certificates requested,
258 sorted in order of preference. Each individual certificate
259 type is 1 octet. This field is NOT required.
260 */
261 /* # Certificate Authorities (1 octet) */
262 /* Certificate Authorities (variable length) */
263 } __attribute__((__packed__));
264
265 /* 3.11 Hash Payload */
266 struct isakmp_pl_hash {
267 struct isakmp_gen h;
268 /* Hash Data */
269 } __attribute__((__packed__));
270
271 /* 3.12 Signature Payload */
272 struct isakmp_pl_sig {
273 struct isakmp_gen h;
274 /* Signature Data */
275 } __attribute__((__packed__));
276
277 /* 3.13 Nonce Payload */
278 struct isakmp_pl_nonce {
279 struct isakmp_gen h;
280 /* Nonce Data */
281 } __attribute__((__packed__));
282
283 /* 3.14 Notification Payload */
284 struct isakmp_pl_n {
285 struct isakmp_gen h;
286 u_int32_t doi; /* Domain of Interpretation */
287 u_int8_t proto_id; /* Protocol-ID */
288 u_int8_t spi_size; /* SPI Size */
289 u_int16_t type; /* Notify Message Type */
290 /* SPI */
291 /* Notification Data */
292 } __attribute__((__packed__));
293
294 /* 3.14.1 Notify Message Types */
295 /* NOTIFY MESSAGES - ERROR TYPES */
296 #define ISAKMP_NTYPE_INVALID_PAYLOAD_TYPE 1
297 #define ISAKMP_NTYPE_DOI_NOT_SUPPORTED 2
298 #define ISAKMP_NTYPE_SITUATION_NOT_SUPPORTED 3
299 #define ISAKMP_NTYPE_INVALID_COOKIE 4
300 #define ISAKMP_NTYPE_INVALID_MAJOR_VERSION 5
301 #define ISAKMP_NTYPE_INVALID_MINOR_VERSION 6
302 #define ISAKMP_NTYPE_INVALID_EXCHANGE_TYPE 7
303 #define ISAKMP_NTYPE_INVALID_FLAGS 8
304 #define ISAKMP_NTYPE_INVALID_MESSAGE_ID 9
305 #define ISAKMP_NTYPE_INVALID_PROTOCOL_ID 10
306 #define ISAKMP_NTYPE_INVALID_SPI 11
307 #define ISAKMP_NTYPE_INVALID_TRANSFORM_ID 12
308 #define ISAKMP_NTYPE_ATTRIBUTES_NOT_SUPPORTED 13
309 #define ISAKMP_NTYPE_NO_PROPOSAL_CHOSEN 14
310 #define ISAKMP_NTYPE_BAD_PROPOSAL_SYNTAX 15
311 #define ISAKMP_NTYPE_PAYLOAD_MALFORMED 16
312 #define ISAKMP_NTYPE_INVALID_KEY_INFORMATION 17
313 #define ISAKMP_NTYPE_INVALID_ID_INFORMATION 18
314 #define ISAKMP_NTYPE_INVALID_CERT_ENCODING 19
315 #define ISAKMP_NTYPE_INVALID_CERTIFICATE 20
316 #define ISAKMP_NTYPE_BAD_CERT_REQUEST_SYNTAX 21
317 #define ISAKMP_NTYPE_INVALID_CERT_AUTHORITY 22
318 #define ISAKMP_NTYPE_INVALID_HASH_INFORMATION 23
319 #define ISAKMP_NTYPE_AUTHENTICATION_FAILED 24
320 #define ISAKMP_NTYPE_INVALID_SIGNATURE 25
321 #define ISAKMP_NTYPE_ADDRESS_NOTIFICATION 26
322 #define ISAKMP_NTYPE_NOTIFY_SA_LIFETIME 27
323 #define ISAKMP_NTYPE_CERTIFICATE_UNAVAILABLE 28
324 #define ISAKMP_NTYPE_UNSUPPORTED_EXCHANGE_TYPE 29
325 #define ISAKMP_NTYPE_UNEQUAL_PAYLOAD_LENGTHS 30
326 /* NOTIFY MESSAGES - STATUS TYPES */
327 #define ISAKMP_NTYPE_CONNECTED 16384
328 /* 4.6.3 IPSEC DOI Notify Message Types */
329 #define ISAKMP_NTYPE_RESPONDER_LIFETIME 24576
330 #define ISAKMP_NTYPE_REPLAY_STATUS 24577
331 #define ISAKMP_NTYPE_INITIAL_CONTACT 24578
332
333 /* using only to log */
334 #define ISAKMP_LOG_RETRY_LIMIT_REACHED 65530
335
336 /* XXX means internal error but it's not reserved by any drafts... */
337 #define ISAKMP_INTERNAL_ERROR -1
338
339 /* 3.15 Delete Payload */
340 struct isakmp_pl_d {
341 struct isakmp_gen h;
342 u_int32_t doi; /* Domain of Interpretation */
343 u_int8_t proto_id; /* Protocol-Id */
344 u_int8_t spi_size; /* SPI Size */
345 u_int16_t num_spi; /* # of SPIs */
346 /* SPI(es) */
347 } __attribute__((__packed__));
348