aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2010-07-27 18:05:38 +0200
committerTobias Brunner <tobias@strongswan.org>2010-09-02 19:04:20 +0200
commit1ad497c78f2e407fb13c3cc8b72532c786728ab5 (patch)
tree8a7d059b703a96ea1d64e91b3228b4af6238a8ee /src
parent7dd0c17cd4d03225304af8fea1811e46a01ad278 (diff)
downloadstrongswan-1ad497c78f2e407fb13c3cc8b72532c786728ab5.tar.bz2
strongswan-1ad497c78f2e407fb13c3cc8b72532c786728ab5.tar.xz
pluto: Functions to convert IKEv1 ESP algos to IKEv2 identifiers added.
Diffstat (limited to 'src')
-rw-r--r--src/pluto/crypto.c41
-rw-r--r--src/pluto/crypto.h7
2 files changed, 45 insertions, 3 deletions
diff --git a/src/pluto/crypto.c b/src/pluto/crypto.c
index 1819e50f2..0684de618 100644
--- a/src/pluto/crypto.c
+++ b/src/pluto/crypto.c
@@ -1,6 +1,10 @@
/* crypto interfaces
+ *
+ * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2007-2009 Andreas Steffen
+ * Hochschule fuer Technik Rapperswil
+ *
* Copyright (C) 1998-2001 D. Hugh Redelmeier
- * Copyright (C) 2007-2009 Andreas Steffen - Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
@@ -518,7 +522,7 @@ signature_scheme_t oakley_to_signature_scheme(int method)
}
/**
- * Table to map IKEv2 encryption algorithms to IKEv1 (or IKEv1 ESP)
+ * Table to map IKEv2 encryption algorithms to IKEv1 (or IKEv1 ESP) and back
*/
struct {
encryption_algorithm_t alg;
@@ -578,9 +582,24 @@ int esp_from_encryption_algorithm(encryption_algorithm_t alg)
return 0;
}
+/**
+ * Converts IKEv1 ESP encryption to IKEv2 algorithm
+ */
+encryption_algorithm_t encryption_algorithm_from_esp(int esp)
+{
+ int i;
+ for (i = 0; i < countof(encr_map); i++)
+ {
+ if (encr_map[i].esp == esp)
+ {
+ return encr_map[i].alg;
+ }
+ }
+ return 0;
+}
/**
- * Table to map IKEv2 integrity algorithms to IKEv1 (or IKEv1 ESP)
+ * Table to map IKEv2 integrity algorithms to IKEv1 (or IKEv1 ESP) and back
*/
struct {
integrity_algorithm_t alg;
@@ -632,3 +651,19 @@ int esp_from_integrity_algorithm(integrity_algorithm_t alg)
return 0;
}
+/**
+ * Converts IKEv1 ESP authentication to IKEv2 integrity algorithm
+ */
+integrity_algorithm_t integrity_algorithm_from_esp(int esp)
+{
+ int i;
+ for (i = 0; i < countof(auth_map); i++)
+ {
+ if (auth_map[i].esp == esp)
+ {
+ return auth_map[i].alg;
+ }
+ }
+ return 0;
+}
+
diff --git a/src/pluto/crypto.h b/src/pluto/crypto.h
index 019ba5764..16ad12780 100644
--- a/src/pluto/crypto.h
+++ b/src/pluto/crypto.h
@@ -1,4 +1,9 @@
/* crypto interfaces
+ *
+ * Copyright (C) 2010 Tobias Brunner
+ * Copyright (C) 2009 Andreas Steffen
+ * Hochschule fuer Technik Rapperswil
+ *
* Copyright (C) 1998, 1999 D. Hugh Redelmeier.
*
* This program is free software; you can redistribute it and/or modify it
@@ -54,4 +59,6 @@ extern int oakley_from_encryption_algorithm(encryption_algorithm_t alg);
extern int oakley_from_integrity_algorithm(integrity_algorithm_t alg);
extern int esp_from_encryption_algorithm(encryption_algorithm_t alg);
extern int esp_from_integrity_algorithm(integrity_algorithm_t alg);
+extern encryption_algorithm_t encryption_algorithm_from_esp(int esp);
+extern integrity_algorithm_t integrity_algorithm_from_esp(int esp);