summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-09-16 05:28:45 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-09-16 05:30:24 +0200
commitce1b13c5ea3ea0c7ba8b8250b2d91942ca0db065 (patch)
tree5259c1e3d3a51bb92ba64eab04a22ed66c84c497 /src/config.c
parent7305c533516df296124d6b2415482d2febb7328a (diff)
downloadfastd-ce1b13c5ea3ea0c7ba8b8250b2d91942ca0db065.tar
fastd-ce1b13c5ea3ea0c7ba8b8250b2d91942ca0db065.zip
Make implementations used for AES128-CTR and GHASH configurable.
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/config.c b/src/config.c
index 8b19fd4..168a640 100644
--- a/src/config.c
+++ b/src/config.c
@@ -37,6 +37,7 @@
#include <dirent.h>
#include <libgen.h>
#include <stdarg.h>
+#include <strings.h>
#include <sys/stat.h>
#include <sys/types.h>
@@ -85,6 +86,8 @@ static void default_config(fastd_config *conf) {
conf->secret = NULL;
conf->key_valid = 3600; /* 60 minutes */
conf->key_refresh = 3300; /* 55 minutes */
+ conf->alg_impl_aes128ctr = ALG_IMPL_DEFAULT;
+ conf->alg_impl_ghash = ALG_IMPL_DEFAULT;
conf->peer_dirs = NULL;
conf->peers = NULL;
@@ -174,6 +177,32 @@ bool fastd_config_method(fastd_context *ctx, fastd_config *conf, const char *nam
exit_bug(ctx, "MAX_METHODS too low");
}
+bool fastd_config_algorithm(fastd_context *ctx, fastd_config *conf, const char *alg, const char *impl) {
+ if (!strcasecmp(alg, "aes128-ctr") || !strcasecmp(alg, "aes128") || !strcasecmp(alg, "aes-ctr") || !strcasecmp(alg, "aes")) {
+ if (!strcasecmp(impl, "default"))
+ conf->alg_impl_aes128ctr = ALG_IMPL_DEFAULT;
+ else if (!strcasecmp(impl, "algif"))
+ conf->alg_impl_aes128ctr = ALG_IMPL_ALGIF;
+ else
+ return false;
+
+ return true;
+ }
+ else if (!strcasecmp(alg, "ghash")) {
+ if (!strcasecmp(impl, "default"))
+ conf->alg_impl_ghash = ALG_IMPL_DEFAULT;
+ else if (!strcasecmp(impl, "algif"))
+ conf->alg_impl_ghash = ALG_IMPL_ALGIF;
+ else
+ return false;
+
+ return true;
+ }
+ else {
+ return false;
+ }
+}
+
bool fastd_config_add_log_file(fastd_context *ctx, fastd_config *conf, const char *name, int level) {
char *name2 = strdup(name);
char *name3 = strdup(name);