Add mud_set_aes()

Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
Adrien Gallouët
2017-11-15 22:41:13 +00:00
parent 63b0b4261c
commit 21957cc0cc
2 changed files with 14 additions and 3 deletions

14
mud.c
View File

@@ -773,8 +773,19 @@ mud_keyx_init(struct mud *mud, uint64_t now)
return 0;
}
int
mud_set_aes(struct mud *mud)
{
if (!crypto_aead_aes256gcm_is_available())
return 1;
mud->crypto.aes = 1;
return 0;
}
struct mud *
mud_create(int port, int v4, int v6, int aes, int mtu)
mud_create(int port, int v4, int v6, int mtu)
{
uint64_t now = mud_now();
@@ -799,7 +810,6 @@ mud_create(int port, int v4, int v6, int aes, int mtu)
mud->send_timeout = MUD_SEND_TIMEOUT;
mud->time_tolerance = MUD_TIME_TOLERANCE;
mud->tc = MUD_PACKET_TC;
mud->crypto.aes = aes && crypto_aead_aes256gcm_is_available();
randombytes_buf(mud->kiss, sizeof(mud->kiss));
mud_set_mtu(mud, mtu);

3
mud.h
View File

@@ -4,7 +4,7 @@
struct mud;
struct mud *mud_create (int, int, int, int, int);
struct mud *mud_create (int, int, int, int);
void mud_delete (struct mud *);
int mud_get_fd (struct mud *);
@@ -19,6 +19,7 @@ int mud_get_mtu (struct mud *);
int mud_set_send_timeout_msec (struct mud *, unsigned);
int mud_set_time_tolerance_sec (struct mud *, unsigned);
int mud_set_tc (struct mud *, int);
int mud_set_aes (struct mud *);
int mud_peer (struct mud *, const char *, const char *, int, int);