From 40be483e2bd5c79d8c80da862f28913b322893d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20Gallou=C3=ABt?= Date: Fri, 16 Mar 2018 08:12:33 +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 | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/mud.c b/mud.c index d611f63..9b58001 100644 --- a/mud.c +++ b/mud.c @@ -886,14 +886,11 @@ mud_delete(struct mud *mud) } static int -mud_encrypt(struct mud *mud, uint64_t nonce, +mud_encrypt(struct mud *mud, uint64_t now, unsigned char *dst, size_t dst_size, const unsigned char *src, size_t src_size) { - if (!nonce) - return 0; - - size_t size = src_size + MUD_PACKET_MIN_SIZE; + const size_t size = src_size + MUD_PACKET_MIN_SIZE; if (size > dst_size) return 0; @@ -910,7 +907,7 @@ mud_encrypt(struct mud *mud, uint64_t nonce, }, }; - mud_write48(opt.npub, nonce); + mud_write48(opt.npub, now); memcpy(&opt.npub[MUD_U48_SIZE], mud->local.kiss, sizeof(mud->local.kiss)); memcpy(dst, opt.npub, MUD_U48_SIZE); @@ -928,7 +925,7 @@ mud_decrypt(struct mud *mud, unsigned char *dst, size_t dst_size, const unsigned char *src, size_t src_size) { - size_t size = src_size - MUD_PACKET_MIN_SIZE; + const size_t size = src_size - MUD_PACKET_MIN_SIZE; if (size > dst_size) return 0;