summaryrefslogtreecommitdiffstats
path: root/src/config.c
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2012-04-14 13:06:11 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2012-04-14 13:06:11 +0200
commit701fcc7c7e353def78d89d9ee0ca52d32fb894b9 (patch)
treee39e37e1bf8e8bd5d38885d059c61006ce90f172 /src/config.c
parentac235fb7d28da6690f5ef7d7dc37d40bcebbd87a (diff)
downloadfastd-701fcc7c7e353def78d89d9ee0ca52d32fb894b9.tar
fastd-701fcc7c7e353def78d89d9ee0ca52d32fb894b9.zip
Separate handshake from encryption method
Diffstat (limited to 'src/config.c')
-rw-r--r--src/config.c47
1 files changed, 36 insertions, 11 deletions
diff --git a/src/config.c b/src/config.c
index 8c63b4e..e7c8640 100644
--- a/src/config.c
+++ b/src/config.c
@@ -41,10 +41,12 @@
#include <sys/types.h>
-extern const fastd_protocol fastd_protocol_null;
+extern const fastd_protocol fastd_protocol_ec25519_fhmqvc;
-#ifdef WITH_PROTOCOL_ECFXP
-extern const fastd_protocol fastd_protocol_ec25519_fhmqvc_xsalsa20_poly1305;
+extern const fastd_method fastd_method_null;
+
+#ifdef WITH_METHOD_XSALSA20_POLY1305
+extern const fastd_method fastd_method_xsalsa20_poly1305;
#endif
@@ -66,7 +68,8 @@ static void default_config(fastd_config *conf) {
conf->peer_to_peer = false;
- conf->protocol = &fastd_protocol_null;
+ conf->protocol = &fastd_protocol_ec25519_fhmqvc;
+ conf->method = &fastd_method_null;
conf->secret = NULL;
conf->key_valid = 3600; /* 60 minutes */
conf->key_refresh = 3300; /* 55 minutes */
@@ -107,6 +110,28 @@ static bool config_match(const char *opt, ...) {
return match;
}
+bool fastd_config_protocol(fastd_context *ctx, fastd_config *conf, const char *name) {
+ if (!strcmp(name, "ec25519-fhmqvc"))
+ conf->protocol = &fastd_protocol_ec25519_fhmqvc;
+ else
+ return false;
+
+ return true;
+}
+
+bool fastd_config_method(fastd_context *ctx, fastd_config *conf, const char *name) {
+ if (!strcmp(name, "null"))
+ conf->method = &fastd_method_null;
+#ifdef WITH_METHOD_XSALSA20_POLY1305
+ else if (!strcmp(name, "xsalsa20-poly1305"))
+ conf->method = &fastd_method_xsalsa20_poly1305;
+#endif
+ else
+ return false;
+
+ return true;
+}
+
static void read_peer_dir(fastd_context *ctx, fastd_config *conf, const char *dir) {
DIR *dirh = opendir(".");
@@ -436,17 +461,17 @@ void fastd_configure(fastd_context *ctx, fastd_config *conf, int argc, char *con
IF_OPTION_ARG("-P", "--protocol") {
- if (!strcmp(arg, "null"))
- conf->protocol = &fastd_protocol_null;
-#ifdef WITH_PROTOCOL_ECFXP
- else if (!strcmp(arg, "ecfxp"))
- conf->protocol = &fastd_protocol_ec25519_fhmqvc_xsalsa20_poly1305;
-#endif
- else
+ if (!fastd_config_protocol(ctx, conf, arg))
exit_error(ctx, "invalid protocol `%s'", arg);
continue;
}
+ IF_OPTION_ARG("--method") {
+ if (!fastd_config_method(ctx, conf, arg))
+ exit_error(ctx, "invalid method `%s'", arg);
+ continue;
+ }
+
IF_OPTION_ARG("-p", "--peer") {
peer = fastd_peer_config_new(ctx, conf);