From ce1b13c5ea3ea0c7ba8b8250b2d91942ca0db065 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 16 Sep 2012 05:28:45 +0200 Subject: Make implementations used for AES128-CTR and GHASH configurable. --- src/config.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'src/config.c') 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 #include #include +#include #include #include @@ -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); -- cgit v1.2.3