1 /* $KAME: isakmp_ident.c,v 1.63 2001/12/12 17:57:26 sakane 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) */
34 #include <sys/types.h>
35 #include <sys/param.h>
41 #include <netinet/in.h>
42 #if TIME_WITH_SYS_TIME
43 # include <sys/time.h>
47 # include <sys/time.h>
61 #include "localconf.h"
62 #include "remoteconf.h"
63 #include "isakmp_var.h"
67 #include "ipsec_doi.h"
68 #include "crypto_openssl.h"
70 #include "isakmp_ident.h"
71 #include "isakmp_inf.h"
72 #include "isakmp_natd.h"
79 static vchar_t
*ident_ir2mx
__P((struct ph1handle
*));
80 static vchar_t
*ident_ir3mx
__P((struct ph1handle
*));
83 * begin Identity Protection Mode as initiator.
93 ident_i1send(iph1
, msg
)
94 struct ph1handle
*iph1
;
95 vchar_t
*msg
; /* must be null */
97 struct isakmp_gen
*gen
;
105 plog(LLV_ERROR
, LOCATION
, NULL
,
106 "msg has to be NULL in this function.\n");
109 if (iph1
->status
!= PHASE1ST_START
) {
110 plog(LLV_ERROR
, LOCATION
, NULL
,
111 "status mismatched %d.\n", iph1
->status
);
115 /* create isakmp index */
116 memset(&iph1
->index
, 0, sizeof(iph1
->index
));
117 isakmp_newcookie((caddr_t
)&iph1
->index
, iph1
->remote
, iph1
->local
);
119 /* create SA payload for my proposal */
120 iph1
->sa
= ipsecdoi_setph1proposal(iph1
->rmconf
->proposal
);
121 if (iph1
->sa
== NULL
)
124 /* create buffer to send isakmp payload */
125 tlen
= sizeof(struct isakmp
)
126 + sizeof(*gen
) + iph1
->sa
->l
;
129 vid
= set_vendorid(VENDORID_NATT
);
130 if (vid
) tlen
+= sizeof(*gen
) + vid
->l
;
133 iph1
->sendbuf
= vmalloc(tlen
);
134 if (iph1
->sendbuf
== NULL
) {
135 plog(LLV_ERROR
, LOCATION
, NULL
,
136 "failed to get buffer to send.\n");
140 /* set isakmp header */
141 p
= set_isakmp_header(iph1
->sendbuf
, iph1
, ISAKMP_NPTYPE_SA
);
145 /* set SA payload to propose */
146 p
= set_isakmp_payload(p
, iph1
->sa
, vid
? ISAKMP_NPTYPE_VID
: ISAKMP_NPTYPE_NONE
);
149 p
= set_isakmp_payload(p
, vid
, ISAKMP_NPTYPE_NONE
);
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
;
172 * receive from responder
179 ident_i2recv(iph1
, msg
)
180 struct ph1handle
*iph1
;
183 vchar_t
*pbuf
= NULL
;
184 struct isakmp_parse_t
*pa
;
185 vchar_t
*satmp
= NULL
;
189 if (iph1
->status
!= PHASE1ST_MSG1SENT
) {
190 plog(LLV_ERROR
, LOCATION
, NULL
,
191 "status mismatched %d.\n", iph1
->status
);
195 /* validate the type of next payload */
197 * NOTE: RedCreek(as responder) attaches N[responder-lifetime] here,
198 * if proposal-lifetime > lifetime-redcreek-wants.
200 * => According to the seciton 4.6.3 in RFC 2407, This is illegal.
201 * NOTE: we do not really care about ordering of VID and N.
203 * NOTE: even if there's multiple VID/N, we'll ignore them.
205 pbuf
= isakmp_parse(msg
);
208 pa
= (struct isakmp_parse_t
*)pbuf
->v
;
210 /* SA payload is fixed postion */
211 if (pa
->type
!= ISAKMP_NPTYPE_SA
) {
212 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
213 "received invalid next payload type %d, "
215 pa
->type
, ISAKMP_NPTYPE_SA
);
218 if (isakmp_p2ph(&satmp
, pa
->ptr
) < 0)
223 pa
->type
!= ISAKMP_NPTYPE_NONE
;
227 case ISAKMP_NPTYPE_VID
:
228 if (check_vendorid(pa
->ptr
) == VENDORID_NATT
)
231 iph1
->natt_flags
|= natt_remote_support
;
236 /* don't send information, see ident_r1recv() */
237 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
238 "ignore the packet, "
239 "received unexpecting payload type %d.\n",
245 /* check SA payload and set approval SA for use */
246 if (ipsecdoi_checkph1proposal(satmp
, iph1
) < 0) {
247 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
248 "failed to get valid proposal.\n");
249 /* XXX send information */
257 iph1
->status
= PHASE1ST_MSG2RECEIVED
;
273 * gssapi: HDR, KE, Ni, GSSi
274 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
275 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
276 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
279 ident_i2send(iph1
, msg
)
280 struct ph1handle
*iph1
;
286 if (iph1
->status
!= PHASE1ST_MSG2RECEIVED
) {
287 plog(LLV_ERROR
, LOCATION
, NULL
,
288 "status mismatched %d.\n", iph1
->status
);
292 /* fix isakmp index */
293 memcpy(&iph1
->index
.r_ck
, &((struct isakmp
*)msg
->v
)->r_ck
,
296 /* generate DH public value */
297 if (oakley_dh_generate(iph1
->approval
->dhgrp
,
298 &iph1
->dhpub
, &iph1
->dhpriv
) < 0)
301 /* generate NONCE value */
302 iph1
->nonce
= eay_set_random(iph1
->rmconf
->nonce_size
);
303 if (iph1
->nonce
== NULL
)
307 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
308 gssapi_get_itoken(iph1
, NULL
) < 0)
312 /* create buffer to send isakmp payload */
313 iph1
->sendbuf
= ident_ir2mx(iph1
);
314 if (iph1
->sendbuf
== NULL
)
317 #ifdef HAVE_PRINT_ISAKMP_C
318 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
321 /* send the packet, add to the schedule to resend */
322 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
323 if (isakmp_ph1resend(iph1
) == -1)
326 /* the sending message is added to the received-list. */
327 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
328 plog(LLV_ERROR
, LOCATION
, NULL
,
329 "failed to add a response packet to the tree.\n");
333 iph1
->status
= PHASE1ST_MSG2SENT
;
342 * receive from responder
344 * sig: HDR, KE, Nr [, CR ]
345 * gssapi: HDR, KE, Nr, GSSr
346 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
347 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
350 ident_i3recv(iph1
, msg
)
351 struct ph1handle
*iph1
;
354 vchar_t
*pbuf
= NULL
;
355 struct isakmp_parse_t
*pa
;
358 vchar_t
*gsstoken
= NULL
;
362 if (iph1
->status
!= PHASE1ST_MSG2SENT
) {
363 plog(LLV_ERROR
, LOCATION
, NULL
,
364 "status mismatched %d.\n", iph1
->status
);
368 /* validate the type of next payload */
369 pbuf
= isakmp_parse(msg
);
373 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
374 pa
->type
!= ISAKMP_NPTYPE_NONE
;
378 case ISAKMP_NPTYPE_KE
:
379 if (isakmp_p2ph(&iph1
->dhpub_p
, pa
->ptr
) < 0)
382 case ISAKMP_NPTYPE_NONCE
:
383 if (isakmp_p2ph(&iph1
->nonce_p
, pa
->ptr
) < 0)
386 case ISAKMP_NPTYPE_VID
:
387 (void)check_vendorid(pa
->ptr
);
389 #ifdef HAVE_SIGNING_C
390 case ISAKMP_NPTYPE_CR
:
391 if (oakley_savecr(iph1
, pa
->ptr
) < 0)
396 case ISAKMP_NPTYPE_GSS
:
397 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
399 gssapi_save_received_token(iph1
, gsstoken
);
402 case ISAKMP_NPTYPE_NATD
:
405 natd_match_t match
= natd_matches(iph1
, pa
->ptr
);
406 iph1
->natt_flags
|= natt_natd_received
;
407 if ((match
& natd_match_local
) != 0)
408 iph1
->natt_flags
|= natt_no_local_nat
;
409 if ((match
& natd_match_remote
) != 0)
410 iph1
->natt_flags
|= natt_no_remote_nat
;
415 /* don't send information, see ident_r1recv() */
416 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
417 "ignore the packet, "
418 "received unexpecting payload type %d.\n",
425 /* Determine if we need to switch to port 4500 */
426 if (natd_hasnat(iph1
))
428 /* There is a NAT between us! Switch to port 4500. */
429 if (iph1
->remote
->sa_family
== AF_INET
)
431 struct sockaddr_in
*sin
= (struct sockaddr_in
*)iph1
->remote
;
432 plog(LLV_INFO
, LOCATION
, NULL
,
433 "detected NAT, switching to port %d for %s",
434 PORT_ISAKMP_NATT
, saddr2str(iph1
->remote
));
435 sin
->sin_port
= htons(PORT_ISAKMP_NATT
);
436 sin
= (struct sockaddr_in
*)iph1
->local
;
437 sin
->sin_port
= htons(PORT_ISAKMP_NATT
);
442 /* payload existency check */
443 if (iph1
->dhpub_p
== NULL
|| iph1
->nonce_p
== NULL
) {
444 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
445 "few isakmp message received.\n");
449 #ifdef HAVE_SIGNING_C
450 if (oakley_checkcr(iph1
) < 0) {
451 /* Ignore this error in order to be interoperability. */
456 iph1
->status
= PHASE1ST_MSG3RECEIVED
;
464 VPTRINIT(iph1
->dhpub_p
);
465 VPTRINIT(iph1
->nonce_p
);
466 VPTRINIT(iph1
->id_p
);
467 oakley_delcert(iph1
->cr_p
);
476 * psk: HDR*, IDi1, HASH_I
477 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
478 * gssapi: HDR*, IDi1, < Gssi(n) | HASH_I >
483 ident_i3send(iph1
, msg0
)
484 struct ph1handle
*iph1
;
494 if (iph1
->status
!= PHASE1ST_MSG3RECEIVED
) {
495 plog(LLV_ERROR
, LOCATION
, NULL
,
496 "status mismatched %d.\n", iph1
->status
);
500 /* compute sharing secret of DH */
501 if (oakley_dh_compute(iph1
->approval
->dhgrp
, iph1
->dhpub
,
502 iph1
->dhpriv
, iph1
->dhpub_p
, &iph1
->dhgxy
) < 0)
505 /* generate SKEYIDs & IV & final cipher key */
506 if (oakley_skeyid(iph1
) < 0)
508 if (oakley_skeyid_dae(iph1
) < 0)
510 if (oakley_compute_enckey(iph1
) < 0)
512 if (oakley_newiv(iph1
) < 0)
515 /* make ID payload into isakmp status */
516 if (ipsecdoi_setid1(iph1
) < 0)
520 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
521 gssapi_more_tokens(iph1
)) {
522 plog(LLV_DEBUG
, LOCATION
, NULL
, "calling get_itoken\n");
523 if (gssapi_get_itoken(iph1
, &len
) < 0)
530 /* generate HASH to send */
532 iph1
->hash
= oakley_ph1hash_common(iph1
, GENERATE
);
533 if (iph1
->hash
== NULL
)
538 /* set encryption flag */
539 iph1
->flags
|= ISAKMP_FLAG_E
;
541 /* create HDR;ID;HASH payload */
542 iph1
->sendbuf
= ident_ir3mx(iph1
);
543 if (iph1
->sendbuf
== NULL
)
546 /* send the packet, add to the schedule to resend */
547 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
548 if (isakmp_ph1resend(iph1
) == -1)
551 /* the sending message is added to the received-list. */
552 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg0
) == -1) {
553 plog(LLV_ERROR
, LOCATION
, NULL
,
554 "failed to add a response packet to the tree.\n");
558 /* see handler.h about IV synchronization. */
559 memcpy(iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->v
, iph1
->ivm
->iv
->l
);
561 iph1
->status
= PHASE1ST_MSG3SENT
;
570 * receive from responder
571 * psk: HDR*, IDr1, HASH_R
572 * sig: HDR*, IDr1, [ CERT, ] SIG_R
573 * gssapi: HDR*, IDr1, < GSSr(n) | HASH_R >
578 ident_i4recv(iph1
, msg0
)
579 struct ph1handle
*iph1
;
582 vchar_t
*pbuf
= NULL
;
583 struct isakmp_parse_t
*pa
;
588 vchar_t
*gsstoken
= NULL
;
592 if (iph1
->status
!= PHASE1ST_MSG3SENT
) {
593 plog(LLV_ERROR
, LOCATION
, NULL
,
594 "status mismatched %d.\n", iph1
->status
);
599 if (!ISSET(((struct isakmp
*)msg0
->v
)->flags
, ISAKMP_FLAG_E
)) {
600 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
601 "ignore the packet, "
602 "expecting the packet encrypted.\n");
605 msg
= oakley_do_decrypt(iph1
, msg0
, iph1
->ivm
->iv
, iph1
->ivm
->ive
);
609 /* validate the type of next payload */
610 pbuf
= isakmp_parse(msg
);
614 iph1
->pl_hash
= NULL
;
616 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
617 pa
->type
!= ISAKMP_NPTYPE_NONE
;
621 case ISAKMP_NPTYPE_ID
:
622 if (isakmp_p2ph(&iph1
->id_p
, pa
->ptr
) < 0)
625 case ISAKMP_NPTYPE_HASH
:
626 iph1
->pl_hash
= (struct isakmp_pl_hash
*)pa
->ptr
;
628 #ifdef HAVE_SIGNING_C
629 case ISAKMP_NPTYPE_CERT
:
630 if (oakley_savecert(iph1
, pa
->ptr
) < 0)
633 case ISAKMP_NPTYPE_SIG
:
634 if (isakmp_p2ph(&iph1
->sig_p
, pa
->ptr
) < 0)
639 case ISAKMP_NPTYPE_GSS
:
640 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
642 gssapi_save_received_token(iph1
, gsstoken
);
645 case ISAKMP_NPTYPE_VID
:
646 (void)check_vendorid(pa
->ptr
);
648 case ISAKMP_NPTYPE_N
:
649 isakmp_check_notify(pa
->ptr
, iph1
);
652 /* don't send information, see ident_r1recv() */
653 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
654 "ignore the packet, "
655 "received unexpecting payload type %d.\n",
661 /* payload existency check */
663 /* see handler.h about IV synchronization. */
664 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->ive
->l
);
666 /* verify identifier */
667 if (ipsecdoi_checkid1(iph1
) != 0) {
668 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
669 "invalid ID payload.\n");
673 /* validate authentication value */
675 if (gsstoken
== NULL
) {
677 type
= oakley_validate_auth(iph1
);
680 /* msg printed inner oakley_validate_auth() */
683 isakmp_info_send_n1(iph1
, type
, NULL
);
691 * XXX: Should we do compare two addresses, ph1handle's and ID
695 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
, "peer's ID:");
696 plogdump(LLV_DEBUG
, iph1
->id_p
->v
, iph1
->id_p
->l
);
699 * If we got a GSS token, we need to this roundtrip again.
702 iph1
->status
= gsstoken
!= 0 ? PHASE1ST_MSG3RECEIVED
:
703 PHASE1ST_MSG4RECEIVED
;
705 iph1
->status
= PHASE1ST_MSG4RECEIVED
;
721 VPTRINIT(iph1
->id_p
);
722 oakley_delcert(iph1
->cert_p
);
724 oakley_delcert(iph1
->crl_p
);
726 VPTRINIT(iph1
->sig_p
);
733 * status update and establish isakmp sa.
736 ident_i4send(iph1
, msg
)
737 struct ph1handle
*iph1
;
743 if (iph1
->status
!= PHASE1ST_MSG4RECEIVED
) {
744 plog(LLV_ERROR
, LOCATION
, NULL
,
745 "status mismatched %d.\n", iph1
->status
);
749 /* see handler.h about IV synchronization. */
750 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->l
);
752 iph1
->status
= PHASE1ST_ESTABLISHED
;
761 * receive from initiator
768 ident_r1recv(iph1
, msg
)
769 struct ph1handle
*iph1
;
772 vchar_t
*pbuf
= NULL
;
773 struct isakmp_parse_t
*pa
;
777 if (iph1
->status
!= PHASE1ST_START
) {
778 plog(LLV_ERROR
, LOCATION
, NULL
,
779 "status mismatched %d.\n", iph1
->status
);
783 /* validate the type of next payload */
785 * NOTE: XXX even if multiple VID, we'll silently ignore those.
787 pbuf
= isakmp_parse(msg
);
790 pa
= (struct isakmp_parse_t
*)pbuf
->v
;
792 /* check the position of SA payload */
793 if (pa
->type
!= ISAKMP_NPTYPE_SA
) {
794 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
795 "received invalid next payload type %d, "
797 pa
->type
, ISAKMP_NPTYPE_SA
);
800 if (isakmp_p2ph(&iph1
->sa
, pa
->ptr
) < 0)
805 pa
->type
!= ISAKMP_NPTYPE_NONE
;
809 case ISAKMP_NPTYPE_VID
:
810 if (check_vendorid(pa
->ptr
) == VENDORID_NATT
)
812 iph1
->natt_flags
|= natt_remote_support
;
817 * We don't send information to the peer even
818 * if we received malformed packet. Because we
819 * can't distinguish the malformed packet and
820 * the re-sent packet. And we do same behavior
821 * when we expect encrypted packet.
823 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
824 "ignore the packet, "
825 "received unexpecting payload type %d.\n",
831 /* check SA payload and set approval SA for use */
832 if (ipsecdoi_checkph1proposal(iph1
->sa
, iph1
) < 0) {
833 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
834 "failed to get valid proposal.\n");
835 /* XXX send information */
839 iph1
->status
= PHASE1ST_MSG1RECEIVED
;
861 ident_r1send(iph1
, msg
)
862 struct ph1handle
*iph1
;
865 struct isakmp_gen
*gen
;
869 vchar_t
*gss_sa
= NULL
;
872 vchar_t
*nattvid
= NULL
;
876 if (iph1
->status
!= PHASE1ST_MSG1RECEIVED
) {
877 plog(LLV_ERROR
, LOCATION
, NULL
,
878 "status mismatched %d.\n", iph1
->status
);
882 /* set responder's cookie */
883 isakmp_newcookie((caddr_t
)&iph1
->index
.r_ck
, iph1
->remote
, iph1
->local
);
886 if (iph1
->approval
->gssid
!= NULL
)
887 gss_sa
= ipsecdoi_setph1proposal(iph1
->approval
);
890 gss_sa
= iph1
->sa_ret
;
892 /* create buffer to send isakmp payload */
893 tlen
= sizeof(struct isakmp
)
894 + sizeof(*gen
) + gss_sa
->l
;
896 if ((vid
= set_vendorid(iph1
->approval
->vendorid
)) != NULL
)
897 tlen
+= sizeof(*gen
) + vid
->l
;
900 if ((nattvid
= set_vendorid(VENDORID_NATT
)) != NULL
)
902 tlen
+= sizeof(*gen
) + nattvid
->l
;
906 iph1
->sendbuf
= vmalloc(tlen
);
907 if (iph1
->sendbuf
== NULL
) {
908 plog(LLV_ERROR
, LOCATION
, NULL
,
909 "failed to get buffer to send.\n");
913 /* set isakmp header */
914 p
= set_isakmp_header(iph1
->sendbuf
, iph1
, ISAKMP_NPTYPE_SA
);
918 /* set SA payload to reply */
919 p
= set_isakmp_payload(p
, gss_sa
,
920 (vid
|| nattvid
) ? ISAKMP_NPTYPE_VID
921 : ISAKMP_NPTYPE_NONE
);
923 /* Set Vendor ID, if necessary. */
925 p
= set_isakmp_payload(p
, vid
, nattvid
? ISAKMP_NPTYPE_VID
926 : ISAKMP_NPTYPE_NONE
);
929 p
= set_isakmp_payload(p
, nattvid
, ISAKMP_NPTYPE_NONE
);
931 #ifdef HAVE_PRINT_ISAKMP_C
932 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
935 /* send the packet, add to the schedule to resend */
936 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
937 if (isakmp_ph1resend(iph1
) == -1)
940 /* the sending message is added to the received-list. */
941 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
942 plog(LLV_ERROR
, LOCATION
, NULL
,
943 "failed to add a response packet to the tree.\n");
947 iph1
->status
= PHASE1ST_MSG1SENT
;
953 if (gss_sa
!= iph1
->sa_ret
)
964 * receive from initiator
967 * gssapi: HDR, KE, Ni, GSSi
968 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
969 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
970 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
973 ident_r2recv(iph1
, msg
)
974 struct ph1handle
*iph1
;
977 vchar_t
*pbuf
= NULL
;
978 struct isakmp_parse_t
*pa
;
981 vchar_t
*gsstoken
= NULL
;
985 if (iph1
->status
!= PHASE1ST_MSG1SENT
) {
986 plog(LLV_ERROR
, LOCATION
, NULL
,
987 "status mismatched %d.\n", iph1
->status
);
991 /* validate the type of next payload */
992 pbuf
= isakmp_parse(msg
);
996 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
997 pa
->type
!= ISAKMP_NPTYPE_NONE
;
1001 case ISAKMP_NPTYPE_KE
:
1002 if (isakmp_p2ph(&iph1
->dhpub_p
, pa
->ptr
) < 0)
1005 case ISAKMP_NPTYPE_NONCE
:
1006 if (isakmp_p2ph(&iph1
->nonce_p
, pa
->ptr
) < 0)
1009 case ISAKMP_NPTYPE_VID
:
1010 (void)check_vendorid(pa
->ptr
);
1012 case ISAKMP_NPTYPE_CR
:
1013 plog(LLV_WARNING
, LOCATION
, iph1
->remote
,
1014 "CR received, ignore it. "
1015 "It should be in other exchange.\n");
1018 case ISAKMP_NPTYPE_GSS
:
1019 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
1021 gssapi_save_received_token(iph1
, gsstoken
);
1024 case ISAKMP_NPTYPE_NATD
:
1027 natd_match_t match
= natd_matches(iph1
, pa
->ptr
);
1028 iph1
->natt_flags
|= natt_natd_received
;
1029 if ((match
& natd_match_local
) != 0)
1030 iph1
->natt_flags
|= natt_no_local_nat
;
1031 if ((match
& natd_match_remote
) != 0)
1032 iph1
->natt_flags
|= natt_no_remote_nat
;
1037 /* don't send information, see ident_r1recv() */
1038 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1039 "ignore the packet, "
1040 "received unexpecting payload type %d.\n",
1046 /* payload existency check */
1047 if (iph1
->dhpub_p
== NULL
|| iph1
->nonce_p
== NULL
) {
1048 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1049 "few isakmp message received.\n");
1053 iph1
->status
= PHASE1ST_MSG2RECEIVED
;
1066 VPTRINIT(iph1
->dhpub_p
);
1067 VPTRINIT(iph1
->nonce_p
);
1068 VPTRINIT(iph1
->id_p
);
1077 * sig: HDR, KE, Nr [, CR ]
1078 * gssapi: HDR, KE, Nr, GSSr
1079 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
1080 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
1083 ident_r2send(iph1
, msg
)
1084 struct ph1handle
*iph1
;
1089 /* validity check */
1090 if (iph1
->status
!= PHASE1ST_MSG2RECEIVED
) {
1091 plog(LLV_ERROR
, LOCATION
, NULL
,
1092 "status mismatched %d.\n", iph1
->status
);
1096 /* generate DH public value */
1097 if (oakley_dh_generate(iph1
->approval
->dhgrp
,
1098 &iph1
->dhpub
, &iph1
->dhpriv
) < 0)
1101 /* generate NONCE value */
1102 iph1
->nonce
= eay_set_random(iph1
->rmconf
->nonce_size
);
1103 if (iph1
->nonce
== NULL
)
1107 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1108 gssapi_get_rtoken(iph1
, NULL
);
1111 /* create HDR;KE;NONCE payload */
1112 iph1
->sendbuf
= ident_ir2mx(iph1
);
1113 if (iph1
->sendbuf
== NULL
)
1116 #ifdef HAVE_PRINT_ISAKMP_C
1117 isakmp_printpacket(iph1
->sendbuf
, iph1
->local
, iph1
->remote
, 0);
1120 /* send the packet, add to the schedule to resend */
1121 iph1
->retry_counter
= iph1
->rmconf
->retry_counter
;
1122 if (isakmp_ph1resend(iph1
) == -1)
1125 /* the sending message is added to the received-list. */
1126 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
1127 plog(LLV_ERROR
, LOCATION
, NULL
,
1128 "failed to add a response packet to the tree.\n");
1132 /* compute sharing secret of DH */
1133 if (oakley_dh_compute(iph1
->approval
->dhgrp
, iph1
->dhpub
,
1134 iph1
->dhpriv
, iph1
->dhpub_p
, &iph1
->dhgxy
) < 0)
1137 /* generate SKEYIDs & IV & final cipher key */
1138 if (oakley_skeyid(iph1
) < 0)
1140 if (oakley_skeyid_dae(iph1
) < 0)
1142 if (oakley_compute_enckey(iph1
) < 0)
1144 if (oakley_newiv(iph1
) < 0)
1147 iph1
->status
= PHASE1ST_MSG2SENT
;
1156 * receive from initiator
1157 * psk: HDR*, IDi1, HASH_I
1158 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
1159 * gssapi: HDR*, [ IDi1, ] < GSSi(n) | HASH_I >
1164 ident_r3recv(iph1
, msg0
)
1165 struct ph1handle
*iph1
;
1168 vchar_t
*msg
= NULL
;
1169 vchar_t
*pbuf
= NULL
;
1170 struct isakmp_parse_t
*pa
;
1174 vchar_t
*gsstoken
= NULL
;
1177 /* validity check */
1178 if (iph1
->status
!= PHASE1ST_MSG2SENT
) {
1179 plog(LLV_ERROR
, LOCATION
, NULL
,
1180 "status mismatched %d.\n", iph1
->status
);
1185 if (!ISSET(((struct isakmp
*)msg0
->v
)->flags
, ISAKMP_FLAG_E
)) {
1186 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1187 "reject the packet, "
1188 "expecting the packet encrypted.\n");
1191 msg
= oakley_do_decrypt(iph1
, msg0
, iph1
->ivm
->iv
, iph1
->ivm
->ive
);
1195 /* validate the type of next payload */
1196 pbuf
= isakmp_parse(msg
);
1200 iph1
->pl_hash
= NULL
;
1202 for (pa
= (struct isakmp_parse_t
*)pbuf
->v
;
1203 pa
->type
!= ISAKMP_NPTYPE_NONE
;
1207 case ISAKMP_NPTYPE_ID
:
1208 if (isakmp_p2ph(&iph1
->id_p
, pa
->ptr
) < 0)
1211 case ISAKMP_NPTYPE_HASH
:
1212 iph1
->pl_hash
= (struct isakmp_pl_hash
*)pa
->ptr
;
1214 #ifdef HAVE_SIGNING_C
1215 case ISAKMP_NPTYPE_CR
:
1216 if (oakley_savecr(iph1
, pa
->ptr
) < 0)
1219 case ISAKMP_NPTYPE_CERT
:
1220 if (oakley_savecert(iph1
, pa
->ptr
) < 0)
1223 case ISAKMP_NPTYPE_SIG
:
1224 if (isakmp_p2ph(&iph1
->sig_p
, pa
->ptr
) < 0)
1229 case ISAKMP_NPTYPE_GSS
:
1230 if (isakmp_p2ph(&gsstoken
, pa
->ptr
) < 0)
1232 gssapi_save_received_token(iph1
, gsstoken
);
1235 case ISAKMP_NPTYPE_VID
:
1236 (void)check_vendorid(pa
->ptr
);
1238 case ISAKMP_NPTYPE_N
:
1239 isakmp_check_notify(pa
->ptr
, iph1
);
1242 /* don't send information, see ident_r1recv() */
1243 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1244 "ignore the packet, "
1245 "received unexpecting payload type %d.\n",
1251 /* payload existency check */
1252 /* XXX same as ident_i4recv(), should be merged. */
1256 switch (iph1
->approval
->authmethod
) {
1257 case OAKLEY_ATTR_AUTH_METHOD_PSKEY
:
1258 if (iph1
->id_p
== NULL
|| iph1
->pl_hash
== NULL
)
1261 case OAKLEY_ATTR_AUTH_METHOD_DSSSIG
:
1262 case OAKLEY_ATTR_AUTH_METHOD_RSASIG
:
1263 if (iph1
->id_p
== NULL
|| iph1
->sig_p
== NULL
)
1266 case OAKLEY_ATTR_AUTH_METHOD_RSAENC
:
1267 case OAKLEY_ATTR_AUTH_METHOD_RSAREV
:
1268 if (iph1
->pl_hash
== NULL
)
1272 case OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
:
1273 if (gsstoken
== NULL
&& iph1
->pl_hash
== NULL
)
1278 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1279 "invalid authmethod %d why ?\n",
1280 iph1
->approval
->authmethod
);
1284 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1285 "few isakmp message received.\n");
1290 /* see handler.h about IV synchronization. */
1291 memcpy(iph1
->ivm
->iv
->v
, iph1
->ivm
->ive
->v
, iph1
->ivm
->ive
->l
);
1293 /* verify identifier */
1294 if (ipsecdoi_checkid1(iph1
) != 0) {
1295 plog(LLV_ERROR
, LOCATION
, iph1
->remote
,
1296 "invalid ID payload.\n");
1300 /* validate authentication value */
1302 if (gsstoken
== NULL
) {
1304 type
= oakley_validate_auth(iph1
);
1307 /* msg printed inner oakley_validate_auth() */
1310 isakmp_info_send_n1(iph1
, type
, NULL
);
1317 #ifdef HAVE_SIGNING_C
1318 if (oakley_checkcr(iph1
) < 0) {
1319 /* Ignore this error in order to be interoperability. */
1325 * XXX: Should we do compare two addresses, ph1handle's and ID
1329 plog(LLV_DEBUG
, LOCATION
, iph1
->remote
, "peer's ID\n");
1330 plogdump(LLV_DEBUG
, iph1
->id_p
->v
, iph1
->id_p
->l
);
1333 iph1
->status
= gsstoken
!= NULL
? PHASE1ST_MSG2RECEIVED
:
1334 PHASE1ST_MSG3RECEIVED
;
1336 iph1
->status
= PHASE1ST_MSG3RECEIVED
;
1352 VPTRINIT(iph1
->id_p
);
1353 oakley_delcert(iph1
->cert_p
);
1354 iph1
->cert_p
= NULL
;
1355 oakley_delcert(iph1
->crl_p
);
1357 VPTRINIT(iph1
->sig_p
);
1358 oakley_delcert(iph1
->cr_p
);
1367 * psk: HDR*, IDr1, HASH_R
1368 * sig: HDR*, IDr1, [ CERT, ] SIG_R
1369 * gssapi: HDR*, IDr1, < GSSr(n) | HASH_R >
1374 ident_r3send(iph1
, msg
)
1375 struct ph1handle
*iph1
;
1384 /* validity check */
1385 if (iph1
->status
!= PHASE1ST_MSG3RECEIVED
) {
1386 plog(LLV_ERROR
, LOCATION
, NULL
,
1387 "status mismatched %d.\n", iph1
->status
);
1391 /* make ID payload into isakmp status */
1392 if (ipsecdoi_setid1(iph1
) < 0)
1396 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
&&
1397 gssapi_more_tokens(iph1
)) {
1398 gssapi_get_rtoken(iph1
, &len
);
1405 /* generate HASH to send */
1406 plog(LLV_DEBUG
, LOCATION
, NULL
, "generate HASH_R\n");
1407 iph1
->hash
= oakley_ph1hash_common(iph1
, GENERATE
);
1408 if (iph1
->hash
== NULL
)
1413 /* set encryption flag */
1414 iph1
->flags
|= ISAKMP_FLAG_E
;
1416 /* create HDR;ID;HASH payload */
1417 iph1
->sendbuf
= ident_ir3mx(iph1
);
1418 if (iph1
->sendbuf
== NULL
)
1421 /* send HDR;ID;HASH to responder */
1422 if (isakmp_send(iph1
, iph1
->sendbuf
) < 0)
1425 /* the sending message is added to the received-list. */
1426 if (add_recvdpkt(iph1
->remote
, iph1
->local
, iph1
->sendbuf
, msg
) == -1) {
1427 plog(LLV_ERROR
, LOCATION
, NULL
,
1428 "failed to add a response packet to the tree.\n");
1432 /* see handler.h about IV synchronization. */
1433 memcpy(iph1
->ivm
->ive
->v
, iph1
->ivm
->iv
->v
, iph1
->ivm
->iv
->l
);
1435 iph1
->status
= PHASE1ST_ESTABLISHED
;
1445 * This is used in main mode for:
1446 * initiator's 3rd exchange send to responder
1449 * rsa: HDR, KE, [ HASH(1), ] <IDi1_b>PubKey_r, <Ni_b>PubKey_r
1450 * rev: HDR, [ HASH(1), ] <Ni_b>Pubkey_r, <KE_b>Ke_i,
1451 * <IDi1_b>Ke_i, [<<Cert-I_b>Ke_i]
1452 * responders 2nd exchnage send to initiator
1454 * sig: HDR, KE, Nr [, CR ]
1455 * rsa: HDR, KE, <IDr1_b>PubKey_i, <Nr_b>PubKey_i
1456 * rev: HDR, <Nr_b>PubKey_i, <KE_b>Ke_r, <IDr1_b>Ke_r,
1460 struct ph1handle
*iph1
;
1463 struct isakmp_gen
*gen
;
1468 vchar_t
*vid
= NULL
;
1472 vchar_t
*gsstoken
= NULL
;
1476 #ifdef HAVE_SIGNING_C
1477 /* create CR if need */
1478 if (iph1
->side
== RESPONDER
1479 && iph1
->rmconf
->send_cr
1480 && oakley_needcr(iph1
->approval
->authmethod
)
1481 && iph1
->rmconf
->peerscertfile
== NULL
) {
1483 cr
= oakley_getcr(iph1
);
1485 plog(LLV_ERROR
, LOCATION
, NULL
,
1486 "failed to get cr buffer.\n");
1493 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1494 gssapi_get_token_to_send(iph1
, &gsstoken
);
1498 tlen
= sizeof(struct isakmp
)
1499 + sizeof(*gen
) + iph1
->dhpub
->l
1500 + sizeof(*gen
) + iph1
->nonce
->l
;
1501 if ((vid
= set_vendorid(iph1
->approval
->vendorid
)) != NULL
)
1502 tlen
+= sizeof(*gen
) + vid
->l
;
1504 tlen
+= sizeof(*gen
) + cr
->l
;
1507 tlen
+= sizeof(*gen
) + gsstoken
->l
;
1511 if ((iph1
->natt_flags
& natt_remote_support
) != 0) {
1514 if (iph1
->local_natd
)
1515 tlen
+= sizeof(*gen
) + iph1
->local_natd
->l
;
1516 if (iph1
->remote_natd
)
1517 tlen
+= sizeof(*gen
) + iph1
->remote_natd
->l
;
1521 buf
= vmalloc(tlen
);
1523 plog(LLV_ERROR
, LOCATION
, NULL
,
1524 "failed to get buffer to send.\n");
1528 /* set isakmp header */
1529 p
= set_isakmp_header(buf
, iph1
, ISAKMP_NPTYPE_KE
);
1533 /* create isakmp KE payload */
1534 p
= set_isakmp_payload(p
, iph1
->dhpub
, ISAKMP_NPTYPE_NONCE
);
1536 /* create isakmp NONCE payload */
1538 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
)
1539 nptype
= ISAKMP_NPTYPE_GSS
;
1542 nptype
= vid
? ISAKMP_NPTYPE_VID
:
1543 (need_cr
? ISAKMP_NPTYPE_CR
:
1544 (need_natd
? ISAKMP_NPTYPE_NATD
: ISAKMP_NPTYPE_NONE
));
1545 p
= set_isakmp_payload(p
, iph1
->nonce
, nptype
);
1548 if (iph1
->approval
->authmethod
== OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
) {
1549 p
= set_isakmp_payload(p
, gsstoken
,
1550 vid
? ISAKMP_NPTYPE_VID
1551 : (need_cr
? ISAKMP_NPTYPE_CR
1552 : (need_natd
? ISAKMP_NPTYPE_NATD
: ISAKMP_NPTYPE_NONE
)));
1556 /* append vendor id, if needed */
1558 p
= set_isakmp_payload(p
, vid
,
1559 need_cr
? ISAKMP_NPTYPE_CR
1560 : (need_natd
? ISAKMP_NPTYPE_NATD
: ISAKMP_NPTYPE_NONE
));
1562 /* create isakmp CR payload if needed */
1564 p
= set_isakmp_payload(p
, cr
, need_natd
? ISAKMP_NPTYPE_NATD
: ISAKMP_NPTYPE_NONE
);
1568 if (iph1
->local_natd
)
1569 p
= set_isakmp_payload(p
, iph1
->local_natd
, ISAKMP_NPTYPE_NATD
);
1570 if (iph1
->remote_natd
)
1571 p
= set_isakmp_payload(p
, iph1
->remote_natd
, ISAKMP_NPTYPE_NONE
);
1577 if (error
&& buf
!= NULL
) {
1594 * This is used in main mode for:
1595 * initiator's 4th exchange send to responder
1596 * psk: HDR*, IDi1, HASH_I
1597 * sig: HDR*, IDi1, [ CR, ] [ CERT, ] SIG_I
1598 * gssapi: HDR*, [ IDi1, ] < GSSi(n) | HASH_I >
1601 * responders 3rd exchnage send to initiator
1602 * psk: HDR*, IDr1, HASH_R
1603 * sig: HDR*, IDr1, [ CERT, ] SIG_R
1604 * gssapi: HDR*, [ IDr1, ] < GSSr(n) | HASH_R >
1610 struct ph1handle
*iph1
;
1612 vchar_t
*buf
= NULL
, *new = NULL
;
1615 struct isakmp_gen
*gen
;
1622 vchar_t
*gsstoken
= NULL
;
1623 vchar_t
*gsshash
= NULL
;
1626 tlen
= sizeof(struct isakmp
);
1628 switch (iph1
->approval
->authmethod
) {
1629 case OAKLEY_ATTR_AUTH_METHOD_PSKEY
:
1630 tlen
+= sizeof(*gen
) + iph1
->id
->l
1631 + sizeof(*gen
) + iph1
->hash
->l
;
1633 buf
= vmalloc(tlen
);
1635 plog(LLV_ERROR
, LOCATION
, NULL
,
1636 "failed to get buffer to send.\n");
1640 /* set isakmp header */
1641 p
= set_isakmp_header(buf
, iph1
, ISAKMP_NPTYPE_ID
);
1645 /* create isakmp ID payload */
1646 p
= set_isakmp_payload(p
, iph1
->id
, ISAKMP_NPTYPE_HASH
);
1648 /* create isakmp HASH payload */
1649 p
= set_isakmp_payload(p
, iph1
->hash
, ISAKMP_NPTYPE_NONE
);
1651 #ifdef HAVE_SIGNING_C
1652 case OAKLEY_ATTR_AUTH_METHOD_DSSSIG
:
1653 case OAKLEY_ATTR_AUTH_METHOD_RSASIG
:
1654 if (oakley_getmycert(iph1
) < 0)
1657 if (oakley_getsign(iph1
) < 0)
1660 /* create CR if need */
1661 if (iph1
->side
== INITIATOR
1662 && iph1
->rmconf
->send_cr
1663 && oakley_needcr(iph1
->approval
->authmethod
)
1664 && iph1
->rmconf
->peerscertfile
== NULL
) {
1666 cr
= oakley_getcr(iph1
);
1668 plog(LLV_ERROR
, LOCATION
, NULL
,
1669 "failed to get cr buffer.\n");
1674 if (iph1
->cert
!= NULL
&& iph1
->rmconf
->send_cert
)
1677 tlen
+= sizeof(*gen
) + iph1
->id
->l
1678 + sizeof(*gen
) + iph1
->sig
->l
;
1680 tlen
+= sizeof(*gen
) + iph1
->cert
->pl
->l
;
1682 tlen
+= sizeof(*gen
) + cr
->l
;
1684 buf
= vmalloc(tlen
);
1686 plog(LLV_ERROR
, LOCATION
, NULL
,
1687 "failed to get buffer to send.\n");
1691 /* set isakmp header */
1692 p
= set_isakmp_header(buf
, iph1
, ISAKMP_NPTYPE_ID
);
1696 /* add ID payload */
1697 p
= set_isakmp_payload(p
, iph1
->id
, need_cert
1698 ? ISAKMP_NPTYPE_CERT
1699 : ISAKMP_NPTYPE_SIG
);
1701 /* add CERT payload if there */
1703 p
= set_isakmp_payload(p
, iph1
->cert
->pl
, ISAKMP_NPTYPE_SIG
);
1704 /* add SIG payload */
1705 p
= set_isakmp_payload(p
, iph1
->sig
,
1706 need_cr
? ISAKMP_NPTYPE_CR
: ISAKMP_NPTYPE_NONE
);
1708 /* create isakmp CR payload */
1710 p
= set_isakmp_payload(p
, cr
, ISAKMP_NPTYPE_NONE
);
1714 case OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB
:
1715 if (!gssapi_id_sent(iph1
))
1716 tlen
+= sizeof (*gen
) + iph1
->id
->l
;
1717 if (iph1
->hash
!= NULL
) {
1718 gsshash
= gssapi_wraphash(iph1
);
1719 if (gsshash
== NULL
)
1721 tlen
+= sizeof (*gen
) + gsshash
->l
;
1723 gssapi_get_token_to_send(iph1
, &gsstoken
);
1724 tlen
+= sizeof (*gen
) + gsstoken
->l
;
1727 buf
= vmalloc(tlen
);
1729 plog(LLV_ERROR
, LOCATION
, NULL
,
1730 "failed to get buffer to send.\n");
1734 /* set isakmp header */
1735 if (!gssapi_id_sent(iph1
))
1736 nptype
= ISAKMP_NPTYPE_ID
;
1738 nptype
= iph1
->hash
!= NULL
? ISAKMP_NPTYPE_HASH
:
1740 p
= set_isakmp_header(buf
, iph1
, nptype
);
1744 if (!gssapi_id_sent(iph1
)) {
1745 /* create isakmp ID payload */
1746 nptype
= iph1
->hash
!= NULL
? ISAKMP_NPTYPE_HASH
:
1748 p
= set_isakmp_payload(p
, iph1
->id
, nptype
);
1751 gssapi_set_id_sent(iph1
);
1754 if (iph1
->hash
!= NULL
)
1755 /* create isakmp HASH payload */
1756 p
= set_isakmp_payload(p
, gsshash
,
1757 ISAKMP_NPTYPE_NONE
);
1759 p
= set_isakmp_payload(p
, gsstoken
, ISAKMP_NPTYPE_NONE
);
1762 case OAKLEY_ATTR_AUTH_METHOD_RSAENC
:
1763 case OAKLEY_ATTR_AUTH_METHOD_RSAREV
:
1764 plog(LLV_ERROR
, LOCATION
, NULL
,
1765 "not supported authentication type %d\n",
1766 iph1
->approval
->authmethod
);
1769 plog(LLV_ERROR
, LOCATION
, NULL
,
1770 "invalid authentication type %d\n",
1771 iph1
->approval
->authmethod
);
1775 #ifdef HAVE_PRINT_ISAKMP_C
1776 isakmp_printpacket(buf
, iph1
->local
, iph1
->remote
, 1);
1780 new = oakley_do_encrypt(iph1
, buf
, iph1
->ivm
->ive
, iph1
->ivm
->iv
);
1793 if (error
&& buf
!= NULL
) {