summaryrefslogtreecommitdiff
path: root/src/libcharon/sa/ikev1
diff options
context:
space:
mode:
Diffstat (limited to 'src/libcharon/sa/ikev1')
-rw-r--r--src/libcharon/sa/ikev1/phase1.c44
-rw-r--r--src/libcharon/sa/ikev1/tasks/mode_config.c2
-rw-r--r--src/libcharon/sa/ikev1/tasks/quick_mode.c2
3 files changed, 32 insertions, 16 deletions
diff --git a/src/libcharon/sa/ikev1/phase1.c b/src/libcharon/sa/ikev1/phase1.c
index adce59f7e..5856f829e 100644
--- a/src/libcharon/sa/ikev1/phase1.c
+++ b/src/libcharon/sa/ikev1/phase1.c
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2012 Tobias Brunner
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2012-2017 Tobias Brunner
+ * HSR Hochschule fuer Technik Rapperswil
*
* Copyright (C) 2012 Martin Willi
* Copyright (C) 2012 revosec AG
@@ -102,6 +102,31 @@ static auth_cfg_t *get_auth_cfg(peer_cfg_t *peer_cfg, bool local)
}
/**
+ * Find a shared key for the given identities
+ */
+static shared_key_t *find_shared_key(identification_t *my_id, host_t *me,
+ identification_t *other_id, host_t *other)
+{
+ identification_t *any_id = NULL;
+ shared_key_t *shared_key;
+
+ if (!other_id)
+ {
+ any_id = identification_create_from_encoding(ID_ANY, chunk_empty);
+ other_id = any_id;
+ }
+ shared_key = lib->credmgr->get_shared(lib->credmgr, SHARED_IKE,
+ my_id, other_id);
+ if (!shared_key)
+ {
+ DBG1(DBG_IKE, "no shared key found for '%Y'[%H] - '%Y'[%H]",
+ my_id, me, other_id, other);
+ }
+ DESTROY_IF(any_id);
+ return shared_key;
+}
+
+/**
* Lookup a shared secret for this IKE_SA
*/
static shared_key_t *lookup_shared_key(private_phase1_t *this,
@@ -131,15 +156,9 @@ static shared_key_t *lookup_shared_key(private_phase1_t *this,
{
other_id = other_auth->get(other_auth, AUTH_RULE_IDENTITY);
}
- if (my_id && other_id)
+ if (my_id)
{
- shared_key = lib->credmgr->get_shared(lib->credmgr, SHARED_IKE,
- my_id, other_id);
- if (!shared_key)
- {
- DBG1(DBG_IKE, "no shared key found for '%Y'[%H] - '%Y'[%H]",
- my_id, me, other_id, other);
- }
+ shared_key = find_shared_key(my_id, me, other_id, other);
}
}
}
@@ -158,14 +177,11 @@ static shared_key_t *lookup_shared_key(private_phase1_t *this,
other_id = other_auth->get(other_auth, AUTH_RULE_IDENTITY);
if (my_id)
{
- shared_key = lib->credmgr->get_shared(lib->credmgr,
- SHARED_IKE, my_id, other_id);
+ shared_key = find_shared_key(my_id, me, other_id, other);
if (shared_key)
{
break;
}
- DBG1(DBG_IKE, "no shared key found for '%Y'[%H] - '%Y'[%H]",
- my_id, me, other_id, other);
}
}
}
diff --git a/src/libcharon/sa/ikev1/tasks/mode_config.c b/src/libcharon/sa/ikev1/tasks/mode_config.c
index 7098d24a2..43897c304 100644
--- a/src/libcharon/sa/ikev1/tasks/mode_config.c
+++ b/src/libcharon/sa/ikev1/tasks/mode_config.c
@@ -547,7 +547,7 @@ static status_t build_reply(private_mode_config_t *this, message_t *message)
type, value));
}
enumerator->destroy(enumerator);
- /* if a client did not re-request all adresses, release them */
+ /* if a client did not re-request all addresses, release them */
enumerator = migrated->create_enumerator(migrated);
while (enumerator->enumerate(enumerator, &found))
{
diff --git a/src/libcharon/sa/ikev1/tasks/quick_mode.c b/src/libcharon/sa/ikev1/tasks/quick_mode.c
index 49b476ad8..77592e59a 100644
--- a/src/libcharon/sa/ikev1/tasks/quick_mode.c
+++ b/src/libcharon/sa/ikev1/tasks/quick_mode.c
@@ -1330,7 +1330,7 @@ METHOD(task_t, process_i, status_t,
&this->cpi_r);
if (!list->get_count(list))
{
- DBG1(DBG_IKE, "peer did not acccept our IPComp proposal, "
+ DBG1(DBG_IKE, "peer did not accept our IPComp proposal, "
"IPComp disabled");
this->cpi_i = 0;
}