1
mirror of https://github.com/jedisct1/libsodium.git synced 2024-12-19 18:15:18 -07:00

Correct an assertion and prefer compile-time assertions

This commit is contained in:
Frank Denis 2016-12-11 20:28:03 +01:00
parent 9979762bbe
commit 9d2ac5f747

View File

@ -1,6 +1,5 @@
#include <stdlib.h>
#include <assert.h>
#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);
}