pluto: Functions to convert IKEv1 ESP algos to IKEv2 identifiers added.

This commit is contained in:
Tobias Brunner
2010-09-02 19:04:20 +02:00
parent 7dd0c17cd4
commit 1ad497c78f
2 changed files with 45 additions and 3 deletions
+38 -3
View File
@@ -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;
}
+7
View File
@@ -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);