Check authorization constraints after main mode completed
This commit is contained in:
@@ -335,18 +335,53 @@ static auth_method_t get_auth_method(private_main_mode_t *this,
|
|||||||
return AUTH_NONE;
|
return AUTH_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a peer skipped authentication by using Hybrid authentication
|
||||||
|
*/
|
||||||
|
static bool skipped_auth(private_main_mode_t *this, bool local)
|
||||||
|
{
|
||||||
|
bool initiator;
|
||||||
|
|
||||||
|
initiator = local == this->initiator;
|
||||||
|
if (initiator && this->auth_method == AUTH_HYBRID_INIT_RSA)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
if (!initiator && this->auth_method == AUTH_HYBRID_RESP_RSA)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if remote authentication constraints fulfilled
|
||||||
|
*/
|
||||||
|
static bool check_constraints(private_main_mode_t *this)
|
||||||
|
{
|
||||||
|
identification_t *id;
|
||||||
|
auth_cfg_t *auth;
|
||||||
|
|
||||||
|
if (skipped_auth(this, FALSE))
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
auth = this->ike_sa->get_auth_cfg(this->ike_sa, FALSE);
|
||||||
|
/* auth identity to comply */
|
||||||
|
id = this->ike_sa->get_other_id(this->ike_sa);
|
||||||
|
auth->add(auth, AUTH_RULE_IDENTITY, id->clone(id));
|
||||||
|
return auth->complies(auth, this->other_auth, TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save authentication information after authentication succeeded
|
* Save authentication information after authentication succeeded
|
||||||
*/
|
*/
|
||||||
static void save_auth_cfg(private_main_mode_t *this, bool local)
|
static void save_auth_cfg(private_main_mode_t *this, bool local)
|
||||||
{
|
{
|
||||||
auth_cfg_t *auth;
|
auth_cfg_t *auth;
|
||||||
bool initiator;
|
|
||||||
|
|
||||||
initiator = local == this->initiator;
|
if (skipped_auth(this, local))
|
||||||
if ((initiator && this->auth_method == AUTH_HYBRID_INIT_RSA) ||
|
{
|
||||||
(!initiator && this->auth_method == AUTH_HYBRID_RESP_RSA))
|
|
||||||
{ /* peer not authenticated in main mode with hybrid methods */
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
auth = auth_cfg_create();
|
auth = auth_cfg_create();
|
||||||
@@ -700,6 +735,10 @@ METHOD(task_t, process_r, status_t,
|
|||||||
return send_notify(this, AUTHENTICATION_FAILED, chunk_empty);
|
return send_notify(this, AUTHENTICATION_FAILED, chunk_empty);
|
||||||
}
|
}
|
||||||
authenticator->destroy(authenticator);
|
authenticator->destroy(authenticator);
|
||||||
|
if (!check_constraints(this))
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
save_auth_cfg(this, FALSE);
|
save_auth_cfg(this, FALSE);
|
||||||
|
|
||||||
this->state = MM_AUTH;
|
this->state = MM_AUTH;
|
||||||
@@ -1018,6 +1057,10 @@ METHOD(task_t, process_i, status_t,
|
|||||||
return FAILED;
|
return FAILED;
|
||||||
}
|
}
|
||||||
authenticator->destroy(authenticator);
|
authenticator->destroy(authenticator);
|
||||||
|
if (!check_constraints(this))
|
||||||
|
{
|
||||||
|
return FAILED;
|
||||||
|
}
|
||||||
save_auth_cfg(this, FALSE);
|
save_auth_cfg(this, FALSE);
|
||||||
|
|
||||||
switch (this->auth_method)
|
switch (this->auth_method)
|
||||||
|
|||||||
Reference in New Issue
Block a user