merged multi-auth branch back into trunk
This commit is contained in:
@@ -570,7 +570,7 @@ static void handle_notify(private_child_create_t *this, notify_payload_t *notify
|
||||
*/
|
||||
static void process_payloads(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
sa_payload_t *sa_payload;
|
||||
ke_payload_t *ke_payload;
|
||||
@@ -579,8 +579,8 @@ static void process_payloads(private_child_create_t *this, message_t *message)
|
||||
/* defaults to TUNNEL mode */
|
||||
this->mode = MODE_TUNNEL;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
switch (payload->get_type(payload))
|
||||
{
|
||||
@@ -616,7 +616,7 @@ static void process_payloads(private_child_create_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -643,9 +643,9 @@ static status_t build_i(private_child_create_t *this, message_t *message)
|
||||
}
|
||||
break;
|
||||
case IKE_AUTH:
|
||||
if (!message->get_payload(message, ID_INITIATOR))
|
||||
if (message->get_message_id(message) != 1)
|
||||
{
|
||||
/* send only in the first request, not in subsequent EAP */
|
||||
/* send only in the first request, not in subsequent rounds */
|
||||
return NEED_MORE;
|
||||
}
|
||||
break;
|
||||
@@ -737,8 +737,6 @@ static status_t build_i(private_child_create_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_r(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
peer_cfg_t *peer_cfg;
|
||||
|
||||
switch (message->get_exchange_type(message))
|
||||
{
|
||||
case IKE_SA_INIT:
|
||||
@@ -747,42 +745,17 @@ static status_t process_r(private_child_create_t *this, message_t *message)
|
||||
get_nonce(message, &this->other_nonce);
|
||||
break;
|
||||
case IKE_AUTH:
|
||||
if (message->get_payload(message, ID_INITIATOR) == NULL)
|
||||
if (message->get_message_id(message) != 1)
|
||||
{
|
||||
/* wait until extensible authentication completed, if used */
|
||||
/* only handle first AUTH payload, not additional rounds */
|
||||
return NEED_MORE;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
process_payloads(this, message);
|
||||
|
||||
if (this->tsi == NULL || this->tsr == NULL)
|
||||
{
|
||||
DBG1(DBG_IKE, "TS payload missing in message");
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
if (peer_cfg)
|
||||
{
|
||||
host_t *me, *other;
|
||||
|
||||
me = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
|
||||
if (me == NULL)
|
||||
{
|
||||
me = this->ike_sa->get_my_host(this->ike_sa);
|
||||
}
|
||||
other = this->ike_sa->get_virtual_ip(this->ike_sa, FALSE);
|
||||
if (other == NULL)
|
||||
{
|
||||
other = this->ike_sa->get_other_host(this->ike_sa);
|
||||
}
|
||||
|
||||
this->config = peer_cfg->select_child_cfg(peer_cfg, this->tsr,
|
||||
this->tsi, me, other);
|
||||
}
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
@@ -810,10 +783,11 @@ static void handle_child_sa_failure(private_child_create_t *this,
|
||||
*/
|
||||
static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
peer_cfg_t *peer_cfg;
|
||||
payload_t *payload;
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
bool no_dh = TRUE;
|
||||
|
||||
|
||||
switch (message->get_exchange_type(message))
|
||||
{
|
||||
case IKE_SA_INIT:
|
||||
@@ -828,9 +802,8 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
no_dh = FALSE;
|
||||
break;
|
||||
case IKE_AUTH:
|
||||
if (message->get_payload(message, EXTENSIBLE_AUTHENTICATION))
|
||||
{
|
||||
/* wait until extensible authentication completed, if used */
|
||||
if (this->ike_sa->get_state(this->ike_sa) != IKE_ESTABLISHED)
|
||||
{ /* wait until all authentication round completed */
|
||||
return NEED_MORE;
|
||||
}
|
||||
default:
|
||||
@@ -844,6 +817,25 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
if (peer_cfg && this->tsi && this->tsr)
|
||||
{
|
||||
host_t *me, *other;
|
||||
|
||||
me = this->ike_sa->get_virtual_ip(this->ike_sa, TRUE);
|
||||
if (me == NULL)
|
||||
{
|
||||
me = this->ike_sa->get_my_host(this->ike_sa);
|
||||
}
|
||||
other = this->ike_sa->get_virtual_ip(this->ike_sa, FALSE);
|
||||
if (other == NULL)
|
||||
{
|
||||
other = this->ike_sa->get_other_host(this->ike_sa);
|
||||
}
|
||||
this->config = peer_cfg->select_child_cfg(peer_cfg, this->tsr,
|
||||
this->tsi, me, other);
|
||||
}
|
||||
|
||||
if (this->config == NULL)
|
||||
{
|
||||
DBG1(DBG_IKE, "traffic selectors %#R=== %#R inacceptable",
|
||||
@@ -854,8 +846,8 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
}
|
||||
|
||||
/* check if ike_config_t included non-critical error notifies */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -868,7 +860,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
DBG1(DBG_IKE,"configuration payload negotation "
|
||||
"failed, no CHILD_SA built");
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
handle_child_sa_failure(this, message);
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -877,7 +869,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
this->child_sa = child_sa_create(this->ike_sa->get_my_host(this->ike_sa),
|
||||
this->ike_sa->get_other_host(this->ike_sa), this->config, this->reqid,
|
||||
@@ -938,7 +930,7 @@ static status_t build_r(private_child_create_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
bool no_dh = TRUE;
|
||||
|
||||
@@ -951,9 +943,8 @@ static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
no_dh = FALSE;
|
||||
break;
|
||||
case IKE_AUTH:
|
||||
if (message->get_payload(message, EXTENSIBLE_AUTHENTICATION))
|
||||
{
|
||||
/* wait until extensible authentication completed, if used */
|
||||
if (this->ike_sa->get_state(this->ike_sa) != IKE_ESTABLISHED)
|
||||
{ /* wait until all authentication round completed */
|
||||
return NEED_MORE;
|
||||
}
|
||||
default:
|
||||
@@ -961,8 +952,8 @@ static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
}
|
||||
|
||||
/* check for erronous notifies */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -982,7 +973,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
{
|
||||
DBG1(DBG_IKE, "received %N notify, no CHILD_SA built",
|
||||
notify_type_names, type);
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
handle_child_sa_failure(this, message);
|
||||
/* an error in CHILD_SA creation is not critical */
|
||||
return SUCCESS;
|
||||
@@ -1000,7 +991,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
bad_group, diffie_hellman_group_names, this->dh_group);
|
||||
|
||||
this->public.task.migrate(&this->public.task, this->ike_sa);
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return NEED_MORE;
|
||||
}
|
||||
default:
|
||||
@@ -1008,7 +999,7 @@ static status_t process_i(private_child_create_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
process_payloads(this, message);
|
||||
|
||||
|
||||
@@ -114,15 +114,16 @@ static void build_payloads(private_child_delete_t *this, message_t *message)
|
||||
*/
|
||||
static void process_payloads(private_child_delete_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *payloads, *spis;
|
||||
enumerator_t *payloads;
|
||||
iterator_t *spis;
|
||||
payload_t *payload;
|
||||
delete_payload_t *delete_payload;
|
||||
u_int32_t *spi;
|
||||
protocol_id_t protocol;
|
||||
child_sa_t *child_sa;
|
||||
|
||||
payloads = message->get_payload_iterator(message);
|
||||
while (payloads->iterate(payloads, (void**)&payload))
|
||||
payloads = message->create_payload_enumerator(message);
|
||||
while (payloads->enumerate(payloads, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == DELETE)
|
||||
{
|
||||
|
||||
@@ -103,11 +103,11 @@ static status_t process_i_delete(private_child_rekey_t *this, message_t *message
|
||||
*/
|
||||
static void find_child(private_child_rekey_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
notify_payload_t *notify;
|
||||
u_int32_t spi;
|
||||
@@ -131,7 +131,7 @@ static void find_child(private_child_rekey_t *this, message_t *message)
|
||||
break;
|
||||
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -220,12 +220,12 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
|
||||
protocol_id_t protocol;
|
||||
u_int32_t spi;
|
||||
child_sa_t *to_delete;
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
/* handle NO_ADDITIONAL_SAS notify */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -239,12 +239,12 @@ static status_t process_i(private_child_rekey_t *this, message_t *message)
|
||||
charon->processor->queue_job(charon->processor,
|
||||
(job_t*)rekey_ike_sa_job_create(
|
||||
this->ike_sa->get_id(this->ike_sa), TRUE));
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (this->child_create->task.process(&this->child_create->task, message) == NEED_MORE)
|
||||
{
|
||||
|
||||
+666
-501
File diff suppressed because it is too large
Load Diff
@@ -64,12 +64,12 @@ static void add_auth_lifetime(private_ike_auth_lifetime_t *this, message_t *mess
|
||||
*/
|
||||
static void process_payloads(private_ike_auth_lifetime_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
notify_payload_t *notify;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -88,7 +88,7 @@ static void process_payloads(private_ike_auth_lifetime_t *this, message_t *messa
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* Copyright (C) 2006-2008 Martin Willi
|
||||
* Copyright (C) 2006-2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -97,71 +97,69 @@ static cert_payload_t *build_cert_payload(private_ike_cert_post_t *this, certifi
|
||||
return payload;
|
||||
}
|
||||
|
||||
/**
|
||||
* from ike_auth.c
|
||||
*/
|
||||
auth_class_t get_auth_class(peer_cfg_t *config);
|
||||
|
||||
/**
|
||||
* add certificates to message
|
||||
*/
|
||||
static void build_certs(private_ike_cert_post_t *this, message_t *message)
|
||||
{
|
||||
peer_cfg_t *peer_cfg;
|
||||
auth_cfg_t *auth;
|
||||
|
||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
if (peer_cfg && get_auth_class(peer_cfg) == AUTH_CLASS_PUBKEY)
|
||||
auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
|
||||
if (!peer_cfg ||
|
||||
(uintptr_t)auth->get(auth, AUTH_RULE_AUTH_CLASS) != AUTH_CLASS_PUBKEY)
|
||||
{
|
||||
switch (peer_cfg->get_cert_policy(peer_cfg))
|
||||
{
|
||||
case CERT_NEVER_SEND:
|
||||
break;
|
||||
case CERT_SEND_IF_ASKED:
|
||||
if (!this->ike_sa->has_condition(this->ike_sa, COND_CERTREQ_SEEN))
|
||||
{
|
||||
break;
|
||||
}
|
||||
/* FALL */
|
||||
case CERT_ALWAYS_SEND:
|
||||
return;
|
||||
}
|
||||
switch (peer_cfg->get_cert_policy(peer_cfg))
|
||||
{
|
||||
case CERT_NEVER_SEND:
|
||||
break;
|
||||
case CERT_SEND_IF_ASKED:
|
||||
if (!this->ike_sa->has_condition(this->ike_sa, COND_CERTREQ_SEEN))
|
||||
{
|
||||
cert_payload_t *payload;
|
||||
enumerator_t *enumerator;
|
||||
certificate_t *cert;
|
||||
auth_info_t *auth;
|
||||
auth_item_t item;
|
||||
|
||||
auth = this->ike_sa->get_my_auth(this->ike_sa);
|
||||
/* get subject cert first, then issuing certificates */
|
||||
if (!auth->get_item(auth, AUTHZ_SUBJECT_CERT, (void**)&cert))
|
||||
break;
|
||||
}
|
||||
/* FALL */
|
||||
case CERT_ALWAYS_SEND:
|
||||
{
|
||||
cert_payload_t *payload;
|
||||
enumerator_t *enumerator;
|
||||
certificate_t *cert;
|
||||
auth_rule_t type;
|
||||
|
||||
/* get subject cert first, then issuing certificates */
|
||||
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
|
||||
if (!cert)
|
||||
{
|
||||
break;
|
||||
}
|
||||
payload = build_cert_payload(this, cert);
|
||||
if (!payload)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DBG1(DBG_IKE, "sending end entity cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
message->add_payload(message, (payload_t*)payload);
|
||||
|
||||
enumerator = auth->create_enumerator(auth);
|
||||
while (enumerator->enumerate(enumerator, &type, &cert))
|
||||
{
|
||||
if (type == AUTH_RULE_IM_CERT)
|
||||
{
|
||||
break;
|
||||
}
|
||||
payload = build_cert_payload(this, cert);
|
||||
if (!payload)
|
||||
{
|
||||
break;
|
||||
}
|
||||
DBG1(DBG_IKE, "sending end entity cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
message->add_payload(message, (payload_t*)payload);
|
||||
|
||||
enumerator = auth->create_item_enumerator(auth);
|
||||
while (enumerator->enumerate(enumerator, &item, &cert))
|
||||
{
|
||||
if (item == AUTHZ_IM_CERT)
|
||||
payload = cert_payload_create_from_cert(cert);
|
||||
if (payload)
|
||||
{
|
||||
payload = cert_payload_create_from_cert(cert);
|
||||
if (payload)
|
||||
{
|
||||
DBG1(DBG_IKE, "sending issuer cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
message->add_payload(message, (payload_t*)payload);
|
||||
}
|
||||
DBG1(DBG_IKE, "sending issuer cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
message->add_payload(message, (payload_t*)payload);
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,12 +168,11 @@ static void build_certs(private_ike_cert_post_t *this, message_t *message)
|
||||
*/
|
||||
static status_t build_i(private_ike_cert_post_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
return NEED_MORE;
|
||||
if (message->get_payload(message, AUTHENTICATION))
|
||||
{ /* CERT payloads are sended along AUTH payloads */
|
||||
build_certs(this, message);
|
||||
}
|
||||
build_certs(this, message);
|
||||
return SUCCESS;
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -191,11 +188,14 @@ static status_t process_r(private_ike_cert_post_t *this, message_t *message)
|
||||
*/
|
||||
static status_t build_r(private_ike_cert_post_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
if (message->get_payload(message, AUTHENTICATION))
|
||||
{ /* CERT payloads are sended along AUTH payloads */
|
||||
build_certs(this, message);
|
||||
}
|
||||
if (this->ike_sa->get_state(this->ike_sa) != IKE_ESTABLISHED)
|
||||
{ /* stay alive, we might have additional rounds with certs */
|
||||
return NEED_MORE;
|
||||
}
|
||||
build_certs(this, message);
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -204,8 +204,8 @@ static status_t build_r(private_ike_cert_post_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_i(private_ike_cert_post_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
if (this->ike_sa->get_state(this->ike_sa) != IKE_ESTABLISHED)
|
||||
{ /* stay alive, we might have additional rounds with CERTS */
|
||||
return NEED_MORE;
|
||||
}
|
||||
return SUCCESS;
|
||||
|
||||
+157
-131
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright (C) 2008 Tobias Brunner
|
||||
* Copyright (C) 2006-2007 Martin Willi
|
||||
* Copyright (C) 2006-2009 Martin Willi
|
||||
* Hochschule fuer Technik Rapperswil
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
@@ -48,9 +48,9 @@ struct private_ike_cert_pre_t {
|
||||
bool initiator;
|
||||
|
||||
/**
|
||||
* Did we send a HTTP_CERT_LOOKUP_SUPPORTED Notify?
|
||||
* Do we accept HTTP certificate lookup requests
|
||||
*/
|
||||
bool http_cert_lookup_supported_sent;
|
||||
bool do_http_lookup;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -58,23 +58,22 @@ struct private_ike_cert_pre_t {
|
||||
*/
|
||||
static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
auth_info_t *auth;
|
||||
bool ca_found = FALSE;
|
||||
auth_cfg_t *auth;
|
||||
|
||||
auth = this->ike_sa->get_my_auth(this->ike_sa);
|
||||
auth = this->ike_sa->get_auth_cfg(this->ike_sa, TRUE);
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
switch(payload->get_type(payload))
|
||||
{
|
||||
case CERTIFICATE_REQUEST:
|
||||
{
|
||||
certreq_payload_t *certreq = (certreq_payload_t*)payload;
|
||||
chunk_t keyid;
|
||||
enumerator_t *enumerator;
|
||||
chunk_t keyid;
|
||||
|
||||
this->ike_sa->set_condition(this->ike_sa, COND_CERTREQ_SEEN, TRUE);
|
||||
|
||||
@@ -98,15 +97,12 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
DBG1(DBG_IKE, "received cert request for \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
auth->add_item(auth, AUTHN_CA_CERT, cert);
|
||||
cert->destroy(cert);
|
||||
ca_found = TRUE;
|
||||
auth->add(auth, AUTH_RULE_CA_CERT, cert);
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1(DBG_IKE, "received cert request for unknown ca "
|
||||
"with keyid %D", id);
|
||||
auth->add_item(auth, AUTHN_CA_CERT_KEYID, id);
|
||||
}
|
||||
id->destroy(id);
|
||||
}
|
||||
@@ -129,7 +125,7 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,6 +136,7 @@ static void process_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
static certificate_t *try_get_cert(cert_payload_t *cert_payload)
|
||||
{
|
||||
certificate_t *cert = NULL;
|
||||
|
||||
switch (cert_payload->get_cert_encoding(cert_payload))
|
||||
{
|
||||
case ENC_X509_SIGNATURE:
|
||||
@@ -158,7 +155,7 @@ static certificate_t *try_get_cert(cert_payload_t *cert_payload)
|
||||
}
|
||||
id = identification_create_from_encoding(ID_CERT_DER_SHA1, hash);
|
||||
cert = charon->credentials->get_cert(charon->credentials,
|
||||
CERT_X509, KEY_ANY, id, FALSE);
|
||||
CERT_X509, KEY_ANY, id, FALSE);
|
||||
id->destroy(id);
|
||||
break;
|
||||
}
|
||||
@@ -175,78 +172,81 @@ static certificate_t *try_get_cert(cert_payload_t *cert_payload)
|
||||
*/
|
||||
static void process_certs(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
auth_info_t *auth;
|
||||
auth_cfg_t *auth;
|
||||
bool first = TRUE;
|
||||
|
||||
auth = this->ike_sa->get_other_auth(this->ike_sa);
|
||||
auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == CERTIFICATE)
|
||||
{
|
||||
cert_payload_t *cert_payload = (cert_payload_t*)payload;
|
||||
cert_encoding_t type = cert_payload->get_cert_encoding(cert_payload);
|
||||
switch (type)
|
||||
cert_payload_t *cert_payload;
|
||||
cert_encoding_t encoding;
|
||||
certificate_t *cert;
|
||||
char *url;
|
||||
|
||||
cert_payload = (cert_payload_t*)payload;
|
||||
encoding = cert_payload->get_cert_encoding(cert_payload);
|
||||
|
||||
switch (encoding)
|
||||
{
|
||||
case ENC_X509_SIGNATURE:
|
||||
case ENC_X509_HASH_AND_URL:
|
||||
{
|
||||
if (type == ENC_X509_HASH_AND_URL &&
|
||||
!this->http_cert_lookup_supported_sent)
|
||||
if (!this->do_http_lookup)
|
||||
{
|
||||
DBG1(DBG_IKE, "received hash-and-url encoded cert, but"
|
||||
" we don't accept them, ignore");
|
||||
break;
|
||||
}
|
||||
|
||||
certificate_t *cert = try_get_cert(cert_payload);
|
||||
|
||||
/* FALL */
|
||||
}
|
||||
case ENC_X509_SIGNATURE:
|
||||
{
|
||||
cert = try_get_cert(cert_payload);
|
||||
if (cert)
|
||||
{
|
||||
/* we've got a certificate from the payload or the cache */
|
||||
if (first)
|
||||
{ /* the first certificate MUST be an end entity one */
|
||||
{ /* the first is an end entity certificate */
|
||||
DBG1(DBG_IKE, "received end entity cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
auth->add_item(auth, AUTHN_SUBJECT_CERT, cert);
|
||||
auth->add(auth, AUTH_HELPER_SUBJECT_CERT, cert);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1(DBG_IKE, "received issuer cert \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
auth->add_item(auth, AUTHN_IM_CERT, cert);
|
||||
auth->add(auth, AUTH_HELPER_IM_CERT, cert);
|
||||
}
|
||||
cert->destroy(cert);
|
||||
}
|
||||
else if (type == ENC_X509_HASH_AND_URL)
|
||||
else if (encoding == ENC_X509_HASH_AND_URL)
|
||||
{
|
||||
/* we received a "Hash and URL" encoded certificate that
|
||||
* we haven't fetched yet, we store the URL and fetch
|
||||
* it later */
|
||||
char *url = cert_payload->get_url(cert_payload);
|
||||
/* we fetch the certificate not yet, but only if
|
||||
* it is really needed during authentication */
|
||||
url = cert_payload->get_url(cert_payload);
|
||||
if (!url)
|
||||
{
|
||||
DBG1(DBG_IKE, "received invalid hash-and-url encoded"
|
||||
" cert, ignore");
|
||||
DBG1(DBG_IKE, "received invalid hash-and-url "
|
||||
"encoded cert, ignore");
|
||||
break;
|
||||
}
|
||||
|
||||
url = strdup(url);
|
||||
if (first)
|
||||
{ /* the first certificate MUST be an end entity one */
|
||||
{ /* first URL is for an end entity certificate */
|
||||
DBG1(DBG_IKE, "received hash-and-url for end"
|
||||
" entity cert \"%s\"", url);
|
||||
auth->add_item(auth, AUTHN_SUBJECT_HASH_URL, url);
|
||||
" entity cert \"%s\"", url);
|
||||
auth->add(auth, AUTH_HELPER_SUBJECT_HASH_URL, url);
|
||||
first = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
DBG1(DBG_IKE, "received hash-and-url for issuer"
|
||||
" cert \"%s\"", url);
|
||||
auth->add_item(auth, AUTHN_IM_HASH_URL, url);
|
||||
auth->add(auth, AUTH_HELPER_IM_HASH_URL, url);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -264,31 +264,23 @@ static void process_certs(private_ike_cert_pre_t *this, message_t *message)
|
||||
case ENC_OCSP_CONTENT:
|
||||
default:
|
||||
DBG1(DBG_ENC, "certificate encoding %N not supported",
|
||||
cert_encoding_names, cert_payload->get_cert_encoding(cert_payload));
|
||||
cert_encoding_names, encoding);
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a certificate request to the message, building request payload if required.
|
||||
* add the keyid of a certificate to the certificate request payload
|
||||
*/
|
||||
static void add_certreq_payload(message_t *message, certreq_payload_t **reqp,
|
||||
certificate_t *cert)
|
||||
static void add_certreq(certreq_payload_t **req, certificate_t *cert)
|
||||
{
|
||||
public_key_t *public;
|
||||
certreq_payload_t *req;
|
||||
|
||||
public = cert->get_public_key(cert);
|
||||
if (!public)
|
||||
{
|
||||
return;
|
||||
}
|
||||
switch (cert->get_type(cert))
|
||||
{
|
||||
case CERT_X509:
|
||||
{
|
||||
public_key_t *public;
|
||||
identification_t *keyid;
|
||||
x509_t *x509 = (x509_t*)cert;
|
||||
|
||||
@@ -296,14 +288,18 @@ static void add_certreq_payload(message_t *message, certreq_payload_t **reqp,
|
||||
{ /* no CA cert, skip */
|
||||
break;
|
||||
}
|
||||
if (*reqp == NULL)
|
||||
public = cert->get_public_key(cert);
|
||||
if (!public)
|
||||
{
|
||||
*reqp = certreq_payload_create_type(CERT_X509);
|
||||
message->add_payload(message, (payload_t*)*reqp);
|
||||
break;
|
||||
}
|
||||
if (*req == NULL)
|
||||
{
|
||||
*req = certreq_payload_create_type(CERT_X509);
|
||||
}
|
||||
req = *reqp;
|
||||
keyid = public->get_id(public, ID_PUBKEY_INFO_SHA1);
|
||||
req->add_keyid(req, keyid->get_encoding(keyid));
|
||||
(*req)->add_keyid(*req, keyid->get_encoding(keyid));
|
||||
public->destroy(public);
|
||||
DBG1(DBG_IKE, "sending cert request for \"%D\"",
|
||||
cert->get_subject(cert));
|
||||
break;
|
||||
@@ -311,7 +307,30 @@ static void add_certreq_payload(message_t *message, certreq_payload_t **reqp,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
public->destroy(public);
|
||||
}
|
||||
|
||||
/**
|
||||
* add a auth_cfg's CA certificates to the certificate request
|
||||
*/
|
||||
static void add_certreqs(certreq_payload_t **req, auth_cfg_t *auth)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
auth_rule_t type;
|
||||
void *value;
|
||||
|
||||
enumerator = auth->create_enumerator(auth);
|
||||
while (enumerator->enumerate(enumerator, &type, &value))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case AUTH_RULE_CA_CERT:
|
||||
add_certreq(req, (certificate_t*)value);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,75 +338,53 @@ static void add_certreq_payload(message_t *message, certreq_payload_t **reqp,
|
||||
*/
|
||||
static void build_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
ike_cfg_t *ike_cfg;
|
||||
peer_cfg_t *peer_cfg;
|
||||
enumerator_t *enumerator;
|
||||
certificate_t *cert;
|
||||
bool restricted = FALSE;
|
||||
certreq_payload_t *x509_req = NULL;
|
||||
auth_cfg_t *auth;
|
||||
certreq_payload_t *req = NULL;
|
||||
|
||||
ike_cfg = this->ike_sa->get_ike_cfg(this->ike_sa);
|
||||
if (!ike_cfg->send_certreq(ike_cfg))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* check if we require a specific CA for that peer */
|
||||
peer_cfg = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
if (peer_cfg)
|
||||
{
|
||||
void *ptr;
|
||||
identification_t *id;
|
||||
auth_item_t item;
|
||||
auth_info_t *auth = peer_cfg->get_auth(peer_cfg);
|
||||
enumerator_t *auth_enumerator = auth->create_item_enumerator(auth);
|
||||
|
||||
while (auth_enumerator->enumerate(auth_enumerator, &item, &ptr))
|
||||
enumerator = peer_cfg->create_auth_cfg_enumerator(peer_cfg, FALSE);
|
||||
while (enumerator->enumerate(enumerator, &auth))
|
||||
{
|
||||
switch (item)
|
||||
{
|
||||
case AUTHZ_CA_CERT:
|
||||
cert = (certificate_t *)ptr;
|
||||
add_certreq_payload(message, &x509_req, cert);
|
||||
restricted = TRUE;
|
||||
break;
|
||||
case AUTHZ_CA_CERT_NAME:
|
||||
id = (identification_t *)ptr;
|
||||
enumerator = charon->credentials->create_cert_enumerator(
|
||||
charon->credentials, CERT_ANY, KEY_ANY, id, TRUE);
|
||||
while (enumerator->enumerate(enumerator, &cert, TRUE))
|
||||
{
|
||||
add_certreq_payload(message, &x509_req, cert);
|
||||
restricted = TRUE;
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
auth_enumerator->destroy(auth_enumerator);
|
||||
}
|
||||
|
||||
if (!restricted)
|
||||
{
|
||||
/* otherwise include all trusted CA certificates */
|
||||
enumerator = charon->credentials->create_cert_enumerator(
|
||||
charon->credentials, CERT_ANY, KEY_ANY, NULL, TRUE);
|
||||
while (enumerator->enumerate(enumerator, &cert, TRUE))
|
||||
{
|
||||
add_certreq_payload(message, &x509_req, cert);
|
||||
add_certreqs(&req, auth);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/* if we've added at least one certreq, we notify our peer that we support
|
||||
* "Hash and URL" for the requested certificates */
|
||||
if (lib->settings->get_bool(lib->settings, "charon.hash_and_url", FALSE) &&
|
||||
message->get_payload(message, CERTIFICATE_REQUEST))
|
||||
if (!req)
|
||||
{
|
||||
message->add_notify(message, FALSE, HTTP_CERT_LOOKUP_SUPPORTED, chunk_empty);
|
||||
this->http_cert_lookup_supported_sent = TRUE;
|
||||
/* otherwise add all trusted CA certificates */
|
||||
enumerator = charon->credentials->create_cert_enumerator(
|
||||
charon->credentials, CERT_ANY, KEY_ANY, NULL, TRUE);
|
||||
while (enumerator->enumerate(enumerator, &cert))
|
||||
{
|
||||
add_certreq(&req, cert);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
if (req)
|
||||
{
|
||||
message->add_payload(message, (payload_t*)req);
|
||||
|
||||
if (lib->settings->get_bool(lib->settings, "charon.hash_and_url", FALSE))
|
||||
{
|
||||
message->add_notify(message, FALSE, HTTP_CERT_LOOKUP_SUPPORTED,
|
||||
chunk_empty);
|
||||
this->do_http_lookup = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,11 +393,10 @@ static void build_certreqs(private_ike_cert_pre_t *this, message_t *message)
|
||||
*/
|
||||
static status_t build_i(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
return NEED_MORE;
|
||||
if (message->get_message_id(message) == 1)
|
||||
{ /* initiator sends CERTREQs in first IKE_AUTH */
|
||||
build_certreqs(this, message);
|
||||
}
|
||||
build_certreqs(this, message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
@@ -408,13 +404,12 @@ static status_t build_i(private_ike_cert_pre_t *this, message_t *message)
|
||||
* Implementation of task_t.process for responder
|
||||
*/
|
||||
static status_t process_r(private_ike_cert_pre_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
return NEED_MORE;
|
||||
{
|
||||
if (message->get_exchange_type(message) != IKE_SA_INIT)
|
||||
{ /* handle certreqs/certs in any IKE_AUTH, just in case */
|
||||
process_certreqs(this, message);
|
||||
process_certs(this, message);
|
||||
}
|
||||
process_certreqs(this, message);
|
||||
process_certs(this, message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
@@ -426,9 +421,12 @@ static status_t build_r(private_ike_cert_pre_t *this, message_t *message)
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
build_certreqs(this, message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
return SUCCESS;
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -439,10 +437,38 @@ static status_t process_i(private_ike_cert_pre_t *this, message_t *message)
|
||||
if (message->get_exchange_type(message) == IKE_SA_INIT)
|
||||
{
|
||||
process_certreqs(this, message);
|
||||
return NEED_MORE;
|
||||
}
|
||||
process_certs(this, message);
|
||||
return SUCCESS;
|
||||
|
||||
/* as ike_auth is not processed yet, we don't know if authentication
|
||||
* is complete (and we can return SUCCESS). Therefore we check for
|
||||
* an AUTH payload without a ANOTHER_AUTH_FOLLOWS notify. */
|
||||
if (message->get_payload(message, AUTHENTICATION))
|
||||
{
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
notify_payload_t *notify;
|
||||
bool done = TRUE;
|
||||
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
notify = (notify_payload_t*)payload;
|
||||
if (notify->get_notify_type(notify) == ANOTHER_AUTH_FOLLOWS)
|
||||
{
|
||||
done = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
if (done)
|
||||
{
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
return NEED_MORE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -493,7 +519,7 @@ ike_cert_pre_t *ike_cert_pre_create(ike_sa_t *ike_sa, bool initiator)
|
||||
|
||||
this->ike_sa = ike_sa;
|
||||
this->initiator = initiator;
|
||||
this->http_cert_lookup_supported_sent = FALSE;
|
||||
this->do_http_lookup = FALSE;
|
||||
|
||||
return &this->public;
|
||||
}
|
||||
|
||||
@@ -260,11 +260,12 @@ static void process_attribute(private_ike_config_t *this,
|
||||
*/
|
||||
static void process_payloads(private_ike_config_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator, *attributes;
|
||||
enumerator_t *enumerator;
|
||||
iterator_t *attributes;
|
||||
payload_t *payload;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == CONFIGURATION)
|
||||
{
|
||||
@@ -290,7 +291,7 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -298,9 +299,8 @@ static void process_payloads(private_ike_config_t *this, message_t *message)
|
||||
*/
|
||||
static status_t build_i(private_ike_config_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
message->get_payload(message, ID_INITIATOR))
|
||||
{
|
||||
if (message->get_message_id(message) == 1)
|
||||
{ /* in first IKE_AUTH only */
|
||||
peer_cfg_t *config;
|
||||
host_t *vip;
|
||||
|
||||
@@ -327,9 +327,8 @@ static status_t build_i(private_ike_config_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_r(private_ike_config_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
message->get_payload(message, ID_INITIATOR))
|
||||
{
|
||||
if (message->get_message_id(message) == 1)
|
||||
{ /* in first IKE_AUTH only */
|
||||
process_payloads(this, message);
|
||||
}
|
||||
return NEED_MORE;
|
||||
@@ -340,9 +339,8 @@ static status_t process_r(private_ike_config_t *this, message_t *message)
|
||||
*/
|
||||
static status_t build_r(private_ike_config_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
message->get_payload(message, EXTENSIBLE_AUTHENTICATION) == NULL)
|
||||
{
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
|
||||
{ /* in last IKE_AUTH exchange */
|
||||
peer_cfg_t *config = this->ike_sa->get_peer_cfg(this->ike_sa);
|
||||
|
||||
if (config && this->virtual_ip)
|
||||
@@ -355,7 +353,6 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
|
||||
ip = charon->attributes->acquire_address(charon->attributes,
|
||||
config->get_pool(config),
|
||||
this->ike_sa->get_other_id(this->ike_sa),
|
||||
this->ike_sa->get_other_auth(this->ike_sa),
|
||||
this->virtual_ip);
|
||||
}
|
||||
if (ip == NULL)
|
||||
@@ -384,9 +381,8 @@ static status_t build_r(private_ike_config_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_i(private_ike_config_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
!message->get_payload(message, EXTENSIBLE_AUTHENTICATION))
|
||||
{
|
||||
if (this->ike_sa->get_state(this->ike_sa) == IKE_ESTABLISHED)
|
||||
{ /* in last IKE_AUTH exchange */
|
||||
host_t *ip;
|
||||
peer_cfg_t *config;
|
||||
|
||||
|
||||
@@ -170,11 +170,11 @@ static void build_payloads(private_ike_init_t *this, message_t *message)
|
||||
*/
|
||||
static void process_payloads(private_ike_init_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
switch (payload->get_type(payload))
|
||||
{
|
||||
@@ -182,7 +182,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
|
||||
{
|
||||
sa_payload_t *sa_payload = (sa_payload_t*)payload;
|
||||
linked_list_t *proposal_list;
|
||||
|
||||
|
||||
proposal_list = sa_payload->get_proposals(sa_payload);
|
||||
this->proposal = this->config->select_proposal(this->config,
|
||||
proposal_list);
|
||||
@@ -225,7 +225,7 @@ static void process_payloads(private_ike_init_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -317,12 +317,12 @@ static status_t process_r(private_ike_init_t *this, message_t *message)
|
||||
#ifdef ME
|
||||
{
|
||||
chunk_t connect_id = chunk_empty;
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
|
||||
/* check for a ME_CONNECTID notify */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -353,7 +353,7 @@ static status_t process_r(private_ike_init_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
if (connect_id.ptr)
|
||||
{
|
||||
@@ -458,12 +458,12 @@ static status_t build_r(private_ike_init_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_i(private_ike_init_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
|
||||
/* check for erronous notifies */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -489,19 +489,22 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
|
||||
this->ike_sa->reset(this->ike_sa);
|
||||
}
|
||||
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return NEED_MORE;
|
||||
}
|
||||
case NAT_DETECTION_SOURCE_IP:
|
||||
case NAT_DETECTION_DESTINATION_IP:
|
||||
/* skip, handled in ike_natd_t */
|
||||
break;
|
||||
case MULTIPLE_AUTH_SUPPORTED:
|
||||
/* handled in ike_auth_t */
|
||||
break;
|
||||
case COOKIE:
|
||||
{
|
||||
chunk_free(&this->cookie);
|
||||
this->cookie = chunk_clone(notify->get_notification_data(notify));
|
||||
this->ike_sa->reset(this->ike_sa);
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
DBG2(DBG_IKE, "received %N notify", notify_type_names, type);
|
||||
return NEED_MORE;
|
||||
}
|
||||
@@ -511,7 +514,7 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
|
||||
{
|
||||
DBG1(DBG_IKE, "received %N notify error",
|
||||
notify_type_names, type);
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return FAILED;
|
||||
}
|
||||
DBG2(DBG_IKE, "received %N notify",
|
||||
@@ -521,7 +524,7 @@ static status_t process_i(private_ike_init_t *this, message_t *message)
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
process_payloads(this, message);
|
||||
|
||||
|
||||
@@ -166,11 +166,11 @@ static void gather_and_add_endpoints(private_ike_me_t *this, message_t *message)
|
||||
*/
|
||||
static void process_payloads(private_ike_me_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) != NOTIFY)
|
||||
{
|
||||
@@ -237,7 +237,7 @@ static void process_payloads(private_ike_me_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -97,12 +97,12 @@ static void flush_additional_addresses(private_ike_mobike_t *this)
|
||||
*/
|
||||
static void process_payloads(private_ike_mobike_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
bool first = TRUE;
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
int family = AF_INET;
|
||||
notify_payload_t *notify;
|
||||
@@ -181,7 +181,7 @@ static void process_payloads(private_ike_mobike_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,9 +332,8 @@ static void transmit(private_ike_mobike_t *this, packet_t *packet)
|
||||
*/
|
||||
static status_t build_i(private_ike_mobike_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
message->get_payload(message, ID_INITIATOR))
|
||||
{
|
||||
if (message->get_message_id(message) == 1)
|
||||
{ /* only in first IKE_AUTH */
|
||||
message->add_notify(message, FALSE, MOBIKE_SUPPORTED, chunk_empty);
|
||||
build_address_list(this, message);
|
||||
}
|
||||
@@ -381,9 +380,8 @@ static status_t build_i(private_ike_mobike_t *this, message_t *message)
|
||||
*/
|
||||
static status_t process_r(private_ike_mobike_t *this, message_t *message)
|
||||
{
|
||||
if (message->get_exchange_type(message) == IKE_AUTH &&
|
||||
message->get_payload(message, ID_INITIATOR))
|
||||
{
|
||||
if (message->get_message_id(message) == 1)
|
||||
{ /* only first IKE_AUTH */
|
||||
process_payloads(this, message);
|
||||
}
|
||||
else if (message->get_exchange_type(message) == INFORMATIONAL)
|
||||
|
||||
@@ -166,7 +166,7 @@ static notify_payload_t *build_natd_payload(private_ike_natd_t *this,
|
||||
*/
|
||||
static void process_payloads(private_ike_natd_t *this, message_t *message)
|
||||
{
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
notify_payload_t *notify;
|
||||
chunk_t hash, src_hash, dst_hash;
|
||||
@@ -184,8 +184,8 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
|
||||
DBG3(DBG_IKE, "precalculated src_hash %B", &src_hash);
|
||||
DBG3(DBG_IKE, "precalculated dst_hash %B", &dst_hash);
|
||||
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) != NOTIFY)
|
||||
{
|
||||
@@ -235,7 +235,7 @@ static void process_payloads(private_ike_natd_t *this, message_t *message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
chunk_free(&src_hash);
|
||||
chunk_free(&dst_hash);
|
||||
|
||||
@@ -194,12 +194,12 @@ static status_t build_r(private_ike_rekey_t *this, message_t *message)
|
||||
static status_t process_i(private_ike_rekey_t *this, message_t *message)
|
||||
{
|
||||
ike_sa_id_t *to_delete;
|
||||
iterator_t *iterator;
|
||||
enumerator_t *enumerator;
|
||||
payload_t *payload;
|
||||
|
||||
|
||||
/* handle NO_ADDITIONAL_SAS notify */
|
||||
iterator = message->get_payload_iterator(message);
|
||||
while (iterator->iterate(iterator, (void**)&payload))
|
||||
enumerator = message->create_payload_enumerator(message);
|
||||
while (enumerator->enumerate(enumerator, &payload))
|
||||
{
|
||||
if (payload->get_type(payload) == NOTIFY)
|
||||
{
|
||||
@@ -213,12 +213,12 @@ static status_t process_i(private_ike_rekey_t *this, message_t *message)
|
||||
charon->processor->queue_job(charon->processor,
|
||||
(job_t*)rekey_ike_sa_job_create(
|
||||
this->ike_sa->get_id(this->ike_sa), TRUE));
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
return SUCCESS;
|
||||
}
|
||||
}
|
||||
}
|
||||
iterator->destroy(iterator);
|
||||
enumerator->destroy(enumerator);
|
||||
|
||||
switch (this->ike_init->task.process(&this->ike_init->task, message))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user