From 0c037c5831ab88d41614fa30dca7647b3c30cf3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Thu, 15 Mar 2018 20:42:51 +0000 Subject: [PATCH] Code cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Adrien Gallouët --- mud.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/mud.c b/mud.c index 4425df4..76f6a9e 100644 --- a/mud.c +++ b/mud.c @@ -766,15 +766,16 @@ mud_keyx(struct mud *mud, unsigned char *public, int aes) mud->crypto.next.aes = mud->crypto.aes && aes; - if (mud->crypto.next.aes) { - crypto_aead_aes256gcm_beforenm((crypto_aead_aes256gcm_state *) - mud->crypto.next.encrypt.state, - mud->crypto.next.encrypt.key); + if (!mud->crypto.next.aes) + return; - crypto_aead_aes256gcm_beforenm((crypto_aead_aes256gcm_state *) - mud->crypto.next.decrypt.state, - mud->crypto.next.decrypt.key); - } + crypto_aead_aes256gcm_beforenm((crypto_aead_aes256gcm_state *) + mud->crypto.next.encrypt.state, + mud->crypto.next.encrypt.key); + + crypto_aead_aes256gcm_beforenm((crypto_aead_aes256gcm_state *) + mud->crypto.next.decrypt.state, + mud->crypto.next.decrypt.key); } static void @@ -1003,12 +1004,10 @@ static void mud_packet_send(struct mud *mud, enum mud_packet_code code, struct mud_path *path, uint64_t now, int flags) { - unsigned char data[MUD_PACKET_MAX_SIZE]; + unsigned char data[MUD_PACKET_MAX_SIZE] = {0}; struct mud_packet *packet = (struct mud_packet *)data; size_t size = 0; - memset(data, 0, sizeof(data)); - mud_write48(packet->hdr.time, now); memcpy(packet->hdr.kiss, mud->local.kiss, sizeof(mud->local.kiss)); @@ -1054,7 +1053,7 @@ mud_packet_send(struct mud *mud, enum mud_packet_code code, struct mud_crypto_opt opt = { .dst = data + sizeof(packet->hdr) + size, .ad = { - .data = packet->hdr.zero, + .data = data, .size = sizeof(packet->hdr) + size, }, };