summaryrefslogtreecommitdiff
path: root/src/libstrongswan/plugins/af_alg
diff options
context:
space:
mode:
authorYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
committerYves-Alexis Perez <corsac@corsac.net>2012-06-28 21:16:07 +0200
commitb34738ed08c2227300d554b139e2495ca5da97d6 (patch)
tree62f33b52820f2e49f0e53c0f8c636312037c8054 /src/libstrongswan/plugins/af_alg
parent0a9d51a49042a68daa15b0c74a2b7f152f52606b (diff)
downloadvyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.tar.gz
vyos-strongswan-b34738ed08c2227300d554b139e2495ca5da97d6.zip
Imported Upstream version 4.6.4
Diffstat (limited to 'src/libstrongswan/plugins/af_alg')
-rw-r--r--src/libstrongswan/plugins/af_alg/Makefile.in7
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_crypter.c19
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_crypter.h11
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_hasher.c7
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_hasher.h11
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_ops.c2
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_plugin.c38
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_prf.c9
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_prf.h11
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_signer.c7
-rw-r--r--src/libstrongswan/plugins/af_alg/af_alg_signer.h11
11 files changed, 80 insertions, 53 deletions
diff --git a/src/libstrongswan/plugins/af_alg/Makefile.in b/src/libstrongswan/plugins/af_alg/Makefile.in
index 00b54b026..679e883e1 100644
--- a/src/libstrongswan/plugins/af_alg/Makefile.in
+++ b/src/libstrongswan/plugins/af_alg/Makefile.in
@@ -195,6 +195,9 @@ am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
+attest_plugins = @attest_plugins@
+axis2c_CFLAGS = @axis2c_CFLAGS@
+axis2c_LIBS = @axis2c_LIBS@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
@@ -203,6 +206,7 @@ build_os = @build_os@
build_vendor = @build_vendor@
builddir = @builddir@
c_plugins = @c_plugins@
+clearsilver_LIBS = @clearsilver_LIBS@
datadir = @datadir@
datarootdir = @datarootdir@
dbusservicedir = @dbusservicedir@
@@ -219,11 +223,13 @@ host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
htmldir = @htmldir@
+imcvdir = @imcvdir@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
ipsecdir = @ipsecdir@
ipsecgroup = @ipsecgroup@
+ipseclibdir = @ipseclibdir@
ipsecuser = @ipsecuser@
libcharon_plugins = @libcharon_plugins@
libdir = @libdir@
@@ -267,6 +273,7 @@ sharedstatedir = @sharedstatedir@
soup_CFLAGS = @soup_CFLAGS@
soup_LIBS = @soup_LIBS@
srcdir = @srcdir@
+starter_plugins = @starter_plugins@
strongswan_conf = @strongswan_conf@
sysconfdir = @sysconfdir@
systemdsystemunitdir = @systemdsystemunitdir@
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_crypter.c b/src/libstrongswan/plugins/af_alg/af_alg_crypter.c
index 7b3c062aa..9c547140d 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_crypter.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_crypter.c
@@ -61,7 +61,7 @@ static struct {
/* size of the keying material (key + nonce for ctr mode) */
size_t keymat_size;
size_t iv_size;
-} algs[] = {
+} algs[AF_ALG_CRYPTER] = {
{ENCR_DES, "cbc(des)", 8, 8, 8, 8, },
{ENCR_DES_ECB, "ecb(des)", 8, 8, 8, 0, },
{ENCR_3DES, "cbc(des3_ede)", 8, 24, 24, 8, },
@@ -92,25 +92,20 @@ static struct {
/**
* See header.
*/
-void af_alg_crypter_probe(char *plugin)
+void af_alg_crypter_probe(plugin_feature_t *features, int *pos)
{
- encryption_algorithm_t prev = -1;
af_alg_ops_t *ops;
int i;
for (i = 0; i < countof(algs); i++)
{
- if (prev != algs[i].id)
+ ops = af_alg_ops_create("skcipher", algs[i].name);
+ if (ops)
{
- ops = af_alg_ops_create("skcipher", algs[i].name);
- if (ops)
- {
- ops->destroy(ops);
- lib->crypto->add_crypter(lib->crypto, algs[i].id, plugin,
- (crypter_constructor_t)af_alg_crypter_create);
- }
+ ops->destroy(ops);
+ features[(*pos)++] = PLUGIN_PROVIDE(CRYPTER,
+ algs[i].id, algs[i].key_size);
}
- prev = algs[i].id;
}
}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_crypter.h b/src/libstrongswan/plugins/af_alg/af_alg_crypter.h
index ed7799cc8..ad2d42a97 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_crypter.h
+++ b/src/libstrongswan/plugins/af_alg/af_alg_crypter.h
@@ -23,8 +23,12 @@
typedef struct af_alg_crypter_t af_alg_crypter_t;
+#include <plugins/plugin.h>
#include <crypto/crypters/crypter.h>
+/** Number of crypters */
+#define AF_ALG_CRYPTER 25
+
/**
* Implementation of signers using AF_ALG.
*/
@@ -47,10 +51,11 @@ af_alg_crypter_t *af_alg_crypter_create(encryption_algorithm_t algo,
size_t key_size);
/**
- * Probe algorithms and register af_alg_crypter_create().
+ * Probe algorithms and return plugin features.
*
- * @param plugin plugin name to register algorithms for
+ * @param features plugin features to create
+ * @param pos current position in features
*/
-void af_alg_crypter_probe(char *plugin);
+void af_alg_crypter_probe(plugin_feature_t *features, int *pos);
#endif /** AF_ALG_CRYPTER_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_hasher.c b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c
index 11074c4bd..ef2350497 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_hasher.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_hasher.c
@@ -46,7 +46,7 @@ static struct {
hash_algorithm_t id;
char *name;
size_t size;
-} algs[] = {
+} algs[AF_ALG_HASHER] = {
{HASH_SHA1, "sha1", HASH_SIZE_SHA1 },
{HASH_MD5, "md5", HASH_SIZE_MD5 },
{HASH_SHA224, "sha224", HASH_SIZE_SHA224 },
@@ -59,7 +59,7 @@ static struct {
/**
* See header.
*/
-void af_alg_hasher_probe(char *plugin)
+void af_alg_hasher_probe(plugin_feature_t *features, int *pos)
{
af_alg_ops_t *ops;
int i;
@@ -70,8 +70,7 @@ void af_alg_hasher_probe(char *plugin)
if (ops)
{
ops->destroy(ops);
- lib->crypto->add_hasher(lib->crypto, algs[i].id, plugin,
- (hasher_constructor_t)af_alg_hasher_create);
+ features[(*pos)++] = PLUGIN_PROVIDE(HASHER, algs[i].id);
}
}
}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_hasher.h b/src/libstrongswan/plugins/af_alg/af_alg_hasher.h
index f44ba2938..5b540875a 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_hasher.h
+++ b/src/libstrongswan/plugins/af_alg/af_alg_hasher.h
@@ -23,8 +23,12 @@
typedef struct af_alg_hasher_t af_alg_hasher_t;
+#include <plugins/plugin.h>
#include <crypto/hashers/hasher.h>
+/** Number of hashers */
+#define AF_ALG_HASHER 7
+
/**
* Implementation of hashers using AF_ALG.
*/
@@ -45,10 +49,11 @@ struct af_alg_hasher_t {
af_alg_hasher_t *af_alg_hasher_create(hash_algorithm_t algo);
/**
- * Probe algorithms and register af_alg_hasher_create().
+ * Probe algorithms and return plugin features.
*
- * @param plugin plugin name to register algorithms for
+ * @param features plugin features to create
+ * @param pos current position in deps
*/
-void af_alg_hasher_probe(char *plugin);
+void af_alg_hasher_probe(plugin_feature_t *features, int *pos);
#endif /** af_alg_HASHER_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_ops.c b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
index 82a227d97..a7b5de264 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_ops.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_ops.c
@@ -122,7 +122,7 @@ METHOD(af_alg_ops_t, crypt, void,
cmsg->cmsg_level = SOL_ALG;
cmsg->cmsg_type = ALG_SET_OP;
cmsg->cmsg_len = CMSG_LEN(sizeof(type));
- *(u_int32_t*)CMSG_DATA(cmsg) = type;
+ memcpy(CMSG_DATA(cmsg), &type, sizeof(type));
cmsg = CMSG_NXTHDR(&msg, cmsg);
cmsg->cmsg_level = SOL_ALG;
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_plugin.c b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c
index 280ea4e98..445667507 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_plugin.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_plugin.c
@@ -41,18 +41,31 @@ METHOD(plugin_t, get_name, char*,
return "af-alg";
}
+METHOD(plugin_t, get_features, int,
+ private_af_alg_plugin_t *this, plugin_feature_t *features[])
+{
+ static plugin_feature_t f[AF_ALG_HASHER + AF_ALG_SIGNER +
+ AF_ALG_PRF + AF_ALG_CRYPTER + 4] = {};
+ static int count = 0;
+
+ if (!count)
+ { /* initialize only once */
+ f[count++] = PLUGIN_REGISTER(HASHER, af_alg_hasher_create);
+ af_alg_hasher_probe(f, &count);
+ f[count++] = PLUGIN_REGISTER(SIGNER, af_alg_signer_create);
+ af_alg_signer_probe(f, &count);
+ f[count++] = PLUGIN_REGISTER(PRF, af_alg_prf_create);
+ af_alg_prf_probe(f, &count);
+ f[count++] = PLUGIN_REGISTER(CRYPTER, af_alg_crypter_create);
+ af_alg_crypter_probe(f, &count);
+ }
+ *features = f;
+ return count;
+}
+
METHOD(plugin_t, destroy, void,
private_af_alg_plugin_t *this)
{
- lib->crypto->remove_hasher(lib->crypto,
- (hasher_constructor_t)af_alg_hasher_create);
- lib->crypto->remove_signer(lib->crypto,
- (signer_constructor_t)af_alg_signer_create);
- lib->crypto->remove_prf(lib->crypto,
- (prf_constructor_t)af_alg_prf_create);
- lib->crypto->remove_crypter(lib->crypto,
- (crypter_constructor_t)af_alg_crypter_create);
-
free(this);
}
@@ -67,16 +80,11 @@ plugin_t *af_alg_plugin_create()
.public = {
.plugin = {
.get_name = _get_name,
- .reload = (void*)return_false,
+ .get_features = _get_features,
.destroy = _destroy,
},
},
);
- af_alg_hasher_probe(get_name(this));
- af_alg_signer_probe(get_name(this));
- af_alg_prf_probe(get_name(this));
- af_alg_crypter_probe(get_name(this));
-
return &this->public.plugin;
}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_prf.c b/src/libstrongswan/plugins/af_alg/af_alg_prf.c
index 1c1174abb..a7912291f 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_prf.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_prf.c
@@ -57,7 +57,7 @@ static struct {
char *name;
size_t block_size;
bool xcbc;
-} algs[] = {
+} algs[AF_ALG_PRF] = {
{PRF_HMAC_SHA1, "hmac(sha1)", 20, FALSE, },
{PRF_HMAC_SHA2_256, "hmac(sha256)", 32, FALSE, },
{PRF_HMAC_MD5, "hmac(md5)", 16, FALSE, },
@@ -70,7 +70,7 @@ static struct {
/**
* See header.
*/
-void af_alg_prf_probe(char *plugin)
+void af_alg_prf_probe(plugin_feature_t *features, int *pos)
{
af_alg_ops_t *ops;
int i;
@@ -81,8 +81,7 @@ void af_alg_prf_probe(char *plugin)
if (ops)
{
ops->destroy(ops);
- lib->crypto->add_prf(lib->crypto, algs[i].id, plugin,
- (prf_constructor_t)af_alg_prf_create);
+ features[(*pos)++] = PLUGIN_PROVIDE(PRF, algs[i].id);
}
}
}
@@ -90,7 +89,7 @@ void af_alg_prf_probe(char *plugin)
/**
* Get the kernel algorithm string and block size for our identifier
*/
-static size_t lookup_alg(integrity_algorithm_t algo, char **name, bool *xcbc)
+static size_t lookup_alg(pseudo_random_function_t algo, char **name, bool *xcbc)
{
int i;
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_prf.h b/src/libstrongswan/plugins/af_alg/af_alg_prf.h
index d3275e7be..2f6cf0cf1 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_prf.h
+++ b/src/libstrongswan/plugins/af_alg/af_alg_prf.h
@@ -23,8 +23,12 @@
typedef struct af_alg_prf_t af_alg_prf_t;
+#include <plugins/plugin.h>
#include <crypto/prfs/prf.h>
+/** Number of PRFs */
+#define AF_ALG_PRF 7
+
/**
* Implementation of PRFs using AF_ALG.
*/
@@ -45,10 +49,11 @@ struct af_alg_prf_t {
af_alg_prf_t *af_alg_prf_create(pseudo_random_function_t algo);
/**
- * Probe algorithms and register af_alg_prf_create().
+ * Probe algorithms and return plugin features.
*
- * @param plugin plugin name to register algorithms for
+ * @param features plugin features to create
+ * @param pos current position in features
*/
-void af_alg_prf_probe(char *plugin);
+void af_alg_prf_probe(plugin_feature_t *features, int *pos);
#endif /** AF_ALG_PRF_H_ @}*/
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_signer.c b/src/libstrongswan/plugins/af_alg/af_alg_signer.c
index 34534a06b..6cd79f8f2 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_signer.c
+++ b/src/libstrongswan/plugins/af_alg/af_alg_signer.c
@@ -52,7 +52,7 @@ static struct {
char *name;
size_t block_size;
size_t key_size;
-} algs[] = {
+} algs[AF_ALG_SIGNER] = {
{AUTH_HMAC_SHA1_96, "hmac(sha1)", 12, 20, },
{AUTH_HMAC_SHA1_128, "hmac(sha1)", 16, 20, },
{AUTH_HMAC_SHA1_160, "hmac(sha1)", 20, 20, },
@@ -71,7 +71,7 @@ static struct {
/**
* See header.
*/
-void af_alg_signer_probe(char *plugin)
+void af_alg_signer_probe(plugin_feature_t *features, int *pos)
{
af_alg_ops_t *ops;
int i;
@@ -82,8 +82,7 @@ void af_alg_signer_probe(char *plugin)
if (ops)
{
ops->destroy(ops);
- lib->crypto->add_signer(lib->crypto, algs[i].id, plugin,
- (signer_constructor_t)af_alg_signer_create);
+ features[(*pos)++] = PLUGIN_PROVIDE(SIGNER, algs[i].id);
}
}
}
diff --git a/src/libstrongswan/plugins/af_alg/af_alg_signer.h b/src/libstrongswan/plugins/af_alg/af_alg_signer.h
index 21487a118..deced7110 100644
--- a/src/libstrongswan/plugins/af_alg/af_alg_signer.h
+++ b/src/libstrongswan/plugins/af_alg/af_alg_signer.h
@@ -23,8 +23,12 @@
typedef struct af_alg_signer_t af_alg_signer_t;
+#include <plugins/plugin.h>
#include <crypto/signers/signer.h>
+/** Number of signers */
+#define AF_ALG_SIGNER 13
+
/**
* Implementation of signers using AF_ALG.
*/
@@ -45,10 +49,11 @@ struct af_alg_signer_t {
af_alg_signer_t *af_alg_signer_create(integrity_algorithm_t algo);
/**
- * Probe algorithms and register af_alg_signer_create().
+ * Probe algorithms and return plugin features.
*
- * @param plugin plugin name to register algorithms for
+ * @param features plugin features to create
+ * @param pos current position in features
*/
-void af_alg_signer_probe(char *plugin);
+void af_alg_signer_probe(plugin_feature_t *features, int *pos);
#endif /** AF_ALG_SIGNER_H_ @}*/