summaryrefslogtreecommitdiff
path: root/src/pluto/alg_info.c
diff options
context:
space:
mode:
authorRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
committerRene Mayrhofer <rene@mayrhofer.eu.org>2010-02-23 10:34:14 +0000
commited7d79f96177044949744da10f4431c1d6242241 (patch)
tree3aabaa55ed3b5291daef891cfee9befb5235e2b8 /src/pluto/alg_info.c
parent7410d3c6d6a9a1cd7aa55083c938946af6ff9498 (diff)
downloadvyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.tar.gz
vyos-strongswan-ed7d79f96177044949744da10f4431c1d6242241.zip
[svn-upgrade] Integrating new upstream version, strongswan (4.3.6)
Diffstat (limited to 'src/pluto/alg_info.c')
-rw-r--r--src/pluto/alg_info.c59
1 files changed, 27 insertions, 32 deletions
diff --git a/src/pluto/alg_info.c b/src/pluto/alg_info.c
index c25418fc1..edecf14c6 100644
--- a/src/pluto/alg_info.c
+++ b/src/pluto/alg_info.c
@@ -51,19 +51,13 @@ int alg_info_esp_aa2sadb(int auth)
{
int sadb_aalg = 0;
- switch(auth) {
+ switch(auth)
+ {
case AUTH_ALGORITHM_HMAC_MD5:
case AUTH_ALGORITHM_HMAC_SHA1:
sadb_aalg = auth + 1;
break;
- case AUTH_ALGORITHM_HMAC_SHA2_256:
- case AUTH_ALGORITHM_HMAC_SHA2_384:
- case AUTH_ALGORITHM_HMAC_SHA2_512:
- case AUTH_ALGORITHM_HMAC_RIPEMD:
- sadb_aalg = auth;
- break;
default:
- /* loose ... */
sadb_aalg = auth;
}
return sadb_aalg;
@@ -73,20 +67,13 @@ int alg_info_esp_sadb2aa(int sadb_aalg)
{
int auth = 0;
- switch(sadb_aalg) {
+ switch(sadb_aalg)
+ {
case SADB_AALG_MD5HMAC:
case SADB_AALG_SHA1HMAC:
auth = sadb_aalg - 1;
break;
- /* since they are the same ... :) */
- case AUTH_ALGORITHM_HMAC_SHA2_256:
- case AUTH_ALGORITHM_HMAC_SHA2_384:
- case AUTH_ALGORITHM_HMAC_SHA2_512:
- case AUTH_ALGORITHM_HMAC_RIPEMD:
- auth = sadb_aalg;
- break;
default:
- /* loose ... */
auth = sadb_aalg;
}
return auth;
@@ -133,7 +120,7 @@ static void __alg_info_esp_add(struct alg_info_esp *alg_info, int ealg_id,
DBG(DBG_CRYPT,
DBG_log("esp alg added: %s_%d/%s, cnt=%d",
- enum_show(&esp_transformid_names, ealg_id), ek_bits,
+ enum_show(&esp_transform_names, ealg_id), ek_bits,
enum_show(&auth_alg_names, aalg_id),
alg_info->alg_info_cnt)
)
@@ -238,12 +225,12 @@ static void __alg_info_ike_add (struct alg_info_ike *alg_info, int ealg_id,
* merging alg_info (ike_info) contents
*/
-static int default_ike_groups[] = {
+static int default_ike_groups[] = {
MODP_1536_BIT,
MODP_1024_BIT
};
-/*
+/*
* Add IKE alg info _with_ logic (policy):
*/
static void alg_info_ike_add (struct alg_info *alg_info, int ealg_id,
@@ -258,7 +245,7 @@ static void alg_info_ike_add (struct alg_info *alg_info, int ealg_id,
n_groups=0;
goto in_loop;
}
-
+
for (; n_groups--; i++)
{
modp_id = default_ike_groups[i];
@@ -372,7 +359,7 @@ static status_t alg_info_parse_str(struct alg_info *alg_info, char *alg_str)
eat_whitespace(&string);
- if (string.len > 0)
+ if (string.len > 0)
{
chunk_t alg;
@@ -397,7 +384,7 @@ static status_t alg_info_parse_str(struct alg_info *alg_info, char *alg_str)
{
case PROTO_IPSEC_ESP:
alg_info_esp_add(alg_info, ealg, ealg_keysize,
- aalg, aalg_keysize);
+ aalg, aalg_keysize);
break;
case PROTO_ISAKMP:
alg_info_ike_add(alg_info, ealg, ealg_keysize,
@@ -461,12 +448,16 @@ struct alg_info_esp *alg_info_esp_create_from_str(char *alg_str)
status = alg_info_parse_str((struct alg_info *)alg_info_esp, alg_str);
out:
- if (status != SUCCESS)
+ if (status == SUCCESS)
+ {
+ alg_info_esp->ref_cnt = 1;
+ return alg_info_esp;
+ }
+ else
{
free(alg_info_esp);
- alg_info_esp = NULL;
+ return NULL;
}
- return alg_info_esp;
}
struct alg_info_ike *alg_info_ike_create_from_str(char *alg_str)
@@ -481,12 +472,16 @@ struct alg_info_ike *alg_info_ike_create_from_str(char *alg_str)
zero(alg_info_ike);
alg_info_ike->alg_info_protoid = PROTO_ISAKMP;
- if (alg_info_parse_str((struct alg_info *)alg_info_ike, alg_str) != SUCCESS)
+ if (alg_info_parse_str((struct alg_info *)alg_info_ike, alg_str) == SUCCESS)
+ {
+ alg_info_ike->ref_cnt = 1;
+ return alg_info_ike;
+ }
+ else
{
free(alg_info_ike);
return NULL;
}
- return alg_info_ike;
}
/*
@@ -494,7 +489,7 @@ struct alg_info_ike *alg_info_ike_create_from_str(char *alg_str)
* several connections instances,
* handle free() with ref_cnts
*/
-void
+void
alg_info_addref(struct alg_info *alg_info)
{
if (alg_info != NULL)
@@ -529,7 +524,7 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info)
struct esp_info *esp_info;
struct ike_info *ike_info;
int cnt;
-
+
switch (alg_info->alg_info_protoid) {
case PROTO_IPSEC_ESP:
{
@@ -538,7 +533,7 @@ alg_info_snprint(char *buf, int buflen, struct alg_info *alg_info)
ALG_INFO_ESP_FOREACH(alg_info_esp, esp_info, cnt)
{
np = snprintf(ptr, buflen, "%s",
- enum_show(&esp_transformid_names, esp_info->esp_ealg_id));
+ enum_show(&esp_transform_names, esp_info->esp_ealg_id));
ptr += np;
buflen -= np;
if (esp_info->esp_ealg_keylen)
@@ -608,7 +603,7 @@ out:
, "buffer space exhausted in alg_info_snprint_ike(), buflen=%d"
, buflen);
}
-
+
return ptr - buf;
}