1 /* Mode config related functions
2 * Copyright (C) 2001-2002 Colubris Networks
3 * Copyright (C) 2003 Sean Mathews - Nu Tech Software Solutions, inc.
4 * Copyright (C) 2003-2004 Xelerance Corporation
5 * Copyright (C) 2006 Andreas Steffen - Hochschule fuer Technik Rapperswil
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
17 * RCSID $Id: modecfg.c,v 1.6 2006/04/24 20:44:57 as Exp $
19 * This code originally written by Colubris Networks, Inc.
20 * Extraction of patch and porting to 1.99 codebases by Xelerance Corporation
21 * Porting to 2.x by Sean Mathews
30 #include "constants.h"
35 #include "ipsec_doi.h"
44 #define MAX_XAUTH_TRIES 3
46 #define SUPPORTED_ATTR_SET ( LELEM(INTERNAL_IP4_ADDRESS) \
47 | LELEM(INTERNAL_IP4_NETMASK) \
48 | LELEM(INTERNAL_IP4_DNS) \
49 | LELEM(INTERNAL_IP4_NBNS) \
53 * Addresses assigned (usually via ModeCfg) to the Initiator
55 typedef struct internal_addr internal_addr_t
;
61 /* ModeCfg variables */
73 * Initialize an internal_addr struct
76 init_internal_addr(internal_addr_t
*ia
)
78 ia
->attr_set
= LEMPTY
;
79 ia
->xauth_secret
.user_name
= empty_chunk
;
80 ia
->xauth_secret
.user_password
= empty_chunk
;
81 ia
->xauth_status
= FALSE
;
83 anyaddr(AF_INET
, &ia
->ipaddr
);
84 anyaddr(AF_INET
, &ia
->dns
[0]);
85 anyaddr(AF_INET
, &ia
->dns
[1]);
86 anyaddr(AF_INET
, &ia
->wins
[0]);
87 anyaddr(AF_INET
, &ia
->wins
[1]);
91 * get internal IP address for a connection
94 get_internal_addr(struct connection
*c
, internal_addr_t
*ia
)
96 init_internal_addr(ia
);
98 if (isanyaddr(&c
->spd
.that
.host_srcip
))
100 /* not defined in connection - fetch it from LDAP */
104 char srcip
[ADDRTOT_BUF
];
106 ia
->ipaddr
= c
->spd
.that
.host_srcip
;
108 addrtot(&ia
->ipaddr
, 0, srcip
, sizeof(srcip
));
109 plog("assigning virtual IP source address %s", srcip
);
112 if (!isanyaddr(&ia
->ipaddr
)) /* We got an IP address, send it */
114 c
->spd
.that
.client
.addr
= ia
->ipaddr
;
115 c
->spd
.that
.client
.maskbits
= 32;
116 c
->spd
.that
.has_client
= TRUE
;
118 ia
->attr_set
|= LELEM(INTERNAL_IP4_ADDRESS
) | LELEM(INTERNAL_IP4_NETMASK
);
122 if (!isanyaddr(&ia
->dns
[0])) /* We got DNS addresses, send them */
123 ia
->attr_set
|= LELEM(INTERNAL_IP4_DNS
);
125 if (!isanyaddr(&ia
->wins
[0])) /* We got WINS addresses, send them */
126 ia
->attr_set
|= LELEM(INTERNAL_IP4_NBNS
);
130 * Set srcip and client subnet to internal IP address
133 set_internal_addr(struct connection
*c
, internal_addr_t
*ia
)
135 if (ia
->attr_set
& LELEM(INTERNAL_IP4_ADDRESS
)
136 && !isanyaddr(&ia
->ipaddr
))
138 if (addrbytesptr(&c
->spd
.this.host_srcip
, NULL
) == 0
139 || isanyaddr(&c
->spd
.this.host_srcip
)
140 || sameaddr(&c
->spd
.this.host_srcip
, &ia
->ipaddr
))
142 char srcip
[ADDRTOT_BUF
];
144 addrtot(&ia
->ipaddr
, 0, srcip
, sizeof(srcip
));
145 plog("setting virtual IP source address to %s", srcip
);
149 char old_srcip
[ADDRTOT_BUF
];
150 char new_srcip
[ADDRTOT_BUF
];
152 addrtot(&c
->spd
.this.host_srcip
, 0, old_srcip
, sizeof(old_srcip
));
153 addrtot(&ia
->ipaddr
, 0, new_srcip
, sizeof(new_srcip
));
154 plog("replacing virtual IP source address %s by %s"
155 , old_srcip
, new_srcip
);
159 c
->spd
.this.host_srcip
= ia
->ipaddr
;
161 /* setting client subnet to srcip/32 */
162 addrtosubnet(&ia
->ipaddr
, &c
->spd
.this.client
);
163 setportof(0, &c
->spd
.this.client
.addr
);
164 c
->spd
.this.has_client
= TRUE
;
171 * Compute HASH of Mode Config.
174 modecfg_hash(u_char
*dest
, const u_char
*start
, const u_char
*roof
175 , const struct state
*st
)
179 hmac_init_chunk(&ctx
, st
->st_oakley
.hasher
, st
->st_skeyid_a
);
180 hmac_update(&ctx
, (const u_char
*) &st
->st_msgid
, sizeof(st
->st_msgid
));
181 hmac_update(&ctx
, start
, roof
-start
);
182 hmac_final(dest
, &ctx
);
185 DBG_log("ModeCfg HASH computed:");
186 DBG_dump("", dest
, ctx
.hmac_digest_size
)
188 return ctx
.hmac_digest_size
;
193 * Generate an IKE message containing ModeCfg information (eg: IP, DNS, WINS)
196 modecfg_build_msg(struct state
*st
, pb_stream
*rbody
198 , internal_addr_t
*ia
201 u_char
*r_hash_start
, *r_hashval
;
203 START_HASH_PAYLOAD(*rbody
, ISAKMP_NEXT_ATTR
);
207 struct isakmp_mode_attr attrh
;
208 struct isakmp_attribute attr
;
209 pb_stream strattr
,attrval
;
211 int dns_idx
, wins_idx
;
213 lset_t attr_set
= ia
->attr_set
;
215 attrh
.isama_np
= ISAKMP_NEXT_NONE
;
216 attrh
.isama_type
= msg_type
;
217 attrh
.isama_identifier
= ap_id
;
219 if (!out_struct(&attrh
, &isakmp_attr_desc
, rbody
, &strattr
))
220 return STF_INTERNAL_ERROR
;
226 while (attr_set
!= 0)
228 dont_advance
= FALSE
;
231 const u_char
*byte_ptr
;
234 /* ISAKMP attr out */
235 if (attr_type
== XAUTH_TYPE
)
237 attr
.isaat_af_type
= attr_type
| ISAKMP_ATTR_AF_TV
;
238 attr
.isaat_lv
= ia
->xauth_type
;
240 else if (attr_type
== XAUTH_STATUS
)
242 attr
.isaat_af_type
= attr_type
| ISAKMP_ATTR_AF_TV
;
243 attr
.isaat_lv
= ia
->xauth_status
;
247 attr
.isaat_af_type
= attr_type
| ISAKMP_ATTR_AF_TLV
;
249 out_struct(&attr
, &isakmp_modecfg_attribute_desc
, &strattr
, &attrval
);
253 case INTERNAL_IP4_ADDRESS
:
254 if (!isanyaddr(&ia
->ipaddr
))
256 len
= addrbytesptr(&ia
->ipaddr
, &byte_ptr
);
257 out_raw(byte_ptr
, len
, &attrval
, "IP4_addr");
260 case INTERNAL_IP4_NETMASK
:
264 char mask
[4],bits
[8]={0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};
265 int t
,m
=st
->st_connection
->that
.host_addr
.maskbit
;
275 if (st
->st_connection
->spd
.this.client
.maskbits
== 0)
278 mask
= 0xffffffff * 1;
279 out_raw(&mask
, 4, &attrval
, "IP4_mask");
282 case INTERNAL_IP4_SUBNET
:
285 char bits
[8] = {0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe};
287 int m
= st
->st_connection
->spd
.this.client
.maskbits
;
289 for (t
= 0; t
< 4; t
++)
299 len
= addrbytesptr(&st
->st_connection
->spd
.this.client
.addr
, &byte_ptr
);
300 out_raw(byte_ptr
, len
, &attrval
, "IP4_subnet");
301 out_raw(mask
, sizeof(mask
), &attrval
, "IP4_submsk");
304 case INTERNAL_IP4_DNS
:
305 if (!isanyaddr(&ia
->dns
[dns_idx
]))
307 len
= addrbytesptr(&ia
->dns
[dns_idx
++], &byte_ptr
);
308 out_raw(byte_ptr
, len
, &attrval
, "IP4_dns");
310 if (dns_idx
< 2 && !isanyaddr(&ia
->dns
[dns_idx
]))
315 case INTERNAL_IP4_NBNS
:
316 if (!isanyaddr(&ia
->wins
[wins_idx
]))
318 len
= addrbytesptr(&ia
->wins
[wins_idx
++], &byte_ptr
);
319 out_raw(byte_ptr
, len
, &attrval
, "IP4_wins");
321 if (wins_idx
< 2 && !isanyaddr(&ia
->wins
[wins_idx
]))
328 case XAUTH_USER_NAME
:
329 if (ia
->xauth_secret
.user_name
.ptr
!= NULL
)
331 out_raw(ia
->xauth_secret
.user_name
.ptr
332 , ia
->xauth_secret
.user_name
.len
333 , &attrval
, "xauth_user_name");
336 case XAUTH_USER_PASSWORD
:
337 if (ia
->xauth_secret
.user_password
.ptr
!= NULL
)
339 out_raw(ia
->xauth_secret
.user_password
.ptr
340 , ia
->xauth_secret
.user_password
.len
341 , &attrval
, "xauth_user_password");
347 plog("attempt to send unsupported mode cfg attribute %s."
348 , enum_show(&modecfg_attr_names
, attr_type
));
351 close_output_pbs(&attrval
);
356 if (attr_type
== MODECFG_ROOF
)
358 attr_type
= XAUTH_BASE
;
360 else if (attr_type
== XAUTH_ROOF
)
362 attr_type
= UNITY_BASE
;
367 close_message(&strattr
);
370 modecfg_hash(r_hashval
, r_hash_start
, rbody
->cur
, st
);
371 close_message(rbody
);
372 encrypt_message(rbody
, st
);
377 * Send ModeCfg message
380 modecfg_send_msg(struct state
*st
, int isama_type
, internal_addr_t
*ia
)
387 init_pbs(&msg
, buf
, sizeof(buf
), "ModeCfg msg buffer");
389 /* this is the beginning of a new exchange */
390 st
->st_msgid
= generate_msgid(st
);
391 init_phase2_iv(st
, &st
->st_msgid
);
395 struct isakmp_hdr hdr
;
397 zero(&hdr
); /* default to 0 */
398 hdr
.isa_version
= ISAKMP_MAJOR_VERSION
<< ISA_MAJ_SHIFT
| ISAKMP_MINOR_VERSION
;
399 hdr
.isa_np
= ISAKMP_NEXT_HASH
;
400 hdr
.isa_xchg
= ISAKMP_XCHG_MODE_CFG
;
401 hdr
.isa_flags
= ISAKMP_FLAG_ENCRYPTION
;
402 memcpy(hdr
.isa_icookie
, st
->st_icookie
, COOKIE_SIZE
);
403 memcpy(hdr
.isa_rcookie
, st
->st_rcookie
, COOKIE_SIZE
);
404 hdr
.isa_msgid
= st
->st_msgid
;
406 if (!out_struct(&hdr
, &isakmp_hdr_desc
, &msg
, &rbody
))
408 return STF_INTERNAL_ERROR
;
413 modecfg_build_msg(st
, &rbody
416 , 0 /* XXX isama_id */
419 freeanychunk(st
->st_tpacket
);
420 clonetochunk(st
->st_tpacket
, msg
.start
, pbs_offset(&msg
), "ModeCfg msg");
423 send_packet(st
, "ModeCfg msg");
425 if (st
->st_event
->ev_type
!= EVENT_RETRANSMIT
)
428 event_schedule(EVENT_RETRANSMIT
, EVENT_RETRANSMIT_DELAY_0
, st
);
434 * Parse a ModeCfg attribute payload
437 modecfg_parse_attributes(pb_stream
*attrs
, internal_addr_t
*ia
)
439 struct isakmp_attribute attr
;
442 while (pbs_left(attrs
) >= sizeof(struct isakmp_attribute
))
447 if (!in_struct(&attr
, &isakmp_modecfg_attribute_desc
, attrs
, &strattr
))
451 attr_type
= attr
.isaat_af_type
& ISAKMP_ATTR_RTYPE_MASK
;
452 attr_len
= attr
.isaat_lv
;
456 case INTERNAL_IP4_ADDRESS
:
459 initaddr((char *)(strattr
.cur
), 4, AF_INET
, &ia
->ipaddr
);
461 /* fall through to set attribute flags */
462 case INTERNAL_IP4_NETMASK
:
463 case INTERNAL_IP4_DNS
:
464 case INTERNAL_IP4_SUBNET
:
465 case INTERNAL_IP4_NBNS
:
466 ia
->attr_set
|= LELEM(attr_type
);
468 case APPLICATION_VERSION
:
469 case UNITY_DDNS_HOSTNAME
:
473 DBG_log(" '%.*s'", attr_len
, strattr
.cur
)
478 ia
->xauth_type
= attr
.isaat_lv
;
479 ia
->attr_set
|= LELEM(attr_type
- XAUTH_BASE
+ MODECFG_ROOF
);
481 case XAUTH_USER_NAME
:
482 setchunk(ia
->xauth_secret
.user_name
, strattr
.cur
, attr_len
);
483 ia
->attr_set
|= LELEM(attr_type
- XAUTH_BASE
+ MODECFG_ROOF
);
485 case XAUTH_USER_PASSWORD
:
486 setchunk(ia
->xauth_secret
.user_password
, strattr
.cur
, attr_len
);
487 ia
->attr_set
|= LELEM(attr_type
- XAUTH_BASE
+ MODECFG_ROOF
);
490 ia
->xauth_status
= attr
.isaat_lv
;
491 ia
->attr_set
|= LELEM(attr_type
- XAUTH_BASE
+ MODECFG_ROOF
);
494 plog("unsupported ModeCfg attribute %s received."
495 , enum_show(&modecfg_attr_names
, attr_type
));
503 * Parse a ModeCfg message
506 modecfg_parse_msg(struct msg_digest
*md
, int isama_type
, u_int16_t
*isama_id
507 , internal_addr_t
*ia
)
509 struct state
*const st
= md
->st
;
510 struct payload_digest
*p
;
513 st
->st_msgid
= md
->hdr
.isa_msgid
;
515 CHECK_QUICK_HASH(md
, modecfg_hash(hash_val
517 , md
->message_pbs
.roof
, st
)
518 , "MODECFG-HASH", "ISAKMP_CFG_MSG");
520 /* process the ModeCfg payloads received */
521 for (p
= md
->chain
[ISAKMP_NEXT_ATTR
]; p
!= NULL
; p
= p
->next
)
523 internal_addr_t ia_candidate
;
525 init_internal_addr(&ia_candidate
);
527 if (p
->payload
.attribute
.isama_type
== isama_type
)
529 *isama_id
= p
->payload
.attribute
.isama_identifier
;
531 stat
= modecfg_parse_attributes(&p
->pbs
, &ia_candidate
);
534 /* return with a valid set of attributes */
541 plog("expected %s, got %s instead (ignored)"
542 , enum_name(&attr_msg_type_names
, isama_type
)
543 , enum_name(&attr_msg_type_names
, p
->payload
.attribute
.isama_type
));
545 stat
= modecfg_parse_attributes(&p
->pbs
, &ia_candidate
);
554 * Send ModeCfg request message from client to server in pull mode
557 modecfg_send_request(struct state
*st
)
562 init_internal_addr(&ia
);
563 ia
.attr_set
= LELEM(INTERNAL_IP4_ADDRESS
)
564 | LELEM(INTERNAL_IP4_NETMASK
);
566 plog("sending ModeCfg request");
567 st
->st_state
= STATE_MODE_CFG_I1
;
568 stat
= modecfg_send_msg(st
, ISAKMP_CFG_REQUEST
, &ia
);
570 st
->st_modecfg
.started
= TRUE
;
574 /* STATE_MODE_CFG_R0:
575 * HDR*, HASH, ATTR(REQ=IP) --> HDR*, HASH, ATTR(REPLY=IP)
577 * used in ModeCfg pull mode, on the server (responder)
580 modecfg_inR0(struct msg_digest
*md
)
582 struct state
*const st
= md
->st
;
585 stf_status stat
, stat_build
;
587 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_REQUEST
, &isama_id
, &ia
);
591 get_internal_addr(st
->st_connection
, &ia
);
593 plog("sending ModeCfg reply");
595 stat_build
= modecfg_build_msg(st
, &md
->rbody
599 if (stat_build
!= STF_OK
)
606 /* STATE_MODE_CFG_I1:
607 * HDR*, HASH, ATTR(REPLY=IP)
609 * used in ModeCfg pull mode, on the client (initiator)
612 modecfg_inI1(struct msg_digest
*md
)
614 struct state
*const st
= md
->st
;
619 plog("parsing ModeCfg reply");
621 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_REPLY
, &isama_id
, &ia
);
625 st
->st_modecfg
.vars_set
= set_internal_addr(st
->st_connection
, &ia
);
632 * Send ModeCfg set message from server to client in push mode
635 modecfg_send_set(struct state
*st
)
640 get_internal_addr(st
->st_connection
, &ia
);
642 plog("sending ModeCfg set");
643 st
->st_state
= STATE_MODE_CFG_R3
;
644 stat
= modecfg_send_msg(st
, ISAKMP_CFG_SET
, &ia
);
646 st
->st_modecfg
.started
= TRUE
;
650 /* STATE_MODE_CFG_I0:
651 * HDR*, HASH, ATTR(SET=IP) --> HDR*, HASH, ATTR(ACK,OK)
653 * used in ModeCfg push mode, on the client (initiator).
656 modecfg_inI0(struct msg_digest
*md
)
658 struct state
*const st
= md
->st
;
662 stf_status stat
, stat_build
;
664 plog("parsing ModeCfg set");
666 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_SET
, &isama_id
, &ia
);
670 st
->st_modecfg
.vars_set
= set_internal_addr(st
->st_connection
, &ia
);
672 /* prepare ModeCfg ack which sends zero length attributes */
673 attr_set
= ia
.attr_set
;
674 init_internal_addr(&ia
);
675 ia
.attr_set
= attr_set
& SUPPORTED_ATTR_SET
;
677 plog("sending ModeCfg ack");
679 stat_build
= modecfg_build_msg(st
, &md
->rbody
683 if (stat_build
!= STF_OK
)
690 /* STATE_MODE_CFG_R3:
691 * HDR*, HASH, ATTR(ACK,OK)
693 * used in ModeCfg push mode, on the server (responder)
696 modecfg_inR3(struct msg_digest
*md
)
698 struct state
*const st
= md
->st
;
703 plog("parsing ModeCfg ack");
705 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_ACK
, &isama_id
, &ia
);
714 * Send XAUTH credentials request (username + password)
717 xauth_send_request(struct state
*st
)
722 init_internal_addr(&ia
);
723 ia
.attr_set
= LELEM(XAUTH_USER_NAME
- XAUTH_BASE
+ MODECFG_ROOF
)
724 | LELEM(XAUTH_USER_PASSWORD
- XAUTH_BASE
+ MODECFG_ROOF
);
726 plog("sending XAUTH request");
727 st
->st_state
= STATE_XAUTH_R1
;
728 stat
= modecfg_send_msg(st
, ISAKMP_CFG_REQUEST
, &ia
);
730 st
->st_xauth
.started
= TRUE
;
735 * HDR*, HASH, ATTR(REQ) --> HDR*, HASH, ATTR(REPLY=USERNAME/PASSWORD)
737 * used on the XAUTH client (initiator)
740 xauth_inI0(struct msg_digest
*md
)
742 struct state
*const st
= md
->st
;
745 stf_status stat
, stat_build
;
747 plog("parsing XAUTH request");
749 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_REQUEST
, &isama_id
, &ia
);
753 /* check XAUTH attributes */
754 if ((ia
.attr_set
& LELEM(XAUTH_TYPE
- XAUTH_BASE
+ MODECFG_ROOF
)) != LEMPTY
755 && ia
.xauth_type
!= XAUTH_TYPE_GENERIC
)
757 plog("xauth type %s is not supported", enum_name(&xauth_type_names
, ia
.xauth_type
));
760 else if ((ia
.attr_set
& LELEM(XAUTH_USER_NAME
- XAUTH_BASE
+ MODECFG_ROOF
)) == LEMPTY
)
762 plog("user name attribute is missing in XAUTH request");
765 else if ((ia
.attr_set
& LELEM(XAUTH_USER_PASSWORD
- XAUTH_BASE
+ MODECFG_ROOF
)) == LEMPTY
)
767 plog("user password attribute is missing in XAUTH request");
771 /* prepare XAUTH reply */
772 init_internal_addr(&ia
);
776 /* get user credentials using a plugin function */
777 if (!xauth_module
.get_secret(&ia
.xauth_secret
))
779 plog("xauth user credentials not found");
786 DBG_log("my xauth user name is '%.*s'"
787 , ia
.xauth_secret
.user_name
.len
788 , ia
.xauth_secret
.user_name
.ptr
)
791 DBG_log("my xauth user password is '%.*s'"
792 , ia
.xauth_secret
.user_password
.len
793 , ia
.xauth_secret
.user_password
.ptr
)
795 ia
.attr_set
= LELEM(XAUTH_USER_NAME
- XAUTH_BASE
+ MODECFG_ROOF
)
796 | LELEM(XAUTH_USER_PASSWORD
- XAUTH_BASE
+ MODECFG_ROOF
);
800 ia
.attr_set
= LELEM(XAUTH_STATUS
- XAUTH_BASE
+ MODECFG_ROOF
);
801 ia
.xauth_status
= FALSE
;
804 plog("sending XAUTH reply");
806 stat_build
= modecfg_build_msg(st
, &md
->rbody
810 if (stat_build
!= STF_OK
)
815 st
->st_xauth
.started
= TRUE
;
820 /* send XAUTH reply msg and then delete ISAKMP SA */
821 freeanychunk(st
->st_tpacket
);
822 clonetochunk(st
->st_tpacket
, md
->reply
.start
823 , pbs_offset(&md
->reply
), "XAUTH reply msg");
824 send_packet(st
, "XAUTH reply msg");
831 * HDR*, HASH, ATTR(REPLY=USERNAME/PASSWORD) --> HDR*, HASH, ATTR(STATUS)
833 * used on the XAUTH server (responder)
836 xauth_inR1(struct msg_digest
*md
)
838 struct state
*const st
= md
->st
;
841 stf_status stat
, stat_build
;
843 plog("parsing XAUTH reply");
845 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_REPLY
, &isama_id
, &ia
);
849 /* did the client return an XAUTH FAIL status? */
850 if ((ia
.attr_set
& LELEM(XAUTH_STATUS
- XAUTH_BASE
+ MODECFG_ROOF
)) != LEMPTY
)
852 plog("received FAIL status in XAUTH reply");
854 /* client is not able to do XAUTH, delete ISAKMP SA */
859 /* check XAUTH reply */
860 if ((ia
.attr_set
& LELEM(XAUTH_USER_NAME
- XAUTH_BASE
+ MODECFG_ROOF
)) == LEMPTY
)
862 plog("user name attribute is missing in XAUTH reply");
863 st
->st_xauth
.status
= FALSE
;
865 else if ((ia
.attr_set
& LELEM(XAUTH_USER_PASSWORD
- XAUTH_BASE
+ MODECFG_ROOF
)) == LEMPTY
)
867 plog("user password attribute is missing in XAUTH reply");
868 st
->st_xauth
.status
= FALSE
;
873 DBG_log("peer xauth user name is '%.*s'"
874 , ia
.xauth_secret
.user_name
.len
875 , ia
.xauth_secret
.user_name
.ptr
)
878 DBG_log("peer xauth user password is '%.*s'"
879 , ia
.xauth_secret
.user_password
.len
880 , ia
.xauth_secret
.user_password
.ptr
)
882 /* verify the user credentials using a plugn function */
883 st
->st_xauth
.status
= xauth_module
.verify_secret(&ia
.xauth_secret
);
884 plog("extended authentication %s", st
->st_xauth
.status?
"was successful":"failed");
887 /* prepare XAUTH set which sends the authentication status */
888 init_internal_addr(&ia
);
889 ia
.attr_set
= LELEM(XAUTH_STATUS
- XAUTH_BASE
+ MODECFG_ROOF
);
890 ia
.xauth_status
= st
->st_xauth
.status
;
892 plog("sending XAUTH status:");
894 stat_build
= modecfg_build_msg(st
, &md
->rbody
898 if (stat_build
!= STF_OK
)
904 * HDR*, HASH, ATTR(STATUS) --> HDR*, HASH, ATTR(ACK)
906 * used on the XAUTH client (initiator)
909 xauth_inI1(struct msg_digest
*md
)
911 struct state
*const st
= md
->st
;
914 stf_status stat
, stat_build
;
916 plog("parsing XAUTH status");
917 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_SET
, &isama_id
, &ia
);
920 /* notification payload - not exactly the right choice, but okay */
921 md
->note
= ATTRIBUTES_NOT_SUPPORTED
;
925 st
->st_xauth
.status
= ia
.xauth_status
;
926 plog("extended authentication %s", st
->st_xauth
.status?
"was successful":"failed");
928 plog("sending XAUTH ack");
929 init_internal_addr(&ia
);
930 stat_build
= modecfg_build_msg(st
, &md
->rbody
934 if (stat_build
!= STF_OK
)
937 if (st
->st_xauth
.status
)
944 /* send XAUTH ack msg and then delete ISAKMP SA */
945 freeanychunk(st
->st_tpacket
);
946 clonetochunk(st
->st_tpacket
, md
->reply
.start
947 , pbs_offset(&md
->reply
), "XAUTH ack msg");
948 send_packet(st
, "XAUTH ack msg");
955 * HDR*, ATTR(STATUS), HASH --> Done
957 * used on the XAUTH server (responder)
960 xauth_inR2(struct msg_digest
*md
)
962 struct state
*const st
= md
->st
;
967 plog("parsing XAUTH ack");
969 stat
= modecfg_parse_msg(md
, ISAKMP_CFG_ACK
, &isama_id
, &ia
);
974 if (st
->st_xauth
.status
)