1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
|
stf_status main_inI2_outR2_tail(struct pluto_crypto_req_cont *pcrc , struct pluto_crypto_req *r) { struct ke_continuation *ke = (struct ke_continuation *)pcrc; struct msg_digest *md = ke->md; struct state *st = md->st;
bool send_cr = FALSE;
send_cr = !no_cr_send && (st->st_oakley.auth == OAKLEY_RSA_SIG) && !has_preloaded_public_key(st) && st->st_connection->spd.that.ca.ptr != NULL;
echo_hdr(md, FALSE, ISAKMP_NEXT_KE);
if (!ship_KE(st, r, &st->st_gr , &md->rbody, ISAKMP_NEXT_NONCE)) { osw_abort(); return STF_INTERNAL_ERROR; }
#ifdef DEBUG { int next_payload; next_payload = ISAKMP_NEXT_NONE;
if(cur_debugging & IMPAIR_BUST_MR2) { next_payload = ISAKMP_NEXT_VID; } if(send_cr) { next_payload = ISAKMP_NEXT_CR; } if (!ship_nonce(&st->st_nr, r , &md->rbody , next_payload , "Nr")) return STF_INTERNAL_ERROR;
if (cur_debugging & IMPAIR_BUST_MR2) { pb_stream vid_pbs;
if (!out_generic((send_cr)? ISAKMP_NEXT_CR : ISAKMP_NEXT_NONE, &isakmp_vendor_id_desc, &md->rbody, &vid_pbs)) return STF_INTERNAL_ERROR; if (!out_zero(1500 , &vid_pbs, "Filler VID")) return STF_INTERNAL_ERROR; close_output_pbs(&vid_pbs); } } #else if (!ship_nonce(&st->st_nr, r , &md->rbody , (send_cr)? ISAKMP_NEXT_CR : ISAKMP_NEXT_NONE , "Nr")) return STF_INTERNAL_ERROR; #endif
if (send_cr) { if (st->st_connection->kind == CK_PERMANENT) { if (!build_and_ship_CR(CERT_X509_SIGNATURE , st->st_connection->spd.that.ca , &md->rbody, ISAKMP_NEXT_NONE)) return STF_INTERNAL_ERROR; } else { generalName_t *ca = NULL; if (collect_rw_ca_candidates(md, &ca)) { generalName_t *gn;
for (gn = ca; gn != NULL; gn = gn->next) { if (!build_and_ship_CR(CERT_X509_SIGNATURE, gn->name , &md->rbody , gn->next == NULL ? ISAKMP_NEXT_NONE : ISAKMP_NEXT_CR)) return STF_INTERNAL_ERROR; } free_generalNames(ca, FALSE); } else { if (!build_and_ship_CR(CERT_X509_SIGNATURE, empty_chunk , &md->rbody, ISAKMP_NEXT_NONE)) return STF_INTERNAL_ERROR; } } }
#ifdef NAT_TRAVERSAL if (st->hidden_variables.st_nat_traversal & NAT_T_WITH_NATD) { if (!nat_traversal_add_natd(ISAKMP_NEXT_NONE, &md->rbody, md)) return STF_INTERNAL_ERROR; } #endif
close_message(&md->rbody);
{
struct dh_continuation *dh = alloc_thing(struct dh_continuation , "main_inI2_outR2_tail"); stf_status e;
dh->md = NULL; dh->serialno = st->st_serialno; pcrc_init(&dh->dh_pcrc); dh->dh_pcrc.pcrc_func = main_inI2_outR2_calcdone; passert(st->st_suspended_md == NULL);
DBG(DBG_CONTROLMORE , DBG_log("main inI2_outR2: starting async DH calculation (group=%d)", st->st_oakley.group->group));
e = start_dh_secretiv(&dh->dh_pcrc, st , st->st_import , RESPONDER , st->st_oakley.group->group);
DBG(DBG_CONTROLMORE, DBG_log("started dh_secretiv, returned: stf=%s\n" , stf_status_name(e)));
if(e == STF_FAIL) { loglog(RC_LOG_SERIOUS, "failed to start async DH calculation, stf=%s\n" , stf_status_name(e)); return e; }
if(e == STF_SUSPEND) { st->st_calculating = FALSE; } } return STF_OK; }
|