17
mud.c
17
mud.c
@@ -577,6 +577,15 @@ mud_set_key(struct mud *mud, unsigned char *key, size_t size)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
mud_new_key(struct mud *mud)
|
||||||
|
{
|
||||||
|
unsigned char key[MUD_KEY_SIZE];
|
||||||
|
|
||||||
|
randombytes_buf(key, sizeof(key));
|
||||||
|
return mud_set_key(mud, key, sizeof(key));
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
mud_set_tc(struct mud *mud, int tc)
|
mud_set_tc(struct mud *mud, int tc)
|
||||||
{
|
{
|
||||||
@@ -790,17 +799,9 @@ mud_create(int port, int v4, int v6, int aes, int mtu)
|
|||||||
mud->send_timeout = MUD_SEND_TIMEOUT;
|
mud->send_timeout = MUD_SEND_TIMEOUT;
|
||||||
mud->time_tolerance = MUD_TIME_TOLERANCE;
|
mud->time_tolerance = MUD_TIME_TOLERANCE;
|
||||||
mud->tc = MUD_PACKET_TC;
|
mud->tc = MUD_PACKET_TC;
|
||||||
|
|
||||||
unsigned char key[MUD_KEY_SIZE];
|
|
||||||
|
|
||||||
randombytes_buf(key, sizeof(key));
|
|
||||||
mud_set_key(mud, key, sizeof(key));
|
|
||||||
|
|
||||||
mud->crypto.aes = aes && crypto_aead_aes256gcm_is_available();
|
mud->crypto.aes = aes && crypto_aead_aes256gcm_is_available();
|
||||||
mud_keyx_init(mud, now);
|
|
||||||
|
|
||||||
randombytes_buf(mud->kiss, sizeof(mud->kiss));
|
randombytes_buf(mud->kiss, sizeof(mud->kiss));
|
||||||
|
|
||||||
mud_set_mtu(mud, mtu);
|
mud_set_mtu(mud, mtu);
|
||||||
|
|
||||||
return mud;
|
return mud;
|
||||||
|
|||||||
1
mud.h
1
mud.h
@@ -9,6 +9,7 @@ void mud_delete (struct mud *);
|
|||||||
|
|
||||||
int mud_get_fd (struct mud *);
|
int mud_get_fd (struct mud *);
|
||||||
|
|
||||||
|
int mud_new_key (struct mud *);
|
||||||
int mud_set_key (struct mud *, unsigned char *, size_t);
|
int mud_set_key (struct mud *, unsigned char *, size_t);
|
||||||
int mud_get_key (struct mud *, unsigned char *, size_t *);
|
int mud_get_key (struct mud *, unsigned char *, size_t *);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user