From 9d2ac5f7470dfa1edc84f7b8846aa4cf0db3346c Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Sun, 11 Dec 2016 20:28:03 +0100 Subject: [PATCH] Correct an assertion and prefer compile-time assertions --- src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c b/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c index 1af0a991..57ed7ea3 100644 --- a/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c +++ b/src/libsodium/crypto_stream/xchacha20/stream_xchacha20.c @@ -1,6 +1,5 @@ #include -#include #include "crypto_core_hchacha20.h" #include "crypto_stream_chacha20.h" @@ -23,9 +22,10 @@ crypto_stream_xchacha20(unsigned char *c, unsigned long long clen, unsigned char k2[crypto_core_hchacha20_OUTPUTBYTES]; crypto_core_hchacha20(k2, n, k, NULL); - assert(crypto_stream_chacha20_KEYBYTES <= sizeof k2); - assert(crypto_stream_chacha20_NONCEBYTES == - (sizeof n) - crypto_core_hchacha20_INPUTBYTES); + (void) sizeof(int[crypto_stream_chacha20_KEYBYTES <= sizeof k2 ? 1 : -1]); + (void) sizeof(int[crypto_stream_chacha20_NONCEBYTES == + crypto_stream_xchacha20_NONCEBYTES - + crypto_core_hchacha20_INPUTBYTES ? 1 : -1]); return crypto_stream_chacha20(c, clen, n + crypto_core_hchacha20_INPUTBYTES, k2); }