aboutsummaryrefslogtreecommitdiffstats
path: root/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2012-09-13 15:50:52 +0200
committerTobias Brunner <tobias@strongswan.org>2012-09-13 15:50:52 +0200
commit7d786057b4e62bb46fbc33fea6063abc9a13bc66 (patch)
tree3d35a16fc979238bf7aa6f8b31d08f221eb251dd /src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
parentbc6ec4de7314885d2725bccc186a527bda37c2bc (diff)
parent08ad639f327d2e5445d7274b7705093704151f35 (diff)
downloadstrongswan-7d786057b4e62bb46fbc33fea6063abc9a13bc66.tar.bz2
strongswan-7d786057b4e62bb46fbc33fea6063abc9a13bc66.tar.xz
Merge branch 'custom-crypto'
This provides plugins with an interface to register keywords for proposals (e.g. when parsing the esp and ike options from ipsec.conf) and the possibility to register identifiers for kernel algorithms. It is based on patches contributed by Nanoteq Pty Ltd.
Diffstat (limited to 'src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c')
-rw-r--r--src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c b/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
index 5f077b234..fa7f6107c 100644
--- a/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
+++ b/src/libhydra/plugins/kernel_klips/kernel_klips_ipsec.c
@@ -820,8 +820,22 @@ static kernel_algorithm_t compression_algs[] = {
/**
* Look up a kernel algorithm ID and its key size
*/
-static int lookup_algorithm(kernel_algorithm_t *list, int ikev2)
+static int lookup_algorithm(transform_type_t type, int ikev2)
{
+ kernel_algorithm_t *list;
+ int alg = 0;
+
+ switch (type)
+ {
+ case ENCRYPTION_ALGORITHM:
+ list = encryption_algs;
+ break;
+ case INTEGRITY_ALGORITHM:
+ list = integrity_algs;
+ break;
+ default:
+ return 0;
+ }
while (list->ikev2 != END_OF_LIST)
{
if (ikev2 == list->ikev2)
@@ -830,7 +844,9 @@ static int lookup_algorithm(kernel_algorithm_t *list, int ikev2)
}
list++;
}
- return 0;
+ hydra->kernel_interface->lookup_algorithm(hydra->kernel_interface, ikev2,
+ type, &alg, NULL);
+ return alg;
}
/**
@@ -1713,8 +1729,8 @@ METHOD(kernel_ipsec_t, add_sa, status_t,
sa->sadb_sa_spi = spi;
sa->sadb_sa_state = SADB_SASTATE_MATURE;
sa->sadb_sa_replay = (protocol == IPPROTO_COMP) ? 0 : 32;
- sa->sadb_sa_auth = lookup_algorithm(integrity_algs, int_alg);
- sa->sadb_sa_encrypt = lookup_algorithm(encryption_algs, enc_alg);
+ sa->sadb_sa_auth = lookup_algorithm(INTEGRITY_ALGORITHM, int_alg);
+ sa->sadb_sa_encrypt = lookup_algorithm(ENCRYPTION_ALGORITHM, enc_alg);
PFKEY_EXT_ADD(msg, sa);
add_addr_ext(msg, src, SADB_EXT_ADDRESS_SRC);