1 /* $NetBSD: proposal.h,v 1.5 2006/12/05 13:38:40 vanhu Exp $ */
3 /* Id: proposal.h,v 1.5 2004/06/11 16:00:17 ludvigm Exp */
6 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the project nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 #include <sys/queue.h>
40 * A. chained list of transform, only for single proto_id
41 * (this is same as set of transforms in single proposal payload)
42 * B. proposal. this will point to multiple (A) items (order is important
43 * here so pointer to (A) must be ordered array, or chained list).
44 * this covers multiple proposal on a packet if proposal # is the same.
45 * C. finally, (B) needs to be connected as chained list.
47 * head ---> prop[.......] ---> prop[...] ---> prop[...] ---> ...
49 * | | | +- proto4 <== must preserve order here
52 * +------- proto1[trans1, trans2, trans3, ...]
54 * incoming packets needs to be parsed to construct the same structure
55 * (check "prop_pair" too).
57 /* SA proposal specification */
62 int pfs_group
; /* pfs group */
63 int claim
; /* flag to send RESPONDER-LIFETIME. */
64 /* XXX assumed DOI values are 1 or 2. */
66 struct security_ctx sctx
; /* security context structure */
72 /* SA protocol specification */
75 size_t spisize
; /* spi size */
76 int encmode
; /* encryption mode */
78 int udp_encap
; /* UDP encapsulation */
80 /* XXX should be vchar_t * */
81 /* these are network byte order */
82 u_int32_t spi
; /* inbound. i.e. --SA-> me */
83 u_int32_t spi_p
; /* outbound. i.e. me -SA-> */
85 vchar_t
*keymat
; /* KEYMAT */
86 vchar_t
*keymat_p
; /* peer's KEYMAT */
88 int reqid_out
; /* request id (outbound) */
89 int reqid_in
; /* request id (inbound) */
91 int ok
; /* if 1, success to set SA in kenrel */
93 struct satrns
*head
; /* header of transform */
94 struct saproto
*next
; /* next protocol */
97 /* SA algorithm specification */
100 int trns_id
; /* transform id */
101 int encklen
; /* key length of encryption algorithm */
102 int authtype
; /* authentication algorithm if ESP */
104 struct satrns
*next
; /* next transform */
108 * prop_pair: (proposal number, transform number)
110 * (SA (P1 (T1 T2)) (P1' (T1' T2')) (P2 (T1" T2")))
113 * top (P1,T1) (P2",T1")
116 * | (P1, T2) (P2", T2")
123 * when we convert it to saprop in prop2saprop(), it should become like:
126 * saprop --------------------> saprop
128 * +-> saproto +-> saproto
129 * | | (head) | (head)
130 * | +-> satrns(P1 T1) +-> satrns(P2" T1")
131 * | | (next) | (next)
133 * | satrns(P1, T2) satrns(P2", T2")
137 * +-> satrns(P1' T1')
143 struct isakmp_pl_p
*prop
;
144 struct isakmp_pl_t
*trns
;
145 struct prop_pair
*next
; /* next prop_pair with same proposal # */
147 struct prop_pair
*tnext
; /* next prop_pair in same proposal payload */
148 /* (multiple tranform case) */
150 #define MAXPROPPAIRLEN 256 /* It's enough because field size is 1 octet. */
153 * Lifetime length selection refered to the section 4.5.4 of RFC2407. It does
154 * not completely conform to the description of RFC. There are four types of
155 * the behavior. If the value of "proposal_check" in "remote" directive is;
157 * the responder obey the initiator anytime.
159 * If the responder's length is longer than the initiator's one, the
160 * responder uses the intitiator's one. Otherwise rejects the proposal.
161 * If PFS is not required by the responder, the responder obeys the
162 * proposal. If PFS is required by both sides and if the responder's
163 * group is not equal to the initiator's one, then the responder reject
166 * If the responder's length is longer than the initiator's one, the
167 * responder use the intitiator's one. If the responder's length is
168 * shorter than the initiator's one, the responder uses own length
169 * AND send RESPONDER-LIFETIME notify message to a initiator in the
171 * About PFS, this directive is same as "strict".
173 * If the initiator's length is not equal to the responder's one, the
174 * responder rejects the proposal.
175 * If PFS is required and if the responder's group is not equal to
176 * the initiator's one, then the responder reject the proposal.
177 * XXX should be defined the behavior of key length.
179 #define PROP_CHECK_OBEY 1
180 #define PROP_CHECK_STRICT 2
181 #define PROP_CHECK_CLAIM 3
182 #define PROP_CHECK_EXACT 4
187 extern struct saprop
*newsaprop
__P((void));
188 extern struct saproto
*newsaproto
__P((void));
189 extern void inssaprop
__P((struct saprop
**, struct saprop
*));
190 extern void inssaproto
__P((struct saprop
*, struct saproto
*));
191 extern void inssaprotorev
__P((struct saprop
*, struct saproto
*));
192 extern struct satrns
*newsatrns
__P((void));
193 extern void inssatrns
__P((struct saproto
*, struct satrns
*));
194 extern struct saprop
*cmpsaprop_alloc
__P((struct ph1handle
*,
195 const struct saprop
*, const struct saprop
*, int));
196 extern int cmpsaprop
__P((const struct saprop
*, const struct saprop
*));
197 extern int cmpsatrns
__P((int, const struct satrns
*, const struct satrns
*, int));
198 extern int set_satrnsbysainfo
__P((struct saproto
*, struct sainfo
*));
199 extern struct saprop
*aproppair2saprop
__P((struct prop_pair
*));
200 extern void free_proppair
__P((struct prop_pair
**));
201 extern void flushsaprop
__P((struct saprop
*));
202 extern void flushsaproto
__P((struct saproto
*));
203 extern void flushsatrns
__P((struct satrns
*));
204 extern void printsaprop
__P((const int, const struct saprop
*));
205 extern void printsaprop0
__P((const int, const struct saprop
*));
206 extern void printsaproto
__P((const int, const struct saproto
*));
207 extern void printsatrns
__P((const int, const int, const struct satrns
*));
208 extern void print_proppair0
__P((int, struct prop_pair
*, int));
209 extern void print_proppair
__P((int, struct prop_pair
*));
210 extern int set_proposal_from_policy
__P((struct ph2handle
*,
211 struct secpolicy
*, struct secpolicy
*));
212 extern int set_proposal_from_proposal
__P((struct ph2handle
*));
214 #endif /* _PROPOSAL_H */