From 04a7ab95f2f0e4f6fb48aa1d2953cfbdf5a8a36a Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Mon, 10 Sep 2018 19:57:06 +0200 Subject: [PATCH] Don't mix lengths and block sizes --- src/libsodium/crypto_stream/chacha20/stream_chacha20.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c index 0a5a7fa5..be1577f3 100644 --- a/src/libsodium/crypto_stream/chacha20/stream_chacha20.c +++ b/src/libsodium/crypto_stream/chacha20/stream_chacha20.c @@ -120,8 +120,7 @@ int crypto_stream_chacha20_ietf(unsigned char *c, unsigned long long clen, const unsigned char *n, const unsigned char *k) { - if (clen > - crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX / 64ULL - (clen + 63ULL) / 64ULL) { + if (clen > crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX) { sodium_misuse(); } return crypto_stream_chacha20_ietf_ext(c, clen, n, k); @@ -145,8 +144,7 @@ crypto_stream_chacha20_ietf_xor(unsigned char *c, const unsigned char *m, unsigned long long mlen, const unsigned char *n, const unsigned char *k) { - if (mlen > - crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX / 64ULL - (mlen + 63ULL) / 64ULL) { + if (mlen > crypto_stream_chacha20_ietf_MESSAGEBYTES_MAX) { sodium_misuse(); } return crypto_stream_chacha20_ietf_ext_xor(c, m, mlen, n, k);