Пример #1
0
bool ship_nonce(chunk_t *n, struct pluto_crypto_req *r,
		pb_stream *outs, u_int8_t np,
		const char *name)
{
	unpack_nonce(n, r);
	return justship_nonce(n, outs, np, name);
}
Пример #2
0
/*
 * for aggressive mode, this is sub-optimal, since we should have
 * had the crypto helper actually do everything, but we need to do
 * some additional work to set that all up, so this is fine for now.
 *
 */
static void aggr_inI1_outR1_continue1(struct pluto_crypto_req_cont *pcrc,
				      struct pluto_crypto_req *r,
				      err_t ugh)
{
	struct ke_continuation *ke = (struct ke_continuation *)pcrc;
	struct msg_digest *md = ke->ke_md;
	struct state *const st = md->st;
	stf_status e;

	DBG(DBG_CONTROLMORE,
	    DBG_log("aggr inI1_outR1: calculated ke+nonce, calculating DH"));

	if (st == NULL) {
		loglog(RC_LOG_SERIOUS,
		       "%s: Request was disconnected from state",
		       __FUNCTION__);
		release_any_md(&ke->ke_md);
		return;
	}

	/* XXX should check out ugh */
	passert(ugh == NULL);
	passert(cur_state == NULL);
	passert(st != NULL);

	passert(st->st_suspended_md == ke->ke_md);
	unset_suspended(st); /* no longer connected or suspended */

	set_cur_state(st);
	DBG(DBG_CONTROLMORE, DBG_log("#%lu %s:%u st->st_calculating = FALSE;", st->st_serialno, __FUNCTION__, __LINE__));
	st->st_calculating = FALSE;

	/* unpack first calculation */
	unpack_KE(st, r, &st->st_gr);

	/* unpack nonce too */
	unpack_nonce(&st->st_nr, r);

	/* NOTE: the "r" reply will get freed by our caller */

	/* set up second calculation */
	{
		struct dh_continuation *dh = alloc_thing(
			struct dh_continuation,
			"aggr outR1 DH");

		dh->dh_md = md;
		set_suspended(st, md);
		dh->dh_pcrc.pcrc_serialno = st->st_serialno;	/* transitional */
		pcrc_init(&dh->dh_pcrc, aggr_inI1_outR1_continue2);
		e = start_dh_secretiv(&dh->dh_pcrc, st,
				      st->st_import,
				      O_RESPONDER,
				      st->st_oakley.group->group);

		if (e != STF_SUSPEND) {
			if (dh->dh_md != NULL) {
				complete_v1_state_transition(&dh->dh_md, e);
				release_any_md(&dh->dh_md);
			}
		}

		reset_cur_state();
	}
}