1 /* $Id: isakmp_ident.c,v 1.13.2.2 2005/11/21 09:46:23 vanhu Exp $ */
4 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
32 /* Identity Protecion Exchange (Main Mode) */
36 #include <sys/types.h>
37 #include <sys/param.h>
43 #if TIME_WITH_SYS_TIME
44 # include <sys/time.h>
48 # include <sys/time.h>
62 #include "localconf.h"
63 #include "remoteconf.h"
64 #include "isakmp_var.h"
69 #include "ipsec_doi.h"
70 #include "crypto_openssl.h"
72 #include "isakmp_ident.h"
73 #include "isakmp_inf.h"
77 #include "nattraversal.h"
83 #include "vpn_control.h"
84 #include "vpn_control_var.h"
86 static vchar_t
*ident_ir2mx
__P((struct ph1handle
*));
87 static vchar_t
*ident_ir3mx
__P((struct ph1handle
*));
90 * begin Identity Protection Mode as initiator.
100 ident_i1send(iph1
, msg
)
101 struct ph1handle
*iph1
;
102 vchar_t
*msg
; /* must be null */
104 struct payload_list
*plist
= NULL
;
107 vchar_t
*vid_natt
[MAX_NATT_VID_COUNT
] = { NULL
};
111 vchar_t
*vid_dpd
= NULL
;
115 plog(LLV_ERROR
, LOCATION
, NULL
,
116 "msg has to be NULL in this function.\n");
119 if (iph1
->status
!= PHASE1ST_START
) {
120 plog(LLV_ERROR
, LOCATION
, NULL
,
121 "status mismatched %d.\n", iph1
->status
);
125 /* create isakmp index */
126 memset(&iph1
->index
, 0, sizeof(iph1
->index
));
127 isakmp_newcookie((caddr_t
)&iph1
->index
, iph1
->remote
, iph1
->local
);
129 /* create SA payload for my proposal */
130 iph1
->sa
= ipsecdoi_setph1proposal(iph1
->rmconf
->proposal
);
131 if (iph1
->sa
== NULL
)
134 /* set SA payload to propose */
135 plist
= isakmp_plist_append(plist
, iph1
->sa
, ISAKMP_NPTYPE_SA
);
138 /* set VID payload for NAT-T if NAT-T support allowed in the config file */
139 if (iph1
->rmconf
->nat_traversal
)
140 plist
= isakmp_plist_append_natt_vids(plist
, vid_natt
);
143 if(iph1
->rmconf
->dpd
){
144 vid_dpd
= set_vendorid(VENDORID_DPD
);
146 plist
= isakmp_plist_append(plist
, vid_dpd
,
151 iph1
->sendbuf
= isakmp_plist_set_all (&plist
, iph1
);
153 #ifdef HAVE_PRINT_ISAKMP_C
154 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
157 /* send the packet, add to the schedule to resend */
158 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
159 if (isakmp_ph1resend(iph1
) == -1)
162 iph1
->status
= PHASE1ST_MSG1SENT
;
168 for (i
= 0; i
< MAX_NATT_VID_COUNT
&& vid_natt
[i
] != NULL
; i
++)
180 * receive from responder
187 ident_i2recv(iph1
, msg
)
188 struct ph1handle
*iph1
;
191 vchar_t
*pbuf
= NULL
;
192 struct isakmp_parse_t
*pa
;
193 vchar_t
*satmp
= NULL
;
198 if (iph1
->status
!= PHASE1ST_MSG1SENT
) {
199 plog(LLV_ERROR
, LOCATION
, NULL
,
200 "status mismatched %d.\n", iph1
->status
);
204 /* validate the type of next payload */
206 * NOTE: RedCreek(as responder) attaches N[responder-lifetime] here,
207 * if proposal-lifetime > lifetime-redcreek-wants.
209 * => According to the seciton 4.6.3 in RFC 2407, This is illegal.
210 * NOTE: we do not really care about ordering of VID and N.
212 * NOTE: even if there's multiple VID/N, we'll ignore them.
214 pbuf
= isakmp_parse(msg
);
217 pa
= (struct isakmp_parse_t
*)pbuf
->v
;
219 /* SA payload is fixed postion */
220 if (pa
->type
!= ISAKMP_NPTYPE_SA
) {
221 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
222 "received invalid next payload type %d, "
224 pa
->type
, ISAKMP_NPTYPE_SA
);
227 if (isakmp_p2ph(&satmp
, pa
->ptr
) < 0)
232 pa
->type
!= ISAKMP_NPTYPE_NONE
;
236 case ISAKMP_NPTYPE_VID
:
237 vid_numeric
= check_vendorid(pa
->ptr
);
239 if (iph1
->rmconf
->nat_traversal
&& natt_vendorid(vid_numeric
))
240 natt_handle_vendorid(iph1
, vid_numeric
);
243 if (vid_numeric
== VENDORID_DPD
&& iph1
->rmconf
->dpd
)
248 /* don't send information, see ident_r1recv() */
249 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
250 "ignore the packet, "
251 "received unexpecting payload type %d.\n",
258 if (NATT_AVAILABLE(iph1
))
259 plog(LLV_INFO
, LOCATION
, iph1
->remote
,
260 "Selected NAT-T version: %s\n",
261 vid_string_by_id(iph1
->natt_options
->version
));
264 /* check SA payload and set approval SA for use */
265 if (ipsecdoi_checkph1proposal(satmp
, iph1
) < 0) {
266 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
267 "failed to get valid proposal.\n");
268 /* XXX send information */
271 VPTRINIT(iph1
->sa_ret
);
273 iph1
->status
= PHASE1ST_MSG2RECEIVED
;
275 #ifdef ENABLE_VPNCONTROL_PORT
276 vpncontrol_notify_phase_change(1, FROM_REMOTE
, iph1
, NULL
);
293 * gssapi: HDR, KE, Ni, GSSi
294 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
295 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
296 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
299 ident_i2send(iph1
, msg
)
300 struct ph1handle
*iph1
;
306 if (iph1
->status
!= PHASE1ST_MSG2RECEIVED
) {
307 plog(LLV_ERROR
, LOCATION
, NULL
,
308 "status mismatched %d.\n", iph1
->status
);
312 /* fix isakmp index */
313 memcpy(&iph1
->index
.r_ck
, &((struct isakmp
*)msg
->v
)->r_ck
,
316 /* generate DH public value */
317 if (oakley_dh_generate(iph1
->approval
->dhgrp
,
318 &iph1
->dhpub
, &iph1
->dhpriv
) < 0)
321 /* generate NONCE value */
322 iph1
->nonce
= eay_set_random(iph1
->rmconf
->nonce_size
);
323 if (iph1
->nonce
== NULL
)
327 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
328 gssapi_get_itoken(iph1
, NULL
) < 0)
332 /* create buffer to send isakmp payload */
333 iph1
->sendbuf
= ident_ir2mx(iph1
);
334 if (iph1
->sendbuf
== NULL
)
337 #ifdef HAVE_PRINT_ISAKMP_C
338 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
341 /* send the packet, add to the schedule to resend */
342 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
343 if (isakmp_ph1resend(iph1
) == -1)
346 /* the sending message is added to the received-list. */
347 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
348 plog(LLV_ERROR
, LOCATION
, NULL
,
349 "failed to add a response packet to the tree.\n");
353 iph1
->status
= PHASE1ST_MSG2SENT
;
362 * receive from responder
364 * sig: HDR, KE, Nr [, CR ]
365 * gssapi: HDR, KE, Nr, GSSr
366 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
367 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
370 ident_i3recv(iph1
, msg
)
371 struct ph1handle
*iph1
;
374 vchar_t
*pbuf
= NULL
;
375 struct isakmp_parse_t
*pa
;
378 vchar_t
*gsstoken
= NULL
;
381 vchar_t
*natd_received
;
382 int natd_seq
= 0, natd_verified
;
386 if (iph1
->status
!= PHASE1ST_MSG2SENT
) {
387 plog(LLV_ERROR
, LOCATION
, NULL
,
388 "status mismatched %d.\n", iph1
->status
);
392 /* validate the type of next payload */
393 pbuf
= isakmp_parse(msg
);
397 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
398 pa
->type
!= ISAKMP_NPTYPE_NONE
;
402 case ISAKMP_NPTYPE_KE
:
403 if (isakmp_p2ph(&iph1
->dhpub_p
, pa
->ptr
) < 0)
406 case ISAKMP_NPTYPE_NONCE
:
407 if (isakmp_p2ph(&iph1
->nonce_p
, pa
->ptr
) < 0)
410 case ISAKMP_NPTYPE_VID
:
411 (void)check_vendorid(pa
->ptr
);
413 case ISAKMP_NPTYPE_CR
:
414 if (oakley_savecr(iph1
, pa
->ptr
) < 0)
418 case ISAKMP_NPTYPE_GSS
:
419 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
421 gssapi_save_received_token(iph1
, gsstoken
);
426 case ISAKMP_NPTYPE_NATD_DRAFT
:
427 case ISAKMP_NPTYPE_NATD_RFC
:
429 case ISAKMP_NPTYPE_NATD_BADDRAFT
:
431 if (NATT_AVAILABLE(iph1
) && iph1
->natt_options
!= NULL
&&
432 pa
->type
== iph1
->natt_options
->payload_nat_d
) {
433 natd_received
= NULL
;
434 if (isakmp_p2ph (&natd_received
, pa
->ptr
) < 0)
437 /* set both bits first so that we can clear them
438 upon verifying hashes */
440 iph1
->natt_flags
|= NAT_DETECTED
;
442 /* this function will clear appropriate bits bits
443 from iph1->natt_flags */
444 natd_verified
= natt_compare_addr_hash (iph1
,
445 natd_received
, natd_seq
++);
447 plog (LLV_INFO
, LOCATION
, NULL
, "NAT-D payload #%d %s\n",
449 natd_verified
? "verified" : "doesn't match");
451 vfree (natd_received
);
454 /* %%%% Be lenient here - some servers send natd payloads */
455 /* when no nat is detected */
460 /* don't send information, see ident_r1recv() */
461 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
462 "ignore the packet, "
463 "received unexpecting payload type %d.\n",
470 if (NATT_AVAILABLE(iph1
)) {
471 plog (LLV_INFO
, LOCATION
, NULL
, "NAT %s %s%s\n",
472 iph1
->natt_flags
& NAT_DETECTED
?
473 "detected:" : "not detected",
474 iph1
->natt_flags
& NAT_DETECTED_ME
? "ME " : "",
475 iph1
->natt_flags
& NAT_DETECTED_PEER
? "PEER" : "");
476 if (iph1
->natt_flags
& NAT_DETECTED
)
477 natt_float_ports (iph1
);
481 /* payload existency check */
482 if (iph1
->dhpub_p
== NULL
|| iph1
->nonce_p
== NULL
) {
483 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
484 "few isakmp message received.\n");
488 if (oakley_checkcr(iph1
) < 0) {
489 /* Ignore this error in order to be interoperability. */
493 iph1
->status
= PHASE1ST_MSG3RECEIVED
;
501 VPTRINIT(iph1
->dhpub_p
);
502 VPTRINIT(iph1
->nonce_p
);
503 VPTRINIT(iph1
->id_p
);
504 oakley_delcert(iph1
->cr_p
);
513 * psk: HDR*, IDi1, HASH_I
514 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
515 * gssapi: HDR*, IDi1, < Gssi(n) | HASH_I >
520 ident_i3send(iph1
, msg0
)
521 struct ph1handle
*iph1
;
531 if (iph1
->status
!= PHASE1ST_MSG3RECEIVED
) {
532 plog(LLV_ERROR
, LOCATION
, NULL
,
533 "status mismatched %d.\n", iph1
->status
);
537 /* compute sharing secret of DH */
538 if (oakley_dh_compute(iph1
->approval
->dhgrp
, iph1
->dhpub
,
539 iph1
->dhpriv
, iph1
->dhpub_p
, &iph1
->dhgxy
) < 0)
542 /* generate SKEYIDs & IV & final cipher key */
543 if (oakley_skeyid(iph1
) < 0)
545 if (oakley_skeyid_dae(iph1
) < 0)
547 if (oakley_compute_enckey(iph1
) < 0)
549 if (oakley_newiv(iph1
) < 0)
552 /* make ID payload into isakmp status */
553 if (ipsecdoi_setid1(iph1
) < 0)
557 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
558 gssapi_more_tokens(iph1
)) {
559 plog(LLV_DEBUG
, LOCATION
, NULL
, "calling get_itoken\n");
560 if (gssapi_get_itoken(iph1
, &len
) < 0)
567 /* generate HASH to send */
569 iph1
->hash
= oakley_ph1hash_common(iph1
, GENERATE
);
570 if (iph1
->hash
== NULL
)
575 /* set encryption flag */
576 iph1
->flags
|= ISAKMP_FLAG_E
;
578 /* create HDR;ID;HASH payload */
579 iph1
->sendbuf
= ident_ir3mx(iph1
);
580 if (iph1
->sendbuf
== NULL
)
583 /* send the packet, add to the schedule to resend */
584 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
585 if (isakmp_ph1resend(iph1
) == -1)
588 /* the sending message is added to the received-list. */
589 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg0
) == -1) {
590 plog(LLV_ERROR
, LOCATION
, NULL
,
591 "failed to add a response packet to the tree.\n");
595 /* see handler.h about IV synchronization. */
596 memcpy(iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->v
, iph1
->ivm
->iv
->l
);
598 iph1
->status
= PHASE1ST_MSG3SENT
;
607 * receive from responder
608 * psk: HDR*, IDr1, HASH_R
609 * sig: HDR*, IDr1, [ CERT, ] SIG_R
610 * gssapi: HDR*, IDr1, < GSSr(n) | HASH_R >
615 ident_i4recv(iph1
, msg0
)
616 struct ph1handle
*iph1
;
619 vchar_t
*pbuf
= NULL
;
620 struct isakmp_parse_t
*pa
;
625 vchar_t
*gsstoken
= NULL
;
629 if (iph1
->status
!= PHASE1ST_MSG3SENT
) {
630 plog(LLV_ERROR
, LOCATION
, NULL
,
631 "status mismatched %d.\n", iph1
->status
);
636 if (!ISSET(((struct isakmp
*)msg0
->v
)->flags
, ISAKMP_FLAG_E
)) {
637 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
638 "ignore the packet, "
639 "expecting the packet encrypted.\n");
642 msg
= oakley_do_decrypt(iph1
, msg0
, iph1
->ivm
->iv
, iph1
->ivm
->ive
);
646 /* validate the type of next payload */
647 pbuf
= isakmp_parse(msg
);
651 iph1
->pl_hash
= NULL
;
653 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
654 pa
->type
!= ISAKMP_NPTYPE_NONE
;
658 case ISAKMP_NPTYPE_ID
:
659 if (isakmp_p2ph(&iph1
->id_p
, pa
->ptr
) < 0)
662 case ISAKMP_NPTYPE_HASH
:
663 iph1
->pl_hash
= (struct isakmp_pl_hash
*)pa
->ptr
;
665 case ISAKMP_NPTYPE_CERT
:
666 if (oakley_savecert(iph1
, pa
->ptr
) < 0)
669 case ISAKMP_NPTYPE_SIG
:
670 if (isakmp_p2ph(&iph1
->sig_p
, pa
->ptr
) < 0)
674 case ISAKMP_NPTYPE_GSS
:
675 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
677 gssapi_save_received_token(iph1
, gsstoken
);
680 case ISAKMP_NPTYPE_VID
:
681 (void)check_vendorid(pa
->ptr
);
683 case ISAKMP_NPTYPE_N
:
684 isakmp_check_notify(pa
->ptr
, iph1
);
687 /* don't send information, see ident_r1recv() */
688 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
689 "ignore the packet, "
690 "received unexpecting payload type %d.\n",
696 /* payload existency check */
698 /* verify identifier */
699 if (ipsecdoi_checkid1(iph1
) != 0) {
700 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
701 "invalid ID payload.\n");
705 /* validate authentication value */
707 if (gsstoken
== NULL
) {
709 type
= oakley_validate_auth(iph1
);
712 /* msg printed inner oakley_validate_auth() */
715 EVT_PUSH(iph1
->local
, iph1
->remote
,
716 EVTT_PEERPH1AUTH_FAILED
, NULL
);
717 isakmp_info_send_n1(iph1
, type
, NULL
);
725 * XXX: Should we do compare two addresses, ph1handle's and ID
729 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
, "peer's ID:");
730 plogdump(LLV_DEBUG
, iph1
->id_p
->v
, iph1
->id_p
->l
);
732 /* see handler.h about IV synchronization. */
733 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->ive
->l
);
736 * If we got a GSS token, we need to this roundtrip again.
739 iph1
->status
= gsstoken
!= 0 ? PHASE1ST_MSG3RECEIVED
:
740 PHASE1ST_MSG4RECEIVED
;
742 iph1
->status
= PHASE1ST_MSG4RECEIVED
;
758 VPTRINIT(iph1
->id_p
);
759 oakley_delcert(iph1
->cert_p
);
761 oakley_delcert(iph1
->crl_p
);
763 VPTRINIT(iph1
->sig_p
);
770 * status update and establish isakmp sa.
773 ident_i4send(iph1
, msg
)
774 struct ph1handle
*iph1
;
780 if (iph1
->status
!= PHASE1ST_MSG4RECEIVED
) {
781 plog(LLV_ERROR
, LOCATION
, NULL
,
782 "status mismatched %d.\n", iph1
->status
);
786 /* see handler.h about IV synchronization. */
787 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->l
);
789 iph1
->status
= PHASE1ST_ESTABLISHED
;
798 * receive from initiator
805 ident_r1recv(iph1
, msg
)
806 struct ph1handle
*iph1
;
809 vchar_t
*pbuf
= NULL
;
810 struct isakmp_parse_t
*pa
;
815 if (iph1
->status
!= PHASE1ST_START
) {
816 plog(LLV_ERROR
, LOCATION
, NULL
,
817 "status mismatched %d.\n", iph1
->status
);
821 /* validate the type of next payload */
823 * NOTE: XXX even if multiple VID, we'll silently ignore those.
825 pbuf
= isakmp_parse(msg
);
828 pa
= (struct isakmp_parse_t
*)pbuf
->v
;
830 /* check the position of SA payload */
831 if (pa
->type
!= ISAKMP_NPTYPE_SA
) {
832 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
833 "received invalid next payload type %d, "
835 pa
->type
, ISAKMP_NPTYPE_SA
);
838 if (isakmp_p2ph(&iph1
->sa
, pa
->ptr
) < 0)
843 pa
->type
!= ISAKMP_NPTYPE_NONE
;
847 case ISAKMP_NPTYPE_VID
:
848 vid_numeric
= check_vendorid(pa
->ptr
);
850 if (iph1
->rmconf
->nat_traversal
&& natt_vendorid(vid_numeric
))
851 natt_handle_vendorid(iph1
, vid_numeric
);
854 if (vid_numeric
== VENDORID_DPD
&& iph1
->rmconf
->dpd
)
860 * We don't send information to the peer even
861 * if we received malformed packet. Because we
862 * can't distinguish the malformed packet and
863 * the re-sent packet. And we do same behavior
864 * when we expect encrypted packet.
866 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
867 "ignore the packet, "
868 "received unexpecting payload type %d.\n",
875 if (NATT_AVAILABLE(iph1
))
876 plog(LLV_INFO
, LOCATION
, iph1
->remote
,
877 "Selected NAT-T version: %s\n",
878 vid_string_by_id(iph1
->natt_options
->version
));
881 /* check SA payload and set approval SA for use */
882 if (ipsecdoi_checkph1proposal(iph1
->sa
, iph1
) < 0) {
883 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
884 "failed to get valid proposal.\n");
885 /* XXX send information */
889 iph1
->status
= PHASE1ST_MSG1RECEIVED
;
911 ident_r1send(iph1
, msg
)
912 struct ph1handle
*iph1
;
915 struct payload_list
*plist
= NULL
;
917 vchar_t
*gss_sa
= NULL
;
920 vchar_t
*vid_natt
= NULL
;
923 vchar_t
*vid_dpd
= NULL
;
927 if (iph1
->status
!= PHASE1ST_MSG1RECEIVED
) {
928 plog(LLV_ERROR
, LOCATION
, NULL
,
929 "status mismatched %d.\n", iph1
->status
);
933 /* set responder's cookie */
934 isakmp_newcookie((caddr_t
)&iph1
->index
.r_ck
, iph1
->remote
, iph1
->local
);
937 if (iph1
->approval
->gssid
!= NULL
)
938 gss_sa
= ipsecdoi_setph1proposal(iph1
->approval
);
941 gss_sa
= iph1
->sa_ret
;
943 /* set SA payload to reply */
944 plist
= isakmp_plist_append(plist
, gss_sa
, ISAKMP_NPTYPE_SA
);
946 /* Set Vendor ID, if necessary. */
948 plist
= isakmp_plist_append(plist
, vid
, ISAKMP_NPTYPE_VID
);
951 /* Has the peer announced NAT-T? */
952 if (NATT_AVAILABLE(iph1
))
953 vid_natt
= set_vendorid(iph1
->natt_options
->version
);
956 plist
= isakmp_plist_append(plist
, vid_natt
, ISAKMP_NPTYPE_VID
);
959 /* XXX only send DPD VID if remote sent it ? */
960 if(iph1
->rmconf
->dpd
){
961 vid_dpd
= set_vendorid(VENDORID_DPD
);
963 plist
= isakmp_plist_append(plist
, vid_dpd
, ISAKMP_NPTYPE_VID
);
967 iph1
->sendbuf
= isakmp_plist_set_all (&plist
, iph1
);
969 #ifdef HAVE_PRINT_ISAKMP_C
970 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
973 /* send the packet, add to the schedule to resend */
974 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
975 if (isakmp_ph1resend(iph1
) == -1)
978 /* the sending message is added to the received-list. */
979 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
980 plog(LLV_ERROR
, LOCATION
, NULL
,
981 "failed to add a response packet to the tree.\n");
985 iph1
->status
= PHASE1ST_MSG1SENT
;
987 #ifdef ENABLE_VPNCONTROL_PORT
988 vpncontrol_notify_phase_change(1, FROM_LOCAL
, iph1
, NULL
);
995 if (gss_sa
!= iph1
->sa_ret
)
1006 if (vid_dpd
!= NULL
)
1014 * receive from initiator
1017 * gssapi: HDR, KE, Ni, GSSi
1018 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
1019 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
1020 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
1023 ident_r2recv(iph1
, msg
)
1024 struct ph1handle
*iph1
;
1027 vchar_t
*pbuf
= NULL
;
1028 struct isakmp_parse_t
*pa
;
1031 vchar_t
*gsstoken
= NULL
;
1037 /* validity check */
1038 if (iph1
->status
!= PHASE1ST_MSG1SENT
) {
1039 plog(LLV_ERROR
, LOCATION
, NULL
,
1040 "status mismatched %d.\n", iph1
->status
);
1044 /* validate the type of next payload */
1045 pbuf
= isakmp_parse(msg
);
1049 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
1050 pa
->type
!= ISAKMP_NPTYPE_NONE
;
1053 case ISAKMP_NPTYPE_KE
:
1054 if (isakmp_p2ph(&iph1
->dhpub_p
, pa
->ptr
) < 0)
1057 case ISAKMP_NPTYPE_NONCE
:
1058 if (isakmp_p2ph(&iph1
->nonce_p
, pa
->ptr
) < 0)
1061 case ISAKMP_NPTYPE_VID
:
1062 (void)check_vendorid(pa
->ptr
);
1064 case ISAKMP_NPTYPE_CR
:
1065 plog(LLV_WARNING
, LOCATION
, iph1
->remote
,
1066 "CR received, ignore it. "
1067 "It should be in other exchange.\n");
1070 case ISAKMP_NPTYPE_GSS
:
1071 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
1073 gssapi_save_received_token(iph1
, gsstoken
);
1078 case ISAKMP_NPTYPE_NATD_DRAFT
:
1079 case ISAKMP_NPTYPE_NATD_RFC
:
1081 case ISAKMP_NPTYPE_NATD_BADDRAFT
:
1083 if (NATT_AVAILABLE(iph1
) && iph1
->natt_options
!= NULL
&&
1084 pa
->type
== iph1
->natt_options
->payload_nat_d
)
1086 vchar_t
*natd_received
= NULL
;
1089 if (isakmp_p2ph (&natd_received
, pa
->ptr
) < 0)
1093 iph1
->natt_flags
|= NAT_DETECTED
;
1095 natd_verified
= natt_compare_addr_hash (iph1
,
1096 natd_received
, natd_seq
++);
1098 plog (LLV_INFO
, LOCATION
, NULL
, "NAT-D payload #%d %s\n",
1100 natd_verified
? "verified" : "doesn't match");
1102 vfree (natd_received
);
1105 /* %%%% Be lenient here - some servers send natd payloads */
1106 /* when no nat is detected */
1111 /* don't send information, see ident_r1recv() */
1112 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1113 "ignore the packet, "
1114 "received unexpecting payload type %d.\n",
1121 if (NATT_AVAILABLE(iph1
))
1122 plog (LLV_INFO
, LOCATION
, NULL
, "NAT %s %s%s\n",
1123 iph1
->natt_flags
& NAT_DETECTED
?
1124 "detected:" : "not detected",
1125 iph1
->natt_flags
& NAT_DETECTED_ME
? "ME " : "",
1126 iph1
->natt_flags
& NAT_DETECTED_PEER
? "PEER" : "");
1129 /* payload existency check */
1130 if (iph1
->dhpub_p
== NULL
|| iph1
->nonce_p
== NULL
) {
1131 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1132 "few isakmp message received.\n");
1136 iph1
->status
= PHASE1ST_MSG2RECEIVED
;
1149 VPTRINIT(iph1
->dhpub_p
);
1150 VPTRINIT(iph1
->nonce_p
);
1151 VPTRINIT(iph1
->id_p
);
1160 * sig: HDR, KE, Nr [, CR ]
1161 * gssapi: HDR, KE, Nr, GSSr
1162 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
1163 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
1166 ident_r2send(iph1
, msg
)
1167 struct ph1handle
*iph1
;
1172 /* validity check */
1173 if (iph1
->status
!= PHASE1ST_MSG2RECEIVED
) {
1174 plog(LLV_ERROR
, LOCATION
, NULL
,
1175 "status mismatched %d.\n", iph1
->status
);
1179 /* generate DH public value */
1180 if (oakley_dh_generate(iph1
->approval
->dhgrp
,
1181 &iph1
->dhpub
, &iph1
->dhpriv
) < 0)
1184 /* generate NONCE value */
1185 iph1
->nonce
= eay_set_random(iph1
->rmconf
->nonce_size
);
1186 if (iph1
->nonce
== NULL
)
1190 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1191 gssapi_get_rtoken(iph1
, NULL
);
1194 /* create HDR;KE;NONCE payload */
1195 iph1
->sendbuf
= ident_ir2mx(iph1
);
1196 if (iph1
->sendbuf
== NULL
)
1199 #ifdef HAVE_PRINT_ISAKMP_C
1200 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
1203 /* send the packet, add to the schedule to resend */
1204 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
1205 if (isakmp_ph1resend(iph1
) == -1)
1208 /* the sending message is added to the received-list. */
1209 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
1210 plog(LLV_ERROR
, LOCATION
, NULL
,
1211 "failed to add a response packet to the tree.\n");
1215 /* compute sharing secret of DH */
1216 if (oakley_dh_compute(iph1
->approval
->dhgrp
, iph1
->dhpub
,
1217 iph1
->dhpriv
, iph1
->dhpub_p
, &iph1
->dhgxy
) < 0)
1220 /* generate SKEYIDs & IV & final cipher key */
1221 if (oakley_skeyid(iph1
) < 0)
1223 if (oakley_skeyid_dae(iph1
) < 0)
1225 if (oakley_compute_enckey(iph1
) < 0)
1227 if (oakley_newiv(iph1
) < 0)
1230 iph1
->status
= PHASE1ST_MSG2SENT
;
1239 * receive from initiator
1240 * psk: HDR*, IDi1, HASH_I
1241 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
1242 * gssapi: HDR*, [ IDi1, ] < GSSi(n) | HASH_I >
1247 ident_r3recv(iph1
, msg0
)
1248 struct ph1handle
*iph1
;
1251 vchar_t
*msg
= NULL
;
1252 vchar_t
*pbuf
= NULL
;
1253 struct isakmp_parse_t
*pa
;
1257 vchar_t
*gsstoken
= NULL
;
1260 /* validity check */
1261 if (iph1
->status
!= PHASE1ST_MSG2SENT
) {
1262 plog(LLV_ERROR
, LOCATION
, NULL
,
1263 "status mismatched %d.\n", iph1
->status
);
1268 if (!ISSET(((struct isakmp
*)msg0
->v
)->flags
, ISAKMP_FLAG_E
)) {
1269 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1270 "reject the packet, "
1271 "expecting the packet encrypted.\n");
1274 msg
= oakley_do_decrypt(iph1
, msg0
, iph1
->ivm
->iv
, iph1
->ivm
->ive
);
1278 /* validate the type of next payload */
1279 pbuf
= isakmp_parse(msg
);
1283 iph1
->pl_hash
= NULL
;
1285 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
1286 pa
->type
!= ISAKMP_NPTYPE_NONE
;
1290 case ISAKMP_NPTYPE_ID
:
1291 if (isakmp_p2ph(&iph1
->id_p
, pa
->ptr
) < 0)
1294 case ISAKMP_NPTYPE_HASH
:
1295 iph1
->pl_hash
= (struct isakmp_pl_hash
*)pa
->ptr
;
1297 case ISAKMP_NPTYPE_CR
:
1298 if (oakley_savecr(iph1
, pa
->ptr
) < 0)
1301 case ISAKMP_NPTYPE_CERT
:
1302 if (oakley_savecert(iph1
, pa
->ptr
) < 0)
1305 case ISAKMP_NPTYPE_SIG
:
1306 if (isakmp_p2ph(&iph1
->sig_p
, pa
->ptr
) < 0)
1310 case ISAKMP_NPTYPE_GSS
:
1311 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
1313 gssapi_save_received_token(iph1
, gsstoken
);
1316 case ISAKMP_NPTYPE_VID
:
1317 (void)check_vendorid(pa
->ptr
);
1319 case ISAKMP_NPTYPE_N
:
1320 isakmp_check_notify(pa
->ptr
, iph1
);
1323 /* don't send information, see ident_r1recv() */
1324 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1325 "ignore the packet, "
1326 "received unexpecting payload type %d.\n",
1332 /* payload existency check */
1333 /* XXX same as ident_i4recv(), should be merged. */
1337 switch (iph1
->approval
->authmethod
) {
1338 case OAKLEY_ATTR_AUTH_METHOD_PSKEY
:
1339 if (iph1
->id_p
== NULL
|| iph1
->pl_hash
== NULL
)
1342 case OAKLEY_ATTR_AUTH_METHOD_DSSSIG
:
1343 case OAKLEY_ATTR_AUTH_METHOD_RSASIG
:
1344 if (iph1
->id_p
== NULL
|| iph1
->sig_p
== NULL
)
1347 case OAKLEY_ATTR_AUTH_METHOD_RSAENC
:
1348 case OAKLEY_ATTR_AUTH_METHOD_RSAREV
:
1349 if (iph1
->pl_hash
== NULL
)
1353 case OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
:
1354 if (gsstoken
== NULL
&& iph1
->pl_hash
== NULL
)
1359 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1360 "invalid authmethod %d why ?\n",
1361 iph1
->approval
->authmethod
);
1365 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1366 "few isakmp message received.\n");
1371 /* verify identifier */
1372 if (ipsecdoi_checkid1(iph1
) != 0) {
1373 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1374 "invalid ID payload.\n");
1378 /* validate authentication value */
1380 if (gsstoken
== NULL
) {
1382 type
= oakley_validate_auth(iph1
);
1385 /* msg printed inner oakley_validate_auth() */
1388 EVT_PUSH(iph1
->local
, iph1
->remote
,
1389 EVTT_PEERPH1AUTH_FAILED
, NULL
);
1390 isakmp_info_send_n1(iph1
, type
, NULL
);
1397 if (oakley_checkcr(iph1
) < 0) {
1398 /* Ignore this error in order to be interoperability. */
1403 * XXX: Should we do compare two addresses, ph1handle's and ID
1407 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
, "peer's ID\n");
1408 plogdump(LLV_DEBUG
, iph1
->id_p
->v
, iph1
->id_p
->l
);
1410 /* see handler.h about IV synchronization. */
1411 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->ive
->l
);
1414 iph1
->status
= gsstoken
!= NULL
? PHASE1ST_MSG2RECEIVED
:
1415 PHASE1ST_MSG3RECEIVED
;
1417 iph1
->status
= PHASE1ST_MSG3RECEIVED
;
1433 VPTRINIT(iph1
->id_p
);
1434 oakley_delcert(iph1
->cert_p
);
1435 iph1
->cert_p
= NULL
;
1436 oakley_delcert(iph1
->crl_p
);
1438 VPTRINIT(iph1
->sig_p
);
1439 oakley_delcert(iph1
->cr_p
);
1448 * psk: HDR*, IDr1, HASH_R
1449 * sig: HDR*, IDr1, [ CERT, ] SIG_R
1450 * gssapi: HDR*, IDr1, < GSSr(n) | HASH_R >
1455 ident_r3send(iph1
, msg
)
1456 struct ph1handle
*iph1
;
1465 /* validity check */
1466 if (iph1
->status
!= PHASE1ST_MSG3RECEIVED
) {
1467 plog(LLV_ERROR
, LOCATION
, NULL
,
1468 "status mismatched %d.\n", iph1
->status
);
1472 /* make ID payload into isakmp status */
1473 if (ipsecdoi_setid1(iph1
) < 0)
1477 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
1478 gssapi_more_tokens(iph1
)) {
1479 gssapi_get_rtoken(iph1
, &len
);
1486 /* generate HASH to send */
1487 plog(LLV_DEBUG
, LOCATION
, NULL
, "generate HASH_R\n");
1488 iph1
->hash
= oakley_ph1hash_common(iph1
, GENERATE
);
1489 if (iph1
->hash
== NULL
)
1494 /* set encryption flag */
1495 iph1
->flags
|= ISAKMP_FLAG_E
;
1497 /* create HDR;ID;HASH payload */
1498 iph1
->sendbuf
= ident_ir3mx(iph1
);
1499 if (iph1
->sendbuf
== NULL
)
1502 /* send HDR;ID;HASH to responder */
1503 if (isakmp_send(iph1
, iph1
->sendbuf
) < 0)
1506 /* the sending message is added to the received-list. */
1507 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
1508 plog(LLV_ERROR
, LOCATION
, NULL
,
1509 "failed to add a response packet to the tree.\n");
1513 /* see handler.h about IV synchronization. */
1514 memcpy(iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->v
, iph1
->ivm
->iv
->l
);
1516 iph1
->status
= PHASE1ST_ESTABLISHED
;
1526 * This is used in main mode for:
1527 * initiator's 3rd exchange send to responder
1530 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
1531 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
1532 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
1533 * responders 2nd exchnage send to initiator
1535 * sig: HDR, KE, Nr [, CR ]
1536 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
1537 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
1541 struct ph1handle
*iph1
;
1544 struct payload_list
*plist
= NULL
;
1547 vchar_t
*vid
= NULL
;
1550 vchar_t
*gsstoken
= NULL
;
1553 vchar_t
*natd
[2] = { NULL
, NULL
};
1556 /* create CR if need */
1557 if (iph1
->side
== RESPONDER
1558 && iph1
->rmconf
->send_cr
1559 && oakley_needcr(iph1
->approval
->authmethod
)
1560 && iph1
->rmconf
->peerscertfile
== NULL
) {
1562 cr
= oakley_getcr(iph1
);
1564 plog(LLV_ERROR
, LOCATION
, NULL
,
1565 "failed to get cr buffer.\n");
1571 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1572 gssapi_get_token_to_send(iph1
, &gsstoken
);
1575 /* create isakmp KE payload */
1576 plist
= isakmp_plist_append(plist
, iph1
->dhpub
, ISAKMP_NPTYPE_KE
);
1578 /* create isakmp NONCE payload */
1579 plist
= isakmp_plist_append(plist
, iph1
->nonce
, ISAKMP_NPTYPE_NONCE
);
1582 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1583 plist
= isakmp_plist_append(plist
, gsstoken
, ISAKMP_NPTYPE_GSS
);
1586 /* append vendor id, if needed */
1588 plist
= isakmp_plist_append(plist
, vid
, ISAKMP_NPTYPE_VID
);
1590 /* create isakmp CR payload if needed */
1592 plist
= isakmp_plist_append(plist
, cr
, ISAKMP_NPTYPE_CR
);
1595 /* generate and append NAT-D payloads */
1596 if (NATT_AVAILABLE(iph1
) && iph1
->status
== PHASE1ST_MSG2RECEIVED
)
1598 if ((natd
[0] = natt_hash_addr (iph1
, iph1
->remote
)) == NULL
) {
1599 plog(LLV_ERROR
, LOCATION
, NULL
,
1600 "NAT-D hashing failed for %s\n", saddr2str(iph1
->remote
));
1604 if ((natd
[1] = natt_hash_addr (iph1
, iph1
->local
)) == NULL
) {
1605 plog(LLV_ERROR
, LOCATION
, NULL
,
1606 "NAT-D hashing failed for %s\n", saddr2str(iph1
->local
));
1610 plog (LLV_INFO
, LOCATION
, NULL
, "Adding remote and local NAT-D payloads.\n");
1612 /* old Apple version sends natd payloads in the wrong order */
1613 if (iph1
->natt_options
->version
== VENDORID_NATT_APPLE
) {
1614 plist
= isakmp_plist_append(plist
, natd
[1], iph1
->natt_options
->payload_nat_d
);
1615 plist
= isakmp_plist_append(plist
, natd
[0], iph1
->natt_options
->payload_nat_d
);
1619 plist
= isakmp_plist_append(plist
, natd
[0], iph1
->natt_options
->payload_nat_d
);
1620 plist
= isakmp_plist_append(plist
, natd
[1], iph1
->natt_options
->payload_nat_d
);
1625 buf
= isakmp_plist_set_all (&plist
, iph1
);
1630 if (error
&& buf
!= NULL
) {
1654 * This is used in main mode for:
1655 * initiator's 4th exchange send to responder
1656 * psk: HDR*, IDi1, HASH_I
1657 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
1658 * gssapi: HDR*, [ IDi1, ] < GSSi(n) | HASH_I >
1661 * responders 3rd exchnage send to initiator
1662 * psk: HDR*, IDr1, HASH_R
1663 * sig: HDR*, IDr1, [ CERT, ] SIG_R
1664 * gssapi: HDR*, [ IDr1, ] < GSSr(n) | HASH_R >
1670 struct ph1handle
*iph1
;
1672 struct payload_list
*plist
= NULL
;
1673 vchar_t
*buf
= NULL
, *new = NULL
;
1680 vchar_t
*gsstoken
= NULL
;
1681 vchar_t
*gsshash
= NULL
;
1684 switch (iph1
->approval
->authmethod
) {
1685 case OAKLEY_ATTR_AUTH_METHOD_PSKEY
:
1686 /* create isakmp ID payload */
1687 plist
= isakmp_plist_append(plist
, iph1
->id
, ISAKMP_NPTYPE_ID
);
1689 /* create isakmp HASH payload */
1690 plist
= isakmp_plist_append(plist
, iph1
->hash
, ISAKMP_NPTYPE_HASH
);
1692 case OAKLEY_ATTR_AUTH_METHOD_DSSSIG
:
1693 case OAKLEY_ATTR_AUTH_METHOD_RSASIG
:
1694 if (oakley_getmycert(iph1
) < 0)
1697 if (oakley_getsign(iph1
) < 0)
1700 /* create CR if need */
1701 if (iph1
->side
== INITIATOR
1702 && iph1
->rmconf
->send_cr
1703 && oakley_needcr(iph1
->approval
->authmethod
)
1704 && iph1
->rmconf
->peerscertfile
== NULL
) {
1706 cr
= oakley_getcr(iph1
);
1708 plog(LLV_ERROR
, LOCATION
, NULL
,
1709 "failed to get cr buffer.\n");
1714 if (iph1
->cert
!= NULL
&& iph1
->rmconf
->send_cert
)
1717 /* add ID payload */
1718 plist
= isakmp_plist_append(plist
, iph1
->id
, ISAKMP_NPTYPE_ID
);
1720 /* add CERT payload if there */
1722 plist
= isakmp_plist_append(plist
, iph1
->cert
->pl
, ISAKMP_NPTYPE_CERT
);
1723 /* add SIG payload */
1724 plist
= isakmp_plist_append(plist
, iph1
->sig
, ISAKMP_NPTYPE_SIG
);
1726 /* create isakmp CR payload */
1728 plist
= isakmp_plist_append(plist
, cr
, ISAKMP_NPTYPE_CR
);
1731 case OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
:
1732 if (iph1
->hash
!= NULL
) {
1733 gsshash
= gssapi_wraphash(iph1
);
1734 if (gsshash
== NULL
)
1737 gssapi_get_token_to_send(iph1
, &gsstoken
);
1740 if (!gssapi_id_sent(iph1
)) {
1741 /* create isakmp ID payload */
1742 plist
= isakmp_plist_append(plist
, iph1
->id
, ISAKMP_NPTYPE_ID
);
1743 gssapi_set_id_sent(iph1
);
1746 if (iph1
->hash
!= NULL
)
1747 /* create isakmp HASH payload */
1748 plist
= isakmp_plist_append(plist
, gsshash
, ISAKMP_NPTYPE_HASH
);
1750 plist
= isakmp_plist_append(plist
, gsstoken
, ISAKMP_NPTYPE_GSS
);
1753 case OAKLEY_ATTR_AUTH_METHOD_RSAENC
:
1754 case OAKLEY_ATTR_AUTH_METHOD_RSAREV
:
1755 plog(LLV_ERROR
, LOCATION
, NULL
,
1756 "not supported authentication type %d\n",
1757 iph1
->approval
->authmethod
);
1760 plog(LLV_ERROR
, LOCATION
, NULL
,
1761 "invalid authentication type %d\n",
1762 iph1
->approval
->authmethod
);
1766 buf
= isakmp_plist_set_all (&plist
, iph1
);
1768 #ifdef HAVE_PRINT_ISAKMP_C
1769 isakmp_printpacket(buf
, iph1
->local
, iph1
->remote
, 1);
1773 new = oakley_do_encrypt(iph1
, buf
, iph1
->ivm
->ive
, iph1
->ivm
->iv
);
1786 if (error
&& buf
!= NULL
) {