Home | History | Annotate | Download | only in racoon

Lines Matching refs:iph1

108 ident_i1send(iph1, msg)
109 struct ph1handle *iph1;
134 if (iph1->status != PHASE1ST_START) {
136 "status mismatched %d.\n", iph1->status);
141 memset(&iph1->index, 0, sizeof(iph1->index));
142 isakmp_newcookie((caddr_t)&iph1->index, iph1->remote, iph1->local);
145 iph1->sa = ipsecdoi_setph1proposal(iph1->rmconf,
146 iph1->rmconf->proposal);
147 if (iph1->sa == NULL)
151 plist = isakmp_plist_append(plist, iph1->sa, ISAKMP_NPTYPE_SA);
155 if (iph1->rmconf->nat_traversal)
160 switch (iph1->rmconf->proposal->authmethod) {
187 if (iph1->rmconf->ike_frag) {
200 if(iph1->rmconf->dpd){
208 iph1->sendbuf = isakmp_plist_set_all (&plist, iph1);
211 isakmp_printpacket(iph1->sendbuf, iph1->local, iph1->remote, 0);
215 if (isakmp_ph1send(iph1) == -1)
218 iph1->status = PHASE1ST_MSG1SENT;
253 ident_i2recv(iph1, msg)
254 struct ph1handle *iph1;
263 if (iph1->status != PHASE1ST_MSG1SENT) {
265 "status mismatched %d.\n", iph1->status);
286 plog(LLV_ERROR, LOCATION, iph1->remote,
302 handle_vendorid(iph1, pa->ptr);
306 plog(LLV_ERROR, LOCATION, iph1->remote,
315 if (NATT_AVAILABLE(iph1))
316 plog(LLV_INFO, LOCATION, iph1->remote,
318 vid_string_by_id(iph1->natt_options->version));
322 if (ipsecdoi_checkph1proposal(satmp, iph1) < 0) {
323 plog(LLV_ERROR, LOCATION, iph1->remote,
328 VPTRINIT(iph1->sa_ret);
330 iph1->status = PHASE1ST_MSG2RECEIVED;
352 ident_i2send(iph1, msg)
353 struct ph1handle *iph1;
359 if (iph1->status != PHASE1ST_MSG2RECEIVED) {
361 "status mismatched %d.\n", iph1->status);
366 memcpy(&iph1->index.r_ck, &((struct isakmp *)msg->v)->r_ck,
370 if (oakley_dh_generate(iph1->approval->dhgrp,
371 &iph1->dhpub, &iph1->dhpriv) < 0)
375 iph1->nonce = eay_set_random(iph1->rmconf->nonce_size);
376 if (iph1->nonce == NULL)
380 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB &&
381 gssapi_get_itoken(iph1, NULL) < 0)
386 iph1->sendbuf = ident_ir2mx(iph1);
387 if (iph1->sendbuf == NULL)
391 isakmp_printpacket(iph1->sendbuf, iph1->local, iph1->remote, 0);
395 if (isakmp_ph1send(iph1) == -1)
399 if (add_recvdpkt(iph1->remote, iph1->local, iph1->sendbuf, msg) == -1) {
405 iph1->status = PHASE1ST_MSG2SENT;
422 ident_i3recv(iph1, msg)
423 struct ph1handle *iph1;
438 if (iph1->status != PHASE1ST_MSG2SENT) {
440 "status mismatched %d.\n", iph1->status);
455 if (isakmp_p2ph(&iph1->dhpub_p, pa->ptr) < 0)
459 if (isakmp_p2ph(&iph1->nonce_p, pa->ptr) < 0)
463 handle_vendorid(iph1, pa->ptr);
466 if (oakley_savecr(iph1, pa->ptr) < 0)
473 gssapi_save_received_token(iph1, gsstoken);
480 if (NATT_AVAILABLE(iph1) && iph1->natt_options != NULL &&
481 pa->type == iph1->natt_options->payload_nat_d) {
489 iph1->natt_flags |= NAT_DETECTED;
492 from iph1->natt_flags */
493 natd_verified = natt_compare_addr_hash (iph1,
508 plog(LLV_ERROR, LOCATION, iph1->remote,
517 if (NATT_AVAILABLE(iph1)) {
519 iph1->natt_flags & NAT_DETECTED ?
521 iph1->natt_flags & NAT_DETECTED_ME ? "ME " : "",
522 iph1->natt_flags & NAT_DETECTED_PEER ? "PEER" : "");
523 if (iph1->natt_flags & NAT_DETECTED)
524 natt_float_ports (iph1);
529 if (iph1->dhpub_p == NULL || iph1->nonce_p == NULL) {
530 plog(LLV_ERROR, LOCATION, iph1->remote,
535 if (oakley_checkcr(iph1) < 0) {
540 iph1->status = PHASE1ST_MSG3RECEIVED;
552 VPTRINIT(iph1->dhpub_p);
553 VPTRINIT(iph1->nonce_p);
554 VPTRINIT(iph1->id_p);
555 VPTRINIT(iph1->cr_p);
570 ident_i3send(iph1, msg0)
571 struct ph1handle *iph1;
581 if (iph1->status != PHASE1ST_MSG3RECEIVED) {
583 "status mismatched %d.\n", iph1->status);
588 if (oakley_dh_compute(iph1->approval->dhgrp, iph1->dhpub,
589 iph1->dhpriv, iph1->dhpub_p, &iph1->dhgxy) < 0)
593 if (oakley_skeyid(iph1) < 0)
595 if (oakley_skeyid_dae(iph1) < 0)
597 if (oakley_compute_enckey(iph1) < 0)
599 if (oakley_newiv(iph1) < 0)
603 if (ipsecdoi_setid1(iph1) < 0)
607 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB &&
608 gssapi_more_tokens(iph1)) {
610 if (gssapi_get_itoken(iph1, &len) < 0)
619 iph1->hash = oakley_ph1hash_common(iph1, GENERATE);
620 if (iph1->hash == NULL)
623 iph1->hash = NULL;
626 iph1->flags |= ISAKMP_FLAG_E;
629 iph1->sendbuf = ident_ir3mx(iph1);
630 if (iph1->sendbuf == NULL)
634 if (isakmp_ph1send(iph1) == -1)
638 if (add_recvdpkt(iph1->remote, iph1->local, iph1->sendbuf, msg0) == -1) {
645 memcpy(iph1->ivm->ive->v, iph1->ivm->iv->v, iph1->ivm->iv->l);
647 iph1->status = PHASE1ST_MSG3SENT;
664 ident_i4recv(iph1, msg0)
665 struct ph1handle *iph1;
678 if (iph1->status != PHASE1ST_MSG3SENT) {
680 "status mismatched %d.\n", iph1
686 plog(LLV_ERROR, LOCATION, iph1->remote,
691 msg = oakley_do_decrypt(iph1, msg0, iph1->ivm->iv, iph1->ivm->ive);
700 iph1->pl_hash = NULL;
708 if (isakmp_p2ph(&iph1->id_p, pa->ptr) < 0)
712 iph1->pl_hash = (struct isakmp_pl_hash *)pa->ptr;
715 if (oakley_savecert(iph1, pa->ptr) < 0)
719 if (isakmp_p2ph(&iph1->sig_p, pa->ptr) < 0)
726 gssapi_save_received_token(iph1, gsstoken);
730 handle_vendorid(iph1, pa->ptr);
733 ident_recv_n(iph1, pa->ptr);
737 plog(LLV_ERROR, LOCATION, iph1->remote,
748 if (ipsecdoi_checkid1(iph1) != 0) {
749 plog(LLV_ERROR, LOCATION, iph1->remote,
758 type = oakley_validate_auth(iph1);
764 evt_phase1(iph1, EVT_PHASE1_AUTH_FAILED, NULL);
765 isakmp_info_send_n1(iph1, type, NULL);
777 plog(LLV_DEBUG, LOCATION, iph1->remote, "peer's ID:");
778 plogdump(LLV_DEBUG, iph1->id_p->v, iph1->id_p->l);
781 memcpy(iph1->ivm->iv->v, iph1->ivm->ive->v, iph1->ivm->ive->l);
787 iph1->status = gsstoken != 0 ? PHASE1ST_MSG3RECEIVED :
790 iph1->status = PHASE1ST_MSG4RECEIVED;
806 VPTRINIT(iph1->id_p);
807 VPTRINIT(iph1->cert_p);
808 VPTRINIT(iph1->crl_p);
809 VPTRINIT(iph1->sig_p);
819 ident_i4send(iph1, msg)
820 struct ph1handle *iph1;
826 if (iph1->status != PHASE1ST_MSG4RECEIVED) {
828 "status mismatched %d.\n", iph1->status);
833 memcpy(iph1->ivm->iv->v, iph1->ivm->ive->v, iph1->ivm->iv->l);
835 iph1->status = PHASE1ST_ESTABLISHED;
851 ident_r1recv(iph1, msg)
852 struct ph1handle *iph1;
861 if (iph1->status != PHASE1ST_START) {
863 "status mismatched %d.\n", iph1->status);
878 plog(LLV_ERROR, LOCATION, iph1->remote,
884 if (isakmp_p2ph(&iph1->sa, pa->ptr) < 0)
894 vid_numeric = handle_vendorid(iph1, pa->ptr);
898 iph1->frag = 1;
909 plog(LLV_ERROR, LOCATION, iph1->remote,
918 if (NATT_AVAILABLE(iph1))
919 plog(LLV_INFO, LOCATION, iph1->remote,
921 vid_string_by_id(iph1->natt_options->version));
925 if (ipsecdoi_checkph1proposal(iph1->sa, iph1) < 0) {
926 plog(LLV_ERROR, LOCATION, iph1->remote,
932 iph1->status = PHASE1ST_MSG1RECEIVED;
940 VPTRINIT(iph1->sa);
954 ident_r1send(iph1, msg)
955 struct ph1handle *iph1;
979 if (iph1->status != PHASE1ST_MSG1RECEIVED) {
981 "status mismatched %d.\n", iph1->status);
986 isakmp_newcookie((caddr_t)&iph1->index.r_ck, iph1->remote, iph1->local);
989 if (iph1->approval->gssid != NULL) {
990 gss_sa = ipsecdoi_setph1proposal(iph1->rmconf, iph1->approval);
991 if (gss_sa != iph1->sa_ret)
995 gss_sa = iph1->sa_ret;
1001 if (iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_XAUTH) {
1012 if (iph1->mode_cfg->flags & ISAKMP_CFG_VENDORID_UNITY) {
1024 if (NATT_AVAILABLE(iph1))
1025 vid_natt = set_vendorid(iph1->natt_options->version);
1031 if (iph1->dpd_support) {
1038 if (iph1->frag) {
1052 iph1->sendbuf = isakmp_plist_set_all (&plist, iph1);
1055 isakmp_printpacket(iph1->sendbuf, iph1->local, iph1->remote, 0);
1059 if (isakmp_ph1send(iph1) == -1)
1063 if (add_recvdpkt(iph1->remote, iph1->local, iph1->sendbuf, msg) == -1) {
1069 iph1->status = PHASE1ST_MSG1SENT;
1110 ident_r2recv(iph1, msg)
1111 struct ph1handle *iph1;
1125 if (iph1->status != PHASE1ST_MSG1SENT) {
1127 "status mismatched %d.\n", iph1->status);
1141 if (isakmp_p2ph(&iph1->dhpub_p, pa->ptr) < 0)
1145 if (isakmp_p2ph(&iph1->nonce_p, pa->ptr) < 0)
1149 handle_vendorid(iph1, pa->ptr);
1152 plog(LLV_WARNING, LOCATION, iph1->remote,
1160 gssapi_save_received_token(iph1, gsstoken);
1167 if (NATT_AVAILABLE(iph1) && iph1->natt_options != NULL &&
1168 pa->type == iph1->natt_options->payload_nat_d)
1177 iph1->natt_flags |= NAT_DETECTED;
1179 natd_verified = natt_compare_addr_hash (iph1,
1194 plog(LLV_ERROR, LOCATION, iph1->remote,
1203 if (NATT_AVAILABLE(iph1))
1205 iph1->natt_flags & NAT_DETECTED ?
1207 iph1->natt_flags & NAT_DETECTED_ME ? "ME " : "",
1208 iph1->natt_flags & NAT_DETECTED_PEER ? "PEER" : "");
1212 if (iph1->dhpub_p == NULL || iph1->nonce_p == NULL) {
1213 plog(LLV_ERROR, LOCATION, iph1->remote,
1218 iph1->status = PHASE1ST_MSG2RECEIVED;
1231 VPTRINIT(iph1->dhpub_p);
1232 VPTRINIT(iph1->nonce_p);
1233 VPTRINIT(iph1->id_p);
1248 ident_r2send(iph1, msg)
1249 struct ph1handle *iph1;
1255 if (iph1->status != PHASE1ST_MSG2RECEIVED) {
1257 "status mismatched %d.\n", iph1->status);
1262 if (oakley_dh_generate(iph1->approval->dhgrp,
1263 &iph1->dhpub, &iph1->dhpriv) < 0)
1267 iph1->nonce = eay_set_random(RMCONF_NONCE_SIZE(iph1->rmconf));
1268 if (iph1->nonce == NULL)
1272 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB)
1273 gssapi_get_rtoken(iph1, NULL);
1277 iph1->sendbuf = ident_ir2mx(iph1);
1278 if (iph1->sendbuf == NULL)
1282 isakmp_printpacket(iph1->sendbuf, iph1->local, iph1->remote, 0);
1286 if (isakmp_ph1send(iph1) == -1)
1290 if (add_recvdpkt(iph1->remote, iph1->local, iph1->sendbuf, msg) == -1) {
1297 if (oakley_dh_compute(iph1->approval->dhgrp, iph1->dhpub,
1298 iph1->dhpriv, iph1->dhpub_p, &iph1->dhgxy) < 0)
1302 if (oakley_skeyid(iph1) < 0)
1304 if (oakley_skeyid_dae(iph1) < 0)
1306 if (oakley_compute_enckey(iph1) < 0)
1308 if (oakley_newiv(iph1) < 0)
1311 iph1->status = PHASE1ST_MSG2SENT;
1328 ident_r3recv(iph1, msg0)
1329 struct ph1handle *iph1;
1342 if (iph1->status != PHASE1ST_MSG2SENT) {
1344 "status mismatched %d.\n", iph1->status);
1350 plog(LLV_ERROR, LOCATION, iph1->remote,
1355 msg = oakley_do_decrypt(iph1, msg0, iph1->ivm->iv, iph1->ivm->ive);
1364 iph1->pl_hash = NULL;
1372 if (isakmp_p2ph(&iph1->id_p, pa->ptr) < 0)
1374 if (resolveph1rmconf(iph1) < 0)
1378 iph1->pl_hash = (struct isakmp_pl_hash *)pa->ptr;
1381 if (oakley_savecr(iph1, pa->ptr) < 0)
1385 if (oakley_savecert(iph1, pa->ptr) < 0)
1389 if (isakmp_p2ph(&iph1->sig_p, pa->ptr) < 0)
1396 gssapi_save_received_token(iph1, gsstoken);
1400 handle_vendorid(iph1, pa->ptr);
1403 ident_recv_n(iph1, pa->ptr);
1407 plog(LLV_ERROR, LOCATION, iph1->remote,
1420 switch (iph1->approval->authmethod) {
1427 if (iph1->id_p == NULL || iph1->pl_hash == NULL)
1436 if (iph1->id_p == NULL || iph1->sig_p == NULL)
1445 if (iph1->pl_hash == NULL)
1450 if (gsstoken == NULL && iph1->pl_hash == NULL)
1455 plog(LLV_ERROR, LOCATION, iph1->remote,
1457 iph1->approval->authmethod);
1461 plog(LLV_ERROR, LOCATION, iph1->remote,
1468 if (ipsecdoi_checkid1(iph1) != 0) {
1469 plog(LLV_ERROR, LOCATION, iph1->remote,
1478 type = oakley_validate_auth(iph1);
1484 evt_phase1(iph1, EVT_PHASE1_AUTH_FAILED, NULL);
1485 isakmp_info_send_n1(iph1, type, NULL);
1492 if (oakley_checkcr(iph1) < 0) {
1502 plog(LLV_DEBUG, LOCATION, iph1->remote, "peer's ID\n");
1503 plogdump(LLV_DEBUG, iph1->id_p->v, iph1->id_p->l);
1506 memcpy(iph1->ivm->iv->v, iph1->ivm->ive->v, iph1->ivm->ive->l);
1509 iph1->status = gsstoken != NULL ? PHASE1ST_MSG2RECEIVED :
1512 iph1->status = PHASE1ST_MSG3RECEIVED;
1528 VPTRINIT(iph1->id_p);
1529 VPTRINIT(iph1->cert_p);
1530 VPTRINIT(iph1->crl_p);
1531 VPTRINIT(iph1->sig_p);
1532 VPTRINIT(iph1->cr_p);
1547 ident_r3send(iph1, msg)
1548 struct ph1handle *iph1;
1558 if (iph1->status != PHASE1ST_MSG3RECEIVED) {
1560 "status mismatched %d.\n", iph1->status);
1565 if (ipsecdoi_setid1(iph1) < 0)
1569 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB &&
1570 gssapi_more_tokens(iph1)) {
1571 gssapi_get_rtoken(iph1, &len);
1580 iph1->hash = oakley_ph1hash_common(iph1, GENERATE);
1581 if (iph1->hash == NULL)
1584 iph1->hash = NULL;
1587 iph1->flags |= ISAKMP_FLAG_E;
1590 iph1->sendbuf = ident_ir3mx(iph1);
1591 if (iph1->sendbuf == NULL)
1595 if (isakmp_send(iph1, iph1->sendbuf) < 0)
1599 if (add_recvdpkt(iph1->remote, iph1->local, iph1->sendbuf, msg) == -1) {
1606 memcpy(iph1->ivm->ive->v, iph1->ivm->iv->v, iph1->ivm->iv->l);
1608 iph1->status = PHASE1ST_ESTABLISHED;
1632 ident_ir2mx(iph1)
1633 struct ph1handle *iph1;
1647 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB) {
1648 if (gssapi_get_token_to_send(iph1, &gsstoken) < 0) {
1657 plist = isakmp_plist_append(plist, iph1->dhpub, ISAKMP_NPTYPE_KE);
1660 plist = isakmp_plist_append(plist, iph1->nonce, ISAKMP_NPTYPE_NONCE);
1663 if (iph1->approval->authmethod == OAKLEY_ATTR_AUTH_METHOD_GSSAPI_KRB)
1672 if (iph1->side == RESPONDER &&
1673 oakley_needcr(iph1->approval->authmethod))
1674 plist = oakley_append_cr(plist, iph1);
1678 if (NATT_AVAILABLE(iph1) && iph1->status == PHASE1ST_MSG2RECEIVED)
1680 if ((natd[0] = natt_hash_addr (iph1, iph1->remote)) == NULL) {
1682 "NAT-D hashing failed for %s\n", saddr2str(iph1->remote));
1686 if ((natd[1] = natt_hash_addr (iph1, iph1->local)) == NULL) {
1688 "NAT-D hashing failed for %s\n", saddr2str(iph1->local));
1693 plist = isakmp_plist_append(plist, natd[0], iph1->natt_options->payload_nat_d);
1694 plist = isakmp_plist_append(plist, natd[1], iph1->natt_options->payload_nat_d);
1698 buf = isakmp_plist_set_all (&plist, iph1);
1740 ident_ir3mx(iph1)
1741 struct ph1handle *iph1;
1753 switch (iph1->approval->authmethod) {
1762 plist = isakmp_plist_append(plist, iph1->id, ISAKMP_NPTYPE_ID);
1765 plist = isakmp_plist_append(plist, iph1->hash, ISAKMP_NPTYPE_HASH);
1777 if (oakley_getmycert(iph1) < 0)
1780 if (oakley_getsign(iph1) < 0)
1783 if (iph1->cert != NULL && iph1->rmconf->send_cert)
1787 plist = isakmp_plist_append(plist, iph1->id, ISAKMP_NPTYPE_ID);
1791 plist = isakmp_plist_append(plist, iph1->cert,
1794 plist = isakmp_plist_append(plist, iph1->sig, ISAKMP_NPTYPE_SIG);
1797 if (iph1->side == INITIATOR &&
1798 oakley_needcr(iph1->approval->authmethod))
1799 plist = oakley_append_cr(plist, iph1);
1803 if (iph1->hash != NULL) {
1804 gsshash = gssapi_wraphash(iph1);
1808 if (gssapi_get_token_to_send(iph1, &gsstoken) < 0) {
1815 if (!gssapi_id_sent(iph1)) {
1817 plist = isakmp_plist_append(plist, iph1->id, ISAKMP_NPTYPE_ID);
1818 gssapi_set_id_sent(iph1);
1821 if (iph1->hash != NULL)
1838 iph1->approval->authmethod);
1843 iph1->approval->authmethod);
1847 buf = isakmp_plist_set_all (&plist, iph1);
1850 isakmp_printpacket(buf, iph1->local, iph1->remote, 1);
1854 new = oakley_do_encrypt(iph1, buf, iph1->ivm->ive, iph1->ivm->iv);
1882 ident_recv_n(iph1, gen)
1883 struct ph1handle *iph1;
1892 iph1->initial_contact_received = TRUE;
1895 isakmp_log_notify(iph1, notify, "identity exchange");